@Override
  public ImportResult importItem(
      UUID jobId,
      IdempotentImportExecutor idempotentImportExecutor,
      TokensAndUrlAuthData authData,
      PhotosContainerResource resource)
      throws Exception {
    KoofrClient koofrClient = koofrClientFactory.create(authData);
    monitor.debug(
        () ->
            String.format(
                "%s: Importing %s albums and %s photos before transmogrification",
                jobId, resource.getAlbums().size(), resource.getPhotos().size()));

    // Make the data Koofr compatible
    resource.transmogrify(transmogrificationConfig);
    monitor.debug(
        () ->
            String.format(
                "%s: Importing %s albums and %s photos after transmogrification",
                jobId, resource.getAlbums().size(), resource.getPhotos().size()));

    for (PhotoAlbum album : resource.getAlbums()) {
      // Create a Koofr folder and then save the id with the mapping data
      idempotentImportExecutor.executeAndSwallowIOExceptions(
          album.getId(), album.getName(), () -> createAlbumFolder(album, koofrClient));
    }

    final LongAdder totalImportedFilesSizes = new LongAdder();
    for (PhotoModel photoModel : resource.getPhotos()) {
      idempotentImportExecutor.importAndSwallowIOExceptions(
          photoModel,
          photo -> {
            ItemImportResult<String> fileImportResult =
                importSinglePhoto(photoModel, jobId, idempotentImportExecutor, koofrClient);
            if (fileImportResult != null && fileImportResult.hasBytes()) {
              totalImportedFilesSizes.add(fileImportResult.getBytes());
            }
            return fileImportResult;
          });
    }
    return ImportResult.OK.copyWithBytes(totalImportedFilesSizes.longValue());
  }
@Test
  public void testImportItemFromJobStoreUserTimeZoneCalledOnce() throws Exception {
    ByteArrayInputStream inputStream = new ByteArrayInputStream(new byte[] {0, 1, 2, 3, 4});
    when(jobStore.getStream(any(), any())).thenReturn(new InputStreamWrapper(inputStream, 5L));

    UUID jobId = UUID.randomUUID();

    PortabilityJob job = mock(PortabilityJob.class);
    when(job.userTimeZone()).thenReturn(TimeZone.getTimeZone("Europe/Rome"));
    when(jobStore.findJob(jobId)).thenReturn(job);

    Collection<PhotoAlbum> albums =
        ImmutableList.of(new PhotoAlbum("id1", "Album 1", "This is a fake album"));

    DateFormat format = new SimpleDateFormat("yyyy:MM:dd HH:mm:ss");
    format.setTimeZone(TimeZone.getTimeZone("Europe/Kiev"));

    Collection<PhotoModel> photos1 =
        ImmutableList.of(
            new PhotoModel(
                "pic1.jpg",
                "http://fake.com/1.jpg",
                "A pic",
                "image/jpeg",
                "p1",
                "id1",
                true,
                format.parse("2021:02:16 11:55:00")));

    Collection<PhotoModel> photos2 =
        ImmutableList.of(
            new PhotoModel(
                "pic2.jpg",
                "http://fake.com/2.jpg",
                "A pic",
                "image/jpeg",
                "p2",
                "id1",
                true,
                format.parse("2021:02:17 11:55:00")));

    PhotosContainerResource resource1 = spy(new PhotosContainerResource(albums, photos1));
    PhotosContainerResource resource2 = spy(new PhotosContainerResource(albums, photos2));
    importer.importItem(jobId, executor, authData, resource1);
    importer.importItem(jobId, executor, authData, resource2);
    InOrder clientInOrder = Mockito.inOrder(client);

    String[] titles = {"2021-02-16 10.55.00 pic1.jpg", "2021-02-17 10.55.00 pic2.jpg"};
    for (String title : titles) {
      clientInOrder.verify(client).uploadFile(any(), eq(title), any(), any(), any(), any());
    }

    verify(jobStore, atMostOnce()).findJob(jobId);
  }