diff --git a/build.gradle b/build.gradle index 95cb5d216..e60484f1f 100644 --- a/build.gradle +++ b/build.gradle @@ -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.0' classpath 'com.netflix.nebula:nebula-publishing-plugin:13.6.1' - classpath 'com.palantir.baseline:gradle-baseline-java:2.12.0' + classpath 'com.palantir.baseline:gradle-baseline-java:2.13.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' diff --git a/tritium-caffeine/src/test/java/com/palantir/tritium/metrics/caffeine/CaffeineStatsTest.java b/tritium-caffeine/src/test/java/com/palantir/tritium/metrics/caffeine/CaffeineStatsTest.java index 21e6b5310..0a426191b 100644 --- a/tritium-caffeine/src/test/java/com/palantir/tritium/metrics/caffeine/CaffeineStatsTest.java +++ b/tritium-caffeine/src/test/java/com/palantir/tritium/metrics/caffeine/CaffeineStatsTest.java @@ -68,7 +68,7 @@ void evictionCount() { @Test void hitCount() { - assertThat(stats.hitCount().getValue()).isEqualTo(1); + assertThat(stats.hitCount().getValue()).isOne(); verifyNoMoreInteractions(cache, policy, eviction); } diff --git a/tritium-lib/src/test/java/com/palantir/tritium/TritiumTest.java b/tritium-lib/src/test/java/com/palantir/tritium/TritiumTest.java index ccfcb0bb9..40d06274f 100644 --- a/tritium-lib/src/test/java/com/palantir/tritium/TritiumTest.java +++ b/tritium-lib/src/test/java/com/palantir/tritium/TritiumTest.java @@ -90,17 +90,17 @@ public void after() { @Test public void testInstrument() { - assertThat(delegate.invocationCount()).isEqualTo(0); + assertThat(delegate.invocationCount()).isZero(); assertThat(metricRegistry.getTimers().get(Runnable.class.getName())).isNull(); instrumentedService.test(); - assertThat(delegate.invocationCount()).isEqualTo(1); + assertThat(delegate.invocationCount()).isOne(); SortedMap 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.get(EXPECTED_METRIC_NAME).getCount()).isEqualTo(1); + assertThat(timers.get(EXPECTED_METRIC_NAME).getCount()).isOne(); instrumentedService.test(); @@ -112,13 +112,13 @@ public void testInstrument() { @Test public void testInstrumentWithTags() { - assertThat(delegate.invocationCount()).isEqualTo(0); + assertThat(delegate.invocationCount()).isZero(); assertThat(taggedMetricRegistry.getMetrics()) // The global failures metric is created eagerly .containsOnlyKeys(MetricName.builder().safeName("failures").build()); taggedInstrumentedService.test(); - assertThat(delegate.invocationCount()).isEqualTo(1); + assertThat(delegate.invocationCount()).isOne(); Map metrics = taggedMetricRegistry.getMetrics(); assertThat(metrics.keySet()) @@ -126,7 +126,7 @@ public void testInstrumentWithTags() { Metric actual = metrics.get(EXPECTED_TAGGED_METRIC_NAME); assertThat(actual).isInstanceOf(Timer.class); Timer timer = (Timer) actual; - assertThat(timer.getCount()).isEqualTo(1); + assertThat(timer.getCount()).isOne(); taggedInstrumentedService.test(); @@ -147,12 +147,10 @@ public void rethrowOutOfMemoryErrorMetrics() { String methodMetricName = MetricRegistry.name(TestInterface.class, "throwsOutOfMemoryError"); assertThat(metricRegistry.meter( MetricRegistry.name(methodMetricName, "failures")) - .getCount()) - .isEqualTo(0); + .getCount()).isZero(); assertThat(metricRegistry.meter( MetricRegistry.name(methodMetricName, "failures", "java.lang.OutOfMemoryError")) - .getCount()) - .isEqualTo(0); + .getCount()).isZero(); assertThatThrownBy(instrumentedService::throwsOutOfMemoryError) .isInstanceOf(OutOfMemoryError.class) @@ -160,12 +158,10 @@ public void rethrowOutOfMemoryErrorMetrics() { assertThat(metricRegistry.meter( MetricRegistry.name(methodMetricName, "failures")) - .getCount()) - .isEqualTo(1); + .getCount()).isOne(); assertThat(metricRegistry.meter( MetricRegistry.name(methodMetricName, "failures", "java.lang.OutOfMemoryError")) - .getCount()) - .isEqualTo(1); + .getCount()).isOne(); } @Test diff --git a/tritium-lib/src/test/java/com/palantir/tritium/event/log/LoggingInstrumentationTest.java b/tritium-lib/src/test/java/com/palantir/tritium/event/log/LoggingInstrumentationTest.java index ebea74892..c97157697 100644 --- a/tritium-lib/src/test/java/com/palantir/tritium/event/log/LoggingInstrumentationTest.java +++ b/tritium-lib/src/test/java/com/palantir/tritium/event/log/LoggingInstrumentationTest.java @@ -67,9 +67,9 @@ public void testNoLogging() { Runnable instrumentedService = Instrumentation.builder(Runnable.class, delegate) .withLogging(logger, LoggingLevel.TRACE, LoggingInvocationEventHandler.LOG_ALL_DURATIONS) .build(); - assertThat(delegate.invocationCount()).isEqualTo(0); + assertThat(delegate.invocationCount()).isZero(); instrumentedService.run(); - assertThat(delegate.invocationCount()).isEqualTo(1); + assertThat(delegate.invocationCount()).isOne(); } @Test @@ -86,11 +86,11 @@ public String test() { TestInterface instrumentedService = Instrumentation.builder(TestInterface.class, delegate) .withLogging(logger, LoggingLevel.ERROR, LoggingInvocationEventHandler.NEVER_LOG) .build(); - assertThat(delegate.invocationCount()).isEqualTo(0); + assertThat(delegate.invocationCount()).isZero(); assertThatExceptionOfType(RuntimeException.class) .isThrownBy(instrumentedService::test) .withMessage("expected"); - assertThat(delegate.invocationCount()).isEqualTo(1); + assertThat(delegate.invocationCount()).isOne(); } @@ -112,7 +112,7 @@ private static void testLoggingAtLevel(LoggingLevel level) { assertThat(LoggingInvocationEventHandler.isEnabled(logger, level)).isTrue(); - assertThat(delegate.invocationCount()).isEqualTo(0); + assertThat(delegate.invocationCount()).isZero(); instrumented.multiArgumentMethod("test", 1, Collections.singletonList("hello")); @@ -133,7 +133,7 @@ private static void testLoggingAtLevel(LoggingLevel level) { assertThat(logger.isTraceEnabled()).isTrue(); break; } - assertThat(delegate.invocationCount()).isEqualTo(1); + assertThat(delegate.invocationCount()).isOne(); } diff --git a/tritium-lib/src/test/java/com/palantir/tritium/proxy/InstrumentationTest.java b/tritium-lib/src/test/java/com/palantir/tritium/proxy/InstrumentationTest.java index 8e3904e44..4a86e8c8b 100644 --- a/tritium-lib/src/test/java/com/palantir/tritium/proxy/InstrumentationTest.java +++ b/tritium-lib/src/test/java/com/palantir/tritium/proxy/InstrumentationTest.java @@ -146,17 +146,17 @@ void testBuilder() { .withPerformanceTraceLogging() .build(); - assertThat(delegate.invocationCount()).isEqualTo(0); + assertThat(delegate.invocationCount()).isZero(); assertThat(metricRegistry.getTimers().get(Runnable.class.getName())).isNull(); instrumentedService.test(); - assertThat(delegate.invocationCount()).isEqualTo(1); + assertThat(delegate.invocationCount()).isOne(); SortedMap 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.get(EXPECTED_METRIC_NAME).getCount()).isEqualTo(1); + assertThat(timers.get(EXPECTED_METRIC_NAME).getCount()).isOne(); executeManyTimes(instrumentedService, INVOCATION_ITERATIONS); Slf4jReporter.forRegistry(metricRegistry).withLoggingLevel(LoggingLevel.INFO).build().report(); @@ -185,9 +185,9 @@ void testMetricGroupBuilder() { assertThat(metricRegistry.timer(AnnotatedInterface.class.getName() + ".ONE").getCount()).isEqualTo(2L); assertThat(metricRegistry.timer(globalPrefix + ".ONE").getCount()).isEqualTo(2L); - assertThat(metricRegistry.timer(AnnotatedInterface.class.getName() + ".DEFAULT").getCount()).isEqualTo(1L); - assertThat(metricRegistry.timer(globalPrefix + ".DEFAULT").getCount()).isEqualTo(1L); - assertThat(metricRegistry.timer(AnnotatedInterface.class.getName() + ".method").getCount()).isEqualTo(1L); + assertThat(metricRegistry.timer(AnnotatedInterface.class.getName() + ".DEFAULT").getCount()).isOne(); + assertThat(metricRegistry.timer(globalPrefix + ".DEFAULT").getCount()).isOne(); + assertThat(metricRegistry.timer(AnnotatedInterface.class.getName() + ".method").getCount()).isOne(); } private void executeManyTimes(TestInterface instrumentedService, int invocations) { @@ -360,9 +360,9 @@ void testTaggedMetrics() { .withTaggedMetrics(taggedMetricRegistry, "testPrefix") .withMetrics(metrics) .build(); - assertThat(delegate.invocationCount()).isEqualTo(0); + assertThat(delegate.invocationCount()).isZero(); runnable.test(); - assertThat(delegate.invocationCount()).isEqualTo(1); + assertThat(delegate.invocationCount()).isOne(); Map taggedMetrics = taggedMetricRegistry.getMetrics(); assertThat(taggedMetrics.keySet()).containsExactly( MetricName.builder() diff --git a/tritium-metrics/src/test/java/com/palantir/tritium/event/metrics/MetricsInvocationEventHandlerTest.java b/tritium-metrics/src/test/java/com/palantir/tritium/event/metrics/MetricsInvocationEventHandlerTest.java index e30750e61..33da59a46 100644 --- a/tritium-metrics/src/test/java/com/palantir/tritium/event/metrics/MetricsInvocationEventHandlerTest.java +++ b/tritium-metrics/src/test/java/com/palantir/tritium/event/metrics/MetricsInvocationEventHandlerTest.java @@ -62,7 +62,7 @@ void testFailure() throws Exception { handler.onFailure(context, new RuntimeException("unexpected")); assertThat(metricRegistry.getMeters().get("failures")).isNotNull(); - assertThat(metricRegistry.getMeters().get("failures").getCount()).isEqualTo(1L); + assertThat(metricRegistry.getMeters().get("failures").getCount()).isOne(); } @Test @@ -85,7 +85,7 @@ void testOnFailureNullContext() { handler.onFailure(null, new RuntimeException("expected")); assertThat(metricRegistry.getMeters().get("failures")).isNotNull(); - assertThat(metricRegistry.getMeters().get("failures").getCount()).isEqualTo(1L); + assertThat(metricRegistry.getMeters().get("failures").getCount()).isOne(); } @Test @@ -117,13 +117,13 @@ void testMetricGroupAnnotations() throws Exception { callVoidMethod(handler, obj, "methodA", /* success= */false); assertThat(metricRegistry.timer(obj.getClass().getName() + ".ONE").getCount()).isEqualTo(2L); - assertThat(metricRegistry.timer(obj.getClass().getName() + ".TWO").getCount()).isEqualTo(1L); - assertThat(metricRegistry.timer(obj.getClass().getName() + ".DEFAULT").getCount()).isEqualTo(1L); - assertThat(metricRegistry.timer(obj.getClass().getName() + ".ONE.failures").getCount()).isEqualTo(1L); + assertThat(metricRegistry.timer(obj.getClass().getName() + ".TWO").getCount()).isOne(); + assertThat(metricRegistry.timer(obj.getClass().getName() + ".DEFAULT").getCount()).isOne(); + assertThat(metricRegistry.timer(obj.getClass().getName() + ".ONE.failures").getCount()).isOne(); //AnnotatedOtherInterface callVoidMethod(otherHandler, other, "methodE", /* success= */true); - assertThat(metricRegistry.timer(other.getClass().getName() + ".DEFAULT").getCount()).isEqualTo(1L); + assertThat(metricRegistry.timer(other.getClass().getName() + ".DEFAULT").getCount()).isOne(); //GlobalPrefix Tests assertThat(metricRegistry.timer(globalPrefix + ".DEFAULT").getCount()).isEqualTo(2L); diff --git a/tritium-metrics/src/test/java/com/palantir/tritium/metrics/InstrumentedSslContextTest.java b/tritium-metrics/src/test/java/com/palantir/tritium/metrics/InstrumentedSslContextTest.java index 4a6563afb..0360eab5f 100644 --- a/tritium-metrics/src/test/java/com/palantir/tritium/metrics/InstrumentedSslContextTest.java +++ b/tritium-metrics/src/test/java/com/palantir/tritium/metrics/InstrumentedSslContextTest.java @@ -74,7 +74,7 @@ void testClientInstrumentationHttpsUrlConnection() throws Exception { .putSafeTags("protocol", ENABLED_PROTOCOL) .build(); assertThat(metrics.getMetrics()).containsOnlyKeys(name); - assertThat(metrics.meter(name).getCount()).isEqualTo(1); + assertThat(metrics.meter(name).getCount()).isOne(); } @Test @@ -101,7 +101,7 @@ void testClientInstrumentationOkHttp() throws Exception { .putSafeTags("protocol", ENABLED_PROTOCOL) .build(); assertThat(metrics.getMetrics()).containsOnlyKeys(name); - assertThat(metrics.meter(name).getCount()).isEqualTo(1); + assertThat(metrics.meter(name).getCount()).isOne(); } @Test @@ -129,7 +129,7 @@ void testClientInstrumentationOkHttpHttp2() throws Exception { .putSafeTags("protocol", ENABLED_PROTOCOL) .build(); assertThat(metrics.getMetrics()).containsOnlyKeys(name); - assertThat(metrics.meter(name).getCount()).isEqualTo(1); + assertThat(metrics.meter(name).getCount()).isOne(); } @Test @@ -155,7 +155,7 @@ void testServerInstrumentationHttp2() throws Exception { .putSafeTags("protocol", ENABLED_PROTOCOL) .build(); assertThat(metrics.getMetrics()).containsOnlyKeys(name); - assertThat(metrics.meter(name).getCount()).isEqualTo(1); + assertThat(metrics.meter(name).getCount()).isOne(); } @Test @@ -174,7 +174,7 @@ void testServerInstrumentation() throws Exception { .putSafeTags("protocol", ENABLED_PROTOCOL) .build(); assertThat(metrics.getMetrics()).containsOnlyKeys(name); - assertThat(metrics.meter(name).getCount()).isEqualTo(1); + assertThat(metrics.meter(name).getCount()).isOne(); } @Test diff --git a/tritium-metrics/src/test/java/com/palantir/tritium/metrics/MetricRegistriesTest.java b/tritium-metrics/src/test/java/com/palantir/tritium/metrics/MetricRegistriesTest.java index 95ddc7f15..67de0290b 100644 --- a/tritium-metrics/src/test/java/com/palantir/tritium/metrics/MetricRegistriesTest.java +++ b/tritium-metrics/src/test/java/com/palantir/tritium/metrics/MetricRegistriesTest.java @@ -100,14 +100,14 @@ void testHdrHistogram() { Histogram histogram = metrics.histogram("histogram"); histogram.update(42L); - assertThat(histogram.getCount()).isEqualTo(1); + assertThat(histogram.getCount()).isOne(); Snapshot histogramSnapshot = histogram.getSnapshot(); - assertThat(histogram.getCount()).isEqualTo(1); - assertThat(histogramSnapshot.size()).isEqualTo(1); + assertThat(histogram.getCount()).isOne(); + assertThat(histogramSnapshot.size()).isOne(); assertThat(histogramSnapshot.getMax()).isEqualTo(42); metrics.timer("timer").update(123, TimeUnit.MILLISECONDS); - assertThat(metrics.timer("timer").getCount()).isEqualTo(1); + assertThat(metrics.timer("timer").getCount()).isOne(); } @Test @@ -117,14 +117,14 @@ void testSlidingTimeWindowHistogram() { Histogram histogram = metrics.histogram("histogram"); histogram.update(42L); - assertThat(histogram.getCount()).isEqualTo(1); + assertThat(histogram.getCount()).isOne(); Snapshot histogramSnapshot = histogram.getSnapshot(); - assertThat(histogram.getCount()).isEqualTo(1); - assertThat(histogramSnapshot.size()).isEqualTo(1); + assertThat(histogram.getCount()).isOne(); + assertThat(histogramSnapshot.size()).isOne(); assertThat(histogramSnapshot.getMax()).isEqualTo(42); metrics.timer("timer").update(123, TimeUnit.MILLISECONDS); - assertThat(metrics.timer("timer").getCount()).isEqualTo(1); + assertThat(metrics.timer("timer").getCount()).isOne(); } @Test @@ -139,10 +139,10 @@ void testSlidingTimeWindowHistogramExpiery() { Histogram histogram = metrics.histogram("histogram"); histogram.update(42L); - assertThat(histogram.getCount()).isEqualTo(1); + assertThat(histogram.getCount()).isOne(); Snapshot histogramSnapshot = histogram.getSnapshot(); - assertThat(histogram.getCount()).isEqualTo(1); - assertThat(histogramSnapshot.size()).isEqualTo(1); + assertThat(histogram.getCount()).isOne(); + assertThat(histogramSnapshot.size()).isOne(); assertThat(histogramSnapshot.getMax()).isEqualTo(42); clock.advance(window / 2, windowUnit); @@ -157,17 +157,17 @@ void testSlidingTimeWindowHistogramExpiery() { histogramSnapshot = histogram.getSnapshot(); assertThat(histogram.getCount()).isEqualTo(2); - assertThat(histogramSnapshot.size()).isEqualTo(1); + assertThat(histogramSnapshot.size()).isOne(); assertThat(histogramSnapshot.getMax()).isEqualTo(1337); clock.advance(window, windowUnit); histogramSnapshot = histogram.getSnapshot(); assertThat(histogram.getCount()).isEqualTo(2); - assertThat(histogramSnapshot.size()).isEqualTo(0); + assertThat(histogramSnapshot.size()).isZero(); metrics.timer("timer").update(123, TimeUnit.MILLISECONDS); - assertThat(metrics.timer("timer").getCount()).isEqualTo(1); + assertThat(metrics.timer("timer").getCount()).isOne(); } @Test @@ -177,14 +177,14 @@ void testDecayingHistogramReservoirs() { Histogram histogram = metrics.histogram("histogram"); histogram.update(42L); - assertThat(histogram.getCount()).isEqualTo(1); + assertThat(histogram.getCount()).isOne(); Snapshot histogramSnapshot = histogram.getSnapshot(); - assertThat(histogram.getCount()).isEqualTo(1); - assertThat(histogramSnapshot.size()).isEqualTo(1); + assertThat(histogram.getCount()).isOne(); + assertThat(histogramSnapshot.size()).isOne(); assertThat(histogramSnapshot.getMax()).isEqualTo(42); metrics.timer("timer").update(123, TimeUnit.MILLISECONDS); - assertThat(metrics.timer("timer").getCount()).isEqualTo(1); + assertThat(metrics.timer("timer").getCount()).isOne(); } @Test diff --git a/tritium-metrics/src/test/java/com/palantir/tritium/metrics/TaggedMetricsExecutorServiceTest.java b/tritium-metrics/src/test/java/com/palantir/tritium/metrics/TaggedMetricsExecutorServiceTest.java index e5cd13479..022d4ae04 100644 --- a/tritium-metrics/src/test/java/com/palantir/tritium/metrics/TaggedMetricsExecutorServiceTest.java +++ b/tritium-metrics/src/test/java/com/palantir/tritium/metrics/TaggedMetricsExecutorServiceTest.java @@ -47,11 +47,11 @@ void testMetrics(TaggedMetricRegistry registry) throws Exception { assertThat(registry.getMetrics()) .containsKeys(SUBMITTED, RUNNING, COMPLETED, DURATION, QUEUED_DURATION); - assertThat(registry.meter(SUBMITTED).getCount()).isEqualTo(0); - assertThat(registry.counter(RUNNING).getCount()).isEqualTo(0); - assertThat(registry.meter(COMPLETED).getCount()).isEqualTo(0); - assertThat(registry.timer(DURATION).getCount()).isEqualTo(0); - assertThat(registry.timer(QUEUED_DURATION).getCount()).isEqualTo(0); + assertThat(registry.meter(SUBMITTED).getCount()).isZero(); + assertThat(registry.counter(RUNNING).getCount()).isZero(); + assertThat(registry.meter(COMPLETED).getCount()).isZero(); + assertThat(registry.timer(DURATION).getCount()).isZero(); + assertThat(registry.timer(QUEUED_DURATION).getCount()).isZero(); CountDownLatch startLatch = new CountDownLatch(1); CountDownLatch finishLatch = new CountDownLatch(1); @@ -64,20 +64,20 @@ void testMetrics(TaggedMetricRegistry registry) throws Exception { executorService.shutdown(); startLatch.await(); - assertThat(registry.meter(SUBMITTED).getCount()).isEqualTo(1); - assertThat(registry.counter(RUNNING).getCount()).isEqualTo(1); - assertThat(registry.meter(COMPLETED).getCount()).isEqualTo(0); - assertThat(registry.timer(DURATION).getCount()).isEqualTo(0); - assertThat(registry.timer(QUEUED_DURATION).getCount()).isEqualTo(1); + assertThat(registry.meter(SUBMITTED).getCount()).isOne(); + assertThat(registry.counter(RUNNING).getCount()).isOne(); + assertThat(registry.meter(COMPLETED).getCount()).isZero(); + assertThat(registry.timer(DURATION).getCount()).isZero(); + assertThat(registry.timer(QUEUED_DURATION).getCount()).isOne(); finishLatch.countDown(); future.get(); - assertThat(registry.meter(SUBMITTED).getCount()).isEqualTo(1); - assertThat(registry.counter(RUNNING).getCount()).isEqualTo(0); - assertThat(registry.meter(COMPLETED).getCount()).isEqualTo(1); - assertThat(registry.timer(DURATION).getCount()).isEqualTo(1); - assertThat(registry.timer(QUEUED_DURATION).getCount()).isEqualTo(1); + assertThat(registry.meter(SUBMITTED).getCount()).isOne(); + assertThat(registry.counter(RUNNING).getCount()).isZero(); + assertThat(registry.meter(COMPLETED).getCount()).isOne(); + assertThat(registry.timer(DURATION).getCount()).isOne(); + assertThat(registry.timer(QUEUED_DURATION).getCount()).isOne(); } private static MetricName metricName(String metricName) { diff --git a/tritium-metrics/src/test/java/com/palantir/tritium/metrics/TaggedMetricsScheduledExecutorServiceTest.java b/tritium-metrics/src/test/java/com/palantir/tritium/metrics/TaggedMetricsScheduledExecutorServiceTest.java index 79eff3dbd..6b0a87005 100644 --- a/tritium-metrics/src/test/java/com/palantir/tritium/metrics/TaggedMetricsScheduledExecutorServiceTest.java +++ b/tritium-metrics/src/test/java/com/palantir/tritium/metrics/TaggedMetricsScheduledExecutorServiceTest.java @@ -53,10 +53,10 @@ void testMetrics(TaggedMetricRegistry registry) throws Exception { assertThat(registry.getMetrics()) .containsKeys(SUBMITTED, RUNNING, COMPLETED, DURATION); - assertThat(registry.meter(SUBMITTED).getCount()).isEqualTo(0); - assertThat(registry.counter(RUNNING).getCount()).isEqualTo(0); - assertThat(registry.meter(COMPLETED).getCount()).isEqualTo(0); - assertThat(registry.timer(DURATION).getCount()).isEqualTo(0); + assertThat(registry.meter(SUBMITTED).getCount()).isZero(); + assertThat(registry.counter(RUNNING).getCount()).isZero(); + assertThat(registry.meter(COMPLETED).getCount()).isZero(); + assertThat(registry.timer(DURATION).getCount()).isZero(); CountDownLatch startLatch = new CountDownLatch(1); CountDownLatch finishLatch = new CountDownLatch(1); @@ -69,18 +69,18 @@ void testMetrics(TaggedMetricRegistry registry) throws Exception { executorService.shutdown(); startLatch.await(); - assertThat(registry.meter(SUBMITTED).getCount()).isEqualTo(1); - assertThat(registry.counter(RUNNING).getCount()).isEqualTo(1); - assertThat(registry.meter(COMPLETED).getCount()).isEqualTo(0); - assertThat(registry.timer(DURATION).getCount()).isEqualTo(0); + assertThat(registry.meter(SUBMITTED).getCount()).isOne(); + assertThat(registry.counter(RUNNING).getCount()).isOne(); + assertThat(registry.meter(COMPLETED).getCount()).isZero(); + assertThat(registry.timer(DURATION).getCount()).isZero(); finishLatch.countDown(); future.get(); - assertThat(registry.meter(SUBMITTED).getCount()).isEqualTo(1); - assertThat(registry.counter(RUNNING).getCount()).isEqualTo(0); - assertThat(registry.meter(COMPLETED).getCount()).isEqualTo(1); - assertThat(registry.timer(DURATION).getCount()).isEqualTo(1); + assertThat(registry.meter(SUBMITTED).getCount()).isOne(); + assertThat(registry.counter(RUNNING).getCount()).isZero(); + assertThat(registry.meter(COMPLETED).getCount()).isOne(); + assertThat(registry.timer(DURATION).getCount()).isOne(); } @ParameterizedTest @@ -91,22 +91,22 @@ void testScheduledMetrics(TaggedMetricRegistry registry) { assertThat(registry.getMetrics()) .containsKeys(SCHEDULED_ONCE, SCHEDULED_REPETITIVELY); - assertThat(registry.meter(SCHEDULED_ONCE).getCount()).isEqualTo(0); - assertThat(registry.meter(SCHEDULED_REPETITIVELY).getCount()).isEqualTo(0); + assertThat(registry.meter(SCHEDULED_ONCE).getCount()).isZero(); + assertThat(registry.meter(SCHEDULED_REPETITIVELY).getCount()).isZero(); assertThat((Future) executorService.schedule(() -> { }, 1L, TimeUnit.DAYS)).isNotNull(); - assertThat(registry.meter(SCHEDULED_ONCE).getCount()).isEqualTo(1); - assertThat(registry.meter(SCHEDULED_REPETITIVELY).getCount()).isEqualTo(0); + assertThat(registry.meter(SCHEDULED_ONCE).getCount()).isOne(); + assertThat(registry.meter(SCHEDULED_REPETITIVELY).getCount()).isZero(); assertThat((Future) executorService.scheduleAtFixedRate(() -> { }, 1L, 1L, TimeUnit.DAYS)).isNotNull(); - assertThat(registry.meter(SCHEDULED_ONCE).getCount()).isEqualTo(1); - assertThat(registry.meter(SCHEDULED_REPETITIVELY).getCount()).isEqualTo(1); + assertThat(registry.meter(SCHEDULED_ONCE).getCount()).isOne(); + assertThat(registry.meter(SCHEDULED_REPETITIVELY).getCount()).isOne(); assertThat((Future) executorService.scheduleWithFixedDelay(() -> { }, 1L, 1L, TimeUnit.DAYS)).isNotNull(); - assertThat(registry.meter(SCHEDULED_ONCE).getCount()).isEqualTo(1); + assertThat(registry.meter(SCHEDULED_ONCE).getCount()).isOne(); assertThat(registry.meter(SCHEDULED_REPETITIVELY).getCount()).isEqualTo(2); } @@ -118,8 +118,8 @@ void testScheduledDurationMetrics(TaggedMetricRegistry registry) throws Exceptio assertThat(registry.getMetrics()) .containsKeys(SCHEDULED_OVERRAN, SCHEDULED_PERCENT_OF_PERIOD); - assertThat(registry.counter(SCHEDULED_OVERRAN).getCount()).isEqualTo(0); - assertThat(registry.histogram(SCHEDULED_PERCENT_OF_PERIOD).getCount()).isEqualTo(0); + assertThat(registry.counter(SCHEDULED_OVERRAN).getCount()).isZero(); + assertThat(registry.histogram(SCHEDULED_PERCENT_OF_PERIOD).getCount()).isZero(); Semaphore startSemaphore = new Semaphore(0); Semaphore finishSemaphore = new Semaphore(1); @@ -131,14 +131,14 @@ void testScheduledDurationMetrics(TaggedMetricRegistry registry) throws Exceptio startSemaphore.acquire(2); - assertThat(registry.counter(SCHEDULED_OVERRAN).getCount()).isEqualTo(0); - assertThat(registry.histogram(SCHEDULED_PERCENT_OF_PERIOD).getCount()).isEqualTo(1); + assertThat(registry.counter(SCHEDULED_OVERRAN).getCount()).isZero(); + assertThat(registry.histogram(SCHEDULED_PERCENT_OF_PERIOD).getCount()).isOne(); TimeUnit.MILLISECONDS.sleep(2); finishSemaphore.release(); startSemaphore.acquire(); - assertThat(registry.counter(SCHEDULED_OVERRAN).getCount()).isEqualTo(1); + assertThat(registry.counter(SCHEDULED_OVERRAN).getCount()).isOne(); assertThat(registry.histogram(SCHEDULED_PERCENT_OF_PERIOD).getCount()).isEqualTo(2); } diff --git a/tritium-registry/src/test/java/com/palantir/tritium/metrics/registry/TaggedMetricRegistryTest.java b/tritium-registry/src/test/java/com/palantir/tritium/metrics/registry/TaggedMetricRegistryTest.java index 026daea61..00bb6766a 100644 --- a/tritium-registry/src/test/java/com/palantir/tritium/metrics/registry/TaggedMetricRegistryTest.java +++ b/tritium-registry/src/test/java/com/palantir/tritium/metrics/registry/TaggedMetricRegistryTest.java @@ -93,7 +93,7 @@ void testGauge(TaggedMetricRegistry registry) { Gauge gauge1 = registry.gauge(METRIC_1, () -> 1); Gauge gauge2 = registry.gauge(METRIC_2, () -> 2); - assertThat(gauge1.getValue()).isEqualTo(1); + assertThat(gauge1.getValue()).isOne(); assertThat(gauge2.getValue()).isEqualTo(2); assertThat(gauge1).isNotSameAs(gauge2); @@ -233,7 +233,7 @@ void testGetMetrics(TaggedMetricRegistry registry) { .putSafeTags("tagA", Long.toString(1)) .putSafeTags("tagB", Integer.toString(2)) .build())); - assertThat(counter.getCount()).isEqualTo(1); + assertThat(counter.getCount()).isOne(); } private static void assertMetric(