* DefaultHost can retrieve Cloudwatch stats and cache the results.
*/
@Test
public void retrievesAndCachesCloudWatchStats() {
final long sum = 10;
final CloudWatch cloudwatch = this.cloudWatch();
final GetMetricStatisticsResult result = new GetMetricStatisticsResult()
.withDatapoints(new Datapoint().withSum(Double.valueOf(sum)));
Mockito.doReturn(result).when(cloudwatch.get())
.getMetricStatistics(Mockito.any(GetMetricStatisticsRequest.class));
MatcherAssert.assertThat(
new DefaultHost(
new BucketMocker().mock(),
cloudwatch
).stats().bytesTransferred(),
Matchers.allOf(
Matchers.is(sum),
Matchers.is(
new DefaultHost(
new BucketMocker().mock(),
cloudwatch
).stats().bytesTransferred()
)
)
);
Mockito.verify(cloudwatch.get(), Mockito.times(1)).getMetricStatistics(
Mockito.any(GetMetricStatisticsRequest.class)
);
}