|
15 | 15 | import io.opentelemetry.instrumentation.testing.junit.AgentInstrumentationExtension;
|
16 | 16 | import io.opentelemetry.instrumentation.testing.junit.InstrumentationExtension;
|
17 | 17 | import io.opentelemetry.javaagent.instrumentation.spring.actuator.v2_0.SpringApp.TestBean;
|
18 |
| -import java.util.Collection; |
19 |
| -import org.assertj.core.api.AbstractCollectionAssert; |
20 |
| -import org.assertj.core.api.ObjectAssert; |
| 18 | +import java.util.ArrayList; |
| 19 | +import java.util.Collections; |
| 20 | +import java.util.Set; |
21 | 21 | import org.junit.jupiter.api.Test;
|
22 | 22 | import org.junit.jupiter.api.extension.RegisterExtension;
|
23 | 23 | import org.springframework.boot.SpringApplication;
|
@@ -61,16 +61,18 @@ void shouldInjectOtelMeterRegistry() {
|
61 | 61 |
|
62 | 62 | MeterRegistry meterRegistry = context.getBean(MeterRegistry.class);
|
63 | 63 | assertThat(meterRegistry).isInstanceOf(CompositeMeterRegistry.class);
|
64 |
| - AbstractCollectionAssert< |
65 |
| - ?, Collection<? extends MeterRegistry>, MeterRegistry, ObjectAssert<MeterRegistry>> |
66 |
| - match = |
67 |
| - assertThat(((CompositeMeterRegistry) meterRegistry).getRegistries()) |
68 |
| - .anyMatch(r -> r.getClass().getSimpleName().equals("OpenTelemetryMeterRegistry")) |
69 |
| - .anyMatch(r -> r.getClass().getSimpleName().equals("SimpleMeterRegistry")); |
| 64 | + |
| 65 | + Set<MeterRegistry> registries = ((CompositeMeterRegistry) meterRegistry).getRegistries(); |
| 66 | + ArrayList<MeterRegistry> list = new ArrayList<>(registries); |
| 67 | + |
| 68 | + String last = list.get(list.size() - 1).getClass().getSimpleName(); |
| 69 | + assertThat(last).isEqualTo("OpenTelemetryMeterRegistry"); |
70 | 70 |
|
71 | 71 | try {
|
72 | 72 | Class.forName("io.micrometer.prometheusmetrics.PrometheusMeterRegistry");
|
73 |
| - match.anyMatch(r -> r.getClass().getSimpleName().equals("PrometheusMeterRegistry")); |
| 73 | + assertThat(registries) |
| 74 | + .extracting(r -> r.getClass().getSimpleName()) |
| 75 | + .contains("PrometheusMeterRegistry"); |
74 | 76 | } catch (ClassNotFoundException e) {
|
75 | 77 | // not testing prometheus
|
76 | 78 | }
|
|
0 commit comments