@Test
    public void testMetadata() throws Exception {
        ConfigurationManager mgr = new DefaultConfigurationManager();
        mgr.configure();

        val configuration = new SAML2Configuration();
        configuration.setForceKeystoreGeneration(true);
        configuration.setKeystorePath("target/keystore.jks");
        configuration.setKeystorePassword("pac4j");
        configuration.setPrivateKeyPassword("pac4j");
        configuration.setSignMetadata(true);
        configuration.setServiceProviderEntityId(ENTITY_ID);
        configuration.setMetadataGenerator(this.mongoMetadataGenerator);
        configuration.setIdentityProviderMetadataResource(new ClassPathResource("idp-metadata.xml"));
        configuration.init();

        var metadataGenerator = configuration.toMetadataGenerator();
        val entity = metadataGenerator.buildEntityDescriptor();
        assertNotNull(entity);
        val metadata = metadataGenerator.getMetadata(entity);
        assertNotNull(metadata);

        assertTrue(metadataGenerator.storeMetadata(metadata, true));
        var resolver = metadataGenerator.buildMetadataResolver();
        assertNotNull(resolver);
        var entityDescriptor = resolver.resolveSingle(new CriteriaSet(new EntityIdCriterion(configuration.getServiceProviderEntityId())));
        assertNotNull(entityDescriptor);

        // now update
        assertTrue(metadataGenerator.storeMetadata(metadata, true));
    }
This is {@link SAML2MongoMetadataGeneratorIT}.

@author Misagh Moayyed
@since 5.7.0
pac4j-saml/src/test/java/org/pac4j/saml/metadata/mongo/SAML2MongoMetadataGeneratorIT.java