mirror of
https://github.com/spring-projects/spring-boot.git
synced 2026-05-03 03:43:54 +01:00
Add nullability annotations to tests in module/spring-boot-jpa-test
See gh-47263
This commit is contained in:
@@ -34,3 +34,7 @@ dependencies {
|
||||
|
||||
testRuntimeOnly("ch.qos.logback:logback-classic")
|
||||
}
|
||||
|
||||
tasks.named("compileTestJava") {
|
||||
options.nullability.checking = "tests"
|
||||
}
|
||||
|
||||
+4
@@ -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");
|
||||
|
||||
Reference in New Issue
Block a user