OAuthApiV1 implements OAuthApi { public OAuthToken getAccessToken(OAuthToken requestOAuthToken, String verifier) throws Exception { List<EncodedPair> oauthPairs = oauth(variantProvider, requestOAuthToken, methodType, accessTokenPath, EMPTY_HTTP_PAIRS, pair("oauth_verifier", verifier)); Map<String,String> params = asMap(oauthPairs); return oauthInterface.getAccessToken( 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_verifier"), 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 shouldGetAnAccessTokenUsingGET() throws Exception { OAuthInterface mockOAuthInterface = mockGetOAuthInterface(); OAuthToken actual = newToTest(GET, mockOAuthInterface).getAccessToken(token, verifier); assertEquals(mockOAuthToken, actual); verify(mockOAuthInterface).getAccessToken( token.getToken(), signatureMethod, timestamp, nonce, version, verifier, "rcFomzZTgPWGoiQov%2FNHOa0mvwE%3D"); }
@Test public void shouldGetAnAccessTokenUsingPOST() throws Exception { OAuthInterface mockOAuthInterface = mockPostOAuthInterface(); OAuthToken actual = newToTest(POST, mockOAuthInterface).getAccessToken(token, verifier); assertEquals(mockOAuthToken, actual); verify(mockOAuthInterface).getAccessToken( token.getToken(), signatureMethod, timestamp, nonce, version, verifier, "lkywwGVYjBtyiNRjiulpfRK2Qoo%3D"); }