### Question:
TokenOperationFactoryImpl implements TokenOperationFactory { @Override public TokenProvider getTokenProvider(TokenType issuedTokenType) throws STSInitializationException{ if (TokenType.SAML2.equals(issuedTokenType)) { return SoapSamlTokenProvider.builder() .tokenGenerationServiceConsumer(tokenServiceConsumer) .amSessionInvalidator(amSessionInvalidatorProvider.get()) .threadLocalAMTokenCache(threadLocalAMTokenCache) .stsInstanceId(stsInstanceId) .realm(realm) .xmlUtilities(xmlUtilities) .authnContextMapper(saml2XmlTokenAuthnContextMapper) .soapSTSAccessTokenProvider(soapSTSAccessTokenProvider) .logger(logger) .build(); } else if (TokenType.OPENIDCONNECT.equals(issuedTokenType)) { return SoapOpenIdConnectTokenProvider.builder() .tokenGenerationServiceConsumer(tokenServiceConsumer) .amSessionInvalidator(amSessionInvalidatorProvider.get()) .threadLocalAMTokenCache(threadLocalAMTokenCache) .stsInstanceId(stsInstanceId) .realm(realm) .xmlUtilities(xmlUtilities) .soapSTSAccessTokenProvider(soapSTSAccessTokenProvider) .authenticationContextReferenceMapper(soapOpenIdConnectTokenAuthnContextMapper) .authenticationMethodsReferencesMapper(soapOpenIdConnectTokenAuthnMethodsReferencesMapper) .logger(logger) .build(); } throw new STSInitializationException(ResourceException.BAD_REQUEST, "Unhandled outputTokenType specified in " + "getTokenProviderForTransformOperation. OutputTokenType: " + issuedTokenType); } @Inject  TokenOperationFactoryImpl(
            ThreadLocalAMTokenCache threadLocalAMTokenCache,
            PrincipalFromSession principalFromSession,
            TokenServiceConsumer tokenServiceConsumer,
            @Named(AMSTSConstants.STS_INSTANCE_ID) String stsInstanceId,
            @Named (AMSTSConstants.REALM) String realm,
            XMLUtilities xmlUtilities,
            Saml2XmlTokenAuthnContextMapper saml2XmlTokenAuthnContextMapper,
            Provider<AMSessionInvalidator> amSessionInvalidatorProvider,
            SoapSTSAccessTokenProvider soapSTSAccessTokenProvider,
            AuthenticationHandler<UsernameToken> usernameTokenAuthenticationHandler,
            SoapOpenIdConnectTokenAuthnContextMapper soapOpenIdConnectTokenAuthnContextMapper,
            SoapOpenIdConnectTokenAuthnMethodsReferencesMapper soapOpenIdConnectTokenAuthnMethodsReferencesMapper,
            CTSTokenIdGenerator ctsTokenIdGenerator,
            Logger logger); @Override TokenValidator getTokenValidator(TokenType validatedTokenType, ValidationInvocationContext validationInvocationContext,
                                            boolean invalidateAMSession); @Override TokenProvider getTokenProvider(TokenType issuedTokenType); @Override TokenValidator getSimpleTokenValidator(TokenType validatedTokenType); @Override TokenCanceller getTokenCanceller(TokenType cancelledTokenType);  }### Answer:
@Test public void testProvider() throws STSInitializationException { assertTrue(operationFactory.getTokenProvider(TokenType.SAML2) instanceof SoapSamlTokenProvider); }
@Test(expectedExceptions = STSInitializationException.class) public void testNonExistentProvider() throws STSInitializationException { operationFactory.getTokenProvider(TokenType.USERNAME); }