mirror of
https://github.com/spring-projects/spring-boot.git
synced 2026-10-09 02:49:02 +00:00
Add nullability annotations to tests in module/spring-boot-webclient-test
See gh-47263
This commit is contained in:
@@ -40,3 +40,7 @@ dependencies {
|
||||
|
||||
testRuntimeOnly("ch.qos.logback:logback-classic")
|
||||
}
|
||||
|
||||
tasks.named("compileTestJava") {
|
||||
options.nullability.checking = "tests"
|
||||
}
|
||||
|
||||
+9
-2
@@ -16,9 +16,14 @@
|
||||
|
||||
package org.springframework.boot.webclient.test.autoconfigure;
|
||||
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.reactive.function.client.WebClient;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
/**
|
||||
* A second example web client used with {@link WebClientTest @WebClientTest} tests.
|
||||
*
|
||||
@@ -40,8 +45,10 @@ public class AnotherExampleWebClientService {
|
||||
return this.builder;
|
||||
}
|
||||
|
||||
public String test() {
|
||||
return this.webClient.get().uri("/test").retrieve().toEntity(String.class).block().getBody();
|
||||
public @Nullable String test() {
|
||||
ResponseEntity<String> response = this.webClient.get().uri("/test").retrieve().toEntity(String.class).block();
|
||||
assertThat(response).isNotNull();
|
||||
return response.getBody();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+9
-2
@@ -16,9 +16,14 @@
|
||||
|
||||
package org.springframework.boot.webclient.test.autoconfigure;
|
||||
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.reactive.function.client.WebClient;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
/**
|
||||
* Example web client using {@code WebClient} with {@link WebClientTest @WebClientTest}
|
||||
* tests.
|
||||
@@ -41,8 +46,10 @@ public class ExampleWebClientService {
|
||||
return this.builder;
|
||||
}
|
||||
|
||||
public String test() {
|
||||
return this.webClient.get().uri("/test").retrieve().toEntity(String.class).block().getBody();
|
||||
public @Nullable String test() {
|
||||
ResponseEntity<String> response = this.webClient.get().uri("/test").retrieve().toEntity(String.class).block();
|
||||
assertThat(response).isNotNull();
|
||||
return response.getBody();
|
||||
}
|
||||
|
||||
public void testPostWithBody(String body) {
|
||||
|
||||
Reference in New Issue
Block a user