@Test
  public void ensureCanBeInstantiatedWithCorrectProperties() {

    DateMidnight start = new DateMidnight(2015, 9, 21);
    DateMidnight end = new DateMidnight(2015, 9, 23);

    Period period = new Period(start, end, DayLength.FULL);

    Absence absence = new Absence(person, period, EventType.WAITING_APPLICATION, timeConfiguration);

    Assert.assertNotNull("Start date must not be null", absence.getStartDate());
    Assert.assertNotNull("End date must not be null", absence.getEndDate());
    Assert.assertNotNull("Person must not be null", absence.getPerson());
    Assert.assertNotNull("Event type must not be null", absence.getEventType());

    Assert.assertEquals("Wrong start date", start.toDate(), absence.getStartDate());
    Assert.assertEquals("Wrong end date", end.plusDays(1).toDate(), absence.getEndDate());
    Assert.assertEquals("Wrong person", person, absence.getPerson());
    Assert.assertEquals("Wrong event type", EventType.WAITING_APPLICATION, absence.getEventType());
  }
  @Test
  public void ensureCanBeInstantiatedWithCorrectPropertiesConsideringDaylightSavingTime() {

    // Date where daylight saving time is relevant
    DateMidnight start = new DateMidnight(2015, 10, 23);
    DateMidnight end = new DateMidnight(2015, 10, 25);

    Period period = new Period(start, end, DayLength.FULL);

    Absence absence = new Absence(person, period, EventType.ALLOWED_APPLICATION, timeConfiguration);

    Assert.assertNotNull("Start date must not be null", absence.getStartDate());
    Assert.assertNotNull("End date must not be null", absence.getEndDate());
    Assert.assertNotNull("Person must not be null", absence.getPerson());
    Assert.assertNotNull("Event type must not be null", absence.getEventType());

    Assert.assertEquals("Wrong start date", start.toDate(), absence.getStartDate());
    Assert.assertEquals("Wrong end date", end.plusDays(1).toDate(), absence.getEndDate());
    Assert.assertEquals("Wrong person", person, absence.getPerson());
    Assert.assertEquals("Wrong event type", EventType.ALLOWED_APPLICATION, absence.getEventType());
  }
  @Test
  public void ensureCorrectTimeForMorningAbsence() {

    DateMidnight today = DateMidnight.now();

    Date start = today.toDateTime().withHourOfDay(8).toDate();
    Date end = today.toDateTime().withHourOfDay(12).toDate();

    Period period = new Period(today, today, DayLength.MORNING);

    Absence absence = new Absence(person, period, EventType.ALLOWED_APPLICATION, timeConfiguration);

    Assert.assertEquals("Should start at 8 am", start, absence.getStartDate());
    Assert.assertEquals("Should end at 12 pm", end, absence.getEndDate());
  }