@Test public void home() throws Exception { mockMvc.perform(get("/")) .andExpect(status().is3xxRedirection()) .andExpect(redirectedUrl("/requests")); }
@RequestMapping("/") public ModelAndView home(@RequestParam(value = "ref", required = false) String ref, RedirectAttributes redirectAttributes, Principal principal) { final List<RequestView> requests = mappers.mapList(RequestDto.class, RequestView.class, requestService.findAll()) .stream() .filter(request -> request.getPhase().toLowerCase().equals("open") && (hasFunds(request.getFunds().getFndFunds()) || hasFunds(request.getFunds().getOtherFunds()))) .collect(toList()); if (principal != null && StringUtils.isNotBlank(ref)) { eventPublisher.publishEvent(RefSignupEvent.builder().principal(principal).ref(ref).build()); return redirectView(redirectAttributes).url("/").build(); } return redirectView(redirectAttributes) .url("/requests") .build(); }
HomeController extends AbstractController { @RequestMapping("/") public ModelAndView home(@RequestParam(value = "ref", required = false) String ref, RedirectAttributes redirectAttributes, Principal principal) { final List<RequestView> requests = mappers.mapList(RequestDto.class, RequestView.class, requestService.findAll()) .stream() .filter(request -> request.getPhase().toLowerCase().equals("open") && (hasFunds(request.getFunds().getFndFunds()) || hasFunds(request.getFunds().getOtherFunds()))) .collect(toList()); if (principal != null && StringUtils.isNotBlank(ref)) { eventPublisher.publishEvent(RefSignupEvent.builder().principal(principal).ref(ref).build()); return redirectView(redirectAttributes).url("/").build(); } return redirectView(redirectAttributes) .url("/requests") .build(); } }
HomeController extends AbstractController { @RequestMapping("/") public ModelAndView home(@RequestParam(value = "ref", required = false) String ref, RedirectAttributes redirectAttributes, Principal principal) { final List<RequestView> requests = mappers.mapList(RequestDto.class, RequestView.class, requestService.findAll()) .stream() .filter(request -> request.getPhase().toLowerCase().equals("open") && (hasFunds(request.getFunds().getFndFunds()) || hasFunds(request.getFunds().getOtherFunds()))) .collect(toList()); if (principal != null && StringUtils.isNotBlank(ref)) { eventPublisher.publishEvent(RefSignupEvent.builder().principal(principal).ref(ref).build()); return redirectView(redirectAttributes).url("/").build(); } return redirectView(redirectAttributes) .url("/requests") .build(); } HomeController(ProfileService profileService,
                          ApplicationEventPublisher eventPublisher,
                          final RequestService requestService,
                          final ObjectMapper objectMapper,
                          final Mappers mappers); }
HomeController extends AbstractController { @RequestMapping("/") public ModelAndView home(@RequestParam(value = "ref", required = false) String ref, RedirectAttributes redirectAttributes, Principal principal) { final List<RequestView> requests = mappers.mapList(RequestDto.class, RequestView.class, requestService.findAll()) .stream() .filter(request -> request.getPhase().toLowerCase().equals("open") && (hasFunds(request.getFunds().getFndFunds()) || hasFunds(request.getFunds().getOtherFunds()))) .collect(toList()); if (principal != null && StringUtils.isNotBlank(ref)) { eventPublisher.publishEvent(RefSignupEvent.builder().principal(principal).ref(ref).build()); return redirectView(redirectAttributes).url("/").build(); } return redirectView(redirectAttributes) .url("/requests") .build(); } HomeController(ProfileService profileService,
                          ApplicationEventPublisher eventPublisher,
                          final RequestService requestService,
                          final ObjectMapper objectMapper,
                          final Mappers mappers); @RequestMapping("/") ModelAndView home(@RequestParam(value = "ref", required = false) String ref, RedirectAttributes redirectAttributes, Principal principal); @GetMapping(value = {"/requestsActiveCount"}, produces = MediaType.APPLICATION_JSON_UTF8_VALUE) @ResponseBody String getRequestsActiveCount(Principal principal); @RequestMapping("/user/login") ModelAndView login(RedirectAttributes redirectAttributes, HttpServletRequest request); @GetMapping(path = "/logout") String logout(Principal principal, HttpServletRequest request); }
HomeController extends AbstractController { @RequestMapping("/") public ModelAndView home(@RequestParam(value = "ref", required = false) String ref, RedirectAttributes redirectAttributes, Principal principal) { final List<RequestView> requests = mappers.mapList(RequestDto.class, RequestView.class, requestService.findAll()) .stream() .filter(request -> request.getPhase().toLowerCase().equals("open") && (hasFunds(request.getFunds().getFndFunds()) || hasFunds(request.getFunds().getOtherFunds()))) .collect(toList()); if (principal != null && StringUtils.isNotBlank(ref)) { eventPublisher.publishEvent(RefSignupEvent.builder().principal(principal).ref(ref).build()); return redirectView(redirectAttributes).url("/").build(); } return redirectView(redirectAttributes) .url("/requests") .build(); } HomeController(ProfileService profileService,
                          ApplicationEventPublisher eventPublisher,
                          final RequestService requestService,
                          final ObjectMapper objectMapper,
                          final Mappers mappers); @RequestMapping("/") ModelAndView home(@RequestParam(value = "ref", required = false) String ref, RedirectAttributes redirectAttributes, Principal principal); @GetMapping(value = {"/requestsActiveCount"}, produces = MediaType.APPLICATION_JSON_UTF8_VALUE) @ResponseBody String getRequestsActiveCount(Principal principal); @RequestMapping("/user/login") ModelAndView login(RedirectAttributes redirectAttributes, HttpServletRequest request); @GetMapping(path = "/logout") String logout(Principal principal, HttpServletRequest request);  }