@Test public void hotByZone() throws Exception { when(articleService.listHotZoneArticles(zone.getZone(), null)).thenReturn(asList(article1)); oauthPerform(user, get("/v1/article/zone/fun/hot")) .andExpect(status().isOk()).andExpect(jsonPath("$.data[0].title", is("art1"))); }
@ApiOperation(value = "[public] List hot articles for the zone", notes = "List hot articles for the zone, 25 articles a page. " + "To retrieve next page, passing last article id of previous page in parameter start-article-id") @RequiredScope(ClientAppScope.PUBLIC) @RequestMapping(value = "/zone/{zone}/hot", method = RequestMethod.GET) public List<V1ArticleDto> hotByZone(ClientAppUserAccessToken accessToken, @PathVariable("zone") String zone, @RequestParam(value = "start-article-id", required = false) FlakeId startArticleId) { return toDtos(articleService.listHotZoneArticles(Zone.valueOf(zone), startArticleId)); }
V1ArticleResource { @ApiOperation(value = "[public] List hot articles for the zone", notes = "List hot articles for the zone, 25 articles a page. " + "To retrieve next page, passing last article id of previous page in parameter start-article-id") @RequiredScope(ClientAppScope.PUBLIC) @RequestMapping(value = "/zone/{zone}/hot", method = RequestMethod.GET) public List<V1ArticleDto> hotByZone(ClientAppUserAccessToken accessToken, @PathVariable("zone") String zone, @RequestParam(value = "start-article-id", required = false) FlakeId startArticleId) { return toDtos(articleService.listHotZoneArticles(Zone.valueOf(zone), startArticleId)); } }
V1ArticleResource { @ApiOperation(value = "[public] List hot articles for the zone", notes = "List hot articles for the zone, 25 articles a page. " + "To retrieve next page, passing last article id of previous page in parameter start-article-id") @RequiredScope(ClientAppScope.PUBLIC) @RequestMapping(value = "/zone/{zone}/hot", method = RequestMethod.GET) public List<V1ArticleDto> hotByZone(ClientAppUserAccessToken accessToken, @PathVariable("zone") String zone, @RequestParam(value = "start-article-id", required = false) FlakeId startArticleId) { return toDtos(articleService.listHotZoneArticles(Zone.valueOf(zone), startArticleId)); }  }
V1ArticleResource { @ApiOperation(value = "[public] List hot articles for the zone", notes = "List hot articles for the zone, 25 articles a page. " + "To retrieve next page, passing last article id of previous page in parameter start-article-id") @RequiredScope(ClientAppScope.PUBLIC) @RequestMapping(value = "/zone/{zone}/hot", method = RequestMethod.GET) public List<V1ArticleDto> hotByZone(ClientAppUserAccessToken accessToken, @PathVariable("zone") String zone, @RequestParam(value = "start-article-id", required = false) FlakeId startArticleId) { return toDtos(articleService.listHotZoneArticles(Zone.valueOf(zone), startArticleId)); }  @ApiOperation(value = "[public] Get an article", notes = "Get an article by articleId") @RequiredScope(ClientAppScope.PUBLIC) @RequestMapping(value = "/{articleId}", method = RequestMethod.GET) V1ArticleDto article(ClientAppUserAccessToken accessToken,
      @PathVariable("articleId") FlakeId articleId); @ApiOperation(value = "[public] List hot articles of all zones", notes = "List hot articles of all zones, 25 articles a page. " + "To retrieve next page, passing last article id of previous page in parameter start-article-id") @RequiredScope(ClientAppScope.PUBLIC) @RequestMapping(value = "/hot", method = RequestMethod.GET) List<V1ArticleDto> hot(ClientAppUserAccessToken accessToken,
      @RequestParam(value = "start-article-id", required = false) FlakeId startArticleId); @ApiOperation(value = "[public] List latest articles of all zones", notes = "List latest articles of all zones, 25 articles a page. " + "To retrieve next page, passing last article id of previous page in parameter start-article-id") @RequiredScope(ClientAppScope.PUBLIC) @RequestMapping(value = "/latest", method = RequestMethod.GET) List<V1ArticleDto> latest(ClientAppUserAccessToken accessToken,
      @RequestParam(value = "start-article-id", required = false) FlakeId startArticleId); @ApiOperation(value = "[public] List latest articles for the zone", notes = "List latest articles for the zone, 25 articles a page. " + "To retrieve next page, passing last article id of previous page in parameter start-article-id") @RequiredScope(ClientAppScope.PUBLIC) @RequestMapping(value = "/zone/{zone}/latest", method = RequestMethod.GET) List<V1ArticleDto> latestByZone(ClientAppUserAccessToken accessToken,
      @PathVariable("zone") String zone,
      @RequestParam(value = "start-article-id", required = false) FlakeId startArticleId); @ApiOperation(value = "[public] List hot articles for the zone", notes = "List hot articles for the zone, 25 articles a page. " + "To retrieve next page, passing last article id of previous page in parameter start-article-id") @RequiredScope(ClientAppScope.PUBLIC) @RequestMapping(value = "/zone/{zone}/hot", method = RequestMethod.GET) List<V1ArticleDto> hotByZone(ClientAppUserAccessToken accessToken,
      @PathVariable("zone") String zone,
      @RequestParam(value = "start-article-id", required = false) FlakeId startArticleId); @ApiOperation(value = "[public] List submitted articles of the user", notes = "List submitted articles of the user, 25 articles a page. " + "To retrieve next page, passing last article id of previous page in parameter start-article-id") @RequiredScope(ClientAppScope.PUBLIC) @RequestMapping(value = "/user/{username}/submitted", method = RequestMethod.GET) List<V1ArticleDto> submitted(ClientAppUserAccessToken accessToken,
      @PathVariable("username") String username,
      @RequestParam(value = "start-article-id", required = false) FlakeId startArticleId); @ApiOperation(value = "[vote] List voted articles of the user", notes = "List voted articles of the user, 25 articles a page. " + "To retrieve next page, passing last article id of previous page in parameter start-article-id") @RequiredScope(ClientAppScope.VOTE) @RequestMapping(value = "/voted", method = RequestMethod.GET) List<V1ArticleDto> voted(ClientAppUserAccessToken accessToken,
      @RequestParam(value = "start-article-id", required = false) FlakeId startArticleId); @ApiOperation(value = "[article] Create an article with external link", notes = "Create an article with external link in specified zone. Before calling the method, " + "it is recommended check the link already submitted by other users. check API - " + "'GET /zone/{zone}/external-link'") @ResponseStatus(HttpStatus.CREATED) @RequiredScope(ClientAppScope.ARTICLE) @RequestMapping(value = "/external-link", method = RequestMethod.PUT, consumes = { MediaType.APPLICATION_JSON_VALUE }) V1ArticleDto externalLink(ClientAppUserAccessToken token,
      @Valid @RequestBody ExternalLinkEntry entry); @ApiOperation(value = "[public] List articles for external link", notes = "List most 3 external-url-articles for a specific url." + "You are encouraged to show exist articles to end user before creating the article " + "to prevent article duplication in zone.") @RequiredScope(ClientAppScope.PUBLIC) @RequestMapping(value = "/zone/{zone}/external-link", method = RequestMethod.GET) List<V1ArticleDto> externalLink(ClientAppUserAccessToken accessToken,
      @PathVariable(value = "zone") String zone,
      @RequestParam("url") String url); @ApiOperation(value = "[public] check url already submitted in zone", notes = "Check url already submitted as external-url-article in zone") @RequiredScope(ClientAppScope.PUBLIC) @RequestMapping(value = "/zone/{zone}/external-link/exist", method = RequestMethod.GET) boolean isExternalLinkExist(ClientAppUserAccessToken accessToken,
      @PathVariable(value = "zone") String zone,
      @RequestParam("url") String url); @ApiOperation(value = "[public] check the article can be deleted", notes = "Check the article can be deleted by user. Note that there is time-constraint " + "on article deletion. If article is old enough, the method return false.") @RequiredScope(ClientAppScope.PUBLIC) @RequestMapping(value = "/{articleId}/can-delete", method = RequestMethod.GET) boolean canDeleteArticle(ClientAppUserAccessToken accessToken,
      @PathVariable(value = "articleId") FlakeId articleId,
      @RequestParam("username") String username); @ApiOperation(value = "[article] Create an article with content", notes = "Create an article with content in specified zone") @ResponseStatus(HttpStatus.CREATED) @RequiredScope(ClientAppScope.ARTICLE) @RequestMapping(value = "/speak", method = RequestMethod.PUT, consumes = { MediaType.APPLICATION_JSON_VALUE }) V1ArticleDto speak(ClientAppUserAccessToken token, @Valid @RequestBody SpeakEntry entry); @ApiOperation(value = "[article] Delete an article", notes = "Delete an article, return status 200 if success, response as error if sign-in user " + "not allow to delete the article.") @RequiredScope(ClientAppScope.ARTICLE) @RequestMapping(value = "/{articleId}", method = RequestMethod.DELETE, consumes = { MediaType.APPLICATION_JSON_VALUE }) void deleteArticle(ClientAppUserAccessToken token,
      @PathVariable("articleId") FlakeId articleId); }
V1ArticleResource { @ApiOperation(value = "[public] List hot articles for the zone", notes = "List hot articles for the zone, 25 articles a page. " + "To retrieve next page, passing last article id of previous page in parameter start-article-id") @RequiredScope(ClientAppScope.PUBLIC) @RequestMapping(value = "/zone/{zone}/hot", method = RequestMethod.GET) public List<V1ArticleDto> hotByZone(ClientAppUserAccessToken accessToken, @PathVariable("zone") String zone, @RequestParam(value = "start-article-id", required = false) FlakeId startArticleId) { return toDtos(articleService.listHotZoneArticles(Zone.valueOf(zone), startArticleId)); }  @ApiOperation(value = "[public] Get an article", notes = "Get an article by articleId") @RequiredScope(ClientAppScope.PUBLIC) @RequestMapping(value = "/{articleId}", method = RequestMethod.GET) V1ArticleDto article(ClientAppUserAccessToken accessToken,
      @PathVariable("articleId") FlakeId articleId); @ApiOperation(value = "[public] List hot articles of all zones", notes = "List hot articles of all zones, 25 articles a page. " + "To retrieve next page, passing last article id of previous page in parameter start-article-id") @RequiredScope(ClientAppScope.PUBLIC) @RequestMapping(value = "/hot", method = RequestMethod.GET) List<V1ArticleDto> hot(ClientAppUserAccessToken accessToken,
      @RequestParam(value = "start-article-id", required = false) FlakeId startArticleId); @ApiOperation(value = "[public] List latest articles of all zones", notes = "List latest articles of all zones, 25 articles a page. " + "To retrieve next page, passing last article id of previous page in parameter start-article-id") @RequiredScope(ClientAppScope.PUBLIC) @RequestMapping(value = "/latest", method = RequestMethod.GET) List<V1ArticleDto> latest(ClientAppUserAccessToken accessToken,
      @RequestParam(value = "start-article-id", required = false) FlakeId startArticleId); @ApiOperation(value = "[public] List latest articles for the zone", notes = "List latest articles for the zone, 25 articles a page. " + "To retrieve next page, passing last article id of previous page in parameter start-article-id") @RequiredScope(ClientAppScope.PUBLIC) @RequestMapping(value = "/zone/{zone}/latest", method = RequestMethod.GET) List<V1ArticleDto> latestByZone(ClientAppUserAccessToken accessToken,
      @PathVariable("zone") String zone,
      @RequestParam(value = "start-article-id", required = false) FlakeId startArticleId); @ApiOperation(value = "[public] List hot articles for the zone", notes = "List hot articles for the zone, 25 articles a page. " + "To retrieve next page, passing last article id of previous page in parameter start-article-id") @RequiredScope(ClientAppScope.PUBLIC) @RequestMapping(value = "/zone/{zone}/hot", method = RequestMethod.GET) List<V1ArticleDto> hotByZone(ClientAppUserAccessToken accessToken,
      @PathVariable("zone") String zone,
      @RequestParam(value = "start-article-id", required = false) FlakeId startArticleId); @ApiOperation(value = "[public] List submitted articles of the user", notes = "List submitted articles of the user, 25 articles a page. " + "To retrieve next page, passing last article id of previous page in parameter start-article-id") @RequiredScope(ClientAppScope.PUBLIC) @RequestMapping(value = "/user/{username}/submitted", method = RequestMethod.GET) List<V1ArticleDto> submitted(ClientAppUserAccessToken accessToken,
      @PathVariable("username") String username,
      @RequestParam(value = "start-article-id", required = false) FlakeId startArticleId); @ApiOperation(value = "[vote] List voted articles of the user", notes = "List voted articles of the user, 25 articles a page. " + "To retrieve next page, passing last article id of previous page in parameter start-article-id") @RequiredScope(ClientAppScope.VOTE) @RequestMapping(value = "/voted", method = RequestMethod.GET) List<V1ArticleDto> voted(ClientAppUserAccessToken accessToken,
      @RequestParam(value = "start-article-id", required = false) FlakeId startArticleId); @ApiOperation(value = "[article] Create an article with external link", notes = "Create an article with external link in specified zone. Before calling the method, " + "it is recommended check the link already submitted by other users. check API - " + "'GET /zone/{zone}/external-link'") @ResponseStatus(HttpStatus.CREATED) @RequiredScope(ClientAppScope.ARTICLE) @RequestMapping(value = "/external-link", method = RequestMethod.PUT, consumes = { MediaType.APPLICATION_JSON_VALUE }) V1ArticleDto externalLink(ClientAppUserAccessToken token,
      @Valid @RequestBody ExternalLinkEntry entry); @ApiOperation(value = "[public] List articles for external link", notes = "List most 3 external-url-articles for a specific url." + "You are encouraged to show exist articles to end user before creating the article " + "to prevent article duplication in zone.") @RequiredScope(ClientAppScope.PUBLIC) @RequestMapping(value = "/zone/{zone}/external-link", method = RequestMethod.GET) List<V1ArticleDto> externalLink(ClientAppUserAccessToken accessToken,
      @PathVariable(value = "zone") String zone,
      @RequestParam("url") String url); @ApiOperation(value = "[public] check url already submitted in zone", notes = "Check url already submitted as external-url-article in zone") @RequiredScope(ClientAppScope.PUBLIC) @RequestMapping(value = "/zone/{zone}/external-link/exist", method = RequestMethod.GET) boolean isExternalLinkExist(ClientAppUserAccessToken accessToken,
      @PathVariable(value = "zone") String zone,
      @RequestParam("url") String url); @ApiOperation(value = "[public] check the article can be deleted", notes = "Check the article can be deleted by user. Note that there is time-constraint " + "on article deletion. If article is old enough, the method return false.") @RequiredScope(ClientAppScope.PUBLIC) @RequestMapping(value = "/{articleId}/can-delete", method = RequestMethod.GET) boolean canDeleteArticle(ClientAppUserAccessToken accessToken,
      @PathVariable(value = "articleId") FlakeId articleId,
      @RequestParam("username") String username); @ApiOperation(value = "[article] Create an article with content", notes = "Create an article with content in specified zone") @ResponseStatus(HttpStatus.CREATED) @RequiredScope(ClientAppScope.ARTICLE) @RequestMapping(value = "/speak", method = RequestMethod.PUT, consumes = { MediaType.APPLICATION_JSON_VALUE }) V1ArticleDto speak(ClientAppUserAccessToken token, @Valid @RequestBody SpeakEntry entry); @ApiOperation(value = "[article] Delete an article", notes = "Delete an article, return status 200 if success, response as error if sign-in user " + "not allow to delete the article.") @RequiredScope(ClientAppScope.ARTICLE) @RequestMapping(value = "/{articleId}", method = RequestMethod.DELETE, consumes = { MediaType.APPLICATION_JSON_VALUE }) void deleteArticle(ClientAppUserAccessToken token,
      @PathVariable("articleId") FlakeId articleId);  }