title: java.lang.AssertionError: on call of method in easy mock spring webflow junit
body: <p>I have tried to resume the flow with directly from particular state i.e <code>setCurrentState("initialFlowSetup")</code>. In which  the flow is transition to other state with the given eventid <code>error</code> but after certain transition there is one action involved <strong>setErrorMessages.getErrorMessagesMap(flowRequestContext)" result="flowScope.errorMessageMap"</strong> in state <strong>set_error_in_scope</strong> which is returning the Map. </p>
  
  <p>When I call the method using EasyMock and set the expectation the return result as map in my test case  the return result is not taken by webflow. Below  is the error.</p>
  
  <p>I am not able to understand the concept , when to set expectation and set the result to webflow so the return result will be identified by flow.</p>
  
  <p>Error</p>
  
  <pre><code>    org.springframework.webflow.execution.ActionExecutionException: Exception thrown executing [AnnotatedAction@7c974942 targetAction = [EvaluateAction@1eea9d2d expression = setErrorMessages.getErrorMessagesMap(flowRequestContext), resultExpression = flowScope.errorMessageMap], attributes = map[[empty]]] in state 'set_error_in_scope' of flow 'shclogin-flow' -- action execution attributes were 'map[[empty]]'
      at org.springframework.webflow.execution.ActionExecutor.execute(ActionExecutor.java:60)
      at org.springframework.webflow.engine.ActionState.doEnter(ActionState.java:101)
      at org.springframework.webflow.engine.State.enter(State.java:194)
      at org.springframework.webflow.engine.Transition.execute(Transition.java:228)
      at org.springframework.webflow.engine.DecisionState.doEnter(DecisionState.java:51)
      at org.springframework.webflow.engine.State.enter(State.java:194)
      at org.springframework.webflow.engine.Transition.execute(Transition.java:228)
      at org.springframework.webflow.engine.impl.FlowExecutionImpl.execute(FlowExecutionImpl.java:395)
      at org.springframework.webflow.engine.impl.RequestControlContextImpl.execute(RequestControlContextImpl.java:214)
      at org.springframework.webflow.engine.support.TransitionExecutingFlowExecutionExceptionHandler.handle(TransitionExecutingFlowExecutionExceptionHandler.java:111)
      at org.springframework.webflow.engine.FlowExecutionExceptionHandlerSet.handleException(FlowExecutionExceptionHandlerSet.java:109)
      at org.springframework.webflow.engine.Flow.handleException(Flow.java:600)
      at org.springframework.webflow.engine.impl.FlowExecutionImpl.tryFlowHandlers(FlowExecutionImpl.java:647)
      at org.springframework.webflow.engine.impl.FlowExecutionImpl.handleException(FlowExecutionImpl.java:603)
      at org.springframework.webflow.engine.impl.FlowExecutionImpl.resume(FlowExecutionImpl.java:263)
      at org.springframework.webflow.test.execution.AbstractFlowExecutionTests.resumeFlow(AbstractFlowExecutionTests.java:136)
      at com.shc.ecom.test.usr.TestloginlFlow.testAction(TestloginlFlow.java:149)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:483)
      at junit.framework.TestCase.runTest(TestCase.java:154)
      at junit.framework.TestCase.runBare(TestCase.java:127)
      at junit.framework.TestResult$1.protect(TestResult.java:106)
      at junit.framework.TestResult.runProtected(TestResult.java:124)
      at junit.framework.TestResult.run(TestResult.java:109)
      at junit.framework.TestCase.run(TestCase.java:118)
      at junit.framework.TestSuite.runTest(TestSuite.java:208)
      at junit.framework.TestSuite.run(TestSuite.java:203)
      at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:131)
      at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)
  Caused by: org.springframework.expression.ExpressionInvocationTargetException: A problem occurred when trying to execute method 'getErrorMessagesMap' on object of type [com.shc.ecom.sso.cas.web.flow.SetErrorMessages$$EnhancerByCGLIB$$ae43a022]
      at org.springframework.expression.spel.ast.MethodReference.throwSimpleExceptionIfPossible(MethodReference.java:227)
      at org.springframework.expression.spel.ast.MethodReference.getValueInternal(MethodReference.java:133)
      at org.springframework.expression.spel.ast.MethodReference.access$000(MethodReference.java:49)
      at org.springframework.expression.spel.ast.MethodReference$MethodValueRef.getValue(MethodReference.java:342)
      at org.springframework.expression.spel.ast.CompoundExpression.getValueInternal(CompoundExpression.java:88)
      at org.springframework.expression.spel.ast.SpelNodeImpl.getTypedValue(SpelNodeImpl.java:131)
      at org.springframework.expression.spel.standard.SpelExpression.getValue(SpelExpression.java:299)
      at org.springframework.binding.expression.spel.SpringELExpression.getValue(SpringELExpression.java:84)
      at org.springframework.webflow.action.EvaluateAction.doExecute(EvaluateAction.java:75)
      at org.springframework.webflow.action.AbstractAction.execute(AbstractAction.java:188)
      at org.springframework.webflow.execution.AnnotatedAction.execute(AnnotatedAction.java:145)
      at org.springframework.webflow.execution.ActionExecutor.execute(ActionExecutor.java:51)
      ... 34 more
  Caused by: java.lang.AssertionError: 
    Unexpected method call SetErrorMessages.getErrorMessagesMap([RequestControlContextImpl@48bfb884 externalContext = org.springframework.webflow.test.MockExternalContext@11653e3b, currentEvent = [null], requestScope = map[[empty]], attributes = map[[empty]], messageContext = [DefaultMessageContext@715fb77 sourceMessages = map[[null] -&gt; list[[empty]]]], flowExecution = [FlowExecutionImpl@1b9c1b51 flow = 'shclogin-flow', flowSessions = list[[FlowSessionImpl@2e52fb3e flow = 'shclogin-flow', state = 'set_error_in_scope', scope = map['errorMessageMap' -&gt; map['originalUrl' -&gt; 123]]]]]]):
      SetErrorMessages.getErrorMessagesMap(requestContext): expected: 1, actual: 0
      at org.easymock.internal.MockInvocationHandler.invoke(MockInvocationHandler.java:44)
      at org.easymock.internal.ObjectMethodsFilter.invoke(ObjectMethodsFilter.java:85)
      at org.easymock.internal.ClassProxyFactory$MockMethodInterceptor.intercept(ClassProxyFactory.java:94)
      at com.shc.ecom.sso.cas.web.flow.SetErrorMessages$$EnhancerByCGLIB$$ae43a022.getErrorMessagesMap(&lt;generated&gt;)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:483)
      at org.springframework.expression.spel.support.ReflectiveMethodExecutor.execute(ReflectiveMethodExecutor.java:112)
      at org.springframework.expression.spel.ast.MethodReference.getValueInternal(MethodReference.java:129)
      ... 44 more
  </code></pre>
  
  <p>Xml</p>
  
  <pre><code>    &lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;flow xmlns="http://www.springframework.org/schema/webflow"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="
                http://www.springframework.org/schema/webflow
                http://www.springframework.org/schema/webflow/spring-webflow-2.4.xsd" 
                start-state="initialFlowSetup" &gt;
  
  
      &lt;input name="loginId" value="requestScope.loginId" /&gt;
      &lt;input name="logonPassword" value="requestScope.logonPassword" /&gt;
      &lt;input name="sourceSiteId" value="requestScope.sourceSiteId" /&gt;
      &lt;input name="fullpage" value="requestScope.fullpage" /&gt;
      &lt;input name="partialuser" value="requestScope.partialuser" /&gt;
      &lt;input name="sourceSiteId" value="flowScope.sourceSite" /&gt;
      &lt;input name="service" value="requestScope.service" /&gt;
      &lt;input name="redirectUrl" value="requestScope.redirectUrl" /&gt;
      &lt;input name="sywLogin" value="requestScope.sywLogin" /&gt;
      &lt;input name="tncmodal" value="requestScope.tncmodal" /&gt;
      &lt;input name="modifyservice" value="requestScope.modifyservice" /&gt;
      &lt;input name="reglogin" value="flowScope.reglogin" /&gt;
      &lt;input name="enrollresponse" value="flowScope.enrollresponse" /&gt;
      &lt;input name="shcCaptchaKey" value="requestScope.shcKey" /&gt;
      &lt;input name="shcCaptchaResponse" value="requestScope.shcResponse" /&gt;
      &lt;input name="sywmax" value="flowScope.sywmax" /&gt;
      &lt;input name="auth" value="flowScope.auth" /&gt;
      &lt;input name="maxactivationflow" value="flowScope.maxactivationflow" /&gt;
  
  
      &lt;action-state id="initialFlowSetup"&gt;
          &lt;evaluate expression="usrInitialFlowSetupAction" /&gt;
          &lt;transition on="success" to="ticketGrantingTicketExistsCheck" /&gt;
          &lt;transition on="error" to="pickup_error_redirect" /&gt;
      &lt;/action-state&gt;
  
      &lt;decision-state id="ticketGrantingTicketExistsCheck"&gt;
          &lt;if test="flowScope.ticketGrantingTicketId != null" then="hasServiceCheck"
              else="gatewayRequestCheck" /&gt;
      &lt;/decision-state&gt;
  
      &lt;decision-state id="gatewayRequestCheck"&gt;
          &lt;if
              test="externalContext.requestParameterMap['gateway'] != '' &amp;amp;&amp;amp; externalContext.requestParameterMap['gateway'] != null &amp;amp;&amp;amp; flowScope.service != null"
              then="redirect" else="submit" /&gt;
      &lt;/decision-state&gt;
  
      &lt;decision-state id="hasServiceCheck"&gt;
          &lt;if test="flowScope.service != null" then="renewRequestCheck"
              else="viewGenericLoginSuccess" /&gt;
      &lt;/decision-state&gt;
  
      &lt;decision-state id="renewRequestCheck"&gt;
          &lt;if
              test="externalContext.requestParameterMap['renew'] != '' &amp;amp;&amp;amp; externalContext.requestParameterMap['renew'] != null"
              then="submit" else="generateServiceTicket" /&gt;
      &lt;/decision-state&gt;
  
      &lt;!-- The "warn" action makes the determination of whether to redirect directly 
          to the requested service or display the "confirmation" page to go back to 
          the server. --&gt;
      &lt;decision-state id="warn"&gt;
          &lt;if test="flowScope.warnCookieValue" then="showWarningView"
              else="redirect" /&gt;
      &lt;/decision-state&gt;
  
      &lt;!-- &lt;action-state id="startAuthenticate"&gt; &lt;action bean="x509Check" /&gt; &lt;transition 
          on="success" to="sendTicketGrantingTicket" /&gt; &lt;transition on="error" to="viewLoginForm" 
          /&gt; &lt;/action-state&gt; --&gt;
      &lt;view-state id="viewLoginForm" view="casLoginView"&gt;
          &lt;on-render&gt;
              &lt;evaluate expression="authenticationViaFormAction.setupForm()" /&gt;
              &lt;evaluate expression="authenticationViaFormAction.referenceData()"/&gt;
          &lt;/on-render&gt;
          &lt;transition on="submit" to="bindAndValidate" /&gt;
      &lt;/view-state&gt;
  
      &lt;action-state id="bindAndValidate"&gt;
          &lt;evaluate expression="usrAuthenticationViaFormAction" /&gt;
          &lt;transition on="success" to="submit" /&gt;
          &lt;transition on="error" to="redirect" /&gt;
      &lt;/action-state&gt;
  
      &lt;action-state id="submit"&gt;
          &lt;evaluate expression = "usrAuthenticationViaFormAction.setCredentialsToFlowScope()" /&gt;
          &lt;evaluate expression="usrAuthenticationViaFormAction.submit(flowRequestContext, flowScope.credentials, messageContext)" /&gt;
          &lt;transition on="success" to="sendTicketGrantingTicket" /&gt;
          &lt;transition on="authenticationFailure" to="pickup_error_redirect" /&gt;
          &lt;transition on="error" to="pickup_error_redirect"&gt;
              &lt;set name="errorCode" value="flowScope.errorCode" /&gt; &lt;!--  scope="conversation" /&gt;--&gt;
          &lt;/transition&gt;
      &lt;/action-state&gt;
  
      &lt;action-state id="sendTicketGrantingTicket"&gt;
          &lt;evaluate expression="sendTicketGrantingTicketAction" /&gt;
          &lt;transition on="success" to="serviceCheck" /&gt;
      &lt;/action-state&gt;
  
      &lt;decision-state id="serviceCheck"&gt;
          &lt;if test="flowScope.service != null" then="checkEnrollResponse"
              else="viewGenericLoginSuccess" /&gt;
      &lt;/decision-state&gt;
  
      &lt;decision-state id="checkEnrollResponse"&gt;
          &lt;if test="flowScope.enrollresponse != null" then="generateServiceTicket"
              else="checksywrrequired" /&gt;
      &lt;/decision-state&gt;
  
      &lt;!-- select the success modal based on the flow caller --&gt;
      &lt;decision-state id="checksywrrequired"&gt;
          &lt;if test="requestScope.sywLogin == 'true'" then="sywrRequired"
              else="generateServiceTicket" /&gt;
      &lt;/decision-state&gt;
  
      &lt;action-state id="sywrRequired"&gt;
          &lt;evaluate expression="usrIsSYWRUserCheckAction" /&gt;
          &lt;transition on="success" to="isAffinityCheckRequired" /&gt;
          &lt;transition on="error" to="generateServiceTicketNoSywr" /&gt;
      &lt;/action-state&gt;
      &lt;decision-state id="isAffinityCheckRequired"&gt;
          &lt;if test="requestScope.sourceSiteId==6" then="craftsmanAffinityCheck"
              else="generateServiceTicket" /&gt;
      &lt;/decision-state&gt;
      &lt;action-state id="craftsmanAffinityCheck"&gt;
      &lt;evaluate expression="ssoGatewayService.searchUserByMemberNumberInTelluride(flowScope.sywrNumber,
                      requestParameters.sourceSiteId)" result="returnEmailResponse"/&gt;
          &lt;transition on="success" to="checkForCcAffinityModal" /&gt;
      &lt;/action-state&gt;
  
      &lt;!-- 
          &lt;bean-action bean="ssoGatewayService" method="searchUserByMemberNumberInTelluride"&gt;
              &lt;method-arguments&gt;
                  &lt;argument expression="flowScope.sywrNumber" /&gt;
                  &lt;argument expression="${requestParameters.sourceSiteId}" /&gt;
              &lt;/method-arguments&gt;
              &lt;method-result name="returnEmailResponse" scope="flow" /&gt;
          &lt;/bean-action&gt;
       --&gt;
  
      &lt;decision-state id="checkForCcAffinityModal"&gt;
          &lt;if test="flowScope.returnEmailResponse.ccAffinity==true" then="generateServiceTicket"
              else="generateServiceTicketNoCcaffinity" /&gt;
      &lt;/decision-state&gt;
      &lt;action-state id="generateServiceTicketNoSywr"&gt;
          &lt;evaluate expression="generateServiceTicketAction" /&gt;
          &lt;transition on="success" to="sendtickettomodalforloginnosywr" /&gt;
          &lt;transition on="error" to="setErrorCode" /&gt;
          &lt;transition on="gateway" to="redirect" /&gt;
      &lt;/action-state&gt;
  
      &lt;action-state id="generateServiceTicketNoCcaffinity"&gt;
          &lt;evaluate expression="generateServiceTicketAction" /&gt;
          &lt;transition on="success" to="sendtickettomodalforloginnoccaffinity" /&gt;
          &lt;transition on="error" to="setErrorCode" /&gt;
          &lt;transition on="gateway" to="redirect" /&gt;
      &lt;/action-state&gt;
  
      &lt;action-state id="generateServiceTicket"&gt;
          &lt;evaluate expression="generateServiceTicketAction" /&gt;
          &lt;transition on="success" to="pickupticketmodal" /&gt;
          &lt;transition on="error" to="setErrorCode" /&gt;
          &lt;transition on="gateway" to="redirect" /&gt;
      &lt;/action-state&gt;
  
      &lt;action-state id="setErrorCode"&gt;
          &lt;evaluate expression="setErrorCodeBean.submit()" /&gt;
          &lt;transition on="success" to="pickup_error_redirect" /&gt;
      &lt;/action-state&gt;
  
      &lt;!-- the "viewGenericLogin" is the end state for when a user attempts to 
          login without coming directly from a service. They have only initialized 
          their single-sign on session. --&gt;
      &lt;end-state id="viewGenericLoginSuccess" view="casLoginGenericSuccessView" /&gt;
  
      &lt;!-- The "showWarningView" end state is the end state for when the user 
          has requested privacy settings (to be "warned") to be turned on. It delegates 
          to a view defines in default_views.properties that display the "Please click 
          here to go to the service." message. --&gt;
      &lt;end-state id="showWarningView" view="casLoginConfirmView" /&gt;
  
      &lt;!-- The "redirect" end state allows CAS to properly end the workflow while 
          still redirecting the user back to the service required. --&gt;
      &lt;end-state id="redirect" view="externalRedirect:#{requestScope.response.url}" /&gt;
  
      &lt;end-state id="viewServiceErrorView" view="viewServiceErrorView" /&gt;
  
      &lt;end-state id="viewServiceSsoErrorView" view="viewServiceSsoErrorView" /&gt;
  
  
      &lt;!-- select the success modal based on the flow caller --&gt;
      &lt;decision-state id="pickupticketmodal"&gt;
          &lt;if test="flowScope.enrollresponse != null" then="sendtickettomodal_reg"
              else="sendTicket" /&gt;
      &lt;/decision-state&gt;
  
      &lt;!-- send the service ticket back to the modal, no view required in this 
          subflow --&gt;
      &lt;end-state id="sendtickettomodal_reg"&gt;
          &lt;output name = "serviceTicketId" value = "requestScope.serviceTicketId"/&gt;
      &lt;/end-state&gt;
  
      &lt;!-- &lt;output-mapper&gt;
              &lt;mapping source="${requestScope.serviceTicketId}" target="serviceTicketId" /&gt;
          &lt;/output-mapper&gt; --&gt;
  
      &lt;decision-state id="sendTicket"&gt;
          &lt;if test="flowScope.auth != null &amp;amp;&amp;amp; flowScope.auth != ''"
              then="sendtickettomodalforloginnosywr" else="sendtickettomodalforlogin" /&gt;
      &lt;/decision-state&gt;
  
      &lt;end-state id="sendtickettomodalforlogin" view="/displayserviceticketandcookie"&gt;    
          &lt;output name = "modifyservice" value = "requestScope.modifyservice"/&gt;
          &lt;output name = "sywmax" value = "requestScope.sywmax"/&gt;
          &lt;output name = "irp" value = "requestScope.irp"/&gt;
          &lt;output name = "auth" value = "requestScope.auth"/&gt;
      &lt;/end-state&gt;
  
      &lt;!-- 
          &lt;output-mapper&gt;
              &lt;mapping source="${requestScope.modifyservice}" target="modifyservice"/&gt;
              &lt;mapping source="${requestScope.sywmax}" target="sywmax"/&gt;
              &lt;mapping source="${requestScope.irp}" target="irp"/&gt;
              &lt;mapping source="${requestScope.auth}" target="auth"/&gt;
          &lt;/output-mapper&gt;
       --&gt;
  
      &lt;!-- for login, directly sending the st to the modal --&gt;
      &lt;end-state id="sendtickettomodalforloginnosywr" view="displayserviceticketandcookienosywr" &gt;
          &lt;output name = "modifyservice" value = "requestScope.modifyservice"/&gt;
          &lt;output name = "irp" value = "requestScope.irp"/&gt;
      &lt;/end-state&gt;
      &lt;!-- 
          &lt;output-mapper&gt;
              &lt;mapping source="${requestScope.modifyservice}" target="modifyservice" /&gt;
              &lt;mapping source="${requestScope.irp}" target="irp" /&gt;
          &lt;/output-mapper&gt;
       --&gt;
      &lt;end-state id="sendtickettomodalforloginnoccaffinity" view="displayserviceticketandcookienoccaffinity"&gt;
          &lt;output name = "modifyservice" value = "requestScope.modifyservice"/&gt;
          &lt;output name = "irp" value = "requestScope.irp"/&gt;
      &lt;/end-state&gt;
      &lt;!-- 
          &lt;output-mapper&gt;
              &lt;mapping source="${requestScope.modifyservice}" target="modifyservice" /&gt;
              &lt;mapping source="${requestScope.irp}" target="irp" /&gt;
          &lt;/output-mapper&gt;
       --&gt;
  
      &lt;!-- for login, directly sending the st to the modal --&gt;
      &lt;end-state id="showTnCModal" view="/showTnCModalToUsers"&gt;
  
      &lt;/end-state&gt;
      &lt;!-- select the error redirect based on the flow caller --&gt;
      &lt;decision-state id="pickup_error_redirect"&gt;
          &lt;if test="flowScope.enrollresponse != null" then="pickup_error_redirect_reg"
              else="set_error_in_scope" /&gt;
      &lt;/decision-state&gt;
  
      &lt;action-state id="set_error_in_scope"&gt;
          &lt;evaluate expression="setErrorMessages.getErrorMessagesMap(flowRequestContext)" result="flowScope.errorMessageMap"
          result-type="java.util.HashMap"&gt;&lt;/evaluate&gt;
          &lt;transition on="success" to="pickup_error_redirect_login"&gt;  &lt;/transition&gt;
      &lt;/action-state&gt;
  
        &lt;!-- redirect when error to create sso session, no view required in this subflow --&gt;
      &lt;end-state id="pickup_error_redirect_reg"  /&gt;
  
  
      &lt;end-state id="pickup_error_redirect_login" view="/loginfailure" &gt;
          &lt;on-entry&gt;
              &lt;set name="flowScope.parameters" value="flowScope.errorMessageMap.parameters"&gt;&lt;/set&gt;
          &lt;/on-entry&gt;
      &lt;/end-state&gt;
  
  
      &lt;!-- current not properly defined the global error condition --&gt;
      &lt;global-transitions&gt;
          &lt;transition to="pickup_error_redirect"
              on-exception="org.springframework.webflow.execution.repository.NoSuchFlowExecutionException" /&gt;
          &lt;transition to="pickup_error_redirect"
              on-exception="org.jasig.cas.services.UnauthorizedSsoServiceException" /&gt;
          &lt;transition to="pickup_error_redirect"
              on-exception="org.jasig.cas.services.UnauthorizedServiceException" /&gt;
          &lt;transition to="pickup_error_redirect"
              on-exception="org.springframework.webflow.execution.FlowExecutionException" /&gt;
      &lt;/global-transitions&gt;
  
  &lt;/flow&gt;
  </code></pre>
  
  <p>Test Case</p>
  
  <pre><code> public class TestloginlFlow extends AbstractXmlFlowExecutionTests {
  
      UsrInitialFlowSetupAction usrInitialFlowSetupAction;
  
      AuthenticationViaFormAction authenticationViaFormAction;
  
      UsrIsSYWRUserCheckAction usrIsSYWRUserCheckAction;
  
      SSOGatewayService ssoGatewayService;
  
      CustomGenerateServiceTicketAction generateServiceTicketAction;
  
      CentralAuthenticationService centralAuthenticateService;
  
      CookieRetrievingCookieGenerator warnCookieGenerator;
  
      USRAuthenticationViaFormAction usrAuthenticationViaFormAction;
  
      List&lt;ArgumentExtractor&gt; argumentExtractor;
  
      SetErrorMessages setErrorMessages;
      RequestControlContext requestContext;
  
      @Override
      protected void setUp() throws Exception {
          usrInitialFlowSetupAction = EasyMock.createMock("usrInitialFlowSetupAction", UsrInitialFlowSetupAction.class); // usrAuthenticationViaFormAction
          setErrorMessages = EasyMock.createMock("SetErrorMessages", SetErrorMessages.class);
          usrAuthenticationViaFormAction = EasyMock.createMock("usrAuthenticationViaFormAction",
                  USRAuthenticationViaFormAction.class);
          usrIsSYWRUserCheckAction = EasyMock.createMock("usrIsSYWRUserCheckAction", UsrIsSYWRUserCheckAction.class); // ssoGatewayService
  
          ssoGatewayService = EasyMock.createMock("ssoGatewayService", SSOGatewayService.class);
          generateServiceTicketAction = EasyMock.createMock("generateServiceTicketAction",
                  CustomGenerateServiceTicketAction.class);
          centralAuthenticateService = EasyMock.createMock("centralAuthenticateService",
                  CentralAuthenticationService.class);
          warnCookieGenerator = EasyMock.createMock("centralAuthenticateService", CookieRetrievingCookieGenerator.class);
          argumentExtractor = EasyMock.createMock("argumentExtractors", List.class);
          generateServiceTicketAction = EasyMock.createMock("generateServiceTicketAction",
                  CustomGenerateServiceTicketAction.class);
          requestContext=EasyMock.createMock("requestContext",RequestControlContext.class);
      }
  
      @Override
      protected FlowDefinitionResource getResource(FlowDefinitionResourceFactory resourceFactory) {
          return resourceFactory.createFileResource("src/main/webapp/WEB-INF/usr/flows/shclogin-flow.xml");
      }
  
      @Override
      protected void registerMockFlowBeans(ConfigurableBeanFactory builderContext) {
  
          builderContext.registerSingleton("argumentExtractors", argumentExtractor);
          builderContext.registerSingleton("warnCookieGenerator", warnCookieGenerator);
          builderContext.registerSingleton("centralAuthenticateService", centralAuthenticateService);
          builderContext.registerSingleton("usrAuthenticationViaFormAction", usrAuthenticationViaFormAction);
          builderContext.registerSingleton("usrIsSYWRUserCheckAction", usrIsSYWRUserCheckAction);
          builderContext.registerSingleton("ssoGatewayService", ssoGatewayService);
          builderContext.registerSingleton("generateServiceTicketAction", generateServiceTicketAction);
          builderContext.registerSingleton("ticketGrantingTicketCookieGenerator", warnCookieGenerator);
          builderContext.registerSingleton("setErrorMessages", setErrorMessages);
          builderContext.registerSingleton("request", requestContext);
  
      }
  
      @Override
      protected void configureFlowBuilderContext(MockFlowBuilderContext builderContext) {
  
          usrAuthenticationViaFormAction.setCentralAuthenticationService(centralAuthenticateService);
          usrAuthenticationViaFormAction.setWarnCookieGenerator(warnCookieGenerator);
          builderContext.registerBean("warnCookieGenerator", warnCookieGenerator);
          builderContext.registerBean("centralAuthenticateService", centralAuthenticateService);
          builderContext.registerBean("usrAuthenticationViaFormAction", usrAuthenticationViaFormAction);
          builderContext.registerBean("usrIsSYWRUserCheckAction", usrIsSYWRUserCheckAction);
          builderContext.registerBean("ssoGatewayService", ssoGatewayService);
          builderContext.registerBean("generateServiceTicketAction", generateServiceTicketAction);
          builderContext.registerBean("setErrorMessages", setErrorMessages);
          builderContext.registerBean("request", requestContext);
  
      }
  
      public void testAction() throws Exception {
          setCurrentState("initialFlowSetup");
          MockExternalContext ctx = new MockExternalContext();
          MutableAttributeMap input = new LocalAttributeMap();
          MockRequestControlContext context = new MockRequestControlContext();
  
          FlowExecution flowExecution = getFlowExecution();
          FlowSession session = flowExecution.getActiveSession();
          Map&lt;String, Object&gt; model = new HashMap&lt;String, Object&gt;();
          model.put("originalUrl", 123);
          session.getScope().put("errorMessageMap", model);
  
          updateFlowExecution(flowExecution);
          ctx.setEventId("error");
          EasyMock.expect(setErrorMessages.getErrorMessagesMap(requestContext)).andReturn(model);
          EasyMock.replay(setErrorMessages);
  
          resumeFlow(ctx);
          assertResponseWrittenEquals("/loginfailure", ctx);
          assertFlowExecutionEnded();
  
      }
  
      public void testAction1() throws Exception {
      // setCurrentState("initialFlowSetup");
      MockExternalContext ctx = new MockExternalContext();
      MutableAttributeMap input = new LocalAttributeMap();
  
      input.put("loginId", "12");
      input.put("logonPassword", "ankur");
      input.put("sourceSiteId", "3");
      input.put("fullpage", "");
      input.put("partialuser", "true");
      input.put("service", "");
      input.put("redirectUrl", "");
      input.put("sywLogin", "er4fju");
      input.put("tncmodal", null);
      input.put("modifyservice", "no");
      // input.put("reglogin", false);
      // input.put("enrollresponse", 200);
      input.put("shcCaptchaKey", null);
      input.put("ticketGrantingTicketId", "1234");
      Map&lt;String, Object&gt; parameters = new HashMap&lt;&gt;();
      parameters.put("renew", "yes");
      ParameterMap requestParameterMap = new LocalParameterMap(parameters);
      ctx.setRequestParameterMap(requestParameterMap);
      MockRequestContext context = new MockRequestContext();
      Event event = new Event(this, "success");
      EasyMock.expect(usrInitialFlowSetupAction.doExecute(flowRequestContext)).andReturn(event);
      EasyMock.replay(usrInitialFlowSetupAction);
  
      //Mockito.mock(usrInitialFlowSetupAction.doExecute(flowRequestContext), event)
      /*
       * FlowExecution flowExecution = getFlowExecution(); FlowSession session
       * = flowExecution.getActiveSession();
       * session.getScope().put("ticketGrantingTicketId", "ee");
       */
      // updateFlowExecution(flowExecution);
  
      startFlow(input, ctx);
  
  }
  
  }
  </code></pre>