### Question:
TokenIssueOperationProvider implements Provider<IssueOperation> { public IssueOperation get() { try { TokenIssueOperation tokenIssueOperation = new TokenIssueOperation(); tokenIssueOperation.setEncryptIssuedToken(false); tokenIssueOperation.setStsProperties(stsPropertiesMBean); tokenIssueOperation.setTokenStore(tokenStore); tokenIssueOperation.setTokenValidators(getDelegationTokenValidators()); tokenIssueOperation.setDelegationHandlers(tokenDelegationHandlers); List<TokenProvider> tokenProviders = new ArrayList<TokenProvider>(); for(TokenType tokenType: issueTokenTypes) { tokenProviders.add(operationFactory.getTokenProvider(tokenType)); } tokenIssueOperation.setTokenProviders(tokenProviders); return new TokenIssueOperationWrapper(tokenIssueOperation, threadLocalAMTokenCache); } catch (STSInitializationException e) { logger.error("Exception caught initializing a IssueOperation: " + e, e); throw new RuntimeException(e); } } @Inject  TokenIssueOperationProvider(
            STSPropertiesMBean stsPropertiesMBean,
            TokenStore tokenStore,
            @Named(AMSTSConstants.ISSUED_TOKEN_TYPES) Set<TokenType> issueTokenTypes,
            @Named(AMSTSConstants.DELEGATED_TOKEN_VALIDATORS) Set<TokenValidationConfig> delegatedTokenValidationConfig,
            List<TokenDelegationHandler> tokenDelegationHandlers,
            TokenOperationFactory operationFactory,
            ThreadLocalAMTokenCache threadLocalAMTokenCache,
            Logger logger); IssueOperation get();  }### Answer:
@Test public void testDelegate() throws STSInitializationException { TokenOperationFactory mockOperationFactory = mock(TokenOperationFactory.class); TokenProvider mockProvider = mock(TokenProvider.class); when(mockOperationFactory.getTokenProvider(any(TokenType.class))).thenReturn(mockProvider); TokenIssueOperationProvider issueOperationProvider = Guice.createInjector(new MyModule(mockOperationFactory)).getInstance(TokenIssueOperationProvider.class); assertTrue(issueOperationProvider.get() instanceof TokenIssueOperationProvider.TokenIssueOperationWrapper); }
@Test(expectedExceptions = RuntimeException.class) public void testExceptionInitialization() throws STSInitializationException { TokenOperationFactory mockOperationFactory = mock(TokenOperationFactory.class); TokenProvider mockProvider = mock(TokenProvider.class); when(mockOperationFactory.getTokenProvider(any(TokenType.class))).thenThrow(STSInitializationException.class); TokenIssueOperationProvider issueOperationProvider = Guice.createInjector(new MyModule(mockOperationFactory)).getInstance(TokenIssueOperationProvider.class); issueOperationProvider.get(); }