JobExecutionMapper { public JobResult toJobResultTo(Map.Entry<JobInstance, List<JobExecution>> mapEntry) { JobInstance jobInstance = mapEntry.getKey(); List<JobExecution> jobExecutions = mapEntry.getValue(); JobStartParams jobStartParams = getJobStartParams(jobExecutions.get(0).getJobParameters()); List<JobExecutionResult> jobExecutionResults = getJobExecutionResults(jobExecutions); JobResult jobResult = new JobResult(getJobName(jobInstance, jobStartParams), jobStartParams, jobExecutionResults); return jobResult; }  JobResult toJobResultTo(Map.Entry<JobInstance, List<JobExecution>> mapEntry);  }
@Test public void testToJobResultTo() throws Exception { Date now = DateTime.now().toDate(); JobInstance jobInstance = new JobInstance(JOB_ID, JOB_NAME); JobParameters jobParams = new JobParameters(); JobExecution jobExecution = new JobExecution(jobInstance, jobParams); jobExecution.setStatus(BatchStatus.ABANDONED); jobExecution.setStartTime(new DateTime(now).minusSeconds(DURATION_IN_SECONDS).toDate()); jobExecution.setEndTime(now); jobExecution.setId(JOB_EXECUTION_ID); Map.Entry<JobInstance, List<JobExecution>> entry = new Map.Entry<JobInstance, List<JobExecution>>() { @Override public JobInstance getKey() { return jobInstance; } @Override public List<JobExecution> getValue() { return Arrays.asList(jobExecution); } @Override public List<JobExecution> setValue(List<JobExecution> value) { return null; } }; JobResult resultTo = mapper.toJobResultTo(entry); assertThat(resultTo.getJobExecutionResults()).hasSize(1); JobExecutionResult jobExecutionResult = resultTo.getJobExecutionResults().get(0); assertThat(jobExecutionResult.getStatus()).isEqualTo(BatchStatus.ABANDONED.toString()); assertThat(jobExecutionResult.getDuration()).isEqualTo(DURATION_IN_SECONDS * 1000); }