OAuthApiV1 implements OAuthApi { public OAuthToken refreshAccessToken(OAuthToken token) throws Exception { List<EncodedPair> oauthPairs = oauth(variantProvider, consumerToken, token, methodType, refreshAccessTokenPath, EMPTY_HTTP_PAIRS, token.getAttribute("oauth_session_handle")); Map<String,String> params = asMap(oauthPairs); return oauthInterface.refreshAccessToken( params.get("oauth_token"), params.get("oauth_consumer_key"), params.get("oauth_signature_method"), params.get("oauth_timestamp"), params.get("oauth_nonce"), params.get("oauth_version"), params.get("oauth_session_handle"), params.get("oauth_signature") ); } OAuthApiV1(MethodType methodType, String oauthEndPoint, String requestTokenPath, String accessTokenPath, String refreshAccessTokenPath, OAuthInterface oauthInterface, OAuthToken consumerToken, VariantProvider variantProvider); OAuthToken getRequestToken(); OAuthToken getAccessToken(OAuthToken requestOAuthToken, String verifier); OAuthToken refreshAccessToken(OAuthToken token);  }
@Test public void shouldRefreshAnAccessTokenUsingGET() throws Exception { OAuthInterface mockOAuthInterface = mockGetOAuthInterface(); OAuthToken actual = newToTest(GET, mockOAuthInterface).refreshAccessToken(token); assertEquals(mockOAuthToken, actual); verify(mockOAuthInterface).refreshAccessToken( token.getToken(), consumerKey, signatureMethod, timestamp, nonce, version, sessionHandle, "Vy4e1G1RP2XrIQ7MVS2atACp%2FWc%3D"); }
@Test public void shouldRefreshAnAccessTokenUsingPOST() throws Exception { OAuthInterface mockOAuthInterface = mockPostOAuthInterface(); OAuthToken actual = newToTest(POST, mockOAuthInterface).refreshAccessToken(token); assertEquals(mockOAuthToken, actual); verify(mockOAuthInterface).refreshAccessToken( token.getToken(), consumerKey, signatureMethod, timestamp, nonce, version, sessionHandle, "hZmlZPXeBOZAF1oXM%2FR5IUOqPm4%3D"); }