}
public void testQueryCalendar() throws Exception {
Calendar calendar = this.calendarAggregate();
CalendarSharer sharerZoe = new CalendarSharer(
new Participant("zoe", "Zoe Doe", "zoe@saasovation.com"));
calendar.shareCalendarWith(sharerZoe);
CalendarSharer sharerJoe = new CalendarSharer(
new Participant("joe", "Joe Smith", "joe@saasovation.com"));
calendar.shareCalendarWith(sharerJoe);
DomainRegistry.calendarRepository().save(calendar);
CalendarData calendarData =
calendarQueryService.calendarDataOfId(
calendar.tenant().id(),
calendar.calendarId().id());
assertNotNull(calendarData);
assertEquals(calendar.calendarId().id(), calendarData.getCalendarId());
assertEquals(calendar.description(), calendarData.getDescription());
assertEquals(calendar.name(), calendarData.getName());
assertEquals(calendar.owner().emailAddress(), calendarData.getOwnerEmailAddress());
assertEquals(calendar.owner().identity(), calendarData.getOwnerIdentity());
assertEquals(calendar.owner().name(), calendarData.getOwnerName());
assertEquals(calendar.tenant().id(), calendarData.getTenantId());
assertNotNull(calendarData.getSharers());
assertFalse(calendarData.getSharers().isEmpty());
assertEquals(2, calendarData.getSharers().size());
for (CalendarSharerData sharer : calendarData.getSharers()) {
if (sharer.getParticipantIdentity().equals("zoe")) {
assertEquals(calendar.calendarId().id(), sharer.getCalendarId());
assertEquals(sharerZoe.participant().emailAddress(), sharer.getParticipantEmailAddress());
assertEquals(sharerZoe.participant().identity(), sharer.getParticipantIdentity());
assertEquals(sharerZoe.participant().name(), sharer.getParticipantName());
} else {
assertEquals(calendar.calendarId().id(), sharer.getCalendarId());
assertEquals(sharerJoe.participant().emailAddress(), sharer.getParticipantEmailAddress());
assertEquals(sharerJoe.participant().identity(), sharer.getParticipantIdentity());
assertEquals(sharerJoe.participant().name(), sharer.getParticipantName());
}
}
}