Search in sources :

Example 1 with MetricsFilter

use of com.amazonaws.services.s3.model.metrics.MetricsFilter 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)

Example 2 with MetricsFilter

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

the class BucketMetricsSaxUnmarshallerTest method getResponse_unmarshalls_properly.

@Test
public void getResponse_unmarshalls_properly() throws Exception {
    MetricsConfiguration configuration = parseGetBucketMetricsConfigurationResponse(GET_RESPONSE).getMetricsConfiguration();
    MetricsFilter filter = configuration.getFilter();
    assertEquals("metrics-id", configuration.getId());
    List<MetricsFilterPredicate> operands = ((MetricsAndOperator) filter.getPredicate()).getOperands();
    assertEquals(3, 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());
    assertEquals("", ((MetricsTagPredicate) operands.get(2)).getTag().getKey());
    assertEquals("", ((MetricsTagPredicate) operands.get(2)).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) MetricsAndOperator(com.amazonaws.services.s3.model.metrics.MetricsAndOperator) MetricsFilter(com.amazonaws.services.s3.model.metrics.MetricsFilter) Test(org.junit.Test)

Aggregations

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