@Override
  public ImportResult importItem(UUID jobId, IdempotentImportExecutor idempotentImportExecutor,
      TokensAndUrlAuthData authData, MediaContainerResource resource) throws Exception {
    // Ensure credential is populated
    getOrCreateCredential(authData);

    logDebugJobStatus("%s before transmogrification", jobId, resource);

    // Make the data onedrive compatible
    resource.transmogrify(transmogrificationConfig);

    logDebugJobStatus("%s after transmogrification", jobId, resource);

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

    executeIdempotentImport(jobId, idempotentImportExecutor, resource.getVideos());

    executeIdempotentImport(jobId, idempotentImportExecutor, resource.getPhotos());

    return ImportResult.OK;
  }
@Test
  public void testImportItemPermissionDenied() throws Exception {
    List<MediaAlbum> albums =
        ImmutableList.of(new MediaAlbum("id1", "album1.", "This is a fake albumb"));

    MediaContainerResource data = new MediaContainerResource(albums, null /*photos*/,
        null /*videos*/);

    Call call = mock(Call.class);
    doReturn(call).when(client).newCall(
        argThat((Request r)
            -> r.url().toString().equals(
            "https://www.baseurl.com/v1.0/me/drive/special/photos/children")));
    Response response = mock(Response.class);
    ResponseBody body = mock(ResponseBody.class);
    when(body.bytes())
        .thenReturn(
            ResponseBody.create(MediaType.parse("application/json"), "{\"id\": \"id1\"}").bytes());
    when(body.string())
        .thenReturn(
            ResponseBody.create(MediaType.parse("application/json"), "{\"id\": \"id1\"}").string());
    when(response.code()).thenReturn(403);
    when(response.message()).thenReturn("Access Denied");
    when(response.body()).thenReturn(body);
    when(call.execute()).thenReturn(response);

    assertThrows(PermissionDeniedException.class, () -> {
      ImportResult result = importer.importItem(uuid, executor, authData, data);
    });
  }