AllReports { public List<Report> allFor(List<ReportIndicator> indicators) { List<String> indicatorList = new ArrayList<String>(); for (ReportIndicator indicator : indicators) { indicatorList.add(indicator.value()); } return repository.allFor(indicatorList.toArray(new String[indicatorList.size()])); } AllReports(ReportRepository repository); void handleAction(Action action); List<Report> allFor(List<ReportIndicator> indicators);  }
@Test public void shouldGetReportsForGivenIndicators() throws Exception { List<Report> expectedReports = asList(new Report("IUD", "40", "some-month-summary-json"), new Report("ANC_LT_12", "30", "some-month-summary-json")); when(repository.allFor("IUD", "CONDOM", "ANC_LT_12")).thenReturn(expectedReports); List<Report> reports = allReports.allFor(asList(IUD, CONDOM, EARLY_ANC_REGISTRATIONS)); assertEquals(expectedReports, reports); }
@Test public void shouldGetReportsForGivenIndicators() throws Exception { List<Report> expectedReports = Arrays.asList(new Report("IUD", "40", "some-month-summary-json"), new Report("ANC_LT_12", "30", "some-month-summary-json")); Mockito.when(repository.allFor("IUD", "CONDOM", "ANC_LT_12")).thenReturn(expectedReports); List<Report> reports = allReports.allFor(Arrays.asList(ReportIndicator.IUD, ReportIndicator.CONDOM, ReportIndicator.EARLY_ANC_REGISTRATIONS)); Assert.assertEquals(expectedReports, reports); }