@Test
    void verifyUsernameProviderWithAttributeReleasePolicy() throws Throwable {
        val resource = new ClassPathResource("UsernameAttrRelease-100.json");
        val serializer = new RegisteredServiceJsonSerializer(applicationContext);
        val service = serializer.from(resource.getInputStream());
        val context = RegisteredServiceAttributeReleasePolicyContext.builder()
            .registeredService(service)
            .service(CoreAuthenticationTestUtils.getService())
            .applicationContext(applicationContext)
            .principal(RegisteredServiceTestUtils.getPrincipal("casuser",
                Map.of("groups", List.of("g1", "g2"), "username", List.of("casuser"))))
            .build();
        val attributes = service.getAttributeReleasePolicy().getAttributes(context);
        assertEquals(3, attributes.size());
        assertTrue(attributes.containsKey("groups"));
        assertTrue(attributes.containsKey("username"));
        assertTrue(attributes.containsKey("familyName"));

        val usernameContext = RegisteredServiceUsernameProviderContext.builder()
            .registeredService(context.getRegisteredService())
            .service(context.getService())
            .principal(context.getPrincipal())
            .applicationContext(applicationContext)
            .build();
        val username = service.getUsernameAttributeProvider().resolveUsername(usernameContext);
        assertEquals("casuser", username);
    }
Handles test cases for {@link JsonServiceRegistry}.

@author Misagh Moayyed
@since 4.1.0
support/cas-server-support-json-service-registry/src/test/java/org/apereo/cas/services/JsonServiceRegistryTests.java