protected OAuth20Code addCode(final Principal principal,
                                  final OAuthRegisteredService registeredService) throws Throwable {
        val ticketGrantingTicket = new MockTicketGrantingTicket("casuser");
        val authentication = RegisteredServiceTestUtils.getAuthentication(principal);
        val service = webApplicationServiceFactory.createService(registeredService.getClientId());
        val scopes = List.of(OidcConstants.StandardScopes.OPENID.getScope());
        val code = defaultOAuthCodeFactory.create(service, authentication,
            ticketGrantingTicket, scopes, registeredService.getClientId(),
            OAuth20ResponseTypes.CODE, OAuth20GrantTypes.AUTHORIZATION_CODE);
        ticketRegistry.addTicket(code);
        return code;
    }
This is {@link AbstractOidcTests}.

@author Misagh Moayyed
@since 5.3.0
support/cas-server-support-oidc/src/test/java/org/apereo/cas/oidc/AbstractOidcTests.java