From 22ae5caf4c4febb03b9994c7cb1058fb54e3b5bb Mon Sep 17 00:00:00 2001 From: Dhrubajyoti Sadhu Date: Wed, 16 Aug 2023 16:27:24 +0100 Subject: [PATCH] Tested the tags to verify the changes. --- .../metrics/MonitoredAspectTest.java | 21 ++++++++----------- 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/waggle-dance-core/src/test/java/com/hotels/bdp/waggledance/metrics/MonitoredAspectTest.java b/waggle-dance-core/src/test/java/com/hotels/bdp/waggledance/metrics/MonitoredAspectTest.java index cb040708f..33adfc61b 100644 --- a/waggle-dance-core/src/test/java/com/hotels/bdp/waggledance/metrics/MonitoredAspectTest.java +++ b/waggle-dance-core/src/test/java/com/hotels/bdp/waggledance/metrics/MonitoredAspectTest.java @@ -20,7 +20,6 @@ import static org.mockito.Mockito.reset; import static org.mockito.Mockito.when; -import java.util.ArrayList; import java.util.Collection; import org.aspectj.lang.ProceedingJoinPoint; @@ -33,8 +32,6 @@ import io.micrometer.core.instrument.Meter; import io.micrometer.core.instrument.MeterRegistry; -import io.micrometer.core.instrument.cumulative.CumulativeCounter; -import io.micrometer.core.instrument.cumulative.CumulativeTimer; import io.micrometer.core.instrument.search.RequiredSearch; import io.micrometer.core.instrument.simple.SimpleMeterRegistry; @@ -119,29 +116,29 @@ public void monitorSuccesses() throws Throwable { public void monitorSuccessWithTags() throws Throwable { aspect.monitor(pjp, monitored); - Collection successMeters = meterRegistry.get("counter.Type_Anonymous.success").meters(); - assertThat(successMeters.size(), is(1)); - assertThat(((CumulativeCounter) ((ArrayList) successMeters).get(0)).count(), is(1.0)); + RequiredSearch rs = meterRegistry.get("counter.Type_Anonymous.success"); + assertThat(rs.counter().count(), is(1.0)); - Collection callsMeters = meterRegistry.get("counter.Type_Anonymous.calls").meters(); - assertThat(callsMeters.size(), is(1)); - assertThat(((CumulativeCounter) ((ArrayList) callsMeters).get(0)).count(), is(1.0)); + rs = meterRegistry.get("counter.Type_Anonymous.calls"); + assertThat(rs.counter().count(), is(1.0)); - Collection durationMeters = meterRegistry.get("timer.Type_Anonymous.duration").meters(); - assertThat(durationMeters.size(), is(1)); - assertThat(((CumulativeTimer) ((ArrayList) durationMeters).get(0)).count(), is(1L)); + rs = meterRegistry.get("timer.Type_Anonymous.duration"); + assertThat(rs.timer().count(), is(1L)); // Verify the tags for successMeters + Collection successMeters = meterRegistry.get("counter.Type_Anonymous.success").meters(); Meter successMeter = successMeters.iterator().next(); assertThat(successMeter.getId().getTag("federation_namespace"), is("all")); assertThat(successMeter.getId().getTag("method_name"), is("myMethod")); // Verify the tags for callsMeters + Collection callsMeters = meterRegistry.get("counter.Type_Anonymous.calls").meters(); Meter callsMeter = callsMeters.iterator().next(); assertThat(callsMeter.getId().getTag("federation_namespace"), is("all")); assertThat(successMeter.getId().getTag("method_name"), is("myMethod")); // Verify the tags for durationMeters + Collection durationMeters = meterRegistry.get("timer.Type_Anonymous.duration").meters(); Meter durationMeter = durationMeters.iterator().next(); assertThat(durationMeter.getId().getTag("federation_namespace"), is("all")); assertThat(successMeter.getId().getTag("method_name"), is("myMethod"));