Search in sources :

Example 11 with ExportInformation

use of org.dataportabilityproject.dataModels.ExportInformation in project data-transfer-project by google.

the class GoogleContactsServiceTest method exportFirstPage.

@Test
public void exportFirstPage() throws IOException {
    setUpSinglePersonResponse();
    // Looking at first page, with at least one page after it
    ExportInformation emptyExportInformation = new ExportInformation(Optional.empty(), Optional.empty());
    listConnectionsResponse.setNextPageToken(NEXT_PAGE_TOKEN);
    // Run test
    ContactsModelWrapper wrapper = contactsService.export(emptyExportInformation);
    // Check that correct methods were called
    verify(connections).list(SELF_RESOURCE);
    InOrder inOrder = Mockito.inOrder(getBatchGet);
    inOrder.verify(getBatchGet).setResourceNames(Collections.singletonList(RESOURCE_NAME));
    inOrder.verify(getBatchGet).setPersonFields(PERSON_FIELDS);
    inOrder.verify(getBatchGet).execute();
    // Check continuation information
    assertThat(wrapper.getContinuationInformation().getSubResources()).isEmpty();
    StringPaginationToken paginationToken = (StringPaginationToken) wrapper.getContinuationInformation().getPaginationInformation();
    assertThat(paginationToken.getId()).isEqualTo(NEXT_PAGE_TOKEN);
    // Check that the right number of VCards was returned
    Collection<VCard> vCardCollection = wrapper.getVCards();
    assertThat(vCardCollection.size()).isEqualTo(connectionsList.size());
}
Also used : ExportInformation(org.dataportabilityproject.dataModels.ExportInformation) InOrder(org.mockito.InOrder) ContactsModelWrapper(org.dataportabilityproject.dataModels.contacts.ContactsModelWrapper) VCard(ezvcard.VCard) StringPaginationToken(org.dataportabilityproject.shared.StringPaginationToken) Test(org.junit.Test)

Aggregations

ExportInformation (org.dataportabilityproject.dataModels.ExportInformation)11 Test (org.junit.Test)8 StringPaginationToken (org.dataportabilityproject.shared.StringPaginationToken)7 IdOnlyResource (org.dataportabilityproject.shared.IdOnlyResource)5 InOrder (org.mockito.InOrder)5 Resource (org.dataportabilityproject.dataModels.Resource)4 CalendarModelWrapper (org.dataportabilityproject.dataModels.calendar.CalendarModelWrapper)4 ContinuationInformation (org.dataportabilityproject.dataModels.ContinuationInformation)3 ContactsModelWrapper (org.dataportabilityproject.dataModels.contacts.ContactsModelWrapper)3 VCard (ezvcard.VCard)2 IOException (java.io.IOException)2 Collection (java.util.Collection)2 Collectors (java.util.stream.Collectors)2 JobDataCache (org.dataportabilityproject.cloud.interfaces.JobDataCache)2 PaginationInformation (org.dataportabilityproject.dataModels.PaginationInformation)2 CalendarEventModel (org.dataportabilityproject.dataModels.calendar.CalendarEventModel)2 PhotosModelWrapper (org.dataportabilityproject.dataModels.photos.PhotosModelWrapper)2 GoogleStaticObjects (org.dataportabilityproject.serviceProviders.google.GoogleStaticObjects)2 Matchers.anyString (org.mockito.Matchers.anyString)2 Photo (com.flickr4java.flickr.photos.Photo)1