@Test
  public void exportMediaWithNextPage() throws IOException {
    // Setup
    when(driveItemsResponse.getNextPageLink()).thenReturn(null);
    when(driveItemsResponse.getDriveItems()).thenReturn(new MicrosoftDriveItem[] {
      setUpSinglePhoto(PHOTO_FILENAME, PHOTO_URI, PHOTO_ID),
      setUpSingleVideo(VIDEO_FILENAME, VIDEO_URI, VIDEO_ID)
    });
    when(driveItemsResponse.getNextPageLink()).thenReturn(DRIVE_PAGE_URL);
    IdOnlyContainerResource idOnlyContainerResource = new IdOnlyContainerResource(FOLDER_ID);

    // Run
    ExportResult<MediaContainerResource> result = microsoftMediaExporter.exportOneDrivePhotos(
        null, Optional.of(idOnlyContainerResource), Optional.empty(), uuid);

    // Verify method calls
    verify(mediaInterface).getDriveItems(Optional.of(FOLDER_ID), Optional.empty());
    verify(driveItemsResponse).getDriveItems();

    // Verify pagination token is set
    ContinuationData continuationData = result.getContinuationData();
    StringPaginationToken paginationToken =
        (StringPaginationToken) continuationData.getPaginationData();
    assertThat(paginationToken.getToken()).isEqualTo(DRIVE_TOKEN_PREFIX + DRIVE_PAGE_URL);

    // Verify no albums are exported
    Collection<MediaAlbum> actualAlbums = result.getExportedData().getAlbums();
    assertThat(actualAlbums).isEmpty();

    // Verify one photo (in an album) should be exported
    Collection<PhotoModel> actualPhotos = result.getExportedData().getPhotos();
    assertThat(actualPhotos.size()).isEqualTo(1);
    assertThat(actualPhotos.stream().map(PhotoModel::getFetchableUrl).collect(Collectors.toList()))
        .containsExactly(PHOTO_URI);
    assertThat(actualPhotos.stream().map(PhotoModel::getAlbumId).collect(Collectors.toList()))
        .containsExactly(FOLDER_ID);
    assertThat(actualPhotos.stream().map(PhotoModel::getTitle).collect(Collectors.toList()))
        .containsExactly(PHOTO_FILENAME);

    // Verify one video (in an album) should be exported
    Collection<VideoModel> actualVideos = result.getExportedData().getVideos();
    assertThat(actualVideos.size()).isEqualTo(1);
    assertThat(actualVideos.stream().map(VideoModel::getFetchableUrl).collect(Collectors.toList()))
        .containsExactly(VIDEO_URI);
    assertThat(actualVideos.stream().map(VideoModel::getAlbumId).collect(Collectors.toList()))
        .containsExactly(FOLDER_ID);
    assertThat(actualVideos.stream().map(VideoModel::getName).collect(Collectors.toList()))
        .containsExactly(VIDEO_FILENAME);

    // Verify there are no containers ready for sub-processing
    List<ContainerResource> actualResources = continuationData.getContainerResources();
    assertThat(actualResources).isEmpty();
  }
Unit tests of Microsoft onedrive exporter for Media models.
extensions/data-transfer/portability-data-transfer-microsoft/src/test/java/org/datatransferproject/transfer/microsoft/media/MicrosoftMediaExporterTest.java