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