Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ buildscript {
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.4'
classpath 'com.netflix.nebula:gradle-info-plugin:5.1.1'
classpath 'com.netflix.nebula:nebula-publishing-plugin:14.0.0'
classpath 'com.palantir.baseline:gradle-baseline-java:2.17.0'
classpath 'com.palantir.baseline:gradle-baseline-java:2.18.0'
classpath 'com.palantir.gradle.consistentversions:gradle-consistent-versions:1.12.4'
classpath 'com.palantir.gradle.gitversion:gradle-git-version:0.12.2'
classpath 'gradle.plugin.org.inferred:gradle-processors:3.1.0'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,15 +91,15 @@ public void after() {
@Test
public void testInstrument() {
assertThat(delegate.invocationCount()).isZero();
assertThat(metricRegistry.getTimers().get(Runnable.class.getName())).isNull();
assertThat(metricRegistry.getTimers()).doesNotContainKey(Runnable.class.getName());

instrumentedService.test();
assertThat(delegate.invocationCount()).isOne();

SortedMap<String, Timer> timers = metricRegistry.getTimers();
assertThat(timers.keySet()).hasSize(1);
assertThat(timers.keySet()).isEqualTo(ImmutableSet.of(EXPECTED_METRIC_NAME));
assertThat(timers.get(EXPECTED_METRIC_NAME)).isNotNull();
assertThat(timers).containsKey(EXPECTED_METRIC_NAME);
assertThat(timers.get(EXPECTED_METRIC_NAME).getCount()).isOne();

instrumentedService.test();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,15 +147,15 @@ void testBuilder() {
.build();

assertThat(delegate.invocationCount()).isZero();
assertThat(metricRegistry.getTimers().get(Runnable.class.getName())).isNull();
assertThat(metricRegistry.getTimers()).doesNotContainKey(Runnable.class.getName());

instrumentedService.test();
assertThat(delegate.invocationCount()).isOne();

SortedMap<String, Timer> timers = metricRegistry.getTimers();
assertThat(timers.keySet()).hasSize(1);
assertThat(timers.keySet()).isEqualTo(ImmutableSet.of(EXPECTED_METRIC_NAME));
assertThat(timers.get(EXPECTED_METRIC_NAME)).isNotNull();
assertThat(timers).containsKey(EXPECTED_METRIC_NAME);
assertThat(timers.get(EXPECTED_METRIC_NAME).getCount()).isOne();

executeManyTimes(instrumentedService, INVOCATION_ITERATIONS);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,34 +57,34 @@ void testFailure() throws Exception {

InvocationContext context = mock(InvocationContext.class);
when(context.getMethod()).thenReturn(String.class.getDeclaredMethod("length"));
assertThat(metricRegistry.getMeters().get("failures")).isNull();
assertThat(metricRegistry.getMeters()).doesNotContainKey("failures");

handler.onFailure(context, new RuntimeException("unexpected"));

assertThat(metricRegistry.getMeters().get("failures")).isNotNull();
assertThat(metricRegistry.getMeters()).containsKey("failures");
assertThat(metricRegistry.getMeters().get("failures").getCount()).isOne();
}

@Test
void testOnSuccessNullContext() {
MetricRegistry metricRegistry = new MetricRegistry();
MetricsInvocationEventHandler handler = new MetricsInvocationEventHandler(metricRegistry, "test");
assertThat(metricRegistry.getMeters().get("failures")).isNull();
assertThat(metricRegistry.getMeters()).doesNotContainKey("failures");

handler.onSuccess(null, new Object());

assertThat(metricRegistry.getMeters().get("failures")).isNull();
assertThat(metricRegistry.getMeters()).doesNotContainKey("failures");
}

@Test
void testOnFailureNullContext() {
MetricRegistry metricRegistry = new MetricRegistry();
MetricsInvocationEventHandler handler = new MetricsInvocationEventHandler(metricRegistry, "test");
assertThat(metricRegistry.getMeters().get("failures")).isNull();
assertThat(metricRegistry.getMeters()).doesNotContainKey("failures");

handler.onFailure(null, new RuntimeException("expected"));

assertThat(metricRegistry.getMeters().get("failures")).isNotNull();
assertThat(metricRegistry.getMeters()).containsKey("failures");
assertThat(metricRegistry.getMeters().get("failures").getCount()).isOne();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,11 @@ void estimatedSize() {

@Test
void maximumSize() {
assertThat(metrics.get("test.cache.maximum.size")).isNull();
assertThat(metrics).doesNotContainKey("test.cache.maximum.size");
}

@Test
void weightedSize() {
assertThat(metrics.get("test.cache.weighted.size")).isNull();
assertThat(metrics).doesNotContainKey("test.cache.weighted.size");
}
}