use of com.signalfx.codahale.reporter.MetricMetadata.BuilderTagger in project riposte by Nike-Inc.
the class SignalFxEndpointMetricsHandlerTest method ChainedMetricDimensionConfigurator_setupMetricWithDimensions_chains_calls_as_expected.
@Test
public void ChainedMetricDimensionConfigurator_setupMetricWithDimensions_chains_calls_as_expected() {
// given
MetricDimensionConfigurator first = mock(MetricDimensionConfigurator.class);
MetricDimensionConfigurator second = mock(MetricDimensionConfigurator.class);
ChainedMetricDimensionConfigurator instance = new ChainedMetricDimensionConfigurator(first, second);
int responseStatusCode = 242;
int responseStatusCodeXXValue = 2;
long elapsedTimeMillis = 42;
String endpointClass = UUID.randomUUID().toString();
String method = UUID.randomUUID().toString();
BuilderTagger origBuilderMock = mock(BuilderTagger.class);
BuilderTagger firstResultBuilderMock = mock(BuilderTagger.class);
BuilderTagger secondResultBuilderMock = mock(BuilderTagger.class);
doReturn(firstResultBuilderMock).when(first).setupMetricWithDimensions(any(BuilderTagger.class), any(RequestInfo.class), any(ResponseInfo.class), any(HttpProcessingState.class), anyInt(), anyInt(), anyLong(), any(Endpoint.class), anyString(), anyString(), anyString());
doReturn(secondResultBuilderMock).when(second).setupMetricWithDimensions(any(BuilderTagger.class), any(RequestInfo.class), any(ResponseInfo.class), any(HttpProcessingState.class), anyInt(), anyInt(), anyLong(), any(Endpoint.class), anyString(), anyString(), anyString());
// when
BuilderTagger finalResult = instance.setupMetricWithDimensions(origBuilderMock, requestInfoMock, responseInfoMock, httpStateMock, responseStatusCode, responseStatusCodeXXValue, elapsedTimeMillis, endpointMock, endpointClass, method, matchingPathTemplate);
// then
verify(first).setupMetricWithDimensions(origBuilderMock, requestInfoMock, responseInfoMock, httpStateMock, responseStatusCode, responseStatusCodeXXValue, elapsedTimeMillis, endpointMock, endpointClass, method, matchingPathTemplate);
verify(second).setupMetricWithDimensions(firstResultBuilderMock, requestInfoMock, responseInfoMock, httpStateMock, responseStatusCode, responseStatusCodeXXValue, elapsedTimeMillis, endpointMock, endpointClass, method, matchingPathTemplate);
assertThat(finalResult).isSameAs(secondResultBuilderMock);
}
use of com.signalfx.codahale.reporter.MetricMetadata.BuilderTagger in project riposte by Nike-Inc.
the class SignalFxEndpointMetricsHandlerTest method DefaultMetricDimensionConfigurator_setupMetricWithDimensions_works_as_expected.
@Test
public void DefaultMetricDimensionConfigurator_setupMetricWithDimensions_works_as_expected() {
// given
BuilderTagger builderMock = mock(BuilderTagger.class);
doReturn(builderMock).when(builderMock).withMetricName(anyString());
doReturn(builderMock).when(builderMock).withDimension(anyString(), anyString());
String metricName = UUID.randomUUID().toString();
String responseCodeDimKey = UUID.randomUUID().toString();
String uriDimKey = UUID.randomUUID().toString();
String methodDimKey = UUID.randomUUID().toString();
String endpointDimKey = UUID.randomUUID().toString();
DefaultMetricDimensionConfigurator instance = new DefaultMetricDimensionConfigurator(metricName, responseCodeDimKey, uriDimKey, methodDimKey, endpointDimKey);
int responseStatusCode = 242;
int responseStatusCodeXXValue = 2;
long elapsedTimeMillis = 42;
String endpointClass = UUID.randomUUID().toString();
String method = UUID.randomUUID().toString();
// when
BuilderTagger result = instance.setupMetricWithDimensions(builderMock, requestInfoMock, responseInfoMock, httpStateMock, responseStatusCode, responseStatusCodeXXValue, elapsedTimeMillis, endpointMock, endpointClass, method, matchingPathTemplate);
// then
assertThat(result).isSameAs(builderMock);
verify(builderMock).withMetricName(metricName);
verify(builderMock).withDimension(responseCodeDimKey, String.valueOf(responseStatusCode));
verify(builderMock).withDimension(uriDimKey, matchingPathTemplate);
verify(builderMock).withDimension(methodDimKey, method);
verify(builderMock).withDimension(endpointDimKey, endpointClass);
verifyNoMoreInteractions(builderMock);
}
Aggregations