diff --git a/module/spring-boot-data-elasticsearch-test/build.gradle b/module/spring-boot-data-elasticsearch-test/build.gradle index cb71861c576..0be074f5731 100644 --- a/module/spring-boot-data-elasticsearch-test/build.gradle +++ b/module/spring-boot-data-elasticsearch-test/build.gradle @@ -46,3 +46,11 @@ dependencies { testRuntimeOnly("ch.qos.logback:logback-classic") } + +tasks.named("compileTestJava") { + options.nullability.checking = "tests" +} + +tasks.named("compileDockerTestJava") { + options.nullability.checking = "tests" +} diff --git a/module/spring-boot-data-elasticsearch-test/src/dockerTest/java/org/springframework/boot/data/elasticsearch/test/autoconfigure/DataElasticsearchTestReactiveIntegrationTests.java b/module/spring-boot-data-elasticsearch-test/src/dockerTest/java/org/springframework/boot/data/elasticsearch/test/autoconfigure/DataElasticsearchTestReactiveIntegrationTests.java index ccc3ab2d2c6..c9898959ceb 100644 --- a/module/spring-boot-data-elasticsearch-test/src/dockerTest/java/org/springframework/boot/data/elasticsearch/test/autoconfigure/DataElasticsearchTestReactiveIntegrationTests.java +++ b/module/spring-boot-data-elasticsearch-test/src/dockerTest/java/org/springframework/boot/data/elasticsearch/test/autoconfigure/DataElasticsearchTestReactiveIntegrationTests.java @@ -58,6 +58,7 @@ class DataElasticsearchTestReactiveIntegrationTests { ExampleDocument exampleDocument = new ExampleDocument(); exampleDocument.setText("Look, new @DataElasticsearchTest!"); exampleDocument = this.exampleReactiveRepository.save(exampleDocument).block(Duration.ofSeconds(30)); + assertThat(exampleDocument).isNotNull(); assertThat(exampleDocument.getId()).isNotNull(); assertThat(this.elasticsearchTemplate.exists(exampleDocument.getId(), ExampleDocument.class) .block(Duration.ofSeconds(30))).isTrue(); diff --git a/module/spring-boot-data-elasticsearch-test/src/dockerTest/java/org/springframework/boot/data/elasticsearch/test/autoconfigure/DataElasticsearchTestWithIncludeFilterIntegrationTests.java b/module/spring-boot-data-elasticsearch-test/src/dockerTest/java/org/springframework/boot/data/elasticsearch/test/autoconfigure/DataElasticsearchTestWithIncludeFilterIntegrationTests.java index ad6af437757..ece922ebd26 100644 --- a/module/spring-boot-data-elasticsearch-test/src/dockerTest/java/org/springframework/boot/data/elasticsearch/test/autoconfigure/DataElasticsearchTestWithIncludeFilterIntegrationTests.java +++ b/module/spring-boot-data-elasticsearch-test/src/dockerTest/java/org/springframework/boot/data/elasticsearch/test/autoconfigure/DataElasticsearchTestWithIncludeFilterIntegrationTests.java @@ -61,6 +61,7 @@ class DataElasticsearchTestWithIncludeFilterIntegrationTests { String id = UUID.randomUUID().toString(); document.setId(id); ExampleDocument savedDocument = this.exampleRepository.save(document); + assertThat(savedDocument.getId()).isNotNull(); assertThat(this.service.findById(savedDocument.getId())).isNotNull(); } diff --git a/module/spring-boot-data-elasticsearch-test/src/dockerTest/java/org/springframework/boot/data/elasticsearch/test/autoconfigure/ExampleDocument.java b/module/spring-boot-data-elasticsearch-test/src/dockerTest/java/org/springframework/boot/data/elasticsearch/test/autoconfigure/ExampleDocument.java index 9cca99ae960..f1f35d29bc7 100644 --- a/module/spring-boot-data-elasticsearch-test/src/dockerTest/java/org/springframework/boot/data/elasticsearch/test/autoconfigure/ExampleDocument.java +++ b/module/spring-boot-data-elasticsearch-test/src/dockerTest/java/org/springframework/boot/data/elasticsearch/test/autoconfigure/ExampleDocument.java @@ -16,6 +16,8 @@ package org.springframework.boot.data.elasticsearch.test.autoconfigure; +import org.jspecify.annotations.Nullable; + import org.springframework.data.annotation.Id; import org.springframework.data.elasticsearch.annotations.Document; @@ -28,23 +30,23 @@ import org.springframework.data.elasticsearch.annotations.Document; public class ExampleDocument { @Id - private String id; + private @Nullable String id; - private String text; + private @Nullable String text; - public String getId() { + public @Nullable String getId() { return this.id; } - public void setId(String id) { + public void setId(@Nullable String id) { this.id = id; } - public String getText() { + public @Nullable String getText() { return this.text; } - public void setText(String text) { + public void setText(@Nullable String text) { this.text = text; } diff --git a/module/spring-boot-data-elasticsearch-test/src/dockerTest/java/org/springframework/boot/data/elasticsearch/test/autoconfigure/ExampleService.java b/module/spring-boot-data-elasticsearch-test/src/dockerTest/java/org/springframework/boot/data/elasticsearch/test/autoconfigure/ExampleService.java index 59ff347ec7f..d21e62f168c 100644 --- a/module/spring-boot-data-elasticsearch-test/src/dockerTest/java/org/springframework/boot/data/elasticsearch/test/autoconfigure/ExampleService.java +++ b/module/spring-boot-data-elasticsearch-test/src/dockerTest/java/org/springframework/boot/data/elasticsearch/test/autoconfigure/ExampleService.java @@ -16,6 +16,8 @@ package org.springframework.boot.data.elasticsearch.test.autoconfigure; +import org.jspecify.annotations.Nullable; + import org.springframework.data.elasticsearch.client.elc.ElasticsearchTemplate; import org.springframework.stereotype.Service; @@ -33,7 +35,7 @@ public class ExampleService { this.elasticsearchTemplate = elasticsearchRestTemplate; } - public ExampleDocument findById(String id) { + public @Nullable ExampleDocument findById(String id) { return this.elasticsearchTemplate.get(id, ExampleDocument.class); }