|
| 1 | +/* |
| 2 | + * Copyright 2020-2023 the original author or authors. |
| 3 | + * |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | + * you may not use this file except in compliance with the License. |
| 6 | + * You may obtain a copy of the License at |
| 7 | + * |
| 8 | + * https://www.apache.org/licenses/LICENSE-2.0 |
| 9 | + * |
| 10 | + * Unless required by applicable law or agreed to in writing, software |
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | + * See the License for the specific language governing permissions and |
| 14 | + * limitations under the License. |
| 15 | + */ |
| 16 | + |
1 | 17 | package org.springframework.batch.integration.partition;
|
2 | 18 |
|
| 19 | +import java.util.Arrays; |
3 | 20 | import java.util.Collection;
|
4 | 21 | import java.util.Collections;
|
5 | 22 | import java.util.HashSet;
|
@@ -154,7 +171,12 @@ public void testHandleWithJobRepositoryPolling() throws Exception {
|
154 | 171 | stepExecutions.add(partition2);
|
155 | 172 | stepExecutions.add(partition3);
|
156 | 173 | when(stepExecutionSplitter.split(any(StepExecution.class), eq(1))).thenReturn(stepExecutions);
|
157 |
| - when(jobExplorer.getStepExecution(eq(5L), any(Long.class))).thenReturn(partition2, partition1, partition3, partition3, partition3, partition3, partition4); |
| 174 | + JobExecution runningJobExecution = new JobExecution(5L, new JobParameters()); |
| 175 | + runningJobExecution.addStepExecutions(Arrays.asList(partition2, partition1, partition3)); |
| 176 | + JobExecution completedJobExecution = new JobExecution(5L, new JobParameters()); |
| 177 | + completedJobExecution.addStepExecutions(Arrays.asList(partition2, partition1, partition4)); |
| 178 | + when(jobExplorer.getJobExecution(5L)).thenReturn(runningJobExecution, runningJobExecution, runningJobExecution, |
| 179 | + completedJobExecution); |
158 | 180 |
|
159 | 181 | //set
|
160 | 182 | messageChannelPartitionHandler.setMessagingOperations(operations);
|
@@ -198,7 +220,9 @@ public void testHandleWithJobRepositoryPollingTimeout() throws Exception {
|
198 | 220 | stepExecutions.add(partition2);
|
199 | 221 | stepExecutions.add(partition3);
|
200 | 222 | when(stepExecutionSplitter.split(any(StepExecution.class), eq(1))).thenReturn(stepExecutions);
|
201 |
| - when(jobExplorer.getStepExecution(eq(5L), any(Long.class))).thenReturn(partition2, partition1, partition3); |
| 223 | + JobExecution runningJobExecution = new JobExecution(5L, new JobParameters()); |
| 224 | + runningJobExecution.addStepExecutions(Arrays.asList(partition2, partition1, partition3)); |
| 225 | + when(jobExplorer.getJobExecution(5L)).thenReturn(runningJobExecution); |
202 | 226 |
|
203 | 227 | //set
|
204 | 228 | messageChannelPartitionHandler.setMessagingOperations(operations);
|
|
0 commit comments