@Test public void requests() throws Exception { final List<RequestDto> requestDtos = new ArrayList<>(); final List<RequestView> returnedRequestViews = Arrays.asList(buildRequestView("2", null), buildRequestView("0", null), buildRequestView(null, "3"), buildRequestView(null, "0"), buildRequestView("5", "4"), buildRequestView("0", "0"), buildRequestView(null, null)); final List<RequestView> filteredRequestViews = Arrays.asList(buildRequestView("2", null), buildRequestView(null, "3"), buildRequestView("5", "4")); final StatisticsDto statisticsDto = StatisticsDto.builder().build(); final Set<String> projects = new HashSet<>(); final Set<String> technologies = new HashSet<>(); boolean isAuthenticated = false; when(requestService.findAll()).thenReturn(requestDtos); when(mappers.mapList(RequestDto.class, RequestView.class, requestDtos)).thenReturn(returnedRequestViews); when(statisticsService.getStatistics()).thenReturn(statisticsDto); when(requestService.findAllProjects()).thenReturn(projects); when(requestService.findAllTechnologies()).thenReturn(technologies); when(securityContextService.isUserFullyAuthenticated()).thenReturn(isAuthenticated); when(objectMapper.writeValueAsString(filteredRequestViews)).thenReturn("requestViews"); when(objectMapper.writeValueAsString(same(projects))).thenReturn("projects"); when(objectMapper.writeValueAsString(same(technologies))).thenReturn("technologies"); this.mockMvc.perform(get("/requests").principal(principal)) .andExpect(MockMvcResultMatchers.status().isOk()) .andExpect(MockMvcResultMatchers.model().attribute("requests", "requestViews")) .andExpect(MockMvcResultMatchers.model().attribute("statistics", statisticsDto)) .andExpect(MockMvcResultMatchers.model().attribute("projects", "projects")) .andExpect(MockMvcResultMatchers.model().attribute("technologies", "technologies")) .andExpect(MockMvcResultMatchers.model().attribute("isAuthenticated", Boolean.toString(isAuthenticated))) .andExpect(MockMvcResultMatchers.view().name("pages/requests/index")); }
@GetMapping("/requests") public ModelAndView requests() { final List<RequestView> requests = mappers.mapList(RequestDto.class, RequestView.class, requestService.findAll()) .stream() .filter(request -> hasFunds(request.getFunds().getFndFunds()) || hasFunds(request.getFunds().getOtherFunds())) .collect(toList()); final Map<String, Long> requestsPerPhaseCount = requests.stream().collect(Collectors.groupingBy(RequestView::getPhase, Collectors.counting())); return modelAndView().withObject("requestsPerPhaseCount", requestsPerPhaseCount) .withObject("requests", getAsJson(requests)) .withObject("statistics", statisticsService.getStatistics()) .withObject("projects", getAsJson(requestService.findAllProjects())) .withObject("technologies", getAsJson(requestService.findAllTechnologies())) .withObject("isAuthenticated", getAsJson(securityContextService.isUserFullyAuthenticated())) .withView("pages/requests/index") .build(); }
RequestController extends AbstractController { @GetMapping("/requests") public ModelAndView requests() { final List<RequestView> requests = mappers.mapList(RequestDto.class, RequestView.class, requestService.findAll()) .stream() .filter(request -> hasFunds(request.getFunds().getFndFunds()) || hasFunds(request.getFunds().getOtherFunds())) .collect(toList()); final Map<String, Long> requestsPerPhaseCount = requests.stream().collect(Collectors.groupingBy(RequestView::getPhase, Collectors.counting())); return modelAndView().withObject("requestsPerPhaseCount", requestsPerPhaseCount) .withObject("requests", getAsJson(requests)) .withObject("statistics", statisticsService.getStatistics()) .withObject("projects", getAsJson(requestService.findAllProjects())) .withObject("technologies", getAsJson(requestService.findAllTechnologies())) .withObject("isAuthenticated", getAsJson(securityContextService.isUserFullyAuthenticated())) .withView("pages/requests/index") .build(); } }
RequestController extends AbstractController { @GetMapping("/requests") public ModelAndView requests() { final List<RequestView> requests = mappers.mapList(RequestDto.class, RequestView.class, requestService.findAll()) .stream() .filter(request -> hasFunds(request.getFunds().getFndFunds()) || hasFunds(request.getFunds().getOtherFunds())) .collect(toList()); final Map<String, Long> requestsPerPhaseCount = requests.stream().collect(Collectors.groupingBy(RequestView::getPhase, Collectors.counting())); return modelAndView().withObject("requestsPerPhaseCount", requestsPerPhaseCount) .withObject("requests", getAsJson(requests)) .withObject("statistics", statisticsService.getStatistics()) .withObject("projects", getAsJson(requestService.findAllProjects())) .withObject("technologies", getAsJson(requestService.findAllTechnologies())) .withObject("isAuthenticated", getAsJson(securityContextService.isUserFullyAuthenticated())) .withView("pages/requests/index") .build(); } RequestController(final SecurityContextService securityContextService,
                             final RequestService requestService,
                             final PendingFundService pendingFundService,
                             final StatisticsService statisticsService,
                             final ProfileService profileService, FundService fundService,
                             final RefundService refundService,
                             final ClaimService claimService,
                             final FiatService fiatService,
                             final PlatformIssueService platformIssueService,
                             final ObjectMapper objectMapper,
                             final Mappers mappers); }
RequestController extends AbstractController { @GetMapping("/requests") public ModelAndView requests() { final List<RequestView> requests = mappers.mapList(RequestDto.class, RequestView.class, requestService.findAll()) .stream() .filter(request -> hasFunds(request.getFunds().getFndFunds()) || hasFunds(request.getFunds().getOtherFunds())) .collect(toList()); final Map<String, Long> requestsPerPhaseCount = requests.stream().collect(Collectors.groupingBy(RequestView::getPhase, Collectors.counting())); return modelAndView().withObject("requestsPerPhaseCount", requestsPerPhaseCount) .withObject("requests", getAsJson(requests)) .withObject("statistics", statisticsService.getStatistics()) .withObject("projects", getAsJson(requestService.findAllProjects())) .withObject("technologies", getAsJson(requestService.findAllTechnologies())) .withObject("isAuthenticated", getAsJson(securityContextService.isUserFullyAuthenticated())) .withView("pages/requests/index") .build(); } RequestController(final SecurityContextService securityContextService,
                             final RequestService requestService,
                             final PendingFundService pendingFundService,
                             final StatisticsService statisticsService,
                             final ProfileService profileService, FundService fundService,
                             final RefundService refundService,
                             final ClaimService claimService,
                             final FiatService fiatService,
                             final PlatformIssueService platformIssueService,
                             final ObjectMapper objectMapper,
                             final Mappers mappers); @GetMapping("/requests") ModelAndView requests(); @RequestMapping("/requests/{type}") ModelAndView details(@PathVariable String type, @RequestParam Map<String, String> queryParameters); @GetMapping("/requests/{id}") ModelAndView details(@PathVariable Long id, Model model); @GetMapping("/requests/github/{owner}/{repo}/{number}") ModelAndView details(@PathVariable String owner, @PathVariable String repo, @PathVariable String number, Model model); @GetMapping(value = "/requests/{id}/badge", produces = "image/svg+xml") ModelAndView detailsBadge(@PathVariable final Long id, final Model model, final HttpServletResponse response); @PostMapping("/requests/{id}/claim") ModelAndView claimRequest(Principal principal, @PathVariable Long id, @Valid UserClaimRequest userClaimRequest, RedirectAttributes redirectAttributes); @GetMapping("/requests/{id}/actions") ModelAndView detailActions(final Principal principal, @PathVariable final Long id); @PostMapping(value = {"/requests/{id}/watch"}, produces = MediaType.APPLICATION_JSON_UTF8_VALUE) @ResponseBody String toggleWatchRequest(Principal principal, @PathVariable Long id); @GetMapping("/user/requests") ModelAndView userRequests(Principal principal); @PostMapping(value = {"/rest/requests/erc67/fund"}, produces = MediaType.APPLICATION_JSON_UTF8_VALUE, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE) @ResponseBody ERC67FundDto generateERC67ForFunding(@RequestBody @Valid CreateERC67FundRequest createERC67FundRequest); }
RequestController extends AbstractController { @GetMapping("/requests") public ModelAndView requests() { final List<RequestView> requests = mappers.mapList(RequestDto.class, RequestView.class, requestService.findAll()) .stream() .filter(request -> hasFunds(request.getFunds().getFndFunds()) || hasFunds(request.getFunds().getOtherFunds())) .collect(toList()); final Map<String, Long> requestsPerPhaseCount = requests.stream().collect(Collectors.groupingBy(RequestView::getPhase, Collectors.counting())); return modelAndView().withObject("requestsPerPhaseCount", requestsPerPhaseCount) .withObject("requests", getAsJson(requests)) .withObject("statistics", statisticsService.getStatistics()) .withObject("projects", getAsJson(requestService.findAllProjects())) .withObject("technologies", getAsJson(requestService.findAllTechnologies())) .withObject("isAuthenticated", getAsJson(securityContextService.isUserFullyAuthenticated())) .withView("pages/requests/index") .build(); } RequestController(final SecurityContextService securityContextService,
                             final RequestService requestService,
                             final PendingFundService pendingFundService,
                             final StatisticsService statisticsService,
                             final ProfileService profileService, FundService fundService,
                             final RefundService refundService,
                             final ClaimService claimService,
                             final FiatService fiatService,
                             final PlatformIssueService platformIssueService,
                             final ObjectMapper objectMapper,
                             final Mappers mappers); @GetMapping("/requests") ModelAndView requests(); @RequestMapping("/requests/{type}") ModelAndView details(@PathVariable String type, @RequestParam Map<String, String> queryParameters); @GetMapping("/requests/{id}") ModelAndView details(@PathVariable Long id, Model model); @GetMapping("/requests/github/{owner}/{repo}/{number}") ModelAndView details(@PathVariable String owner, @PathVariable String repo, @PathVariable String number, Model model); @GetMapping(value = "/requests/{id}/badge", produces = "image/svg+xml") ModelAndView detailsBadge(@PathVariable final Long id, final Model model, final HttpServletResponse response); @PostMapping("/requests/{id}/claim") ModelAndView claimRequest(Principal principal, @PathVariable Long id, @Valid UserClaimRequest userClaimRequest, RedirectAttributes redirectAttributes); @GetMapping("/requests/{id}/actions") ModelAndView detailActions(final Principal principal, @PathVariable final Long id); @PostMapping(value = {"/requests/{id}/watch"}, produces = MediaType.APPLICATION_JSON_UTF8_VALUE) @ResponseBody String toggleWatchRequest(Principal principal, @PathVariable Long id); @GetMapping("/user/requests") ModelAndView userRequests(Principal principal); @PostMapping(value = {"/rest/requests/erc67/fund"}, produces = MediaType.APPLICATION_JSON_UTF8_VALUE, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE) @ResponseBody ERC67FundDto generateERC67ForFunding(@RequestBody @Valid CreateERC67FundRequest createERC67FundRequest);  }