diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/observation/web/client/RestClientObservationConfigurationTests.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/observation/web/client/RestClientObservationConfigurationTests.java index 1400c4f6c027..9851a0ceab0d 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/observation/web/client/RestClientObservationConfigurationTests.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/observation/web/client/RestClientObservationConfigurationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2023 the original author or authors. + * Copyright 2012-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,7 +20,6 @@ import io.micrometer.core.instrument.MeterRegistry; import io.micrometer.observation.ObservationRegistry; import io.micrometer.observation.tck.TestObservationRegistry; -import io.micrometer.observation.tck.TestObservationRegistryAssert; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; @@ -72,8 +71,7 @@ void restClientCreatedWithBuilderIsInstrumented() { RestClient restClient = buildRestClient(context); restClient.get().uri("/projects/{project}", "spring-boot").retrieve().toBodilessEntity(); TestObservationRegistry registry = context.getBean(TestObservationRegistry.class); - TestObservationRegistryAssert.assertThat(registry) - .hasObservationWithNameEqualToIgnoringCase("http.client.requests"); + assertThat(registry).hasObservationWithNameEqualToIgnoringCase("http.client.requests"); }); } @@ -85,8 +83,7 @@ void restClientCreatedWithBuilderUsesCustomConventionName() { RestClient restClient = buildRestClient(context); restClient.get().uri("/projects/{project}", "spring-boot").retrieve().toBodilessEntity(); TestObservationRegistry registry = context.getBean(TestObservationRegistry.class); - TestObservationRegistryAssert.assertThat(registry) - .hasObservationWithNameEqualToIgnoringCase(observationName); + assertThat(registry).hasObservationWithNameEqualToIgnoringCase(observationName); }); } @@ -96,8 +93,7 @@ void restClientCreatedWithBuilderUsesCustomConvention() { RestClient restClient = buildRestClient(context); restClient.get().uri("/projects/{project}", "spring-boot").retrieve().toBodilessEntity(); TestObservationRegistry registry = context.getBean(TestObservationRegistry.class); - TestObservationRegistryAssert.assertThat(registry) - .hasObservationWithNameEqualTo("http.client.requests") + assertThat(registry).hasObservationWithNameEqualTo("http.client.requests") .that() .hasLowCardinalityKeyValue("project", "spring-boot"); }); @@ -118,8 +114,7 @@ void afterMaxUrisReachedFurtherUrisAreDenied(CapturedOutput output) { restClient.get().uri("/test/" + i, String.class).retrieve().toBodilessEntity(); } TestObservationRegistry registry = context.getBean(TestObservationRegistry.class); - TestObservationRegistryAssert.assertThat(registry) - .hasNumberOfObservationsWithNameEqualTo("http.client.requests", 3); + assertThat(registry).hasNumberOfObservationsWithNameEqualTo("http.client.requests", 3); MeterRegistry meterRegistry = context.getBean(MeterRegistry.class); assertThat(meterRegistry.find("http.client.requests").timers()).hasSize(2); assertThat(output).contains("Reached the maximum number of URI tags for 'http.client.requests'.") diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/observation/web/client/RestClientObservationConfigurationWithoutMetricsTests.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/observation/web/client/RestClientObservationConfigurationWithoutMetricsTests.java index 3aa82c08c26b..defcd9385d63 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/observation/web/client/RestClientObservationConfigurationWithoutMetricsTests.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/observation/web/client/RestClientObservationConfigurationWithoutMetricsTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2023 the original author or authors. + * Copyright 2012-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,7 +18,6 @@ import io.micrometer.observation.ObservationRegistry; import io.micrometer.observation.tck.TestObservationRegistry; -import io.micrometer.observation.tck.TestObservationRegistryAssert; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; @@ -34,6 +33,7 @@ import org.springframework.web.client.RestClient; import org.springframework.web.client.RestClient.Builder; +import static org.assertj.core.api.Assertions.assertThat; import static org.springframework.test.web.client.match.MockRestRequestMatchers.requestTo; import static org.springframework.test.web.client.response.MockRestResponseCreators.withStatus; @@ -59,8 +59,7 @@ void restClientCreatedWithBuilderIsInstrumented() { RestClient restClient = buildRestClient(context); restClient.get().uri("/projects/{project}", "spring-boot").retrieve().toBodilessEntity(); TestObservationRegistry registry = context.getBean(TestObservationRegistry.class); - TestObservationRegistryAssert.assertThat(registry) - .hasObservationWithNameEqualToIgnoringCase("http.client.requests"); + assertThat(registry).hasObservationWithNameEqualToIgnoringCase("http.client.requests"); }); } diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/observation/web/client/RestTemplateObservationConfigurationTests.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/observation/web/client/RestTemplateObservationConfigurationTests.java index 92b4367cad0c..bb3413ddc3e8 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/observation/web/client/RestTemplateObservationConfigurationTests.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/observation/web/client/RestTemplateObservationConfigurationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2023 the original author or authors. + * Copyright 2012-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,7 +20,6 @@ import io.micrometer.core.instrument.MeterRegistry; import io.micrometer.observation.ObservationRegistry; import io.micrometer.observation.tck.TestObservationRegistry; -import io.micrometer.observation.tck.TestObservationRegistryAssert; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; @@ -70,8 +69,7 @@ void restTemplateCreatedWithBuilderIsInstrumented() { RestTemplate restTemplate = buildRestTemplate(context); restTemplate.getForEntity("/projects/{project}", Void.class, "spring-boot"); TestObservationRegistry registry = context.getBean(TestObservationRegistry.class); - TestObservationRegistryAssert.assertThat(registry) - .hasObservationWithNameEqualToIgnoringCase("http.client.requests"); + assertThat(registry).hasObservationWithNameEqualToIgnoringCase("http.client.requests"); }); } @@ -83,8 +81,7 @@ void restTemplateCreatedWithBuilderUsesCustomConventionName() { RestTemplate restTemplate = buildRestTemplate(context); restTemplate.getForEntity("/projects/{project}", Void.class, "spring-boot"); TestObservationRegistry registry = context.getBean(TestObservationRegistry.class); - TestObservationRegistryAssert.assertThat(registry) - .hasObservationWithNameEqualToIgnoringCase(observationName); + assertThat(registry).hasObservationWithNameEqualToIgnoringCase(observationName); }); } @@ -94,8 +91,7 @@ void restTemplateCreatedWithBuilderUsesCustomConvention() { RestTemplate restTemplate = buildRestTemplate(context); restTemplate.getForEntity("/projects/{project}", Void.class, "spring-boot"); TestObservationRegistry registry = context.getBean(TestObservationRegistry.class); - TestObservationRegistryAssert.assertThat(registry) - .hasObservationWithNameEqualTo("http.client.requests") + assertThat(registry).hasObservationWithNameEqualTo("http.client.requests") .that() .hasLowCardinalityKeyValue("project", "spring-boot"); }); @@ -115,8 +111,7 @@ void afterMaxUrisReachedFurtherUrisAreDenied(CapturedOutput output) { restTemplate.getForObject("/test/" + i, String.class); } TestObservationRegistry registry = context.getBean(TestObservationRegistry.class); - TestObservationRegistryAssert.assertThat(registry) - .hasNumberOfObservationsWithNameEqualTo("http.client.requests", 3); + assertThat(registry).hasNumberOfObservationsWithNameEqualTo("http.client.requests", 3); MeterRegistry meterRegistry = context.getBean(MeterRegistry.class); assertThat(meterRegistry.find("http.client.requests").timers()).hasSize(2); assertThat(output).contains("Reached the maximum number of URI tags for 'http.client.requests'.") diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/observation/web/client/RestTemplateObservationConfigurationWithoutMetricsTests.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/observation/web/client/RestTemplateObservationConfigurationWithoutMetricsTests.java index 9d821b7f31ff..f295fd829a36 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/observation/web/client/RestTemplateObservationConfigurationWithoutMetricsTests.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/observation/web/client/RestTemplateObservationConfigurationWithoutMetricsTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2023 the original author or authors. + * Copyright 2012-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,7 +18,6 @@ import io.micrometer.observation.ObservationRegistry; import io.micrometer.observation.tck.TestObservationRegistry; -import io.micrometer.observation.tck.TestObservationRegistryAssert; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; @@ -34,6 +33,7 @@ import org.springframework.test.web.client.MockRestServiceServer; import org.springframework.web.client.RestTemplate; +import static org.assertj.core.api.Assertions.assertThat; import static org.springframework.test.web.client.match.MockRestRequestMatchers.requestTo; import static org.springframework.test.web.client.response.MockRestResponseCreators.withStatus; @@ -58,8 +58,7 @@ void restTemplateCreatedWithBuilderIsInstrumented() { RestTemplate restTemplate = buildRestTemplate(context); restTemplate.getForEntity("/projects/{project}", Void.class, "spring-boot"); TestObservationRegistry registry = context.getBean(TestObservationRegistry.class); - TestObservationRegistryAssert.assertThat(registry) - .hasObservationWithNameEqualToIgnoringCase("http.client.requests"); + assertThat(registry).hasObservationWithNameEqualToIgnoringCase("http.client.requests"); }); } diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/observation/web/client/WebClientObservationConfigurationTests.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/observation/web/client/WebClientObservationConfigurationTests.java index 8a917298b0e0..e899d40439c3 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/observation/web/client/WebClientObservationConfigurationTests.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/observation/web/client/WebClientObservationConfigurationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2023 the original author or authors. + * Copyright 2012-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,7 +22,6 @@ import io.micrometer.core.instrument.MeterRegistry; import io.micrometer.observation.ObservationRegistry; import io.micrometer.observation.tck.TestObservationRegistry; -import io.micrometer.observation.tck.TestObservationRegistryAssert; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import reactor.core.publisher.Mono; @@ -84,14 +83,13 @@ void shouldUseCustomConventionIfAvailable() { TestObservationRegistry registry = context.getBean(TestObservationRegistry.class); WebClient.Builder builder = context.getBean(WebClient.Builder.class); WebClient webClient = mockWebClient(builder); - TestObservationRegistryAssert.assertThat(registry).doesNotHaveAnyObservation(); + assertThat(registry).doesNotHaveAnyObservation(); webClient.get() .uri("https://example.org/projects/{project}", "spring-boot") .retrieve() .toBodilessEntity() .block(Duration.ofSeconds(30)); - TestObservationRegistryAssert.assertThat(registry) - .hasObservationWithNameEqualTo("http.client.requests") + assertThat(registry).hasObservationWithNameEqualTo("http.client.requests") .that() .hasLowCardinalityKeyValue("project", "spring-boot"); }); @@ -101,8 +99,7 @@ void shouldUseCustomConventionIfAvailable() { void afterMaxUrisReachedFurtherUrisAreDenied(CapturedOutput output) { this.contextRunner.withPropertyValues("management.metrics.web.client.max-uri-tags=2").run((context) -> { TestObservationRegistry registry = getInitializedRegistry(context); - TestObservationRegistryAssert.assertThat(registry) - .hasNumberOfObservationsWithNameEqualTo("http.client.requests", 3); + assertThat(registry).hasNumberOfObservationsWithNameEqualTo("http.client.requests", 3); MeterRegistry meterRegistry = context.getBean(MeterRegistry.class); assertThat(meterRegistry.find("http.client.requests").timers()).hasSize(1); // MeterFilter.maximumAllowableTags() works with prefix matching. @@ -116,8 +113,7 @@ void afterMaxUrisReachedFurtherUrisAreDenied(CapturedOutput output) { void shouldNotDenyNorLogIfMaxUrisIsNotReached(CapturedOutput output) { this.contextRunner.withPropertyValues("management.metrics.web.client.max-uri-tags=5").run((context) -> { TestObservationRegistry registry = getInitializedRegistry(context); - TestObservationRegistryAssert.assertThat(registry) - .hasNumberOfObservationsWithNameEqualTo("http.client.requests", 3); + assertThat(registry).hasNumberOfObservationsWithNameEqualTo("http.client.requests", 3); MeterRegistry meterRegistry = context.getBean(MeterRegistry.class); assertThat(meterRegistry.find("http.client.requests").timers()).hasSize(3); assertThat(output).doesNotContain("Reached the maximum number of URI tags for 'http.client.requests'.") @@ -140,14 +136,13 @@ private TestObservationRegistry getInitializedRegistry(AssertableApplicationCont private void validateWebClient(WebClient.Builder builder, TestObservationRegistry registry) { WebClient webClient = mockWebClient(builder); - TestObservationRegistryAssert.assertThat(registry).doesNotHaveAnyObservation(); + assertThat(registry).doesNotHaveAnyObservation(); webClient.get() .uri("https://example.org/projects/{project}", "spring-boot") .retrieve() .toBodilessEntity() .block(Duration.ofSeconds(30)); - TestObservationRegistryAssert.assertThat(registry) - .hasObservationWithNameEqualTo("http.client.requests") + assertThat(registry).hasObservationWithNameEqualTo("http.client.requests") .that() .hasLowCardinalityKeyValue("uri", "/projects/{project}"); }