ManagerReportController extends AbstractReportController { @RequestMapping(method = GET, value = ManagerReportConfig.REPORT_NAME) public ModelAndView handleReportRequest( @RequestParam Optional<ReportFormat> format, @RequestParam @DateTimeFormat(pattern = "MM/dd/yyyy") LocalDate startDate, @RequestParam @DateTimeFormat(pattern = "MM/dd/yyyy") LocalDate endDate, @RequestParam Optional<Boolean> noAccountInformation, @RequestParam Optional<Boolean> noCatagoryDescription) { final ReportFormat reportFormat = format.orElse(HTML); Boolean noInformation = noAccountInformation.orElse(false); Boolean noDescription = noCatagoryDescription.orElse(false); RequestScopedParameters requestScopedParameters = requestScopedParametersProvider .getRequestScopedParameters(); LocalDateTime startDateTime = reportUtils.getStartDateTime(startDate); LocalDateTime endDateTime = reportUtils.getEndDateTime(endDate); long startSqlTimeStamp = reportUtils .convertLocalDateTimeToEpoch(startDateTime); long endSqlTimeStamp = reportUtils .convertLocalDateTimeToEpoch(endDateTime); requestScopedParameters .add("startDateTime", startDateTime.format(DateTimeFormatter .ofPattern("MM/dd/yyyy HH:mm:ss"))) .add("endDateTime", endDateTime.format(DateTimeFormatter .ofPattern("MM/dd/yyyy HH:mm:ss"))) .add("noInformation", noInformation) .add("noDescription", noDescription); Object[] args = new Object[] { startSqlTimeStamp, endSqlTimeStamp }; Collection<Object> reportData = this.reportDataProvider .getReportData(args); if (reportData.size() == 0) { return new ModelAndView("views/Administrator/noReportDataFound"); } else { return reportModelAndView(reportFormat, () -> reportData); } } @Autowired  ManagerReportController(
			@Qualifier(ManagerReportConfig.REPORT_DATA_PROVIDER_NAME) ReportDataProvider reportDataProvider,
			@Qualifier(ManagerReportConfig.REPORT_CONFIG_NAME) AbstractReportConfig abstractReportConfig,
			ReportUtils reportUtils,
			RequestScopedParametersProvider requestScopedParametersProvider); @RequestMapping(method = GET, value = ManagerReportConfig.REPORT_NAME) ModelAndView handleReportRequest(
			@RequestParam Optional<ReportFormat> format,
			@RequestParam @DateTimeFormat(pattern = "MM/dd/yyyy") LocalDate startDate,
			@RequestParam @DateTimeFormat(pattern = "MM/dd/yyyy") LocalDate endDate,
			@RequestParam Optional<Boolean> noAccountInformation,
			@RequestParam Optional<Boolean> noCatagoryDescription);  }
@SuppressWarnings("unchecked") @Test public void testHandleReportRequest() throws Exception { final ReportFormat format = ReportFormat.HTML; DateTimeFormatter df = DateTimeFormatter.ofPattern("MM/dd/yyyy"); final LocalDate startDate = LocalDate.parse("03/01/2015",df); final LocalDate endDate = LocalDate.parse("06/01/2015",df); DateTimeFormatter dtf = DateTimeFormatter.ofPattern("MM/dd/yyyy HH:mm:ss"); final LocalDateTime startDateTime = LocalDateTime.parse("03/01/2015 00:00:00", dtf); final LocalDateTime endDateTime = LocalDateTime.parse("06/01/2015 23:59:59", dtf); when(reportUtils.getStartDateTime(startDate)).thenReturn(startDateTime); when(reportUtils.getEndDateTime(endDate)).thenReturn(endDateTime); final Boolean noInformation = false; final Boolean noDescription = false; final ManagerReportEntryDto entry = new ManagerReportEntryDto(); final long startSqlTimeStamp = 1425186000000l; when(reportUtils.convertLocalDateTimeToEpoch(startDateTime)).thenReturn(startSqlTimeStamp); final long endSqlTimeStamp = 1433217599000l; when(reportUtils.convertLocalDateTimeToEpoch(endDateTime)).thenReturn(endSqlTimeStamp); Object[] args = new Object[] { startSqlTimeStamp, endSqlTimeStamp }; @SuppressWarnings("rawtypes") final Collection managerReport = Arrays.asList(entry); when(reportDataProvider.getReportData(args)).thenReturn(managerReport); final RequestScopedParameters requestScopedParameters = new RequestScopedParameters(); requestScopedParameters.add("startDateTime", startDateTime); requestScopedParameters.add("endDateTime", endDateTime); requestScopedParameters.add("noInformation", noInformation); requestScopedParameters.add("noDescription", noDescription); when(requestScopedParametersProvider.getRequestScopedParameters()).thenReturn(requestScopedParameters); final Map<String, Object> parameters = new HashMap<>(); final String key = "key"; final Object value = "value"; parameters.put(key, value); when( abstractReportConfig.configure(eq(format), any(JRDataSource.class))).thenReturn(parameters); when(abstractReportConfig.getReportName()).thenReturn( ManagerReportConfig.REPORT_NAME); mockMvc.perform(get("/Administrator/reports/managerReport?startDate="+startDate.format(df)+"&endDate="+endDate.format(df))) .andExpect(status().isOk()) .andExpect(model().attribute("key", "value")) .andExpect(model().size(parameters.size())) .andExpect(view().name(ManagerReportConfig.REPORT_NAME)); verify(reportDataProvider, times(1)).getReportData(args); verify(abstractReportConfig, times(1)).configure(eq(format), any(JRDataSource.class)); }