protected static OAuth20Code getCode() {
        val tgt = new MockTicketGrantingTicket("casuser");
        val service = RegisteredServiceTestUtils.getService();
        val oauthCode = mock(OAuth20Code.class);
        when(oauthCode.getCreationTime()).thenReturn(ZonedDateTime.now(Clock.systemUTC()));
        when(oauthCode.getId()).thenReturn(UUID.randomUUID().toString());
        when(oauthCode.getTicketGrantingTicket()).thenReturn(tgt);
        when(oauthCode.getAuthentication()).thenReturn(tgt.getAuthentication());
        when(oauthCode.getService()).thenReturn(service);
        when(oauthCode.getExpirationPolicy()).thenReturn(NeverExpiresExpirationPolicy.INSTANCE);
        return oauthCode;
    }
This is {@link BaseOAuth20AuthenticatorTests}.

@author Misagh Moayyed
@since 6.0.0
support/cas-server-support-oauth/src/test/java/org/apereo/cas/support/oauth/authenticator/BaseOAuth20AuthenticatorTests.java