use of com.amazonaws.services.s3.model.S3ObjectSummary in project athenz by yahoo.
the class S3ChangeLogStoreTest method testGetServerDomains.
@Test
public void testGetServerDomains() {
MockS3ChangeLogStore store = new MockS3ChangeLogStore(null);
ArrayList<S3ObjectSummary> objectList = new ArrayList<>();
S3ObjectSummary objectSummary = new S3ObjectSummary();
objectSummary.setKey("iaas");
objectList.add(objectSummary);
objectSummary = new S3ObjectSummary();
objectSummary.setKey("iaas.athenz");
objectList.add(objectSummary);
ObjectListing objectListing = mock(ObjectListing.class);
when(objectListing.getObjectSummaries()).thenReturn(objectList);
when(objectListing.isTruncated()).thenReturn(false);
when(store.awsS3Client.listObjects(any(ListObjectsRequest.class))).thenReturn(objectListing);
// verify that our last mod time is 0 before the call
assertEquals(store.lastModTime, 0);
// retrieve the list of domains
Set<String> domains = store.getServerDomainList();
assertEquals(domains.size(), 2);
assertTrue(domains.contains("iaas"));
assertTrue(domains.contains("iaas.athenz"));
// also verify that last mod time is not updated
assertEquals(store.lastModTime, 0);
}
Aggregations