@Test public void shouldUpdateEvent() { @SuppressWarnings("unchecked") Set<Student> newAttendees = new HashSet(); newAttendees.add(pat); newAttendees.add(jim); EventForm updateParameter = new EventUpdateParameterBuilder() .id(1) .title("Spice Girls") .date(new Date(12, 12, 2011)) .time("10:10") .description("Spice Girls 4 Lyf") .venue("P-81") .coordinator("Joel Tellez") .notes("Sick as party") .attendees(newAttendees) .build(); Event newEvent = new EventBuilder() .title("Spice Girls") .attendees(newAttendees) .date(new Date(12, 12, 2011)) .description("Spice Girls 4 Lyf") .venue("P-81") .coordinator("Joel Tellez") .notes("Sick as party") .build(); when(eventRepository.load(1)).thenReturn(sportsEvent); when(service.update(updateParameter)).thenReturn(newEvent); Event updatedEvent = service.update(updateParameter); assertEquals(newEvent, updatedEvent); }
@Test public void shouldListAllEvents() { when(eventRepository.list()).thenReturn(events); assertThat(service.list(), hasItems(sportsEvent, annualEvent)); }