Add a new test case to check MoneyCostCalculator when there is not relationship via cost category
FEA: ItEr76S17MoneyCostMonitoringSystem
This commit is contained in:
parent
5da1e11b26
commit
0eb5f7bc46
1 changed files with 27 additions and 9 deletions
|
|
@ -111,18 +111,20 @@ public class MoneyCostCalculatorTest {
|
|||
costCategoryDAO.save(costCategory);
|
||||
}
|
||||
|
||||
private void givenResource() {
|
||||
private void givenResource(boolean relatedWithCostCategory) {
|
||||
resource = Worker.createUnvalidated("default-resource",
|
||||
"default-resource", "default-resource", "default-resource");
|
||||
|
||||
ResourcesCostCategoryAssignment resourcesCostCategoryAssignment = ResourcesCostCategoryAssignment
|
||||
.create();
|
||||
resourcesCostCategoryAssignment
|
||||
.setCode("resources-cost-category-assignment");
|
||||
resourcesCostCategoryAssignment.setCostCategory(costCategory);
|
||||
resourcesCostCategoryAssignment.setInitDate(new LocalDate());
|
||||
if (relatedWithCostCategory) {
|
||||
ResourcesCostCategoryAssignment resourcesCostCategoryAssignment = ResourcesCostCategoryAssignment
|
||||
.create();
|
||||
resourcesCostCategoryAssignment
|
||||
.setCode("resources-cost-category-assignment");
|
||||
resourcesCostCategoryAssignment.setCostCategory(costCategory);
|
||||
resourcesCostCategoryAssignment.setInitDate(new LocalDate());
|
||||
|
||||
resource.addResourcesCostCategoryAssignment(resourcesCostCategoryAssignment);
|
||||
resource.addResourcesCostCategoryAssignment(resourcesCostCategoryAssignment);
|
||||
}
|
||||
resourceDAO.save(resource);
|
||||
}
|
||||
|
||||
|
|
@ -160,7 +162,15 @@ public class MoneyCostCalculatorTest {
|
|||
private void givenBasicExample() {
|
||||
givenTypeOfWorkHours();
|
||||
givenCostCategory();
|
||||
givenResource();
|
||||
givenResource(true);
|
||||
givenOrderElement();
|
||||
giveWorkReportType();
|
||||
givenWorkReport();
|
||||
}
|
||||
|
||||
private void givenBasicExampleWithoutCostCategoryRelationship() {
|
||||
givenTypeOfWorkHours();
|
||||
givenResource(false);
|
||||
givenOrderElement();
|
||||
giveWorkReportType();
|
||||
givenWorkReport();
|
||||
|
|
@ -173,4 +183,12 @@ public class MoneyCostCalculatorTest {
|
|||
equalTo(new BigDecimal(500).setScale(2)));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void basicTestWithoutCostCategoryRelationship()
|
||||
throws InstanceNotFoundException {
|
||||
givenBasicExampleWithoutCostCategoryRelationship();
|
||||
assertThat(moneyCostCalculator.getMoneyCost(orderElement),
|
||||
equalTo(new BigDecimal(300).setScale(2)));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue