@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); }