use of com.signalfx.codahale.reporter.MetricMetadata in project riposte by Nike-Inc.
the class SignalFxEndpointMetricsHandlerTest method wireUpReporterForConstructor.
private MetricMetadata wireUpReporterForConstructor(SignalFxReporter reporterMock) {
MetricMetadata metricMetadataMock = mock(MetricMetadata.class);
doReturn(metricMetadataMock).when(reporterMock).getMetricMetadata();
return metricMetadataMock;
}
use of com.signalfx.codahale.reporter.MetricMetadata in project riposte by Nike-Inc.
the class SignalFxEndpointMetricsHandlerTest method two_arg_constructor_sets_fields_as_expected.
@Test
public void two_arg_constructor_sets_fields_as_expected() {
// given
SignalFxReporterFactory reporterFactoryMock = mock(SignalFxReporterFactory.class);
Pair<Pair<SignalFxReporter, MetricMetadata>, Pair<Long, TimeUnit>> wiredUpMocksAndData = wireUpReporterFactoryMockForConstructor(reporterFactoryMock, metricRegistryMock);
MetricMetadata expectedMetricMetadata = wiredUpMocksAndData.getLeft().getRight();
long expectedReportingInterval = wiredUpMocksAndData.getRight().getLeft();
TimeUnit expectedReportingTimeUnit = wiredUpMocksAndData.getRight().getRight();
// when
SignalFxEndpointMetricsHandler instance = new SignalFxEndpointMetricsHandler(reporterFactoryMock, metricRegistryMock);
// then
assertThat(instance.metricMetadata).isSameAs(expectedMetricMetadata);
assertThat(instance.metricRegistry).isSameAs(metricRegistryMock);
assertThat(instance.requestTimerBuilder).isInstanceOf(RollingWindowTimerBuilder.class);
RollingWindowTimerBuilder rwtb = (RollingWindowTimerBuilder) instance.requestTimerBuilder;
assertThat(rwtb.amount).isEqualTo(expectedReportingInterval);
assertThat(rwtb.timeUnit).isEqualTo(expectedReportingTimeUnit);
assertThat(instance.requestTimerDimensionConfigurator).isSameAs(DEFAULT_REQUEST_LATENCY_TIMER_DIMENSION_CONFIGURATOR);
}
use of com.signalfx.codahale.reporter.MetricMetadata in project riposte by Nike-Inc.
the class SignalFxEndpointMetricsHandlerTest method wireUpReporterFactoryMockForConstructor.
private Pair<Pair<SignalFxReporter, MetricMetadata>, Pair<Long, TimeUnit>> wireUpReporterFactoryMockForConstructor(SignalFxReporterFactory factoryMock, MetricRegistry expectedMetricRegistry) {
SignalFxReporter reporterMock = mock(SignalFxReporter.class);
doReturn(reporterMock).when(factoryMock).getReporter(expectedMetricRegistry);
MetricMetadata metricMetadataMock = wireUpReporterForConstructor(reporterMock);
long reportingInterval = 42;
TimeUnit reportingTimeUnit = TimeUnit.DAYS;
doReturn(reportingInterval).when(factoryMock).getInterval();
doReturn(reportingTimeUnit).when(factoryMock).getTimeUnit();
return Pair.of(Pair.of(reporterMock, metricMetadataMock), Pair.of(reportingInterval, reportingTimeUnit));
}
use of com.signalfx.codahale.reporter.MetricMetadata in project riposte by Nike-Inc.
the class SignalFxEndpointMetricsHandlerTest method three_arg_constructor_sets_fields_as_expected.
@Test
public void three_arg_constructor_sets_fields_as_expected() {
// given
SignalFxReporter reporterMock = mock(SignalFxReporter.class);
MetricMetadata expectedMetricMetadata = wireUpReporterForConstructor(reporterMock);
Pair<Long, TimeUnit> reportingFrequency = Pair.of(42L, TimeUnit.DAYS);
// when
SignalFxEndpointMetricsHandler instance = new SignalFxEndpointMetricsHandler(reporterMock, reportingFrequency, metricRegistryMock);
// then
assertThat(instance.metricMetadata).isSameAs(expectedMetricMetadata);
assertThat(instance.metricRegistry).isSameAs(metricRegistryMock);
assertThat(instance.requestTimerBuilder).isInstanceOf(RollingWindowTimerBuilder.class);
RollingWindowTimerBuilder rwtb = (RollingWindowTimerBuilder) instance.requestTimerBuilder;
assertThat(rwtb.amount).isEqualTo(reportingFrequency.getLeft());
assertThat(rwtb.timeUnit).isEqualTo(reportingFrequency.getRight());
assertThat(instance.requestTimerDimensionConfigurator).isSameAs(DEFAULT_REQUEST_LATENCY_TIMER_DIMENSION_CONFIGURATOR);
}
use of com.signalfx.codahale.reporter.MetricMetadata in project riposte by Nike-Inc.
the class SignalFxEndpointMetricsHandlerTest method kitchen_sink_constructor_fails_with_IllegalArgumentException_if_certain_args_are_null.
@DataProvider(value = { "true | false | false | signalFxReporterMetricMetadata cannot be null", "false | true | false | metricRegistry cannot be null", "false | false | true | requestTimerBuilder cannot be null" }, splitBy = "\\|")
@Test
public void kitchen_sink_constructor_fails_with_IllegalArgumentException_if_certain_args_are_null(boolean metadataIsNull, boolean registryIsNull, boolean timerBuilderIsNull, String expectedMessage) {
// given
MetricMetadata metricMetadata = (metadataIsNull) ? null : metricMetadataMock;
MetricRegistry registry = (registryIsNull) ? null : metricRegistryMock;
MetricBuilder<Timer> timerBuilder = (timerBuilderIsNull) ? null : requestTimerBuilderMock;
// when
Throwable ex = catchThrowable(() -> new SignalFxEndpointMetricsHandler(metricMetadata, registry, timerBuilder, null));
// then
assertThat(ex).isInstanceOf(IllegalArgumentException.class).hasMessage(expectedMessage);
}
Aggregations