Search in sources :

Example 6 with CalendarEventModel

use of org.dataportabilityproject.dataModels.calendar.CalendarEventModel 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);
}
Also used : CalendarModelWrapper(org.dataportabilityproject.dataModels.calendar.CalendarModelWrapper) ExportInformation(org.dataportabilityproject.dataModels.ExportInformation) Resource(org.dataportabilityproject.dataModels.Resource) IdOnlyResource(org.dataportabilityproject.shared.IdOnlyResource) IdOnlyResource(org.dataportabilityproject.shared.IdOnlyResource) CalendarEventModel(org.dataportabilityproject.dataModels.calendar.CalendarEventModel) StringPaginationToken(org.dataportabilityproject.shared.StringPaginationToken) Test(org.junit.Test)

Aggregations

CalendarEventModel (org.dataportabilityproject.dataModels.calendar.CalendarEventModel)6 Event (com.google.api.services.calendar.model.Event)4 CalendarModelWrapper (org.dataportabilityproject.dataModels.calendar.CalendarModelWrapper)4 CalendarModel (org.dataportabilityproject.dataModels.calendar.CalendarModel)3 StringPaginationToken (org.dataportabilityproject.shared.StringPaginationToken)3 Test (org.junit.Test)3 Events (com.google.api.services.calendar.model.Events)2 ExportInformation (org.dataportabilityproject.dataModels.ExportInformation)2 PaginationInformation (org.dataportabilityproject.dataModels.PaginationInformation)2 Resource (org.dataportabilityproject.dataModels.Resource)2 IdOnlyResource (org.dataportabilityproject.shared.IdOnlyResource)2 Calendar (com.google.api.services.calendar.Calendar)1 CalendarList (com.google.api.services.calendar.model.CalendarList)1 CalendarListEntry (com.google.api.services.calendar.model.CalendarListEntry)1 EventAttendee (com.google.api.services.calendar.model.EventAttendee)1 Truth.assertThat (com.google.common.truth.Truth.assertThat)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1 Collections (java.util.Collections)1