SubmitController { @PostMapping({ "problems/{problemId}/submit", "contests/{contestId}/problems/{problemId}/submit" }) public synchronized String submit(HttpServletRequest request, @PathVariable(value = "contestId", required = false) Long contestId, @PathVariable("problemId") long problemId, @RequestParam("language") int languageId, @RequestParam("source") String source, RedirectAttributes redirectAttributes, Authentication authentication) { contestOnlyService.checkSubmit(request, contestId, problemId); String userId = authentication.getName(); String ip = request.getRemoteAddr(); redirectAttributes.addAttribute("user_id", userId); if (contestId == null) { submissionService.submit(languageId, source, userId, ip, problemId, true); } else { redirectAttributes.addAttribute("contest_id", contestId); submissionService.contestSubmit(languageId, source, userId, ip, contestId, problemId); } return "redirect:/status"; }  @GetMapping({"submitpage", "submit"}) String submitPage(Model model,
            @RequestParam(value = "problem_id", required = false) Long problemId,
            Authentication authentication); @GetMapping({ "problems/{problemId}/submit", "contests/{contestId}/problems/{problemId}/submit" }) String contestSubmitPage(Model model,
            @PathVariable(value = "contestId", required = false) Long contestId,
            @PathVariable("problemId") long problemId,
            Authentication authentication); @PostMapping({ "problems/{problemId}/submit", "contests/{contestId}/problems/{problemId}/submit" }) synchronized String submit(HttpServletRequest request,
            @PathVariable(value = "contestId", required = false) Long contestId,
            @PathVariable("problemId") long problemId,
            @RequestParam("language") int languageId,
            @RequestParam("source") String source,
            RedirectAttributes redirectAttributes,
            Authentication authentication);  }
@Test public void testSubmit() throws Exception { log.info("submit"); int language = mockDataService.anyLanguage().getId(); long problemId = mockDataService.problem().getId(); String source = Strings.repeat(" ", 20); String userId = mockDataService.user().getId(); MvcResult result = mvc.perform(post("/problems/{problemId}/submit", problemId).with(user(userId)) .param("language", Integer.toString(language)) .param("source", source)) .andExpect(status().isFound()) .andExpect(redirectedUrl("/status?user_id=" + userId)) .andReturn(); }