@Test
    public void verifyOperation() {
        val nameIdBuilder = (SAMLObjectBuilder<NameID>)
            this.builderFactory.getBuilder(NameID.DEFAULT_ELEMENT_NAME);
        assertNotNull(nameIdBuilder);

        val nameid = nameIdBuilder.buildObject();
        nameid.setValue("pac4j");
        nameid.setSPNameQualifier("pac4j");
        nameid.setNameQualifier("pac4j");
        nameid.setSPProvidedID("pac4j");

        val conditionsBuilder = (SAMLObjectBuilder<Conditions>)
            this.builderFactory.getBuilder(Conditions.DEFAULT_ELEMENT_NAME);
        assertNotNull(conditionsBuilder);

        val conditions = conditionsBuilder.buildObject();
        conditions.setNotBefore(Instant.now());
        conditions.setNotOnOrAfter(Instant.now());

        final List<String> contexts = new ArrayList<>();
        contexts.add("cas-context");

        val attributeBuilder = (SAMLObjectBuilder<Attribute>)
            this.builderFactory.getBuilder(Attribute.DEFAULT_ELEMENT_NAME);
        assertNotNull(attributeBuilder);

        final List<Attribute> attributes = new ArrayList<>();
        val attr = attributeBuilder.buildObject();
        attr.setFriendlyName("pac4j");
        attr.setName("pac4j");
        attr.setNameFormat("pac4j");
        attributes.add(attr);
        Serializable credentials = new SAML2AuthenticationCredentials(
            SAML2AuthenticationCredentials.SAMLNameID.from(nameid), "example.issuer.com",
            SAML2AuthenticationCredentials.SAMLAttribute.from(
                new SimpleSAML2AttributeConverter(), attributes), conditions, "session-index",
            contexts, List.of(), UUID.randomUUID().toString());
        val data = SerializationUtils.serialize(credentials);
        val result = (SAML2AuthenticationCredentials) SerializationUtils.deserialize(data);
        assertNotNull(result);
        assertNotNull(result.getInResponseTo());
    }
This is {@link SAML2CredentialsSerializationTests}.

@author Misagh Moayyed
pac4j-saml/src/test/java/org/pac4j/saml/credentials/SAML2CredentialsSerializationTests.java