Junit测试子流,里面有多重过渡

时间:2016-08-24 18:41:48

标签: junit4 spring-webflow-2

嗨我在子流程中有多个过渡状态如何测试那些过渡。当我的流程遇到子流内的第一个过渡状态时,它会抛出org.springframework.webflow.engine.NoMatchingTransitionException: No transition found on occurence of event 'process_and_redirect' in state 'go_to_login_flow' of flow 'regEnroll-flow' -- valid transitional criteria are array<TransitionCriteria>[finish, redirect, sendtickettomodal_reg, pickup_error_redirect_reg, pickup_error_redirect_login] -- likely programmer error, check the set of TransitionCriteria for this state

然后,Error将委托给全局转换标记,其中将转到淋浴视图页面。我需要编写子流的测试用例,我不知道如何测试它。

这是我的webflow定义的链接 not able to get the flow scope variable from one state transition to another state transition junit

这是我到目前为止所尝试的内容 嘲笑子流并在

中注册
@Override
protected void configureFlowBuilderContext(MockFlowBuilderContext builderContext) {
    // I Have tried even mocking using Easy Mock
    saveQueryParamInSession = EasyMock.createMock("saveQueryParamInSession", SavingQueryParamInSessionAction.class);
    ssoGatewayService = EasyMock.createMock("ssoGatewayService", SSOGatewayServiceImpl.class);
    sywNumSetupAction = EasyMock.createMock("sywNumSetupAction", SywNumSetupAction.class);
    regEnrollFormAction = EasyMock.createMock("regEnrollFormAction", RegEnrollFormAction.class);

    builderContext.registerBean("saveQueryParamInSession", saveQueryParamInSession);

    builderContext.registerBean("sywNumSetupAction", sywNumSetupAction);
    builderContext.registerBean("ssoGatewayService", ssoGatewayService);
    builderContext.registerBean("regEnrollFormAction", regEnrollFormAction);
    Flow mockDetailFlow = new Flow("shclogin-flow");
    mockDetailFlow.setInputMapper(new Mapper() {
        @SuppressWarnings("unchecked")
        public MappingResults map(Object source, Object target) {

            return null;
        }
    });

    new EndState(mockDetailFlow, "process_and_redirect");
    builderContext.registerSubflow(mockDetailFlow);

}

测试用例

public void testsubflowTransition() throws Exception {

        setCurrentState("renderform");
        MockExternalContext context = new MockExternalContext();

        FlowExecution flowExecution = getFlowExecution();
        FlowSession session = flowExecution.getActiveSession();

        Regform regform = createRegistrationForm();
        session.getScope().put("regform", regform);
        session.getScope().put("reglogin", "yes");
        ResponseVO value = new ResponseVO(200, "success");
        updateFlowExecution(flowExecution);
        context.setEventId("submit");
        EasyMock.expect(ssoGatewayService.register(regform, context)).andReturn(value);
        EasyMock.expect(ssoGatewayService
                .updateCCAffinity(flowExecution.getActiveSession().getScope().get("regform", Regform.class), value))
                .andReturn(value);
        EasyMock.replay(ssoGatewayService);
        flowExecution.resume(context);
        setCurrentState("go_to_login_flow");
        context.setEventId("sendtickettomodal_reg");
        flowExecution.resume(context);

0 个答案:

没有答案