fix exceptions tests

This commit is contained in:
Loredana Crusoveanu 2018-08-15 22:19:02 +03:00
parent 53d9f144d1
commit 854614166f
2 changed files with 13 additions and 9 deletions

View File

@ -25,7 +25,11 @@ public class Exceptions {
}
public List<Player> loadAllPlayers(String playersFile) throws IOException{
try {
throw new IOException();
} catch(IOException ex) {
throw new IllegalStateException();
}
}
public int getPlayerScoreThrows(String playerFile) throws FileNotFoundException {
@ -160,7 +164,13 @@ public class Exceptions {
}
public void throwAsGotoAntiPattern() throws MyException {
try {
// bunch of code
throw new MyException();
// second bunch of code
} catch ( MyException e ) {
// third bunch of code
}
}
public int getPlayerScoreSwallowingExceptionAntiPattern(String playerFile) {

View File

@ -21,7 +21,7 @@ public class ExceptionsUnitTest {
@Test
public void loadAllPlayers() {
assertThatThrownBy(() -> exceptions.loadAllPlayers(""))
.isInstanceOf(IOException.class);
.isInstanceOf(IllegalStateException.class);
}
@Test
@ -72,12 +72,6 @@ public class ExceptionsUnitTest {
.isInstanceOf(NullPointerException.class);
}
@Test
public void throwAsGotoAntiPattern() {
assertThatThrownBy(() -> exceptions.throwAsGotoAntiPattern())
.isInstanceOf(MyException.class);
}
@Test
public void getPlayerScoreSwallowingExceptionAntiPatternAlternative2() {
assertThatThrownBy(() -> exceptions.getPlayerScoreSwallowingExceptionAntiPatternAlternative2(""))