use of org.dataportabilityproject.dataModels.Resource in project data-transfer-project by google.
the class GoogleCalendarServiceTest method testExportEventSubsequentSet.
@Test
public void testExportEventSubsequentSet() throws IOException {
setUpSingleEventResponse();
;
// Looking at subsequent page, with no pages after it
Resource resource = new IdOnlyResource(CALENDAR_ID);
PaginationInformation paginationInformation = new StringPaginationToken(NEXT_TOKEN);
ExportInformation resourceExportInformation = new ExportInformation(Optional.of(resource), Optional.of(paginationInformation));
eventListResponse.setNextPageToken(null);
// Run test
CalendarModelWrapper wrapper = calendarService.export(resourceExportInformation);
// Check results
// Verify correct methods were called in order
InOrder inOrder = Mockito.inOrder(eventListRequest);
inOrder.verify(eventListRequest).setPageToken(NEXT_TOKEN);
inOrder.verify(eventListRequest).execute();
// Check pagination token
StringPaginationToken paginationToken = (StringPaginationToken) wrapper.getContinuationInformation().getPaginationInformation();
assertThat(paginationToken).isNull();
}
use of org.dataportabilityproject.dataModels.Resource in project data-transfer-project by google.
the class GoogleCalendarServiceTest method testExportEventFirstSet.
@Test
public void testExportEventFirstSet() throws IOException {
setUpSingleEventResponse();
// Looking at first page, with at least one page after it
Resource resource = new IdOnlyResource(CALENDAR_ID);
ExportInformation resourceExportInformation = new ExportInformation(Optional.of(resource), Optional.empty());
eventListResponse.setNextPageToken(NEXT_TOKEN);
// Run test
CalendarModelWrapper wrapper = calendarService.export(resourceExportInformation);
// Check results
// Verify correct methods were called
verify(calendarEvents).list(CALENDAR_ID);
verify(eventListRequest).setMaxAttendees(GoogleStaticObjects.MAX_ATTENDEES);
verify(eventListRequest).execute();
// Check events
Collection<CalendarEventModel> events = wrapper.getEvents();
assertThat(events.stream().map(CalendarEventModel::getCalendarId).collect(Collectors.toList())).containsExactly(CALENDAR_ID);
assertThat(events.stream().map(CalendarEventModel::getTitle).collect(Collectors.toList())).containsExactly(EVENT_DESCRIPTION);
// Check pagination token
StringPaginationToken paginationToken = (StringPaginationToken) wrapper.getContinuationInformation().getPaginationInformation();
assertThat(paginationToken.getId()).isEqualTo(NEXT_TOKEN);
}
Aggregations