@Test(expected = ExecutionException.class) public void testGetTokenWithNullConsumerKey() throws Exception { context.checking(new Expectations() { { oneOf(actionContext).getParams(); will(returnValue(new GetConsumerTokenInfoRequest(securityToken, consumerInfo, "serviceName", "tokenName"))); 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 { GetConsumerTokenInfoRequest request = (GetConsumerTokenInfoRequest) inActionContext.getParams(); SecurityToken securityToken = request.getSecurityToken(); OAuthConsumer consumer = consumerMapper.execute(new OAuthConsumerRequest(request.getServiceName(), securityToken.getAppUrl())); if (consumer == null) { throw new ExecutionException("OAuth Consumer was not found"); } OAuthToken token = tokenMapper.execute(new OAuthTokenRequest(consumer, securityToken.getViewerId(), securityToken.getOwnerId())); if (token != null) { TokenInfo tokenInfo = new TokenInfo(token.getAccessToken(), token.getTokenSecret(), null, token .getTokenExpireMillis()); return new TokenInfoResponse(tokenInfo); } return null; }
GetConsumerTokenInfoExecution implements ExecutionStrategy<PrincipalActionContext> { @Override public Serializable execute(final PrincipalActionContext inActionContext) throws ExecutionException { GetConsumerTokenInfoRequest request = (GetConsumerTokenInfoRequest) inActionContext.getParams(); SecurityToken securityToken = request.getSecurityToken(); OAuthConsumer consumer = consumerMapper.execute(new OAuthConsumerRequest(request.getServiceName(), securityToken.getAppUrl())); if (consumer == null) { throw new ExecutionException("OAuth Consumer was not found"); } OAuthToken token = tokenMapper.execute(new OAuthTokenRequest(consumer, securityToken.getViewerId(), securityToken.getOwnerId())); if (token != null) { TokenInfo tokenInfo = new TokenInfo(token.getAccessToken(), token.getTokenSecret(), null, token .getTokenExpireMillis()); return new TokenInfoResponse(tokenInfo); } return null; } }
GetConsumerTokenInfoExecution implements ExecutionStrategy<PrincipalActionContext> { @Override public Serializable execute(final PrincipalActionContext inActionContext) throws ExecutionException { GetConsumerTokenInfoRequest request = (GetConsumerTokenInfoRequest) inActionContext.getParams(); SecurityToken securityToken = request.getSecurityToken(); OAuthConsumer consumer = consumerMapper.execute(new OAuthConsumerRequest(request.getServiceName(), securityToken.getAppUrl())); if (consumer == null) { throw new ExecutionException("OAuth Consumer was not found"); } OAuthToken token = tokenMapper.execute(new OAuthTokenRequest(consumer, securityToken.getViewerId(), securityToken.getOwnerId())); if (token != null) { TokenInfo tokenInfo = new TokenInfo(token.getAccessToken(), token.getTokenSecret(), null, token .getTokenExpireMillis()); return new TokenInfoResponse(tokenInfo); } return null; } GetConsumerTokenInfoExecution(final DomainMapper<OAuthConsumerRequest, OAuthConsumer> inConsumerMapper,
            final DomainMapper<OAuthTokenRequest, OAuthToken> inTokenMapper); }
GetConsumerTokenInfoExecution implements ExecutionStrategy<PrincipalActionContext> { @Override public Serializable execute(final PrincipalActionContext inActionContext) throws ExecutionException { GetConsumerTokenInfoRequest request = (GetConsumerTokenInfoRequest) inActionContext.getParams(); SecurityToken securityToken = request.getSecurityToken(); OAuthConsumer consumer = consumerMapper.execute(new OAuthConsumerRequest(request.getServiceName(), securityToken.getAppUrl())); if (consumer == null) { throw new ExecutionException("OAuth Consumer was not found"); } OAuthToken token = tokenMapper.execute(new OAuthTokenRequest(consumer, securityToken.getViewerId(), securityToken.getOwnerId())); if (token != null) { TokenInfo tokenInfo = new TokenInfo(token.getAccessToken(), token.getTokenSecret(), null, token .getTokenExpireMillis()); return new TokenInfoResponse(tokenInfo); } return null; } GetConsumerTokenInfoExecution(final DomainMapper<OAuthConsumerRequest, OAuthConsumer> inConsumerMapper,
            final DomainMapper<OAuthTokenRequest, OAuthToken> inTokenMapper); @Override Serializable execute(final PrincipalActionContext inActionContext); }
GetConsumerTokenInfoExecution implements ExecutionStrategy<PrincipalActionContext> { @Override public Serializable execute(final PrincipalActionContext inActionContext) throws ExecutionException { GetConsumerTokenInfoRequest request = (GetConsumerTokenInfoRequest) inActionContext.getParams(); SecurityToken securityToken = request.getSecurityToken(); OAuthConsumer consumer = consumerMapper.execute(new OAuthConsumerRequest(request.getServiceName(), securityToken.getAppUrl())); if (consumer == null) { throw new ExecutionException("OAuth Consumer was not found"); } OAuthToken token = tokenMapper.execute(new OAuthTokenRequest(consumer, securityToken.getViewerId(), securityToken.getOwnerId())); if (token != null) { TokenInfo tokenInfo = new TokenInfo(token.getAccessToken(), token.getTokenSecret(), null, token .getTokenExpireMillis()); return new TokenInfoResponse(tokenInfo); } return null; } GetConsumerTokenInfoExecution(final DomainMapper<OAuthConsumerRequest, OAuthConsumer> inConsumerMapper,
            final DomainMapper<OAuthTokenRequest, OAuthToken> inTokenMapper); @Override Serializable execute(final PrincipalActionContext inActionContext);  }