JobResultsServiceImpl implements JobResultsService { public List<JobStartParams> getJobStartParamsPreviousMonths(int year, int month) { List<JobStartParams> entries = new ArrayList<>(); for (int i = 0; i < NUMBER_OF_MONTHS; i++) { if (month == 0) { month = 12; --year; } JobStartParams jobStart = new JobStartParams(year, month); entries.add(jobStart); --month; } return entries; }  List<JobResult> getJobResults(); List<JobStartParams> getJobStartParamsPreviousMonths(int year, int month); static final int NUMBER_OF_MONTHS; }
@Test public void testGetJobStartParamsPreviousMonths() { int month = 3; int year = 2014; List<JobStartParams> jobStartParamsPreviousMonths = jobResultsService.getJobStartParamsPreviousMonths(year, month); assertThat(jobStartParamsPreviousMonths.size()).isEqualTo(6); assertThat(jobStartParamsPreviousMonths.get(0).getMonth()).isEqualTo(month); assertThat(jobStartParamsPreviousMonths.get(0).getYear()).isEqualTo(year); assertThat(jobStartParamsPreviousMonths.get(1).getMonth()).isEqualTo(month - 1); assertThat(jobStartParamsPreviousMonths.get(1).getYear()).isEqualTo(year); assertThat(jobStartParamsPreviousMonths.get(2).getMonth()).isEqualTo(month - 2); assertThat(jobStartParamsPreviousMonths.get(2).getYear()).isEqualTo(year); assertThat(jobStartParamsPreviousMonths.get(3).getMonth()).isEqualTo(12); assertThat(jobStartParamsPreviousMonths.get(3).getYear()).isEqualTo(year - 1); assertThat(jobStartParamsPreviousMonths.get(4).getMonth()).isEqualTo(11); assertThat(jobStartParamsPreviousMonths.get(4).getYear()).isEqualTo(year - 1); assertThat(jobStartParamsPreviousMonths.get(5).getMonth()).isEqualTo(10); assertThat(jobStartParamsPreviousMonths.get(5).getYear()).isEqualTo(year - 1); }