@Test
    void verifyMergeCredentialMetadata() {
        val credential1 = getCredential();
        credential1.setCredentialMetadata(new BasicCredentialMetadata(credential1, Map.of("P1", "V1")));
        val credential2 = getCredential();
        credential2.setCredentialMetadata(new BasicCredentialMetadata(credential2, Map.of("P2", "V1")));

        val handler = new SimpleTestUsernamePasswordAuthenticationHandler();
        val builder = new DefaultAuthenticationBuilder(CoreAuthenticationTestUtils.getPrincipal());
        builder.addSuccess("test", new DefaultAuthenticationHandlerExecutionResult(handler, credential1));
        builder.setCredentials(List.of(credential1, credential2));

        val result = new DefaultAuthenticationHandlerExecutionResult(new SimpleTestUsernamePasswordAuthenticationHandler(), credential2);
        builder.addSuccess("Success", result);
        builder.setFailures(Map.of("Failure1", new FailedLoginException()));
        builder.addFailure("Success", new FailedLoginException());
        assertFalse(builder.hasAttribute("invalid"));
        val authentication = builder.build();
        assertNotNull(authentication);
        assertEquals(1, authentication.getCredentials().size());
        val credentialMetaData = authentication.getCredentials().getFirst().getCredentialMetadata();
        assertEquals(2, credentialMetaData.getProperties().size());
        assertTrue(credentialMetaData.getProperties().containsKey("P1"));
        assertTrue(credentialMetaData.getProperties().containsKey("P2"));
    }
This is {@link DefaultAuthenticationBuilderTests}.

@author Misagh Moayyed
@since 6.2.0
core/cas-server-core-authentication-api/src/test/java/org/apereo/cas/authentication/DefaultAuthenticationBuilderTests.java