use of org.datatransferproject.types.common.ExportInformation in project data-transfer-project by google.
the class GoogleCalendarExporterTest method exportCalendarSubsequentSet.
@Test
public void exportCalendarSubsequentSet() throws IOException {
setUpSingleCalendarResponse();
// Looking at subsequent page, with no page after it
PaginationData paginationData = new StringPaginationToken(CALENDAR_TOKEN_PREFIX + NEXT_TOKEN);
ExportInformation exportInformation = new ExportInformation(paginationData, null);
calendarListResponse.setNextPageToken(null);
// Run test
ExportResult<CalendarContainerResource> result = googleCalendarExporter.export(UUID.randomUUID(), null, Optional.of(exportInformation));
// Check results
// Verify correct calls were made
InOrder inOrder = Mockito.inOrder(calendarListRequest);
inOrder.verify(calendarListRequest).setPageToken(NEXT_TOKEN);
inOrder.verify(calendarListRequest).execute();
// Check pagination token
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 testAlbumPhotosExport.
@Test
public void testAlbumPhotosExport() throws Exception {
server.enqueue(new MockResponse().setBody(albumsResponse));
server.enqueue(new MockResponse().setBody(album1ImagesResponse));
// export albums
exporter.export(UUID.randomUUID(), token, Optional.empty());
// export album photos
ExportResult<PhotosContainerResource> result = exporter.export(UUID.randomUUID(), token, Optional.of(new ExportInformation(null, new IdOnlyContainerResource("albumId1"))));
assertThat(result.getExportedData().getPhotos()).containsExactly(ALBUM_PHOTO_1, ALBUM_PHOTO_2).inOrder();
}
use of org.datatransferproject.types.common.ExportInformation in project data-transfer-project by google.
the class FlickrPhotosExporterTest method exportPhotosFromPhotoset.
@Test
public void exportPhotosFromPhotoset() throws FlickrException {
// set up auth, flickr service
when(user.getId()).thenReturn("userId");
when(authInterface.checkToken(any(Token.class))).thenReturn(auth);
when(flickr.getPhotosetsInterface()).thenReturn(photosetsInterface);
when(flickr.getPhotosInterface()).thenReturn(photosInterface);
when(flickr.getAuthInterface()).thenReturn(authInterface);
// getting photos from a set with id photosetsId and page 1
int page = 1;
String photosetsId = "photosetsId";
ExportInformation exportInformation = new ExportInformation(null, new IdOnlyContainerResource(photosetsId));
// make lots of photos and add them to PhotoList (also adding pagination information)
int numPhotos = 4;
PhotoList<Photo> photosList = new PhotoList<>();
for (int i = 0; i < numPhotos; i++) {
photosList.add(FlickrTestUtils.initializePhoto("title" + 1, "url" + i, "description" + i, MEDIA_TYPE));
}
photosList.setPage(page);
photosList.setPages(page + 1);
when(photosetsInterface.getPhotos(anyString(), anySet(), anyInt(), anyInt(), anyInt())).thenReturn(photosList);
// run test
FlickrPhotosExporter exporter = new FlickrPhotosExporter(flickr, TransferServiceConfig.getDefaultInstance());
ExportResult<PhotosContainerResource> result = exporter.export(UUID.randomUUID(), new TokenSecretAuthData("token", "secret"), Optional.of(exportInformation));
assertThat(result.getExportedData().getPhotos().size()).isEqualTo(numPhotos);
assertThat(result.getExportedData().getAlbums()).isEmpty();
ContinuationData continuationData = (ContinuationData) result.getContinuationData();
assertThat(continuationData.getContainerResources()).isEmpty();
assertThat(((IntPaginationToken) continuationData.getPaginationData()).getStart()).isEqualTo(page + 1);
}
use of org.datatransferproject.types.common.ExportInformation in project data-transfer-project by google.
the class FacebookPhotosExporterTest method testExportPhoto.
@Test
public void testExportPhoto() throws CopyExceptionWithFailureReason {
ExportResult<PhotosContainerResource> result = facebookPhotosExporter.export(uuid, new TokensAndUrlAuthData("accessToken", null, null), Optional.of(new ExportInformation(null, new IdOnlyContainerResource(ALBUM_ID))));
assertEquals(ExportResult.ResultType.END, result.getType());
PhotosContainerResource exportedData = result.getExportedData();
assertEquals(1, exportedData.getPhotos().size());
assertEquals(new PhotoModel(PHOTO_ID + ".jpg", PHOTO_ID, PHOTO_NAME, "image/jpg", PHOTO_ID, ALBUM_ID, false, PHOTO_TIME), exportedData.getPhotos().toArray()[0]);
}
use of org.datatransferproject.types.common.ExportInformation in project data-transfer-project by google.
the class FacebookVideosExporterTest method testExportVideo.
@Test
public void testExportVideo() throws CopyExceptionWithFailureReason {
ExportResult<VideosContainerResource> result = facebookVideosExporter.export(uuid, new TokensAndUrlAuthData("accessToken", null, null), Optional.of(new ExportInformation(null, null)));
assertEquals(ExportResult.ResultType.END, result.getType());
VideosContainerResource exportedData = result.getExportedData();
assertEquals(1, exportedData.getVideos().size());
assertEquals(new VideoModel(VIDEO_ID + ".mp4", VIDEO_SOURCE, VIDEO_NAME, "video/mp4", VIDEO_ID, null, false), exportedData.getVideos().toArray()[0]);
}
Aggregations