CloudWatch { public static void putMetricData(CloudWatchApi cloudWatchApi, String region, Iterable<MetricDatum> metrics, String namespace) { MetricApi metricApi = cloudWatchApi.getMetricApiForRegion(region); for (List<MetricDatum> slice : Iterables.partition(metrics, 10)) { metricApi.putMetricsInNamespace(slice, namespace); } }  static Iterable<Metric> listMetrics(final MetricApi metricApi, final ListMetricsOptions options); static Iterable<Metric> listMetrics(CloudWatchApi cloudWatchApi, String region,
            final ListMetricsOptions options); static void putMetricData(CloudWatchApi cloudWatchApi, String region, Iterable<MetricDatum> metrics,
            String namespace);  }
@Test public void testPutMetricData() throws Exception { CloudWatchApi api = createMock(CloudWatchApi.class); MetricApi metricApi = createMock(MetricApi.class); Set<MetricDatum> metrics = Sets.newLinkedHashSet(); String namespace = "JCLOUDS/Test"; for (int i = 0; i < 11; i++) { metrics.add(MetricDatum.builder().metricName("foo").build()); } expect(api.getMetricApiForRegion(EasyMock.eq(""))) .andReturn(metricApi) .atLeastOnce(); for (List<MetricDatum> slice : Iterables.partition(metrics, 10)) { metricApi.putMetricsInNamespace(slice, namespace); } EasyMock.replay(api, metricApi); CloudWatch.putMetricData(api, "", metrics, namespace); EasyMock.verify(metricApi); }