StatisticsController { @RequestMapping(value = "/comments/sum", method = RequestMethod.GET) public List<LineChartStatisticsResult> getSumComments( @RequestParam @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) DateTime startDate, @RequestParam @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) DateTime endDate) { return Collections.singletonList(statisticsService.getSumComments(new TimeRangedStatisticsRequest(startDate, endDate))); } @Autowired  StatisticsController(StatisticsService statisticsService); @RequestMapping(value = "/current", method = RequestMethod.GET) List<LineChartStatisticsResult> getCurrentStatisticsResult(
            @RequestParam @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) DateTime startDate,
            @RequestParam @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) DateTime endDate); @RequestMapping(value = "/projects_per_status", method = RequestMethod.GET) List<BarChartStatisticsResult> getProjectsPerStatus(); @RequestMapping(value = "/comment_count_per_project") List<BarChartStatisticsResult> getCommentCountPerProject(@RequestParam(defaultValue = "5") int projectCount); @RequestMapping(value = "/comments/sum", method = RequestMethod.GET) List<LineChartStatisticsResult> getSumComments(
            @RequestParam @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) DateTime startDate,
            @RequestParam @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) DateTime endDate);  }
@Test public void getSumComments_shouldCallStatisticsService() throws Exception { ArgumentCaptor<TimeRangedStatisticsRequest> requestCaptor = ArgumentCaptor.forClass(TimeRangedStatisticsRequest.class); when(statisticsService.getSumComments(requestCaptor.capture())).thenReturn(new LineChartStatisticsResult("test_res", Collections.emptyList())); final String dateTimeString = "2016-01-12T22:59:59.000Z"; mockMvc.perform(get("/statistics/comments/sum") .contentType(MediaType.APPLICATION_JSON) .param("startDate", dateTimeString) .param("endDate", dateTimeString)) .andExpect(status().is(200)); DateTime dateTime = DateTime.parse(dateTimeString).withZone(DateTimeZone.getDefault()); assertThat(requestCaptor.getValue().getStartDate(), is(dateTime.withTimeAtStartOfDay())); assertThat(requestCaptor.getValue().getEndDate(), is(dateTime.plusDays(1).withTimeAtStartOfDay())); }