Add nullability annotations to tests in module/spring-boot-data-cassandra

See gh-47263
This commit is contained in:
Moritz Halbritter 2025-09-18 12:24:38 +02:00
parent f5d6bea934
commit 4a62872d63
4 changed files with 16 additions and 3 deletions

View File

@ -45,3 +45,11 @@ dependencies {
testRuntimeOnly("ch.qos.logback:logback-classic")
}
tasks.named("compileTestJava") {
options.nullability.checking = "tests"
}
tasks.named("compileDockerTestJava") {
options.nullability.checking = "tests"
}

View File

@ -19,6 +19,7 @@ package org.springframework.boot.data.cassandra.autoconfigure;
import java.util.Collections;
import com.datastax.oss.driver.api.core.CqlSession;
import org.jspecify.annotations.Nullable;
import org.junit.jupiter.api.Test;
import org.springframework.boot.autoconfigure.AutoConfigurations;
@ -144,7 +145,7 @@ class DataCassandraAutoConfigurationTests {
static class MyConverter implements Converter<Person, String> {
@Override
public String convert(Person o) {
public @Nullable String convert(Person o) {
return null;
}

View File

@ -94,7 +94,9 @@ class DataCassandraReactiveRepositoriesAutoConfigurationTests {
private ManagedTypes getManagedTypes(ApplicationContext context) {
CassandraMappingContext mappingContext = context.getBean(CassandraMappingContext.class);
return (ManagedTypes) ReflectionTestUtils.getField(mappingContext, "managedTypes");
Object field = ReflectionTestUtils.getField(mappingContext, "managedTypes");
assertThat(field).isNotNull();
return (ManagedTypes) field;
}
@Configuration(proxyBeanMethods = false)

View File

@ -91,7 +91,9 @@ class DataCassandraRepositoriesAutoConfigurationTests {
private ManagedTypes getManagedTypes(AssertableApplicationContext context) {
CassandraMappingContext mappingContext = context.getBean(CassandraMappingContext.class);
return (ManagedTypes) ReflectionTestUtils.getField(mappingContext, "managedTypes");
Object field = ReflectionTestUtils.getField(mappingContext, "managedTypes");
assertThat(field).isNotNull();
return (ManagedTypes) field;
}
@Configuration(proxyBeanMethods = false)