Add nullability annotations to tests in module/spring-boot-jooq

See gh-47263
This commit is contained in:
Moritz Halbritter 2025-10-06 12:18:25 +02:00
parent 49c7546662
commit 1f293cc653
4 changed files with 9 additions and 3 deletions

View File

@ -43,3 +43,7 @@ dependencies {
testRuntimeOnly("org.glassfish.jaxb:jaxb-runtime")
testRuntimeOnly("org.hsqldb:hsqldb")
}
tasks.named("compileTestJava") {
options.nullability.checking = "tests"
}

View File

@ -50,6 +50,7 @@ class DefaultExceptionTranslatorExecuteListenerTests {
private final ExceptionTranslatorExecuteListener listener = new DefaultExceptionTranslatorExecuteListener();
@Test
@SuppressWarnings("NullAway") // Test null check
void createWhenTranslatorFactoryIsNullThrowsException() {
assertThatIllegalArgumentException()
.isThrownBy(() -> new DefaultExceptionTranslatorExecuteListener(
@ -74,7 +75,7 @@ class DefaultExceptionTranslatorExecuteListenerTests {
@Test
void exceptionWhenHasCustomTranslatorFactory() {
SQLExceptionTranslator translator = BadSqlGrammarException::new;
SQLExceptionTranslator translator = (task, sql, ex) -> new BadSqlGrammarException(task, "sql", ex);
ExceptionTranslatorExecuteListener listener = new DefaultExceptionTranslatorExecuteListener(
(context) -> translator);
SQLException sqlException = sqlException(123);

View File

@ -361,7 +361,7 @@ class JooqAutoConfigurationTests {
@Override
public ExecuteListener provide() {
return null;
return mock(ExecuteListener.class);
}
}

View File

@ -23,6 +23,7 @@ import java.sql.SQLException;
import javax.sql.DataSource;
import org.jooq.SQLDialect;
import org.jspecify.annotations.Nullable;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Test;
@ -44,7 +45,7 @@ import static org.mockito.Mockito.never;
*/
class JooqPropertiesTests {
private AnnotationConfigApplicationContext context;
private @Nullable AnnotationConfigApplicationContext context;
@AfterEach
void close() {