ItEr27S07CUVistaRecursosTempoPorProxectoItEr26S08: Adding method to check if a ResourcesPerDay has a zero amount
This commit is contained in:
parent
49ba6a45d4
commit
740192980d
2 changed files with 25 additions and 0 deletions
|
|
@ -48,4 +48,9 @@ public class ResourcesPerDay {
|
|||
return false;
|
||||
}
|
||||
|
||||
public boolean isZero() {
|
||||
BigDecimal withoutDecimalpart = amount.movePointRight(2);
|
||||
return withoutDecimalpart.intValue() == 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,9 @@ package org.navalplanner.business.test.planner.entities;
|
|||
|
||||
import static org.hamcrest.CoreMatchers.equalTo;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
|
|
@ -95,4 +97,22 @@ public class ResourcesPerDayTest {
|
|||
assertEquals(a, b);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isZeroIfHaveZeroValue() {
|
||||
BigDecimal[] examples = { new BigDecimal(0.0001), new BigDecimal(0),
|
||||
new BigDecimal(00), new BigDecimal(0.00) };
|
||||
for (BigDecimal example : examples) {
|
||||
assertTrue(ResourcesPerDay.amount(example).isZero());
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void notZeroIfNoZeroValue() {
|
||||
BigDecimal[] examples = { new BigDecimal(0.01), new BigDecimal(0.009),
|
||||
new BigDecimal(1), new BigDecimal(0.10) };
|
||||
for (BigDecimal example : examples) {
|
||||
assertFalse(ResourcesPerDay.amount(example).isZero());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue