I got a method which includes a REST-request(Spring-Social) and i want to mock it. The thing is that i dont know how to access the call inside it or if it is possible at all. I got Mockito and PowerMock at my disposal
private FacebookConnectionFactory facebookFactory;
private OAuth2Operations authOps;
private final OAuthCredentials credentials;
...
public AccessToken exchangeAuthentication(String aCode) {
facebookFactory = getOAuthConnectionFactory();
authOps = facebookFactory.getOAuthOperations();
authPar = new OAuth2Parameters();
authPar.setRedirectUri(credentials.getFacebookRedirectURI());
authPar.setScope("email");
AccessGrant grant = authOps.exchangeForAccess(aCode, credentials.getFacebookRedirectURI(), null); // I want mock this somehow
AccessToken token = new AccessToken();
token.setAccess_token(grant.getAccessToken());
token.setExpires_in(grant.getExpireTime());
token.setToken_type("bearer");
return token;
}