@Override
  public ImportResult importItem(
      UUID jobId,
      IdempotentImportExecutor idempotentExecutor,
      TokensAndUrlAuthData authData,
      MediaContainerResource data)
      throws Exception {
    if (data == null) {
      return ImportResult.OK;
    }

    for (PhotoModel photoModel: data.getPhotos()) {
      monitor.debug(() -> "AppleMediaImporter received data",
              AuditKeys.dataId, photoModel.getDataId(),
              AuditKeys.updatedTimeInMs, photoModel.getUploadedTime());
    }

    AppleMediaInterface mediaInterface = factory
      .getOrCreateMediaInterface(jobId, authData, appCredentials, exportingService, monitor);

    final int albumCount =
        mediaInterface.importAlbums(
            jobId,
            idempotentExecutor,
            data.getAlbums(),
          DataVertical.MEDIA.getDataType());
    final Map<String, Long> importPhotosMap =
        mediaInterface.importAllMedia(
            jobId,
            idempotentExecutor,
            data.getPhotos(),
          DataVertical.MEDIA.getDataType());
    final Map<String, Long> importVideosResult =
        mediaInterface.importAllMedia(
            jobId,
            idempotentExecutor,
            data.getVideos(),
          DataVertical.MEDIA.getDataType());

    final Map<String, Integer> counts =
        new ImmutableMap.Builder<String, Integer>()
            .put(MediaContainerResource.ALBUMS_COUNT_DATA_NAME, albumCount)
            .put(
                MediaContainerResource.PHOTOS_COUNT_DATA_NAME,
                importPhotosMap.getOrDefault(ApplePhotosConstants.COUNT_KEY, 0L).intValue())
            .put(
                MediaContainerResource.VIDEOS_COUNT_DATA_NAME,
                importVideosResult.getOrDefault(ApplePhotosConstants.COUNT_KEY, 0L).intValue())
            .build();

    monitor.info(() -> "AppleMediaImporter imported batch",
            MediaContainerResource.ALBUMS_COUNT_DATA_NAME, albumCount,
            MediaContainerResource.PHOTOS_COUNT_DATA_NAME, importPhotosMap.getOrDefault(ApplePhotosConstants.COUNT_KEY, 0L).intValue(),
            MediaContainerResource.VIDEOS_COUNT_DATA_NAME, importVideosResult.getOrDefault(ApplePhotosConstants.COUNT_KEY, 0L).intValue());

    return ImportResult.OK
        .copyWithBytes(
            importPhotosMap.getOrDefault(ApplePhotosConstants.BYTES_KEY, 0L)
                + importVideosResult.getOrDefault(ApplePhotosConstants.BYTES_KEY, 0L))
        .copyWithCounts(counts);
  }
@Test
  public void importEmptyNamePhoto() throws Exception {
    // set up photos
    final int photoCount = 1;
    final List<PhotoModel> photos = Arrays.asList(
            new PhotoModel(
                    "", // empty title
                    "fetchableUrl",
                    "description",
                    "mediaType",
                    PHOTOS_DATAID_BASE + UUID.randomUUID(),
                    null ,
                    false,
                    null,
                    new Date(),
                    new FavoriteInfo(true, new Date())),
            new PhotoModel(
                    null, // empty title
                    "fetchableUrl",
                    "description",
                    "mediaType",
                    PHOTOS_DATAID_BASE + UUID.randomUUID(),
                    null ,
                    false,
                    null,
                    new Date(),
                    new FavoriteInfo(true, new Date())));

    final Map<String, Integer> dataIdToStatus =
            photos.stream()
                    .collect(
                            Collectors.toMap(PhotoModel::getDataId, photoModel -> SC_OK));

    setUpGetUploadUrlResponse(dataIdToStatus);
    setUpUploadContentResponse(dataIdToStatus);
    setUpCreateMediaResponse(dataIdToStatus);

    MediaContainerResource mediaData = new MediaContainerResource(null, photos, null);
    appleMediaImporter.importItem(uuid, executor, authData, mediaData);

    // verify correct methods were called
    final List<String> photosDataIds =
            photos.stream().map(PhotoModel::getDataId).collect(Collectors.toList());

    verify(mediaInterface)
            .getUploadUrl(uuid.toString(), DataVertical.MEDIA.getDataType(), photosDataIds);
    verify(mediaInterface, times(1)).uploadContent(anyMap(), anyList());
    verify(mediaInterface, times(1)).createMedia(anyString(), anyString(), argThat(newMediaRequestList -> {
      assertThat(newMediaRequestList).isNotNull();
      assertThat(newMediaRequestList.stream().allMatch(newMediaRequest -> newMediaRequest.getFilename().equals(ApplePhotosConstants.APPLE_PHOTOS_UNTITLED_FILE_NAME))).isTrue();
      return true;
    }));
  }