Skip to content

Commit

Permalink
un-capitalize photo ids
Browse files Browse the repository at this point in the history
  • Loading branch information
osamahan999 committed Dec 6, 2023
1 parent e2db91b commit cff366a
Showing 1 changed file with 23 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -397,16 +397,16 @@ public void testGetGoogleMediaItemSucceeds() throws IOException, InvalidTokenExc

@Test
public void testExportPhotosContainer_photosRetrying() throws IOException, InvalidTokenException, PermissionDeniedException, UploadErrorException {
String PHOTO_ID_TO_FAIL_1 = "photo3";
String PHOTO_ID_TO_FAIL_2 = "photo5";
String photoIdToFail1 = "photo3";
String photoIdToFail2 = "photo5";

ImmutableList<PhotoAlbum> albums = ImmutableList.of();
ImmutableList<PhotoModel> photos = ImmutableList.of(
setUpSinglePhotoModel("", "photo1"),
setUpSinglePhotoModel("", "photo2"),
setUpSinglePhotoModel("", PHOTO_ID_TO_FAIL_1),
setUpSinglePhotoModel("", photoIdToFail1),
setUpSinglePhotoModel("", "photo4"),
setUpSinglePhotoModel("", PHOTO_ID_TO_FAIL_2),
setUpSinglePhotoModel("", photoIdToFail2),
setUpSinglePhotoModel("", "photo6")
);

Expand All @@ -418,11 +418,11 @@ public void testExportPhotosContainer_photosRetrying() throws IOException, Inval


// For the photo_id_to_fail photos, throw an exception.
when(photosInterface.getMediaItem(PHOTO_ID_TO_FAIL_1)).thenThrow(IOException.class);
when(photosInterface.getMediaItem(PHOTO_ID_TO_FAIL_2)).thenThrow(IOException.class);
when(photosInterface.getMediaItem(photoIdToFail1)).thenThrow(IOException.class);
when(photosInterface.getMediaItem(photoIdToFail2)).thenThrow(IOException.class);
// For all other photos, return a media item.
for (PhotoModel photoModel: photos) {
if (photoModel.getDataId().equals(PHOTO_ID_TO_FAIL_1) || photoModel.getDataId().equals(PHOTO_ID_TO_FAIL_2)) {
if (photoModel.getDataId().equals(photoIdToFail1) || photoModel.getDataId().equals(photoIdToFail2)) {
continue;
}
when(photosInterface.getMediaItem(photoModel.getDataId())).thenReturn(
Expand All @@ -439,7 +439,7 @@ public void testExportPhotosContainer_photosRetrying() throws IOException, Inval
photos.stream().map(
x -> x.getDataId()
).filter(
dataId -> !(dataId.equals(PHOTO_ID_TO_FAIL_1) || dataId.equals(PHOTO_ID_TO_FAIL_2))
dataId -> !(dataId.equals(photoIdToFail1) || dataId.equals(photoIdToFail2))
).collect(
Collectors.toList()
)
Expand Down Expand Up @@ -474,16 +474,16 @@ public void testGetGoogleMediaItemFailed() throws IOException, InvalidTokenExcep

@Test
public void testExportAlbums_failureInterruptsTransfer() throws Exception {
String ALBUM_ID_TO_FAIL_1 = "albumid3";
String ALBUM_ID_TO_FAIL_2 = "albumid5";
String albumIdToFail1 = "albumid3";
String albumIdToFail2 = "albumid5";

ImmutableList<PhotoModel> photos = ImmutableList.of();
ImmutableList<PhotoAlbum> albums = ImmutableList.of(
setUpSinglePhotoAlbum("albumid1", "album 1`", ""),
setUpSinglePhotoAlbum("albumid2", "album 2", ""),
setUpSinglePhotoAlbum(ALBUM_ID_TO_FAIL_1, "album 3", ""),
setUpSinglePhotoAlbum(albumIdToFail1, "album 3", ""),
setUpSinglePhotoAlbum("albumid4", "album 4", ""),
setUpSinglePhotoAlbum(ALBUM_ID_TO_FAIL_2, "album 5", ""),
setUpSinglePhotoAlbum(albumIdToFail2, "album 5", ""),
setUpSinglePhotoAlbum("albumid6", "album 6", "")
);

Expand All @@ -493,13 +493,12 @@ public void testExportAlbums_failureInterruptsTransfer() throws Exception {
MediaMetadata photoMediaMetadata = new MediaMetadata();
photoMediaMetadata.setPhoto(new Photo());


// For the album_id_to_fail albums, throw an exception.
when(photosInterface.getAlbum(ALBUM_ID_TO_FAIL_1)).thenThrow(IOException.class);
when(photosInterface.getAlbum(ALBUM_ID_TO_FAIL_2)).thenThrow(IOException.class);
when(photosInterface.getAlbum(albumIdToFail1)).thenThrow(IOException.class);
when(photosInterface.getAlbum(albumIdToFail2)).thenThrow(IOException.class);
// For all other albums, return a GoogleMediaAlbum.
for (PhotoAlbum photoAlbum: albums) {
if (photoAlbum.getId().equals(ALBUM_ID_TO_FAIL_1) || photoAlbum.getId().equals(ALBUM_ID_TO_FAIL_2)) {
if (photoAlbum.getId().equals(albumIdToFail1) || photoAlbum.getId().equals(albumIdToFail2)) {
continue;
}
when(photosInterface.getAlbum(photoAlbum.getId())).thenReturn(
Expand All @@ -514,16 +513,16 @@ public void testExportAlbums_failureInterruptsTransfer() throws Exception {

@Test
public void testExportAlbums_retryingSkipsFailures() throws Exception {
String ALBUM_ID_TO_FAIL_1 = "albumid3";
String ALBUM_ID_TO_FAIL_2 = "albumid5";
String albumIdToFail1 = "albumid3";
String albumIdToFail2 = "albumid5";

ImmutableList<PhotoModel> photos = ImmutableList.of();
ImmutableList<PhotoAlbum> albums = ImmutableList.of(
setUpSinglePhotoAlbum("albumid1", "album 1`", ""),
setUpSinglePhotoAlbum("albumid2", "album 2", ""),
setUpSinglePhotoAlbum(ALBUM_ID_TO_FAIL_1, "album 3", ""),
setUpSinglePhotoAlbum(albumIdToFail1, "album 3", ""),
setUpSinglePhotoAlbum("albumid4", "album 4", ""),
setUpSinglePhotoAlbum(ALBUM_ID_TO_FAIL_2, "album 5", ""),
setUpSinglePhotoAlbum(albumIdToFail2, "album 5", ""),
setUpSinglePhotoAlbum("albumid6", "album 6", "")
);

Expand All @@ -533,13 +532,12 @@ public void testExportAlbums_retryingSkipsFailures() throws Exception {
MediaMetadata photoMediaMetadata = new MediaMetadata();
photoMediaMetadata.setPhoto(new Photo());


// For the album_id_to_fail albums, throw an exception.
when(photosInterface.getAlbum(ALBUM_ID_TO_FAIL_1)).thenThrow(IOException.class);
when(photosInterface.getAlbum(ALBUM_ID_TO_FAIL_2)).thenThrow(IOException.class);
when(photosInterface.getAlbum(albumIdToFail1)).thenThrow(IOException.class);
when(photosInterface.getAlbum(albumIdToFail2)).thenThrow(IOException.class);
// For all other albums, return a GoogleMediaAlbum.
for (PhotoAlbum photoAlbum: albums) {
if (photoAlbum.getId().equals(ALBUM_ID_TO_FAIL_1) || photoAlbum.getId().equals(ALBUM_ID_TO_FAIL_2)) {
if (photoAlbum.getId().equals(albumIdToFail1) || photoAlbum.getId().equals(albumIdToFail2)) {
continue;
}
when(photosInterface.getAlbum(photoAlbum.getId())).thenReturn(
Expand All @@ -557,7 +555,7 @@ public void testExportAlbums_retryingSkipsFailures() throws Exception {
albums.stream().map(
x -> x.getId()
).filter(
id -> !(id.equals(ALBUM_ID_TO_FAIL_1) || id.equals(ALBUM_ID_TO_FAIL_2))
id -> !(id.equals(albumIdToFail1) || id.equals(albumIdToFail2))
).collect(
Collectors.toList()
)
Expand Down

0 comments on commit cff366a

Please sign in to comment.