@Test
    void verifyOperationWithExpPolicyRemoveDescendantTickets() throws Throwable {
        val registeredService = getRegisteredService("https://code.oauth.org", "clientid-code", "secret-at");
        registeredService.setCodeExpirationPolicy(
            new DefaultRegisteredServiceOAuthCodeExpirationPolicy(10, "PT10S"));
        servicesManager.save(registeredService);
        val tgt = new MockTicketGrantingTicket("casuser");
        val trackingPolicy = new DefaultDescendantTicketsTrackingPolicy();
        val newOAuthCodeFactory = new OAuth20DefaultOAuthCodeFactory(oAuthCodeIdGenerator, oAuthCodeExpirationPolicy,
            servicesManager, protocolTicketCipherExecutor, trackingPolicy);
        val token = newOAuthCodeFactory.create(RegisteredServiceTestUtils.getService("https://code.oauth.org"),
            RegisteredServiceTestUtils.getAuthentication(),
            tgt,
            Set.of("Scope1", "Scope2"), "code-challenge", "plain",
            "clientid-code", Map.of(),
            OAuth20ResponseTypes.CODE, OAuth20GrantTypes.AUTHORIZATION_CODE);
        assertNotNull(token);
        assertTrue(trackingPolicy.countTickets(tgt, token.getId()) > 0);
    }
This is {@link OAuth20DefaultOAuthCodeFactoryTests}.

@author Misagh Moayyed
@since 6.2.0
support/cas-server-support-oauth/src/test/java/org/apereo/cas/ticket/code/OAuth20DefaultOAuthCodeFactoryTests.java