diff --git a/module/spring-boot-flyway/build.gradle b/module/spring-boot-flyway/build.gradle index 32f4bb6b6a9..08a9b159249 100644 --- a/module/spring-boot-flyway/build.gradle +++ b/module/spring-boot-flyway/build.gradle @@ -58,8 +58,18 @@ dependencies { testImplementation("org.postgresql:postgresql") testImplementation("org.springframework:spring-orm") + testCompileOnly("org.checkerframework:checker-qual") + testRuntimeOnly("ch.qos.logback:logback-classic") testRuntimeOnly("com.h2database:h2") testRuntimeOnly("com.zaxxer:HikariCP") testRuntimeOnly("org.flywaydb:flyway-database-hsqldb") } + +tasks.named("compileTestJava") { + options.nullability.checking = "tests" +} + +tasks.named("compileDockerTestJava") { + options.nullability.checking = "tests" +} diff --git a/module/spring-boot-flyway/src/test/java/org/springframework/boot/flyway/autoconfigure/FlywayAutoConfigurationTests.java b/module/spring-boot-flyway/src/test/java/org/springframework/boot/flyway/autoconfigure/FlywayAutoConfigurationTests.java index 383bb253627..f02c0380f7c 100644 --- a/module/spring-boot-flyway/src/test/java/org/springframework/boot/flyway/autoconfigure/FlywayAutoConfigurationTests.java +++ b/module/spring-boot-flyway/src/test/java/org/springframework/boot/flyway/autoconfigure/FlywayAutoConfigurationTests.java @@ -43,6 +43,7 @@ import org.flywaydb.core.api.callback.Event; import org.flywaydb.core.api.configuration.FluentConfiguration; import org.flywaydb.core.api.migration.JavaMigration; import org.flywaydb.core.api.pattern.ValidatePattern; +import org.flywaydb.core.internal.configuration.models.ResolvedEnvironment; import org.flywaydb.core.internal.license.FlywayEditionUpgradeRequiredException; import org.flywaydb.database.oracle.OracleConfigurationExtension; import org.flywaydb.database.postgresql.PostgreSQLConfigurationExtension; @@ -393,7 +394,9 @@ class FlywayAutoConfigurationTests { Flyway flyway = context.getBean(Flyway.class); SimpleDriverDataSource dataSource = (SimpleDriverDataSource) flyway.getConfiguration().getDataSource(); assertThat(dataSource.getUrl()).isEqualTo(jdbcUrl); - assertThat(dataSource.getDriver().getClass().getName()).isEqualTo(driverClassName); + java.sql.Driver driver = dataSource.getDriver(); + assertThat(driver).isNotNull(); + assertThat(driver.getClass().getName()).isEqualTo(driverClassName); }); } @@ -737,10 +740,11 @@ class FlywayAutoConfigurationTests { .withPropertyValues("spring.flyway.jdbc-properties.prop=value") .run((context) -> { Flyway flyway = context.getBean(Flyway.class); - assertThat(flyway.getConfiguration() + ResolvedEnvironment environment = flyway.getConfiguration() .getCachedResolvedEnvironments() - .get(flyway.getConfiguration().getCurrentEnvironmentName()) - .getJdbcProperties()).containsEntry("prop", "value"); + .get(flyway.getConfiguration().getCurrentEnvironmentName()); + assertThat(environment).isNotNull(); + assertThat(environment.getJdbcProperties()).containsEntry("prop", "value"); }); } @@ -1216,7 +1220,9 @@ class FlywayAutoConfigurationTests { @Override protected String getDatabaseName(DataSourceProperties properties) { - return properties.determineDatabaseName(); + String result = properties.determineDatabaseName(); + assertThat(result).isNotNull(); + return result; } } @@ -1356,18 +1362,23 @@ class FlywayAutoConfigurationTests { @Id @GeneratedValue + @SuppressWarnings("NullAway.Init") private Long id; @Column(nullable = false) + @SuppressWarnings("NullAway.Init") private String name; @Column(nullable = false) + @SuppressWarnings("NullAway.Init") private String state; @Column(nullable = false) + @SuppressWarnings("NullAway.Init") private String country; @Column(nullable = false) + @SuppressWarnings("NullAway.Init") private String map; protected City() { diff --git a/module/spring-boot-flyway/src/test/java/org/springframework/boot/flyway/endpoint/FlywayEndpointTests.java b/module/spring-boot-flyway/src/test/java/org/springframework/boot/flyway/endpoint/FlywayEndpointTests.java index b7779d43d31..5d10705ef7b 100644 --- a/module/spring-boot-flyway/src/test/java/org/springframework/boot/flyway/endpoint/FlywayEndpointTests.java +++ b/module/spring-boot-flyway/src/test/java/org/springframework/boot/flyway/endpoint/FlywayEndpointTests.java @@ -23,6 +23,7 @@ import org.junit.jupiter.api.Test; import org.springframework.boot.autoconfigure.AutoConfigurations; import org.springframework.boot.flyway.autoconfigure.FlywayAutoConfiguration; import org.springframework.boot.flyway.autoconfigure.FlywayMigrationStrategy; +import org.springframework.boot.flyway.endpoint.FlywayEndpoint.ContextFlywayBeansDescriptor; import org.springframework.boot.flyway.endpoint.FlywayEndpoint.FlywayDescriptor; import org.springframework.boot.jdbc.autoconfigure.EmbeddedDataSourceConfiguration; import org.springframework.boot.test.context.runner.ApplicationContextRunner; @@ -50,11 +51,12 @@ class FlywayEndpointTests { @Test void flywayReportIsProduced() { this.contextRunner.run((context) -> { - Map flywayBeans = context.getBean(FlywayEndpoint.class) + ContextFlywayBeansDescriptor descriptor = context.getBean(FlywayEndpoint.class) .flywayBeans() .getContexts() - .get(context.getId()) - .getFlywayBeans(); + .get(context.getId()); + assertThat(descriptor).isNotNull(); + Map flywayBeans = descriptor.getFlywayBeans(); assertThat(flywayBeans).hasSize(1); assertThat(flywayBeans.values().iterator().next().getMigrations()).hasSize(3); }); @@ -68,11 +70,12 @@ class FlywayEndpointTests { flyway.migrate(); }) .run((context) -> { - Map flywayBeans = context.getBean(FlywayEndpoint.class) + ContextFlywayBeansDescriptor descriptor = context.getBean(FlywayEndpoint.class) .flywayBeans() .getContexts() - .get(context.getId()) - .getFlywayBeans(); + .get(context.getId()); + assertThat(descriptor).isNotNull(); + Map flywayBeans = descriptor.getFlywayBeans(); assertThat(flywayBeans).hasSize(1); assertThat(flywayBeans.values().iterator().next().getMigrations()).hasSize(4); });