@Test public void testGetBestUser() throws Exception { _dbInjecter.injectTree("wood", "Bert", 10, timeOfPlanting); mockMvc.perform(get(Uris.RANKING_BEST_USER + "?page=0&size=10&lastYear=false").accept("application/json")).andExpect(status().isOk()).andExpect(jsonPath("$.content[0].name").value("Bert")) .andExpect(jsonPath("$.content[0].amount").value(10)).andExpect(jsonPath("$.content[0].co2Saved").exists()); }
@RequestMapping(value = Uris.RANKING_BEST_USER, method = RequestMethod.GET) public Page<TreeRankedUserData> getBestUser(@RequestParam(value = "page") int page, @RequestParam(value = "size") int size, @RequestParam(value = "lastYear") boolean lastYear) { if (lastYear) { return _rankingRepository.getBestUserForLastYear(System.currentTimeMillis(), PageRequest.of(page, size)); } else { return _rankingRepository.getBestUser(System.currentTimeMillis(), PageRequest.of(page, size)); } }
RankingController { @RequestMapping(value = Uris.RANKING_BEST_USER, method = RequestMethod.GET) public Page<TreeRankedUserData> getBestUser(@RequestParam(value = "page") int page, @RequestParam(value = "size") int size, @RequestParam(value = "lastYear") boolean lastYear) { if (lastYear) { return _rankingRepository.getBestUserForLastYear(System.currentTimeMillis(), PageRequest.of(page, size)); } else { return _rankingRepository.getBestUser(System.currentTimeMillis(), PageRequest.of(page, size)); } } }
RankingController { @RequestMapping(value = Uris.RANKING_BEST_USER, method = RequestMethod.GET) public Page<TreeRankedUserData> getBestUser(@RequestParam(value = "page") int page, @RequestParam(value = "size") int size, @RequestParam(value = "lastYear") boolean lastYear) { if (lastYear) { return _rankingRepository.getBestUserForLastYear(System.currentTimeMillis(), PageRequest.of(page, size)); } else { return _rankingRepository.getBestUser(System.currentTimeMillis(), PageRequest.of(page, size)); } }  }
RankingController { @RequestMapping(value = Uris.RANKING_BEST_USER, method = RequestMethod.GET) public Page<TreeRankedUserData> getBestUser(@RequestParam(value = "page") int page, @RequestParam(value = "size") int size, @RequestParam(value = "lastYear") boolean lastYear) { if (lastYear) { return _rankingRepository.getBestUserForLastYear(System.currentTimeMillis(), PageRequest.of(page, size)); } else { return _rankingRepository.getBestUser(System.currentTimeMillis(), PageRequest.of(page, size)); } }  @RequestMapping(value = Uris.RANKING_BEST_USER, method = RequestMethod.GET) Page<TreeRankedUserData> getBestUser(@RequestParam(value = "page") int page, @RequestParam(value = "size") int size, @RequestParam(value = "lastYear") boolean lastYear); @RequestMapping(value = Uris.RANKING_LAST_CREATED_USER, method = RequestMethod.GET) List<TimeRankedUserData> getLastUser(); @RequestMapping(value = Uris.RANKING_BEST_ORGANIZATION_TYPE + "{organizationType}", method = RequestMethod.GET) Page<TreeRankedUserData> getBestUserFromOrganizationType(@PathVariable OrganizationType organizationType, @Param(value = "page") int page, @Param(value = "size") int size,
            @RequestParam(value = "lastYear") boolean lastYear); @RequestMapping(value = Uris.RANKING_LAST_PLANTED_TREES, method = RequestMethod.GET) Page<TimeRankedTreeData> getLastPlantedTrees(@Param(value = "page") int page, @Param(value = "size") int size); @RequestMapping(value = Uris.RANKING_BEST_TEAM, method = RequestMethod.GET) Page<TreeRankedUserData> getBestTeams(@Param(value = "page") int page, @Param(value = "size") int size, @RequestParam(value = "lastYear") boolean lastYear); @RequestMapping(value = Uris.RANKING_BEST_USER_FOR_TIMERANGE + "{timeRange}", method = RequestMethod.GET) List<TreeRankedUserData> getBestUserFromTimeRange(@PathVariable String timeRange); @RequestMapping(value = Uris.RANKING_BEST_USER_FOR_PROJECT, method = RequestMethod.GET) Page<TreeRankedUserData> getBestUserForProject(@Param(value = "projectName") String projectName, @Param(value = "page") int page, @Param(value = "size") int size); @RequestMapping(value = Uris.RANKING_BEST_TEAM_FOR_PROJECT, method = RequestMethod.GET) Page<TreeRankedUserData> getBestTeamsForProject(@Param(value = "projectName") String projectName, @Param(value = "page") int page, @Param(value = "size") int size); @RequestMapping(value = Uris.RANKING_LAST_PLANTED_TREES_IN_PROJECT, method = RequestMethod.GET) Page<TimeRankedTreeData> getLastPlantedTreesInProject(@Param(value = "projectName") String projectName, @Param(value = "page") int page, @Param(value = "size") int size); }
RankingController { @RequestMapping(value = Uris.RANKING_BEST_USER, method = RequestMethod.GET) public Page<TreeRankedUserData> getBestUser(@RequestParam(value = "page") int page, @RequestParam(value = "size") int size, @RequestParam(value = "lastYear") boolean lastYear) { if (lastYear) { return _rankingRepository.getBestUserForLastYear(System.currentTimeMillis(), PageRequest.of(page, size)); } else { return _rankingRepository.getBestUser(System.currentTimeMillis(), PageRequest.of(page, size)); } }  @RequestMapping(value = Uris.RANKING_BEST_USER, method = RequestMethod.GET) Page<TreeRankedUserData> getBestUser(@RequestParam(value = "page") int page, @RequestParam(value = "size") int size, @RequestParam(value = "lastYear") boolean lastYear); @RequestMapping(value = Uris.RANKING_LAST_CREATED_USER, method = RequestMethod.GET) List<TimeRankedUserData> getLastUser(); @RequestMapping(value = Uris.RANKING_BEST_ORGANIZATION_TYPE + "{organizationType}", method = RequestMethod.GET) Page<TreeRankedUserData> getBestUserFromOrganizationType(@PathVariable OrganizationType organizationType, @Param(value = "page") int page, @Param(value = "size") int size,
            @RequestParam(value = "lastYear") boolean lastYear); @RequestMapping(value = Uris.RANKING_LAST_PLANTED_TREES, method = RequestMethod.GET) Page<TimeRankedTreeData> getLastPlantedTrees(@Param(value = "page") int page, @Param(value = "size") int size); @RequestMapping(value = Uris.RANKING_BEST_TEAM, method = RequestMethod.GET) Page<TreeRankedUserData> getBestTeams(@Param(value = "page") int page, @Param(value = "size") int size, @RequestParam(value = "lastYear") boolean lastYear); @RequestMapping(value = Uris.RANKING_BEST_USER_FOR_TIMERANGE + "{timeRange}", method = RequestMethod.GET) List<TreeRankedUserData> getBestUserFromTimeRange(@PathVariable String timeRange); @RequestMapping(value = Uris.RANKING_BEST_USER_FOR_PROJECT, method = RequestMethod.GET) Page<TreeRankedUserData> getBestUserForProject(@Param(value = "projectName") String projectName, @Param(value = "page") int page, @Param(value = "size") int size); @RequestMapping(value = Uris.RANKING_BEST_TEAM_FOR_PROJECT, method = RequestMethod.GET) Page<TreeRankedUserData> getBestTeamsForProject(@Param(value = "projectName") String projectName, @Param(value = "page") int page, @Param(value = "size") int size); @RequestMapping(value = Uris.RANKING_LAST_PLANTED_TREES_IN_PROJECT, method = RequestMethod.GET) Page<TimeRankedTreeData> getLastPlantedTreesInProject(@Param(value = "projectName") String projectName, @Param(value = "page") int page, @Param(value = "size") int size);  }