@Test
    void verifyTicketGrantingTicketAsJwtWithHeader() throws Throwable {
        val registeredService = RegisteredServiceTestUtils.getRegisteredService(casProperties.getServer().getPrefix());
        servicesManager.save(registeredService);

        val result = CoreAuthenticationTestUtils.getAuthenticationResult(authenticationSystemSupport,
            CoreAuthenticationTestUtils.getCredentialsWithSameUsernameAndPassword("casuser"));
        val tgt = (TicketGrantingTicket) centralAuthenticationService.createTicketGrantingTicket(result);

        val request = new MockHttpServletRequest();
        request.addHeader(TokenConstants.PARAMETER_NAME_TOKEN, Boolean.TRUE.toString());
        val response = ticketGrantingTicketResourceEntityResponseFactory.build(tgt, request);
        assertNotNull(response);
        assertEquals(HttpStatus.CREATED, response.getStatusCode());

        val jwt = tokenCipherExecutor.decode(response.getBody());
        val claims = JWTClaimsSet.parse(jwt.toString());
        assertEquals(claims.getSubject(), tgt.getAuthentication().getPrincipal().getId());
    }
This is {@link JwtTicketGrantingTicketResourceEntityResponseFactoryTests}.

@author Misagh Moayyed
@since 5.2.0
support/cas-server-support-rest-tokens/src/test/java/org/apereo/cas/tokens/JwtTicketGrantingTicketResourceEntityResponseFactoryTests.java