@Test public void rssFeed() throws Exception { Zone z = zoneInfo.getZone(); when(zoneService.loadZone(z)).thenReturn(zoneInfo); Article article1 = article(z, "javascript discussion"); Article article2 = article(z, FlakeId.fromString("phpone"), "php-lang discussion"); when(articleService.listRssHotZoneArticlesWithCache(z)).thenReturn( asList(article1, article2)); String pubDateStr = RFC1123_FORMATTER.format(article2.getCreateTime()); mockMvc.perform(get("/z/programming/hot.rss")) .andExpect(xpath("/rss/channel/title").string("programming kaif.io")) .andExpect(xpath("/rss/channel/description").string("programming-alias 熱門")) .andExpect(xpath("/rss/channel/pubDate").string(pubDateStr)) .andExpect(xpath("/rss/channel/item[1]/title").string("javascript discussion")) .andExpect(xpath("/rss/channel/item[2]/guid").string("phpone")); }
@RequestMapping("/{zone}/hot.rss") public Object rssFeed(@PathVariable("zone") String rawZone, HttpServletRequest request) { return resolveZone(request, rawZone, zoneInfo -> { request.getRequestURL(); ModelAndView modelAndView = new ModelAndView().addObject("zoneInfo", zoneInfo) .addObject("articles", articleService.listRssHotZoneArticlesWithCache(zoneInfo.getZone())); modelAndView.setView(new HotArticleRssContentView()); return modelAndView; }); }
ZoneController { @RequestMapping("/{zone}/hot.rss") public Object rssFeed(@PathVariable("zone") String rawZone, HttpServletRequest request) { return resolveZone(request, rawZone, zoneInfo -> { request.getRequestURL(); ModelAndView modelAndView = new ModelAndView().addObject("zoneInfo", zoneInfo) .addObject("articles", articleService.listRssHotZoneArticlesWithCache(zoneInfo.getZone())); modelAndView.setView(new HotArticleRssContentView()); return modelAndView; }); } }
ZoneController { @RequestMapping("/{zone}/hot.rss") public Object rssFeed(@PathVariable("zone") String rawZone, HttpServletRequest request) { return resolveZone(request, rawZone, zoneInfo -> { request.getRequestURL(); ModelAndView modelAndView = new ModelAndView().addObject("zoneInfo", zoneInfo) .addObject("articles", articleService.listRssHotZoneArticlesWithCache(zoneInfo.getZone())); modelAndView.setView(new HotArticleRssContentView()); return modelAndView; }); }  }
ZoneController { @RequestMapping("/{zone}/hot.rss") public Object rssFeed(@PathVariable("zone") String rawZone, HttpServletRequest request) { return resolveZone(request, rawZone, zoneInfo -> { request.getRequestURL(); ModelAndView modelAndView = new ModelAndView().addObject("zoneInfo", zoneInfo) .addObject("articles", articleService.listRssHotZoneArticlesWithCache(zoneInfo.getZone())); modelAndView.setView(new HotArticleRssContentView()); return modelAndView; }); }  @RequestMapping("/{zone}") Object hotArticles(@PathVariable("zone") String rawZone,
      @RequestParam(value = "start", required = false) FlakeId startArticleId,
      HttpServletRequest request); @RequestMapping("/{zone}/hot.rss") Object rssFeed(@PathVariable("zone") String rawZone, HttpServletRequest request); @RequestMapping("/{zone}/new") Object newArticles(@PathVariable("zone") String rawZone,
      @RequestParam(value = "start", required = false) FlakeId startArticleId,
      HttpServletRequest request); @RequestMapping("/{zone}/new-debate") Object newDebates(@PathVariable("zone") String rawZone,
      @RequestParam(value = "start", required = false) FlakeId startDebateId,
      HttpServletRequest request); @RequestMapping({ "/{zone}/article/create-link", "/{zone}/article/create-speak" }) Object createArticle(@PathVariable("zone") String rawZone, HttpServletRequest request); @RequestMapping("/{zone}/honor") Object zoneHonors(@PathVariable("zone") String rawZone, HttpServletRequest request); @RequestMapping("/{zone}/debates/{articleId}") Object articleDebates(@PathVariable("zone") String rawZone,
      @PathVariable("articleId") FlakeId articleFlakeId,
      HttpServletRequest request); @RequestMapping("/{zone}/debates/{articleId}/{parentDebateId}") Object childDebates(@PathVariable("zone") String rawZone,
      @PathVariable("articleId") FlakeId articleFlakeId,
      @PathVariable("parentDebateId") FlakeId debateFlakeId,
      HttpServletRequest request); }
ZoneController { @RequestMapping("/{zone}/hot.rss") public Object rssFeed(@PathVariable("zone") String rawZone, HttpServletRequest request) { return resolveZone(request, rawZone, zoneInfo -> { request.getRequestURL(); ModelAndView modelAndView = new ModelAndView().addObject("zoneInfo", zoneInfo) .addObject("articles", articleService.listRssHotZoneArticlesWithCache(zoneInfo.getZone())); modelAndView.setView(new HotArticleRssContentView()); return modelAndView; }); }  @RequestMapping("/{zone}") Object hotArticles(@PathVariable("zone") String rawZone,
      @RequestParam(value = "start", required = false) FlakeId startArticleId,
      HttpServletRequest request); @RequestMapping("/{zone}/hot.rss") Object rssFeed(@PathVariable("zone") String rawZone, HttpServletRequest request); @RequestMapping("/{zone}/new") Object newArticles(@PathVariable("zone") String rawZone,
      @RequestParam(value = "start", required = false) FlakeId startArticleId,
      HttpServletRequest request); @RequestMapping("/{zone}/new-debate") Object newDebates(@PathVariable("zone") String rawZone,
      @RequestParam(value = "start", required = false) FlakeId startDebateId,
      HttpServletRequest request); @RequestMapping({ "/{zone}/article/create-link", "/{zone}/article/create-speak" }) Object createArticle(@PathVariable("zone") String rawZone, HttpServletRequest request); @RequestMapping("/{zone}/honor") Object zoneHonors(@PathVariable("zone") String rawZone, HttpServletRequest request); @RequestMapping("/{zone}/debates/{articleId}") Object articleDebates(@PathVariable("zone") String rawZone,
      @PathVariable("articleId") FlakeId articleFlakeId,
      HttpServletRequest request); @RequestMapping("/{zone}/debates/{articleId}/{parentDebateId}") Object childDebates(@PathVariable("zone") String rawZone,
      @PathVariable("articleId") FlakeId articleFlakeId,
      @PathVariable("parentDebateId") FlakeId debateFlakeId,
      HttpServletRequest request);  }