### Question:
GooglePhotosExporter implements Exporter<TokensAndUrlAuthData, PhotosContainerResource> { @VisibleForTesting void populateContainedPhotosList(UUID jobId, TokensAndUrlAuthData authData) throws IOException, InvalidTokenException, PermissionDeniedException { TempPhotosData tempPhotosData = new TempPhotosData(jobId); String albumToken = null; AlbumListResponse albumListResponse; MediaItemSearchResponse containedMediaSearchResponse; do { albumListResponse = getOrCreatePhotosInterface(authData).listAlbums(Optional.ofNullable(albumToken)); if (albumListResponse.getAlbums() != null) { for (GoogleAlbum album : albumListResponse.getAlbums()) { String albumId = album.getId(); String photoToken = null; do { containedMediaSearchResponse = getOrCreatePhotosInterface(authData) .listMediaItems(Optional.of(albumId), Optional.ofNullable(photoToken)); if (containedMediaSearchResponse.getMediaItems() != null) { for (GoogleMediaItem mediaItem : containedMediaSearchResponse.getMediaItems()) { tempPhotosData.addContainedPhotoId(mediaItem.getId()); } } photoToken = containedMediaSearchResponse.getNextPageToken(); } while (photoToken != null); } } albumToken = albumListResponse.getNextPageToken(); } while (albumToken != null); InputStream stream = convertJsonToInputStream(tempPhotosData); jobStore.create(jobId, createCacheKey(), stream); } GooglePhotosExporter(
      GoogleCredentialFactory credentialFactory,
      TemporaryPerJobDataStore jobStore,
      JsonFactory jsonFactory,
      Monitor monitor); @VisibleForTesting  GooglePhotosExporter(
      GoogleCredentialFactory credentialFactory,
      TemporaryPerJobDataStore jobStore,
      JsonFactory jsonFactory,
      GooglePhotosInterface photosInterface,
      Monitor monitor); @Override ExportResult<PhotosContainerResource> export(
      UUID jobId, TokensAndUrlAuthData authData, Optional<ExportInformation> exportInformation);  }### Answer:
@Test public void populateContainedPhotosList() throws IOException, InvalidTokenException, PermissionDeniedException { setUpSingleAlbum(); when(albumListResponse.getNextPageToken()).thenReturn(null); MediaItemSearchResponse albumMediaResponse = mock(MediaItemSearchResponse.class); GoogleMediaItem firstPhoto = setUpSinglePhoto(IMG_URI, PHOTO_ID); String secondUri = "second uri"; String secondId = "second id"; GoogleMediaItem secondPhoto = setUpSinglePhoto(secondUri, secondId); when(photosInterface.listMediaItems(eq(Optional.of(ALBUM_ID)), any(Optional.class))) .thenReturn(albumMediaResponse); when(albumMediaResponse.getMediaItems()) .thenReturn(new GoogleMediaItem[] {firstPhoto, secondPhoto}); when(albumMediaResponse.getNextPageToken()).thenReturn(null); googlePhotosExporter.populateContainedPhotosList(uuid, null); ArgumentCaptor<InputStream> inputStreamArgumentCaptor = ArgumentCaptor.forClass(InputStream.class); verify(jobStore).create(eq(uuid), eq("tempPhotosData"), inputStreamArgumentCaptor.capture()); TempPhotosData tempPhotosData = new ObjectMapper().readValue(inputStreamArgumentCaptor.getValue(), TempPhotosData.class); assertThat(tempPhotosData.lookupContainedPhotoIds()).containsExactly(PHOTO_ID, secondId); }