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; } DefaultJobService(final JobOperator jobOperator,
                             final JobRegistry jobRegistry,
                             final JobExplorer jobExplorer,
                             final LightminJobExecutionDao lightminJobExecutionDao); @Override int getJobInstanceCount(final String jobName); @Override int getJobExecutionCount(final JobInstance jobInstance); @Override Set<String> getJobNames(); @Override Job getJobByName(final String jobName); @Override Collection<JobInstance> getJobInstances(final String jobName, final int startIndex, final int pageSize); @Override Collection<JobExecution> getJobExecutions(final JobInstance jobInstance); @Override Collection<JobExecution> getJobExecutions(final JobInstance jobInstance, final int start, final int count); @Override JobExecution getJobExecution(final Long jobExecutionId); @Override JobInstance getJobInstance(final Long jobInstanceId); @Override void attachJobInstance(final JobExecution jobExecution); @Override void restartJobExecution(final Long jobExecutionId); @Override void stopJobExecution(final Long jobExecutionId); @Override JobParameters getLastJobParameters(final String jobName); @Override void afterPropertiesSet();  }
@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); }