@BeforeEach
    void initialize() throws Throwable {
        val applicationContext = new StaticApplicationContext();
        applicationContext.refresh();

        ApplicationContextProvider.holdApplicationContext(applicationContext);
        val processor = mock(DelegatedAuthenticationPreProcessor.class);
        when(processor.process(ArgumentMatchers.any(Principal.class), ArgumentMatchers.any(), ArgumentMatchers.any(), ArgumentMatchers.any()))
            .thenAnswer(invocationOnMock -> invocationOnMock.getArgument(0, Principal.class));
        ApplicationContextProvider.registerBeanIntoApplicationContext(applicationContext,
            processor, "customDelegatedAuthenticationPreProcessor");

        fbClient = new FacebookClient();
        fbClient.setCallbackUrl(CALLBACK_URL);
        
        val factory = mock(DelegatedIdentityProviderFactory.class);
        when(factory.build()).thenReturn(List.of(fbClient));
        when(factory.rebuild()).thenReturn(List.of(fbClient));
        val clients = new DefaultDelegatedIdentityProviders(factory, mock(TenantExtractor.class));

        handler = new DelegatedClientAuthenticationHandler(new Pac4jDelegatedAuthenticationCoreProperties(),
            mock(ServicesManager.class), PrincipalFactoryUtils.newPrincipalFactory(), clients,
            DelegatedClientUserProfileProvisioner.noOp(), new JEESessionStore(), applicationContext);
        handler.setTypedIdUsed(true);

        val credentials = new OAuth20Credentials(null);
        clientCredential = new ClientCredential(credentials, fbClient.getName());
        val mock = new ServletExternalContext(new MockServletContext(),
            new MockHttpServletRequest(), new MockHttpServletResponse());
        ExternalContextHolder.setExternalContext(mock);
    }
Tests the {@link DelegatedClientAuthenticationHandler}.

@author Jerome Leleu
@since 4.1.0
support/cas-server-support-pac4j-oidc/src/test/java/org/apereo/cas/support/pac4j/authentication/handler/DelegatedClientAuthenticationHandlerTests.java