Skip to content

Commit 8cd7c22

Browse files
committed
Polish "Start building against Spring Batch 6.0.0-RC1 snapshots"
See gh-47477
1 parent 491019d commit 8cd7c22

File tree

2 files changed

+14
-15
lines changed

2 files changed

+14
-15
lines changed

module/spring-boot-batch/src/main/java/org/springframework/boot/batch/autoconfigure/JobLauncherApplicationRunner.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -179,9 +179,8 @@ private void executeRegisteredJobs(JobParameters jobParameters) throws JobExecut
179179
if (this.jobRegistry != null && StringUtils.hasText(this.jobName)) {
180180
if (!isLocalJob(this.jobName)) {
181181
Job job = this.jobRegistry.getJob(this.jobName);
182-
if (job != null) {
183-
execute(job, jobParameters);
184-
}
182+
Assert.notNull(job, () -> "No job found with name '" + this.jobName + "'");
183+
execute(job, jobParameters);
185184
}
186185
}
187186
}

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

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -29,36 +29,36 @@
2929
* Tests for {@link JobExecutionExitCodeGenerator}.
3030
*
3131
* @author Dave Syer
32-
* @author Mahmoud Ben Hassine
3332
*/
3433
class JobExecutionExitCodeGeneratorTests {
3534

3635
private final JobExecutionExitCodeGenerator generator = new JobExecutionExitCodeGenerator();
3736

3837
@Test
3938
void testExitCodeForRunning() {
40-
JobInstance jobInstance = new JobInstance(1L, "job");
41-
JobExecution jobExecution = new JobExecution(1L, jobInstance, new JobParameters());
42-
this.generator.onApplicationEvent(new JobExecutionEvent(jobExecution));
39+
this.generator.onApplicationEvent(new JobExecutionEvent(testJobExecution()));
4340
assertThat(this.generator.getExitCode()).isOne();
4441
}
4542

4643
@Test
4744
void testExitCodeForCompleted() {
48-
JobInstance jobInstance = new JobInstance(1L, "job");
49-
JobExecution jobExecution = new JobExecution(1L, jobInstance, new JobParameters());
50-
jobExecution.setStatus(BatchStatus.COMPLETED);
51-
this.generator.onApplicationEvent(new JobExecutionEvent(jobExecution));
45+
JobExecution execution = testJobExecution();
46+
execution.setStatus(BatchStatus.COMPLETED);
47+
this.generator.onApplicationEvent(new JobExecutionEvent(execution));
5248
assertThat(this.generator.getExitCode()).isZero();
5349
}
5450

5551
@Test
5652
void testExitCodeForFailed() {
57-
JobInstance jobInstance = new JobInstance(1L, "job");
58-
JobExecution jobExecution = new JobExecution(1L, jobInstance, new JobParameters());
59-
jobExecution.setStatus(BatchStatus.FAILED);
60-
this.generator.onApplicationEvent(new JobExecutionEvent(jobExecution));
53+
JobExecution execution = testJobExecution();
54+
execution.setStatus(BatchStatus.FAILED);
55+
this.generator.onApplicationEvent(new JobExecutionEvent(execution));
6156
assertThat(this.generator.getExitCode()).isEqualTo(5);
6257
}
6358

59+
private static JobExecution testJobExecution() {
60+
JobInstance jobInstance = new JobInstance(1L, "job");
61+
return new JobExecution(0L, jobInstance, new JobParameters());
62+
}
63+
6464
}

0 commit comments

Comments
 (0)