when(factory.createConnection(ArgMatchers.oAuthToken(oAuthToken))).thenReturn(connection);
when(operations.getVersion()).thenReturn(OAuth1Version.CORE_10_REVISION_A);
when(operations.fetchRequestToken("http://"+serverName+"/auth/foo?param=param_value", null)).thenReturn(oAuthToken);
when(operations.exchangeForAccessToken(ArgMatchers.authorizedRequestToken(oAuthToken, verifier), Matchers.same((MultiValueMap<String, String>) null))).thenReturn(oAuthToken);
when(operations.buildAuthenticateUrl(oAuthToken.getValue(), OAuth1Parameters.NONE)).thenReturn(serviceUrl + "?oauth_token=" + oAuthToken.getValue());
// first phase
MockHttpServletRequest request = new MockHttpServletRequest(context, "GET", "/auth/foo");
request.setServerName(serverName);
request.setSession(session);