StatisticsService { public List<LineChartStatisticsResult> getCurrentStatistics(TimeRangedStatisticsRequest request) { try { final Future<LineChartStatisticsResult> createdProjectSumFuture = createdProjectSumAction.getCreatedProjectSumByTimeRange(request); final Future<LineChartStatisticsResult> registeredUserSumFuture = registeredUserSumAction.getCountOfRegisteredUsersByTimeRange(request); return Arrays.asList(createdProjectSumFuture.get(), registeredUserSumFuture.get()); } catch (ExecutionException | InterruptedException e) { throw new RuntimeException("Failed to retrieve statistic data", e); } } @Autowired  StatisticsService(CreatedProjectSumAction createdProjectSumAction, RegisteredUserSumAction registeredUserSumAction, ProjectPerStatusSumAction projectPerStatusSumAction, CommentSumAction commentSumAction, CommentCountPerProjectAction commentCountPerProjectAction); List<LineChartStatisticsResult> getCurrentStatistics(TimeRangedStatisticsRequest request); List<BarChartStatisticsResult> getProjectsPerStatus(); LineChartStatisticsResult getSumComments(TimeRangedStatisticsRequest request); List<BarChartStatisticsResult> getCommentsCountPerProject(int projectCount);  }
@Test public void getCurrentStatistics_should_callBothActionsToRetrieveData() throws Exception { final DateTime startDate = new DateTime(); final DateTime endDate = new DateTime(); TimeRangedStatisticsRequest timeRangedStatisticsRequest = new TimeRangedStatisticsRequest(startDate, endDate); Future<LineChartStatisticsResult> asyncResult = new AsyncResult<>(new LineChartStatisticsResult("name", Collections.emptyMap())); when(createdProjectSumAction.getCreatedProjectSumByTimeRange(eq(timeRangedStatisticsRequest))).thenReturn(asyncResult); when(registeredUserSumAction.getCountOfRegisteredUsersByTimeRange(eq(timeRangedStatisticsRequest))).thenReturn(asyncResult); instance.getCurrentStatistics(timeRangedStatisticsRequest); verify(createdProjectSumAction).getCreatedProjectSumByTimeRange(timeRangedStatisticsRequest); verify(registeredUserSumAction).getCountOfRegisteredUsersByTimeRange(timeRangedStatisticsRequest); }