protected static Authentication getAuthentication(final Principal principal) {
        val metadata = new BasicIdentifiableCredential(principal.getId());
        val handlerResult = new DefaultAuthenticationHandlerExecutionResult(principal.getClass().getCanonicalName(),
            metadata, principal, new ArrayList<>());

        return DefaultAuthenticationBuilder.newInstance()
            .setPrincipal(principal)
            .setAuthenticationDate(ZonedDateTime.now(ZoneOffset.UTC))
            .addCredential(metadata)
            .addSuccess(principal.getClass().getCanonicalName(), handlerResult)
            .build();
    }
This is {@link AbstractOAuth20Tests}.

@author Misagh Moayyed
@since 5.0.0
support/cas-server-support-oauth/src/test/java/org/apereo/cas/AbstractOAuth20Tests.java