Skip to content

Commit 2edd8f9

Browse files
committed
Add nullability annotations to tests in module/spring-boot-data-jpa-test
See gh-47263
1 parent 3353090 commit 2edd8f9

File tree

3 files changed

+9
-0
lines changed

3 files changed

+9
-0
lines changed

module/spring-boot-data-jpa-test/build.gradle

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,7 @@ dependencies {
3838
testRuntimeOnly("com.h2database:h2")
3939
testRuntimeOnly("org.hsqldb:hsqldb")
4040
}
41+
42+
tasks.named("compileTestJava") {
43+
options.nullability.checking = "tests"
44+
}

module/spring-boot-data-jpa-test/src/test/java/org/springframework/boot/data/jpa/test/autoconfigure/DataJpaTestIntegrationTests.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,9 @@ void testEntityManager() {
6767
ExampleEntity entity = this.entities.persist(new ExampleEntity("spring", "123"));
6868
this.entities.flush();
6969
Object id = this.entities.getId(entity);
70+
assertThat(id).isNotNull();
7071
ExampleEntity found = this.entities.find(ExampleEntity.class, id);
72+
assertThat(found).isNotNull();
7173
assertThat(found.getName()).isEqualTo("spring");
7274
}
7375

module/spring-boot-data-jpa-test/src/test/java/org/springframework/boot/data/jpa/test/autoconfigure/ExampleEntity.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,13 @@ public class ExampleEntity {
3030

3131
@Id
3232
@GeneratedValue
33+
@SuppressWarnings("NullAway.Init")
3334
private Long id;
3435

36+
@SuppressWarnings("NullAway.Init")
3537
private String name;
3638

39+
@SuppressWarnings("NullAway.Init")
3740
private String reference;
3841

3942
protected ExampleEntity() {

0 commit comments

Comments
 (0)