Skip to content

Commit 9d85c37

Browse files
committed
Add nullability annotations to tests in module/spring-boot-jpa-test
See gh-47263
1 parent 9d63a74 commit 9d85c37

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,7 @@ dependencies {
3434

3535
testRuntimeOnly("ch.qos.logback:logback-classic")
3636
}
37+
38+
tasks.named("compileTestJava") {
39+
options.nullability.checking = "tests"
40+
}

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,15 @@
4343
class TestEntityManagerTests {
4444

4545
@Mock
46+
@SuppressWarnings("NullAway.Init")
4647
private EntityManagerFactory entityManagerFactory;
4748

4849
@Mock
50+
@SuppressWarnings("NullAway.Init")
4951
private EntityManager entityManager;
5052

5153
@Mock
54+
@SuppressWarnings("NullAway.Init")
5255
private PersistenceUnitUtil persistenceUnitUtil;
5356

5457
private TestEntityManager testEntityManager;
@@ -59,6 +62,7 @@ void setup() {
5962
}
6063

6164
@Test
65+
@SuppressWarnings("NullAway") // Test null check
6266
void createWhenEntityManagerIsNullShouldThrowException() {
6367
assertThatIllegalArgumentException().isThrownBy(() -> new TestEntityManager(null))
6468
.withMessageContaining("'entityManagerFactory' must not be null");

0 commit comments

Comments
 (0)