Add nullability annotations to tests in core/spring-boot-properties-migrator

See gh-47263
This commit is contained in:
Moritz Halbritter 2025-09-10 11:45:52 +02:00
parent ea05f6df15
commit 532ea9abc1
3 changed files with 13 additions and 6 deletions

View File

@ -34,4 +34,8 @@ dependencies {
tasks.named("javadoc").configure {
// No public or protected classes
enabled = false
}
}
tasks.named("compileTestJava") {
options.nullability.checking = "tests"
}

View File

@ -16,6 +16,7 @@
package org.springframework.boot.context.properties.migrator;
import org.jspecify.annotations.Nullable;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
@ -36,7 +37,7 @@ import static org.assertj.core.api.Assertions.assertThat;
@ExtendWith(OutputCaptureExtension.class)
class PropertiesMigrationListenerTests {
private ConfigurableApplicationContext context;
private @Nullable ConfigurableApplicationContext context;
@AfterEach
void closeContext() {

View File

@ -23,6 +23,7 @@ import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import org.jspecify.annotations.Nullable;
import org.junit.jupiter.api.Test;
import org.springframework.boot.configurationmetadata.ConfigurationMetadataRepository;
@ -230,12 +231,13 @@ class PropertiesMigrationReporterTests {
}
@SuppressWarnings("unchecked")
private Origin getOrigin(PropertySource<?> propertySource, String name) {
private @Nullable Origin getOrigin(PropertySource<?> propertySource, String name) {
return ((OriginLookup<String>) propertySource).getOrigin(name);
}
@SuppressWarnings("unchecked")
private void assertMappedProperty(PropertySource<?> propertySource, String name, Object value, Origin origin) {
private void assertMappedProperty(PropertySource<?> propertySource, String name, Object value,
@Nullable Origin origin) {
assertThat(propertySource.containsProperty(name)).isTrue();
assertThat(propertySource.getProperty(name)).isEqualTo(value);
if (origin != null) {
@ -269,11 +271,11 @@ class PropertiesMigrationReporterTests {
}
}
private String createWarningReport(ConfigurationMetadataRepository repository) {
private @Nullable String createWarningReport(ConfigurationMetadataRepository repository) {
return createAnalyzer(repository).getReport().getWarningReport();
}
private String createErrorReport(ConfigurationMetadataRepository repository) {
private @Nullable String createErrorReport(ConfigurationMetadataRepository repository) {
return createAnalyzer(repository).getReport().getErrorReport();
}