@Test
    void verifyBadType() {
        val factory = (ServiceTicketFactory) this.ticketFactory.get(ServiceTicket.class);
        assertThrows(ClassCastException.class,
            () -> factory.create(new MockTicketGrantingTicket("casuser"),
                RegisteredServiceTestUtils.getService("customExpirationPolicy"),
                true, BaseMockTicketServiceTicket.class));
    }
This is {@link DefaultServiceTicketFactoryTests}.

@author Misagh Moayyed
@since 6.1.0
core/cas-server-core-tickets/src/test/java/org/apereo/cas/ticket/factory/DefaultServiceTicketFactoryTests.java