@Test
    void verifyPrincipalIdViaCurrentPrincipal() {
        Stream.of(PrincipalAttributesCoreProperties.MergingStrategyTypes.REPLACE, PrincipalAttributesCoreProperties.MergingStrategyTypes.MULTIVALUED)
            .map(merger -> getPrincipalResolutionContextBuilder(merger, CoreAuthenticationTestUtils.getAttributeRepository())
                .returnNullIfNoAttributes(true)
                .principalAttributeNames("custom:attribute")
                .useCurrentPrincipalId(true)
                .resolveAttributes(true)
                .build())
            .map(context -> PersonDirectoryPrincipalResolver.newPersonDirectoryPrincipalResolver(PersonDirectoryPrincipalResolver.class, context))
            .forEach(Unchecked.consumer(resolver -> {
                val credential = mock(Credential.class);
                val principal = CoreAuthenticationTestUtils.getPrincipal(Map.of("custom:attribute", List.of("customUserId")));
                val resolved = resolver.resolve(credential, Optional.of(principal),
                    Optional.of(new SimpleTestUsernamePasswordAuthenticationHandler()),
                    Optional.of(CoreAuthenticationTestUtils.getService()));
                assertNotNull(resolved);
                assertEquals("customUserId", resolved.getId());
            }));
    }
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