@Test
public void testListObjectsAllObjectsMultiplePages() {

    
    MockS3ChangeLogStore store = new MockS3ChangeLogStore();
    
    ArrayList<S3ObjectSummary> objectList1 = new ArrayList<>();
    S3ObjectSummary objectSummary = new S3ObjectSummary();
    objectSummary.setKey("iaas");
    objectList1.add(objectSummary);
    objectSummary = new S3ObjectSummary();
    objectSummary.setKey("iaas.athenz");
    objectList1.add(objectSummary);
    
    ArrayList<S3ObjectSummary> objectList2 = new ArrayList<>();
    objectSummary = new S3ObjectSummary();
    objectSummary.setKey("cd");
    objectList2.add(objectSummary);
    objectSummary = new S3ObjectSummary();
    objectSummary.setKey("cd.docker");
    objectList2.add(objectSummary);
    
    ArrayList<S3ObjectSummary> objectList3 = new ArrayList<>();
    objectSummary = new S3ObjectSummary();
    objectSummary.setKey("platforms");
    objectList3.add(objectSummary);
    objectSummary = new S3ObjectSummary();
    objectSummary.setKey("platforms.mh2");
    objectList3.add(objectSummary);
    
    ObjectListing objectListing = mock(ObjectListing.class);
    when(objectListing.getObjectSummaries())
        .thenReturn(objectList1)
        .thenReturn(objectList2)
        .thenReturn(objectList3);
    when(objectListing.isTruncated())
        .thenReturn(true)
        .thenReturn(true)
        .thenReturn(false);
    when(store.awsS3Client.listObjects(any(ListObjectsRequest.class))).thenReturn(objectListing);
    when(store.awsS3Client.listNextBatchOfObjects(any(ObjectListing.class))).thenReturn(objectListing);
    ArrayList<String> domains = new ArrayList<>();
    store.listObjects(store.awsS3Client, domains, 0);
    
    assertEquals(domains.size(), 6);
    assertTrue(domains.contains("iaas"));
    assertTrue(domains.contains("iaas.athenz"));
    assertTrue(domains.contains("cd"));
    assertTrue(domains.contains("cd.docker"));
    assertTrue(domains.contains("platforms"));
    assertTrue(domains.contains("platforms.mh2"));
}