@Test
        void verifyRefreshTokenIsRefreshedWithAllScopes() throws Throwable {
            val registeredService = getRegisteredService(UUID.randomUUID().toString(), "secret", new LinkedHashSet<>());
            registeredService.setGenerateRefreshToken(true);
            registeredService.setRenewRefreshToken(true);
            registeredService.setScopes(Set.of("openid", "email", "profile"));
            servicesManager.save(registeredService);
            val service = RegisteredServiceTestUtils.getService(SERVICE_URL);

            val authentication = RegisteredServiceTestUtils.getAuthentication("casuser");
            val refreshToken = OAuth20TestUtils.getRefreshToken(registeredService.getServiceId(), registeredService.getClientId());
            when(refreshToken.getScopes()).thenReturn(Set.of("email", "openid"));
            ticketRegistry.addTicket(refreshToken);

            val context = AccessTokenRequestContext.builder()
                .authentication(authentication)
                .service(service)
                .scopes(Set.of("email"))
                .token(refreshToken)
                .grantType(OAuth20GrantTypes.REFRESH_TOKEN)
                .generateRefreshToken(true)
                .registeredService(registeredService)
                .ticketGrantingTicket(refreshToken.getTicketGrantingTicket())
                .build();
            val response = oauthTokenGenerator.generate(context);
            assertTrue(response.getRefreshToken().isPresent());
            val ticket = response.getRefreshToken().get();
            assertInstanceOf(OAuth20RefreshToken.class, ticket);
            assertEquals(Set.of("openid", "email"), ((OAuth20Token) ticket).getScopes());
            assertTrue(response.getAccessToken().isPresent());
            val ticket2 = response.getAccessToken().get();
            assertInstanceOf(OAuth20AccessToken.class, ticket2);
            assertEquals(Set.of("email"), ((OAuth20Token) ticket2).getScopes());
        }
This is {@link OAuth20DefaultTokenGeneratorTests}.

@author Misagh Moayyed
@since 6.1.0
support/cas-server-support-oauth/src/test/java/org/apereo/cas/support/oauth/web/response/accesstoken/OAuth20DefaultTokenGeneratorTests.java