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

        val code = createOAuthCode();
        val at = accessTokenFactory.create(RegisteredServiceTestUtils.getService(),
            RegisteredServiceTestUtils.getAuthentication(), tgt,
            Set.of("scope1"), code.getId(), "client1", Collections.emptyMap(),
            OAuth20ResponseTypes.CODE, OAuth20GrantTypes.AUTHORIZATION_CODE);

        ticketRegistry.addTicket(at);
        ticketRegistry.updateTicket(tgt);

        assertEquals(1, ticketRegistry.sessionCount());
        assertNotNull(ticketRegistry.getTicket(at.getId()));

        at.markTicketExpired();
        tgt.markTicketExpired();

        ticketRegistry.updateTicket(at);
        ticketRegistry.updateTicket(tgt);

        assertEquals(2, ticketRegistryCleaner.clean());
        assertEquals(0, ticketRegistry.sessionCount());
        assertNull(ticketRegistry.getTicket(at.getId()));
    }
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