MCTSSMSReportService { public List<MCTSReport> fetch(String date) throws Exception { try { return mctsReportRepository.allReportsToBeSentAsOf(date); } catch (Exception e) { logger.error(format("Fetching MCTS Reports for Date: {0} failed with exception : {1}", date, getFullStackTrace(e))); throw e; } } @Autowired  MCTSSMSReportService(AllMCTSReports mctsReportRepository); List<MCTSReport> fetch(String date); void markReportAsSent(MCTSReport report);  }
@Test public void shouldFetchAllReportsForAGivenDate() throws Exception { MCTSReport mctsReport = new MCTSReport().withCaseId("case id 1").withEntityId("entity id 1").withSendDate("2014-01-01").withEntityRegistrationDate("2014-01-01").withReportText("report text 1").withReportSent("false"); when(allMCTSReports.allReportsToBeSentAsOf("2014-01-01")).thenReturn(asList(mctsReport)); List<MCTSReport> reports = reportService.fetch("2014-01-01"); verify(allMCTSReports).allReportsToBeSentAsOf("2014-01-01"); assertEquals(asList(new MCTSReport().withCaseId("case id 1").withEntityId("entity id 1") .withSendDate("2014-01-01").withEntityRegistrationDate("2014-01-01") .withReportText("report text 1").withReportSent("false")), reports); }