@VisibleForTesting void importSinglePhoto(UUID jobId, PhotoModel inputPhoto, SmugMugInterface smugMugInterface) throws IOException { // Find album to upload photo to TempPhotosData tempPhotosData = jobStore.findData(jobId, createCacheKey(), TempPhotosData.class); checkState( tempPhotosData != null, "cached temp photos data for %s is null", inputPhoto.getAlbumId()); String newAlbumUri = tempPhotosData.lookupNewAlbumId(inputPhoto.getAlbumId()); checkState( !Strings.isNullOrEmpty(newAlbumUri), "Cached album URI for %s is null", inputPhoto.getAlbumId()); InputStream inputStream; if (inputPhoto.isInTempStore()) { inputStream = jobStore.getStream(jobId, inputPhoto.getFetchableUrl()); } else { inputStream = smugMugInterface.getImageAsStream(inputPhoto.getFetchableUrl()); } SmugMugImageUploadResponse response = smugMugInterface.uploadImage(inputPhoto, newAlbumUri, inputStream); }
String newAlbumId = tempData.lookupNewAlbumId(oldAlbumId);
albumId = tempPhotosData.lookupNewAlbumId(inputPhoto.getAlbumId());
@Test public void exportAlbum() throws IOException { // Set up String albumName = "Album Name"; String albumDescription = "Album description"; PhotoAlbum albumModel = new PhotoAlbum(OLD_ALBUM_ID, albumName, albumDescription); GoogleAlbum responseAlbum = new GoogleAlbum(); responseAlbum.setId(NEW_ALBUM_ID); when(googlePhotosInterface.createAlbum(Matchers.any(GoogleAlbum.class))) .thenReturn(responseAlbum); // Run test googlePhotosImporter.importSingleAlbum(uuid, null, albumModel); // Check results ArgumentCaptor<GoogleAlbum> albumArgumentCaptor = ArgumentCaptor.forClass(GoogleAlbum.class); verify(googlePhotosInterface).createAlbum(albumArgumentCaptor.capture()); assertEquals(albumArgumentCaptor.getValue().getTitle(), "Copy of " + albumName); assertNull(albumArgumentCaptor.getValue().getId()); TempPhotosData tempPhotosData = jobStore.findData(uuid, "tempPhotosData", TempPhotosData.class); assertEquals(tempPhotosData.lookupNewAlbumId(OLD_ALBUM_ID), NEW_ALBUM_ID); }
assertThat(tempPhotosData.lookupNewAlbumId(ALBUM_ID)).isEqualTo(FLICKR_ALBUM_ID);