org.springframework.webflow.engine.Flow.<init>()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(8.5k)|赞(0)|评价(0)|浏览(149)

本文整理了Java中org.springframework.webflow.engine.Flow.<init>()方法的一些代码示例,展示了Flow.<init>()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Flow.<init>()方法的具体详情如下:
包路径:org.springframework.webflow.engine.Flow
类名称:Flow
方法名:<init>

Flow.<init>介绍

[英]Construct a new flow definition with the given id. The id should be unique among all flows.
[中]使用给定id构造新的流定义。该id在所有流中应该是唯一的。

代码示例

代码示例来源:origin: org.springframework.webflow/spring-webflow

/**
 * Creates a new mock flow session that sets a flow with id "mockFlow" as the 'active flow' in state "mockState".
 */
public MockFlowSession() {
  setDefinition(new Flow("mockFlow"));
  State state = new TransitionableState(definition, "mockState") {
    protected void doEnter(RequestControlContext context) throws FlowExecutionException {
      // nothing to do
    }
  };
  setState(state);
}

代码示例来源:origin: org.springframework.webflow/spring-webflow

/**
 * Create a new flow with the given id and attributes.
 * @param id the flow id
 * @param attributes the attributes
 * @return the flow
 */
public static Flow create(String id, AttributeMap<?> attributes) {
  Flow flow = new Flow(id);
  flow.getAttributes().putAll(attributes);
  return flow;
}

代码示例来源:origin: spring-projects/spring-webflow

public void setUp() {
  flow = new Flow("flow");
  state = new State(flow, "myState") {
    protected void doEnter(RequestControlContext context) throws FlowExecutionException {
      entered = true;
    }
  };
}

代码示例来源:origin: spring-projects/spring-webflow

/**
 * Creates a new mock flow session that sets a flow with id "mockFlow" as the 'active flow' in state "mockState".
 */
public MockFlowSession() {
  setDefinition(new Flow("mockFlow"));
  State state = new TransitionableState(definition, "mockState") {
    protected void doEnter(RequestControlContext context) throws FlowExecutionException {
      // nothing to do
    }
  };
  setState(state);
}

代码示例来源:origin: spring-projects/spring-webflow

public void testGetStateNoStartState() {
  Flow flow = new Flow("myFlow");
  try {
    flow.getStartState();
    fail("Retrieved start state when no such state");
  } catch (IllegalStateException e) {
    // expected
  }
}

代码示例来源:origin: spring-projects/spring-webflow

protected void setUp() throws Exception {
  flow = new Flow("myFlow");
  state = new EndState(flow, "end");
  context = new MockRequestContext(flow);
}

代码示例来源:origin: spring-projects/spring-webflow

public void testMultipleFlowMatch() {
    FlowExecutionListenerCriteria c = factory.flows("foo", "bar");
    assertEquals(true, c.appliesTo(new Flow("foo")));
    assertEquals(true, c.appliesTo(new Flow("bar")));
    assertEquals(false, c.appliesTo(new Flow("baz")));
  }
}

代码示例来源:origin: spring-projects/spring-webflow

public void testStartWithoutStartState() {
  MockRequestControlContext context = new MockRequestControlContext(flow);
  try {
    Flow empty = new Flow("empty");
    empty.start(context, null);
    fail("should have failed");
  } catch (IllegalStateException e) {
  }
}

代码示例来源:origin: spring-projects/spring-webflow

public void testStaticListener() {
  final FlowExecutionListener listener1 = new FlowExecutionListener() {};
  loader = new StaticFlowExecutionListenerLoader(listener1);
  assertEquals(listener1, loader.getListeners(new Flow("foo"))[0]);
}

代码示例来源:origin: spring-projects/spring-webflow

protected void setUp() {
  flow = new Flow("myFlow");
  state = new TransitionableState(flow, "state1") {
    protected void doEnter(RequestControlContext context) {
      throw new FlowExecutionException(getFlow().getId(), getId(), "Oops!", new TestException());
    }
  };
  state.getTransitionSet().add(new Transition(toState("end")));
}

代码示例来源:origin: spring-projects/spring-webflow

private MockRequestContext getRequestContext() {
    Flow flow = new Flow("id");
    MockRequestContext ctx = new MockRequestContext(flow);
    RequestContextHolder.setRequestContext(ctx);
    ctx.getFlowScope().put("foo", "bar");
    ctx.setCurrentEvent(new Event(this, "sample"));
    return ctx;
  }
}

代码示例来源:origin: spring-projects/spring-webflow

public void testEnterEndStateTerminateFlowExecution() {
  Flow flow = new Flow("myFlow");
  EndState state = new EndState(flow, "end");
  MockRequestControlContext context = new MockRequestControlContext(flow);
  state.enter(context);
  assertFalse("Active", context.getFlowExecutionContext().isActive());
}

代码示例来源:origin: spring-projects/spring-webflow

public void testStartCannotCallTwice() {
  Flow flow = new Flow("flow");
  new EndState(flow, "end");
  FlowExecutionImpl execution = new FlowExecutionImpl(flow);
  MockExternalContext context = new MockExternalContext();
  execution.start(null, context);
  try {
    execution.start(null, context);
    fail("Should've failed");
  } catch (IllegalStateException e) {
  }
}

代码示例来源:origin: spring-projects/spring-webflow

public void testResumeAfterEnding() {
  Flow flow = new Flow("flow");
  new EndState(flow, "end");
  FlowExecutionImpl execution = new FlowExecutionImpl(flow);
  MockExternalContext context = new MockExternalContext();
  execution.start(null, context);
  try {
    execution.resume(context);
    fail("Should've failed");
  } catch (IllegalStateException e) {
  }
}

代码示例来源:origin: spring-projects/spring-webflow

public void testGetFlowExecutorBasicConfig() throws Exception {
  factoryBean.setFlowDefinitionLocator(id -> {
    Flow flow = new Flow(id);
    ViewState view = new ViewState(flow, "view", new StubViewFactory());
    view.getTransitionSet().add(new Transition(new DefaultTargetStateResolver("end")));
    new EndState(flow, "end");
    return flow;
  });
  factoryBean.afterPropertiesSet();
  factoryBean.getObject();
}

代码示例来源:origin: spring-projects/spring-webflow

private Flow createSimpleFlow() {
  flow = new Flow("myFlow");
  ViewState state1 = new ViewState(flow, "myState1", new StubViewFactory());
  state1.getTransitionSet().add(new Transition(on("submit"), to("myState2")));
  new EndState(flow, "myState2");
  flow.getGlobalTransitionSet().add(new Transition(on("globalEvent"), to("myState2")));
  return flow;
}

代码示例来源:origin: spring-projects/spring-webflow

public void testEnterViewStateWithNoLocalRedirect() {
  Flow flow = new Flow("myFlow");
  StubViewFactory viewFactory = new StubViewFactory();
  ViewState state = new ViewState(flow, "viewState", viewFactory);
  state.setRedirect(false);
  MockRequestControlContext context = new MockRequestControlContext(flow);
  context.getFlashScope().put("foo", "bar");
  state.enter(context);
  assertTrue("Render called", context.getFlowScope().contains("renderCalled"));
  assertFalse(context.getMockExternalContext().getFlowExecutionRedirectRequested());
  assertFalse(context.getFlashScope().contains("foo"));
}

代码示例来源:origin: spring-projects/spring-webflow

public void testEnterViewStateRedirectResponseAlreadyComplete() {
  Flow flow = new Flow("myFlow");
  StubViewFactory viewFactory = new StubViewFactory();
  ViewState state = new ViewState(flow, "viewState", viewFactory);
  MockRequestControlContext context = new MockRequestControlContext(flow);
  context.getExternalContext().requestFlowExecutionRedirect();
  context.getFlashScope().put("foo", "bar");
  state.enter(context);
  assertFalse("Render called", context.getFlowScope().contains("renderCalled"));
  assertTrue(context.getMockExternalContext().getFlowExecutionRedirectRequested());
  assertTrue(context.getFlashScope().contains("foo"));
}

代码示例来源:origin: spring-projects/spring-webflow

public void testEnterViewStateRenderResponse() {
  Flow flow = new Flow("myFlow");
  StubViewFactory viewFactory = new StubViewFactory();
  ViewState state = new ViewState(flow, "viewState", viewFactory);
  MockRequestControlContext context = new MockRequestControlContext(flow);
  context.getFlashScope().put("foo", "bar");
  state.enter(context);
  assertTrue("Render not called", context.getFlowScope().contains("renderCalled"));
  assertTrue(context.getExternalContext().isResponseComplete());
  assertFalse(context.getMockExternalContext().getFlowExecutionRedirectRequested());
  assertFalse(context.getFlashScope().contains("foo"));
}

代码示例来源:origin: spring-projects/spring-webflow

public void testElseDecision() {
  Flow flow = new Flow("flow");
  DecisionState state = new DecisionState(flow, "decisionState");
  state.getTransitionSet().add(new Transition(new MockTransitionCriteria("foo"), to("invalid")));
  state.getTransitionSet().add(new Transition(to("target")));
  new EndState(flow, "target");
  MockRequestControlContext context = new MockRequestControlContext(flow);
  context.setCurrentEvent(new Event(this, "bogus"));
  state.enter(context);
  assertFalse(context.getFlowExecutionContext().isActive());
}

相关文章