Skip to content

Commit c65a259

Browse files
committed
Add nullability annotations to tests in module/spring-boot-batch-jdbc
See gh-47263
1 parent 1b44baf commit c65a259

File tree

2 files changed

+17
-9
lines changed

2 files changed

+17
-9
lines changed

module/spring-boot-batch-jdbc/build.gradle

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,7 @@ dependencies {
4747
testRuntimeOnly("com.h2database:h2")
4848
testRuntimeOnly("com.zaxxer:HikariCP")
4949
}
50+
51+
tasks.named("compileTestJava") {
52+
options.nullability.checking = "tests"
53+
}

module/spring-boot-batch-jdbc/src/test/java/org/springframework/boot/batch/jdbc/autoconfigure/BatchJdbcAutoConfigurationTests.java

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -189,9 +189,10 @@ void testRegisteredAndLocalJob() {
189189
.run((context) -> {
190190
assertThat(context).hasSingleBean(JobOperator.class);
191191
context.getBean(JobLauncherApplicationRunner.class).run();
192-
assertThat(context.getBean(JobRepository.class)
193-
.getLastJobExecution("discreteRegisteredJob", new JobParameters())
194-
.getStatus()).isEqualTo(BatchStatus.COMPLETED);
192+
JobExecution lastJobExecution = context.getBean(JobRepository.class)
193+
.getLastJobExecution("discreteRegisteredJob", new JobParameters());
194+
assertThat(lastJobExecution).isNotNull();
195+
assertThat(lastJobExecution.getStatus()).isEqualTo(BatchStatus.COMPLETED);
195196
});
196197
}
197198

@@ -213,8 +214,11 @@ void testMultipleJobsAndNoJobName() {
213214
this.contextRunner.withUserConfiguration(MultipleJobConfiguration.class, EmbeddedDataSourceConfiguration.class)
214215
.run((context) -> {
215216
assertThat(context).hasFailed();
216-
assertThat(context.getStartupFailure().getCause().getMessage())
217-
.contains("Job name must be specified in case of multiple jobs");
217+
Throwable startupFailure = context.getStartupFailure();
218+
assertThat(startupFailure).isNotNull();
219+
Throwable cause = startupFailure.getCause();
220+
assertThat(cause).isNotNull();
221+
assertThat(cause.getMessage()).contains("Job name must be specified in case of multiple jobs");
218222
});
219223
}
220224

@@ -642,7 +646,7 @@ public Collection<String> getStepNames() {
642646

643647
@Override
644648
public Step getStep(String stepName) {
645-
return null;
649+
return mock(Step.class);
646650
}
647651

648652
@Override
@@ -679,7 +683,7 @@ public Collection<String> getStepNames() {
679683

680684
@Override
681685
public Step getStep(String stepName) {
682-
return null;
686+
return mock(Step.class);
683687
}
684688

685689
@Override
@@ -710,7 +714,7 @@ public Collection<String> getStepNames() {
710714

711715
@Override
712716
public Step getStep(String stepName) {
713-
return null;
717+
return mock(Step.class);
714718
}
715719

716720
@Override
@@ -756,7 +760,7 @@ public Collection<String> getStepNames() {
756760

757761
@Override
758762
public Step getStep(String stepName) {
759-
return null;
763+
return mock(Step.class);
760764
}
761765

762766
@Override

0 commit comments

Comments
 (0)