@Test
    void verifyAuthenticationResultBuildsPrincipals() throws Throwable {
        val electionStrategy = new DefaultPrincipalElectionStrategy();
        val builder = new DefaultAuthenticationResultBuilder(electionStrategy);
        assertFalse(builder.getInitialAuthentication().isPresent());
        assertFalse(builder.getInitialCredential().isPresent());

        val p1 = CoreAuthenticationTestUtils.getPrincipal("casuser1", CollectionUtils.wrap("uid", "casuser1"));
        val p2 = CoreAuthenticationTestUtils.getPrincipal("casuser2", CollectionUtils.wrap("givenName", "CAS"));
        val authn1 = CoreAuthenticationTestUtils.getAuthentication(p1, CollectionUtils.wrap("authn1", "first"));
        val authn2 = CoreAuthenticationTestUtils.getAuthentication(p2, CollectionUtils.wrap("authn2", "second"));

        val result = builder.collect(authn1).collect(authn2).build();

        val authentication = result.getAuthentication();
        assertNotNull(authentication);
        val authnAttributes = authentication.getAttributes();
        assertTrue(authnAttributes.containsKey("authn1"));
        assertTrue(authnAttributes.containsKey("authn2"));

        val principal = authentication.getPrincipal();
        assertNotNull(principal);

        val attributes = principal.getAttributes();
        assertFalse(attributes.isEmpty());

        assertTrue(attributes.containsKey("uid"));
        assertTrue(attributes.containsKey("givenName"));
        assertEquals(1, attributes.get("uid").size());
        assertEquals(1, attributes.get("givenName").size());
    }
This is {@link DefaultAuthenticationResultBuilderTests}.

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