@Test
public void testToJobResultTo() throws Exception {

    //ARRANGE
    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;
        }
    };
    //ACT
    JobResult resultTo = mapper.toJobResultTo(entry);
    //ASSERT
    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);
}