GroupsResource extends Resource { @Experimental public CallSpec<List<Group>, HttpError> findGroupByKeyword(String keywords) { return Resource.<List<Group>, HttpError>newGetSpec(api, "/v1/groups/find") .responseAs(list(single(Group.class, "group"), "groups", "items")) .queryParam("keywords", keywords) .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 findGroupsByKeyword() throws Exception { server.enqueue(new MockResponse().setBody(file("groups/search_result.json"))); Response<List<Group>, HttpError> response = resource.findGroupByKeyword("android").execute(); assertThat(response.body().size()).isEqualTo(10); Group firstGroup = response.body().get(0); assertThat(firstGroup.closed()).isEqualTo(false); assertThat(firstGroup.name()).isEqualTo("Android Community"); }