@Test
    void verifyMergeOperation() throws Throwable {
        val builder1 = new DefaultAuthenticationBuilder(CoreAuthenticationTestUtils.getPrincipal());
        builder1.mergeAttribute("key", 12345);
        builder1.mergeAttribute("key", CollectionUtils.wrapList(54321, 998877));
        val authn1 = builder1.build();

        val builder2 = new DefaultAuthenticationBuilder(CoreAuthenticationTestUtils.getPrincipal());
        builder2.mergeAttribute("key", 112233);
        builder2.mergeAttribute("key", CollectionUtils.wrapList(443322));
        val authn2 = builder2.build();

        val strategy = new DefaultPrincipalElectionStrategy();
        val resultBuilder = new DefaultAuthenticationResultBuilderFactory(strategy).newBuilder();
        strategy.setAttributeMerger(CoreAuthenticationUtils.getAttributeMerger(PrincipalAttributesCoreProperties.MergingStrategyTypes.MULTIVALUED));
        val resultAuthn = resultBuilder.collect(authn1).collect(authn2).build();
        assertNotNull(resultAuthn);
        assertEquals(5, resultAuthn.getAuthentication().getAttributes().get("key").size());
    }
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