Search in sources :

Example 1 with ListBucketMetricsConfigurationsResult

use of com.amazonaws.services.s3.model.ListBucketMetricsConfigurationsResult in project aws-sdk-android by aws-amplify.

the class BucketMetricsSaxUnmarshallerTest method listResponse_unmarshalls_properly.

@Test
public void listResponse_unmarshalls_properly() throws Exception {
    ListBucketMetricsConfigurationsResult result = parseListBucketMetricsConfigurationsResponse(LIST_RESPONSE);
    assertTrue(result.isTruncated());
    assertEquals("token1", result.getContinuationToken());
    assertEquals("token2", result.getNextContinuationToken());
    List<MetricsConfiguration> metricsConfigurationList = result.getMetricsConfigurationList();
    assertEquals(2, metricsConfigurationList.size());
    // Test first metrics configuration
    MetricsConfiguration configuration = metricsConfigurationList.get(0);
    MetricsFilter filter = configuration.getFilter();
    assertEquals("id1", configuration.getId());
    assertNotNull(filter);
    List<MetricsFilterPredicate> operands = ((MetricsAndOperator) filter.getPredicate()).getOperands();
    assertEquals(2, operands.size());
    assertEquals("documents/", ((MetricsPrefixPredicate) operands.get(0)).getPrefix());
    assertEquals("foo", ((MetricsTagPredicate) operands.get(1)).getTag().getKey());
    assertEquals("bar", ((MetricsTagPredicate) operands.get(1)).getTag().getValue());
    // Test second metrics configuration
    configuration = metricsConfigurationList.get(1);
    assertEquals("id2", configuration.getId());
    MetricsTagPredicate tagPredicate = (MetricsTagPredicate) configuration.getFilter().getPredicate();
    assertEquals("key", tagPredicate.getTag().getKey());
    assertEquals("value", tagPredicate.getTag().getValue());
}
Also used : MetricsTagPredicate(com.amazonaws.services.s3.model.metrics.MetricsTagPredicate) MetricsConfiguration(com.amazonaws.services.s3.model.metrics.MetricsConfiguration) MetricsFilterPredicate(com.amazonaws.services.s3.model.metrics.MetricsFilterPredicate) ListBucketMetricsConfigurationsResult(com.amazonaws.services.s3.model.ListBucketMetricsConfigurationsResult) MetricsAndOperator(com.amazonaws.services.s3.model.metrics.MetricsAndOperator) MetricsFilter(com.amazonaws.services.s3.model.metrics.MetricsFilter) Test(org.junit.Test)

Aggregations

ListBucketMetricsConfigurationsResult (com.amazonaws.services.s3.model.ListBucketMetricsConfigurationsResult)1 MetricsAndOperator (com.amazonaws.services.s3.model.metrics.MetricsAndOperator)1 MetricsConfiguration (com.amazonaws.services.s3.model.metrics.MetricsConfiguration)1 MetricsFilter (com.amazonaws.services.s3.model.metrics.MetricsFilter)1 MetricsFilterPredicate (com.amazonaws.services.s3.model.metrics.MetricsFilterPredicate)1 MetricsTagPredicate (com.amazonaws.services.s3.model.metrics.MetricsTagPredicate)1 Test (org.junit.Test)1