2016-08-30 1 views
0

Wenn ich Methode mit EasyMock aufrufen und die Erwartung für den Methodenaufruf setzen, in welcher Methode Ergebnis zurückgeben ist Map. In meinem Testfall ist das Ergebnis der Rückgabe nicht von Feder webflow genommen. Die Methode erwartet den RequestContext von spring webflow, der org.springframework.webflow.execution.RequestContext ist. Ich versuche, die MockRequestContext in JUnit-Testfall zu passieren, aber es funktioniert nicht Im Folgenden wird der Fehlerjava.lang.AssertionError: erwartet: 1, tatsächlich: 0 Frühling webflow junit

org.springframework.webflow.execution.ActionExecutionException: Exception thrown executing [[email protected] targetAction = [[email protected] 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:193) 
    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 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$$500571b9] 
    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) 
    ... 32 more 
Caused by: java.lang.AssertionError: 
    Unexpected method call SetErrorMessages.getErrorMessagesMap([[email protected] externalContext = [email protected], currentEvent = [null], requestScope = map[[empty]], attributes = map[[empty]], messageContext = [[email protected] sourceMessages = map[[null] -> list[[empty]]]], flowExecution = [[email protected] flow = 'shclogin-flow', flowSessions = list[[[email protected] flow = 'shclogin-flow', state = 'set_error_in_scope', scope = map[[empty]]]]]]): 
    SetErrorMessages.getErrorMessagesMap(flowRequestContext): 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$$500571b9.getErrorMessagesMap(<generated>) 
    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) 
    ... 42 more 

Testfälle

public class TestloginlFlow extends AbstractXmlFlowExecutionTests { 

    UsrInitialFlowSetupAction usrInitialFlowSetupAction; 

    AuthenticationViaFormAction authenticationViaFormAction; 

    UsrIsSYWRUserCheckAction usrIsSYWRUserCheckAction; 

    SSOGatewayService ssoGatewayService; 

    CustomGenerateServiceTicketAction generateServiceTicketAction; 

    CentralAuthenticationService centralAuthenticateService; 

    CookieRetrievingCookieGenerator warnCookieGenerator; 

    USRAuthenticationViaFormAction usrAuthenticationViaFormAction; 

    List<ArgumentExtractor> argumentExtractor; 

    SetErrorMessages setErrorMessages; 
    MockRequestContext flowRequestContext; 

    @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); 
     flowRequestContext = EasyMock.createMock("flowRequestContext", MockRequestContext.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("usrInitialFlowSetupAction", usrInitialFlowSetupAction); 
     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("flowRequestContext", flowRequestContext); 

    } 

    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<String, Object> parameters = new HashMap<>(); 
     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); 
     /* 
     * FlowExecution flowExecution = getFlowExecution(); FlowSession session 
     * = flowExecution.getActiveSession(); 
     * session.getScope().put("ticketGrantingTicketId", "ee"); 
     */ 
     // updateFlowExecution(flowExecution); 

     startFlow(input, ctx); 

    } 

    public void testAction() throws Exception { 
     setCurrentState("initialFlowSetup"); 

     FlowExecutionContext flowExecution = getFlowExecution(); 

     MockRequestContext context = new MockRequestContext(); 

     MockExternalContext ctx = new MockExternalContext(); 
     //context.setExternalContext(ctx); 
     //context.setFlowExecutionContext(flowExecution); 
     //context.setActiveSession(flowExecution.getActiveSession()); 
     Map<String, Object> model = new HashMap<String, Object>(); 
     model.put("originalUrl", 123); 
     model.put("parameters", "xyz"); 
     // context.getFlowScope().put("errorMessageMap", model); 

     ctx.setEventId("error"); 
     EasyMock.expect(setErrorMessages.getErrorMessagesMap(flowRequestContext)).andReturn(model); 
     EasyMock.replay(setErrorMessages); 

     resumeFlow(ctx); 
     assertResponseWrittenEquals("/loginfailure", ctx); 
     assertFlowExecutionEnded(); 

    } 

} 

xml fließen

version="1.0" encoding="UTF-8"?> 
<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" > 


    <input name="loginId" value="requestScope.loginId" /> 
    <input name="logonPassword" value="requestScope.logonPassword" /> 
    <input name="sourceSiteId" value="requestScope.sourceSiteId" /> 
    <input name="fullpage" value="requestScope.fullpage" /> 
    <input name="partialuser" value="requestScope.partialuser" /> 
    <input name="sourceSiteId" value="flowScope.sourceSite" /> 
    <input name="service" value="requestScope.service" /> 
    <input name="redirectUrl" value="requestScope.redirectUrl" /> 
    <input name="sywLogin" value="requestScope.sywLogin" /> 
    <input name="tncmodal" value="requestScope.tncmodal" /> 
    <input name="modifyservice" value="requestScope.modifyservice" /> 
    <input name="reglogin" value="flowScope.reglogin" /> 
    <input name="enrollresponse" value="flowScope.enrollresponse" /> 
    <input name="shcCaptchaKey" value="requestScope.shcKey" /> 
    <input name="shcCaptchaResponse" value="requestScope.shcResponse" /> 
    <input name="sywmax" value="flowScope.sywmax" /> 
    <input name="auth" value="flowScope.auth" /> 
    <input name="maxactivationflow" value="flowScope.maxactivationflow" /> 


    <action-state id="initialFlowSetup"> 
     <evaluate expression="usrInitialFlowSetupAction" /> 
     <transition on="success" to="ticketGrantingTicketExistsCheck" /> 
     <transition on="error" to="pickup_error_redirect" /> 
    </action-state> 

    <decision-state id="ticketGrantingTicketExistsCheck"> 
     <if test="flowScope.ticketGrantingTicketId != null" then="hasServiceCheck" 
      else="gatewayRequestCheck" /> 
    </decision-state> 

    <decision-state id="gatewayRequestCheck"> 
     <if 
      test="externalContext.requestParameterMap['gateway'] != '' &amp;&amp; externalContext.requestParameterMap['gateway'] != null &amp;&amp; flowScope.service != null" 
      then="redirect" else="submit" /> 
    </decision-state> 

    <decision-state id="hasServiceCheck"> 
     <if test="flowScope.service != null" then="renewRequestCheck" 
      else="viewGenericLoginSuccess" /> 
    </decision-state> 

    <decision-state id="renewRequestCheck"> 
     <if 
      test="externalContext.requestParameterMap['renew'] != '' &amp;&amp; externalContext.requestParameterMap['renew'] != null" 
      then="submit" else="generateServiceTicket" /> 
    </decision-state> 

    <!-- 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. --> 
    <decision-state id="warn"> 
     <if test="flowScope.warnCookieValue" then="showWarningView" 
      else="redirect" /> 
    </decision-state> 

    <!-- <action-state id="startAuthenticate"> <action bean="x509Check" /> <transition 
     on="success" to="sendTicketGrantingTicket" /> <transition on="error" to="viewLoginForm" 
     /> </action-state> --> 
    <view-state id="viewLoginForm" view="casLoginView"> 
     <on-render> 
      <evaluate expression="authenticationViaFormAction.setupForm()" /> 
      <evaluate expression="authenticationViaFormAction.referenceData()"/> 
     </on-render> 
     <transition on="submit" to="bindAndValidate" /> 
    </view-state> 

    <action-state id="bindAndValidate"> 
     <evaluate expression="usrAuthenticationViaFormAction" /> 
     <transition on="success" to="submit" /> 
     <transition on="error" to="redirect" /> 
    </action-state> 

    <action-state id="submit"> 
     <evaluate expression = "usrAuthenticationViaFormAction.setCredentialsToFlowScope()" /> 
     <evaluate expression="usrAuthenticationViaFormAction.submit(flowRequestContext, flowScope.credentials, messageContext)" /> 
     <transition on="success" to="sendTicketGrantingTicket" /> 
     <transition on="authenticationFailure" to="pickup_error_redirect" /> 
     <transition on="error" to="pickup_error_redirect"> 
      <set name="errorCode" value="flowScope.errorCode" /> <!-- scope="conversation" />--> 
     </transition> 
    </action-state> 

    <action-state id="sendTicketGrantingTicket"> 
     <evaluate expression="sendTicketGrantingTicketAction" /> 
     <transition on="success" to="serviceCheck" /> 
    </action-state> 

    <decision-state id="serviceCheck"> 
     <if test="flowScope.service != null" then="checkEnrollResponse" 
      else="viewGenericLoginSuccess" /> 
    </decision-state> 

    <decision-state id="checkEnrollResponse"> 
     <if test="flowScope.enrollresponse != null" then="generateServiceTicket" 
      else="checksywrrequired" /> 
    </decision-state> 

    <!-- select the success modal based on the flow caller --> 
    <decision-state id="checksywrrequired"> 
     <if test="requestScope.sywLogin == 'true'" then="sywrRequired" 
      else="generateServiceTicket" /> 
    </decision-state> 

    <action-state id="sywrRequired"> 
     <evaluate expression="usrIsSYWRUserCheckAction" /> 
     <transition on="success" to="isAffinityCheckRequired" /> 
     <transition on="error" to="generateServiceTicketNoSywr" /> 
    </action-state> 
    <decision-state id="isAffinityCheckRequired"> 
     <if test="requestScope.sourceSiteId==6" then="craftsmanAffinityCheck" 
      else="generateServiceTicket" /> 
    </decision-state> 
    <action-state id="craftsmanAffinityCheck"> 
    <evaluate expression="ssoGatewayService.searchUserByMemberNumberInTelluride(flowScope.sywrNumber, 
        requestParameters.sourceSiteId)" result="returnEmailResponse"/> 
     <transition on="success" to="checkForCcAffinityModal" /> 
    </action-state> 

    <!-- 
     <bean-action bean="ssoGatewayService" method="searchUserByMemberNumberInTelluride"> 
      <method-arguments> 
       <argument expression="flowScope.sywrNumber" /> 
       <argument expression="${requestParameters.sourceSiteId}" /> 
      </method-arguments> 
      <method-result name="returnEmailResponse" scope="flow" /> 
     </bean-action> 
    --> 

    <decision-state id="checkForCcAffinityModal"> 
     <if test="flowScope.returnEmailResponse.ccAffinity==true" then="generateServiceTicket" 
      else="generateServiceTicketNoCcaffinity" /> 
    </decision-state> 
    <action-state id="generateServiceTicketNoSywr"> 
     <evaluate expression="generateServiceTicketAction" /> 
     <transition on="success" to="sendtickettomodalforloginnosywr" /> 
     <transition on="error" to="setErrorCode" /> 
     <transition on="gateway" to="redirect" /> 
    </action-state> 

    <action-state id="generateServiceTicketNoCcaffinity"> 
     <evaluate expression="generateServiceTicketAction" /> 
     <transition on="success" to="sendtickettomodalforloginnoccaffinity" /> 
     <transition on="error" to="setErrorCode" /> 
     <transition on="gateway" to="redirect" /> 
    </action-state> 

    <action-state id="generateServiceTicket"> 
     <evaluate expression="generateServiceTicketAction" /> 
     <transition on="success" to="pickupticketmodal" /> 
     <transition on="error" to="setErrorCode" /> 
     <transition on="gateway" to="redirect" /> 
    </action-state> 

    <action-state id="setErrorCode"> 
     <evaluate expression="setErrorCodeBean.submit()" /> 
     <transition on="success" to="pickup_error_redirect" /> 
    </action-state> 

    <!-- 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. --> 
    <end-state id="viewGenericLoginSuccess" view="casLoginGenericSuccessView" /> 

    <!-- 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. --> 
    <end-state id="showWarningView" view="casLoginConfirmView" /> 

    <!-- The "redirect" end state allows CAS to properly end the workflow while 
     still redirecting the user back to the service required. --> 
    <end-state id="redirect" view="externalRedirect:#{requestScope.response.url}" /> 

    <end-state id="viewServiceErrorView" view="viewServiceErrorView" /> 

    <end-state id="viewServiceSsoErrorView" view="viewServiceSsoErrorView" /> 


    <!-- select the success modal based on the flow caller --> 
    <decision-state id="pickupticketmodal"> 
     <if test="flowScope.enrollresponse != null" then="sendtickettomodal_reg" 
      else="sendTicket" /> 
    </decision-state> 

    <!-- send the service ticket back to the modal, no view required in this 
     subflow --> 
    <end-state id="sendtickettomodal_reg"> 
     <output name = "serviceTicketId" value = "requestScope.serviceTicketId"/> 
    </end-state> 

    <!-- <output-mapper> 
      <mapping source="${requestScope.serviceTicketId}" target="serviceTicketId" /> 
     </output-mapper> --> 

    <decision-state id="sendTicket"> 
     <if test="flowScope.auth != null &amp;&amp; flowScope.auth != ''" 
      then="sendtickettomodalforloginnosywr" else="sendtickettomodalforlogin" /> 
    </decision-state> 

    <end-state id="sendtickettomodalforlogin" view="/displayserviceticketandcookie">  
     <output name = "modifyservice" value = "requestScope.modifyservice"/> 
     <output name = "sywmax" value = "requestScope.sywmax"/> 
     <output name = "irp" value = "requestScope.irp"/> 
     <output name = "auth" value = "requestScope.auth"/> 
    </end-state> 

    <!-- 
     <output-mapper> 
      <mapping source="${requestScope.modifyservice}" target="modifyservice"/> 
      <mapping source="${requestScope.sywmax}" target="sywmax"/> 
      <mapping source="${requestScope.irp}" target="irp"/> 
      <mapping source="${requestScope.auth}" target="auth"/> 
     </output-mapper> 
    --> 

    <!-- for login, directly sending the st to the modal --> 
    <end-state id="sendtickettomodalforloginnosywr" view="displayserviceticketandcookienosywr" > 
     <output name = "modifyservice" value = "requestScope.modifyservice"/> 
     <output name = "irp" value = "requestScope.irp"/> 
    </end-state> 
    <!-- 
     <output-mapper> 
      <mapping source="${requestScope.modifyservice}" target="modifyservice" /> 
      <mapping source="${requestScope.irp}" target="irp" /> 
     </output-mapper> 
    --> 
    <end-state id="sendtickettomodalforloginnoccaffinity" view="displayserviceticketandcookienoccaffinity"> 
     <output name = "modifyservice" value = "requestScope.modifyservice"/> 
     <output name = "irp" value = "requestScope.irp"/> 
    </end-state> 
    <!-- 
     <output-mapper> 
      <mapping source="${requestScope.modifyservice}" target="modifyservice" /> 
      <mapping source="${requestScope.irp}" target="irp" /> 
     </output-mapper> 
    --> 

    <!-- for login, directly sending the st to the modal --> 
    <end-state id="showTnCModal" view="/showTnCModalToUsers"> 

    </end-state> 
    <!-- select the error redirect based on the flow caller --> 
    <decision-state id="pickup_error_redirect"> 
     <if test="flowScope.enrollresponse != null" then="pickup_error_redirect_reg" 
      else="set_error_in_scope" /> 
    </decision-state> 

    <action-state id="set_error_in_scope"> 
     <evaluate expression="setErrorMessages.getErrorMessagesMap(flowRequestContext)" result="flowScope.errorMessageMap" 
     result-type="java.util.HashMap"></evaluate> 
     <transition on="success" to="pickup_error_redirect_login"> </transition> 
    </action-state> 

     <!-- redirect when error to create sso session, no view required in this subflow --> 
    <end-state id="pickup_error_redirect_reg" /> 


    <end-state id="pickup_error_redirect_login" view="/loginfailure" > 
     <on-entry> 
      <set name="flowScope.parameters" value="flowScope.errorMessageMap.parameters"></set> 
     </on-entry> 
    </end-state> 


    <!-- current not properly defined the global error condition --> 
    <global-transitions> 
     <transition to="pickup_error_redirect" 
      on-exception="org.springframework.webflow.execution.repository.NoSuchFlowExecutionException" /> 
     <transition to="pickup_error_redirect" 
      on-exception="org.jasig.cas.services.UnauthorizedSsoServiceException" /> 
     <transition to="pickup_error_redirect" 
      on-exception="org.jasig.cas.services.UnauthorizedServiceException" /> 
     <transition to="pickup_error_redirect" 
      on-exception="org.springframework.webflow.execution.FlowExecutionException" /> 
    </global-transitions> 

</flow> 

Antwort

0

Sie haben immer noch die gleiche Probleme, bei denen es darum geht, das gleiche Objekt als Parameter zu verspotten und zu erwarten.

Warum interessieren Sie sich so sehr für das Objekt flowRequestContext?

EasyMock.expect(setErrorMessages.getErrorMessagesMap(flowRequestContext)).andReturn(model); 

nur verwenden:

EasyMock.expect(setErrorMessages.getErrorMessagesMap((RequestContext)EasyMock.anyObject())).andReturn(model); 

, die mit jeder Instanz von Request arbeiten, die in Ihrem Fluss sein können

+0

Ja, ich tat es und es funktioniert, eine weitere Sache, Ich mag würde fragen Wenn Sie diese flowScope.ticketGrantingTicketId im Flow-Bereich sehen, bin ich mir nicht sicher, wie dies beim Schreiben von junit im Flow-Bereich verfügbar sein wird, da wir sie in unserem Flow nicht irgendwo einstellen. Können Sie bitte sagen, bevor Sie den Flow selbst beginnen, wie wir zur Verfügung stellen flowScope.ticketGrantingTicketId, flowScope.service usw. – henrycharles

+0

wird es am Anfang null sein, und es sieht aus wie generateServiceTicketAction könnte diese ticketgrantingTicketId setzen. Nun, das wäre meine Vermutung – rptmat57

+0

Ja, das wurde von der Methode festgelegt, aber ich habe verspottet, dass es irgendeinen anderen Weg gibt, den Flussbereich variabel zu setzen, bevor Sie den Fluss – henrycharles

Verwandte Themen