GroupsResource extends Resource { public CallSpec<MediaPreview, HttpError> createMediaPreview(String url) { return Resource.<MediaPreview, HttpError>newPostSpec(api, "/v1/groups/media_previews", false) .responseAs(single(MediaPreview.class, "media_preview")) .queryParam("url", url) .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 createMediaPreview() throws Exception { server.enqueue(new MockResponse().setBody(file("groups/media_preview.json"))); Response<MediaPreview, HttpError> response = resource.createMediaPreview("https: assertThat(response.body()).isNotNull(); assertThat(response.body().title()).isEqualTo("XING Developer"); assertThat(response.body().description()) .isEqualTo("The XING API helps you connect your app with over 14 million users."); assertThat(response.body().imageUrl()).isNullOrEmpty(); }