Add nullability annotations to tests in module/spring-boot-integration
See gh-47263
This commit is contained in:
parent
cae3fb578c
commit
7f225a8df5
|
@ -50,3 +50,7 @@ dependencies {
|
|||
testRuntimeOnly("com.h2database:h2")
|
||||
testRuntimeOnly("com.zaxxer:HikariCP")
|
||||
}
|
||||
|
||||
tasks.named("compileTestJava") {
|
||||
options.nullability.checking = "tests"
|
||||
}
|
||||
|
|
|
@ -31,6 +31,7 @@ import io.micrometer.observation.ObservationRegistry;
|
|||
import io.rsocket.transport.ClientTransport;
|
||||
import io.rsocket.transport.netty.client.TcpClientTransport;
|
||||
import org.assertj.core.api.InstanceOfAssertFactories;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.condition.EnabledForJreRange;
|
||||
import org.junit.jupiter.api.condition.JRE;
|
||||
|
@ -38,6 +39,7 @@ import reactor.core.publisher.Mono;
|
|||
|
||||
import org.springframework.beans.DirectFieldAccessor;
|
||||
import org.springframework.beans.PropertyAccessorFactory;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.AutoConfigurations;
|
||||
import org.springframework.boot.autoconfigure.jmx.JmxAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.task.TaskSchedulingAutoConfiguration;
|
||||
|
@ -421,7 +423,7 @@ class IntegrationAutoConfigurationTests {
|
|||
.withPropertyValues("spring.integration.channel.auto-create=false",
|
||||
"spring.integration.endpoint.read-only-headers=ignoredHeader")
|
||||
.withInitializer((applicationContext) -> new IntegrationPropertiesEnvironmentPostProcessor()
|
||||
.postProcessEnvironment(applicationContext.getEnvironment(), null))
|
||||
.postProcessEnvironment(applicationContext.getEnvironment(), new SpringApplication()))
|
||||
.run((context) -> {
|
||||
assertThat(context).hasSingleBean(org.springframework.integration.context.IntegrationProperties.class);
|
||||
org.springframework.integration.context.IntegrationProperties integrationProperties = context
|
||||
|
@ -644,7 +646,7 @@ class IntegrationAutoConfigurationTests {
|
|||
|
||||
@Override
|
||||
public Mono<Void> handleMessage(Message<?> message) {
|
||||
return null;
|
||||
return Mono.empty();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -707,7 +709,7 @@ class IntegrationAutoConfigurationTests {
|
|||
this.name = name;
|
||||
}
|
||||
|
||||
Object get(org.springframework.integration.context.IntegrationProperties properties) {
|
||||
@Nullable Object get(org.springframework.integration.context.IntegrationProperties properties) {
|
||||
return ReflectionTestUtils.invokeMethod(properties, this.name);
|
||||
}
|
||||
|
||||
|
|
|
@ -36,6 +36,7 @@ import org.springframework.boot.context.properties.bind.Binder;
|
|||
import org.springframework.boot.origin.Origin;
|
||||
import org.springframework.boot.origin.OriginLookup;
|
||||
import org.springframework.boot.origin.TextResourceOrigin;
|
||||
import org.springframework.boot.origin.TextResourceOrigin.Location;
|
||||
import org.springframework.boot.testsupport.classpath.resources.WithResource;
|
||||
import org.springframework.core.env.ConfigurableEnvironment;
|
||||
import org.springframework.core.env.MapPropertySource;
|
||||
|
@ -141,6 +142,7 @@ class IntegrationPropertiesEnvironmentPostProcessorTests {
|
|||
.formatted(IntegrationPropertiesEnvironmentPostProcessor.class.getName()), getClass().getClassLoader());
|
||||
Map<String, String> mappings = (Map<String, String>) ReflectionTestUtils.getField(propertySource,
|
||||
"KEYS_MAPPING");
|
||||
assertThat(mappings).isNotNull();
|
||||
assertThat(mappings.values()).containsExactlyInAnyOrderElementsOf(integrationPropertyNames());
|
||||
}
|
||||
|
||||
|
@ -148,6 +150,7 @@ class IntegrationPropertiesEnvironmentPostProcessorTests {
|
|||
List<String> propertiesToMap = new ArrayList<>();
|
||||
ReflectionUtils.doWithFields(IntegrationProperties.class, (field) -> {
|
||||
String value = (String) ReflectionUtils.getField(field, null);
|
||||
assertThat(value).isNotNull();
|
||||
if (value.startsWith(IntegrationProperties.INTEGRATION_PROPERTIES_PREFIX)
|
||||
&& value.length() > IntegrationProperties.INTEGRATION_PROPERTIES_PREFIX.length()) {
|
||||
propertiesToMap.add(value);
|
||||
|
@ -177,6 +180,7 @@ class IntegrationPropertiesEnvironmentPostProcessorTests {
|
|||
.formatted(IntegrationPropertiesEnvironmentPostProcessor.class.getName()), null);
|
||||
Map<String, String> mappings = (Map<String, String>) ReflectionTestUtils.getField(propertySource,
|
||||
"KEYS_MAPPING");
|
||||
assertThat(mappings).isNotNull();
|
||||
return mappings.keySet();
|
||||
}
|
||||
catch (Exception ex) {
|
||||
|
@ -189,8 +193,10 @@ class IntegrationPropertiesEnvironmentPostProcessorTests {
|
|||
assertThat(origin).isInstanceOf(TextResourceOrigin.class);
|
||||
TextResourceOrigin textOrigin = (TextResourceOrigin) origin;
|
||||
assertThat(textOrigin.getResource()).isEqualTo(resource);
|
||||
assertThat(textOrigin.getLocation().getLine()).isEqualTo(line);
|
||||
assertThat(textOrigin.getLocation().getColumn()).isEqualTo(column);
|
||||
Location location = textOrigin.getLocation();
|
||||
assertThat(location).isNotNull();
|
||||
assertThat(location.getLine()).isEqualTo(line);
|
||||
assertThat(location.getColumn()).isEqualTo(column);
|
||||
};
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue