### Question:
BannerController { @RequestMapping(value = "/banners/upload", method = RequestMethod.POST) public String upload(@ModelAttribute Banner uploadedBanner, HttpServletRequest request) { Component component = componentService.getComponentOfForum(); bannerService.uploadBanner(uploadedBanner, component); return "redirect:" + getSourcePageUrl(request); } @Autowired  BannerController(BannerService bannerService, ComponentService componentService); @RequestMapping(value = "/banners/upload", method = RequestMethod.POST) String upload(@ModelAttribute Banner uploadedBanner, HttpServletRequest request);  }### Answer:
@Test public void afterBannerUploadingUserShouldStayInTheSamePage() { HttpServletRequest request = mock(HttpServletRequest.class); String initialPage = "/topics/2"; when(request.getHeader("referer")).thenReturn(initialPage); Banner uploadedBanner = new Banner(); String resultUrl = bannerController.upload(uploadedBanner, request); assertEquals(resultUrl, "redirect:" + initialPage); }