Skip to content

Commit 8c25063

Browse files
committed
Add nullability annotations to tests in module/spring-boot-liquibase
See gh-47263
1 parent 4893362 commit 8c25063

File tree

3 files changed

+19
-4
lines changed

3 files changed

+19
-4
lines changed

module/spring-boot-liquibase/build.gradle

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,3 +56,11 @@ dependencies {
5656
testRuntimeOnly("ch.qos.logback:logback-classic")
5757
testRuntimeOnly("org.postgresql:postgresql")
5858
}
59+
60+
tasks.named("compileTestJava") {
61+
options.nullability.checking = "tests"
62+
}
63+
64+
tasks.named("compileDockerTestJava") {
65+
options.nullability.checking = "tests"
66+
}

module/spring-boot-liquibase/src/test/java/org/springframework/boot/liquibase/LiquibaseChangelogMissingFailureAnalyzerTests.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
import com.zaxxer.hikari.HikariDataSource;
2222
import liquibase.integration.spring.SpringLiquibase;
23+
import org.jspecify.annotations.Nullable;
2324
import org.junit.jupiter.api.Test;
2425

2526
import org.springframework.beans.factory.BeanCreationException;
@@ -40,20 +41,21 @@ class LiquibaseChangelogMissingFailureAnalyzerTests {
4041
@Test
4142
void changelogParseExceptionDueToChangelogNotPresent() {
4243
FailureAnalysis analysis = performAnalysis();
44+
assertThat(analysis).isNotNull();
4345
assertThat(analysis.getDescription())
4446
.isEqualTo("Liquibase failed to start because no changelog could be found at '"
4547
+ "classpath:/db/changelog/db.changelog-master.yaml'.");
4648
assertThat(analysis.getAction())
4749
.isEqualTo("Make sure a Liquibase changelog is present at the configured path.");
4850
}
4951

50-
private FailureAnalysis performAnalysis() {
52+
private @Nullable FailureAnalysis performAnalysis() {
5153
BeanCreationException failure = createFailure();
5254
assertThat(failure).isNotNull();
5355
return new LiquibaseChangelogMissingFailureAnalyzer().analyze(failure);
5456
}
5557

56-
private BeanCreationException createFailure() {
58+
private @Nullable BeanCreationException createFailure() {
5759
try (AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(
5860
LiquibaseConfiguration.class)) {
5961
return null;

module/spring-boot-liquibase/src/test/java/org/springframework/boot/liquibase/autoconfigure/LiquibaseAutoConfigurationTests.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import java.nio.file.Files;
2626
import java.nio.file.Path;
2727
import java.sql.Connection;
28+
import java.sql.Driver;
2829
import java.sql.SQLException;
2930
import java.util.Map;
3031
import java.util.UUID;
@@ -334,7 +335,9 @@ void overrideDataSource() {
334335
.run(assertLiquibase((liquibase) -> {
335336
SimpleDriverDataSource dataSource = (SimpleDriverDataSource) liquibase.getDataSource();
336337
assertThat(dataSource.getUrl()).isEqualTo(jdbcUrl);
337-
assertThat(dataSource.getDriver().getClass().getName()).isEqualTo("org.h2.Driver");
338+
Driver driver = dataSource.getDriver();
339+
assertThat(driver).isNotNull();
340+
assertThat(driver.getClass().getName()).isEqualTo("org.h2.Driver");
338341
}));
339342
}
340343

@@ -349,7 +352,9 @@ void overrideDataSourceAndDriverClassName() {
349352
.run(assertLiquibase((liquibase) -> {
350353
SimpleDriverDataSource dataSource = (SimpleDriverDataSource) liquibase.getDataSource();
351354
assertThat(dataSource.getUrl()).isEqualTo(jdbcUrl);
352-
assertThat(dataSource.getDriver().getClass().getName()).isEqualTo(driverClassName);
355+
Driver driver = dataSource.getDriver();
356+
assertThat(driver).isNotNull();
357+
assertThat(driver.getClass().getName()).isEqualTo(driverClassName);
353358
}));
354359
}
355360

0 commit comments

Comments
 (0)