### Question:
TokenValidateOperationProvider implements Provider<ValidateOperation> { public ValidateOperation get() { if (issuedTokensPersistedInCTS) { return getFunctionalValidateOperation(); } else { return getUnsupportedValidateOperation(); } } @Inject  TokenValidateOperationProvider(
            STSPropertiesMBean stsPropertiesMBean,
            TokenStore tokenStore,
            @Named(AMSTSConstants.ISSUED_TOKEN_TYPES) Set<TokenType> validatedTokens,
            TokenOperationFactory operationFactory,
            ThreadLocalAMTokenCache threadLocalAMTokenCache,
            @Named (AMSTSConstants.ISSUED_TOKENS_PERSISTED_IN_CTS) boolean issuedTokensPersistedInCTS); ValidateOperation get();  }### Answer:
@Test public void testDelegate() throws STSInitializationException { TokenOperationFactory mockOperationFactory = mock(TokenOperationFactory.class); TokenValidator mockValidator = mock(TokenValidator.class); when(mockOperationFactory.getTokenValidator(any(TokenType.class), any(ValidationInvocationContext.class), any(boolean.class))).thenReturn(mockValidator); TokenValidateOperationProvider validateOperationProvider = Guice.createInjector(new MyModule(mockOperationFactory)).getInstance(TokenValidateOperationProvider.class); assertTrue(validateOperationProvider.get() instanceof TokenValidateOperationProvider.TokenValidateOperationWrapper); }
@Test(expectedExceptions = RuntimeException.class) public void testExceptionInitialization() throws STSInitializationException { TokenOperationFactory mockOperationFactory = mock(TokenOperationFactory.class); when(mockOperationFactory.getSimpleTokenValidator(any(TokenType.class))).thenThrow(RuntimeException.class); TokenValidateOperationProvider validateOperationProvider = Guice.createInjector(new MyModule(mockOperationFactory)).getInstance(TokenValidateOperationProvider.class); validateOperationProvider.get(); }