@Test
public void resumeUpload_andVerifyListMultipartUploadPartsResponse() {

    String pageToken = "nextPage";
    String uploadId = "exists";
    ArrayList<MultipartUpload> existingUploads = new ArrayList<>();
    existingUploads.add(MultipartUpload.builder().uploadId(uploadId).build());
    // empty first page, result found on second page
    ListMultipartUploadsResponse listResponse1 =
            ListMultipartUploadsResponse.builder()
                    .opcNextPage(pageToken)
                    .items(new ArrayList<MultipartUpload>())
                    .build();
    ListMultipartUploadsResponse listResponse2 =
            ListMultipartUploadsResponse.builder().items(existingUploads).build();
    when(service.listMultipartUploads(any(ListMultipartUploadsRequest.class)))
            .thenReturn(listResponse1)
            .thenReturn(listResponse2);
    ArrayList<MultipartUploadPartSummary> parts1 = new ArrayList<>();
    parts1.add(MultipartUploadPartSummary.builder().etag("etag1").partNumber(1).build());
    ArrayList<MultipartUploadPartSummary> parts2 = new ArrayList<>();
    parts2.add(MultipartUploadPartSummary.builder().etag("etag3").partNumber(3).build());
    ListMultipartUploadPartsResponse partsResponse1 =
            ListMultipartUploadPartsResponse.builder()
                    .opcNextPage(pageToken)
                    .items(parts1)
                    .build();
    ListMultipartUploadPartsResponse partsResponse2 =
            ListMultipartUploadPartsResponse.builder().items(parts2).build();
    when(service.listMultipartUploadParts(any(ListMultipartUploadPartsRequest.class)))
            .thenReturn(partsResponse1)
            .thenReturn(partsResponse2);
    MultipartManifest manifest = assembler.resumeRequest(uploadId);
    assertNotNull(manifest);
    assertEquals(uploadId, manifest.getUploadId());
    assertEquals(2, manifest.listCompletedParts().size());
    ArgumentCaptor<ListMultipartUploadsRequest> listUploadsCaptor =
            ArgumentCaptor.forClass(ListMultipartUploadsRequest.class);
    verify(service, times(2)).listMultipartUploads(listUploadsCaptor.capture());
    ListMultipartUploadsRequest listUploadsRequest1 = listUploadsCaptor.getAllValues().get(0);
    assertEquals(NAMESPACE, listUploadsRequest1.getNamespaceName());
    assertEquals(BUCKET, listUploadsRequest1.getBucketName());
    assertEquals(100, listUploadsRequest1.getLimit().intValue());
    assertEquals(mockInvocationCallback, listUploadsRequest1.getInvocationCallback());
    assertNull(listUploadsRequest1.getPage());
    ListMultipartUploadsRequest listUploadsRequest2 = listUploadsCaptor.getAllValues().get(1);
    assertEquals(NAMESPACE, listUploadsRequest2.getNamespaceName());
    assertEquals(BUCKET, listUploadsRequest2.getBucketName());
    assertEquals(100, listUploadsRequest2.getLimit().intValue());
    assertEquals(pageToken, listUploadsRequest2.getPage());
    assertEquals(mockInvocationCallback, listUploadsRequest2.getInvocationCallback());
    ArgumentCaptor<ListMultipartUploadPartsRequest> listPartsCaptor =
            ArgumentCaptor.forClass(ListMultipartUploadPartsRequest.class);
    verify(service, times(2)).listMultipartUploadParts(listPartsCaptor.capture());
    ListMultipartUploadPartsRequest listPartsRequest1 = listPartsCaptor.getAllValues().get(0);
    assertEquals(NAMESPACE, listPartsRequest1.getNamespaceName());
    assertEquals(BUCKET, listPartsRequest1.getBucketName());
    assertEquals(uploadId, listPartsRequest1.getUploadId());
    assertEquals(100, listPartsRequest1.getLimit().intValue());
    assertEquals(mockInvocationCallback, listPartsRequest1.getInvocationCallback());
    assertNull(listPartsRequest1.getPage());
    ListMultipartUploadPartsRequest listPartsRequest2 = listPartsCaptor.getAllValues().get(1);
    assertEquals(NAMESPACE, listPartsRequest2.getNamespaceName());
    assertEquals(BUCKET, listPartsRequest2.getBucketName());
    assertEquals(uploadId, listPartsRequest2.getUploadId());
    assertEquals(100, listPartsRequest2.getLimit().intValue());
    assertEquals(pageToken, listPartsRequest2.getPage());
    assertEquals(mockInvocationCallback, listPartsRequest2.getInvocationCallback());
}