@Test public void userProfile() throws Exception { Account accountWithDesc = account.withDescription("**bold**"); when(accountService.loadAccount("foo-user")).thenReturn(accountWithDesc); when(accountService.loadAccountStats("foo-user")).thenReturn(AccountStats.zero(accountWithDesc.getAccountId())); mockMvc.perform(get("/u/foo-user")) .andExpect(content().string(containsString("<p><strong>bold</strong></p>"))) .andExpect(content().string(containsString("關於 foo-user"))) .andExpect(content().string(containsString( "<link rel=\"canonical\" href=\"https: }
@RequestMapping("/u/{username}") public Object userProfile(@PathVariable("username") String username) { Account account = accountService.loadAccount(username); if (!account.getUsername().equals(username)) { RedirectView redirectView = new RedirectView("/u/" + account.getUsername()); redirectView.setStatusCode(HttpStatus.MOVED_PERMANENTLY); return redirectView; } AccountStats accountStats = accountService.loadAccountStats(account.getUsername()); List<ZoneInfo> zones = zoneService.listAdministerZones(account.getUsername()); return new ModelAndView("account/user-profile") .addObject("account", account) .addObject("accountStats", accountStats) .addObject("administerZones", zones); }
UserController { @RequestMapping("/u/{username}") public Object userProfile(@PathVariable("username") String username) { Account account = accountService.loadAccount(username); if (!account.getUsername().equals(username)) { RedirectView redirectView = new RedirectView("/u/" + account.getUsername()); redirectView.setStatusCode(HttpStatus.MOVED_PERMANENTLY); return redirectView; } AccountStats accountStats = accountService.loadAccountStats(account.getUsername()); List<ZoneInfo> zones = zoneService.listAdministerZones(account.getUsername()); return new ModelAndView("account/user-profile") .addObject("account", account) .addObject("accountStats", accountStats) .addObject("administerZones", zones); } }
UserController { @RequestMapping("/u/{username}") public Object userProfile(@PathVariable("username") String username) { Account account = accountService.loadAccount(username); if (!account.getUsername().equals(username)) { RedirectView redirectView = new RedirectView("/u/" + account.getUsername()); redirectView.setStatusCode(HttpStatus.MOVED_PERMANENTLY); return redirectView; } AccountStats accountStats = accountService.loadAccountStats(account.getUsername()); List<ZoneInfo> zones = zoneService.listAdministerZones(account.getUsername()); return new ModelAndView("account/user-profile") .addObject("account", account) .addObject("accountStats", accountStats) .addObject("administerZones", zones); }  }
UserController { @RequestMapping("/u/{username}") public Object userProfile(@PathVariable("username") String username) { Account account = accountService.loadAccount(username); if (!account.getUsername().equals(username)) { RedirectView redirectView = new RedirectView("/u/" + account.getUsername()); redirectView.setStatusCode(HttpStatus.MOVED_PERMANENTLY); return redirectView; } AccountStats accountStats = accountService.loadAccountStats(account.getUsername()); List<ZoneInfo> zones = zoneService.listAdministerZones(account.getUsername()); return new ModelAndView("account/user-profile") .addObject("account", account) .addObject("accountStats", accountStats) .addObject("administerZones", zones); }  @RequestMapping("/u/{username}") Object userProfile(@PathVariable("username") String username); @RequestMapping("/u/{username}/articles") ModelAndView createdArticles(@PathVariable("username") String username,
      @RequestParam(value = "start", required = false) FlakeId startArticleId); @RequestMapping("/u/{username}/honors") ModelAndView userHonors(@PathVariable("username") String username); @RequestMapping("/u/{username}/debates") ModelAndView createdDebates(@PathVariable("username") String username,
      @RequestParam(value = "start", required = false) FlakeId startDebateId); }
UserController { @RequestMapping("/u/{username}") public Object userProfile(@PathVariable("username") String username) { Account account = accountService.loadAccount(username); if (!account.getUsername().equals(username)) { RedirectView redirectView = new RedirectView("/u/" + account.getUsername()); redirectView.setStatusCode(HttpStatus.MOVED_PERMANENTLY); return redirectView; } AccountStats accountStats = accountService.loadAccountStats(account.getUsername()); List<ZoneInfo> zones = zoneService.listAdministerZones(account.getUsername()); return new ModelAndView("account/user-profile") .addObject("account", account) .addObject("accountStats", accountStats) .addObject("administerZones", zones); }  @RequestMapping("/u/{username}") Object userProfile(@PathVariable("username") String username); @RequestMapping("/u/{username}/articles") ModelAndView createdArticles(@PathVariable("username") String username,
      @RequestParam(value = "start", required = false) FlakeId startArticleId); @RequestMapping("/u/{username}/honors") ModelAndView userHonors(@PathVariable("username") String username); @RequestMapping("/u/{username}/debates") ModelAndView createdDebates(@PathVariable("username") String username,
      @RequestParam(value = "start", required = false) FlakeId startDebateId);  }