Add nullability annotations to tests in module/spring-boot-flyway
See gh-47263
This commit is contained in:
parent
0753e7dbf2
commit
657c537cc2
|
@ -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"
|
||||
}
|
||||
|
|
|
@ -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() {
|
||||
|
|
|
@ -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<String, FlywayDescriptor> flywayBeans = context.getBean(FlywayEndpoint.class)
|
||||
ContextFlywayBeansDescriptor descriptor = context.getBean(FlywayEndpoint.class)
|
||||
.flywayBeans()
|
||||
.getContexts()
|
||||
.get(context.getId())
|
||||
.getFlywayBeans();
|
||||
.get(context.getId());
|
||||
assertThat(descriptor).isNotNull();
|
||||
Map<String, FlywayDescriptor> 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<String, FlywayDescriptor> flywayBeans = context.getBean(FlywayEndpoint.class)
|
||||
ContextFlywayBeansDescriptor descriptor = context.getBean(FlywayEndpoint.class)
|
||||
.flywayBeans()
|
||||
.getContexts()
|
||||
.get(context.getId())
|
||||
.getFlywayBeans();
|
||||
.get(context.getId());
|
||||
assertThat(descriptor).isNotNull();
|
||||
Map<String, FlywayDescriptor> flywayBeans = descriptor.getFlywayBeans();
|
||||
assertThat(flywayBeans).hasSize(1);
|
||||
assertThat(flywayBeans.values().iterator().next().getMigrations()).hasSize(4);
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue