@Test(expected = IllegalArgumentException.class) public void testGetTotalNumberOfSickDaysInvalidDateRange() throws Exception { Mockito.when(sickNoteDAO.findAllActiveByYear(2015)).thenReturn(sickNotes); statistics = new SickNoteStatistics(2015, sickNoteDAO, calendarService); statistics.getTotalNumberOfSickDays(); }
@Test public void testGetAverageDurationOfDiseasePerPersonDivisionByZero() throws Exception { Mockito.when(sickNoteDAO.findNumberOfPersonsWithMinimumOneSickNote(2013)).thenReturn(0L); statistics = new SickNoteStatistics(2013, sickNoteDAO, calendarService); Assert.assertEquals(BigDecimal.ZERO, statistics.getAverageDurationOfDiseasePerPerson()); }
@Test public void testGetAverageDurationOfDiseasePerPerson() throws Exception { // 2 sick notes: 1st with 5 workdays and 2nd with 9 workdays --> sum = 14 workdays // 14 workdays / 7 persons = 2 workdays per person statistics = new SickNoteStatistics(2013, sickNoteDAO, calendarService); Assert.assertEquals( new BigDecimal("2").setScale(2, RoundingMode.HALF_UP), statistics.getAverageDurationOfDiseasePerPerson().setScale(2, RoundingMode.HALF_UP)); }
@Test public void testGetTotalNumberOfSickDays() throws Exception { Assert.assertEquals(new BigDecimal("14"), statistics.getTotalNumberOfSickDays()); }
@Test public void testGetTotalNumberOfSickNotes() throws Exception { Assert.assertEquals(2, statistics.getTotalNumberOfSickNotes()); }