From 5da9f14b32aa38809d21b1959d6227fe3748c1ea Mon Sep 17 00:00:00 2001 From: Moritz Halbritter Date: Thu, 16 Oct 2025 09:40:09 +0200 Subject: [PATCH] Add nullability annotations to tests in smoke-test/spring-boot-smoke-test-session-data-mongodb See gh-47263 --- .../build.gradle | 8 ++++++++ .../mongodb/SampleSessionMongoApplicationTests.java | 10 +++++----- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/smoke-test/spring-boot-smoke-test-session-data-mongodb/build.gradle b/smoke-test/spring-boot-smoke-test-session-data-mongodb/build.gradle index a131f5a2583..7d121c7a722 100644 --- a/smoke-test/spring-boot-smoke-test-session-data-mongodb/build.gradle +++ b/smoke-test/spring-boot-smoke-test-session-data-mongodb/build.gradle @@ -34,3 +34,11 @@ dependencies { dockerTestImplementation("org.testcontainers:junit-jupiter") dockerTestImplementation("org.testcontainers:mongodb") } + +tasks.named("compileTestJava") { + options.nullability.checking = "tests" +} + +tasks.named("compileDockerTestJava") { + options.nullability.checking = "tests" +} diff --git a/smoke-test/spring-boot-smoke-test-session-data-mongodb/src/dockerTest/java/smoketest/session/mongodb/SampleSessionMongoApplicationTests.java b/smoke-test/spring-boot-smoke-test-session-data-mongodb/src/dockerTest/java/smoketest/session/mongodb/SampleSessionMongoApplicationTests.java index 9eea032aefa..68f80c2a569 100644 --- a/smoke-test/spring-boot-smoke-test-session-data-mongodb/src/dockerTest/java/smoketest/session/mongodb/SampleSessionMongoApplicationTests.java +++ b/smoke-test/spring-boot-smoke-test-session-data-mongodb/src/dockerTest/java/smoketest/session/mongodb/SampleSessionMongoApplicationTests.java @@ -76,20 +76,20 @@ class SampleSessionMongoApplicationTests { ResponseEntity> response = getSessions(); assertThat(response).isNotNull(); assertThat(response.getStatusCode()).isEqualTo(HttpStatus.OK); - List> sessions = (List>) response.getBody().get("sessions"); + Map body = response.getBody(); + assertThat(body).isNotNull(); + List> sessions = (List>) body.get("sessions"); assertThat(sessions).hasSize(1); } - private String performLogin() { + private void performLogin() { HttpHeaders headers = new HttpHeaders(); headers.setAccept(Collections.singletonList(MediaType.TEXT_HTML)); headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED); MultiValueMap form = new LinkedMultiValueMap<>(); form.set("username", "user"); form.set("password", "password"); - ResponseEntity entity = this.restTemplate.exchange("/login", HttpMethod.POST, - new HttpEntity<>(form, headers), String.class); - return entity.getHeaders().getFirst("Set-Cookie"); + this.restTemplate.exchange("/login", HttpMethod.POST, new HttpEntity<>(form, headers), String.class); } private RequestEntity getRequestEntity(URI uri) {