### Question:
TokenDelegationHandlersProvider implements Provider<List<TokenDelegationHandler>> { public List<TokenDelegationHandler> get() { if (!stsInstanceConfig.delegationRelationshipsSupported()) { return Collections.emptyList(); } else { if (stsInstanceConfig.getSoapDelegationConfig().getCustomDelegationTokenHandlers().isEmpty()) { return (List) Lists.newArrayList(new DefaultTokenDelegationHandler()); } else { List customDelegationHandlers = new ArrayList<TokenDelegationHandler>(); for (String className : stsInstanceConfig.getSoapDelegationConfig().getCustomDelegationTokenHandlers()) { try { final TokenDelegationHandler customHandler = Class.forName(className).asSubclass(TokenDelegationHandler.class).newInstance(); customDelegationHandlers.add(new CustomDelegationHandlerWrapper( customHandler, threadLocalAMTokenCache, !stsInstanceConfig.getSoapDelegationConfig().getValidatedDelegatedTokenConfiguration().isEmpty(), logger)); } catch (Exception e) { logger.error("Exception caught instantiating class " + className + " as a custom TokenDelegationHandler implementation. The exception: " + e); } } return customDelegationHandlers; } } } @Inject  TokenDelegationHandlersProvider(SoapSTSInstanceConfig stsInstanceConfig, ThreadLocalAMTokenCache threadLocalAMTokenCache, Logger logger); List<TokenDelegationHandler> get();  }### Answer:
@Test public void testNoDelegationSupported() throws UnsupportedEncodingException { Logger mockLogger = mock(Logger.class); ThreadLocalAMTokenCache mockTokenCache = mock(ThreadLocalAMTokenCache.class); SoapSTSInstanceConfig instanceConfig = createInstanceConfig(!DELEGATION_VALIDATORS_SPECIFIED, !CUSTOM_DELEGATION_HANDLER); assertTrue(new TokenDelegationHandlersProvider(instanceConfig, mockTokenCache, mockLogger).get().isEmpty()); }
@Test public void testDefaultDelegationHandler() throws UnsupportedEncodingException { Logger mockLogger = mock(Logger.class); ThreadLocalAMTokenCache mockTokenCache = mock(ThreadLocalAMTokenCache.class); SoapSTSInstanceConfig instanceConfig = createInstanceConfig(DELEGATION_VALIDATORS_SPECIFIED, !CUSTOM_DELEGATION_HANDLER); assertTrue(new TokenDelegationHandlersProvider(instanceConfig, mockTokenCache, mockLogger).get().get(0) instanceof DefaultTokenDelegationHandler); }
@Test public void testWrappedCustomDelegationHandler() throws UnsupportedEncodingException { Logger mockLogger = mock(Logger.class); ThreadLocalAMTokenCache mockTokenCache = mock(ThreadLocalAMTokenCache.class); SoapSTSInstanceConfig instanceConfig = createInstanceConfig(!DELEGATION_VALIDATORS_SPECIFIED, CUSTOM_DELEGATION_HANDLER); assertTrue(new TokenDelegationHandlersProvider(instanceConfig, mockTokenCache, mockLogger).get().get(0) instanceof CustomDelegationHandlerWrapper); }