@Test public void newsFeedPart() throws Exception { Account account = accountCitizen("bar111"); String token = prepareAccessToken(account); Article article = article(Zone.valueOf("xyz123"), "title1"); Debate d1 = debate(article, "reply 00001", null); Debate d2 = debate(article, "reply 00002", null); FeedAsset f1 = assetReply(d1); FeedAsset f2 = assetReply(d2); when(feedService.listFeeds(isA(Authorization.class), isNull(FlakeId.class))).thenReturn(asList( f1, f2)); when(articleService.listDebatesByIdWithCache(asList(d1.getDebateId(), d2.getDebateId()))).thenReturn(asList(d1, d2)); when(articleService.listArticlesByDebatesWithCache(asList(d1.getDebateId(), d2.getDebateId()))).thenReturn(asList(article)); mockMvc.perform(get("/account/news-feed.part").header(AccountAccessToken.HEADER_KEY, token)) .andExpect(view().name("account/news-feed.part")) .andExpect(model().attribute("isFirstPage", true)) .andExpect(content().string(containsString("reply 00001"))) .andExpect(content().string(containsString("reply 00002"))); }
@RequestMapping("/news-feed.part") public ModelAndView newsFeedPart(AccountAccessToken accountAccessToken, @RequestParam(value = "start", required = false) FlakeId startAssetId) { List<FeedAsset> feedAssets = feedService.listFeeds(accountAccessToken, startAssetId); List<Debate> debates = articleService.listDebatesByIdWithCache(feedAssets.stream() .filter(f -> f.getAssetType().isDebate()) .map(FeedAsset::getAssetId) .collect(toList())); List<Article> articles = articleService.listArticlesByDebatesWithCache(debates.stream() .map(Debate::getDebateId) .collect(toList())); return new ModelAndView("account/news-feed.part").addObject("newsFeed", new NewsFeed(feedAssets, debates, articles)).addObject("isFirstPage", startAssetId == null); }
AccountController { @RequestMapping("/news-feed.part") public ModelAndView newsFeedPart(AccountAccessToken accountAccessToken, @RequestParam(value = "start", required = false) FlakeId startAssetId) { List<FeedAsset> feedAssets = feedService.listFeeds(accountAccessToken, startAssetId); List<Debate> debates = articleService.listDebatesByIdWithCache(feedAssets.stream() .filter(f -> f.getAssetType().isDebate()) .map(FeedAsset::getAssetId) .collect(toList())); List<Article> articles = articleService.listArticlesByDebatesWithCache(debates.stream() .map(Debate::getDebateId) .collect(toList())); return new ModelAndView("account/news-feed.part").addObject("newsFeed", new NewsFeed(feedAssets, debates, articles)).addObject("isFirstPage", startAssetId == null); } }
AccountController { @RequestMapping("/news-feed.part") public ModelAndView newsFeedPart(AccountAccessToken accountAccessToken, @RequestParam(value = "start", required = false) FlakeId startAssetId) { List<FeedAsset> feedAssets = feedService.listFeeds(accountAccessToken, startAssetId); List<Debate> debates = articleService.listDebatesByIdWithCache(feedAssets.stream() .filter(f -> f.getAssetType().isDebate()) .map(FeedAsset::getAssetId) .collect(toList())); List<Article> articles = articleService.listArticlesByDebatesWithCache(debates.stream() .map(Debate::getDebateId) .collect(toList())); return new ModelAndView("account/news-feed.part").addObject("newsFeed", new NewsFeed(feedAssets, debates, articles)).addObject("isFirstPage", startAssetId == null); }  }
AccountController { @RequestMapping("/news-feed.part") public ModelAndView newsFeedPart(AccountAccessToken accountAccessToken, @RequestParam(value = "start", required = false) FlakeId startAssetId) { List<FeedAsset> feedAssets = feedService.listFeeds(accountAccessToken, startAssetId); List<Debate> debates = articleService.listDebatesByIdWithCache(feedAssets.stream() .filter(f -> f.getAssetType().isDebate()) .map(FeedAsset::getAssetId) .collect(toList())); List<Article> articles = articleService.listArticlesByDebatesWithCache(debates.stream() .map(Debate::getDebateId) .collect(toList())); return new ModelAndView("account/news-feed.part").addObject("newsFeed", new NewsFeed(feedAssets, debates, articles)).addObject("isFirstPage", startAssetId == null); }  @RequestMapping("/sign-up") ModelAndView signUp(); @RequestMapping("/sign-in") String signIn(); @RequestMapping("/forget-password") String forgetPassword(); @RequestMapping("/reset-password") ModelAndView resetPassword(@RequestParam("key") String key); @RequestMapping("/settings") String settings(); @RequestMapping("/settings.part") ModelAndView settingsPart(AccountAccessToken accountAccessToken); @RequestMapping("/client-app") String clientApp(); @RequestMapping("/client-app.part") ModelAndView clientAppPart(AccountAccessToken accountAccessToken); @RequestMapping("/news-feed") String newsFeed(); @RequestMapping("/up-voted") String upVoted(); @RequestMapping("/news-feed.part") ModelAndView newsFeedPart(AccountAccessToken accountAccessToken,
      @RequestParam(value = "start", required = false) FlakeId startAssetId); @RequestMapping("/up-voted.part") ModelAndView upVotedPart(AccountAccessToken accountAccessToken,
      @RequestParam(value = "start", required = false) FlakeId startArticleId); @RequestMapping("/activation") ModelAndView activation(@RequestParam("key") String key, HttpServletResponse response); }
AccountController { @RequestMapping("/news-feed.part") public ModelAndView newsFeedPart(AccountAccessToken accountAccessToken, @RequestParam(value = "start", required = false) FlakeId startAssetId) { List<FeedAsset> feedAssets = feedService.listFeeds(accountAccessToken, startAssetId); List<Debate> debates = articleService.listDebatesByIdWithCache(feedAssets.stream() .filter(f -> f.getAssetType().isDebate()) .map(FeedAsset::getAssetId) .collect(toList())); List<Article> articles = articleService.listArticlesByDebatesWithCache(debates.stream() .map(Debate::getDebateId) .collect(toList())); return new ModelAndView("account/news-feed.part").addObject("newsFeed", new NewsFeed(feedAssets, debates, articles)).addObject("isFirstPage", startAssetId == null); }  @RequestMapping("/sign-up") ModelAndView signUp(); @RequestMapping("/sign-in") String signIn(); @RequestMapping("/forget-password") String forgetPassword(); @RequestMapping("/reset-password") ModelAndView resetPassword(@RequestParam("key") String key); @RequestMapping("/settings") String settings(); @RequestMapping("/settings.part") ModelAndView settingsPart(AccountAccessToken accountAccessToken); @RequestMapping("/client-app") String clientApp(); @RequestMapping("/client-app.part") ModelAndView clientAppPart(AccountAccessToken accountAccessToken); @RequestMapping("/news-feed") String newsFeed(); @RequestMapping("/up-voted") String upVoted(); @RequestMapping("/news-feed.part") ModelAndView newsFeedPart(AccountAccessToken accountAccessToken,
      @RequestParam(value = "start", required = false) FlakeId startAssetId); @RequestMapping("/up-voted.part") ModelAndView upVotedPart(AccountAccessToken accountAccessToken,
      @RequestParam(value = "start", required = false) FlakeId startArticleId); @RequestMapping("/activation") ModelAndView activation(@RequestParam("key") String key, HttpServletResponse response);  }