@Test
    void failSign() {
        val builder = new NonInflatingSaml20ObjectBuilder(openSamlConfigBean);
        assertThrows(IllegalArgumentException.class,
            () -> builder.signSamlResponse("bad-response",
                mock(PrivateKey.class), mock(PublicKey.class)));
        val response = builder.newResponse(UUID.randomUUID().toString(), ZonedDateTime.now(ZoneOffset.UTC), "cas",
            CoreAuthenticationTestUtils.getWebApplicationService());
        val result = SamlUtils.transformSamlObject(openSamlConfigBean, response, true).toString();
        assertThrows(IllegalArgumentException.class,
            () -> builder.signSamlResponse(result,
                mock(PrivateKey.class), mock(PublicKey.class)));
        assertThrows(IllegalArgumentException.class,
            () -> {
                val pubKey = mock(PublicKey.class);
                when(pubKey.getAlgorithm()).thenReturn("RSA");
                builder.signSamlResponse(result,
                    mock(PrivateKey.class), pubKey);
            });
    }
This is {@link NonInflatingSaml20ObjectBuilderTests}.

@author Misagh Moayyed
@since 6.2.0
support/cas-server-support-saml-core/src/test/java/org/apereo/cas/support/saml/util/NonInflatingSaml20ObjectBuilderTests.java