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.postgresql:postgresql")
|
||||||
testImplementation("org.springframework:spring-orm")
|
testImplementation("org.springframework:spring-orm")
|
||||||
|
|
||||||
|
testCompileOnly("org.checkerframework:checker-qual")
|
||||||
|
|
||||||
testRuntimeOnly("ch.qos.logback:logback-classic")
|
testRuntimeOnly("ch.qos.logback:logback-classic")
|
||||||
testRuntimeOnly("com.h2database:h2")
|
testRuntimeOnly("com.h2database:h2")
|
||||||
testRuntimeOnly("com.zaxxer:HikariCP")
|
testRuntimeOnly("com.zaxxer:HikariCP")
|
||||||
testRuntimeOnly("org.flywaydb:flyway-database-hsqldb")
|
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.configuration.FluentConfiguration;
|
||||||
import org.flywaydb.core.api.migration.JavaMigration;
|
import org.flywaydb.core.api.migration.JavaMigration;
|
||||||
import org.flywaydb.core.api.pattern.ValidatePattern;
|
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.core.internal.license.FlywayEditionUpgradeRequiredException;
|
||||||
import org.flywaydb.database.oracle.OracleConfigurationExtension;
|
import org.flywaydb.database.oracle.OracleConfigurationExtension;
|
||||||
import org.flywaydb.database.postgresql.PostgreSQLConfigurationExtension;
|
import org.flywaydb.database.postgresql.PostgreSQLConfigurationExtension;
|
||||||
|
@ -393,7 +394,9 @@ class FlywayAutoConfigurationTests {
|
||||||
Flyway flyway = context.getBean(Flyway.class);
|
Flyway flyway = context.getBean(Flyway.class);
|
||||||
SimpleDriverDataSource dataSource = (SimpleDriverDataSource) flyway.getConfiguration().getDataSource();
|
SimpleDriverDataSource dataSource = (SimpleDriverDataSource) flyway.getConfiguration().getDataSource();
|
||||||
assertThat(dataSource.getUrl()).isEqualTo(jdbcUrl);
|
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")
|
.withPropertyValues("spring.flyway.jdbc-properties.prop=value")
|
||||||
.run((context) -> {
|
.run((context) -> {
|
||||||
Flyway flyway = context.getBean(Flyway.class);
|
Flyway flyway = context.getBean(Flyway.class);
|
||||||
assertThat(flyway.getConfiguration()
|
ResolvedEnvironment environment = flyway.getConfiguration()
|
||||||
.getCachedResolvedEnvironments()
|
.getCachedResolvedEnvironments()
|
||||||
.get(flyway.getConfiguration().getCurrentEnvironmentName())
|
.get(flyway.getConfiguration().getCurrentEnvironmentName());
|
||||||
.getJdbcProperties()).containsEntry("prop", "value");
|
assertThat(environment).isNotNull();
|
||||||
|
assertThat(environment.getJdbcProperties()).containsEntry("prop", "value");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1216,7 +1220,9 @@ class FlywayAutoConfigurationTests {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected String getDatabaseName(DataSourceProperties properties) {
|
protected String getDatabaseName(DataSourceProperties properties) {
|
||||||
return properties.determineDatabaseName();
|
String result = properties.determineDatabaseName();
|
||||||
|
assertThat(result).isNotNull();
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1356,18 +1362,23 @@ class FlywayAutoConfigurationTests {
|
||||||
|
|
||||||
@Id
|
@Id
|
||||||
@GeneratedValue
|
@GeneratedValue
|
||||||
|
@SuppressWarnings("NullAway.Init")
|
||||||
private Long id;
|
private Long id;
|
||||||
|
|
||||||
@Column(nullable = false)
|
@Column(nullable = false)
|
||||||
|
@SuppressWarnings("NullAway.Init")
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
@Column(nullable = false)
|
@Column(nullable = false)
|
||||||
|
@SuppressWarnings("NullAway.Init")
|
||||||
private String state;
|
private String state;
|
||||||
|
|
||||||
@Column(nullable = false)
|
@Column(nullable = false)
|
||||||
|
@SuppressWarnings("NullAway.Init")
|
||||||
private String country;
|
private String country;
|
||||||
|
|
||||||
@Column(nullable = false)
|
@Column(nullable = false)
|
||||||
|
@SuppressWarnings("NullAway.Init")
|
||||||
private String map;
|
private String map;
|
||||||
|
|
||||||
protected City() {
|
protected City() {
|
||||||
|
|
|
@ -23,6 +23,7 @@ import org.junit.jupiter.api.Test;
|
||||||
import org.springframework.boot.autoconfigure.AutoConfigurations;
|
import org.springframework.boot.autoconfigure.AutoConfigurations;
|
||||||
import org.springframework.boot.flyway.autoconfigure.FlywayAutoConfiguration;
|
import org.springframework.boot.flyway.autoconfigure.FlywayAutoConfiguration;
|
||||||
import org.springframework.boot.flyway.autoconfigure.FlywayMigrationStrategy;
|
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.flyway.endpoint.FlywayEndpoint.FlywayDescriptor;
|
||||||
import org.springframework.boot.jdbc.autoconfigure.EmbeddedDataSourceConfiguration;
|
import org.springframework.boot.jdbc.autoconfigure.EmbeddedDataSourceConfiguration;
|
||||||
import org.springframework.boot.test.context.runner.ApplicationContextRunner;
|
import org.springframework.boot.test.context.runner.ApplicationContextRunner;
|
||||||
|
@ -50,11 +51,12 @@ class FlywayEndpointTests {
|
||||||
@Test
|
@Test
|
||||||
void flywayReportIsProduced() {
|
void flywayReportIsProduced() {
|
||||||
this.contextRunner.run((context) -> {
|
this.contextRunner.run((context) -> {
|
||||||
Map<String, FlywayDescriptor> flywayBeans = context.getBean(FlywayEndpoint.class)
|
ContextFlywayBeansDescriptor descriptor = context.getBean(FlywayEndpoint.class)
|
||||||
.flywayBeans()
|
.flywayBeans()
|
||||||
.getContexts()
|
.getContexts()
|
||||||
.get(context.getId())
|
.get(context.getId());
|
||||||
.getFlywayBeans();
|
assertThat(descriptor).isNotNull();
|
||||||
|
Map<String, FlywayDescriptor> flywayBeans = descriptor.getFlywayBeans();
|
||||||
assertThat(flywayBeans).hasSize(1);
|
assertThat(flywayBeans).hasSize(1);
|
||||||
assertThat(flywayBeans.values().iterator().next().getMigrations()).hasSize(3);
|
assertThat(flywayBeans.values().iterator().next().getMigrations()).hasSize(3);
|
||||||
});
|
});
|
||||||
|
@ -68,11 +70,12 @@ class FlywayEndpointTests {
|
||||||
flyway.migrate();
|
flyway.migrate();
|
||||||
})
|
})
|
||||||
.run((context) -> {
|
.run((context) -> {
|
||||||
Map<String, FlywayDescriptor> flywayBeans = context.getBean(FlywayEndpoint.class)
|
ContextFlywayBeansDescriptor descriptor = context.getBean(FlywayEndpoint.class)
|
||||||
.flywayBeans()
|
.flywayBeans()
|
||||||
.getContexts()
|
.getContexts()
|
||||||
.get(context.getId())
|
.get(context.getId());
|
||||||
.getFlywayBeans();
|
assertThat(descriptor).isNotNull();
|
||||||
|
Map<String, FlywayDescriptor> flywayBeans = descriptor.getFlywayBeans();
|
||||||
assertThat(flywayBeans).hasSize(1);
|
assertThat(flywayBeans).hasSize(1);
|
||||||
assertThat(flywayBeans.values().iterator().next().getMigrations()).hasSize(4);
|
assertThat(flywayBeans.values().iterator().next().getMigrations()).hasSize(4);
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue