GroupTemplate extends AbstractTemplate implements GroupOperations { public GroupPosts getPosts(Integer groupId) { return restOperations.getForObject(GROUP_POSTS_URL, GroupPosts.class, groupId); } GroupTemplate(RestOperations restOperations); Group getGroupDetails(Integer id); GroupMemberships getGroupMemberships(); GroupMemberships getGroupMemberships(int start, int count); GroupSuggestions getGroupSuggestions(); GroupSuggestions getGroupSuggestions(int start, int count); GroupPosts getPosts(Integer groupId); GroupPosts getPosts(Integer groupId, int start, int count); PostComments getPostComments(String postId); PostComments getPostComments(String postId, int start, int count); void joinGroup(Integer groupId); void leaveGroup(Integer groupId); URI createPost(Integer groupId, String title, String summary); void likePost(String postId); void unlikePost(String postId); void followPost(String postId); void unfollowPost(String postId); void flagPostAsJob(String postId); void flagPostAsPromotion(String postId); void deleteOrFlagPostAsInappropriate(String postId); void addCommentToPost(String postId, String text); void deleteOrFlagCommentAsInappropriate(String commentId); void deleteGroupSuggestion(Integer groupId); static final String BASE_URL; static final String BASE_PEOPLE_URL; static final String GROUP_BASE_URL; static final String GROUP_POSTS_BASE_URL; static final String GROUP_DETAILS_URL; static final String GROUP_JOIN_LEAVE_URL; static final String GROUP_MEMBERSHIPS_URL; static final String GROUP_SUGGESTIONS_URL; static final String GROUP_SUGGESTION_DELETE_URL; static final String GROUP_POSTS_URL; static final String GROUP_POST_COMMENTS_URL; static final String GROUP_CREATE_POST_URL; static final String GROUP_POST_LIKE_URL; static final String GROUP_POST_FOLLOW_URL; static final String GROUP_POST_FLAG_URL; static final String GROUP_POST_DELETE_URL; static final String GROUP_POST_ADD_COMMENT_URL; static final String GROUP_POST_DELETE_COMMENT_URL; }
@Test public void getPosts() { mockServer.expect(requestTo((GroupTemplate.GROUP_POSTS_URL + "&oauth2_access_token=ACCESS_TOKEN").replaceFirst("\\{group-id\\}", "46964"))).andExpect(method(GET)) .andRespond(withSuccess(new ClassPathResource("group_posts.json", getClass()), MediaType.APPLICATION_JSON)); GroupPosts posts = linkedIn.groupOperations().getPosts(46964); assertEquals(10, posts.getCount()); assertEquals(0, posts.getStart()); assertEquals(199, posts.getTotal()); assertEquals(10, posts.getPosts().size()); Post p = posts.getPosts().get(0); assertEquals(new Date(1326384086809l), p.getCreationTimestamp()); assertProfile(p.getCreator(), null, "Programmer analyst trainee at Cognizant Technology Solutions", "Sathish", "K.", null, null); assertEquals(2, p.getLikes().size()); assertProfile(p.getLikes().get(0), "i21Fzhxxxx", "Managing Director", "Tom", "Smith", null, null); assertEquals("g-35936-S-88778673", p.getId()); assertEquals(false, p.getRelationToViewer().isFollowing()); assertEquals(false, p.getRelationToViewer().isLiked()); assertEquals(7, p.getRelationToViewer().getAvailableActions().size()); assertEquals(PostAvailableAction.ADD_COMMENT, p.getRelationToViewer().getAvailableActions().get(0)); assertEquals(PostAvailableAction.CATEGORIZE_AS_JOB, p.getRelationToViewer().getAvailableActions().get(1)); assertEquals("", p.getSummary()); assertEquals("how to integate spring batch admin console into existing spring batch process application /web application.", p.getTitle()); p = posts.getPosts().get(1); assertEquals(new Date(1326376683000l), p.getCreationTimestamp()); assertProfile(p.getCreator(), null, "Contributor at Interns Over 40", "Namita", "M.", null, null); assertEquals(0, p.getLikes().size()); assertEquals("g-35936-S-88778673", p.getId()); assertEquals(false, p.getRelationToViewer().isFollowing()); assertEquals(false, p.getRelationToViewer().isLiked()); assertEquals(7, p.getRelationToViewer().getAvailableActions().size()); assertEquals(PostAvailableAction.ADD_COMMENT, p.getRelationToViewer().getAvailableActions().get(0)); assertEquals(PostAvailableAction.CATEGORIZE_AS_JOB, p.getRelationToViewer().getAvailableActions().get(1)); assertEquals("We keep doing it the same way. Looking for jobs where everyone else is looking . How stupid can I be. Thanks Peggy. Join our Insider updates: https: assertEquals("\"How To Find Jobs in ANY Economy\" For Older Skilled Workers.", p.getTitle()); assertEquals("internsover40beta.blogspot.com", p.getAttachment().getContentDomain()); assertEquals("https: assertEquals("https: assertEquals("We keep doing it the same way. Looking for jobs where everyone else is looking . How stupid can I be. Thanks Peggy. Join our Insider updates: https: assertEquals("\"How To Find Jobs in ANY Economy\" For Older Skilled Workers.", p.getAttachment().getTitle()); }