Fixed no executions returned check and added a unit test
This commit is contained in:
@@ -340,12 +340,12 @@ public class JsrJobOperator implements JobOperator {
|
||||
throws NoSuchJobException, JobSecurityException {
|
||||
Set<org.springframework.batch.core.JobExecution> findRunningJobExecutions = jobExplorer.findRunningJobExecutions(name);
|
||||
|
||||
List<Long> results = new ArrayList<Long>(findRunningJobExecutions.size());
|
||||
|
||||
if(results.isEmpty()) {
|
||||
if(findRunningJobExecutions.isEmpty()) {
|
||||
throw new NoSuchJobException("Job name: " + name + " not found.");
|
||||
}
|
||||
|
||||
List<Long> results = new ArrayList<Long>(findRunningJobExecutions.size());
|
||||
|
||||
for (org.springframework.batch.core.JobExecution jobExecution : findRunningJobExecutions) {
|
||||
results.add(jobExecution.getId());
|
||||
}
|
||||
|
||||
@@ -276,6 +276,15 @@ public class JsrJobOperatorTests {
|
||||
jsrJobOperator.getParameters(5l);
|
||||
}
|
||||
|
||||
@Test(expected=NoSuchJobException.class)
|
||||
public void testGetNoRunningExecutions() {
|
||||
Set<JobExecution> executions = new HashSet<JobExecution>();
|
||||
|
||||
when(jobExplorer.findRunningJobExecutions("myJob")).thenReturn(executions);
|
||||
|
||||
jsrJobOperator.getRunningExecutions("myJob");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetRunningExecutions() {
|
||||
Set<JobExecution> executions = new HashSet<JobExecution>();
|
||||
|
||||
Reference in New Issue
Block a user