mirror of
https://github.com/spring-projects/spring-boot.git
synced 2026-05-02 19:30:23 +01:00
Add nullability annotations to tests in module/spring-boot-data-mongodb-test
See gh-47263
This commit is contained in:
@@ -44,7 +44,17 @@ dependencies {
|
||||
dockerTestImplementation("org.testcontainers:mongodb")
|
||||
dockerTestImplementation("org.testcontainers:testcontainers")
|
||||
|
||||
dockerTestCompileOnly("com.google.code.findbugs:jsr305")
|
||||
|
||||
testImplementation(project(":test-support:spring-boot-test-support"))
|
||||
|
||||
testRuntimeOnly("ch.qos.logback:logback-classic")
|
||||
}
|
||||
|
||||
tasks.named("compileTestJava") {
|
||||
options.nullability.checking = "tests"
|
||||
}
|
||||
|
||||
tasks.named("compileDockerTestJava") {
|
||||
options.nullability.checking = "tests"
|
||||
}
|
||||
|
||||
+1
@@ -57,6 +57,7 @@ class DataMongoTestReactiveIntegrationTests {
|
||||
ExampleDocument exampleDocument = new ExampleDocument();
|
||||
exampleDocument.setText("Look, new @DataMongoTest!");
|
||||
exampleDocument = this.exampleRepository.save(exampleDocument).block(Duration.ofSeconds(30));
|
||||
assertThat(exampleDocument).isNotNull();
|
||||
assertThat(exampleDocument.getId()).isNotNull();
|
||||
assertThat(this.mongoTemplate.collectionExists("exampleDocuments").block(Duration.ofSeconds(30))).isTrue();
|
||||
}
|
||||
|
||||
+8
-6
@@ -16,6 +16,8 @@
|
||||
|
||||
package org.springframework.boot.data.mongodb.test.autoconfigure;
|
||||
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import org.springframework.data.mongodb.core.mapping.Document;
|
||||
|
||||
/**
|
||||
@@ -26,23 +28,23 @@ import org.springframework.data.mongodb.core.mapping.Document;
|
||||
@Document(collection = "exampleDocuments")
|
||||
public class ExampleDocument {
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user