use of org.datatransferproject.types.common.ExportInformation in project data-transfer-project by google.
the class FacebookPhotosExporterTest method testSpecifiedAlbums.
@Test
public void testSpecifiedAlbums() throws CopyExceptionWithFailureReason {
ExportResult<PhotosContainerResource> result = facebookPhotosExporter.export(uuid, new TokensAndUrlAuthData("accessToken", null, null), Optional.of(new ExportInformation(new StringPaginationToken(PHOTO_TOKEN_PREFIX), new PhotosContainerResource(Lists.newArrayList(new PhotoAlbum(ALBUM_ID, ALBUM_NAME, ALBUM_DESCRIPTION)), new ArrayList<>()))));
assertEquals(ExportResult.ResultType.CONTINUE, result.getType());
PhotosContainerResource exportedData = result.getExportedData();
assertEquals(1, exportedData.getAlbums().size());
assertEquals(new PhotoAlbum(ALBUM_ID, ALBUM_NAME, ALBUM_DESCRIPTION), exportedData.getAlbums().toArray()[0]);
assertNull((result.getContinuationData().getPaginationData()));
assertThat(result.getContinuationData().getContainerResources()).contains(new IdOnlyContainerResource(ALBUM_ID));
}
use of org.datatransferproject.types.common.ExportInformation in project data-transfer-project by google.
the class GoogleMailExporterTest method exportMessagesSubsequentSet.
@Test
public void exportMessagesSubsequentSet() throws IOException {
setUpSingleMessageResponse();
// Looking at subsequent page, with no page after it
PaginationData paginationData = new StringPaginationToken(NEXT_TOKEN);
ExportInformation exportInformation = new ExportInformation(paginationData, null);
messageListResponse.setNextPageToken(null);
// Run test
ExportResult<MailContainerResource> result = googleMailExporter.export(JOB_ID, null, Optional.of(exportInformation));
// Check results
// Verify correct calls were made (i.e., token was set before execution)
InOrder inOrder = Mockito.inOrder(messageListRequest);
inOrder.verify(messageListRequest).setPageToken(NEXT_TOKEN);
inOrder.verify(messageListRequest).execute();
// Check pagination token (should be null)
ContinuationData continuationData = (ContinuationData) result.getContinuationData();
StringPaginationToken paginationToken = (StringPaginationToken) continuationData.getPaginationData();
assertThat(paginationToken).isNull();
}
use of org.datatransferproject.types.common.ExportInformation in project data-transfer-project by google.
the class ImgurPhotoExporterTest method testNonAlbumPhotoExport.
@Test
public void testNonAlbumPhotoExport() throws Exception {
// all photos are non-album
server.enqueue(new MockResponse().setBody(allImagesResponse));
ExportResult<PhotosContainerResource> nonAlbumPhotosResult = exporter.export(UUID.randomUUID(), token, Optional.of(new ExportInformation(null, new IdOnlyContainerResource(ImgurPhotosExporter.DEFAULT_ALBUM_ID))));
PhotosContainerResource resource = nonAlbumPhotosResult.getExportedData();
assertEquals(3, resource.getPhotos().size());
}
use of org.datatransferproject.types.common.ExportInformation in project data-transfer-project by google.
the class ImgurPhotoExporterTest method testAlbumAndNonAlbumPhotoExport.
@Test
public void testAlbumAndNonAlbumPhotoExport() throws Exception {
server.enqueue(new MockResponse().setBody(albumsResponse));
server.enqueue(new MockResponse().setBody(album1ImagesResponse));
server.enqueue(new MockResponse().setBody(allImagesResponse));
// export albums
exporter.export(UUID.randomUUID(), token, Optional.empty());
// export album photos
ExportResult<PhotosContainerResource> albumPhotosResult = exporter.export(UUID.randomUUID(), token, Optional.of(new ExportInformation(null, new IdOnlyContainerResource("albumId1"))));
assertEquals(2, albumPhotosResult.getExportedData().getPhotos().size());
// export non-album photos
ExportResult<PhotosContainerResource> nonAlbumPhotosResult = exporter.export(UUID.randomUUID(), token, Optional.of(new ExportInformation(null, new IdOnlyContainerResource(ImgurPhotosExporter.DEFAULT_ALBUM_ID))));
PhotosContainerResource resource = nonAlbumPhotosResult.getExportedData();
assertThat(resource.getPhotos()).containsExactly(NON_ALBUM_PHOTO);
}
use of org.datatransferproject.types.common.ExportInformation in project data-transfer-project by google.
the class ImgurPhotoExporterTest method testPagination.
@Test
public void testPagination() throws Exception {
server.enqueue(new MockResponse().setBody(page1Response));
server.enqueue(new MockResponse().setBody(page2Response));
int page = 0;
ExportResult<PhotosContainerResource> page1Result = exporter.export(UUID.randomUUID(), token, Optional.of(new ExportInformation(new IntPaginationToken(page), new IdOnlyContainerResource(ImgurPhotosExporter.DEFAULT_ALBUM_ID))));
page++;
PhotosContainerResource page1Resource = page1Result.getExportedData();
// 1th request returns 10 photos
assertEquals(10, page1Resource.getPhotos().size());
assertEquals(page, ((IntPaginationToken) page1Result.getContinuationData().getPaginationData()).getStart());
ExportResult<PhotosContainerResource> page2Result = exporter.export(UUID.randomUUID(), token, Optional.of(new ExportInformation(new IntPaginationToken(page), new IdOnlyContainerResource(ImgurPhotosExporter.DEFAULT_ALBUM_ID))));
page++;
PhotosContainerResource page2Resource = page2Result.getExportedData();
// 2th request returns 2 photos
assertEquals(2, page2Resource.getPhotos().size());
assertEquals(page, ((IntPaginationToken) page2Result.getContinuationData().getPaginationData()).getStart());
}
Aggregations