ReportIndicatorDetailViewController { public String get() { String annualTarget = (isBlank(indicatorDetails.annualTarget())) ? "NA" : indicatorDetails.annualTarget(); return new Gson().toJson(new IndicatorReportDetail(categoryDescription, indicatorDetails.reportIndicator().description(), indicatorDetails.reportIndicator().name(), annualTarget, indicatorDetails.monthlySummaries())); } ReportIndicatorDetailViewController(Context context, Report indicatorDetails, String categoryDescription); String get(); void startReportIndicatorCaseList(String month);  }
@Test public void shouldGetIndicatorReportsForGivenCategory() throws Exception { List<MonthSummaryDatum> monthlySummaries = asList(new MonthSummaryDatum("10", "2012", "2", "2", asList("123", "456"))); Report iudReport = new Report("IUD", "40", new Gson().toJson(monthlySummaries)); ReportIndicatorDetailViewController controller = new ReportIndicatorDetailViewController(context, iudReport, "Family Planning"); String indicatorReportDetail = controller.get(); String expectedIndicatorReports = new Gson().toJson(new IndicatorReportDetail("Family Planning", "IUD Adoption", "IUD", "40", monthlySummaries)); assertEquals(expectedIndicatorReports, indicatorReportDetail); }
@Test public void shouldShowNAIfAnnualTargetNotAvailable() throws Exception { List<MonthSummaryDatum> monthlySummaries = asList(new MonthSummaryDatum("6", "2012", "2", "2", asList("123", "456")), new MonthSummaryDatum("8", "2012", "2", "4", asList("321", "654"))); Report iudReport = new Report("IUD", null, new Gson().toJson(monthlySummaries)); ReportIndicatorDetailViewController controller = new ReportIndicatorDetailViewController(context, iudReport, "Family Planning"); String indicatorReportDetail = controller.get(); String expectedIndicatorReports = new Gson().toJson(new IndicatorReportDetail("Family Planning", "IUD Adoption", "IUD", "NA", monthlySummaries)); assertEquals(expectedIndicatorReports, indicatorReportDetail); }