@Test public void testGetFinishedJobResults_DifferentDates_SortingIsDescOnYearAndMonth() throws Exception { JobInstance jobInstance1 = new JobInstance(1L, EmployeeJobConfigSingleJvm.EMPLOYEE_JOB); JobInstance jobInstance2 = new JobInstance(2L, EmployeeJobConfigSingleJvm.EMPLOYEE_JOB); List<JobInstance> jobInstances = asList(jobInstance1, jobInstance2); when(jobExplorer.findJobInstancesByJobName(EmployeeJobConfigSingleJvm.EMPLOYEE_JOB, 0, MAX_VALUE)) .thenReturn(jobInstances); JobExecution jobInstance1_jobExecution1 = createJobExecution(jobInstance1, createJobParameters(2014, 5)); when(jobExplorer.getJobExecutions(jobInstance1)).thenReturn(asList(jobInstance1_jobExecution1)); JobExecution jobInstance2_jobExecution1 = createJobExecution(jobInstance2, createJobParameters(2013, 6)); JobExecution jobInstance2_jobExecution2 = createJobExecution(jobInstance2, createJobParameters(2013, 6)); when(jobExplorer.getJobExecutions(jobInstance2)).thenReturn(asList(jobInstance2_jobExecution1, jobInstance2_jobExecution2)); List<JobResult> jobResults = jobResultsService.getJobResults(); verify(jobExplorer).findJobInstancesByJobName(EmployeeJobConfigSingleJvm.EMPLOYEE_JOB, 0, MAX_VALUE); verify(jobExplorer).getJobExecutions(jobInstance1); verify(jobExplorer).getJobExecutions(jobInstance2); assertThat(jobResults).hasSize(6); }
public List<JobResult> getJobResults() { List<JobInstance> jobInstancesByJobName = jobExplorer.findJobInstancesByJobName(AbstractEmployeeJobConfig.EMPLOYEE_JOB, 0, Integer.MAX_VALUE); DateTime currentTime = new DateTime(); List<JobStartParams> months = getJobStartParamsPreviousMonths(currentTime.getYear(), currentTime.getMonthOfYear()); final Map<JobStartParams, JobResult> jobResultMap = getMapOfJobResultsForJobInstances(jobInstancesByJobName); List<JobResult> collect = months .stream() .map(mapJobStartParamsToJobResult(jobResultMap)) .sorted((comparing(onYear).thenComparing(comparing(onMonth))).reversed()) .collect(Collectors.toList()); return collect; }
JobResultsServiceImpl implements JobResultsService { public List<JobResult> getJobResults() { List<JobInstance> jobInstancesByJobName = jobExplorer.findJobInstancesByJobName(AbstractEmployeeJobConfig.EMPLOYEE_JOB, 0, Integer.MAX_VALUE); DateTime currentTime = new DateTime(); List<JobStartParams> months = getJobStartParamsPreviousMonths(currentTime.getYear(), currentTime.getMonthOfYear()); final Map<JobStartParams, JobResult> jobResultMap = getMapOfJobResultsForJobInstances(jobInstancesByJobName); List<JobResult> collect = months .stream() .map(mapJobStartParamsToJobResult(jobResultMap)) .sorted((comparing(onYear).thenComparing(comparing(onMonth))).reversed()) .collect(Collectors.toList()); return collect; } }
JobResultsServiceImpl implements JobResultsService { public List<JobResult> getJobResults() { List<JobInstance> jobInstancesByJobName = jobExplorer.findJobInstancesByJobName(AbstractEmployeeJobConfig.EMPLOYEE_JOB, 0, Integer.MAX_VALUE); DateTime currentTime = new DateTime(); List<JobStartParams> months = getJobStartParamsPreviousMonths(currentTime.getYear(), currentTime.getMonthOfYear()); final Map<JobStartParams, JobResult> jobResultMap = getMapOfJobResultsForJobInstances(jobInstancesByJobName); List<JobResult> collect = months .stream() .map(mapJobStartParamsToJobResult(jobResultMap)) .sorted((comparing(onYear).thenComparing(comparing(onMonth))).reversed()) .collect(Collectors.toList()); return collect; }  }
JobResultsServiceImpl implements JobResultsService { public List<JobResult> getJobResults() { List<JobInstance> jobInstancesByJobName = jobExplorer.findJobInstancesByJobName(AbstractEmployeeJobConfig.EMPLOYEE_JOB, 0, Integer.MAX_VALUE); DateTime currentTime = new DateTime(); List<JobStartParams> months = getJobStartParamsPreviousMonths(currentTime.getYear(), currentTime.getMonthOfYear()); final Map<JobStartParams, JobResult> jobResultMap = getMapOfJobResultsForJobInstances(jobInstancesByJobName); List<JobResult> collect = months .stream() .map(mapJobStartParamsToJobResult(jobResultMap)) .sorted((comparing(onYear).thenComparing(comparing(onMonth))).reversed()) .collect(Collectors.toList()); return collect; }  List<JobResult> getJobResults(); List<JobStartParams> getJobStartParamsPreviousMonths(int year, int month); }
JobResultsServiceImpl implements JobResultsService { public List<JobResult> getJobResults() { List<JobInstance> jobInstancesByJobName = jobExplorer.findJobInstancesByJobName(AbstractEmployeeJobConfig.EMPLOYEE_JOB, 0, Integer.MAX_VALUE); DateTime currentTime = new DateTime(); List<JobStartParams> months = getJobStartParamsPreviousMonths(currentTime.getYear(), currentTime.getMonthOfYear()); final Map<JobStartParams, JobResult> jobResultMap = getMapOfJobResultsForJobInstances(jobInstancesByJobName); List<JobResult> collect = months .stream() .map(mapJobStartParamsToJobResult(jobResultMap)) .sorted((comparing(onYear).thenComparing(comparing(onMonth))).reversed()) .collect(Collectors.toList()); return collect; }  List<JobResult> getJobResults(); List<JobStartParams> getJobStartParamsPreviousMonths(int year, int month); static final int NUMBER_OF_MONTHS; }