ProblemStatusController { @GetMapping("gotoproblem") public String gotoProblem(@RequestParam(value = "pid", required = false) String pid, RedirectAttributes redirectAttributes) { long problemId; try { problemId = Long.parseLong(pid); } catch (NumberFormatException ex) { redirectAttributes.addAttribute("sstr", pid); return "redirect:/searchproblem"; } redirectAttributes.addAttribute("problem_id", problemId); return "redirect:/showproblem"; }  @GetMapping("gotoproblem") String gotoProblem(@RequestParam(value = "pid", required = false) String pid,
            RedirectAttributes redirectAttributes); @GetMapping("problemstatus") @SuppressWarnings("AssignmentToMethodParameter") String status(HttpServletRequest request,
            @RequestParam("problem_id") long id,
            @RequestParam(value = "language", required = false) Integer language,
            @PageableDefault(size = 20, sort = {"time", "memory", "code_length"}) Pageable pageable,
            @Nullable Authentication authentication);  }
@Test public void testGotoProblem() throws Exception { log.info("gotoProblem"); String pid = "test"; mvc.perform(get("/gotoproblem").param("pid", pid)) .andExpect(redirectedUrl("/searchproblem?sstr=" + pid)) .andReturn(); pid = "1000"; mvc.perform(get("/gotoproblem").param("pid", pid)) .andExpect(redirectedUrl("/showproblem?problem_id=" + pid)) .andReturn(); }