diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/MeterRegistryConfigurerIntegrationTests.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/MeterRegistryConfigurerIntegrationTests.java index 37219e6b06..3836341a5f 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/MeterRegistryConfigurerIntegrationTests.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/MeterRegistryConfigurerIntegrationTests.java @@ -25,21 +25,26 @@ import org.springframework.boot.actuate.autoconfigure.metrics.export.prometheus. import org.springframework.boot.actuate.autoconfigure.metrics.test.MetricsRun; import org.springframework.boot.test.context.runner.ApplicationContextRunner; +/** + * Integration tests for {@link MeterRegistryConfigurer}. + * + * @author Jon Schneider + */ public class MeterRegistryConfigurerIntegrationTests { + private ApplicationContextRunner contextRunner = new ApplicationContextRunner() .with(MetricsRun.limitedTo(AtlasMetricsExportAutoConfiguration.class, PrometheusMetricsExportAutoConfiguration.class)); @Test public void binderMetricsAreSearchableFromTheComposite() { - this.contextRunner - .run((context) -> { - CompositeMeterRegistry composite = context.getBean(CompositeMeterRegistry.class); - composite.get("jvm.memory.used").gauge(); - - for (MeterRegistry registry : context.getBeansOfType(MeterRegistry.class).values()) { - registry.get("jvm.memory.used").gauge(); - } - }); + this.contextRunner.run((context) -> { + CompositeMeterRegistry composite = context + .getBean(CompositeMeterRegistry.class); + composite.get("jvm.memory.used").gauge(); + context.getBeansOfType(MeterRegistry.class) + .forEach((name, registry) -> registry.get("jvm.memory.used").gauge()); + }); } + } diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/MeterRegistryCustomizerTests.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/MeterRegistryCustomizerTests.java index 5cd0fa5767..4aebdd4f15 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/MeterRegistryCustomizerTests.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/MeterRegistryCustomizerTests.java @@ -67,12 +67,12 @@ public class MeterRegistryCustomizerTests { this.contextRunner .withUserConfiguration(MeterRegistryCustomizerConfiguration.class) .run((context) -> { - MeterRegistry prometheus = context.getBean(PrometheusMeterRegistry.class); + MeterRegistry prometheus = context + .getBean(PrometheusMeterRegistry.class); prometheus.get("jvm.memory.used").tags("job", "myjob").gauge(); - MeterRegistry atlas = context.getBean(AtlasMeterRegistry.class); - assertThat(atlas.find("jvm.memory.used").tags("job", "myjob") - .gauge()).isNull(); + assertThat(atlas.find("jvm.memory.used").tags("job", "myjob").gauge()) + .isNull(); }); }