diff --git a/smoke-test/spring-boot-smoke-test-webflux/build.gradle b/smoke-test/spring-boot-smoke-test-webflux/build.gradle index c90977d2a5d..be6451fccda 100644 --- a/smoke-test/spring-boot-smoke-test-webflux/build.gradle +++ b/smoke-test/spring-boot-smoke-test-webflux/build.gradle @@ -30,3 +30,7 @@ dependencies { testImplementation(project(":starter:spring-boot-starter-webflux-test")) testImplementation("io.projectreactor:reactor-test") } + +tasks.named("compileTestJava") { + options.nullability.checking = "tests" +} diff --git a/smoke-test/spring-boot-smoke-test-webflux/src/test/java/smoketest/webflux/SampleWebFluxApplicationIntegrationTests.java b/smoke-test/spring-boot-smoke-test-webflux/src/test/java/smoketest/webflux/SampleWebFluxApplicationIntegrationTests.java index 30015b5d2c7..b1fb9c0f04c 100644 --- a/smoke-test/spring-boot-smoke-test-webflux/src/test/java/smoketest/webflux/SampleWebFluxApplicationIntegrationTests.java +++ b/smoke-test/spring-boot-smoke-test-webflux/src/test/java/smoketest/webflux/SampleWebFluxApplicationIntegrationTests.java @@ -16,6 +16,9 @@ package smoketest.webflux; +import java.util.function.Consumer; + +import org.jspecify.annotations.Nullable; import org.junit.jupiter.api.Test; import reactor.core.publisher.Mono; @@ -77,6 +80,7 @@ class SampleWebFluxApplicationIntegrationTests { @Test void templated404ErrorPage() { + Consumer<@Nullable String> test = (body) -> assertThat(body).isEqualToNormalizingNewlines("404 page\n"); this.webClient.get() .uri("/404") .accept(MediaType.TEXT_HTML) @@ -84,11 +88,12 @@ class SampleWebFluxApplicationIntegrationTests { .expectStatus() .isNotFound() .expectBody(String.class) - .value((body) -> assertThat(body).isEqualToNormalizingNewlines("404 page\n")); + .value(test); } @Test void templated4xxErrorPage() { + Consumer<@Nullable String> test = (body) -> assertThat(body).isEqualToNormalizingNewlines("4xx page\n"); this.webClient.get() .uri("/bad-request") .accept(MediaType.TEXT_HTML) @@ -96,11 +101,13 @@ class SampleWebFluxApplicationIntegrationTests { .expectStatus() .isBadRequest() .expectBody(String.class) - .value((body) -> assertThat(body).isEqualToNormalizingNewlines("4xx page\n")); + .value(test); } @Test void htmlErrorPage() { + Consumer<@Nullable String> test = (body) -> assertThat(body).contains("status: 500") + .contains("message: Expected!"); this.webClient.get() .uri("/five-hundred") .accept(MediaType.TEXT_HTML) @@ -108,7 +115,7 @@ class SampleWebFluxApplicationIntegrationTests { .expectStatus() .isEqualTo(HttpStatus.INTERNAL_SERVER_ERROR) .expectBody(String.class) - .value((body) -> assertThat(body).contains("status: 500").contains("message: Expected!")); + .value(test); } } diff --git a/smoke-test/spring-boot-smoke-test-webflux/src/test/java/smoketest/webflux/SampleWebFluxApplicationTests.java b/smoke-test/spring-boot-smoke-test-webflux/src/test/java/smoketest/webflux/SampleWebFluxApplicationTests.java index 17d1cf8c08c..2d33621c0d9 100644 --- a/smoke-test/spring-boot-smoke-test-webflux/src/test/java/smoketest/webflux/SampleWebFluxApplicationTests.java +++ b/smoke-test/spring-boot-smoke-test-webflux/src/test/java/smoketest/webflux/SampleWebFluxApplicationTests.java @@ -17,7 +17,9 @@ package smoketest.webflux; import java.util.Map; +import java.util.function.Consumer; +import org.jspecify.annotations.Nullable; import org.junit.jupiter.api.Test; import reactor.core.publisher.Mono; @@ -61,6 +63,8 @@ class SampleWebFluxApplicationTests { @Test void testBadRequest() { + Consumer<@Nullable Map> test = (content) -> assertThat(content).containsEntry("path", + "/bad-request"); this.webClient.get() .uri("/bad-request") .accept(MediaType.APPLICATION_JSON) @@ -68,11 +72,13 @@ class SampleWebFluxApplicationTests { .expectStatus() .isBadRequest() .expectBody(MAP_TYPE) - .value((content) -> assertThat(content).containsEntry("path", "/bad-request")); + .value(test); } @Test void testServerError() { + Consumer<@Nullable Map> test = (content) -> assertThat(content).containsEntry("path", + "/five-hundred"); this.webClient.get() .uri("/five-hundred") .accept(MediaType.APPLICATION_JSON) @@ -80,7 +86,7 @@ class SampleWebFluxApplicationTests { .expectStatus() .isEqualTo(HttpStatus.INTERNAL_SERVER_ERROR) .expectBody(MAP_TYPE) - .value((content) -> assertThat(content).containsEntry("path", "/five-hundred")); + .value(test); } }