long importPhotos(
      Collection<PhotoModel> photos,
      GPhotosUpload gPhotosUpload)
      throws Exception {
    return gPhotosUpload.uploadItemsViaBatching(
        photos,
        this::importPhotoBatch);
  }
@Test
  public void importOnePhotoWithHashMismatch() throws Exception {
    PhotoModel photoModel =
        new PhotoModel(
            PHOTO_TITLE,
            IMG_URI,
            PHOTO_DESCRIPTION,
            JPEG_MEDIA_TYPE,
            "oldPhotoID1",
            OLD_ALBUM_ID,
            false,
            SHA1);

    Mockito.when(googlePhotosInterface.uploadMediaContent(any(), eq(SHA1)))
        .thenThrow(new UploadErrorException("Hash mismatch will be thrown", new Throwable()));
    BatchMediaItemResponse batchMediaItemResponse = new BatchMediaItemResponse(
        new NewMediaItemResult[]{});
    Mockito.when(googlePhotosInterface.createPhotos(any(NewMediaItemUpload.class)))
        .thenReturn(batchMediaItemResponse);

    // No photo imported and will return a hash mismatch error for investigation.
    assertThrows(UploadErrorException.class,
        () -> googleMediaImporter.importPhotos(Lists.newArrayList(photoModel), new GPhotosUpload(UUID.randomUUID(), executor,
            mock(TokensAndUrlAuthData.class))));

    String failedDataId = String.format("%s-%s", OLD_ALBUM_ID, "oldPhotoID1");
    assertFalse(executor.isKeyCached(failedDataId));

    ErrorDetail errorDetail = executor.getErrors().iterator().next();
    assertEquals(failedDataId, errorDetail.id());
    assertThat(
        errorDetail.exception(), CoreMatchers.containsString("Hash mismatch"));
  }