Browse Source

Add nullability annotations to tests in smoke-test/spring-boot-smoke-test-session-data-redis

See gh-47263
pull/47665/head
Moritz Halbritter 2 months ago
parent
commit
a995c75891
  1. 8
      smoke-test/spring-boot-smoke-test-session-data-redis/build.gradle
  2. 10
      smoke-test/spring-boot-smoke-test-session-data-redis/src/dockerTest/java/smoketest/session/redis/SampleSessionRedisApplicationTests.java

8
smoke-test/spring-boot-smoke-test-session-data-redis/build.gradle

@ -34,3 +34,11 @@ dependencies { @@ -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"
}

10
smoke-test/spring-boot-smoke-test-session-data-redis/src/dockerTest/java/smoketest/session/redis/SampleSessionRedisApplicationTests.java

@ -72,20 +72,20 @@ class SampleSessionRedisApplicationTests { @@ -72,20 +72,20 @@ class SampleSessionRedisApplicationTests {
ResponseEntity<Map<String, Object>> response = getSessions();
assertThat(response).isNotNull();
assertThat(response.getStatusCode()).isEqualTo(HttpStatus.OK);
List<Map<String, Object>> sessions = (List<Map<String, Object>>) response.getBody().get("sessions");
Map<String, Object> body = response.getBody();
assertThat(body).isNotNull();
List<Map<String, Object>> sessions = (List<Map<String, Object>>) 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<String, String> form = new LinkedMultiValueMap<>();
form.set("username", "user");
form.set("password", "password");
ResponseEntity<String> 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<Object> getRequestEntity(URI uri) {

Loading…
Cancel
Save