@Test public void testGetFinishedJobResults_SameDates_SortingIsDescOnDate() throws Exception { JobInstance jobInstance1 = new JobInstance(1L, EmployeeJobConfigSingleJvm.EMPLOYEE_JOB); when(jobExplorer.findJobInstancesByJobName(EmployeeJobConfigSingleJvm.EMPLOYEE_JOB, 0, MAX_VALUE)) .thenReturn(asList(jobInstance1)); DateTime dateTime = new DateTime(); JobExecution jobInstance1_jobExecution1 = new JobExecution(jobInstance1, 1L, createJobParameters(dateTime.getYear(), dateTime.getMonthOfYear()), null); jobInstance1_jobExecution1.setEndTime(getDateOfDay(3)); JobExecution jobInstance1_jobExecution2 = new JobExecution(jobInstance1, 2L, createJobParameters(dateTime.getYear(), dateTime.getMonthOfYear()), null); jobInstance1_jobExecution2.setEndTime(getDateOfDay(4)); when(jobExplorer.getJobExecutions(jobInstance1)).thenReturn(asList(jobInstance1_jobExecution1, jobInstance1_jobExecution2)); List<JobResult> jobResults = jobResultsService.getJobResults(); assertThat(jobResults.get(0).getJobExecutionResults().get(0).getEndTime()).isAfter(jobResults.get(0).getJobExecutionResults().get(1).getEndTime()); }
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; }