mirror of
https://github.com/spring-projects/spring-boot.git
synced 2026-09-30 06:09:14 +00:00
Add nullability annotations to tests in module/spring-boot-data-elasticsearch
See gh-47263
This commit is contained in:
@@ -51,3 +51,11 @@ dependencies {
|
||||
|
||||
testRuntimeOnly("ch.qos.logback:logback-classic")
|
||||
}
|
||||
|
||||
tasks.named("compileTestJava") {
|
||||
options.nullability.checking = "tests"
|
||||
}
|
||||
|
||||
tasks.named("compileDockerTestJava") {
|
||||
options.nullability.checking = "tests"
|
||||
}
|
||||
|
||||
+2
-1
@@ -20,6 +20,7 @@ import java.math.BigDecimal;
|
||||
import java.util.Collections;
|
||||
|
||||
import org.assertj.core.api.InstanceOfAssertFactories;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.boot.autoconfigure.AutoConfigurations;
|
||||
@@ -151,7 +152,7 @@ class DataElasticsearchAutoConfigurationTests {
|
||||
static class MyConverter implements Converter<ElasticsearchTemplate, Boolean> {
|
||||
|
||||
@Override
|
||||
public Boolean convert(ElasticsearchTemplate source) {
|
||||
public @Nullable Boolean convert(ElasticsearchTemplate source) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
+5
@@ -74,6 +74,7 @@ class DataElasticsearchReactiveHealthIndicatorTests {
|
||||
void elasticsearchIsUp() {
|
||||
setupMockResponse("green");
|
||||
Health health = this.healthIndicator.health().block(TIMEOUT);
|
||||
assertThat(health).isNotNull();
|
||||
assertThat(health.getStatus()).isEqualTo(Status.UP);
|
||||
assertHealthDetailsWithStatus(health.getDetails(), "green");
|
||||
}
|
||||
@@ -82,6 +83,7 @@ class DataElasticsearchReactiveHealthIndicatorTests {
|
||||
void elasticsearchWithYellowStatusIsUp() {
|
||||
setupMockResponse("yellow");
|
||||
Health health = this.healthIndicator.health().block(TIMEOUT);
|
||||
assertThat(health).isNotNull();
|
||||
assertThat(health.getStatus()).isEqualTo(Status.UP);
|
||||
assertHealthDetailsWithStatus(health.getDetails(), "yellow");
|
||||
}
|
||||
@@ -91,6 +93,7 @@ class DataElasticsearchReactiveHealthIndicatorTests {
|
||||
void elasticsearchIsDown() throws Exception {
|
||||
this.server.shutdown();
|
||||
Health health = this.healthIndicator.health().block(TIMEOUT);
|
||||
assertThat(health).isNotNull();
|
||||
assertThat(health.getStatus()).isEqualTo(Status.DOWN);
|
||||
assertThat(health.getDetails().get("error")).asString().contains("Connection refused");
|
||||
}
|
||||
@@ -99,6 +102,7 @@ class DataElasticsearchReactiveHealthIndicatorTests {
|
||||
void elasticsearchIsDownByResponseCode() {
|
||||
this.server.enqueue(new MockResponse().setResponseCode(HttpStatus.INTERNAL_SERVER_ERROR.value()));
|
||||
Health health = this.healthIndicator.health().block(TIMEOUT);
|
||||
assertThat(health).isNotNull();
|
||||
assertThat(health.getStatus()).isEqualTo(Status.DOWN);
|
||||
assertThat(health.getDetails().get("error")).asString().startsWith(ResponseException.class.getName());
|
||||
}
|
||||
@@ -107,6 +111,7 @@ class DataElasticsearchReactiveHealthIndicatorTests {
|
||||
void elasticsearchIsOutOfServiceByStatus() {
|
||||
setupMockResponse("red");
|
||||
Health health = this.healthIndicator.health().block(TIMEOUT);
|
||||
assertThat(health).isNotNull();
|
||||
assertThat(health.getStatus()).isEqualTo(Status.OUT_OF_SERVICE);
|
||||
assertHealthDetailsWithStatus(health.getDetails(), "red");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user