@Test
    void verifyDeviceCodeAndUserCleaning() throws Throwable {
        val tgtFactory = (TicketGrantingTicketFactory) ticketFactory.get(TicketGrantingTicket.class);
        val tgt = tgtFactory.create(RegisteredServiceTestUtils.getAuthentication(),
            RegisteredServiceTestUtils.getService());
        ticketRegistry.addTicket(tgt);

        val deviceCodeFactory = (OAuth20DeviceTokenFactory) ticketFactory.get(OAuth20DeviceToken.class);
        val deviceCode = deviceCodeFactory.createDeviceCode(RegisteredServiceTestUtils.getService());
        ticketRegistry.addTicket(deviceCode);

        val deviceUserCodeFactory = (OAuth20DeviceUserCodeFactory) ticketFactory.get(OAuth20DeviceUserCode.class);
        val deviceUserCode = deviceUserCodeFactory.createDeviceUserCode(deviceCode.getService());
        ticketRegistry.addTicket(deviceUserCode);

        ticketRegistry.updateTicket(tgt);

        deviceCode.markTicketExpired();
        deviceUserCode.markTicketExpired();
        tgt.markTicketExpired();

        ticketRegistry.updateTicket(deviceCode);
        ticketRegistry.updateTicket(deviceUserCode);
        ticketRegistry.updateTicket(tgt);

        assertEquals(3, ticketRegistry.getTickets().size());
        assertEquals(3, ticketRegistryCleaner.clean());
        assertTrue(ticketRegistry.getTickets().isEmpty());
    }
This is {@link BaseJpaTicketRegistryCleanerTests}.

@author Misagh Moayyed
@since 6.0.0
support/cas-server-support-jpa-ticket-registry/src/test/java/org/apereo/cas/ticket/registry/cleaner/BaseJpaTicketRegistryCleanerTests.java