@Test
        void verifyAccessTokenToJWTExchange() throws Throwable {
            val service = getRegisteredService(UUID.randomUUID().toString(), OAuth20GrantTypes.TOKEN_EXCHANGE);
            val subjectToken = getAccessToken(service.getServiceId(), service.getClientId());
            service.setScopes(Set.of("create", "update"));
            servicesManager.save(service);
            ticketRegistry.addTicket(subjectToken);

            val resource = "https://api.example.org/%s".formatted(UUID.randomUUID().toString());
            mvc.perform(post("/cas" + CONTEXT + OAuth20Constants.ACCESS_TOKEN_URL)
                    .param(OAuth20Constants.CLIENT_ID, service.getClientId())
                    .param(OAuth20Constants.CLIENT_SECRET, service.getClientSecret())
                    .queryParam(OAuth20Constants.RESOURCE, resource)
                    .queryParam(OAuth20Constants.SUBJECT_TOKEN, subjectToken.getId())
                    .queryParam(OAuth20Constants.SUBJECT_TOKEN_TYPE, OAuth20TokenExchangeTypes.ACCESS_TOKEN.getType())
                    .queryParam(OAuth20Constants.REQUESTED_TOKEN_TYPE, OAuth20TokenExchangeTypes.JWT.getType())
                    .queryParam(OAuth20Constants.GRANT_TYPE, OAuth20GrantTypes.TOKEN_EXCHANGE.getType())
                    .queryParam(OAuth20Constants.SCOPE, "update")
                )
                .andExpect(jsonPath("$.scope").value("update"))
                .andExpect(jsonPath("$.access_token").exists())
                .andExpect(jsonPath("$.issued_token_type").value(OAuth20TokenExchangeTypes.JWT.getType()));
        }
This class tests the {@link OAuth20AccessTokenEndpointController} class.

@author Jerome Leleu
@since 3.5.2
support/cas-server-support-oauth/src/test/java/org/apereo/cas/support/oauth/web/endpoints/OAuth20AccessTokenEndpointControllerTests.java