Add nullability annotations to tests in module/spring-boot-hibernate

See gh-47263
This commit is contained in:
Moritz Halbritter
2025-10-06 12:03:55 +02:00
parent 80c384e92c
commit f59fc4020a
4 changed files with 10 additions and 2 deletions
@@ -54,3 +54,7 @@ dependencies {
testRuntimeOnly("ch.qos.logback:logback-classic")
testRuntimeOnly("com.h2database:h2")
}
tasks.named("compileTestJava") {
options.nullability.checking = "tests"
}
@@ -1086,7 +1086,9 @@ class HibernateJpaAutoConfigurationTests {
properties.put("hibernate.transaction.jta.platform", NoJtaPlatform.INSTANCE);
factoryBean.setJpaPropertyMap(properties);
factoryBean.afterPropertiesSet();
return factoryBean.getObject();
EntityManagerFactory bean = factoryBean.getObject();
assertThat(bean).isNotNull();
return bean;
}
@Bean
@@ -56,6 +56,7 @@ class HibernatePropertiesTests {
.withUserConfiguration(TestConfiguration.class);
@Mock
@SuppressWarnings("NullAway.Init")
private Supplier<String> ddlAutoSupplier;
@Test
@@ -29,6 +29,7 @@ import jakarta.persistence.GeneratedValue;
import jakarta.persistence.Id;
import jakarta.persistence.PersistenceException;
import org.hibernate.SessionFactory;
import org.jspecify.annotations.Nullable;
import org.junit.jupiter.api.Test;
import org.mockito.ArgumentMatchers;
@@ -181,7 +182,7 @@ class HibernateMetricsAutoConfigurationTests {
@Id
@GeneratedValue
private Long id;
private @Nullable Long id;
}