use of software.amazon.awssdk.metrics.MetricPublisher in project aws-sdk-java-v2 by aws.
the class AsyncClientMetricPublisherResolutionTest method testApiCall_publishersSetOnClientAndRequest_requestPublishersInvoked.
@Test
public void testApiCall_publishersSetOnClientAndRequest_requestPublishersInvoked() throws IOException {
MetricPublisher clientPublisher1 = mock(MetricPublisher.class);
MetricPublisher clientPublisher2 = mock(MetricPublisher.class);
MetricPublisher requestPublisher1 = mock(MetricPublisher.class);
MetricPublisher requestPublisher2 = mock(MetricPublisher.class);
client = clientWithPublishers(clientPublisher1, clientPublisher2);
try {
client.allTypes(r -> r.overrideConfiguration(o -> o.addMetricPublisher(requestPublisher1).addMetricPublisher(requestPublisher2))).join();
} catch (Throwable t) {
// ignored, call fails because our mock HTTP client isn't set up
} finally {
verify(requestPublisher1).publish(any(MetricCollection.class));
verify(requestPublisher2).publish(any(MetricCollection.class));
verifyNoMoreInteractions(clientPublisher1);
verifyNoMoreInteractions(clientPublisher2);
}
}
use of software.amazon.awssdk.metrics.MetricPublisher in project aws-sdk-java-v2 by aws.
the class CoreMetricsTest method testApiCall_publisherOverriddenOnRequest_requestPublisherTakesPrecedence.
@Test
public void testApiCall_publisherOverriddenOnRequest_requestPublisherTakesPrecedence() {
MetricPublisher requestMetricPublisher = mock(MetricPublisher.class);
client.allTypes(r -> r.overrideConfiguration(o -> o.addMetricPublisher(requestMetricPublisher)));
verify(requestMetricPublisher).publish(any(MetricCollection.class));
verifyNoMoreInteractions(mockPublisher);
}
use of software.amazon.awssdk.metrics.MetricPublisher in project aws-sdk-java-v2 by aws.
the class CoreMetricsTest method testPaginatingApiCall_publisherOverriddenOnRequest_requestPublisherTakesPrecedence.
@Test
public void testPaginatingApiCall_publisherOverriddenOnRequest_requestPublisherTakesPrecedence() {
MetricPublisher requestMetricPublisher = mock(MetricPublisher.class);
PaginatedOperationWithResultKeyIterable iterable = client.paginatedOperationWithResultKeyPaginator(r -> r.overrideConfiguration(o -> o.addMetricPublisher(requestMetricPublisher)));
List<SimpleStruct> resultingItems = iterable.items().stream().collect(Collectors.toList());
verify(requestMetricPublisher).publish(any(MetricCollection.class));
verifyNoMoreInteractions(mockPublisher);
}
use of software.amazon.awssdk.metrics.MetricPublisher in project aws-sdk-java-v2 by aws.
the class ClientOverrideConfigurationTest method metricPublishers_overwritesPreviouslyAdded.
@Test
public void metricPublishers_overwritesPreviouslyAdded() {
MetricPublisher firstAdded = mock(MetricPublisher.class);
List<MetricPublisher> publishers = new ArrayList<>();
publishers.add(mock(MetricPublisher.class));
publishers.add(mock(MetricPublisher.class));
ClientOverrideConfiguration.Builder builder = ClientOverrideConfiguration.builder();
builder.addMetricPublisher(firstAdded);
builder.metricPublishers(publishers);
ClientOverrideConfiguration overrideConfig = builder.build();
assertThat(overrideConfig.metricPublishers()).isEqualTo(publishers);
}
use of software.amazon.awssdk.metrics.MetricPublisher in project aws-sdk-java-v2 by aws.
the class ClientOverrideConfigurationTest method addMetricPublisher_listPreviouslyAdded_appendedToList.
@Test
public void addMetricPublisher_listPreviouslyAdded_appendedToList() {
List<MetricPublisher> publishers = new ArrayList<>();
publishers.add(mock(MetricPublisher.class));
publishers.add(mock(MetricPublisher.class));
MetricPublisher thirdAdded = mock(MetricPublisher.class);
ClientOverrideConfiguration.Builder builder = ClientOverrideConfiguration.builder();
builder.metricPublishers(publishers);
builder.addMetricPublisher(thirdAdded);
ClientOverrideConfiguration overrideConfig = builder.build();
assertThat(overrideConfig.metricPublishers()).containsExactly(publishers.get(0), publishers.get(1), thirdAdded);
}
Aggregations