ShowSourceController { @Secured("ROLE_USER") @GetMapping("showsource") @SuppressWarnings("AssignmentToMethodParameter") public String showSource(HttpServletRequest request, @RequestParam("solution_id") long submissionId, @RequestParam(value = "style", required = false) Integer style, @Nullable Authentication authentication) { Submission submission = submissionService.findById(submissionId); contestOnlyService.checkViewSource(request, submission); String userId = authentication != null ? authentication.getName() : null; if (!submissionService.canView(request, submission)) { throw new BusinessException(BusinessCode.VIEW_SOURCE_PERMISSION_DENIED, submissionId); } String language = languageService.getLanguageName(submission.getLanguage()); if (style == null) { style = userPerferenceMapper.getStyle(userId); } else { userPerferenceMapper.setStyle(userId, style); } String source = submissionDetailMapper.findSourceById(submissionId); request.setAttribute("submission", submission); if (submission.getContest() != null) { request.setAttribute("contestId", submission.getContest()); } request.setAttribute("language", language); request.setAttribute("result", ResultType.getShowSourceString(submission.getScore())); request.setAttribute("style", style); request.setAttribute("source", source); return "submissions/source"; }  @Secured("ROLE_USER") @GetMapping("showsource") @SuppressWarnings("AssignmentToMethodParameter") String showSource(HttpServletRequest request,
            @RequestParam("solution_id") long submissionId,
            @RequestParam(value = "style", required = false) Integer style,
            @Nullable Authentication authentication);  }
@Test public void testShowSource() throws Exception { log.info("showSource"); Submission submission = mockDataService.submission(false); long solutionId = submission.getId(); Integer style = null; MvcResult result = mvc.perform(get("/showsource").with(user(submission.getUser())) .param("solution_id", Long.toString(solutionId)) .param("style", Objects.toString(style, ""))) .andExpect(status().isOk()) .andExpect(view().name("submissions/source")) .andExpect(content().contentTypeCompatibleWith(MediaType.TEXT_HTML)) .andReturn(); }