@Test
    void verifyAttributeRepositoryByService() {
        Stream.of(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 attributePolicy = new RegisteredServiceAttributeReleasePolicy() {
                    @Serial
                    private static final long serialVersionUID = 6118477243447737445L;

                    @Override
                    public RegisteredServicePrincipalAttributesRepository getPrincipalAttributesRepository() {
                        val repo = mock(RegisteredServicePrincipalAttributesRepository.class);
                        when(repo.getAttributeRepositoryIds()).thenReturn(Set.of("StubPersonAttributeDao"));
                        return repo;
                    }

                    @Override
                    public Map<String, List<Object>> getAttributes(final RegisteredServiceAttributeReleasePolicyContext context) {
                        return context.getPrincipal().getAttributes();
                    }
                };

                val service = CoreAuthenticationTestUtils.getService(UUID.randomUUID().toString());
                val registeredService = CoreAuthenticationTestUtils.getRegisteredService(service.getId());
                lenient().when(registeredService.getAttributeReleasePolicy()).thenReturn(attributePolicy);
                lenient().when(servicesManager.findServiceBy(any(Service.class))).thenReturn(registeredService);

                val resolved = resolver.resolve(credential, Optional.of(principal),
                    Optional.of(new SimpleTestUsernamePasswordAuthenticationHandler()),
                    Optional.of(service));
                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