@Test public void newDebates() throws Exception { Zone z = zoneInfo.getZone(); when(zoneService.loadZone(z)).thenReturn(zoneInfo); Article a = article(z, "python is serious"); Debate d1 = debate(a, "agree, good.", null); Debate d2 = debate(a, "it's too simple.", null); when(articleService.listLatestZoneDebates(z, null)).thenReturn( asList(d1, d2)); when(articleService.listArticlesByDebatesWithCache(asList(d1.getDebateId(), d2.getDebateId()))).thenReturn(asList(a)); mockMvc.perform(get("/z/programming/new-debate")) .andExpect(content().string(containsString("python is serious"))) .andExpect(content().string(containsString("agree, good."))) .andExpect(content().string(containsString("it&#39;s too simple"))) .andExpect(containsDebateFormTemplate()) .andExpect(containsText("<meta name=\"robots\" content=\"noindex, follow\">")); }
@RequestMapping("/{zone}/new-debate") public Object newDebates(@PathVariable("zone") String rawZone, @RequestParam(value = "start", required = false) FlakeId startDebateId, HttpServletRequest request) { return resolveZone(request, rawZone, zoneInfo -> { List<Debate> debates = articleService.listLatestZoneDebates(zoneInfo.getZone(), startDebateId); List<Article> articles = articleService.listArticlesByDebatesWithCache(debates.stream() .map(Debate::getDebateId) .collect(Collectors.toList())); return new ZonePageModelView(zoneInfo, zoneService).addObject("debateList", new DebateList(debates, articles)); }); }
ZoneController { @RequestMapping("/{zone}/new-debate") public Object newDebates(@PathVariable("zone") String rawZone, @RequestParam(value = "start", required = false) FlakeId startDebateId, HttpServletRequest request) { return resolveZone(request, rawZone, zoneInfo -> { List<Debate> debates = articleService.listLatestZoneDebates(zoneInfo.getZone(), startDebateId); List<Article> articles = articleService.listArticlesByDebatesWithCache(debates.stream() .map(Debate::getDebateId) .collect(Collectors.toList())); return new ZonePageModelView(zoneInfo, zoneService).addObject("debateList", new DebateList(debates, articles)); }); } }
ZoneController { @RequestMapping("/{zone}/new-debate") public Object newDebates(@PathVariable("zone") String rawZone, @RequestParam(value = "start", required = false) FlakeId startDebateId, HttpServletRequest request) { return resolveZone(request, rawZone, zoneInfo -> { List<Debate> debates = articleService.listLatestZoneDebates(zoneInfo.getZone(), startDebateId); List<Article> articles = articleService.listArticlesByDebatesWithCache(debates.stream() .map(Debate::getDebateId) .collect(Collectors.toList())); return new ZonePageModelView(zoneInfo, zoneService).addObject("debateList", new DebateList(debates, articles)); }); }  }
ZoneController { @RequestMapping("/{zone}/new-debate") public Object newDebates(@PathVariable("zone") String rawZone, @RequestParam(value = "start", required = false) FlakeId startDebateId, HttpServletRequest request) { return resolveZone(request, rawZone, zoneInfo -> { List<Debate> debates = articleService.listLatestZoneDebates(zoneInfo.getZone(), startDebateId); List<Article> articles = articleService.listArticlesByDebatesWithCache(debates.stream() .map(Debate::getDebateId) .collect(Collectors.toList())); return new ZonePageModelView(zoneInfo, zoneService).addObject("debateList", new DebateList(debates, articles)); }); }  @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}/new-debate") public Object newDebates(@PathVariable("zone") String rawZone, @RequestParam(value = "start", required = false) FlakeId startDebateId, HttpServletRequest request) { return resolveZone(request, rawZone, zoneInfo -> { List<Debate> debates = articleService.listLatestZoneDebates(zoneInfo.getZone(), startDebateId); List<Article> articles = articleService.listArticlesByDebatesWithCache(debates.stream() .map(Debate::getDebateId) .collect(Collectors.toList())); return new ZonePageModelView(zoneInfo, zoneService).addObject("debateList", new DebateList(debates, articles)); }); }  @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);  }