@Test
        void verifyExpiredUserCode() throws Throwable {
            val token = defaultDeviceTokenFactory.createDeviceCode(
                RegisteredServiceTestUtils.getService("https://device.oauth.org"));
            ticketRegistry.addTicket(token);
            val userCode = defaultDeviceUserCodeFactory.createDeviceUserCode(token.getService());
            token.setUserCode(userCode.getId());
            ticketRegistry.addTicket(userCode);

            Thread.sleep(2000);
            val holder = AccessTokenRequestContext.builder()
                .responseType(OAuth20ResponseTypes.DEVICE_CODE)
                .deviceCode(token.getId())
                .authentication(RegisteredServiceTestUtils.getAuthentication())
                .registeredService(getRegisteredService(UUID.randomUUID().toString(), "secret"))
                .build();
            userCode.markTicketExpired();
            assertThrows(InvalidOAuth20DeviceTokenException.class, () -> oauthTokenGenerator.generate(holder));
        }
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