wdtr10.setAmountOfHours(new BigDecimal("2.75").setScale(2, BigDecimal.ROUND_HALF_UP));
new_objs.add(wdtr10);
del_objs.push(wdtr10);
// save new objects
DataAccessService data_srv = (DataAccessService) applicationContext.getBean("bizService");
data_srv.persistChanges(new_objs, null, null);
Collection<WorkDayTimeRecord> records = new ArrayList<WorkDayTimeRecord>();
records.add(wdtr1);
records.add(wdtr2);
records.add(wdtr3);
records.add(wdtr4);
records.add(wdtr5);
records.add(wdtr6);
records.add(wdtr7);
records.add(wdtr8);
records.add(wdtr9);
records.add(wdtr10);
try {
WorkedTimeSummaryCalcService srv = (WorkedTimeSummaryCalcService) applicationContext.getBean(WorkedTimeSummaryCalcService.BEAN_ID);
WorkedTimeSummaryInfo res = srv.calcSummaryValues(records);
assertNotNull("Result is null.", res);
assertNotNull("Number of hours is null.", res.getNumberOfHours());
assertNotNull("Number of days is null.", res.getNumberOfDays());
assertNotNull("Incomes is null.", res.getIncomes());
assertNotNull("VAT is null.", res.getVatTax());
assertEquals(
"Wrong number of hours: ",
new BigDecimal("18.75").setScale(2, BigDecimal.ROUND_HALF_UP),
res.getNumberOfHours());
assertEquals(
"Wrong number of hours: ",
new BigDecimal("2.34").setScale(2, BigDecimal.ROUND_HALF_UP),
res.getNumberOfDays());
assertEquals(
"Wrong incomes: ",
new BigDecimal("2306.25").setScale(2, BigDecimal.ROUND_HALF_UP),
res.getIncomes());
assertEquals(
"Wrong VAT: ",
new BigDecimal("369.00").setScale(2, BigDecimal.ROUND_HALF_UP),
res.getVatTax());
} finally {
ArrayList<AbstractDomainObject> objs = new ArrayList<AbstractDomainObject>();
while (!del_objs.isEmpty()) {
objs.add(del_objs.pop());
}
data_srv.persistChanges(null, null, objs);
}
}