diff --git a/module/spring-boot-jpa-test/build.gradle b/module/spring-boot-jpa-test/build.gradle index 9e24f10891c..254e6210b91 100644 --- a/module/spring-boot-jpa-test/build.gradle +++ b/module/spring-boot-jpa-test/build.gradle @@ -34,3 +34,7 @@ dependencies { testRuntimeOnly("ch.qos.logback:logback-classic") } + +tasks.named("compileTestJava") { + options.nullability.checking = "tests" +} diff --git a/module/spring-boot-jpa-test/src/test/java/org/springframework/boot/jpa/test/autoconfigure/TestEntityManagerTests.java b/module/spring-boot-jpa-test/src/test/java/org/springframework/boot/jpa/test/autoconfigure/TestEntityManagerTests.java index d3197d049c1..dccd36982de 100644 --- a/module/spring-boot-jpa-test/src/test/java/org/springframework/boot/jpa/test/autoconfigure/TestEntityManagerTests.java +++ b/module/spring-boot-jpa-test/src/test/java/org/springframework/boot/jpa/test/autoconfigure/TestEntityManagerTests.java @@ -43,12 +43,15 @@ import static org.mockito.BDDMockito.then; class TestEntityManagerTests { @Mock + @SuppressWarnings("NullAway.Init") private EntityManagerFactory entityManagerFactory; @Mock + @SuppressWarnings("NullAway.Init") private EntityManager entityManager; @Mock + @SuppressWarnings("NullAway.Init") private PersistenceUnitUtil persistenceUnitUtil; private TestEntityManager testEntityManager; @@ -59,6 +62,7 @@ class TestEntityManagerTests { } @Test + @SuppressWarnings("NullAway") // Test null check void createWhenEntityManagerIsNullShouldThrowException() { assertThatIllegalArgumentException().isThrownBy(() -> new TestEntityManager(null)) .withMessageContaining("'entityManagerFactory' must not be null");