From a995c7589193a3adcd72ff0a6d4d995287e0cbb7 Mon Sep 17 00:00:00 2001 From: Moritz Halbritter Date: Thu, 16 Oct 2025 09:42:24 +0200 Subject: [PATCH] Add nullability annotations to tests in smoke-test/spring-boot-smoke-test-session-data-redis See gh-47263 --- .../build.gradle | 8 ++++++++ .../redis/SampleSessionRedisApplicationTests.java | 10 +++++----- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/smoke-test/spring-boot-smoke-test-session-data-redis/build.gradle b/smoke-test/spring-boot-smoke-test-session-data-redis/build.gradle index 0d05682eec5..3b07f903582 100644 --- a/smoke-test/spring-boot-smoke-test-session-data-redis/build.gradle +++ b/smoke-test/spring-boot-smoke-test-session-data-redis/build.gradle @@ -34,3 +34,11 @@ dependencies { dockerTestImplementation("com.redis:testcontainers-redis") dockerTestImplementation("org.testcontainers:junit-jupiter") } + +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-redis/src/dockerTest/java/smoketest/session/redis/SampleSessionRedisApplicationTests.java b/smoke-test/spring-boot-smoke-test-session-data-redis/src/dockerTest/java/smoketest/session/redis/SampleSessionRedisApplicationTests.java index 58a6ab424f4..8357eea38cf 100644 --- a/smoke-test/spring-boot-smoke-test-session-data-redis/src/dockerTest/java/smoketest/session/redis/SampleSessionRedisApplicationTests.java +++ b/smoke-test/spring-boot-smoke-test-session-data-redis/src/dockerTest/java/smoketest/session/redis/SampleSessionRedisApplicationTests.java @@ -72,20 +72,20 @@ class SampleSessionRedisApplicationTests { 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) {