Add nullability annotations to tests in module/spring-boot-jdbc-test

See gh-47263
This commit is contained in:
Moritz Halbritter 2025-10-06 12:00:54 +02:00
parent a350ead232
commit b503ad3a9a
2 changed files with 14 additions and 4 deletions

View File

@ -51,3 +51,11 @@ dependencies {
testRuntimeOnly("com.h2database:h2") testRuntimeOnly("com.h2database:h2")
testRuntimeOnly("org.hsqldb:hsqldb") testRuntimeOnly("org.hsqldb:hsqldb")
} }
tasks.named("compileTestJava") {
options.nullability.checking = "tests"
}
tasks.named("compileDockerTestJava") {
options.nullability.checking = "tests"
}

View File

@ -16,6 +16,8 @@
package org.springframework.boot.jdbc.test.autoconfigure; package org.springframework.boot.jdbc.test.autoconfigure;
import org.jspecify.annotations.Nullable;
/** /**
* Example entity used with {@link JdbcTest @JdbcTest} tests. * Example entity used with {@link JdbcTest @JdbcTest} tests.
* *
@ -25,9 +27,9 @@ public class ExampleEntity {
private final int id; private final int id;
private String name; private @Nullable String name;
public ExampleEntity(int id, String name) { public ExampleEntity(int id, @Nullable String name) {
this.id = id; this.id = id;
this.name = name; this.name = name;
} }
@ -40,11 +42,11 @@ public class ExampleEntity {
return this.id; return this.id;
} }
public String getName() { public @Nullable String getName() {
return this.name; return this.name;
} }
public void setName(String name) { public void setName(@Nullable String name) {
this.name = name; this.name = name;
} }