コード例 #1
0
  @Test
  public void shouldIgnoreThoseReportsWhichHaveEmptyMonthlySummary() 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));
    Report condomReport = new Report("CONDOM", "30", "[]");
    when(allReports.allFor(anyList())).thenReturn(asList(iudReport, condomReport));

    String indicatorReports = controller.get();

    IndicatorReport iud = new IndicatorReport("IUD", "IUD Adoption", "40", "2", "10", "2012", "2");
    String expectedIndicatorReports =
        new Gson().toJson(new CategoryReports("Family Planning Services", asList(iud)));
    assertEquals(expectedIndicatorReports, indicatorReports);
  }
コード例 #2
0
  @Test
  public void shouldUseLatestMonthDataIfCurrentMonthDataNotAvailable() 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", "40", new Gson().toJson(monthlySummaries));
    when(allReports.allFor(FPS.indicators())).thenReturn(asList(iudReport));

    String indicatorReports = controller.get();

    IndicatorReport iud = new IndicatorReport("IUD", "IUD Adoption", "40", "0", "10", "2012", "4");
    String expectedIndicatorReports =
        new Gson().toJson(new CategoryReports("Family Planning Services", asList(iud)));
    assertEquals(expectedIndicatorReports, indicatorReports);
  }
コード例 #3
0
  @Test
  public void shouldUseCurrentMonthDataForIndicatorReport() throws Exception {
    List<MonthSummaryDatum> monthlySummaries =
        asList(
            new MonthSummaryDatum("1", "2012", "2", "2", asList("123", "456")),
            new MonthSummaryDatum("10", "2012", "2", "4", asList("321", "654")));
    Report earlyANCRegistrationReport =
        new Report("ANC_LT_12", "40", new Gson().toJson(monthlySummaries));
    when(allReports.allFor(ANC_SERVICES.indicators()))
        .thenReturn(asList(earlyANCRegistrationReport));

    controller = new ReportIndicatorListViewController(context, allReports, ANC_SERVICES.value());
    String reports = controller.get();

    IndicatorReport earlyANCRegistration =
        new IndicatorReport(
            "EARLY_ANC_REGISTRATIONS", "Early ANC Registration", "40", "2", "10", "2012", "4");
    String expectedIndicatorReports =
        new Gson().toJson(new CategoryReports("ANC Services", asList(earlyANCRegistration)));
    assertEquals(expectedIndicatorReports, reports);
  }