### Question:
TokenOperationFactoryImpl implements TokenOperationFactory { @Override public TokenValidator getTokenValidator(TokenType validatedTokenType, ValidationInvocationContext validationInvocationContext, boolean invalidateAMSession) throws STSInitializationException { if (TokenType.OPENAM.equals(validatedTokenType)) { return buildAMTokenValidator(validationInvocationContext, invalidateAMSession); } else if (TokenType.USERNAME.equals(validatedTokenType)) { return buildUsernameTokenValidator(validationInvocationContext, invalidateAMSession); } else { throw new STSInitializationException(ResourceException.BAD_REQUEST, "In TokenOperationFactory, unknown " + "TokenType provided to obtain TokenValidator: " + validatedTokenType); } } @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 testGetUsernameTokenValidator() throws STSInitializationException { assertTrue(operationFactory.getTokenValidator(TokenType.USERNAME, ValidationInvocationContext.SOAP_SECURITY_POLICY, true) instanceof org.apache.cxf.sts.token.validator.UsernameTokenValidator); }