@Test public void testMaybeOverride_countertest() { Cook p1 = createPerson("a", newHashSet(THURSDAY), newHashSet()); Cook p2 = createPerson("b", newHashSet(FRIDAY), newHashSet()); Cook p3 = createPerson("c", newHashSet(MONDAY), newHashSet()); // FRIDAYs instead of THURSDAYS CookingDay c1 = new CookingDay(p1, LocalDate.of(2015, 7, 3)); CookingDay c2 = new CookingDay(p1, LocalDate.of(2015, 7, 10)); CookingDay c3 = new CookingDay(p1, LocalDate.of(2015, 7, 17)); // THURSDAYs instead of FRIDAYS CookingDay c4 = new CookingDay(p2, LocalDate.of(2015, 7, 2)); CookingDay c5 = new CookingDay(p2, LocalDate.of(2015, 7, 9)); CookingDay c6 = new CookingDay(p2, LocalDate.of(2015, 7, 16)); // THUESDAYs instead of Mondays CookingDay c7 = new CookingDay(p3, LocalDate.of(2015, 6, 30)); CookingDay c8 = new CookingDay(p3, LocalDate.of(2015, 7, 7)); CookingDay c9 = new CookingDay(p3, LocalDate.of(2015, 7, 14)); kl = new CookingListImpl( Arrays.asList(p1, p2, p3), Arrays.asList(c1, c2, c3, c4, c5, c6, c7, c8, c9)); // Monday CookingDay day = kl.determineCookFor(LocalDate.of(2015, 9, 10)); assertThat(day.getCook(), is(p1)); }
@Test public void testNeverCookedBefore() { Cook p1 = createPerson("a", newHashSet(MONDAY), newHashSet()); Cook p2 = createPerson("b", newHashSet(MONDAY), newHashSet()); CookingDay c1 = new CookingDay(p1, LocalDate.of(2015, 6, 30)); kl = new CookingListImpl(Arrays.asList(p1, p2), Arrays.asList(c1)); // Monday CookingDay day = kl.determineCookFor(LocalDate.of(2015, 9, 10)); assertThat(day.getCook(), is(p2)); }
@Test public void testDayPreferenceWin() { Cook p1 = createPerson("a", newHashSet(DayOfWeek.FRIDAY), newHashSet(DayOfWeek.MONDAY)); Cook p2 = createPerson("b", newHashSet(DayOfWeek.THURSDAY), newHashSet(DayOfWeek.MONDAY)); Cook p3 = createPerson("c", newHashSet(DayOfWeek.WEDNESDAY), newHashSet(DayOfWeek.MONDAY)); CookingDay c1 = new CookingDay(p1, LocalDate.of(2015, 8, 12)); CookingDay c2 = new CookingDay(p2, LocalDate.of(2015, 8, 11)); CookingDay c3 = new CookingDay(p3, LocalDate.of(2015, 8, 13)); kl = new CookingListImpl(Arrays.asList(p1, p2, p3), Arrays.asList(c1, c2, c3)); // Friday CookingDay day = kl.determineCookFor(LocalDate.of(2015, 8, 28)); assertThat(day.getCook(), Is.is(p1)); }
@Test public void testExisDay_blocks() { LocalDate testDay = LocalDate.of(2015, 9, 10); Cook p1 = createPerson("a", newHashSet(MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY), newHashSet()); Cook p2 = createPerson("b", newHashSet(MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY), newHashSet()); p2.setExit(testDay.minusDays(1)); CookingDay c1 = new CookingDay(p1, LocalDate.of(2015, 6, 30)); kl = new CookingListImpl(Arrays.asList(p1, p2), Arrays.asList(c1)); CookingDay day = kl.determineCookFor(testDay); assertThat(day.getCook(), is(p1)); }
@Test public void testCookingCountWin() { Cook p1 = createPerson("a", newHashSet(FRIDAY), newHashSet(MONDAY)); Cook p2 = createPerson("b", newHashSet(THURSDAY), newHashSet(MONDAY)); Cook p3 = createPerson("c", newHashSet(WEDNESDAY), newHashSet(MONDAY)); CookingDay c1 = new CookingDay(p1, LocalDate.of(2015, 8, 10)); CookingDay c2 = new CookingDay(p1, LocalDate.of(2015, 8, 11)); CookingDay c3 = new CookingDay(p2, LocalDate.of(2015, 8, 12)); CookingDay c4 = new CookingDay(p2, LocalDate.of(2015, 8, 13)); CookingDay c5 = new CookingDay(p3, LocalDate.of(2015, 8, 7)); kl = new CookingListImpl(Arrays.asList(p1, p2, p3), Arrays.asList(c1, c2, c3, c4, c5)); // Friday CookingDay day = kl.determineCookFor(LocalDate.of(2015, 8, 28)); assertThat(day.getCook(), Is.is(p3)); }
@Test public void testMinimumDaysbetweenDatesWins_Countertest() { Cook p1 = createPerson("a", newHashSet(FRIDAY), newHashSet(MONDAY)); Cook p2 = createPerson("b", newHashSet(THURSDAY), newHashSet(MONDAY)); Cook p3 = createPerson("c", newHashSet(WEDNESDAY), newHashSet(MONDAY)); CookingDay c1 = new CookingDay(p1, LocalDate.of(2015, 1, 12)); CookingDay c2 = new CookingDay(p1, LocalDate.of(2015, 1, 13)); CookingDay c3 = new CookingDay(p2, LocalDate.of(2015, 1, 14)); CookingDay c4 = new CookingDay(p2, LocalDate.of(2015, 1, 15)); CookingDay c5 = new CookingDay(p3, LocalDate.of(2015, 8, 13)); kl = new CookingListImpl(Arrays.asList(p1, p2, p3), Arrays.asList(c1, c2, c3, c4, c5)); // Wednesday CookingDay day = kl.determineCookFor(LocalDate.of(2015, 8, 27)); assertThat(day.getCook(), is(p3)); }