Search in sources :

Example 1 with KeyTable

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");
}
Also used : KeyTable(org.estatio.module.budget.dom.keytable.KeyTable) Unit(org.estatio.module.asset.dom.Unit) BigDecimal(java.math.BigDecimal) Test(org.junit.Test)

Example 2 with KeyTable

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));
}
Also used : KeyTable(org.estatio.module.budget.dom.keytable.KeyTable) KeyItem(org.estatio.module.budget.dom.keyitem.KeyItem) BigDecimal(java.math.BigDecimal) AbstractBeanPropertiesTest(org.incode.module.unittestsupport.dom.bean.AbstractBeanPropertiesTest) Test(org.junit.Test)

Example 3 with KeyTable

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));
}
Also used : KeyTable(org.estatio.module.budget.dom.keytable.KeyTable) KeyItem(org.estatio.module.budget.dom.keyitem.KeyItem) BigDecimal(java.math.BigDecimal) AbstractBeanPropertiesTest(org.incode.module.unittestsupport.dom.bean.AbstractBeanPropertiesTest) Test(org.junit.Test)

Example 4 with KeyTable

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");
}
Also used : KeyTable(org.estatio.module.budget.dom.keytable.KeyTable) KeyItem(org.estatio.module.budget.dom.keyitem.KeyItem) BigDecimal(java.math.BigDecimal) AbstractBeanPropertiesTest(org.incode.module.unittestsupport.dom.bean.AbstractBeanPropertiesTest) Test(org.junit.Test)

Example 5 with KeyTable

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);
}
Also used : KeyTable(org.estatio.module.budget.dom.keytable.KeyTable) KeyItem(org.estatio.module.budget.dom.keyitem.KeyItem) BigDecimal(java.math.BigDecimal) AbstractBeanPropertiesTest(org.incode.module.unittestsupport.dom.bean.AbstractBeanPropertiesTest) Test(org.junit.Test)

Aggregations

KeyTable (org.estatio.module.budget.dom.keytable.KeyTable)14 BigDecimal (java.math.BigDecimal)9 Test (org.junit.Test)9 KeyItem (org.estatio.module.budget.dom.keyitem.KeyItem)7 AbstractBeanPropertiesTest (org.incode.module.unittestsupport.dom.bean.AbstractBeanPropertiesTest)6 Unit (org.estatio.module.asset.dom.Unit)3 Programmatic (org.apache.isis.applib.annotation.Programmatic)2 Charge (org.estatio.module.charge.dom.Charge)2 ArrayList (java.util.ArrayList)1 List (java.util.List)1 ApplicationException (org.apache.isis.applib.ApplicationException)1 Property (org.estatio.module.asset.dom.Property)1 Budget (org.estatio.module.budget.dom.budget.Budget)1 BudgetItem (org.estatio.module.budget.dom.budgetitem.BudgetItem)1 FoundationValueType (org.estatio.module.budget.dom.keytable.FoundationValueType)1 KeyValueMethod (org.estatio.module.budget.dom.keytable.KeyValueMethod)1 PartitionItem (org.estatio.module.budget.dom.partioning.PartitionItem)1 Partitioning (org.estatio.module.budget.dom.partioning.Partitioning)1 KeyItemImportExportLineItem (org.estatio.module.budgetassignment.imports.KeyItemImportExportLineItem)1