GroupsResource extends Resource { public CallSpec<Post, HttpError> createPost(String title, String content, String forumId) { return Resource.<Post, HttpError>newPostSpec(api, "/v1/groups/forums/{forum_id}/posts", false) .responseAs(single(Post.class, "post")) .pathParam("forum_id", forumId) .queryParam("title", title) .queryParam("content", content) .build(); } GroupsResource(XingApi api); CallSpec<List<Group>, HttpError> getUsersGroups(String userId); CallSpec<List<Group>, HttpError> getOwnGroups(); @Experimental CallSpec<List<Group>, HttpError> findGroupByKeyword(String keywords); CallSpec<List<Forum>, HttpError> getForumsOfGroup(String groupId); CallSpec<List<Post>, HttpError> getPostsOfForum(String forumId); CallSpec<Post, HttpError> getPostInGroup(String postId); CallSpec<List<Post>, HttpError> getAllPostsOfGroup(String groupId); CallSpec<List<XingUser>, HttpError> getLikersOfPost(String postId); CallSpec<Void, HttpError> likePost(String postId); CallSpec<Void, HttpError> unlikePost(String postId); CallSpec<List<Comment>, HttpError> getCommentsOfPost(String postId); CallSpec<Void, HttpError> addCommentToPost(String content, String postId); CallSpec<Void, HttpError> deleteCommentOfPost(String commentId); CallSpec<List<XingUser>, HttpError> getLikersOfComment(String commentId); CallSpec<Void, HttpError> likeComment(String commentId); CallSpec<Void, HttpError> unlikeComment(String commentId); CallSpec<Void, HttpError> markAllPostsAsRead(String groupId); CallSpec<Membership, HttpError> joinGroup(String groupId); CallSpec<Post, HttpError> createPost(String title, String content, String forumId); CallSpec<Void, HttpError> deletePost(String postId); CallSpec<Void, HttpError> leaveGroup(String groupId); CallSpec<MediaPreview, HttpError> createMediaPreview(String url);  }
@Test public void createPost() throws Exception { server.enqueue(new MockResponse().setBody(file("groups/create_post.json"))); Response<Post, HttpError> response = resource.createPost("My funny Post", "A funny rabbit goes to a hole", "213").execute(); assertThat(response.body()).isNotNull(); assertThat(response.body().title()).isEqualTo("My funny Post"); assertThat(response.body().author().displayName()).isEqualTo("Vladimir"); }