diff --git a/.gitignore b/.gitignore index e2509900a..51ee0e177 100644 --- a/.gitignore +++ b/.gitignore @@ -11,3 +11,6 @@ spring-social-core/src/test/java/exploration **/.project **/.settings **/bin +*.iml +*.ipr +*.iws diff --git a/spring-social-facebook-web/src/main/java/org/springframework/social/facebook/web/CanvasSignInController.java b/spring-social-facebook-web/src/main/java/org/springframework/social/facebook/web/CanvasSignInController.java index a061e81ae..70143f782 100644 --- a/spring-social-facebook-web/src/main/java/org/springframework/social/facebook/web/CanvasSignInController.java +++ b/spring-social-facebook-web/src/main/java/org/springframework/social/facebook/web/CanvasSignInController.java @@ -32,6 +32,7 @@ import org.springframework.social.connect.support.OAuth2ConnectionFactory; import org.springframework.social.connect.web.SignInAdapter; import org.springframework.social.facebook.api.Facebook; +import org.springframework.social.facebook.api.GraphApi; import org.springframework.social.oauth2.AccessGrant; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; @@ -72,16 +73,23 @@ public class CanvasSignInController { private String scope; + private String graphVersion; + @Inject public CanvasSignInController(ConnectionFactoryLocator connectionFactoryLocator, UsersConnectionRepository usersConnectionRepository, SignInAdapter signInAdapter, String clientId, String clientSecret, String canvasPage) { + this(connectionFactoryLocator, usersConnectionRepository, signInAdapter, clientId, clientSecret, canvasPage, GraphApi.DEFAULT_GRAPH_API_VERSION); + } + + public CanvasSignInController(ConnectionFactoryLocator connectionFactoryLocator, UsersConnectionRepository usersConnectionRepository, SignInAdapter signInAdapter, String clientId, String clientSecret, String canvasPage, String graphVersion) { this.usersConnectionRepository = usersConnectionRepository; this.signInAdapter = signInAdapter; this.clientId = clientId; this.canvasPage = canvasPage; this.connectionFactoryLocator = connectionFactoryLocator; this.signedRequestDecoder = new SignedRequestDecoder(clientSecret); + this.graphVersion = graphVersion; } - + /** * The URL or path to redirect to after successful canvas authorization. * @param postSignInUrl the url to redirect to after successful canvas authorization. Defaults to "/". @@ -131,7 +139,7 @@ protected String getRedirectUrl(Map model) { String clientId = (String) model.get("clientId"); String canvasPage = (String) model.get("canvasPage"); String scope = (String) model.get("scope"); - String redirectUrl = "https://www.facebook.com/v1.0/dialog/oauth?client_id=" + clientId + "&redirect_uri=" + canvasPage; + String redirectUrl = "https://www.facebook.com/" + graphVersion + "/dialog/oauth?client_id=" + clientId + "&redirect_uri=" + canvasPage; if (scope != null) { redirectUrl += "&scope=" + formEncode(scope); } diff --git a/spring-social-facebook/src/main/java/org/springframework/social/facebook/api/GraphApi.java b/spring-social-facebook/src/main/java/org/springframework/social/facebook/api/GraphApi.java index 36961ed4a..6bec8827b 100644 --- a/spring-social-facebook/src/main/java/org/springframework/social/facebook/api/GraphApi.java +++ b/spring-social-facebook/src/main/java/org/springframework/social/facebook/api/GraphApi.java @@ -151,7 +151,14 @@ public interface GraphApi { * May be null if no namespace was specified. */ String getApplicationNamespace(); + + /** + * @return The Graph version associated with this GraphApi instance. + */ + String getGraphApiUrl(); - static final String GRAPH_API_URL = "https://graph.facebook.com/v2.2/"; + static final String GRAPH_API_URL_VERSIONLESS = "https://graph.facebook.com/"; + + static final String DEFAULT_GRAPH_API_VERSION = "v2.2"; } diff --git a/spring-social-facebook/src/main/java/org/springframework/social/facebook/api/impl/FacebookTemplate.java b/spring-social-facebook/src/main/java/org/springframework/social/facebook/api/impl/FacebookTemplate.java index 2499fc33a..3f3cdaee4 100644 --- a/spring-social-facebook/src/main/java/org/springframework/social/facebook/api/impl/FacebookTemplate.java +++ b/spring-social-facebook/src/main/java/org/springframework/social/facebook/api/impl/FacebookTemplate.java @@ -31,22 +31,7 @@ import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter; import org.springframework.social.NotAuthorizedException; import org.springframework.social.UncategorizedApiException; -import org.springframework.social.facebook.api.AchievementOperations; -import org.springframework.social.facebook.api.CommentOperations; -import org.springframework.social.facebook.api.EventOperations; -import org.springframework.social.facebook.api.Facebook; -import org.springframework.social.facebook.api.FeedOperations; -import org.springframework.social.facebook.api.FqlOperations; -import org.springframework.social.facebook.api.FriendOperations; -import org.springframework.social.facebook.api.GroupOperations; -import org.springframework.social.facebook.api.ImageType; -import org.springframework.social.facebook.api.LikeOperations; -import org.springframework.social.facebook.api.MediaOperations; -import org.springframework.social.facebook.api.OpenGraphOperations; -import org.springframework.social.facebook.api.PageOperations; -import org.springframework.social.facebook.api.PagedList; -import org.springframework.social.facebook.api.PagingParameters; -import org.springframework.social.facebook.api.UserOperations; +import org.springframework.social.facebook.api.*; import org.springframework.social.facebook.api.impl.json.FacebookModule; import org.springframework.social.oauth2.AbstractOAuth2ApiBinding; import org.springframework.social.oauth2.OAuth2Version; @@ -103,6 +88,8 @@ public class FacebookTemplate extends AbstractOAuth2ApiBinding implements Facebo private String applicationNamespace; + private String graphVersion; + /** * Create a new instance of FacebookTemplate. * This constructor creates a new FacebookTemplate able to perform unauthenticated operations against Facebook's Graph API. @@ -112,7 +99,8 @@ public class FacebookTemplate extends AbstractOAuth2ApiBinding implements Facebo * Those operations requiring authentication will throw {@link NotAuthorizedException}. */ public FacebookTemplate() { - initialize(); + this.graphVersion = GraphApi.DEFAULT_GRAPH_API_VERSION; + initialize(); } /** @@ -125,7 +113,12 @@ public FacebookTemplate(String accessToken) { } public FacebookTemplate(String accessToken, String applicationNamespace) { + this(accessToken, applicationNamespace, GraphApi.DEFAULT_GRAPH_API_VERSION); + } + + public FacebookTemplate(String accessToken, String applicationNamespace, String graphVersion) { super(accessToken); + this.graphVersion = graphVersion; this.applicationNamespace = applicationNamespace; initialize(); } @@ -194,7 +187,7 @@ public String getApplicationNamespace() { // low-level Graph API operations public T fetchObject(String objectId, Class type) { - URI uri = URIBuilder.fromUri(GRAPH_API_URL + objectId).build(); + URI uri = URIBuilder.fromUri(getGraphApiUrl() + objectId).build(); return getRestTemplate().getForObject(uri, type); } @@ -208,7 +201,7 @@ public T fetchObject(String objectId, Class type, String... fields) { } public T fetchObject(String objectId, Class type, MultiValueMap queryParameters) { - URI uri = URIBuilder.fromUri(GRAPH_API_URL + objectId).queryParams(queryParameters).build(); + URI uri = URIBuilder.fromUri(getGraphApiUrl() + objectId).queryParams(queryParameters).build(); return getRestTemplate().getForObject(uri, type); } @@ -223,14 +216,14 @@ public PagedList fetchConnections(String objectId, String connectionType, public PagedList fetchConnections(String objectId, String connectionType, Class type, MultiValueMap queryParameters) { String connectionPath = connectionType != null && connectionType.length() > 0 ? "/" + connectionType : ""; - URIBuilder uriBuilder = URIBuilder.fromUri(GRAPH_API_URL + objectId + connectionPath).queryParams(queryParameters); + URIBuilder uriBuilder = URIBuilder.fromUri(getGraphApiUrl() + objectId + connectionPath).queryParams(queryParameters); JsonNode jsonNode = getRestTemplate().getForObject(uriBuilder.build(), JsonNode.class); return pagify(type, jsonNode); } public PagedList fetchPagedConnections(String objectId, String connectionType, Class type, MultiValueMap queryParameters) { String connectionPath = connectionType != null && connectionType.length() > 0 ? "/" + connectionType : ""; - URIBuilder uriBuilder = URIBuilder.fromUri(GRAPH_API_URL + objectId + connectionPath).queryParams(queryParameters); + URIBuilder uriBuilder = URIBuilder.fromUri(getGraphApiUrl() + objectId + connectionPath).queryParams(queryParameters); JsonNode jsonNode = getRestTemplate().getForObject(uriBuilder.build(), JsonNode.class); return pagify(type, jsonNode); } @@ -255,7 +248,7 @@ private PagedList pagify(Class type, JsonNode jsonNode) { } public byte[] fetchImage(String objectId, String connectionType, ImageType type) { - URI uri = URIBuilder.fromUri(GRAPH_API_URL + objectId + "/" + connectionType + "?type=" + type.toString().toLowerCase()).build(); + URI uri = URIBuilder.fromUri(getGraphApiUrl() + objectId + "/" + connectionType + "?type=" + type.toString().toLowerCase()).build(); ResponseEntity response = getRestTemplate().getForEntity(uri, byte[].class); if(response.getStatusCode() == HttpStatus.FOUND) { throw new UnsupportedOperationException("Attempt to fetch image resulted in a redirect which could not be followed. Add Apache HttpComponents HttpClient to the classpath " + @@ -267,36 +260,40 @@ public byte[] fetchImage(String objectId, String connectionType, ImageType type) @SuppressWarnings("unchecked") public String publish(String objectId, String connectionType, MultiValueMap data) { MultiValueMap requestData = new LinkedMultiValueMap(data); - URI uri = URIBuilder.fromUri(GRAPH_API_URL + objectId + "/" + connectionType).build(); + URI uri = URIBuilder.fromUri(getGraphApiUrl() + objectId + "/" + connectionType).build(); Map response = getRestTemplate().postForObject(uri, requestData, Map.class); return (String) response.get("id"); } public void post(String objectId, String connectionType, MultiValueMap data) { - URI uri = URIBuilder.fromUri(GRAPH_API_URL + objectId + "/" + connectionType).build(); + URI uri = URIBuilder.fromUri(getGraphApiUrl() + objectId + "/" + connectionType).build(); getRestTemplate().postForObject(uri, new LinkedMultiValueMap(data), String.class); } public void delete(String objectId) { LinkedMultiValueMap deleteRequest = new LinkedMultiValueMap(); deleteRequest.set("method", "delete"); - URI uri = URIBuilder.fromUri(GRAPH_API_URL + objectId).build(); + URI uri = URIBuilder.fromUri(getGraphApiUrl() + objectId).build(); getRestTemplate().postForObject(uri, deleteRequest, String.class); } public void delete(String objectId, String connectionType) { LinkedMultiValueMap deleteRequest = new LinkedMultiValueMap(); deleteRequest.set("method", "delete"); - URI uri = URIBuilder.fromUri(GRAPH_API_URL + objectId + "/" + connectionType).build(); + URI uri = URIBuilder.fromUri(getGraphApiUrl() + objectId + "/" + connectionType).build(); getRestTemplate().postForObject(uri, deleteRequest, String.class); } public void delete(String objectId, String connectionType, MultiValueMap data) { data.set("method", "delete"); - URI uri = URIBuilder.fromUri(GRAPH_API_URL + objectId + "/" + connectionType).build(); + URI uri = URIBuilder.fromUri(getGraphApiUrl() + objectId + "/" + connectionType).build(); HttpEntity> entity = new HttpEntity>(data, new HttpHeaders()); getRestTemplate().exchange(uri, HttpMethod.POST, entity, String.class); } + + public String getGraphApiUrl() { + return GRAPH_API_URL_VERSIONLESS + graphVersion + "/"; + } // AbstractOAuth2ApiBinding hooks @Override @@ -360,5 +357,9 @@ private String join(String[] strings) { } return builder.toString(); } + + public void setGraphVersion(String graphVersion) { + this.graphVersion = graphVersion; + } } diff --git a/spring-social-facebook/src/main/java/org/springframework/social/facebook/api/impl/FeedTemplate.java b/spring-social-facebook/src/main/java/org/springframework/social/facebook/api/impl/FeedTemplate.java index 82fd9bbdb..5fea9028f 100644 --- a/spring-social-facebook/src/main/java/org/springframework/social/facebook/api/impl/FeedTemplate.java +++ b/spring-social-facebook/src/main/java/org/springframework/social/facebook/api/impl/FeedTemplate.java @@ -74,7 +74,7 @@ public PagedList getFeed(String ownerId) { public PagedList getFeed(String ownerId, PagingParameters pagedListParameters) { requireAuthorization(); - JsonNode responseNode = fetchConnectionList(GraphApi.GRAPH_API_URL + ownerId + "/feed", pagedListParameters); + JsonNode responseNode = fetchConnectionList(graphApi.getGraphApiUrl() + ownerId + "/feed", pagedListParameters); return deserializeList(responseNode, null, Post.class); } @@ -84,7 +84,7 @@ public PagedList getHomeFeed() { public PagedList getHomeFeed(PagingParameters pagedListParameters) { requireAuthorization(); - JsonNode responseNode = fetchConnectionList(GraphApi.GRAPH_API_URL + "me/home", pagedListParameters); + JsonNode responseNode = fetchConnectionList(graphApi.getGraphApiUrl() + "me/home", pagedListParameters); return deserializeList(responseNode, null, Post.class); } @@ -102,7 +102,7 @@ public PagedList getStatuses(String userId) { public PagedList getStatuses(String userId, PagingParameters pagedListParameters) { requireAuthorization(); - JsonNode responseNode = fetchConnectionList(GraphApi.GRAPH_API_URL + userId + "/statuses", pagedListParameters); + JsonNode responseNode = fetchConnectionList(graphApi.getGraphApiUrl() + userId + "/statuses", pagedListParameters); return deserializeList(responseNode, "status", Post.class); } @@ -120,7 +120,7 @@ public PagedList getLinks(String ownerId) { public PagedList getLinks(String ownerId, PagingParameters pagedListParameters) { requireAuthorization(); - JsonNode responseNode = fetchConnectionList(GraphApi.GRAPH_API_URL + ownerId + "/links", pagedListParameters); + JsonNode responseNode = fetchConnectionList(graphApi.getGraphApiUrl() + ownerId + "/links", pagedListParameters); return deserializeList(responseNode, "link", Post.class); } @@ -138,13 +138,13 @@ public PagedList getPosts(String ownerId) { public PagedList getPosts(String ownerId, PagingParameters pagedListParameters) { requireAuthorization(); - JsonNode responseNode = fetchConnectionList(GraphApi.GRAPH_API_URL + ownerId + "/posts", pagedListParameters); + JsonNode responseNode = fetchConnectionList(graphApi.getGraphApiUrl() + ownerId + "/posts", pagedListParameters); return deserializeList(responseNode, null, Post.class); } public Post getPost(String entryId) { requireAuthorization(); - ObjectNode responseNode = (ObjectNode) restTemplate.getForObject(GraphApi.GRAPH_API_URL + entryId, JsonNode.class); + ObjectNode responseNode = (ObjectNode) restTemplate.getForObject(graphApi.getGraphApiUrl() + entryId, JsonNode.class); return deserializePost(null, Post.class, responseNode); } @@ -189,7 +189,7 @@ public PagedList searchPublicFeed(String query) { } public PagedList searchPublicFeed(String query, PagingParameters pagedListParameters) { - String url = GraphApi.GRAPH_API_URL + "search?q={query}&type=post"; + String url = graphApi.getGraphApiUrl() + "search?q={query}&type=post"; Map params = new HashMap(); params.put("query", query); if (pagedListParameters.getLimit() != null) { @@ -214,7 +214,7 @@ public PagedList searchHomeFeed(String query) { public PagedList searchHomeFeed(String query, PagingParameters pagedListParameters) { requireAuthorization(); - URIBuilder uriBuilder = URIBuilder.fromUri(GraphApi.GRAPH_API_URL + "me/home").queryParam("q", query); + URIBuilder uriBuilder = URIBuilder.fromUri(graphApi.getGraphApiUrl() + "me/home").queryParam("q", query); uriBuilder = appendPagedListParameters(pagedListParameters, uriBuilder); URI uri = uriBuilder.build(); JsonNode responseNode = restTemplate.getForObject(uri, JsonNode.class); @@ -235,7 +235,7 @@ public PagedList searchUserFeed(String userId, String query) { public PagedList searchUserFeed(String userId, String query, PagingParameters pagedListParameters) { requireAuthorization(); - URIBuilder uriBuilder = URIBuilder.fromUri(GraphApi.GRAPH_API_URL + userId + "/feed").queryParam("q", query); + URIBuilder uriBuilder = URIBuilder.fromUri(graphApi.getGraphApiUrl() + userId + "/feed").queryParam("q", query); uriBuilder = appendPagedListParameters(pagedListParameters, uriBuilder); URI uri = uriBuilder.build(); JsonNode responseNode = restTemplate.getForObject(uri, JsonNode.class); diff --git a/spring-social-facebook/src/main/java/org/springframework/social/facebook/api/impl/FriendTemplate.java b/spring-social-facebook/src/main/java/org/springframework/social/facebook/api/impl/FriendTemplate.java index a3f1c4b33..18506ff7d 100644 --- a/spring-social-facebook/src/main/java/org/springframework/social/facebook/api/impl/FriendTemplate.java +++ b/spring-social-facebook/src/main/java/org/springframework/social/facebook/api/impl/FriendTemplate.java @@ -76,8 +76,8 @@ public PagedList getFriends(String userId) { } public PagedList getFriendIds(String userId) { - requireAuthorization(); - URI uri = URIBuilder.fromUri(GraphApi.GRAPH_API_URL + userId + "/friends").queryParam("fields", "id").build(); + requireAuthorization(); + URI uri = URIBuilder.fromUri(graphApi.getGraphApiUrl() + userId + "/friends").queryParam("fields", "id").build(); @SuppressWarnings("unchecked") Map>> response = restTemplate.getForObject(uri, Map.class); List> entryList = response.get("data"); diff --git a/spring-social-facebook/src/main/java/org/springframework/social/facebook/api/impl/UserTemplate.java b/spring-social-facebook/src/main/java/org/springframework/social/facebook/api/impl/UserTemplate.java index 600459165..31e1ea93f 100644 --- a/spring-social-facebook/src/main/java/org/springframework/social/facebook/api/impl/UserTemplate.java +++ b/spring-social-facebook/src/main/java/org/springframework/social/facebook/api/impl/UserTemplate.java @@ -72,7 +72,7 @@ public byte[] getUserProfileImage(String userId, ImageType imageType) { public List getUserPermissions() { requireAuthorization(); - JsonNode responseNode = restTemplate.getForObject(GraphApi.GRAPH_API_URL + "me/permissions", JsonNode.class); + JsonNode responseNode = restTemplate.getForObject(graphApi.getGraphApiUrl() + "me/permissions", JsonNode.class); return deserializePermissionsNodeToList(responseNode); } diff --git a/spring-social-facebook/src/main/java/org/springframework/social/facebook/connect/FacebookAdapter.java b/spring-social-facebook/src/main/java/org/springframework/social/facebook/connect/FacebookAdapter.java index 5dedf4ff4..75f879a75 100644 --- a/spring-social-facebook/src/main/java/org/springframework/social/facebook/connect/FacebookAdapter.java +++ b/spring-social-facebook/src/main/java/org/springframework/social/facebook/connect/FacebookAdapter.java @@ -43,7 +43,7 @@ public void setConnectionValues(Facebook facebook, ConnectionValues values) { values.setProviderUserId(profile.getId()); values.setDisplayName(profile.getName()); values.setProfileUrl("https://www.facebook.com/app_scoped_user_id/" + profile.getId() + '/'); - values.setImageUrl("https://graph.facebook.com/v2.2/" + profile.getId() + "/picture"); + values.setImageUrl("https://graph.facebook.com/" + profile.getId() + "/picture"); } public UserProfile fetchUserProfile(Facebook facebook) { diff --git a/spring-social-facebook/src/main/java/org/springframework/social/facebook/connect/FacebookConnectionFactory.java b/spring-social-facebook/src/main/java/org/springframework/social/facebook/connect/FacebookConnectionFactory.java index 5a30b3783..6c93a2d7b 100644 --- a/spring-social-facebook/src/main/java/org/springframework/social/facebook/connect/FacebookConnectionFactory.java +++ b/spring-social-facebook/src/main/java/org/springframework/social/facebook/connect/FacebookConnectionFactory.java @@ -17,6 +17,7 @@ import org.springframework.social.connect.support.OAuth2ConnectionFactory; import org.springframework.social.facebook.api.Facebook; +import org.springframework.social.facebook.api.GraphApi; /** * Facebook ConnectionFactory implementation. @@ -42,7 +43,18 @@ public FacebookConnectionFactory(String appId, String appSecret) { * @param appNamespace The application's App Namespace as configured with Facebook. Enables use of Open Graph operations. */ public FacebookConnectionFactory(String appId, String appSecret, String appNamespace) { - super("facebook", new FacebookServiceProvider(appId, appSecret, appNamespace), new FacebookAdapter()); + this(appId, appSecret, appNamespace, GraphApi.DEFAULT_GRAPH_API_VERSION); + } + + /** + * Creates a FacebookConnectionFactory for the given application ID, secret, and namespace. + * @param appId The application's App ID as assigned by Facebook + * @param appSecret The application's App Secret as assigned by Facebook + * @param appNamespace The application's App Namespace as configured with Facebook. Enables use of Open Graph operations. + * @param graphApiVersion The version of Open Graph to use. + */ + public FacebookConnectionFactory(String appId, String appSecret, String appNamespace, String graphApiVersion) { + super("facebook", new FacebookServiceProvider(appId, appSecret, appNamespace, graphApiVersion), new FacebookAdapter()); } } diff --git a/spring-social-facebook/src/main/java/org/springframework/social/facebook/connect/FacebookOAuth2Template.java b/spring-social-facebook/src/main/java/org/springframework/social/facebook/connect/FacebookOAuth2Template.java index a8b851cfa..0ae184d7a 100644 --- a/spring-social-facebook/src/main/java/org/springframework/social/facebook/connect/FacebookOAuth2Template.java +++ b/spring-social-facebook/src/main/java/org/springframework/social/facebook/connect/FacebookOAuth2Template.java @@ -20,6 +20,7 @@ import org.springframework.http.MediaType; import org.springframework.http.converter.FormHttpMessageConverter; import org.springframework.http.converter.HttpMessageConverter; +import org.springframework.social.facebook.api.GraphApi; import org.springframework.social.oauth2.AccessGrant; import org.springframework.social.oauth2.OAuth2Template; import org.springframework.social.support.ClientHttpRequestFactorySelector; @@ -34,8 +35,13 @@ */ public class FacebookOAuth2Template extends OAuth2Template { + public FacebookOAuth2Template(String clientId, String clientSecret, String graphVersion) { + super(clientId, clientSecret, "https://www.facebook.com/" + graphVersion + "/dialog/oauth", "https://graph.facebook.com/" + graphVersion +"/oauth/access_token"); + setUseParametersForClientAuthentication(true); + } + public FacebookOAuth2Template(String clientId, String clientSecret) { - super(clientId, clientSecret, "https://www.facebook.com/v2.2/dialog/oauth", "https://graph.facebook.com/v2.2/oauth/access_token"); + this(clientId, clientSecret, GraphApi.DEFAULT_GRAPH_API_VERSION); setUseParametersForClientAuthentication(true); } diff --git a/spring-social-facebook/src/main/java/org/springframework/social/facebook/connect/FacebookServiceProvider.java b/spring-social-facebook/src/main/java/org/springframework/social/facebook/connect/FacebookServiceProvider.java index d10260126..1514f8186 100644 --- a/spring-social-facebook/src/main/java/org/springframework/social/facebook/connect/FacebookServiceProvider.java +++ b/spring-social-facebook/src/main/java/org/springframework/social/facebook/connect/FacebookServiceProvider.java @@ -16,6 +16,7 @@ package org.springframework.social.facebook.connect; import org.springframework.social.facebook.api.Facebook; +import org.springframework.social.facebook.api.GraphApi; import org.springframework.social.facebook.api.impl.FacebookTemplate; import org.springframework.social.oauth2.AbstractOAuth2ServiceProvider; @@ -35,7 +36,18 @@ public class FacebookServiceProvider extends AbstractOAuth2ServiceProvider likes = facebook.likeOperations().getLikes("12345678"); @@ -92,7 +92,7 @@ public void getLikes() { @Test public void getPagesLiked() { - mockServer.expect(requestTo("https://graph.facebook.com/v2.2/me/likes?fields=id%2Cname%2Ccategory%2Cdescription%2Clocation%2Cwebsite%2Cpicture%2Cphone%2Caffiliation%2Ccompany_overview%2Clikes%2Ccheckins%2Ccover")).andExpect(method(GET)) + mockServer.expect(requestTo(getGraphApiUrl() + "me/likes?fields=id%2Cname%2Ccategory%2Cdescription%2Clocation%2Cwebsite%2Cpicture%2Cphone%2Caffiliation%2Ccompany_overview%2Clikes%2Ccheckins%2Ccover")).andExpect(method(GET)) .andExpect(header("Authorization", "OAuth someAccessToken")) .andRespond(withSuccess(jsonResource("new-user-likes"), MediaType.APPLICATION_JSON)); List likes = facebook.likeOperations().getPagesLiked(); @@ -101,7 +101,7 @@ public void getPagesLiked() { @Test public void getPagesLiked_withPagingParameters() { - mockServer.expect(requestTo("https://graph.facebook.com/v2.2/me/likes?limit=25&offset=50&fields=id%2Cname%2Ccategory%2Cdescription%2Clocation%2Cwebsite%2Cpicture%2Cphone%2Caffiliation%2Ccompany_overview%2Clikes%2Ccheckins%2Ccover")).andExpect(method(GET)) + mockServer.expect(requestTo(getGraphApiUrl() + "me/likes?limit=25&offset=50&fields=id%2Cname%2Ccategory%2Cdescription%2Clocation%2Cwebsite%2Cpicture%2Cphone%2Caffiliation%2Ccompany_overview%2Clikes%2Ccheckins%2Ccover")).andExpect(method(GET)) .andExpect(header("Authorization", "OAuth someAccessToken")) .andRespond(withSuccess(jsonResource("new-user-likes"), MediaType.APPLICATION_JSON)); List likes = facebook.likeOperations().getPagesLiked(PAGING_PARAMS_25_50); @@ -115,7 +115,7 @@ public void getPagesLiked_unauthorized() { @Test public void getPagesLiked_forSpecificUser() { - mockServer.expect(requestTo("https://graph.facebook.com/v2.2/123456789/likes?fields=id%2Cname%2Ccategory%2Cdescription%2Clocation%2Cwebsite%2Cpicture%2Cphone%2Caffiliation%2Ccompany_overview%2Clikes%2Ccheckins%2Ccover")).andExpect(method(GET)) + mockServer.expect(requestTo(getGraphApiUrl() + "123456789/likes?fields=id%2Cname%2Ccategory%2Cdescription%2Clocation%2Cwebsite%2Cpicture%2Cphone%2Caffiliation%2Ccompany_overview%2Clikes%2Ccheckins%2Ccover")).andExpect(method(GET)) .andExpect(header("Authorization", "OAuth someAccessToken")) .andRespond(withSuccess(jsonResource("new-user-likes"), MediaType.APPLICATION_JSON)); List likes = facebook.likeOperations().getPagesLiked("123456789"); @@ -124,7 +124,7 @@ public void getPagesLiked_forSpecificUser() { @Test public void getPagesLiked_forSpecificUser_withPagingParameters() { - mockServer.expect(requestTo("https://graph.facebook.com/v2.2/123456789/likes?limit=25&offset=50&fields=id%2Cname%2Ccategory%2Cdescription%2Clocation%2Cwebsite%2Cpicture%2Cphone%2Caffiliation%2Ccompany_overview%2Clikes%2Ccheckins%2Ccover")).andExpect(method(GET)) + mockServer.expect(requestTo(getGraphApiUrl() + "123456789/likes?limit=25&offset=50&fields=id%2Cname%2Ccategory%2Cdescription%2Clocation%2Cwebsite%2Cpicture%2Cphone%2Caffiliation%2Ccompany_overview%2Clikes%2Ccheckins%2Ccover")).andExpect(method(GET)) .andExpect(header("Authorization", "OAuth someAccessToken")) .andRespond(withSuccess(jsonResource("new-user-likes"), MediaType.APPLICATION_JSON)); List likes = facebook.likeOperations().getPagesLiked("123456789", PAGING_PARAMS_25_50); @@ -138,7 +138,7 @@ public void getLikes_forSpecificUser_unauthorized() { @Test public void getBooks() { - mockServer.expect(requestTo("https://graph.facebook.com/v2.2/me/books?fields=id%2Cname%2Ccategory%2Cdescription%2Clocation%2Cwebsite%2Cpicture%2Cphone%2Caffiliation%2Ccompany_overview%2Clikes%2Ccheckins%2Ccover")).andExpect(method(GET)) + mockServer.expect(requestTo(getGraphApiUrl() + "me/books?fields=id%2Cname%2Ccategory%2Cdescription%2Clocation%2Cwebsite%2Cpicture%2Cphone%2Caffiliation%2Ccompany_overview%2Clikes%2Ccheckins%2Ccover")).andExpect(method(GET)) .andExpect(header("Authorization", "OAuth someAccessToken")) .andRespond(withSuccess(jsonResource("new-user-likes"), MediaType.APPLICATION_JSON)); List likes = facebook.likeOperations().getBooks(); @@ -147,7 +147,7 @@ public void getBooks() { @Test public void getBooks_withPagingParameters() { - mockServer.expect(requestTo("https://graph.facebook.com/v2.2/me/books?limit=25&offset=50&fields=id%2Cname%2Ccategory%2Cdescription%2Clocation%2Cwebsite%2Cpicture%2Cphone%2Caffiliation%2Ccompany_overview%2Clikes%2Ccheckins%2Ccover")).andExpect(method(GET)) + mockServer.expect(requestTo(getGraphApiUrl() + "me/books?limit=25&offset=50&fields=id%2Cname%2Ccategory%2Cdescription%2Clocation%2Cwebsite%2Cpicture%2Cphone%2Caffiliation%2Ccompany_overview%2Clikes%2Ccheckins%2Ccover")).andExpect(method(GET)) .andExpect(header("Authorization", "OAuth someAccessToken")) .andRespond(withSuccess(jsonResource("new-user-likes"), MediaType.APPLICATION_JSON)); List likes = facebook.likeOperations().getBooks(PAGING_PARAMS_25_50); @@ -161,7 +161,7 @@ public void getBooks_unauthorized() { @Test public void getBooks_forSpecificUser() { - mockServer.expect(requestTo("https://graph.facebook.com/v2.2/123456789/books?fields=id%2Cname%2Ccategory%2Cdescription%2Clocation%2Cwebsite%2Cpicture%2Cphone%2Caffiliation%2Ccompany_overview%2Clikes%2Ccheckins%2Ccover")).andExpect(method(GET)) + mockServer.expect(requestTo(getGraphApiUrl() + "123456789/books?fields=id%2Cname%2Ccategory%2Cdescription%2Clocation%2Cwebsite%2Cpicture%2Cphone%2Caffiliation%2Ccompany_overview%2Clikes%2Ccheckins%2Ccover")).andExpect(method(GET)) .andExpect(header("Authorization", "OAuth someAccessToken")) .andRespond(withSuccess(jsonResource("new-user-likes"), MediaType.APPLICATION_JSON)); List likes = facebook.likeOperations().getBooks("123456789"); @@ -170,7 +170,7 @@ public void getBooks_forSpecificUser() { @Test public void getBooks_forSpecificUser_withPagingParameters() { - mockServer.expect(requestTo("https://graph.facebook.com/v2.2/123456789/books?limit=25&offset=50&fields=id%2Cname%2Ccategory%2Cdescription%2Clocation%2Cwebsite%2Cpicture%2Cphone%2Caffiliation%2Ccompany_overview%2Clikes%2Ccheckins%2Ccover")).andExpect(method(GET)) + mockServer.expect(requestTo(getGraphApiUrl() + "123456789/books?limit=25&offset=50&fields=id%2Cname%2Ccategory%2Cdescription%2Clocation%2Cwebsite%2Cpicture%2Cphone%2Caffiliation%2Ccompany_overview%2Clikes%2Ccheckins%2Ccover")).andExpect(method(GET)) .andExpect(header("Authorization", "OAuth someAccessToken")) .andRespond(withSuccess(jsonResource("new-user-likes"), MediaType.APPLICATION_JSON)); List likes = facebook.likeOperations().getBooks("123456789", PAGING_PARAMS_25_50); @@ -184,7 +184,7 @@ public void getBooks_forSpecificUser_unauthorized() { @Test public void getMovies() { - mockServer.expect(requestTo("https://graph.facebook.com/v2.2/me/movies?fields=id%2Cname%2Ccategory%2Cdescription%2Clocation%2Cwebsite%2Cpicture%2Cphone%2Caffiliation%2Ccompany_overview%2Clikes%2Ccheckins%2Ccover")).andExpect(method(GET)) + mockServer.expect(requestTo(getGraphApiUrl() + "me/movies?fields=id%2Cname%2Ccategory%2Cdescription%2Clocation%2Cwebsite%2Cpicture%2Cphone%2Caffiliation%2Ccompany_overview%2Clikes%2Ccheckins%2Ccover")).andExpect(method(GET)) .andExpect(header("Authorization", "OAuth someAccessToken")) .andRespond(withSuccess(jsonResource("new-user-likes"), MediaType.APPLICATION_JSON)); List likes = facebook.likeOperations().getMovies(); @@ -193,7 +193,7 @@ public void getMovies() { @Test public void getMovies_withPagingParameters() { - mockServer.expect(requestTo("https://graph.facebook.com/v2.2/me/movies?limit=25&offset=50&fields=id%2Cname%2Ccategory%2Cdescription%2Clocation%2Cwebsite%2Cpicture%2Cphone%2Caffiliation%2Ccompany_overview%2Clikes%2Ccheckins%2Ccover")).andExpect(method(GET)) + mockServer.expect(requestTo(getGraphApiUrl() + "me/movies?limit=25&offset=50&fields=id%2Cname%2Ccategory%2Cdescription%2Clocation%2Cwebsite%2Cpicture%2Cphone%2Caffiliation%2Ccompany_overview%2Clikes%2Ccheckins%2Ccover")).andExpect(method(GET)) .andExpect(header("Authorization", "OAuth someAccessToken")) .andRespond(withSuccess(jsonResource("new-user-likes"), MediaType.APPLICATION_JSON)); List likes = facebook.likeOperations().getMovies(PAGING_PARAMS_25_50); @@ -207,7 +207,7 @@ public void getMovies_unauthorized() { @Test public void getMovies_forSpecificUser() { - mockServer.expect(requestTo("https://graph.facebook.com/v2.2/123456789/movies?fields=id%2Cname%2Ccategory%2Cdescription%2Clocation%2Cwebsite%2Cpicture%2Cphone%2Caffiliation%2Ccompany_overview%2Clikes%2Ccheckins%2Ccover")).andExpect(method(GET)) + mockServer.expect(requestTo(getGraphApiUrl() + "123456789/movies?fields=id%2Cname%2Ccategory%2Cdescription%2Clocation%2Cwebsite%2Cpicture%2Cphone%2Caffiliation%2Ccompany_overview%2Clikes%2Ccheckins%2Ccover")).andExpect(method(GET)) .andExpect(header("Authorization", "OAuth someAccessToken")) .andRespond(withSuccess(jsonResource("new-user-likes"), MediaType.APPLICATION_JSON)); List likes = facebook.likeOperations().getMovies("123456789"); @@ -216,7 +216,7 @@ public void getMovies_forSpecificUser() { @Test public void getMovies_forSpecificUser_withPagingParameters() { - mockServer.expect(requestTo("https://graph.facebook.com/v2.2/123456789/movies?limit=25&offset=50&fields=id%2Cname%2Ccategory%2Cdescription%2Clocation%2Cwebsite%2Cpicture%2Cphone%2Caffiliation%2Ccompany_overview%2Clikes%2Ccheckins%2Ccover")).andExpect(method(GET)) + mockServer.expect(requestTo(getGraphApiUrl() + "123456789/movies?limit=25&offset=50&fields=id%2Cname%2Ccategory%2Cdescription%2Clocation%2Cwebsite%2Cpicture%2Cphone%2Caffiliation%2Ccompany_overview%2Clikes%2Ccheckins%2Ccover")).andExpect(method(GET)) .andExpect(header("Authorization", "OAuth someAccessToken")) .andRespond(withSuccess(jsonResource("new-user-likes"), MediaType.APPLICATION_JSON)); List likes = facebook.likeOperations().getMovies("123456789", PAGING_PARAMS_25_50); @@ -230,7 +230,7 @@ public void getMovies_forSpecificUser_unauthorized() { @Test public void getMusic() { - mockServer.expect(requestTo("https://graph.facebook.com/v2.2/me/music?fields=id%2Cname%2Ccategory%2Cdescription%2Clocation%2Cwebsite%2Cpicture%2Cphone%2Caffiliation%2Ccompany_overview%2Clikes%2Ccheckins%2Ccover")).andExpect(method(GET)) + mockServer.expect(requestTo(getGraphApiUrl() + "me/music?fields=id%2Cname%2Ccategory%2Cdescription%2Clocation%2Cwebsite%2Cpicture%2Cphone%2Caffiliation%2Ccompany_overview%2Clikes%2Ccheckins%2Ccover")).andExpect(method(GET)) .andExpect(header("Authorization", "OAuth someAccessToken")) .andRespond(withSuccess(jsonResource("new-user-likes"), MediaType.APPLICATION_JSON)); List likes = facebook.likeOperations().getMusic(); @@ -239,7 +239,7 @@ public void getMusic() { @Test public void getMusic_withPagingParameters() { - mockServer.expect(requestTo("https://graph.facebook.com/v2.2/me/music?limit=25&offset=50&fields=id%2Cname%2Ccategory%2Cdescription%2Clocation%2Cwebsite%2Cpicture%2Cphone%2Caffiliation%2Ccompany_overview%2Clikes%2Ccheckins%2Ccover")).andExpect(method(GET)) + mockServer.expect(requestTo(getGraphApiUrl() + "me/music?limit=25&offset=50&fields=id%2Cname%2Ccategory%2Cdescription%2Clocation%2Cwebsite%2Cpicture%2Cphone%2Caffiliation%2Ccompany_overview%2Clikes%2Ccheckins%2Ccover")).andExpect(method(GET)) .andExpect(header("Authorization", "OAuth someAccessToken")) .andRespond(withSuccess(jsonResource("new-user-likes"), MediaType.APPLICATION_JSON)); List likes = facebook.likeOperations().getMusic(PAGING_PARAMS_25_50); @@ -253,7 +253,7 @@ public void getMusic_unauthorized() { @Test public void getMusic_forSpecificUser() { - mockServer.expect(requestTo("https://graph.facebook.com/v2.2/123456789/music?fields=id%2Cname%2Ccategory%2Cdescription%2Clocation%2Cwebsite%2Cpicture%2Cphone%2Caffiliation%2Ccompany_overview%2Clikes%2Ccheckins%2Ccover")).andExpect(method(GET)) + mockServer.expect(requestTo(getGraphApiUrl() + "123456789/music?fields=id%2Cname%2Ccategory%2Cdescription%2Clocation%2Cwebsite%2Cpicture%2Cphone%2Caffiliation%2Ccompany_overview%2Clikes%2Ccheckins%2Ccover")).andExpect(method(GET)) .andExpect(header("Authorization", "OAuth someAccessToken")) .andRespond(withSuccess(jsonResource("new-user-likes"), MediaType.APPLICATION_JSON)); List likes = facebook.likeOperations().getMusic("123456789"); @@ -262,7 +262,7 @@ public void getMusic_forSpecificUser() { @Test public void getMusic_forSpecificUser_withPagingParameters() { - mockServer.expect(requestTo("https://graph.facebook.com/v2.2/123456789/music?limit=25&offset=50&fields=id%2Cname%2Ccategory%2Cdescription%2Clocation%2Cwebsite%2Cpicture%2Cphone%2Caffiliation%2Ccompany_overview%2Clikes%2Ccheckins%2Ccover")).andExpect(method(GET)) + mockServer.expect(requestTo(getGraphApiUrl() + "123456789/music?limit=25&offset=50&fields=id%2Cname%2Ccategory%2Cdescription%2Clocation%2Cwebsite%2Cpicture%2Cphone%2Caffiliation%2Ccompany_overview%2Clikes%2Ccheckins%2Ccover")).andExpect(method(GET)) .andExpect(header("Authorization", "OAuth someAccessToken")) .andRespond(withSuccess(jsonResource("new-user-likes"), MediaType.APPLICATION_JSON)); List likes = facebook.likeOperations().getMusic("123456789", PAGING_PARAMS_25_50); @@ -276,7 +276,7 @@ public void getMusic_forSpecificUser_unauthorized() { @Test public void getTelevision() { - mockServer.expect(requestTo("https://graph.facebook.com/v2.2/me/television?fields=id%2Cname%2Ccategory%2Cdescription%2Clocation%2Cwebsite%2Cpicture%2Cphone%2Caffiliation%2Ccompany_overview%2Clikes%2Ccheckins%2Ccover")).andExpect(method(GET)) + mockServer.expect(requestTo(getGraphApiUrl() + "me/television?fields=id%2Cname%2Ccategory%2Cdescription%2Clocation%2Cwebsite%2Cpicture%2Cphone%2Caffiliation%2Ccompany_overview%2Clikes%2Ccheckins%2Ccover")).andExpect(method(GET)) .andExpect(header("Authorization", "OAuth someAccessToken")) .andRespond(withSuccess(jsonResource("new-user-likes"), MediaType.APPLICATION_JSON)); List likes = facebook.likeOperations().getTelevision(); @@ -285,7 +285,7 @@ public void getTelevision() { @Test public void getTelevision_withPagingParameters() { - mockServer.expect(requestTo("https://graph.facebook.com/v2.2/me/television?limit=25&offset=50&fields=id%2Cname%2Ccategory%2Cdescription%2Clocation%2Cwebsite%2Cpicture%2Cphone%2Caffiliation%2Ccompany_overview%2Clikes%2Ccheckins%2Ccover")).andExpect(method(GET)) + mockServer.expect(requestTo(getGraphApiUrl() + "me/television?limit=25&offset=50&fields=id%2Cname%2Ccategory%2Cdescription%2Clocation%2Cwebsite%2Cpicture%2Cphone%2Caffiliation%2Ccompany_overview%2Clikes%2Ccheckins%2Ccover")).andExpect(method(GET)) .andExpect(header("Authorization", "OAuth someAccessToken")) .andRespond(withSuccess(jsonResource("new-user-likes"), MediaType.APPLICATION_JSON)); List likes = facebook.likeOperations().getTelevision(PAGING_PARAMS_25_50); @@ -299,7 +299,7 @@ public void getTelevision_unauthorized() { @Test public void getTelevision_forSpecificUser() { - mockServer.expect(requestTo("https://graph.facebook.com/v2.2/123456789/television?fields=id%2Cname%2Ccategory%2Cdescription%2Clocation%2Cwebsite%2Cpicture%2Cphone%2Caffiliation%2Ccompany_overview%2Clikes%2Ccheckins%2Ccover")).andExpect(method(GET)) + mockServer.expect(requestTo(getGraphApiUrl() + "123456789/television?fields=id%2Cname%2Ccategory%2Cdescription%2Clocation%2Cwebsite%2Cpicture%2Cphone%2Caffiliation%2Ccompany_overview%2Clikes%2Ccheckins%2Ccover")).andExpect(method(GET)) .andExpect(header("Authorization", "OAuth someAccessToken")) .andRespond(withSuccess(jsonResource("new-user-likes"), MediaType.APPLICATION_JSON)); List likes = facebook.likeOperations().getTelevision("123456789"); @@ -308,7 +308,7 @@ public void getTelevision_forSpecificUser() { @Test public void getTelevision_forSpecificUser_withPagingParameters() { - mockServer.expect(requestTo("https://graph.facebook.com/v2.2/123456789/television?limit=25&offset=50&fields=id%2Cname%2Ccategory%2Cdescription%2Clocation%2Cwebsite%2Cpicture%2Cphone%2Caffiliation%2Ccompany_overview%2Clikes%2Ccheckins%2Ccover")).andExpect(method(GET)) + mockServer.expect(requestTo(getGraphApiUrl() + "123456789/television?limit=25&offset=50&fields=id%2Cname%2Ccategory%2Cdescription%2Clocation%2Cwebsite%2Cpicture%2Cphone%2Caffiliation%2Ccompany_overview%2Clikes%2Ccheckins%2Ccover")).andExpect(method(GET)) .andExpect(header("Authorization", "OAuth someAccessToken")) .andRespond(withSuccess(jsonResource("new-user-likes"), MediaType.APPLICATION_JSON)); List likes = facebook.likeOperations().getTelevision("123456789", PAGING_PARAMS_25_50); @@ -322,7 +322,7 @@ public void getTelevision_forSpecificUser_unauthorized() { @Test public void getActivities() { - mockServer.expect(requestTo("https://graph.facebook.com/v2.2/me/activities?fields=id%2Cname%2Ccategory%2Cdescription%2Clocation%2Cwebsite%2Cpicture%2Cphone%2Caffiliation%2Ccompany_overview%2Clikes%2Ccheckins%2Ccover")).andExpect(method(GET)) + mockServer.expect(requestTo(getGraphApiUrl() + "me/activities?fields=id%2Cname%2Ccategory%2Cdescription%2Clocation%2Cwebsite%2Cpicture%2Cphone%2Caffiliation%2Ccompany_overview%2Clikes%2Ccheckins%2Ccover")).andExpect(method(GET)) .andExpect(header("Authorization", "OAuth someAccessToken")) .andRespond(withSuccess(jsonResource("new-user-likes"), MediaType.APPLICATION_JSON)); List likes = facebook.likeOperations().getActivities(); @@ -331,7 +331,7 @@ public void getActivities() { @Test public void getActivities_withPagingParameters() { - mockServer.expect(requestTo("https://graph.facebook.com/v2.2/me/activities?limit=25&offset=50&fields=id%2Cname%2Ccategory%2Cdescription%2Clocation%2Cwebsite%2Cpicture%2Cphone%2Caffiliation%2Ccompany_overview%2Clikes%2Ccheckins%2Ccover")).andExpect(method(GET)) + mockServer.expect(requestTo(getGraphApiUrl() + "me/activities?limit=25&offset=50&fields=id%2Cname%2Ccategory%2Cdescription%2Clocation%2Cwebsite%2Cpicture%2Cphone%2Caffiliation%2Ccompany_overview%2Clikes%2Ccheckins%2Ccover")).andExpect(method(GET)) .andExpect(header("Authorization", "OAuth someAccessToken")) .andRespond(withSuccess(jsonResource("new-user-likes"), MediaType.APPLICATION_JSON)); List likes = facebook.likeOperations().getActivities(PAGING_PARAMS_25_50); @@ -345,7 +345,7 @@ public void getActivities_unauthorized() { @Test public void getActivities_forSpecificUser() { - mockServer.expect(requestTo("https://graph.facebook.com/v2.2/123456789/activities?fields=id%2Cname%2Ccategory%2Cdescription%2Clocation%2Cwebsite%2Cpicture%2Cphone%2Caffiliation%2Ccompany_overview%2Clikes%2Ccheckins%2Ccover")).andExpect(method(GET)) + mockServer.expect(requestTo(getGraphApiUrl() + "123456789/activities?fields=id%2Cname%2Ccategory%2Cdescription%2Clocation%2Cwebsite%2Cpicture%2Cphone%2Caffiliation%2Ccompany_overview%2Clikes%2Ccheckins%2Ccover")).andExpect(method(GET)) .andExpect(header("Authorization", "OAuth someAccessToken")) .andRespond(withSuccess(jsonResource("new-user-likes"), MediaType.APPLICATION_JSON)); List likes = facebook.likeOperations().getActivities("123456789"); @@ -354,7 +354,7 @@ public void getActivities_forSpecificUser() { @Test public void getActivities_forSpecificUser_withPagingParameters() { - mockServer.expect(requestTo("https://graph.facebook.com/v2.2/123456789/activities?limit=25&offset=50&fields=id%2Cname%2Ccategory%2Cdescription%2Clocation%2Cwebsite%2Cpicture%2Cphone%2Caffiliation%2Ccompany_overview%2Clikes%2Ccheckins%2Ccover")).andExpect(method(GET)) + mockServer.expect(requestTo(getGraphApiUrl() + "123456789/activities?limit=25&offset=50&fields=id%2Cname%2Ccategory%2Cdescription%2Clocation%2Cwebsite%2Cpicture%2Cphone%2Caffiliation%2Ccompany_overview%2Clikes%2Ccheckins%2Ccover")).andExpect(method(GET)) .andExpect(header("Authorization", "OAuth someAccessToken")) .andRespond(withSuccess(jsonResource("new-user-likes"), MediaType.APPLICATION_JSON)); List likes = facebook.likeOperations().getActivities("123456789", PAGING_PARAMS_25_50); @@ -368,7 +368,7 @@ public void getActivities_forSpecificUser_unauthorized() { @Test public void getInterests() { - mockServer.expect(requestTo("https://graph.facebook.com/v2.2/me/interests?fields=id%2Cname%2Ccategory%2Cdescription%2Clocation%2Cwebsite%2Cpicture%2Cphone%2Caffiliation%2Ccompany_overview%2Clikes%2Ccheckins%2Ccover")).andExpect(method(GET)) + mockServer.expect(requestTo(getGraphApiUrl() + "me/interests?fields=id%2Cname%2Ccategory%2Cdescription%2Clocation%2Cwebsite%2Cpicture%2Cphone%2Caffiliation%2Ccompany_overview%2Clikes%2Ccheckins%2Ccover")).andExpect(method(GET)) .andExpect(header("Authorization", "OAuth someAccessToken")) .andRespond(withSuccess(jsonResource("new-user-likes"), MediaType.APPLICATION_JSON)); List likes = facebook.likeOperations().getInterests(); @@ -377,7 +377,7 @@ public void getInterests() { @Test public void getInterests_withPagingParameters() { - mockServer.expect(requestTo("https://graph.facebook.com/v2.2/me/interests?limit=25&offset=50&fields=id%2Cname%2Ccategory%2Cdescription%2Clocation%2Cwebsite%2Cpicture%2Cphone%2Caffiliation%2Ccompany_overview%2Clikes%2Ccheckins%2Ccover")).andExpect(method(GET)) + mockServer.expect(requestTo(getGraphApiUrl() + "me/interests?limit=25&offset=50&fields=id%2Cname%2Ccategory%2Cdescription%2Clocation%2Cwebsite%2Cpicture%2Cphone%2Caffiliation%2Ccompany_overview%2Clikes%2Ccheckins%2Ccover")).andExpect(method(GET)) .andExpect(header("Authorization", "OAuth someAccessToken")) .andRespond(withSuccess(jsonResource("new-user-likes"), MediaType.APPLICATION_JSON)); List likes = facebook.likeOperations().getInterests(PAGING_PARAMS_25_50); @@ -391,7 +391,7 @@ public void getInterests_unauthorized() { @Test public void getInterests_forSpecificUser() { - mockServer.expect(requestTo("https://graph.facebook.com/v2.2/123456789/interests?fields=id%2Cname%2Ccategory%2Cdescription%2Clocation%2Cwebsite%2Cpicture%2Cphone%2Caffiliation%2Ccompany_overview%2Clikes%2Ccheckins%2Ccover")).andExpect(method(GET)) + mockServer.expect(requestTo(getGraphApiUrl() + "123456789/interests?fields=id%2Cname%2Ccategory%2Cdescription%2Clocation%2Cwebsite%2Cpicture%2Cphone%2Caffiliation%2Ccompany_overview%2Clikes%2Ccheckins%2Ccover")).andExpect(method(GET)) .andExpect(header("Authorization", "OAuth someAccessToken")) .andRespond(withSuccess(jsonResource("new-user-likes"), MediaType.APPLICATION_JSON)); List likes = facebook.likeOperations().getInterests("123456789"); @@ -400,7 +400,7 @@ public void getInterests_forSpecificUser() { @Test public void getInterests_forSpecificUser_withPagingParameters() { - mockServer.expect(requestTo("https://graph.facebook.com/v2.2/123456789/interests?limit=25&offset=50&fields=id%2Cname%2Ccategory%2Cdescription%2Clocation%2Cwebsite%2Cpicture%2Cphone%2Caffiliation%2Ccompany_overview%2Clikes%2Ccheckins%2Ccover")).andExpect(method(GET)) + mockServer.expect(requestTo(getGraphApiUrl() + "123456789/interests?limit=25&offset=50&fields=id%2Cname%2Ccategory%2Cdescription%2Clocation%2Cwebsite%2Cpicture%2Cphone%2Caffiliation%2Ccompany_overview%2Clikes%2Ccheckins%2Ccover")).andExpect(method(GET)) .andExpect(header("Authorization", "OAuth someAccessToken")) .andRespond(withSuccess(jsonResource("new-user-likes"), MediaType.APPLICATION_JSON)); List likes = facebook.likeOperations().getInterests("123456789", PAGING_PARAMS_25_50); @@ -414,7 +414,7 @@ public void getInterests_forSpecificUser_unauthorized() { @Test public void getGames() { - mockServer.expect(requestTo("https://graph.facebook.com/v2.2/me/games?fields=id%2Cname%2Ccategory%2Cdescription%2Clocation%2Cwebsite%2Cpicture%2Cphone%2Caffiliation%2Ccompany_overview%2Clikes%2Ccheckins%2Ccover")).andExpect(method(GET)) + mockServer.expect(requestTo(getGraphApiUrl() + "me/games?fields=id%2Cname%2Ccategory%2Cdescription%2Clocation%2Cwebsite%2Cpicture%2Cphone%2Caffiliation%2Ccompany_overview%2Clikes%2Ccheckins%2Ccover")).andExpect(method(GET)) .andExpect(header("Authorization", "OAuth someAccessToken")) .andRespond(withSuccess(jsonResource("games"), MediaType.APPLICATION_JSON)); List likes = facebook.likeOperations().getGames(); @@ -423,7 +423,7 @@ public void getGames() { @Test public void getGames_withPagingParameters() { - mockServer.expect(requestTo("https://graph.facebook.com/v2.2/me/games?limit=25&offset=50&fields=id%2Cname%2Ccategory%2Cdescription%2Clocation%2Cwebsite%2Cpicture%2Cphone%2Caffiliation%2Ccompany_overview%2Clikes%2Ccheckins%2Ccover")).andExpect(method(GET)) + mockServer.expect(requestTo(getGraphApiUrl() + "me/games?limit=25&offset=50&fields=id%2Cname%2Ccategory%2Cdescription%2Clocation%2Cwebsite%2Cpicture%2Cphone%2Caffiliation%2Ccompany_overview%2Clikes%2Ccheckins%2Ccover")).andExpect(method(GET)) .andExpect(header("Authorization", "OAuth someAccessToken")) .andRespond(withSuccess(jsonResource("games"), MediaType.APPLICATION_JSON)); List likes = facebook.likeOperations().getGames(PAGING_PARAMS_25_50); @@ -437,7 +437,7 @@ public void getGames_unauthorized() { @Test public void getGames_forSpecificUser() { - mockServer.expect(requestTo("https://graph.facebook.com/v2.2/123456789/games?fields=id%2Cname%2Ccategory%2Cdescription%2Clocation%2Cwebsite%2Cpicture%2Cphone%2Caffiliation%2Ccompany_overview%2Clikes%2Ccheckins%2Ccover")).andExpect(method(GET)) + mockServer.expect(requestTo(getGraphApiUrl() + "123456789/games?fields=id%2Cname%2Ccategory%2Cdescription%2Clocation%2Cwebsite%2Cpicture%2Cphone%2Caffiliation%2Ccompany_overview%2Clikes%2Ccheckins%2Ccover")).andExpect(method(GET)) .andExpect(header("Authorization", "OAuth someAccessToken")) .andRespond(withSuccess(jsonResource("games"), MediaType.APPLICATION_JSON)); List likes = facebook.likeOperations().getGames("123456789"); @@ -446,7 +446,7 @@ public void getGames_forSpecificUser() { @Test public void getGames_forSpecificUser_withPagingParameters() { - mockServer.expect(requestTo("https://graph.facebook.com/v2.2/123456789/games?limit=25&offset=50&fields=id%2Cname%2Ccategory%2Cdescription%2Clocation%2Cwebsite%2Cpicture%2Cphone%2Caffiliation%2Ccompany_overview%2Clikes%2Ccheckins%2Ccover")).andExpect(method(GET)) + mockServer.expect(requestTo(getGraphApiUrl() + "123456789/games?limit=25&offset=50&fields=id%2Cname%2Ccategory%2Cdescription%2Clocation%2Cwebsite%2Cpicture%2Cphone%2Caffiliation%2Ccompany_overview%2Clikes%2Ccheckins%2Ccover")).andExpect(method(GET)) .andExpect(header("Authorization", "OAuth someAccessToken")) .andRespond(withSuccess(jsonResource("games"), MediaType.APPLICATION_JSON)); List likes = facebook.likeOperations().getGames("123456789", PAGING_PARAMS_25_50); diff --git a/spring-social-facebook/src/test/java/org/springframework/social/facebook/api/MediaTemplateTest.java b/spring-social-facebook/src/test/java/org/springframework/social/facebook/api/MediaTemplateTest.java index b4d613ce7..f74056cbd 100644 --- a/spring-social-facebook/src/test/java/org/springframework/social/facebook/api/MediaTemplateTest.java +++ b/spring-social-facebook/src/test/java/org/springframework/social/facebook/api/MediaTemplateTest.java @@ -33,7 +33,7 @@ public class MediaTemplateTest extends AbstractFacebookApiTest { @Test public void getAlbums() { - mockServer.expect(requestTo("https://graph.facebook.com/v2.2/me/albums?offset=0&limit=25")) + mockServer.expect(requestTo(getGraphApiUrl() + "me/albums?offset=0&limit=25")) .andExpect(method(GET)) .andExpect(header("Authorization", "OAuth someAccessToken")) .andRespond(withSuccess(jsonResource("albums"), MediaType.APPLICATION_JSON)); @@ -48,7 +48,7 @@ public void getAlbums_unauthorized() { @Test public void getAlbums_forSpecificUser() { - mockServer.expect(requestTo("https://graph.facebook.com/v2.2/192837465/albums?offset=0&limit=25")) + mockServer.expect(requestTo(getGraphApiUrl() + "192837465/albums?offset=0&limit=25")) .andExpect(method(GET)) .andExpect(header("Authorization", "OAuth someAccessToken")) .andRespond(withSuccess(jsonResource("albums"), MediaType.APPLICATION_JSON)); @@ -59,7 +59,7 @@ public void getAlbums_forSpecificUser() { @Test public void getAlbums_forSpecificUser_unauthorized() { try { - unauthorizedMockServer.expect(requestTo("https://graph.facebook.com/v2.2/192837465/albums?offset=0&limit=25")) + unauthorizedMockServer.expect(requestTo(getGraphApiUrl() + "192837465/albums?offset=0&limit=25")) .andExpect(method(GET)) .andRespond(withSuccess(jsonResource("albums"), MediaType.APPLICATION_JSON)); unauthorizedFacebook.mediaOperations().getAlbums("192837465"); @@ -70,7 +70,7 @@ public void getAlbums_forSpecificUser_unauthorized() { @Test public void getAlbum() { - mockServer.expect(requestTo("https://graph.facebook.com/v2.2/10151447271460580")) + mockServer.expect(requestTo(getGraphApiUrl() + "10151447271460580")) .andExpect(method(GET)) .andExpect(header("Authorization", "OAuth someAccessToken")) .andRespond(withSuccess(jsonResource("album"), MediaType.APPLICATION_JSON)); @@ -80,7 +80,7 @@ public void getAlbum() { @Test public void getAlbumWithUnknownPrivacy() { - mockServer.expect(requestTo("https://graph.facebook.com/v2.2/10151447271460580")) + mockServer.expect(requestTo(getGraphApiUrl() + "10151447271460580")) .andExpect(method(GET)) .andExpect(header("Authorization", "OAuth someAccessToken")) .andRespond(withSuccess(jsonResource("album-with-unknown-privacy"), MediaType.APPLICATION_JSON)); @@ -90,7 +90,7 @@ public void getAlbumWithUnknownPrivacy() { @Test public void getAlbumWithUnknownType() { - mockServer.expect(requestTo("https://graph.facebook.com/v2.2/10151447271460580")) + mockServer.expect(requestTo(getGraphApiUrl() + "10151447271460580")) .andExpect(method(GET)) .andExpect(header("Authorization", "OAuth someAccessToken")) .andRespond(withSuccess(jsonResource("album-with-unknown-type"), MediaType.APPLICATION_JSON)); @@ -100,7 +100,7 @@ public void getAlbumWithUnknownType() { @Test public void getPhotos() { - mockServer.expect(requestTo("https://graph.facebook.com/v2.2/10151447271460580/photos?offset=0&limit=25")) + mockServer.expect(requestTo(getGraphApiUrl() + "10151447271460580/photos?offset=0&limit=25")) .andExpect(method(GET)) .andExpect(header("Authorization", "OAuth someAccessToken")) .andRespond(withSuccess(jsonResource("photos"), MediaType.APPLICATION_JSON)); @@ -112,7 +112,7 @@ public void getPhotos() { @Test public void getPhotos_unauthorized() { try { - unauthorizedMockServer.expect(requestTo("https://graph.facebook.com/v2.2/192837465/photos?offset=0&limit=25")) + unauthorizedMockServer.expect(requestTo(getGraphApiUrl() + "192837465/photos?offset=0&limit=25")) .andExpect(method(GET)) .andRespond(withSuccess(jsonResource("photos"), MediaType.APPLICATION_JSON)); unauthorizedFacebook.mediaOperations().getPhotos("192837465"); @@ -123,7 +123,7 @@ public void getPhotos_unauthorized() { @Test public void getPhoto() { - mockServer.expect(requestTo("https://graph.facebook.com/v2.2/10150447271355581")) + mockServer.expect(requestTo(getGraphApiUrl() + "10150447271355581")) .andExpect(method(GET)) .andExpect(header("Authorization", "OAuth someAccessToken")) .andRespond(withSuccess(jsonResource("photo"), MediaType.APPLICATION_JSON)); @@ -133,7 +133,7 @@ public void getPhoto() { @Test public void getPhoto_unauthorized() { try { - unauthorizedMockServer.expect(requestTo("https://graph.facebook.com/v2.2/10150447271355581")) + unauthorizedMockServer.expect(requestTo(getGraphApiUrl() + "10150447271355581")) .andExpect(method(GET)) .andRespond(withSuccess(jsonResource("photo"), MediaType.APPLICATION_JSON)); unauthorizedFacebook.mediaOperations().getPhoto("10150447271355581"); @@ -145,7 +145,7 @@ public void getPhoto_unauthorized() { @Test public void postPhoto_noCaption() { - mockServer.expect(requestTo("https://graph.facebook.com/v2.2/me/photos")) + mockServer.expect(requestTo(getGraphApiUrl() + "me/photos")) .andExpect(method(POST)) .andExpect(header("Authorization", "OAuth someAccessToken")) .andRespond(withSuccess("{\"id\":\"12345\"}", MediaType.APPLICATION_JSON)); @@ -162,7 +162,7 @@ public void postPhoto_noCaption_unauthorized() { @Test public void postPhoto_withCaption() { - mockServer.expect(requestTo("https://graph.facebook.com/v2.2/me/photos")) + mockServer.expect(requestTo(getGraphApiUrl() + "me/photos")) .andExpect(method(POST)) .andExpect(header("Authorization", "OAuth someAccessToken")) .andRespond(withSuccess("{\"id\":\"12345\"}", MediaType.APPLICATION_JSON)); @@ -179,7 +179,7 @@ public void postPhoto_withCaption_unauthorized() { @Test public void postPhoto_ToAlbumNoCaption() { - mockServer.expect(requestTo("https://graph.facebook.com/v2.2/192837465/photos")) + mockServer.expect(requestTo(getGraphApiUrl() + "192837465/photos")) .andExpect(method(POST)) .andExpect(header("Authorization", "OAuth someAccessToken")) .andRespond(withSuccess("{\"id\":\"12345\"}", MediaType.APPLICATION_JSON)); @@ -196,7 +196,7 @@ public void postPhoto_ToAlbumNoCaption_unauthorized() { @Test public void postPhoto_ToAlbumWithCaption() { - mockServer.expect(requestTo("https://graph.facebook.com/v2.2/192837465/photos")) + mockServer.expect(requestTo(getGraphApiUrl() + "192837465/photos")) .andExpect(method(POST)) .andExpect(header("Authorization", "OAuth someAccessToken")) .andRespond(withSuccess("{\"id\":\"12345\"}", MediaType.APPLICATION_JSON)); @@ -213,7 +213,7 @@ public void postPhoto_ToAlbumWithCaption_unauthorized() { @Test public void getVideos() { - mockServer.expect(requestTo("https://graph.facebook.com/v2.2/me/videos?offset=0&limit=25")) + mockServer.expect(requestTo(getGraphApiUrl() + "me/videos?offset=0&limit=25")) .andExpect(method(GET)) .andExpect(header("Authorization", "OAuth someAccessToken")) .andRespond(withSuccess(jsonResource("videos"), MediaType.APPLICATION_JSON)); @@ -228,7 +228,7 @@ public void getVideos_unauthorized() { @Test public void getVideos_forSpecificOwner() { - mockServer.expect(requestTo("https://graph.facebook.com/v2.2/100001387295207/videos?offset=0&limit=25")) + mockServer.expect(requestTo(getGraphApiUrl() + "100001387295207/videos?offset=0&limit=25")) .andExpect(method(GET)) .andExpect(header("Authorization", "OAuth someAccessToken")) .andRespond(withSuccess(jsonResource("videos"), MediaType.APPLICATION_JSON)); @@ -243,7 +243,7 @@ public void getVideos_forSpecificOwner_unauthorized() { @Test public void getVideo_preOctober2012() { - mockServer.expect(requestTo("https://graph.facebook.com/v2.2/161500020572907")) + mockServer.expect(requestTo(getGraphApiUrl() + "161500020572907")) .andExpect(method(GET)) .andExpect(header("Authorization", "OAuth someAccessToken")) .andRespond(withSuccess(jsonResource("video_preOct2012"), MediaType.APPLICATION_JSON)); @@ -253,7 +253,7 @@ public void getVideo_preOctober2012() { @Test public void getVideo() { - mockServer.expect(requestTo("https://graph.facebook.com/v2.2/161500020572907")) + mockServer.expect(requestTo(getGraphApiUrl() + "161500020572907")) .andExpect(method(GET)) .andExpect(header("Authorization", "OAuth someAccessToken")) .andRespond(withSuccess(jsonResource("video"), MediaType.APPLICATION_JSON)); diff --git a/spring-social-facebook/src/test/java/org/springframework/social/facebook/api/MusicActionsTemplateTest.java b/spring-social-facebook/src/test/java/org/springframework/social/facebook/api/MusicActionsTemplateTest.java index dfa6aba9a..7bc944d56 100644 --- a/spring-social-facebook/src/test/java/org/springframework/social/facebook/api/MusicActionsTemplateTest.java +++ b/spring-social-facebook/src/test/java/org/springframework/social/facebook/api/MusicActionsTemplateTest.java @@ -27,7 +27,7 @@ public class MusicActionsTemplateTest extends AbstractFacebookApiTest { @Test public void listenToSong() throws Exception { - mockServer.expect(requestTo("https://graph.facebook.com/v2.2/me/music.listens")) + mockServer.expect(requestTo(getGraphApiUrl() + "me/music.listens")) .andExpect(method(POST)) .andExpect(content().string("song=http%3A%2F%2Fsamples.ogp.me%2F226075010839791")) .andExpect(header("Authorization", "OAuth someAccessToken")) @@ -39,7 +39,7 @@ public void listenToSong() throws Exception { @Test public void listenToAlbum() throws Exception { - mockServer.expect(requestTo("https://graph.facebook.com/v2.2/me/music.listens")) + mockServer.expect(requestTo(getGraphApiUrl() + "me/music.listens")) .andExpect(method(POST)) .andExpect(content().string("album=http%3A%2F%2Fsamples.ogp.me%2F226075010839791")) .andExpect(header("Authorization", "OAuth someAccessToken")) @@ -51,7 +51,7 @@ public void listenToAlbum() throws Exception { @Test public void listenToRadioStation() throws Exception { - mockServer.expect(requestTo("https://graph.facebook.com/v2.2/me/music.listens")) + mockServer.expect(requestTo(getGraphApiUrl() + "me/music.listens")) .andExpect(method(POST)) .andExpect(content().string("radio_station=http%3A%2F%2Fsamples.ogp.me%2F226075010839791")) .andExpect(header("Authorization", "OAuth someAccessToken")) @@ -63,7 +63,7 @@ public void listenToRadioStation() throws Exception { @Test public void listenToMusician() throws Exception { - mockServer.expect(requestTo("https://graph.facebook.com/v2.2/me/music.listens")) + mockServer.expect(requestTo(getGraphApiUrl() + "me/music.listens")) .andExpect(method(POST)) .andExpect(content().string("musician=http%3A%2F%2Fsamples.ogp.me%2F226075010839791")) .andExpect(header("Authorization", "OAuth someAccessToken")) @@ -75,7 +75,7 @@ public void listenToMusician() throws Exception { @Test public void listenToPlaylist() throws Exception { - mockServer.expect(requestTo("https://graph.facebook.com/v2.2/me/music.listens")) + mockServer.expect(requestTo(getGraphApiUrl() + "me/music.listens")) .andExpect(method(POST)) .andExpect(content().string("playlist=http%3A%2F%2Fsamples.ogp.me%2F226075010839791")) .andExpect(header("Authorization", "OAuth someAccessToken")) @@ -87,7 +87,7 @@ public void listenToPlaylist() throws Exception { @Test public void createPlaylist() throws Exception { - mockServer.expect(requestTo("https://graph.facebook.com/v2.2/me/music.playlists")) + mockServer.expect(requestTo(getGraphApiUrl() + "me/music.playlists")) .andExpect(method(POST)) .andExpect(content().string("playlist=http%3A%2F%2Fsamples.ogp.me%2F226075010839791")) .andExpect(header("Authorization", "OAuth someAccessToken")) diff --git a/spring-social-facebook/src/test/java/org/springframework/social/facebook/api/OpenGraphTemplateTest.java b/spring-social-facebook/src/test/java/org/springframework/social/facebook/api/OpenGraphTemplateTest.java index d29346af5..d0f5b127f 100644 --- a/spring-social-facebook/src/test/java/org/springframework/social/facebook/api/OpenGraphTemplateTest.java +++ b/spring-social-facebook/src/test/java/org/springframework/social/facebook/api/OpenGraphTemplateTest.java @@ -37,7 +37,7 @@ protected FacebookTemplate createFacebookTemplate() { @Test public void publishAction() { - mockServer.expect(requestTo("https://graph.facebook.com/v2.2/me/socialshowcase:ding")) + mockServer.expect(requestTo(getGraphApiUrl() + "me/socialshowcase:ding")) .andExpect(method(POST)) .andExpect(content().string("thing=http%3A%2F%2Fwww.springsource.org%2Fspringsocial")) .andExpect(header("Authorization", "OAuth someAccessToken")) diff --git a/spring-social-facebook/src/test/java/org/springframework/social/facebook/api/PageTemplateTest.java b/spring-social-facebook/src/test/java/org/springframework/social/facebook/api/PageTemplateTest.java index ffccbf893..4163ef44d 100644 --- a/spring-social-facebook/src/test/java/org/springframework/social/facebook/api/PageTemplateTest.java +++ b/spring-social-facebook/src/test/java/org/springframework/social/facebook/api/PageTemplateTest.java @@ -38,7 +38,7 @@ public class PageTemplateTest extends AbstractFacebookApiTest { @Test @SuppressWarnings("deprecation") public void getPage_organization() { - mockServer.expect(requestTo("https://graph.facebook.com/v2.2/140804655931206")) + mockServer.expect(requestTo(getGraphApiUrl() + "140804655931206")) .andExpect(method(GET)) .andExpect(header("Authorization", "OAuth someAccessToken")) .andRespond(withSuccess(jsonResource("organization-page"), MediaType.APPLICATION_JSON)); @@ -62,7 +62,7 @@ public void getPage_organization() { @Test @SuppressWarnings("deprecation") public void getPage_product() { - mockServer.expect(requestTo("https://graph.facebook.com/v2.2/21278871488")) + mockServer.expect(requestTo(getGraphApiUrl() + "21278871488")) .andExpect(method(GET)) .andExpect(header("Authorization", "OAuth someAccessToken")) .andRespond(withSuccess(jsonResource("product-page"), MediaType.APPLICATION_JSON)); @@ -91,7 +91,7 @@ public void getPage_product() { @Test @SuppressWarnings("deprecation") public void getPage_place() { - mockServer.expect(requestTo("https://graph.facebook.com/v2.2/150263434985489")) + mockServer.expect(requestTo(getGraphApiUrl() + "150263434985489")) .andExpect(method(GET)) .andExpect(header("Authorization", "OAuth someAccessToken")) .andRespond(withSuccess(jsonResource("place-page"), MediaType.APPLICATION_JSON)); @@ -132,7 +132,7 @@ public void getPage_place() { @Test @SuppressWarnings("deprecation") public void getPage_place_with_hours() { - mockServer.expect(requestTo("https://graph.facebook.com/v2.2/220817147947513")) + mockServer.expect(requestTo(getGraphApiUrl() + "220817147947513")) .andExpect(method(GET)) .andExpect(header("Authorization", "OAuth someAccessToken")) .andRespond(withSuccess(jsonResource("place-with-hours-page"), MediaType.APPLICATION_JSON)); @@ -175,7 +175,7 @@ public void getPage_place_with_hours() { @Test public void getPage_application() { - mockServer.expect(requestTo("https://graph.facebook.com/v2.2/140372495981006")) + mockServer.expect(requestTo(getGraphApiUrl() + "140372495981006")) .andExpect(method(GET)) .andExpect(header("Authorization", "OAuth someAccessToken")) .andRespond(withSuccess(jsonResource("application-page"), MediaType.APPLICATION_JSON)); @@ -192,7 +192,7 @@ public void getPage_application() { @SuppressWarnings("unchecked") @Test public void getPage_withExtraData() { - mockServer.expect(requestTo("https://graph.facebook.com/v2.2/11803178355")) + mockServer.expect(requestTo(getGraphApiUrl() + "11803178355")) .andExpect(method(GET)) .andExpect(header("Authorization", "OAuth someAccessToken")) .andRespond(withSuccess(jsonResource("page-with-extra-data"), MediaType.APPLICATION_JSON)); @@ -254,7 +254,7 @@ public void getAccounts() { public void post_message() throws Exception { expectFetchAccounts(); String requestBody = "message=Hello+Facebook+World&access_token=pageAccessToken"; - mockServer.expect(requestTo("https://graph.facebook.com/v2.2/987654321/feed")) + mockServer.expect(requestTo(getGraphApiUrl() + "987654321/feed")) .andExpect(method(POST)) .andExpect(header("Authorization", "OAuth someAccessToken")) .andExpect(content().string(requestBody)) @@ -278,7 +278,7 @@ public void postMessage_unauthorized() { public void postLink() throws Exception { expectFetchAccounts(); 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/v2.2/987654321/feed")).andExpect(method(POST)) + mockServer.expect(requestTo(getGraphApiUrl() + "987654321/feed")).andExpect(method(POST)) .andExpect(header("Authorization", "OAuth someAccessToken")) .andExpect(content().string(requestBody)) .andRespond(withSuccess("{\"id\":\"123456_78901234\"}", MediaType.APPLICATION_JSON)); @@ -291,7 +291,7 @@ public void postLink() throws Exception { public void postLink_withPicture() throws Exception { expectFetchAccounts(); String requestBody = "link=someLink&name=some+name&caption=some+caption&description=some+description&message=Hello+Facebook+World&access_token=pageAccessToken&picture=somePic"; - mockServer.expect(requestTo("https://graph.facebook.com/v2.2/987654321/feed")).andExpect(method(POST)) + mockServer.expect(requestTo(getGraphApiUrl() + "987654321/feed")).andExpect(method(POST)) .andExpect(header("Authorization", "OAuth someAccessToken")) .andExpect(content().string(requestBody)) .andRespond(withSuccess("{\"id\":\"123456_78901234\"}", MediaType.APPLICATION_JSON)); @@ -316,7 +316,7 @@ public void postLink_unauthorized() { @Test public void postPhoto_noCaption() { expectFetchAccounts(); - mockServer.expect(requestTo("https://graph.facebook.com/v2.2/192837465/photos")) + mockServer.expect(requestTo(getGraphApiUrl() + "192837465/photos")) .andExpect(method(POST)) .andExpect(header("Authorization", "OAuth someAccessToken")) .andRespond(withSuccess("{\"id\":\"12345\"}", MediaType.APPLICATION_JSON)); @@ -334,7 +334,7 @@ public void postPhoto_noCaption_unauthorized() { @Test public void postPhoto_withCaption() { expectFetchAccounts(); - mockServer.expect(requestTo("https://graph.facebook.com/v2.2/192837465/photos")) + mockServer.expect(requestTo(getGraphApiUrl() + "192837465/photos")) .andExpect(method(POST)) .andExpect(header("Authorization", "OAuth someAccessToken")) .andRespond(withSuccess("{\"id\":\"12345\"}", MediaType.APPLICATION_JSON)); @@ -351,7 +351,7 @@ public void postPhoto_withCaption_unauthorized() { @Test public void search() { - mockServer.expect(requestTo("https://graph.facebook.com/v2.2/search?q=coffee&type=place¢er=33.050278%2C-96.745833&distance=5280")) + mockServer.expect(requestTo(getGraphApiUrl() + "search?q=coffee&type=place¢er=33.050278%2C-96.745833&distance=5280")) .andExpect(method(GET)) .andExpect(header("Authorization", "OAuth someAccessToken")) .andRespond(withSuccess(jsonResource("places-list"), MediaType.APPLICATION_JSON)); @@ -387,7 +387,7 @@ public void search_unauthorized() { // private helpers private void expectFetchAccounts() { - mockServer.expect(requestTo("https://graph.facebook.com/v2.2/me/accounts")) + mockServer.expect(requestTo(getGraphApiUrl() + "me/accounts")) .andExpect(method(GET)) .andExpect(header("Authorization", "OAuth someAccessToken")) .andRespond(withSuccess(jsonResource("accounts"), MediaType.APPLICATION_JSON)); diff --git a/spring-social-facebook/src/test/java/org/springframework/social/facebook/api/UserTemplateTest.java b/spring-social-facebook/src/test/java/org/springframework/social/facebook/api/UserTemplateTest.java index f4beadeac..0351ecb50 100644 --- a/spring-social-facebook/src/test/java/org/springframework/social/facebook/api/UserTemplateTest.java +++ b/spring-social-facebook/src/test/java/org/springframework/social/facebook/api/UserTemplateTest.java @@ -45,7 +45,7 @@ public class UserTemplateTest extends AbstractFacebookApiTest { @Test public void getUserProfile_currentUser() { - mockServer.expect(requestTo("https://graph.facebook.com/v2.2/me?fields=" + PROFILE_FIELDS)) + mockServer.expect(requestTo(getGraphApiUrl() + "me?fields=" + PROFILE_FIELDS)) .andExpect(method(GET)) .andExpect(header("Authorization", "OAuth someAccessToken")) .andRespond(withSuccess(jsonResource("full-profile"), MediaType.APPLICATION_JSON)); @@ -109,7 +109,7 @@ public void getUserProfile_currentUser_unauthorized() { @Test public void getUserProfile_specificUserByUserId() { - mockServer.expect(requestTo("https://graph.facebook.com/v2.2/123456789?fields=" + PROFILE_FIELDS)) + mockServer.expect(requestTo(getGraphApiUrl() + "123456789?fields=" + PROFILE_FIELDS)) .andExpect(method(GET)) .andExpect(header("Authorization", "OAuth someAccessToken")) .andRespond(withSuccess(jsonResource("minimal-profile"), MediaType.APPLICATION_JSON)); @@ -120,7 +120,7 @@ public void getUserProfile_specificUserByUserId() { @Test public void getUserProfile_specificUserByUserId_noMiddleName() { - mockServer.expect(requestTo("https://graph.facebook.com/v2.2/123456789?fields=" + PROFILE_FIELDS)) + mockServer.expect(requestTo(getGraphApiUrl() + "123456789?fields=" + PROFILE_FIELDS)) .andExpect(method(GET)) .andExpect(header("Authorization", "OAuth someAccessToken")) .andRespond(withSuccess(jsonResource("minimal-profile-no-middle-name"), MediaType.APPLICATION_JSON)); @@ -131,7 +131,7 @@ public void getUserProfile_specificUserByUserId_noMiddleName() { @Test public void getUserProfile_specificUserByUserId_withRealTimezone() { - mockServer.expect(requestTo("https://graph.facebook.com/v2.2/123456789?fields=" + PROFILE_FIELDS)) + mockServer.expect(requestTo(getGraphApiUrl() + "123456789?fields=" + PROFILE_FIELDS)) .andExpect(method(GET)) .andExpect(header("Authorization", "OAuth someAccessToken")) .andRespond(withSuccess(jsonResource("minimal-profile-with-timezone"), MediaType.APPLICATION_JSON)); @@ -143,7 +143,7 @@ public void getUserProfile_specificUserByUserId_withRealTimezone() { @Test public void getUserProfile_withAgeRange_13_17() { - mockServer.expect(requestTo("https://graph.facebook.com/v2.2/123456789?fields=" + PROFILE_FIELDS)) + mockServer.expect(requestTo(getGraphApiUrl() + "123456789?fields=" + PROFILE_FIELDS)) .andExpect(method(GET)) .andExpect(header("Authorization", "OAuth someAccessToken")) .andRespond(withSuccess(jsonResource("minimal-profile-with-age-range-13-17"), MediaType.APPLICATION_JSON)); @@ -156,7 +156,7 @@ public void getUserProfile_withAgeRange_13_17() { @Test public void getUserProfile_withAgeRange_18_20() { - mockServer.expect(requestTo("https://graph.facebook.com/v2.2/123456789?fields=" + PROFILE_FIELDS)) + mockServer.expect(requestTo(getGraphApiUrl() + "123456789?fields=" + PROFILE_FIELDS)) .andExpect(method(GET)) .andExpect(header("Authorization", "OAuth someAccessToken")) .andRespond(withSuccess(jsonResource("minimal-profile-with-age-range-18-20"), MediaType.APPLICATION_JSON)); @@ -169,7 +169,7 @@ public void getUserProfile_withAgeRange_18_20() { @Test public void getUserProfile_withAgeRange_21_plus() { - mockServer.expect(requestTo("https://graph.facebook.com/v2.2/123456789?fields=" + PROFILE_FIELDS)) + mockServer.expect(requestTo(getGraphApiUrl() + "123456789?fields=" + PROFILE_FIELDS)) .andExpect(method(GET)) .andExpect(header("Authorization", "OAuth someAccessToken")) .andRespond(withSuccess(jsonResource("minimal-profile-with-age-range-21-plus"), MediaType.APPLICATION_JSON)); @@ -182,7 +182,7 @@ public void getUserProfile_withAgeRange_21_plus() { @Test public void getUserProfile_withAgeRange_unknown() { - mockServer.expect(requestTo("https://graph.facebook.com/v2.2/123456789?fields=" + PROFILE_FIELDS)) + mockServer.expect(requestTo(getGraphApiUrl() + "123456789?fields=" + PROFILE_FIELDS)) .andExpect(method(GET)) .andExpect(header("Authorization", "OAuth someAccessToken")) .andRespond(withSuccess(jsonResource("minimal-profile-with-age-range-unknown"), MediaType.APPLICATION_JSON)); @@ -195,7 +195,7 @@ public void getUserProfile_withAgeRange_unknown() { @Test public void getUserProfile_withAgeRange_null() { - mockServer.expect(requestTo("https://graph.facebook.com/v2.2/123456789?fields=" + PROFILE_FIELDS)) + mockServer.expect(requestTo(getGraphApiUrl() + "123456789?fields=" + PROFILE_FIELDS)) .andExpect(method(GET)) .andExpect(header("Authorization", "OAuth someAccessToken")) .andRespond(withSuccess(jsonResource("minimal-profile"), MediaType.APPLICATION_JSON)); @@ -208,7 +208,7 @@ public void getUserProfile_withAgeRange_null() { @Test public void getUserProfileImage() { - mockServer.expect(requestTo("https://graph.facebook.com/v2.2/me/picture?type=normal")) + mockServer.expect(requestTo(getGraphApiUrl() + "me/picture?type=normal")) .andExpect(method(GET)) .andExpect(header("Authorization", "OAuth someAccessToken")) .andRespond(withSuccess(new ClassPathResource("tinyrod.jpg", getClass()), MediaType.IMAGE_JPEG)); @@ -224,7 +224,7 @@ public void getUserProfileImage_currentUser_unauthorized() { @Test public void getUserProfileImage_specificUserByUserId() { - mockServer.expect(requestTo("https://graph.facebook.com/v2.2/1234567/picture?type=normal")) + mockServer.expect(requestTo(getGraphApiUrl() + "1234567/picture?type=normal")) .andExpect(method(GET)) .andExpect(header("Authorization", "OAuth someAccessToken")) .andRespond(withSuccess(new ClassPathResource("tinyrod.jpg", getClass()), MediaType.IMAGE_JPEG)); @@ -235,7 +235,7 @@ public void getUserProfileImage_specificUserByUserId() { @Test public void getUserProfileImage_specificUserAndType() { - mockServer.expect(requestTo("https://graph.facebook.com/v2.2/1234567/picture?type=large")) + mockServer.expect(requestTo(getGraphApiUrl() + "1234567/picture?type=large")) .andExpect(method(GET)) .andExpect(header("Authorization", "OAuth someAccessToken")) .andRespond(withSuccess(new ClassPathResource("tinyrod.jpg", getClass()), MediaType.IMAGE_JPEG)); @@ -251,7 +251,7 @@ public void getUserProfileImage_currentUser_specificType_unauthorized() { @Test public void getUserPermissions() { - mockServer.expect(requestTo("https://graph.facebook.com/v2.2/me/permissions")) + mockServer.expect(requestTo(getGraphApiUrl() + "me/permissions")) .andExpect(method(GET)) .andExpect(header("Authorization", "OAuth someAccessToken")) .andRespond(withSuccess(jsonResource("user-permissions"), MediaType.APPLICATION_JSON)); @@ -270,7 +270,7 @@ public void getUserPermissions_unauthorized() { @Test public void search() { - mockServer.expect(requestTo("https://graph.facebook.com/v2.2/search?q=Michael+Scott&type=user")) + mockServer.expect(requestTo(getGraphApiUrl() + "search?q=Michael+Scott&type=user")) .andExpect(method(GET)) .andExpect(header("Authorization", "OAuth someAccessToken")) .andRespond(withSuccess(jsonResource("user-references"), MediaType.APPLICATION_JSON)); diff --git a/spring-social-facebook/src/test/java/org/springframework/social/facebook/api/VideoActionsTemplateTest.java b/spring-social-facebook/src/test/java/org/springframework/social/facebook/api/VideoActionsTemplateTest.java index 2b65f6ea6..a54ee3fda 100644 --- a/spring-social-facebook/src/test/java/org/springframework/social/facebook/api/VideoActionsTemplateTest.java +++ b/spring-social-facebook/src/test/java/org/springframework/social/facebook/api/VideoActionsTemplateTest.java @@ -27,7 +27,7 @@ public class VideoActionsTemplateTest extends AbstractFacebookApiTest { @Test public void watchMovie() throws Exception { - mockServer.expect(requestTo("https://graph.facebook.com/v2.2/me/video.watches")) + mockServer.expect(requestTo(getGraphApiUrl() + "me/video.watches")) .andExpect(method(POST)) .andExpect(content().string("movie=http%3A%2F%2Fsamples.ogp.me%2F226075010839791")) .andExpect(header("Authorization", "OAuth someAccessToken")) @@ -39,7 +39,7 @@ public void watchMovie() throws Exception { @Test public void watchTvShow() throws Exception { - mockServer.expect(requestTo("https://graph.facebook.com/v2.2/me/video.watches")) + mockServer.expect(requestTo(getGraphApiUrl() + "me/video.watches")) .andExpect(method(POST)) .andExpect(content().string("tv_show=http%3A%2F%2Fsamples.ogp.me%2F226075010839791")) .andExpect(header("Authorization", "OAuth someAccessToken")) @@ -51,7 +51,7 @@ public void watchTvShow() throws Exception { @Test public void watchTvEpisode() throws Exception { - mockServer.expect(requestTo("https://graph.facebook.com/v2.2/me/video.watches")) + mockServer.expect(requestTo(getGraphApiUrl() + "me/video.watches")) .andExpect(method(POST)) .andExpect(content().string("tv_episode=http%3A%2F%2Fsamples.ogp.me%2F226075010839791")) .andExpect(header("Authorization", "OAuth someAccessToken")) @@ -63,7 +63,7 @@ public void watchTvEpisode() throws Exception { @Test public void watchEpisode() throws Exception { - mockServer.expect(requestTo("https://graph.facebook.com/v2.2/me/video.watches")) + mockServer.expect(requestTo(getGraphApiUrl() + "me/video.watches")) .andExpect(method(POST)) .andExpect(content().string("episode=http%3A%2F%2Fsamples.ogp.me%2F226075010839791")) .andExpect(header("Authorization", "OAuth someAccessToken")) @@ -75,7 +75,7 @@ public void watchEpisode() throws Exception { @Test public void watchVideo() throws Exception { - mockServer.expect(requestTo("https://graph.facebook.com/v2.2/me/video.watches")) + mockServer.expect(requestTo(getGraphApiUrl() + "me/video.watches")) .andExpect(method(POST)) .andExpect(content().string("video=http%3A%2F%2Fsamples.ogp.me%2F226075010839791")) .andExpect(header("Authorization", "OAuth someAccessToken")) @@ -87,7 +87,7 @@ public void watchVideo() throws Exception { @Test public void rateMovie() throws Exception { - mockServer.expect(requestTo("https://graph.facebook.com/v2.2/me/video.rates")) + mockServer.expect(requestTo(getGraphApiUrl() + "me/video.rates")) .andExpect(method(POST)) .andExpect(content().string("movie=http%3A%2F%2Fsamples.ogp.me%2F226075010839791&rating%3Avalue=3.2&rating%3Ascale=5")) .andExpect(header("Authorization", "OAuth someAccessToken")) @@ -99,7 +99,7 @@ public void rateMovie() throws Exception { @Test public void rateTvShow() throws Exception { - mockServer.expect(requestTo("https://graph.facebook.com/v2.2/me/video.rates")) + mockServer.expect(requestTo(getGraphApiUrl() + "me/video.rates")) .andExpect(method(POST)) .andExpect(content().string("tv_show=http%3A%2F%2Fsamples.ogp.me%2F226075010839791&rating%3Avalue=3.2&rating%3Ascale=5")) .andExpect(header("Authorization", "OAuth someAccessToken")) @@ -111,7 +111,7 @@ public void rateTvShow() throws Exception { @Test public void rateEpisode() throws Exception { - mockServer.expect(requestTo("https://graph.facebook.com/v2.2/me/video.rates")) + mockServer.expect(requestTo(getGraphApiUrl() + "me/video.rates")) .andExpect(method(POST)) .andExpect(content().string("episode=http%3A%2F%2Fsamples.ogp.me%2F226075010839791&rating%3Avalue=3.2&rating%3Ascale=5")) .andExpect(header("Authorization", "OAuth someAccessToken")) @@ -123,7 +123,7 @@ public void rateEpisode() throws Exception { @Test public void rateVideo() throws Exception { - mockServer.expect(requestTo("https://graph.facebook.com/v2.2/me/video.rates")) + mockServer.expect(requestTo(getGraphApiUrl() + "me/video.rates")) .andExpect(method(POST)) .andExpect(content().string("other=http%3A%2F%2Fsamples.ogp.me%2F226075010839791&rating%3Avalue=3.2&rating%3Ascale=5")) .andExpect(header("Authorization", "OAuth someAccessToken")) @@ -135,7 +135,7 @@ public void rateVideo() throws Exception { @Test public void wantsToWatchMovie() throws Exception { - mockServer.expect(requestTo("https://graph.facebook.com/v2.2/me/video.wants_to_watch")) + mockServer.expect(requestTo(getGraphApiUrl() + "me/video.wants_to_watch")) .andExpect(method(POST)) .andExpect(content().string("movie=http%3A%2F%2Fsamples.ogp.me%2F226075010839791")) .andExpect(header("Authorization", "OAuth someAccessToken")) @@ -147,7 +147,7 @@ public void wantsToWatchMovie() throws Exception { @Test public void wantsToWatchTvShow() throws Exception { - mockServer.expect(requestTo("https://graph.facebook.com/v2.2/me/video.wants_to_watch")) + mockServer.expect(requestTo(getGraphApiUrl() + "me/video.wants_to_watch")) .andExpect(method(POST)) .andExpect(content().string("tv_show=http%3A%2F%2Fsamples.ogp.me%2F226075010839791")) .andExpect(header("Authorization", "OAuth someAccessToken")) @@ -159,7 +159,7 @@ public void wantsToWatchTvShow() throws Exception { @Test public void wantsToWatchEpisode() throws Exception { - mockServer.expect(requestTo("https://graph.facebook.com/v2.2/me/video.wants_to_watch")) + mockServer.expect(requestTo(getGraphApiUrl() + "me/video.wants_to_watch")) .andExpect(method(POST)) .andExpect(content().string("episode=http%3A%2F%2Fsamples.ogp.me%2F226075010839791")) .andExpect(header("Authorization", "OAuth someAccessToken")) @@ -171,7 +171,7 @@ public void wantsToWatchEpisode() throws Exception { @Test public void wantsToWatchVideo() throws Exception { - mockServer.expect(requestTo("https://graph.facebook.com/v2.2/me/video.wants_to_watch")) + mockServer.expect(requestTo(getGraphApiUrl() + "me/video.wants_to_watch")) .andExpect(method(POST)) .andExpect(content().string("other=http%3A%2F%2Fsamples.ogp.me%2F226075010839791")) .andExpect(header("Authorization", "OAuth someAccessToken")) diff --git a/spring-social-facebook/src/test/java/org/springframework/social/facebook/connect/FacebookAdapterTest.java b/spring-social-facebook/src/test/java/org/springframework/social/facebook/connect/FacebookAdapterTest.java index 948b3e457..e2b6c1a8b 100644 --- a/spring-social-facebook/src/test/java/org/springframework/social/facebook/connect/FacebookAdapterTest.java +++ b/spring-social-facebook/src/test/java/org/springframework/social/facebook/connect/FacebookAdapterTest.java @@ -52,7 +52,7 @@ public void setConnectionValues() { TestConnectionValues connectionValues = new TestConnectionValues(); apiAdapter.setConnectionValues(facebook, connectionValues); assertEquals("Craig Walls", connectionValues.getDisplayName()); - assertEquals("https://graph.facebook.com/v2.2/12345678/picture", connectionValues.getImageUrl()); + assertEquals("https://graph.facebook.com/12345678/picture", connectionValues.getImageUrl()); assertEquals("https://www.facebook.com/app_scoped_user_id/12345678/", connectionValues.getProfileUrl()); assertEquals("12345678", connectionValues.getProviderUserId()); }