class DefaultJobService implements JobService {

    @Override
    public JobParameters getLastJobParameters(final String jobName) {
        final List<JobExecution> executions = this.lightminJobExecutionDao.getJobExecutions(jobName, 0, 1);
        JobExecution lastExecution = null;
        if (!CollectionUtils.isEmpty(executions)) {
            lastExecution = executions.iterator().next();
        }
        JobParameters oldParameters = new JobParameters();
        if (lastExecution != null) {
            oldParameters = lastExecution.getJobParameters();
        }
        return oldParameters;
    }

}

class DefaultJobServiceTest {

    private static final String JOB_NAME;
    private static final String JOB_NAME_2;
    private static final String JOB_NAME_3;
    private static final String[] JOB_NAMES;
    @InjectMocks
    private DefaultJobService jobService;
    @Mock
    private JobOperator jobOperator;
    @Mock
    private JobRegistry jobRegistry;
    @Mock
    private JobExplorer jobExplorer;
    @Mock
    private LightminJobExecutionDao lightminJobExecutionDao;

    @Test
    public void getLastJobParametersTest() {

        final List<JobExecution> jobExecutions = new LinkedList<>();
        final JobParameters jobParameters = new JobParametersBuilder().addLong("long", 1L).addString("String",
                "someString").toJobParameters();
        final JobExecution jobExecution = new JobExecution(1L, jobParameters, "test");
        jobExecutions.add(jobExecution);
        when(this.lightminJobExecutionDao.getJobExecutions(anyString(), anyInt(), anyInt())).thenReturn(jobExecutions);
        final JobParameters result = this.jobService.getLastJobParameters("test");
        assertThat(result).isEqualTo(jobParameters);
    }

}