Replace usage of deprecated jobOperator#start method with newer version
Related to #4303
This commit is contained in:
committed by
Mahmoud Ben Hassine
parent
b76993ca3d
commit
2cc0be4a0c
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2022 the original author or authors.
|
||||
* Copyright 2006-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -39,6 +39,7 @@ import org.springframework.batch.core.StepContribution;
|
||||
import org.springframework.batch.core.configuration.JobRegistry;
|
||||
import org.springframework.batch.core.configuration.support.MapJobRegistry;
|
||||
import org.springframework.batch.core.converter.DefaultJobParametersConverter;
|
||||
import org.springframework.batch.core.converter.JobParametersConverter;
|
||||
import org.springframework.batch.core.explore.JobExplorer;
|
||||
import org.springframework.batch.core.job.AbstractJob;
|
||||
import org.springframework.batch.core.job.JobSupport;
|
||||
@@ -69,6 +70,7 @@ import static org.mockito.Mockito.when;
|
||||
* @author Dave Syer
|
||||
* @author Will Schipp
|
||||
* @author Mahmoud Ben Hassine
|
||||
* @author Jinwoo Bae
|
||||
*
|
||||
*/
|
||||
class SimpleJobOperatorTests {
|
||||
@@ -83,9 +85,13 @@ class SimpleJobOperatorTests {
|
||||
|
||||
private JobParameters jobParameters;
|
||||
|
||||
private JobParametersConverter jobParametersConverter;
|
||||
|
||||
@BeforeEach
|
||||
void setUp() throws Exception {
|
||||
|
||||
jobParametersConverter = new DefaultJobParametersConverter();
|
||||
|
||||
job = new JobSupport("foo") {
|
||||
@Nullable
|
||||
@Override
|
||||
@@ -162,18 +168,23 @@ class SimpleJobOperatorTests {
|
||||
|
||||
@Test
|
||||
void testStartNewInstanceSunnyDay() throws Exception {
|
||||
jobParameters = new JobParameters();
|
||||
Properties parameters = new Properties();
|
||||
parameters.setProperty("a", "b");
|
||||
JobParameters jobParameters = jobParametersConverter.getJobParameters(parameters);
|
||||
|
||||
jobRepository.isJobInstanceExists("foo", jobParameters);
|
||||
Long value = jobOperator.start("foo", "a=b");
|
||||
Long value = jobOperator.start("foo", parameters);
|
||||
assertEquals(999, value.longValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
void testStartNewInstanceAlreadyExists() {
|
||||
Properties properties = new Properties();
|
||||
properties.setProperty("a", "b");
|
||||
jobParameters = new JobParameters();
|
||||
when(jobRepository.isJobInstanceExists("foo", jobParameters)).thenReturn(true);
|
||||
jobRepository.isJobInstanceExists("foo", jobParameters);
|
||||
assertThrows(JobInstanceAlreadyExistsException.class, () -> jobOperator.start("foo", "a=b"));
|
||||
assertThrows(JobInstanceAlreadyExistsException.class, () -> jobOperator.start("foo", properties));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user