@Test
    public void testTicketExistsValidationOccurs() {
        val configuration = new CasConfiguration();
        configuration.setLoginUrl(LOGIN_URL);
        configuration.setDefaultTicketValidator((ticket, service) -> {
            if (TICKET.equals(ticket) && CALLBACK_URL.equals(service)) {
                return new AssertionImpl(TICKET);
            }
            throw new TechnicalException("Bad ticket or service");
        });
        val client = new DirectCasClient(configuration);
        val context = MockWebContext.create();
        context.setFullRequestURL(CALLBACK_URL + "?" + CasConfiguration.TICKET_PARAMETER + "=" + TICKET);
        context.addRequestParameter(CasConfiguration.TICKET_PARAMETER, TICKET);
        val ctx = new CallContext(context, new MockSessionStore());
        val credentials = client.getCredentials(ctx).get();
        assertEquals(TICKET, ((TokenCredentials) credentials).getToken());
        val newCredentials = client.validateCredentials(ctx, credentials).get();
        val profile = newCredentials.getUserProfile();
        assertTrue(profile instanceof CasProfile);
        assertEquals(TICKET, profile.getId());
    }
Tests the {@link DirectCasClient}.

@author Jerome Leleu
@since 1.9.2
pac4j-cas/src/test/java/org/pac4j/cas/client/direct/DirectCasClientTests.java