@Test public void shouldGetEventPartiallyMatchingDay() { Date startDate = firstUser.parseStringToDate("23.09.11 17:00"); Date endDate = firstUser.parseStringToDate("24.09.11 18:00"); Date startDate2 = firstUser.parseStringToDate("24.09.11 17:00"); Date endDate2 = firstUser.parseStringToDate("25.09.11 18:00"); Event event = new Event("event1", startDate, endDate, true); Event event2 = new Event("event2", startDate2, endDate2, true); firstCalendar.addEvent(event); firstCalendar.addEvent(event2); Date testDay = secondUser.parseStringToDate("24.09.11 13:30"); eventsVisibleToSecondUser = secondUser.getVisibleEventsOnSpecificDayFrom(firstUser, testDay); assertTrue(eventsVisibleToSecondUser.contains(event)); assertTrue(eventsVisibleToSecondUser.contains(event2)); }
@Test public void shouldGetEventsOverMultipleDays() { Date startDate = firstUser.parseStringToDate("22.09.11 17:00"); Date endDate = firstUser.parseStringToDate("26.09.11 18:00"); Event event = new Event("event", startDate, endDate, true); firstCalendar.addEvent(event); Date testDay = secondUser.parseStringToDate("24.09.11 13:30"); eventsVisibleToSecondUser = secondUser.getVisibleEventsOnSpecificDayFrom(firstUser, testDay); assertTrue(eventsVisibleToSecondUser.contains(event)); }
@Test public void shouldNotGetPrivateEvent() { Date startDate = firstUser.parseStringToDate("23.09.11 18:00"); Date endDate = firstUser.parseStringToDate("30.09.11 17:00"); Event event = new Event("event", startDate, endDate, false); firstCalendar.addEvent(event); Date testDay = secondUser.parseStringToDate("24.09.11 13:30"); eventsVisibleToSecondUser = secondUser.getVisibleEventsOnSpecificDayFrom(firstUser, testDay); assertFalse(eventsVisibleToSecondUser.contains(event)); }