@Test public void listLatestDebates() throws Exception { Article article = article(funZone.getZone(), "article 1"); Debate debate = debate(article, "123456", null); when(articleService.listLatestDebates(null)).thenReturn( singletonList(debate)); when(articleService.listArticlesByDebatesWithCache(singletonList(debate.getDebateId()))).thenReturn( singletonList(article)); mockMvc.perform(get("/new-debate")) .andExpect(model().attributeExists("recommendZones")) .andExpect(content().string(containsString("123456"))) .andExpect(containsDebateFormTemplate()) .andExpect(containsText("<meta name=\"robots\" content=\"noindex, follow\">")); }
@RequestMapping("/new-debate") public ModelAndView listLatestDebates( @RequestParam(value = "start", required = false) FlakeId startDebateId) { List<Debate> debates = articleService.listLatestDebates(startDebateId); List<Article> articles = articleService.listArticlesByDebatesWithCache(debates.stream() .map(Debate::getDebateId) .collect(toList())); return new IndexModelAndView(zoneService).addObject("debateList", new DebateList(debates, articles)); }
HomeController { @RequestMapping("/new-debate") public ModelAndView listLatestDebates( @RequestParam(value = "start", required = false) FlakeId startDebateId) { List<Debate> debates = articleService.listLatestDebates(startDebateId); List<Article> articles = articleService.listArticlesByDebatesWithCache(debates.stream() .map(Debate::getDebateId) .collect(toList())); return new IndexModelAndView(zoneService).addObject("debateList", new DebateList(debates, articles)); } }
HomeController { @RequestMapping("/new-debate") public ModelAndView listLatestDebates( @RequestParam(value = "start", required = false) FlakeId startDebateId) { List<Debate> debates = articleService.listLatestDebates(startDebateId); List<Article> articles = articleService.listArticlesByDebatesWithCache(debates.stream() .map(Debate::getDebateId) .collect(toList())); return new IndexModelAndView(zoneService).addObject("debateList", new DebateList(debates, articles)); }  }
HomeController { @RequestMapping("/new-debate") public ModelAndView listLatestDebates( @RequestParam(value = "start", required = false) FlakeId startDebateId) { List<Debate> debates = articleService.listLatestDebates(startDebateId); List<Article> articles = articleService.listArticlesByDebatesWithCache(debates.stream() .map(Debate::getDebateId) .collect(toList())); return new IndexModelAndView(zoneService).addObject("debateList", new DebateList(debates, articles)); }  @RequestMapping("/") ModelAndView index(
      @RequestParam(value = "start", required = false) FlakeId startArticleId); @RequestMapping("/hot.rss") Object rssFeed(); @RequestMapping("/new") ModelAndView listLatestArticles(
      @RequestParam(value = "start", required = false) FlakeId startArticleId); @RequestMapping("/new-debate") ModelAndView listLatestDebates(
      @RequestParam(value = "start", required = false) FlakeId startDebateId); @RequestMapping("/zone/a-z") ModelAndView zoneAtoZ(); @RequestMapping("/honor") ModelAndView listTopHonor(); }
HomeController { @RequestMapping("/new-debate") public ModelAndView listLatestDebates( @RequestParam(value = "start", required = false) FlakeId startDebateId) { List<Debate> debates = articleService.listLatestDebates(startDebateId); List<Article> articles = articleService.listArticlesByDebatesWithCache(debates.stream() .map(Debate::getDebateId) .collect(toList())); return new IndexModelAndView(zoneService).addObject("debateList", new DebateList(debates, articles)); }  @RequestMapping("/") ModelAndView index(
      @RequestParam(value = "start", required = false) FlakeId startArticleId); @RequestMapping("/hot.rss") Object rssFeed(); @RequestMapping("/new") ModelAndView listLatestArticles(
      @RequestParam(value = "start", required = false) FlakeId startArticleId); @RequestMapping("/new-debate") ModelAndView listLatestDebates(
      @RequestParam(value = "start", required = false) FlakeId startDebateId); @RequestMapping("/zone/a-z") ModelAndView zoneAtoZ(); @RequestMapping("/honor") ModelAndView listTopHonor();  }