Browse Source

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

See gh-47263
pull/47387/head
Moritz Halbritter 5 months ago
parent
commit
532ea9abc1
  1. 6
      core/spring-boot-properties-migrator/build.gradle
  2. 3
      core/spring-boot-properties-migrator/src/test/java/org/springframework/boot/context/properties/migrator/PropertiesMigrationListenerTests.java
  3. 10
      core/spring-boot-properties-migrator/src/test/java/org/springframework/boot/context/properties/migrator/PropertiesMigrationReporterTests.java

6
core/spring-boot-properties-migrator/build.gradle

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

3
core/spring-boot-properties-migrator/src/test/java/org/springframework/boot/context/properties/migrator/PropertiesMigrationListenerTests.java

@ -16,6 +16,7 @@ @@ -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; @@ -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() {

10
core/spring-boot-properties-migrator/src/test/java/org/springframework/boot/context/properties/migrator/PropertiesMigrationReporterTests.java

@ -23,6 +23,7 @@ import java.util.LinkedHashMap; @@ -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 { @@ -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 { @@ -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();
}

Loading…
Cancel
Save