@Test @Transactional public void testSaveWorkReportLine() { WorkReportLine workReportLine = createValidWorkReportLine(); workReportLineDAO.save(workReportLine); assertTrue(workReportLineDAO.exists(workReportLine.getId())); }
@Test @Transactional public void testRemoveWorkReportLine() throws InstanceNotFoundException { WorkReportLine workReportLine = createValidWorkReportLine(); workReportLineDAO.save(workReportLine); workReportLine.getWorkReport().removeWorkReportLine(workReportLine); workReportLineDAO.remove(workReportLine.getId()); assertFalse(workReportLineDAO.exists(workReportLine.getId())); }
private List<WorkReportLine> filterWorkReportLinesByDate( Collection<WorkReportLine> lines, AvailabilityTimeLine.Interval interval) { List<WorkReportLine> result = new ArrayList<WorkReportLine>(); for (WorkReportLine line : lines) { if (interval.includes(line.getLocalDate())) { result.add(line); } } return result; }
@Override public SortedMap<LocalDate, BigDecimal> calculateActualCostWorkPerformed(Interval interval) { SortedMap<LocalDate, BigDecimal> result = new TreeMap<LocalDate, BigDecimal>(); Collection<WorkReportLine> workReportLines = filterWorkReportLinesByDate(databaseSnapshots.snapshotWorkReportLines(), interval); if (workReportLines.isEmpty()) { return result; } for (WorkReportLine workReportLine : workReportLines) { LocalDate day = new LocalDate(workReportLine.getDate()); BigDecimal cost = workReportLine.getEffort().toHoursAsDecimalWithScale(2); if (!result.containsKey(day)) { result.put(day, BigDecimal.ZERO); } result.put(day, result.get(day).add(cost)); } return accumulateResult(result); }