@Test
        void verifyTokenGeneration() throws Throwable {
            val request = new MockHttpServletRequest();
            val profile = new CommonProfile();
            profile.setClientName("OIDC");
            profile.setId(UUID.randomUUID().toString());

            request.setAttribute(Pac4jConstants.USER_PROFILES,
                CollectionUtils.wrapLinkedHashMap(profile.getClientName(), profile));

            val phoneValues = List.of("\\\\123456789", "4805553241");
            val principal = RegisteredServiceTestUtils.getPrincipal(profile.getId(), CollectionUtils.wrap(
                OIDC_CLAIM_EMAIL, List.of("casuser@example.org"),
                OIDC_CLAIM_PHONE_NUMBER, phoneValues,
                "color", List.of("yellow"),
                "custom-attribute", "test",
                OIDC_CLAIM_NAME, List.of(profile.getId())));

            val authentication = CoreAuthenticationTestUtils.getAuthentication(principal,
                CollectionUtils.wrap(OAuth20Constants.STATE, List.of("some-state"),
                    OAuth20Constants.NONCE, List.of("some-nonce")));
            val tgt = new MockTicketGrantingTicket(authentication);
            val callback = casProperties.getServer().getPrefix()
                + OAuth20Constants.BASE_OAUTH20_URL + '/'
                + OAuth20Constants.CALLBACK_AUTHORIZE_URL_DEFINITION;
            val service = webApplicationServiceFactory.createService(callback);
            tgt.getServices().putAll(CollectionUtils.wrap("service", service));
            ticketRegistry.addTicket(tgt);
            
            val accessToken = buildAccessToken(tgt);

            val registeredService = getOidcRegisteredService(UUID.randomUUID().toString(), randomServiceUrl());
            registeredService.setIdTokenIssuer(UUID.randomUUID().toString());
            registeredService.setScopes(CollectionUtils.wrapSet(EMAIL.getScope(), PROFILE.getScope(), PHONE.getScope()));
            servicesManager.save(registeredService);


            val idTokenContext = IdTokenGenerationContext.builder()
                .accessToken(accessToken)
                .userProfile(profile)
                .responseType(OAuth20ResponseTypes.ID_TOKEN)
                .grantType(OAuth20GrantTypes.NONE)
                .registeredService(registeredService)
                .build();
            val idToken = oidcIdTokenGenerator.generate(idTokenContext);
            assertNotNull(idToken);

            val claims = oidcTokenSigningAndEncryptionService.decode(idToken.token(), Optional.of(registeredService));
            assertNotNull(claims);
            assertTrue(claims.hasClaim(OIDC_CLAIM_EMAIL));
            assertEquals(authentication.getAuthenticationDate().toEpochSecond(), (long) claims.getClaimValue(OidcConstants.CLAIM_AUTH_TIME));
            assertTrue(claims.hasClaim(OIDC_CLAIM_NAME));
            assertTrue(claims.hasClaim(OIDC_CLAIM_PHONE_NUMBER));
            assertTrue(claims.hasClaim(OIDC_CLAIM_PREFERRED_USERNAME));
            assertEquals("casuser@example.org", claims.getStringClaimValue(OIDC_CLAIM_EMAIL));
            assertEquals(profile.getId(), claims.getStringClaimValue(OIDC_CLAIM_NAME));
            assertEquals(phoneValues, claims.getStringListClaimValue(OIDC_CLAIM_PHONE_NUMBER));
            assertEquals("test", claims.getStringClaimValue(OIDC_CLAIM_PREFERRED_USERNAME));
            assertEquals(registeredService.getIdTokenIssuer(), claims.getStringClaimValue(OidcConstants.ISS));
        }
This is {@link OidcIdTokenGeneratorServiceTests}.

@author Misagh Moayyed
@since 5.3.0
support/cas-server-support-oidc/src/test/java/org/apereo/cas/oidc/token/OidcIdTokenGeneratorServiceTests.java