Skip to content

Commit 1f293cc

Browse files
committed
Add nullability annotations to tests in module/spring-boot-jooq
See gh-47263
1 parent 49c7546 commit 1f293cc

File tree

4 files changed

+9
-3
lines changed

4 files changed

+9
-3
lines changed

module/spring-boot-jooq/build.gradle

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,7 @@ dependencies {
4343
testRuntimeOnly("org.glassfish.jaxb:jaxb-runtime")
4444
testRuntimeOnly("org.hsqldb:hsqldb")
4545
}
46+
47+
tasks.named("compileTestJava") {
48+
options.nullability.checking = "tests"
49+
}

module/spring-boot-jooq/src/test/java/org/springframework/boot/jooq/autoconfigure/DefaultExceptionTranslatorExecuteListenerTests.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ class DefaultExceptionTranslatorExecuteListenerTests {
5050
private final ExceptionTranslatorExecuteListener listener = new DefaultExceptionTranslatorExecuteListener();
5151

5252
@Test
53+
@SuppressWarnings("NullAway") // Test null check
5354
void createWhenTranslatorFactoryIsNullThrowsException() {
5455
assertThatIllegalArgumentException()
5556
.isThrownBy(() -> new DefaultExceptionTranslatorExecuteListener(
@@ -74,7 +75,7 @@ void exceptionWhenExceptionCannotBeTranslatedDoesNotCallExecuteContextException(
7475

7576
@Test
7677
void exceptionWhenHasCustomTranslatorFactory() {
77-
SQLExceptionTranslator translator = BadSqlGrammarException::new;
78+
SQLExceptionTranslator translator = (task, sql, ex) -> new BadSqlGrammarException(task, "sql", ex);
7879
ExceptionTranslatorExecuteListener listener = new DefaultExceptionTranslatorExecuteListener(
7980
(context) -> translator);
8081
SQLException sqlException = sqlException(123);

module/spring-boot-jooq/src/test/java/org/springframework/boot/jooq/autoconfigure/JooqAutoConfigurationTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,7 @@ static class TestExecuteListenerProvider implements ExecuteListenerProvider {
361361

362362
@Override
363363
public ExecuteListener provide() {
364-
return null;
364+
return mock(ExecuteListener.class);
365365
}
366366

367367
}

module/spring-boot-jooq/src/test/java/org/springframework/boot/jooq/autoconfigure/JooqPropertiesTests.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import javax.sql.DataSource;
2424

2525
import org.jooq.SQLDialect;
26+
import org.jspecify.annotations.Nullable;
2627
import org.junit.jupiter.api.AfterEach;
2728
import org.junit.jupiter.api.Test;
2829

@@ -44,7 +45,7 @@
4445
*/
4546
class JooqPropertiesTests {
4647

47-
private AnnotationConfigApplicationContext context;
48+
private @Nullable AnnotationConfigApplicationContext context;
4849

4950
@AfterEach
5051
void close() {

0 commit comments

Comments
 (0)