@Test(expected = ExecutionException.class) public void testSetTokenWithNullConsumerKey() throws Exception { context.checking(new Expectations() { { oneOf(actionContext).getParams(); will(returnValue(new SetConsumerTokenInfoRequest(securityToken, consumerInfo, "serviceName", "tokenName", tokenInfo))); oneOf(securityToken).getAppUrl(); will(returnValue("http: oneOf(consumerMapper).execute(with(any(OAuthConsumerRequest.class))); will(returnValue(null)); } }); sut.execute(actionContext); context.assertIsSatisfied(); }
@Override public Serializable execute(final PrincipalActionContext inActionContext) throws ExecutionException { SetConsumerTokenInfoRequest request = (SetConsumerTokenInfoRequest) inActionContext.getParams(); SecurityToken securityToken = request.getSecurityToken(); TokenInfo tokenInfo = request.getTokenInfo(); OAuthConsumer consumer = consumerMapper.execute(new OAuthConsumerRequest(request.getServiceName(), securityToken.getAppUrl())); if (consumer != null) { OAuthToken token = new OAuthToken(consumer, securityToken.getViewerId(), securityToken.getOwnerId(), tokenInfo.getAccessToken(), tokenInfo.getTokenSecret()); token.setTokenExpireMillis(tokenInfo.getTokenExpireMillis()); tokenInsertMapper.execute(new PersistenceRequest<OAuthToken>(token)); } else { throw new ExecutionException("OAuth Consumer was not found"); } return null; }
SetConsumerTokenInfoExecution implements ExecutionStrategy<PrincipalActionContext> { @Override public Serializable execute(final PrincipalActionContext inActionContext) throws ExecutionException { SetConsumerTokenInfoRequest request = (SetConsumerTokenInfoRequest) inActionContext.getParams(); SecurityToken securityToken = request.getSecurityToken(); TokenInfo tokenInfo = request.getTokenInfo(); OAuthConsumer consumer = consumerMapper.execute(new OAuthConsumerRequest(request.getServiceName(), securityToken.getAppUrl())); if (consumer != null) { OAuthToken token = new OAuthToken(consumer, securityToken.getViewerId(), securityToken.getOwnerId(), tokenInfo.getAccessToken(), tokenInfo.getTokenSecret()); token.setTokenExpireMillis(tokenInfo.getTokenExpireMillis()); tokenInsertMapper.execute(new PersistenceRequest<OAuthToken>(token)); } else { throw new ExecutionException("OAuth Consumer was not found"); } return null; } }
SetConsumerTokenInfoExecution implements ExecutionStrategy<PrincipalActionContext> { @Override public Serializable execute(final PrincipalActionContext inActionContext) throws ExecutionException { SetConsumerTokenInfoRequest request = (SetConsumerTokenInfoRequest) inActionContext.getParams(); SecurityToken securityToken = request.getSecurityToken(); TokenInfo tokenInfo = request.getTokenInfo(); OAuthConsumer consumer = consumerMapper.execute(new OAuthConsumerRequest(request.getServiceName(), securityToken.getAppUrl())); if (consumer != null) { OAuthToken token = new OAuthToken(consumer, securityToken.getViewerId(), securityToken.getOwnerId(), tokenInfo.getAccessToken(), tokenInfo.getTokenSecret()); token.setTokenExpireMillis(tokenInfo.getTokenExpireMillis()); tokenInsertMapper.execute(new PersistenceRequest<OAuthToken>(token)); } else { throw new ExecutionException("OAuth Consumer was not found"); } return null; } SetConsumerTokenInfoExecution(final DomainMapper<OAuthConsumerRequest, OAuthConsumer> inConsumerMapper,
            final InsertMapper<OAuthToken> inTokenInsertMapper); }
SetConsumerTokenInfoExecution implements ExecutionStrategy<PrincipalActionContext> { @Override public Serializable execute(final PrincipalActionContext inActionContext) throws ExecutionException { SetConsumerTokenInfoRequest request = (SetConsumerTokenInfoRequest) inActionContext.getParams(); SecurityToken securityToken = request.getSecurityToken(); TokenInfo tokenInfo = request.getTokenInfo(); OAuthConsumer consumer = consumerMapper.execute(new OAuthConsumerRequest(request.getServiceName(), securityToken.getAppUrl())); if (consumer != null) { OAuthToken token = new OAuthToken(consumer, securityToken.getViewerId(), securityToken.getOwnerId(), tokenInfo.getAccessToken(), tokenInfo.getTokenSecret()); token.setTokenExpireMillis(tokenInfo.getTokenExpireMillis()); tokenInsertMapper.execute(new PersistenceRequest<OAuthToken>(token)); } else { throw new ExecutionException("OAuth Consumer was not found"); } return null; } SetConsumerTokenInfoExecution(final DomainMapper<OAuthConsumerRequest, OAuthConsumer> inConsumerMapper,
            final InsertMapper<OAuthToken> inTokenInsertMapper); @Override Serializable execute(final PrincipalActionContext inActionContext); }
SetConsumerTokenInfoExecution implements ExecutionStrategy<PrincipalActionContext> { @Override public Serializable execute(final PrincipalActionContext inActionContext) throws ExecutionException { SetConsumerTokenInfoRequest request = (SetConsumerTokenInfoRequest) inActionContext.getParams(); SecurityToken securityToken = request.getSecurityToken(); TokenInfo tokenInfo = request.getTokenInfo(); OAuthConsumer consumer = consumerMapper.execute(new OAuthConsumerRequest(request.getServiceName(), securityToken.getAppUrl())); if (consumer != null) { OAuthToken token = new OAuthToken(consumer, securityToken.getViewerId(), securityToken.getOwnerId(), tokenInfo.getAccessToken(), tokenInfo.getTokenSecret()); token.setTokenExpireMillis(tokenInfo.getTokenExpireMillis()); tokenInsertMapper.execute(new PersistenceRequest<OAuthToken>(token)); } else { throw new ExecutionException("OAuth Consumer was not found"); } return null; } SetConsumerTokenInfoExecution(final DomainMapper<OAuthConsumerRequest, OAuthConsumer> inConsumerMapper,
            final InsertMapper<OAuthToken> inTokenInsertMapper); @Override Serializable execute(final PrincipalActionContext inActionContext);  }