Browse Source

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

See gh-47263
pull/47415/head
Moritz Halbritter 3 months ago
parent
commit
f59fc4020a
  1. 4
      module/spring-boot-hibernate/build.gradle
  2. 4
      module/spring-boot-hibernate/src/test/java/org/springframework/boot/hibernate/autoconfigure/HibernateJpaAutoConfigurationTests.java
  3. 1
      module/spring-boot-hibernate/src/test/java/org/springframework/boot/hibernate/autoconfigure/HibernatePropertiesTests.java
  4. 3
      module/spring-boot-hibernate/src/test/java/org/springframework/boot/hibernate/autoconfigure/metrics/HibernateMetricsAutoConfigurationTests.java

4
module/spring-boot-hibernate/build.gradle

@ -54,3 +54,7 @@ dependencies { @@ -54,3 +54,7 @@ dependencies {
testRuntimeOnly("ch.qos.logback:logback-classic")
testRuntimeOnly("com.h2database:h2")
}
tasks.named("compileTestJava") {
options.nullability.checking = "tests"
}

4
module/spring-boot-hibernate/src/test/java/org/springframework/boot/hibernate/autoconfigure/HibernateJpaAutoConfigurationTests.java

@ -1086,7 +1086,9 @@ class HibernateJpaAutoConfigurationTests { @@ -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

1
module/spring-boot-hibernate/src/test/java/org/springframework/boot/hibernate/autoconfigure/HibernatePropertiesTests.java

@ -56,6 +56,7 @@ class HibernatePropertiesTests { @@ -56,6 +56,7 @@ class HibernatePropertiesTests {
.withUserConfiguration(TestConfiguration.class);
@Mock
@SuppressWarnings("NullAway.Init")
private Supplier<String> ddlAutoSupplier;
@Test

3
module/spring-boot-hibernate/src/test/java/org/springframework/boot/hibernate/autoconfigure/metrics/HibernateMetricsAutoConfigurationTests.java

@ -29,6 +29,7 @@ import jakarta.persistence.GeneratedValue; @@ -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 { @@ -181,7 +182,7 @@ class HibernateMetricsAutoConfigurationTests {
@Id
@GeneratedValue
private Long id;
private @Nullable Long id;
}

Loading…
Cancel
Save