1
1
/*
2
- * Copyright 2006-2022 the original author or authors.
2
+ * Copyright 2006-2023 the original author or authors.
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
39
39
import org .springframework .batch .core .configuration .JobRegistry ;
40
40
import org .springframework .batch .core .configuration .support .MapJobRegistry ;
41
41
import org .springframework .batch .core .converter .DefaultJobParametersConverter ;
42
+ import org .springframework .batch .core .converter .JobParametersConverter ;
42
43
import org .springframework .batch .core .explore .JobExplorer ;
43
44
import org .springframework .batch .core .job .AbstractJob ;
44
45
import org .springframework .batch .core .job .JobSupport ;
69
70
* @author Dave Syer
70
71
* @author Will Schipp
71
72
* @author Mahmoud Ben Hassine
73
+ * @author Jinwoo Bae
72
74
*
73
75
*/
74
76
class SimpleJobOperatorTests {
@@ -83,9 +85,13 @@ class SimpleJobOperatorTests {
83
85
84
86
private JobParameters jobParameters ;
85
87
88
+ private JobParametersConverter jobParametersConverter ;
89
+
86
90
@ BeforeEach
87
91
void setUp () throws Exception {
88
92
93
+ jobParametersConverter = new DefaultJobParametersConverter ();
94
+
89
95
job = new JobSupport ("foo" ) {
90
96
@ Nullable
91
97
@ Override
@@ -162,18 +168,23 @@ void testStartNextInstanceSunnyDay() throws Exception {
162
168
163
169
@ Test
164
170
void testStartNewInstanceSunnyDay () throws Exception {
165
- jobParameters = new JobParameters ();
171
+ Properties parameters = new Properties ();
172
+ parameters .setProperty ("a" , "b" );
173
+ JobParameters jobParameters = jobParametersConverter .getJobParameters (parameters );
174
+
166
175
jobRepository .isJobInstanceExists ("foo" , jobParameters );
167
- Long value = jobOperator .start ("foo" , "a=b" );
176
+ Long value = jobOperator .start ("foo" , parameters );
168
177
assertEquals (999 , value .longValue ());
169
178
}
170
179
171
180
@ Test
172
181
void testStartNewInstanceAlreadyExists () {
182
+ Properties properties = new Properties ();
183
+ properties .setProperty ("a" , "b" );
173
184
jobParameters = new JobParameters ();
174
185
when (jobRepository .isJobInstanceExists ("foo" , jobParameters )).thenReturn (true );
175
186
jobRepository .isJobInstanceExists ("foo" , jobParameters );
176
- assertThrows (JobInstanceAlreadyExistsException .class , () -> jobOperator .start ("foo" , "a=b" ));
187
+ assertThrows (JobInstanceAlreadyExistsException .class , () -> jobOperator .start ("foo" , properties ));
177
188
}
178
189
179
190
@ Test
0 commit comments