ItEr23S03ContornaItEr22S03: Checking that the category throws IllegalArgumentException when receiving a not valid percentage
This commit is contained in:
parent
9133b77940
commit
66528ab3e3
2 changed files with 7 additions and 2 deletions
|
|
@ -15,7 +15,7 @@ public class LoadLevel {
|
|||
SOME_LOAD {
|
||||
@Override
|
||||
public boolean contains(int percentage) {
|
||||
return percentage < 100;
|
||||
return percentage > 0 && percentage < 100;
|
||||
}
|
||||
},
|
||||
FULL_LOAD {
|
||||
|
|
@ -37,7 +37,7 @@ public class LoadLevel {
|
|||
if (category.contains(percentage))
|
||||
return category;
|
||||
}
|
||||
throw new RuntimeException("couldn't handle " + percentage);
|
||||
throw new IllegalArgumentException("couldn't handle " + percentage);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -60,4 +60,9 @@ public class LoadLevelTest {
|
|||
thenTheCategoryIs(Category.OVERLOAD);
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void theCategoryThrowsExceptionIfCantHandleThePercentage() {
|
||||
Category.categoryFor(-1);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue