@Bean
        public SecurityTokenServiceClientBuilder securityTokenServiceClientBuilder() throws Exception {
            val client = mock(SecurityTokenServiceClient.class);

            val builder = mock(SecurityTokenServiceClientBuilder.class);
            when(builder.buildClientForRelyingPartyTokenResponses(any(SecurityToken.class), any(WSFederationRegisteredService.class)))
                .thenReturn(client);
            when(client.getProperties()).thenReturn(new HashMap<>());

            val dbf = DocumentBuilderFactory.newInstance();
            val db = dbf.newDocumentBuilder();
            val elementResponse = db.newDocument().createElement("SecurityToken");
            elementResponse.setAttribute("id", "abcdefgh123456");
            when(client.requestSecurityTokenResponse(ArgumentMatchers.eq("CAS"))).thenReturn(elementResponse);
            when(client.requestSecurityTokenResponse(ArgumentMatchers.eq("FatalError")))
                .thenThrow(new SoapFault("error", Fault.FAULT_CODE_SERVER));
            when(client.requestSecurityTokenResponse(ArgumentMatchers.eq("RequestFailed")))
                .thenThrow(new SoapFault("error", new QName("RequestFailed")));

            return builder;
        }
This is {@link DefaultRelyingPartyTokenProducerTests}.

@author Misagh Moayyed
@since 6.3.0
support/cas-server-support-ws-idp/src/test/java/org/apereo/cas/ws/idp/services/DefaultRelyingPartyTokenProducerTests.java