ReportType reportType2= new ReportType(122, "ReportType2");
ReportType reportType3 = new ReportType(123, "ReportType3");
Dashboard dashboard = new Dashboard(1, 2);
Report report1 = new Report(user,"Report1", reportType1, dashboard);
Report report2 = new Report(user,"Report2", reportType2, dashboard);
Report report3 = new Report(user,"Report3", reportType3, dashboard);
List<Report> reportList = new ArrayList<Report>();
reportList.add(report1);
reportList.add(report2);
reportList.add(report3);
ReportDAO mockedReportDAO = mock(ReportDAO.class);
ViewReportListAction viewReportListAction = new ViewReportListAction();
viewReportListAction.setReportDAO(mockedReportDAO);
when(mockedReportDAO.findAll()).thenReturn(reportList);
String successString = viewReportListAction.displayReportList();
assertEquals(successString, "success");
assertEquals(viewReportListAction.getReportList().get(0).getName(), report1.getName());
assertEquals(viewReportListAction.getReportList().get(1).getName(), report2.getName());
assertEquals(viewReportListAction.getReportList().get(2).getName(), report3.getName());
// Report view index starts with integer 1.
assertEquals(viewReportListAction.getReportList().get(0).getIndex(), 1);
}