public final void testCheckAuthorizationNoRequestToken() {
// Setup.
LoginFormHandler loginForm = mock(LoginFormHandler.class);
OAuthClient client = mock(OAuthClient.class);
PersistenceManager pm = mock(PersistenceManager.class);
PersistenceManagerFactory pmf = mock(PersistenceManagerFactory.class);
OAuthAccessor accessor = buildAccessor(CONSUMER_KEY, CONSUMER_SECRET,
REQUEST_TOKEN_URL, AUTHORIZE_URL, CALLBACK_URL, ACCESS_TOKEN_URL);
accessor.requestToken = REQUEST_TOKEN_STRING;
oauthService = new OAuthServiceImpl(accessor, client, pmf,
USER_RECORD_KEY);
OAuthUser userWithRequestToken = new OAuthUser(USER_RECORD_KEY, REQUEST_TOKEN_STRING);
// Expectations.
when(pmf.getPersistenceManager()).thenReturn(pm);
when(pm.getObjectById(OAuthUser.class, USER_RECORD_KEY)).thenReturn(null, userWithRequestToken,
userWithRequestToken);
assertFalse(oauthService.checkAuthorization(null, loginForm));