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

See gh-47263
This commit is contained in:
Moritz Halbritter 2025-10-06 11:51:53 +02:00
parent 3353090bc6
commit 2edd8f9d62
3 changed files with 9 additions and 0 deletions

View File

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

View File

@ -67,7 +67,9 @@ class DataJpaTestIntegrationTests {
ExampleEntity entity = this.entities.persist(new ExampleEntity("spring", "123"));
this.entities.flush();
Object id = this.entities.getId(entity);
assertThat(id).isNotNull();
ExampleEntity found = this.entities.find(ExampleEntity.class, id);
assertThat(found).isNotNull();
assertThat(found.getName()).isEqualTo("spring");
}

View File

@ -30,10 +30,13 @@ public class ExampleEntity {
@Id
@GeneratedValue
@SuppressWarnings("NullAway.Init")
private Long id;
@SuppressWarnings("NullAway.Init")
private String name;
@SuppressWarnings("NullAway.Init")
private String reference;
protected ExampleEntity() {