@Test(expected = OAuthException.class) public void testLoadConsumerByConsumerKeyFailure() { context.checking(new Expectations() { { oneOf(actionController).execute(with(any(ServiceActionContext.class)), with(any(ServiceAction.class))); will(throwException(new Exception("Failure"))); } }); ConsumerDetails result = sut.loadConsumerByConsumerKey("KEY"); context.assertIsSatisfied(); }
@Override public ConsumerDetails loadConsumerByConsumerKey(final String inConsumerKey) throws OAuthException { try { ServiceActionContext currentContext = new ServiceActionContext(inConsumerKey, null); OAuthConsumer consumer = (OAuthConsumer) actionController.execute(currentContext, getOAuthConsumerByConsumerKeyAction); BaseConsumerDetails details = new BaseConsumerDetails(); details.setConsumerKey(inConsumerKey); details.setConsumerName(inConsumerKey); details.setSignatureSecret(new SharedConsumerSecret(consumer.consumerSecret)); details.setAuthorities(grantedAuthorities); details.setRequiredToObtainAuthenticatedToken(false); return details; } catch (Exception ex) { log.error("Error occurred retrieving consumer with provided key.", ex); throw new OAuthException("Unable to retrieve consumer with provided information."); } }
ConsumerDetailsServiceImpl implements ConsumerDetailsService { @Override public ConsumerDetails loadConsumerByConsumerKey(final String inConsumerKey) throws OAuthException { try { ServiceActionContext currentContext = new ServiceActionContext(inConsumerKey, null); OAuthConsumer consumer = (OAuthConsumer) actionController.execute(currentContext, getOAuthConsumerByConsumerKeyAction); BaseConsumerDetails details = new BaseConsumerDetails(); details.setConsumerKey(inConsumerKey); details.setConsumerName(inConsumerKey); details.setSignatureSecret(new SharedConsumerSecret(consumer.consumerSecret)); details.setAuthorities(grantedAuthorities); details.setRequiredToObtainAuthenticatedToken(false); return details; } catch (Exception ex) { log.error("Error occurred retrieving consumer with provided key.", ex); throw new OAuthException("Unable to retrieve consumer with provided information."); } } }
ConsumerDetailsServiceImpl implements ConsumerDetailsService { @Override public ConsumerDetails loadConsumerByConsumerKey(final String inConsumerKey) throws OAuthException { try { ServiceActionContext currentContext = new ServiceActionContext(inConsumerKey, null); OAuthConsumer consumer = (OAuthConsumer) actionController.execute(currentContext, getOAuthConsumerByConsumerKeyAction); BaseConsumerDetails details = new BaseConsumerDetails(); details.setConsumerKey(inConsumerKey); details.setConsumerName(inConsumerKey); details.setSignatureSecret(new SharedConsumerSecret(consumer.consumerSecret)); details.setAuthorities(grantedAuthorities); details.setRequiredToObtainAuthenticatedToken(false); return details; } catch (Exception ex) { log.error("Error occurred retrieving consumer with provided key.", ex); throw new OAuthException("Unable to retrieve consumer with provided information."); } } ConsumerDetailsServiceImpl(final ActionController inActionController,
            final ServiceAction inGetOAuthConsumerByConsumerKeyAction, final String inGrantedAuthorities); }
ConsumerDetailsServiceImpl implements ConsumerDetailsService { @Override public ConsumerDetails loadConsumerByConsumerKey(final String inConsumerKey) throws OAuthException { try { ServiceActionContext currentContext = new ServiceActionContext(inConsumerKey, null); OAuthConsumer consumer = (OAuthConsumer) actionController.execute(currentContext, getOAuthConsumerByConsumerKeyAction); BaseConsumerDetails details = new BaseConsumerDetails(); details.setConsumerKey(inConsumerKey); details.setConsumerName(inConsumerKey); details.setSignatureSecret(new SharedConsumerSecret(consumer.consumerSecret)); details.setAuthorities(grantedAuthorities); details.setRequiredToObtainAuthenticatedToken(false); return details; } catch (Exception ex) { log.error("Error occurred retrieving consumer with provided key.", ex); throw new OAuthException("Unable to retrieve consumer with provided information."); } } ConsumerDetailsServiceImpl(final ActionController inActionController,
            final ServiceAction inGetOAuthConsumerByConsumerKeyAction, final String inGrantedAuthorities); @Override ConsumerDetails loadConsumerByConsumerKey(final String inConsumerKey); }
ConsumerDetailsServiceImpl implements ConsumerDetailsService { @Override public ConsumerDetails loadConsumerByConsumerKey(final String inConsumerKey) throws OAuthException { try { ServiceActionContext currentContext = new ServiceActionContext(inConsumerKey, null); OAuthConsumer consumer = (OAuthConsumer) actionController.execute(currentContext, getOAuthConsumerByConsumerKeyAction); BaseConsumerDetails details = new BaseConsumerDetails(); details.setConsumerKey(inConsumerKey); details.setConsumerName(inConsumerKey); details.setSignatureSecret(new SharedConsumerSecret(consumer.consumerSecret)); details.setAuthorities(grantedAuthorities); details.setRequiredToObtainAuthenticatedToken(false); return details; } catch (Exception ex) { log.error("Error occurred retrieving consumer with provided key.", ex); throw new OAuthException("Unable to retrieve consumer with provided information."); } } ConsumerDetailsServiceImpl(final ActionController inActionController,
            final ServiceAction inGetOAuthConsumerByConsumerKeyAction, final String inGrantedAuthorities); @Override ConsumerDetails loadConsumerByConsumerKey(final String inConsumerKey);  }