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());
}
Aggregations