Permalink
Browse files

Merge pull request #56 from habuma/master

Cleaned out some deprecated method usage
  • Loading branch information...
2 parents 31ea7e7 + 39f4d6a commit 3e0b7422df08d1681951a13e0f34836d3d11d340 @habuma habuma committed Sep 12, 2012
@@ -113,7 +113,7 @@ public void getComment_postSeptember2012BreakingChanges() {
public void addComment() {
mockServer.expect(requestTo("https://graph.facebook.com/123456/comments"))
.andExpect(method(POST))
- .andExpect(body("message=Cool+beans"))
+ .andExpect(content().string("message=Cool+beans"))
.andExpect(header("Authorization", "OAuth someAccessToken"))
.andRespond(withSuccess("{\"id\":\"123456_543210\"}", MediaType.APPLICATION_JSON));
assertEquals("123456_543210", facebook.commentOperations().addComment("123456", "Cool beans"));
@@ -128,7 +128,7 @@ public void addComment_unauthorized() {
public void deleteComment() {
mockServer.expect(requestTo("https://graph.facebook.com/1533260333_122829644452184_587062"))
.andExpect(method(POST))
- .andExpect(body("method=delete"))
+ .andExpect(content().string("method=delete"))
.andExpect(header("Authorization", "OAuth someAccessToken"))
.andRespond(withSuccess("{}", MediaType.APPLICATION_JSON));
facebook.commentOperations().deleteComment("1533260333_122829644452184_587062");
@@ -45,7 +45,7 @@
private static final String NOT_AUTHORIZED_REVOKATION = "The authorization has been revoked. Reason: Error validating access token: 123456789 has not authorized application 987654321";
@Test
- public void insufficientPrivileges() {
+ public void insufficientPrivileges() {
try {
mockServer.expect(requestTo("https://graph.facebook.com/193482154020832/declined"))
.andExpect(method(POST))
@@ -107,7 +107,7 @@ public void notTheOwner() {
mockServer.expect(requestTo("https://graph.facebook.com/1234567890"))
.andExpect(method(POST))
.andExpect(header("Authorization", "OAuth someAccessToken"))
- .andExpect(body("method=delete"))
+ .andExpect(content().string("method=delete"))
.andRespond(withServerError().body(jsonResource("testdata/error-not-the-owner")).contentType(MediaType.APPLICATION_JSON));
facebook.friendOperations().deleteFriendList("1234567890");
fail();
@@ -264,7 +264,7 @@ public void appDoesNotHaveCapability() {
public void appMustBeOnWhitelist() {
mockServer.expect(requestTo("https://graph.facebook.com/123456/likes"))
.andExpect(method(POST))
- .andExpect(body("method=delete"))
+ .andExpect(content().string("method=delete"))
.andExpect(header("Authorization", "OAuth someAccessToken"))
.andRespond(withBadRequest().body(jsonResource("testdata/error-whitelist")).contentType(MediaType.APPLICATION_JSON));
facebook.likeOperations().unlike("123456");
@@ -302,7 +302,7 @@ public void falseResponse() {
public void rateLimit() {
mockServer.expect(requestTo("https://graph.facebook.com/me/feed"))
.andExpect(method(POST))
- .andExpect(body("message=Test+Message"))
+ .andExpect(content().string("message=Test+Message"))
.andExpect(header("Authorization", "OAuth someAccessToken"))
.andRespond(withBadRequest().body(jsonResource("testdata/error-rate-limit")).contentType(MediaType.APPLICATION_JSON));
facebook.feedOperations().updateStatus("Test Message");
@@ -315,7 +315,7 @@ public void duplicateOrSimilarPostToTwitter() {
responseHeaders.setContentType(MediaType.APPLICATION_JSON);
mockServer.expect(requestTo("https://graph.facebook.com/me/feed"))
.andExpect(method(POST))
- .andExpect(body("message=Test+Message"))
+ .andExpect(content().string("message=Test+Message"))
.andExpect(header("Authorization", "OAuth someAccessToken"))
.andRespond(withBadRequest().body(jsonResource("testdata/error-duplicate-to-twitter")).contentType(MediaType.APPLICATION_JSON));
facebook.feedOperations().updateStatus("Test Message");
@@ -120,7 +120,7 @@ public void getEvent_withLocationAndDescription() {
public void createEvent() {
mockServer.expect(requestTo("https://graph.facebook.com/me/events"))
.andExpect(method(POST))
- .andExpect(body("name=Test+Event&start_time=2011-04-01T15%3A30%3A00&end_time=2011-04-01T18%3A30%3A00"))
+ .andExpect(content().string("name=Test+Event&start_time=2011-04-01T15%3A30%3A00&end_time=2011-04-01T18%3A30%3A00"))
.andExpect(header("Authorization", "OAuth someAccessToken"))
.andRespond(withSuccess("{\"id\":\"193482145020832\"}", MediaType.APPLICATION_JSON));
String eventId = facebook.eventOperations().createEvent("Test Event", "2011-04-01T15:30:00", "2011-04-01T18:30:00");
@@ -136,7 +136,7 @@ public void createEvent_unauthorized() {
public void deleteEvent() {
mockServer.expect(requestTo("https://graph.facebook.com/123456789"))
.andExpect(method(POST))
- .andExpect(body("method=delete"))
+ .andExpect(content().string("method=delete"))
.andRespond(withSuccess("", MediaType.APPLICATION_JSON));
facebook.eventOperations().deleteEvent("123456789");
mockServer.verify();
@@ -419,7 +419,7 @@ public void updateStatus() throws Exception {
mockServer.expect(requestTo("https://graph.facebook.com/me/feed"))
.andExpect(method(POST))
.andExpect(header("Authorization", "OAuth someAccessToken"))
- .andExpect(body(requestBody))
+ .andExpect(content().string(requestBody))
.andRespond(withSuccess("{\"id\":\"123456_78901234\"}", MediaType.APPLICATION_JSON));
assertEquals("123456_78901234", facebook.feedOperations().updateStatus("Hello Facebook World"));
mockServer.verify();
@@ -435,7 +435,7 @@ public void updateStatus_duplicate() {
mockServer.expect(requestTo("https://graph.facebook.com/me/feed"))
.andExpect(method(POST))
.andExpect(header("Authorization", "OAuth someAccessToken"))
- .andExpect(body("message=Duplicate"))
+ .andExpect(content().string("message=Duplicate"))
.andRespond(withBadRequest().body(jsonResource("testdata/error-duplicate-status")).contentType(MediaType.APPLICATION_JSON));
facebook.feedOperations().updateStatus("Duplicate");
}
@@ -446,7 +446,7 @@ public void post_message() throws Exception {
mockServer.expect(requestTo("https://graph.facebook.com/123456789/feed"))
.andExpect(method(POST))
.andExpect(header("Authorization", "OAuth someAccessToken"))
- .andExpect(body(requestBody))
+ .andExpect(content().string(requestBody))
.andRespond(withSuccess("{\"id\":\"123456_78901234\"}", MediaType.APPLICATION_JSON));
assertEquals("123456_78901234", facebook.feedOperations().post("123456789", "Hello Facebook World"));
mockServer.verify();
@@ -462,7 +462,7 @@ public void post_link() throws Exception {
String requestBody = "link=someLink&name=some+name&caption=some+caption&description=some+description&message=Hello+Facebook+World";
mockServer.expect(requestTo("https://graph.facebook.com/me/feed")).andExpect(method(POST))
.andExpect(header("Authorization", "OAuth someAccessToken"))
- .andExpect(body(requestBody))
+ .andExpect(content().string(requestBody))
.andRespond(withSuccess("{\"id\":\"123456_78901234\"}", MediaType.APPLICATION_JSON));
FacebookLink link = new FacebookLink("someLink", "some name", "some caption", "some description");
assertEquals("123456_78901234", facebook.feedOperations().postLink("Hello Facebook World", link));
@@ -480,7 +480,7 @@ public void post_link_toAnotherFeed() throws Exception {
String requestBody = "link=someLink&name=some+name&caption=some+caption&description=some+description&message=Hello+Facebook+World";
mockServer.expect(requestTo("https://graph.facebook.com/123456789/feed")).andExpect(method(POST))
.andExpect(header("Authorization", "OAuth someAccessToken"))
- .andExpect(body(requestBody))
+ .andExpect(content().string(requestBody))
.andRespond(withSuccess("{\"id\":\"123456_78901234\"}", MediaType.APPLICATION_JSON));
FacebookLink link = new FacebookLink("someLink", "some name", "some caption", "some description");
assertEquals("123456_78901234", facebook.feedOperations().postLink("123456789", "Hello Facebook World", link));
@@ -498,7 +498,7 @@ public void deleteFeedEntry() {
String requestBody = "method=delete";
mockServer.expect(requestTo("https://graph.facebook.com/123456_78901234"))
.andExpect(method(POST))
- .andExpect(header("Authorization", "OAuth someAccessToken")).andExpect(body(requestBody))
+ .andExpect(header("Authorization", "OAuth someAccessToken")).andExpect(content().string(requestBody))
.andRespond(withSuccess("{}", MediaType.APPLICATION_JSON));
facebook.feedOperations().deletePost("123456_78901234");
mockServer.verify();
@@ -679,6 +679,7 @@ private void assertFeedEntries(List<Post> feed) {
assertEquals("Spring Social Showcase", feed.get(2).getApplication().getName());
}
+ @SuppressWarnings("deprecation")
private void assertLinks(List<LinkPost> feed) {
assertEquals(2, feed.size());
assertEquals(PostType.LINK, feed.get(0).getType());
@@ -95,7 +95,7 @@ public void createFriendList() {
mockServer.expect(requestTo("https://graph.facebook.com/me/friendlists"))
.andExpect(method(POST))
.andExpect(header("Authorization", "OAuth someAccessToken"))
- .andExpect(body("name=My+List"))
+ .andExpect(content().string("name=My+List"))
.andRespond(withSuccess(jsonResource("testdata/create-friend-list"), MediaType.APPLICATION_JSON));
String friendListId = facebook.friendOperations().createFriendList("My List");
assertEquals("11929590579", friendListId);
@@ -111,7 +111,7 @@ public void createFriendList_unauthorized() {
public void deleteFriendList() {
mockServer.expect(requestTo("https://graph.facebook.com/123456"))
.andExpect(method(POST))
- .andExpect(body("method=delete"))
+ .andExpect(content().string("method=delete"))
.andExpect(header("Authorization", "OAuth someAccessToken"))
.andRespond(withSuccess("", MediaType.APPLICATION_JSON));
facebook.friendOperations().deleteFriendList("123456");
@@ -61,7 +61,7 @@ public void like_unauthorized() {
public void unlike() {
mockServer.expect(requestTo("https://graph.facebook.com/123456/likes"))
.andExpect(method(POST))
- .andExpect(body("method=delete"))
+ .andExpect(content().string("method=delete"))
.andExpect(header("Authorization", "OAuth someAccessToken"))
.andRespond(withSuccess("{}", MediaType.APPLICATION_JSON));
facebook.likeOperations().unlike("123456");
@@ -69,7 +69,7 @@ public void like_unauthorized() {
public void unlike() {
mockServer.expect(requestTo("https://graph.facebook.com/123456/likes"))
.andExpect(method(POST))
- .andExpect(body("method=delete"))
+ .andExpect(content().string("method=delete"))
.andExpect(header("Authorization", "OAuth someAccessToken"))
.andRespond(withSuccess("{}", MediaType.APPLICATION_JSON));
facebook.likeOperations().unlike("123456");
@@ -342,6 +342,7 @@ public String getFilename() throws IllegalStateException {
return video;
}
+ @SuppressWarnings("deprecation")
private void assertPhotos(List<Photo> photos) {
assertEquals(2, photos.size());
assertSinglePhoto(photos.get(1));
@@ -370,6 +371,7 @@ private void assertPhotos(List<Photo> photos) {
assertEquals(toDate("2011-03-24T21:37:43+0000"), photos.get(0).getUpdatedTime());
}
+ @SuppressWarnings("deprecation")
private void assertSingleVideo(Video video) {
assertEquals("161500020572907", video.getId());
assertEquals("100001387295207", video.getFrom().getId());
@@ -389,6 +391,7 @@ private void assertSingleVideo(Video video) {
assertEquals(toDate("2011-03-29T20:25:55+0000"), video.getUpdatedTime());
}
+ @SuppressWarnings("deprecation")
private void assertSinglePhoto(Photo photo) {
assertEquals("10150447271355581", photo.getId());
assertEquals("738140579", photo.getFrom().getId());
@@ -465,6 +468,7 @@ private void assertSingleAlbum(Album album) {
assertEquals(toDate("2011-03-24T22:00:12+0000"), album.getUpdatedTime());
}
+ @SuppressWarnings("deprecation")
private void assertVideos(List<Video> videos) {
assertEquals(2, videos.size());
Video video = videos.get(0);
@@ -39,7 +39,7 @@ protected FacebookTemplate createFacebookTemplate() {
public void publishAction() {
mockServer.expect(requestTo("https://graph.facebook.com/me/socialshowcase:ding"))
.andExpect(method(POST))
- .andExpect(body("thing=http%3A%2F%2Fwww.springsource.org%2Fspringsocial"))
+ .andExpect(content().string("thing=http%3A%2F%2Fwww.springsource.org%2Fspringsocial"))
.andExpect(header("Authorization", "OAuth someAccessToken"))
.andRespond(withSuccess(jsonResource("testdata/id-only"), MediaType.APPLICATION_JSON));
assertEquals("297875170268724", facebook.openGraphOperations().publishAction("ding", "thing", "http://www.springsource.org/springsocial"));
@@ -144,7 +144,7 @@ public void post_message() throws Exception {
mockServer.expect(requestTo("https://graph.facebook.com/987654321/feed"))
.andExpect(method(POST))
.andExpect(header("Authorization", "OAuth someAccessToken"))
- .andExpect(body(requestBody))
+ .andExpect(content().string(requestBody))
.andRespond(withSuccess("{\"id\":\"123456_78901234\"}", MediaType.APPLICATION_JSON));
assertEquals("123456_78901234", facebook.pageOperations().post("987654321", "Hello Facebook World"));
mockServer.verify();
@@ -167,7 +167,7 @@ public void postLink() throws Exception {
String requestBody = "link=someLink&name=some+name&caption=some+caption&description=some+description&message=Hello+Facebook+World&access_token=pageAccessToken";
mockServer.expect(requestTo("https://graph.facebook.com/987654321/feed")).andExpect(method(POST))
.andExpect(header("Authorization", "OAuth someAccessToken"))
- .andExpect(body(requestBody))
+ .andExpect(content().string(requestBody))
.andRespond(withSuccess("{\"id\":\"123456_78901234\"}", MediaType.APPLICATION_JSON));
FacebookLink link = new FacebookLink("someLink", "some name", "some caption", "some description");
assertEquals("123456_78901234", facebook.pageOperations().post("987654321", "Hello Facebook World", link));
@@ -98,7 +98,7 @@ public void checkin() {
mockServer.expect(requestTo("https://graph.facebook.com/me/checkins"))
.andExpect(method(POST))
.andExpect(header("Authorization", "OAuth someAccessToken"))
- .andExpect(body("place=123456789&coordinates=%7B%22latitude%22%3A%2232.943860253093%22%2C%22longitude%22%3A%22-96.648515652755%22%7D"))
+ .andExpect(content().string("place=123456789&coordinates=%7B%22latitude%22%3A%2232.943860253093%22%2C%22longitude%22%3A%22-96.648515652755%22%7D"))
.andRespond(withSuccess("{\"id\":\"10150431253050580\"}", MediaType.APPLICATION_JSON));
assertEquals("10150431253050580", facebook.placesOperations().checkin("123456789", 32.943860253093, -96.648515652755));
}
@@ -113,7 +113,7 @@ public void checkin_withMessage() {
mockServer.expect(requestTo("https://graph.facebook.com/me/checkins"))
.andExpect(method(POST))
.andExpect(header("Authorization", "OAuth someAccessToken"))
- .andExpect(body("place=123456789&coordinates=%7B%22latitude%22%3A%2232.943860253093%22%2C%22longitude%22%3A%22-96.648515652755%22%7D&message=My+favorite+place"))
+ .andExpect(content().string("place=123456789&coordinates=%7B%22latitude%22%3A%2232.943860253093%22%2C%22longitude%22%3A%22-96.648515652755%22%7D&message=My+favorite+place"))
.andRespond(withSuccess("{\"id\":\"10150431253050580\"}", MediaType.APPLICATION_JSON));
assertEquals("10150431253050580", facebook.placesOperations().checkin("123456789", 32.943860253093, -96.648515652755, "My favorite place"));
}
@@ -128,7 +128,7 @@ public void checkin_withMessageAndTags() {
mockServer.expect(requestTo("https://graph.facebook.com/me/checkins"))
.andExpect(method(POST))
.andExpect(header("Authorization", "OAuth someAccessToken"))
- .andExpect(body("place=123456789&coordinates=%7B%22latitude%22%3A%2232.943860253093%22%2C%22longitude%22%3A%22-96.648515652755%22%7D&message=My+favorite+place&tags=24680%2C13579"))
+ .andExpect(content().string("place=123456789&coordinates=%7B%22latitude%22%3A%2232.943860253093%22%2C%22longitude%22%3A%22-96.648515652755%22%7D&message=My+favorite+place&tags=24680%2C13579"))
.andRespond(withSuccess("{\"id\":\"10150431253050580\"}", MediaType.APPLICATION_JSON));
assertEquals("10150431253050580",
facebook.placesOperations().checkin("123456789", 32.943860253093, -96.648515652755, "My favorite place", "24680", "13579"));
@@ -35,7 +35,7 @@ public void askQuestion() {
String requestBody = "question=What+is+your+favorite+color%3F";
mockServer.expect(requestTo("https://graph.facebook.com/me/questions"))
.andExpect(method(POST))
- .andExpect(body(requestBody))
+ .andExpect(content().string(requestBody))
.andExpect(header("Authorization", "OAuth someAccessToken"))
.andRespond(withSuccess(jsonResource("testdata/id-only"), MediaType.APPLICATION_JSON));
assertEquals("297875170268724", facebook.questionOperations().askQuestion("What is your favorite color?"));
@@ -46,7 +46,7 @@ public void addOption() {
String requestBody = "option=Dallas+Cowboys";
mockServer.expect(requestTo("https://graph.facebook.com/297875170268725/options"))
.andExpect(method(POST))
- .andExpect(body(requestBody))
+ .andExpect(content().string(requestBody))
.andExpect(header("Authorization", "OAuth someAccessToken"))
.andRespond(withSuccess(jsonResource("testdata/id-only"), MediaType.APPLICATION_JSON));
assertEquals("297875170268724", facebook.questionOperations().addOption("297875170268725", "Dallas Cowboys"));
@@ -100,7 +100,7 @@ public void getQuestions_forSpecificUser() {
public void deleteQuestion() {
mockServer.expect(requestTo("https://graph.facebook.com/297875170268725"))
.andExpect(method(POST))
- .andExpect(body("method=delete"))
+ .andExpect(content().string("method=delete"))
.andExpect(header("Authorization", "OAuth someAccessToken"))
.andRespond(withSuccess("", MediaType.APPLICATION_JSON));
facebook.questionOperations().deleteQuestion("297875170268725");
@@ -131,7 +131,7 @@ public void getQuestionOptions() {
public void deleteOption() {
mockServer.expect(requestTo("https://graph.facebook.com/297875170268725"))
.andExpect(method(POST))
- .andExpect(body("method=delete"))
+ .andExpect(content().string("method=delete"))
.andExpect(header("Authorization", "OAuth someAccessToken"))
.andRespond(withSuccess("", MediaType.APPLICATION_JSON));
facebook.questionOperations().deleteOption("297875170268725");

0 comments on commit 3e0b742

Please sign in to comment.