@Test
    void verifyChainingResolverOverwrite() throws Throwable {
        val context = getPrincipalResolutionContextBuilder()
            .returnNullIfNoAttributes(false)
            .principalNameTransformer(formUserId -> formUserId)
            .useCurrentPrincipalId(false)
            .resolveAttributes(true)
            .activeAttributeRepositoryIdentifiers(CollectionUtils.wrapSet(PersonAttributeDao.WILDCARD))
            .build();

        val resolver = PersonDirectoryPrincipalResolver.newPersonDirectoryPrincipalResolver(PersonDirectoryPrincipalResolver.class, context);

        val chain = buildResolver(List.of(new EchoingPrincipalResolver(), resolver));
        val attributes = new HashMap<String, List<Object>>();
        attributes.put("cn", List.of("originalCN"));
        attributes.put(ATTR_1, List.of("value1"));
        val principal = chain.resolve(CoreAuthenticationTestUtils.getCredentialsWithSameUsernameAndPassword(),
            Optional.of(CoreAuthenticationTestUtils.getPrincipal(CoreAuthenticationTestUtils.CONST_USERNAME, attributes)),
            Optional.of(new SimpleTestUsernamePasswordAuthenticationHandler()),
            Optional.of(CoreAuthenticationTestUtils.getService()));
        assertEquals(7, principal.getAttributes().size());
        assertTrue(principal.getAttributes().containsKey(ATTR_1));
        assertTrue(principal.getAttributes().containsKey("cn"));
        assertNotEquals("originalCN", principal.getAttributes().get("cn"));
    }
Test cases for {@link PersonDirectoryPrincipalResolver}.

@author Misagh Moayyed
@since 4.2
support/cas-server-support-person-directory-core/src/test/java/org/apereo/cas/authentication/principal/resolvers/PersonDirectoryPrincipalResolverTests.java