use of org.datatransferproject.datatransfer.google.mediaModels.Photo in project data-transfer-project by google.
the class GooglePhotosExporterTest method exportAlbumFirstSet.
@Test
public void exportAlbumFirstSet() throws IOException, InvalidTokenException, PermissionDeniedException {
setUpSingleAlbum();
when(albumListResponse.getNextPageToken()).thenReturn(ALBUM_TOKEN);
// Run test
ExportResult<PhotosContainerResource> result = googlePhotosExporter.exportAlbums(null, Optional.empty(), uuid);
// Check results
// Verify correct methods were called
verify(photosInterface).listAlbums(Optional.empty());
verify(albumListResponse).getAlbums();
// Check pagination token
ContinuationData continuationData = result.getContinuationData();
StringPaginationToken paginationToken = (StringPaginationToken) continuationData.getPaginationData();
assertThat(paginationToken.getToken()).isEqualTo(ALBUM_TOKEN_PREFIX + ALBUM_TOKEN);
// Check albums field of container
Collection<PhotoAlbum> actualAlbums = result.getExportedData().getAlbums();
assertThat(actualAlbums.stream().map(PhotoAlbum::getId).collect(Collectors.toList())).containsExactly(ALBUM_ID);
// Check photos field of container (should be empty, even though there is a photo in the
// original album)
Collection<PhotoModel> actualPhotos = result.getExportedData().getPhotos();
assertThat(actualPhotos).isEmpty();
// Should be one container in the resource list
List<ContainerResource> actualResources = continuationData.getContainerResources();
assertThat(actualResources.stream().map(a -> ((IdOnlyContainerResource) a).getId()).collect(Collectors.toList())).containsExactly(ALBUM_ID);
}
use of org.datatransferproject.datatransfer.google.mediaModels.Photo in project data-transfer-project by google.
the class GooglePhotosExporterTest method setUpSinglePhoto.
/**
* Sets up a response for a single photo
*/
private GoogleMediaItem setUpSinglePhoto(String imageUri, String photoId) {
GoogleMediaItem photoEntry = new GoogleMediaItem();
photoEntry.setDescription("Description");
photoEntry.setMimeType("image/jpeg");
photoEntry.setBaseUrl(imageUri);
photoEntry.setId(photoId);
photoEntry.setFilename(FILENAME);
MediaMetadata mediaMetadata = new MediaMetadata();
mediaMetadata.setPhoto(new Photo());
photoEntry.setMediaMetadata(mediaMetadata);
return photoEntry;
}
Aggregations