@Test
    void verifyRedirectUrlCorrectlyEncoded() {
        val request = new MockHttpServletRequest();
        val response = new MockHttpServletResponse();
        val context = new JEEContext(request, response);

        val service = RegisteredServiceTestUtils.getService("example");
        service.setOriginalUrl("http://service.original.url.com?response_type=idtoken+token");
        val client = new CasClient(new CasConfiguration());
        client.setCustomProperties(Map.of(
            ClientCustomPropertyConstants.CLIENT_CUSTOM_PROPERTY_CSS_CLASS, "custom-class",
            ClientCustomPropertyConstants.CLIENT_CUSTOM_PROPERTY_DISPLAY_NAME, "My Great Client"));
        val factory = DelegatedClientIdentityProviderConfigurationFactory.builder()
            .casProperties(casProperties)
            .client(client)
            .service(service)
            .webContext(context)
            .build();

        val actual = factory.resolve();
        assertTrue(actual.isPresent());
        val redirectUrl = actual.get().getRedirectUrl();
        assertNotNull(redirectUrl);
        assertTrue(redirectUrl.contains(EncodingUtils.urlEncode(service.getOriginalUrl())));
    }
This is {@link DelegatedClientIdentityProviderConfigurationFactoryTests}.

@author Adrian Gonzalez
@since 6.2.0
support/cas-server-support-pac4j-core/src/test/java/org/apereo/cas/web/DelegatedClientIdentityProviderConfigurationFactoryTests.java