ItEr24S07CUEdicionCalendarioLaboralItEr23S08: Added some tests for BaseCalendar entity.

This commit is contained in:
Manuel Rego Casasnovas 2009-09-02 08:49:53 +02:00 committed by Óscar González Fernández
parent 4638221cc6
commit 13d705e1fb

View file

@ -573,6 +573,26 @@ public class BaseCalendarTest {
}
}
@Test
public void testSetExpiringDate() {
BaseCalendar calendar = createBasicCalendar();
LocalDate currentDate = new LocalDate();
calendar.newVersion(currentDate.plusWeeks(4));
assertThat(calendar.getExpiringDate(currentDate), equalTo(currentDate
.plusWeeks(4)));
assertThat(calendar.getExpiringDate(currentDate.plusWeeks(4)),
nullValue());
calendar.setExpiringDate(currentDate.plusWeeks(2), currentDate);
assertThat(calendar.getExpiringDate(currentDate), equalTo(currentDate
.plusWeeks(2)));
assertThat(calendar.getExpiringDate(currentDate.plusWeeks(4)),
nullValue());
}
@Test(expected = IllegalArgumentException.class)
public void testNotAllowNewVersionOnCurrentDate() {
BaseCalendar calendar = createBasicCalendar();
@ -588,4 +608,44 @@ public class BaseCalendarTest {
calendar.setExpiringDate(WEDNESDAY_LOCAL_DATE);
}
@Test
public void testSetValidFrom() {
BaseCalendar calendar = createBasicCalendar();
LocalDate currentDate = new LocalDate();
calendar.newVersion(currentDate.plusWeeks(4));
assertThat(calendar.getValidFrom(currentDate), nullValue());
assertThat(calendar.getValidFrom(currentDate.plusWeeks(4)),
equalTo(currentDate.plusWeeks(4)));
calendar.setValidFrom(currentDate.plusWeeks(2), currentDate
.plusWeeks(4));
assertThat(calendar.getValidFrom(currentDate), nullValue());
assertThat(calendar.getValidFrom(currentDate.plusWeeks(4)),
equalTo(currentDate.plusWeeks(2)));
}
@Test(expected = IllegalArgumentException.class)
public void testNotAllowSetValidFromInThePast() {
BaseCalendar calendar = createBasicCalendar();
LocalDate currentDate = new LocalDate();
calendar.newVersion(currentDate.plusDays(1));
LocalDate pastWeek = currentDate.minusWeeks(1);
calendar.setValidFrom(pastWeek, currentDate.plusDays(1));
}
@Test(expected = IllegalArgumentException.class)
public void testNotAllowSetValidFromIfNotPreviousCalendar() {
BaseCalendar calendar = createBasicCalendar();
assertThat(calendar.getCalendarDataVersions().size(), equalTo(1));
LocalDate currentDate = new LocalDate();
calendar.setValidFrom(currentDate, currentDate);
}
}