@Test public void updateContent() throws Exception { when(articleService.updateDebateContent(eq(FlakeId.fromString("foo3000")), isA(ClientAppUserAccessToken.class), eq("ruby is good"))).thenReturn("ruby is best"); String body = q("{'content':'ruby is good'}"); oauthPerform(user, post("/v1/debate/foo3000/content").content(body)) .andExpect(status().isOk()).andExpect(jsonPath("$.data", is("ruby is best"))); }
@ApiOperation(value = "[debate] Edit content of a debate", notes = "Edit content of a debate that user created.") @RequiredScope(ClientAppScope.DEBATE) @RequestMapping(value = "/{debateId}/content", method = RequestMethod.POST, consumes = { MediaType.APPLICATION_JSON_VALUE }) public String updateDebateContent(ClientAppUserAccessToken accessToken, @PathVariable("debateId") FlakeId debateId, @Valid @RequestBody UpdateDebateEntry entry) { return articleService.updateDebateContent(debateId, accessToken, entry.content.trim()); }
V1DebateResource { @ApiOperation(value = "[debate] Edit content of a debate", notes = "Edit content of a debate that user created.") @RequiredScope(ClientAppScope.DEBATE) @RequestMapping(value = "/{debateId}/content", method = RequestMethod.POST, consumes = { MediaType.APPLICATION_JSON_VALUE }) public String updateDebateContent(ClientAppUserAccessToken accessToken, @PathVariable("debateId") FlakeId debateId, @Valid @RequestBody UpdateDebateEntry entry) { return articleService.updateDebateContent(debateId, accessToken, entry.content.trim()); } }
V1DebateResource { @ApiOperation(value = "[debate] Edit content of a debate", notes = "Edit content of a debate that user created.") @RequiredScope(ClientAppScope.DEBATE) @RequestMapping(value = "/{debateId}/content", method = RequestMethod.POST, consumes = { MediaType.APPLICATION_JSON_VALUE }) public String updateDebateContent(ClientAppUserAccessToken accessToken, @PathVariable("debateId") FlakeId debateId, @Valid @RequestBody UpdateDebateEntry entry) { return articleService.updateDebateContent(debateId, accessToken, entry.content.trim()); }  }
V1DebateResource { @ApiOperation(value = "[debate] Edit content of a debate", notes = "Edit content of a debate that user created.") @RequiredScope(ClientAppScope.DEBATE) @RequestMapping(value = "/{debateId}/content", method = RequestMethod.POST, consumes = { MediaType.APPLICATION_JSON_VALUE }) public String updateDebateContent(ClientAppUserAccessToken accessToken, @PathVariable("debateId") FlakeId debateId, @Valid @RequestBody UpdateDebateEntry entry) { return articleService.updateDebateContent(debateId, accessToken, entry.content.trim()); }  @ApiOperation(value = "[public] Get a debate", notes = "Get a debate by debateId") @RequiredScope(ClientAppScope.PUBLIC) @RequestMapping(value = "/{debateId}", method = RequestMethod.GET) V1DebateDto debate(ClientAppUserAccessToken accessToken,
      @PathVariable("debateId") FlakeId debateId); @ApiOperation(value = "[public] Load all debates for an article", notes = "Load all debates (in tree structure) for an article. Note that result may be a big json.") @RequiredScope(ClientAppScope.PUBLIC) @RequestMapping(value = "/article/{articleId}/tree", method = RequestMethod.GET) V1DebateNodeDto debateTreeOfArticle(ClientAppUserAccessToken accessToken,
      @PathVariable("articleId") FlakeId articleId); @ApiOperation(value = "[public] List latest debates of all zones", notes = "List latest debates of all zones, 25 debates a page. " + "To retrieve next page, passing last debate id of previous page in parameter start-debate-id.") @RequiredScope(ClientAppScope.PUBLIC) @RequestMapping(value = "/latest", method = RequestMethod.GET) List<V1DebateDto> latest(ClientAppUserAccessToken accessToken,
      @RequestParam(value = "start-debate-id", required = false) FlakeId startDebateId); @ApiOperation(value = "[public] List latest debates for a zone", notes = "List latest debates for a zone, 25 debates a page. " + "To retrieve next page, passing last debate id of previous page in parameter start-debate-id") @RequiredScope(ClientAppScope.PUBLIC) @RequestMapping(value = "/zone/{zone}/latest", method = RequestMethod.GET) List<V1DebateDto> latestByZone(ClientAppUserAccessToken accessToken,
      @PathVariable("zone") String zone,
      @RequestParam(value = "start-debate-id", required = false) FlakeId startDebateId); @ApiOperation(value = "[debate] List submitted debates of the user", notes = "List submitted debates of the user, 25 debates a page. " + "To retrieve next page, passing last debate id of previous page in parameter start-debate-id") @RequiredScope(ClientAppScope.DEBATE) @RequestMapping(value = "/user/{username}/submitted", method = RequestMethod.GET) List<V1DebateDto> userSubmitted(ClientAppUserAccessToken accessToken,
      @PathVariable("username") String username,
      @RequestParam(value = "start-debate-id", required = false) FlakeId startDebateId); @ApiOperation(value = "[debate] Create a debate in the article", notes = "Create a debate in the article. If reply to a debate, " + "it should be specified in the field: parentDebateId.") @ResponseStatus(HttpStatus.CREATED) @RequiredScope(ClientAppScope.DEBATE) @RequestMapping(value = "", method = RequestMethod.PUT, consumes = { MediaType.APPLICATION_JSON_VALUE }) V1DebateDto create(ClientAppUserAccessToken accessToken,
      @Valid @RequestBody CreateDebateEntry entry); @ApiOperation(value = "[debate] Edit content of a debate", notes = "Edit content of a debate that user created.") @RequiredScope(ClientAppScope.DEBATE) @RequestMapping(value = "/{debateId}/content", method = RequestMethod.POST, consumes = { MediaType.APPLICATION_JSON_VALUE }) String updateDebateContent(ClientAppUserAccessToken accessToken,
      @PathVariable("debateId") FlakeId debateId,
      @Valid @RequestBody UpdateDebateEntry entry); }
V1DebateResource { @ApiOperation(value = "[debate] Edit content of a debate", notes = "Edit content of a debate that user created.") @RequiredScope(ClientAppScope.DEBATE) @RequestMapping(value = "/{debateId}/content", method = RequestMethod.POST, consumes = { MediaType.APPLICATION_JSON_VALUE }) public String updateDebateContent(ClientAppUserAccessToken accessToken, @PathVariable("debateId") FlakeId debateId, @Valid @RequestBody UpdateDebateEntry entry) { return articleService.updateDebateContent(debateId, accessToken, entry.content.trim()); }  @ApiOperation(value = "[public] Get a debate", notes = "Get a debate by debateId") @RequiredScope(ClientAppScope.PUBLIC) @RequestMapping(value = "/{debateId}", method = RequestMethod.GET) V1DebateDto debate(ClientAppUserAccessToken accessToken,
      @PathVariable("debateId") FlakeId debateId); @ApiOperation(value = "[public] Load all debates for an article", notes = "Load all debates (in tree structure) for an article. Note that result may be a big json.") @RequiredScope(ClientAppScope.PUBLIC) @RequestMapping(value = "/article/{articleId}/tree", method = RequestMethod.GET) V1DebateNodeDto debateTreeOfArticle(ClientAppUserAccessToken accessToken,
      @PathVariable("articleId") FlakeId articleId); @ApiOperation(value = "[public] List latest debates of all zones", notes = "List latest debates of all zones, 25 debates a page. " + "To retrieve next page, passing last debate id of previous page in parameter start-debate-id.") @RequiredScope(ClientAppScope.PUBLIC) @RequestMapping(value = "/latest", method = RequestMethod.GET) List<V1DebateDto> latest(ClientAppUserAccessToken accessToken,
      @RequestParam(value = "start-debate-id", required = false) FlakeId startDebateId); @ApiOperation(value = "[public] List latest debates for a zone", notes = "List latest debates for a zone, 25 debates a page. " + "To retrieve next page, passing last debate id of previous page in parameter start-debate-id") @RequiredScope(ClientAppScope.PUBLIC) @RequestMapping(value = "/zone/{zone}/latest", method = RequestMethod.GET) List<V1DebateDto> latestByZone(ClientAppUserAccessToken accessToken,
      @PathVariable("zone") String zone,
      @RequestParam(value = "start-debate-id", required = false) FlakeId startDebateId); @ApiOperation(value = "[debate] List submitted debates of the user", notes = "List submitted debates of the user, 25 debates a page. " + "To retrieve next page, passing last debate id of previous page in parameter start-debate-id") @RequiredScope(ClientAppScope.DEBATE) @RequestMapping(value = "/user/{username}/submitted", method = RequestMethod.GET) List<V1DebateDto> userSubmitted(ClientAppUserAccessToken accessToken,
      @PathVariable("username") String username,
      @RequestParam(value = "start-debate-id", required = false) FlakeId startDebateId); @ApiOperation(value = "[debate] Create a debate in the article", notes = "Create a debate in the article. If reply to a debate, " + "it should be specified in the field: parentDebateId.") @ResponseStatus(HttpStatus.CREATED) @RequiredScope(ClientAppScope.DEBATE) @RequestMapping(value = "", method = RequestMethod.PUT, consumes = { MediaType.APPLICATION_JSON_VALUE }) V1DebateDto create(ClientAppUserAccessToken accessToken,
      @Valid @RequestBody CreateDebateEntry entry); @ApiOperation(value = "[debate] Edit content of a debate", notes = "Edit content of a debate that user created.") @RequiredScope(ClientAppScope.DEBATE) @RequestMapping(value = "/{debateId}/content", method = RequestMethod.POST, consumes = { MediaType.APPLICATION_JSON_VALUE }) String updateDebateContent(ClientAppUserAccessToken accessToken,
      @PathVariable("debateId") FlakeId debateId,
      @Valid @RequestBody UpdateDebateEntry entry);  }