Ejemplo n.º 1
0
  @Test
  public void ensureIsNotAllDayForNoonPeriod() {

    DateMidnight today = DateMidnight.now();

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

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

    Assert.assertFalse("Should be not all day", absence.isAllDay());
  }
Ejemplo n.º 2
0
  @Test
  public void ensureIsAllDayForFullDayPeriod() {

    DateMidnight start = DateMidnight.now();
    DateMidnight end = start.plusDays(2);

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

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

    Assert.assertTrue("Should be all day", absence.isAllDay());
  }
Ejemplo n.º 3
0
  @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());
  }
Ejemplo n.º 4
0
  @Test
  public void ensureCorrectEventSubject() {

    DateMidnight today = DateMidnight.now();
    Period period = new Period(today, today, DayLength.FULL);

    BiConsumer<EventType, String> assertCorrectEventSubject =
        (type, subject) -> {
          Absence absence = new Absence(person, period, type, timeConfiguration);

          assertThat(absence.getEventType(), is(type));
          assertThat(absence.getEventSubject(), is(subject));
        };

    assertCorrectEventSubject.accept(
        EventType.WAITING_APPLICATION, "Antrag auf Urlaub Marlene Muster");
    assertCorrectEventSubject.accept(EventType.ALLOWED_APPLICATION, "Urlaub Marlene Muster");
    assertCorrectEventSubject.accept(EventType.SICKNOTE, "Marlene Muster krank");
  }
Ejemplo n.º 5
0
  @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());
  }
Ejemplo n.º 6
0
  @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());
  }