Fixed no executions returned check and added a unit test

This commit is contained in:
Michael Minella
2013-09-04 20:39:23 -05:00
parent 46f790eb4b
commit c4231c4cc8
2 changed files with 12 additions and 3 deletions

View File

@@ -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());
}

View File

@@ -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>();