@Override
  public ImportResult importItem(
      UUID jobId,
      IdempotentImportExecutor idempotentExecutor,
      TokenSecretAuthData authData,
      PhotosContainerResource data)
      throws Exception {
    if (data == null) {
      // Nothing to do
      return ImportResult.OK;
    }

    BackblazeDataTransferClient b2Client = b2ClientFactory.getOrCreateB2Client(jobId, authData);

    if (data.getAlbums() != null && data.getAlbums().size() > 0) {
      for (PhotoAlbum album : data.getAlbums()) {
        idempotentExecutor.executeAndSwallowIOExceptions(
            album.getId(),
            String.format("Caching album name for album '%s'", album.getId()),
            () -> album.getName());
      }
    }

    final LongAdder totalImportedFilesSizes = new LongAdder();
    if (data.getPhotos() != null && data.getPhotos().size() > 0) {
      for (PhotoModel photo : data.getPhotos()) {
        idempotentExecutor.importAndSwallowIOExceptions(
            photo,
            p -> {
              ItemImportResult<String> fileImportResult =
                  importSinglePhoto(idempotentExecutor, b2Client, jobId, p);
              if (fileImportResult.hasBytes()) {
                totalImportedFilesSizes.add(fileImportResult.getBytes());
              }
              return fileImportResult;
            });
      }
    }

    return ImportResult.OK.copyWithBytes(totalImportedFilesSizes.longValue());
  }
@Test
  public void testImportPhoto() throws Exception {
    String dataId = "dataId";
    String title = "title";
    String photoUrl = "photoUrl";
    String albumName = "albumName";
    String albumId = "albumId";
    String response = "response";
    UUID jobId = UUID.randomUUID();
    PhotoModel photoModel = new PhotoModel(title, photoUrl, "", "", dataId, albumId, false);
    PhotosContainerResource data =
        new PhotosContainerResource(Collections.emptyList(), Collections.singletonList(photoModel));

    when(executor.getCachedValue(albumId)).thenReturn(albumName);

    when(streamProvider.getInputStreamForItem(jobId, photoModel))
        .thenReturn(new InputStreamWrapper(IOUtils.toInputStream("photo content", "UTF-8")));

    when(client.uploadFile(eq("Photo Transfer/albumName/dataId.jpg"), any())).thenReturn(response);
    when(clientFactory.getOrCreateB2Client(jobId, authData)).thenReturn(client);

    File file = folder.toFile();
    when(dataStore.getTempFileFromInputStream(any(), any(), any())).thenReturn(file);

    BackblazePhotosImporter sut =
        new BackblazePhotosImporter(monitor, dataStore, streamProvider, clientFactory);
    sut.importItem(jobId, executor, authData, data);

    ArgumentCaptor<ImportFunction<PhotoModel, String>> importCapture =
        ArgumentCaptor.forClass(ImportFunction.class);
    verify(executor, times(1))
        .importAndSwallowIOExceptions(eq(photoModel), importCapture.capture());

    String actual = importCapture.getValue().apply(photoModel).getData();
    assertEquals(response, actual);
  }