private static void prepareRequestContextForAuthentication(final MockRequestContext context,
                                                               final Authentication authentication) throws Throwable {
        val builder = mock(AuthenticationResultBuilder.class);
        when(builder.getInitialAuthentication()).thenReturn(Optional.of(authentication));
        when(builder.collect(any(Authentication.class))).thenReturn(builder);

        val result = mock(AuthenticationResult.class);
        when(result.getAuthentication()).thenReturn(authentication);

        when(builder.build()).thenReturn(result);
        when(builder.build(any(Service.class))).thenReturn(result);

        WebUtils.putAuthenticationResultBuilder(builder, context);
        WebUtils.putServiceIntoFlowScope(context, CoreAuthenticationTestUtils.getWebApplicationService());
    }
This is {@link CreateTicketGrantingTicketActionTests}.

@author Misagh Moayyed
@since 5.3.0
support/cas-server-support-actions/src/test/java/org/apereo/cas/web/flow/CreateTicketGrantingTicketActionTests.java