Commit e0ac4e7a7d9127a18c6717899c89b585e45d46b6
- Diff rendering mode:
- inline
- side by side
spring-social-core/src/main/java/org/springframework/social/facebook/FacebookPost.java
(28 / 0)
|   | |||
| 67 | 67 | this.privacy = privacy.toMap(); | |
| 68 | 68 | } | |
| 69 | 69 | } | |
| 70 | |||
| 71 | public boolean equals(Object obj) { | ||
| 72 | if (obj == null) | ||
| 73 | return false; | ||
| 74 | |||
| 75 | if (obj instanceof FacebookPost == false) | ||
| 76 | return false; | ||
| 77 | |||
| 78 | FacebookPost other = (FacebookPost) obj; | ||
| 79 | if (eq(message, other.message) == false) | ||
| 80 | return false; | ||
| 81 | if (eq(link, other.link) == false) | ||
| 82 | return false; | ||
| 83 | if (eq(name, other.name) == false) | ||
| 84 | return false; | ||
| 85 | if (eq(caption, other.caption) == false) | ||
| 86 | return false; | ||
| 87 | if (eq(description, other.description) == false) | ||
| 88 | return false; | ||
| 89 | |||
| 90 | return eq(privacy, other.privacy); | ||
| 91 | } | ||
| 92 | |||
| 93 | private static boolean eq(Object fst, Object snd) { | ||
| 94 | if (fst == null) | ||
| 95 | return snd == null; | ||
| 96 | return fst.equals(snd); | ||
| 97 | } | ||
| 70 | 98 | } |
spring-social-core/src/test/java/org/springframework/social/facebook/FacebookTemplateTest.java
(31 / 0)
|   | |||
| 154 | 154 | eq(ACCESS_TOKEN)); | |
| 155 | 155 | } | |
| 156 | 156 | ||
| 157 | @Test | ||
| 158 | public void updateStatus_withPrivacy() { | ||
| 159 | FacebookPost post = new FacebookPost("Hello Facebook!", null, new Privacy(Privacy.Type.NETWORKS_FRIENDS)); | ||
| 160 | |||
| 161 | PostId postId = new PostId(); | ||
| 162 | postId.id = "12345"; | ||
| 163 | ResponseEntity<PostId> response = new ResponseEntity<PostId>(postId, OK); | ||
| 164 | when(restOperations.postForEntity(eq(CONNECTION_URL), eq(post), eq(PostId.class), eq(CURRENT_USER), eq(FEED), | ||
| 165 | eq(ACCESS_TOKEN))).thenReturn(response); | ||
| 166 | |||
| 167 | assertEquals(facebook.updateStatus(post), "12345"); | ||
| 168 | |||
| 169 | verify(restOperations).postForEntity(eq(CONNECTION_URL), eq(post), eq(PostId.class), eq(CURRENT_USER), eq(FEED), | ||
| 170 | eq(ACCESS_TOKEN)); | ||
| 171 | } | ||
| 172 | |||
| 173 | @Test | ||
| 174 | public void addComment() { | ||
| 175 | FacebookPost post = new FacebookPost("Hello Facebook!"); | ||
| 176 | PostId postId = new PostId(); | ||
| 177 | postId.id = "12345"; | ||
| 178 | ResponseEntity<PostId> response = new ResponseEntity<PostId>(postId, OK); | ||
| 179 | when(restOperations.postForEntity(eq(CONNECTION_URL), eq(post), eq(PostId.class), eq("98765"), eq(COMMENTS), | ||
| 180 | eq(ACCESS_TOKEN))).thenReturn(response); | ||
| 181 | |||
| 182 | assertEquals(facebook.addComment("98765", "Hello Facebook!"), "12345"); | ||
| 183 | |||
| 184 | verify(restOperations).postForEntity(eq(CONNECTION_URL), eq(post), eq(PostId.class), eq("98765"), eq(COMMENTS), | ||
| 185 | eq(ACCESS_TOKEN)); | ||
| 186 | } | ||
| 187 | |||
| 157 | 188 | private FacebookProfile setupRestOperationsForGettingProfile() { | |
| 158 | 189 | FacebookProfile fbProfile = new FacebookProfile(); | |
| 159 | 190 | fbProfile.firstName = "Craig"; |
Comments
Excellent and decent post. I have found much informative, what I was exactly searching for. Thanks for such post and please keep it up.
Add your comment
Please log in to comment



Add a new comment:
Login or create an account to post a comment