@Test
    void examineResolverMergingAttributes() throws Throwable {
        val p1 = principalFactory.createPrincipal("casuser", Map.of("familyName", List.of("Smith")));
        val p2 = principalFactory.createPrincipal("casuser", Map.of("familyName", List.of("smith")));

        val credential = mock(Credential.class);
        when(credential.getId()).thenReturn("input");

        val resolver1 = mock(PrincipalResolver.class);
        when(resolver1.supports(eq(credential))).thenReturn(true);
        when(resolver1.resolve(eq(credential), any(Optional.class), any(Optional.class), any(Optional.class))).thenReturn(p1);

        val resolver2 = mock(PrincipalResolver.class);
        when(resolver2.supports(any(Credential.class))).thenReturn(true);
        when(resolver2.resolve(any(Credential.class), any(Optional.class), any(Optional.class), any(Optional.class))).thenReturn(p2);

        var finalResult = mergeAndResolve(p1, credential, resolver1, resolver2, PrincipalAttributesCoreProperties.MergingStrategyTypes.REPLACE);
        assertTrue(finalResult.getAttributes().containsValue(List.of("smith")));

        finalResult = mergeAndResolve(p1, credential, resolver1, resolver2, PrincipalAttributesCoreProperties.MergingStrategyTypes.ADD);
        assertTrue(finalResult.getAttributes().containsValue(List.of("Smith")));

        /*
            Distinct values are set to true for multivalued merger strategies.
            This means the final attribute collection will only collect one value for Smith.
         */
        finalResult = mergeAndResolve(p1, credential, resolver1, resolver2, PrincipalAttributesCoreProperties.MergingStrategyTypes.MULTIVALUED);
        assertTrue(finalResult.getAttributes().containsValue(List.of("Smith")));
    }
Unit test for {@link ChainingPrincipalResolver}.

@author Marvin S. Addison
@since 4.0.0
core/cas-server-core-authentication/src/test/java/org/apereo/cas/authentication/principal/ChainingPrincipalResolverTests.java