Add nullability annotations to tests in module/spring-boot-batch
See gh-47263
This commit is contained in:
parent
f3df45ace1
commit
4a30228978
|
@ -40,3 +40,7 @@ dependencies {
|
||||||
testRuntimeOnly("com.fasterxml.jackson.core:jackson-databind")
|
testRuntimeOnly("com.fasterxml.jackson.core:jackson-databind")
|
||||||
testRuntimeOnly("com.fasterxml.jackson.datatype:jackson-datatype-jsr310")
|
testRuntimeOnly("com.fasterxml.jackson.datatype:jackson-datatype-jsr310")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tasks.named("compileTestJava") {
|
||||||
|
options.nullability.checking = "tests"
|
||||||
|
}
|
||||||
|
|
|
@ -39,6 +39,7 @@ import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
import static org.mockito.Mockito.mock;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests for {@link BatchJobLauncherAutoConfiguration}.
|
* Tests for {@link BatchJobLauncherAutoConfiguration}.
|
||||||
|
@ -78,9 +79,10 @@ class BatchJobLauncherAutoConfigurationTests {
|
||||||
.run((context) -> {
|
.run((context) -> {
|
||||||
assertThat(context).hasSingleBean(JobOperator.class);
|
assertThat(context).hasSingleBean(JobOperator.class);
|
||||||
context.getBean(JobLauncherApplicationRunner.class).run();
|
context.getBean(JobLauncherApplicationRunner.class).run();
|
||||||
assertThat(context.getBean(JobRepository.class)
|
JobExecution lastJobExecution = context.getBean(JobRepository.class)
|
||||||
.getLastJobExecution("discreteRegisteredJob", new JobParameters())
|
.getLastJobExecution("discreteRegisteredJob", new JobParameters());
|
||||||
.getStatus()).isEqualTo(BatchStatus.COMPLETED);
|
assertThat(lastJobExecution).isNotNull();
|
||||||
|
assertThat(lastJobExecution.getStatus()).isEqualTo(BatchStatus.COMPLETED);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -100,8 +102,11 @@ class BatchJobLauncherAutoConfigurationTests {
|
||||||
void testMultipleJobsAndNoJobName() {
|
void testMultipleJobsAndNoJobName() {
|
||||||
this.contextRunner.withUserConfiguration(MultipleJobConfiguration.class).run((context) -> {
|
this.contextRunner.withUserConfiguration(MultipleJobConfiguration.class).run((context) -> {
|
||||||
assertThat(context).hasFailed();
|
assertThat(context).hasFailed();
|
||||||
assertThat(context.getStartupFailure().getCause().getMessage())
|
Throwable startupFailure = context.getStartupFailure();
|
||||||
.contains("Job name must be specified in case of multiple jobs");
|
assertThat(startupFailure).isNotNull();
|
||||||
|
Throwable cause = startupFailure.getCause();
|
||||||
|
assertThat(cause).isNotNull();
|
||||||
|
assertThat(cause.getMessage()).contains("Job name must be specified in case of multiple jobs");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -146,7 +151,7 @@ class BatchJobLauncherAutoConfigurationTests {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Step getStep(String stepName) {
|
public Step getStep(String stepName) {
|
||||||
return null;
|
return mock(Step.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -183,7 +188,7 @@ class BatchJobLauncherAutoConfigurationTests {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Step getStep(String stepName) {
|
public Step getStep(String stepName) {
|
||||||
return null;
|
return mock(Step.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -214,7 +219,7 @@ class BatchJobLauncherAutoConfigurationTests {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Step getStep(String stepName) {
|
public Step getStep(String stepName) {
|
||||||
return null;
|
return mock(Step.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -260,7 +265,7 @@ class BatchJobLauncherAutoConfigurationTests {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Step getStep(String stepName) {
|
public Step getStep(String stepName) {
|
||||||
return null;
|
return mock(Step.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in New Issue