use of org.estatio.module.budget.dom.keytable.KeyTable in project estatio by estatio.
the class KeyItemRepository_Test method zeroSourceValue.
@Test
public void zeroSourceValue() {
// given
KeyTable keyTable = new KeyTable();
Unit unit = new Unit();
BigDecimal sourcevalue = BigDecimal.ZERO;
BigDecimal keyValue = new BigDecimal(10);
// when
String validateNewBudgetKeyItem = keyItemRepository.validateNewItem(keyTable, unit, sourcevalue, keyValue);
// then
assertThat(validateNewBudgetKeyItem).isEqualTo("sourceValue cannot be zero or less than zero");
}
use of org.estatio.module.budget.dom.keytable.KeyTable in project estatio by estatio.
the class KeyItem_Test method testChangeAuditedValue.
@Test
public void testChangeAuditedValue() {
// given
KeyTable table = new KeyTable();
table.setPrecision(3);
KeyItem item = new KeyItem();
item.setAuditedValue(new BigDecimal(2));
item.setKeyTable(table);
assertTrue(item.getAuditedValue().equals(new BigDecimal(2)));
// when
item.changeAuditedValue(BigDecimal.valueOf(2.3335));
// then
assertEquals(item.getAuditedValue(), BigDecimal.valueOf(2.334).setScale(3, BigDecimal.ROUND_HALF_UP));
}
use of org.estatio.module.budget.dom.keytable.KeyTable in project estatio by estatio.
the class KeyItem_Test method testChangeSourceValue.
@Test
public void testChangeSourceValue() {
// given
KeyTable table = new KeyTable();
table.setPrecision(3);
KeyItem item = new KeyItem();
item.setSourceValue(new BigDecimal(2));
item.setKeyTable(table);
assertTrue(item.getSourceValue().equals(new BigDecimal(2)));
// when
item.changeSourceValue(BigDecimal.valueOf(2.335));
// then
assertEquals(item.getSourceValue(), BigDecimal.valueOf(2.34).setScale(2, BigDecimal.ROUND_HALF_UP));
}
use of org.estatio.module.budget.dom.keytable.KeyTable in project estatio by estatio.
the class KeyItem_Test method testValidateChangeAuditedValue.
@Test
public void testValidateChangeAuditedValue() {
// given
KeyTable table = new KeyTable();
table.setPrecision(3);
KeyItem item = new KeyItem();
item.setAuditedValue(new BigDecimal(2));
item.setKeyTable(table);
assertTrue(item.getAuditedValue().equals(new BigDecimal(2)));
// when, then
assertEquals(item.validateChangeAuditedValue(BigDecimal.valueOf(-0.001)), "Value cannot be less than zero");
}
use of org.estatio.module.budget.dom.keytable.KeyTable in project estatio by estatio.
the class KeyItem_Test method testValidateChangeSourceValue.
@Test
public void testValidateChangeSourceValue() {
// given
KeyTable table = new KeyTable();
table.setPrecision(3);
KeyItem item = new KeyItem();
item.setSourceValue(new BigDecimal(2));
item.setKeyTable(table);
assertTrue(item.getSourceValue().equals(new BigDecimal(2)));
// when, then
assertEquals(item.validateChangeSourceValue(BigDecimal.valueOf(-0.001)), "Source Value must be positive");
assertEquals(item.validateChangeSourceValue(BigDecimal.ZERO), null);
}
Aggregations