/** * Returns the action in this list at the provided index, exposing it as an annotated action. This allows clients to * access specific properties about a target action instance if they exist. * @return the action, as an annotated action */ public AnnotatedAction getAnnotated(int index) throws IndexOutOfBoundsException { Action action = get(index); if (action instanceof AnnotatedAction) { return (AnnotatedAction) action; } else { // wrap the action; no annotations will be available return new AnnotatedAction(action); } }
/** * Returns the action in this list at the provided index, exposing it as an annotated action. This allows clients to * access specific properties about a target action instance if they exist. * @return the action, as an annotated action */ public AnnotatedAction getAnnotated(int index) throws IndexOutOfBoundsException { Action action = get(index); if (action instanceof AnnotatedAction) { return (AnnotatedAction) action; } else { // wrap the action; no annotations will be available return new AnnotatedAction(action); } }
/** * Returns the action in this list at the provided index, exposing it as an annotated action. This allows clients to * access specific properties about a target action instance if they exist. * @return the action, as an annotated action */ public AnnotatedAction getAnnotated(int index) throws IndexOutOfBoundsException { Action action = get(index); if (action instanceof AnnotatedAction) { return (AnnotatedAction) action; } else { // wrap the action; no annotations will be available return new AnnotatedAction(action); } }
/** * Returns the action in this list at the provided index, exposing it as an annotated action. This allows clients to * access specific properties about a target action instance if they exist. * @return the action, as an annotated action */ public AnnotatedAction getAnnotated(int index) throws IndexOutOfBoundsException { Action action = get(index); if (action instanceof AnnotatedAction) { return (AnnotatedAction) action; } else { // wrap the action; no annotations will be available return new AnnotatedAction(action); } }
/** * Add multi factor outcome transitions to submission action state. * * @param flow the flow * @param flowIds the flow ids */ protected void addMultiFactorOutcomeTransitionsToSubmissionActionState(final Flow flow, final String[] flowIds) { final ActionState actionState = (ActionState) flow.getState(STATE_DEFINITION_ID_REAL_SUBMIT); LOGGER.debug("Retrieved action state {}", actionState.getId()); final Action existingAction = actionState.getActionList().get(0); actionState.getActionList().remove(existingAction); final EvaluateAction action = createEvaluateAction("initiatingAuthenticationViaFormAction"); actionState.getActionList().add(action); LOGGER.debug("Set action {} for action state {}", actionState.getId()); for (final String flowId : flowIds) { addTransitionToActionState(actionState, flowId, flowId); } }
public void testExecuteActionCannotHandleResultEvent() { state.getActionList().add(new TestAction()); try { state.enter(context); fail("Should've failed"); } catch (NoMatchingTransitionException e) { assertEquals(1, ((TestAction) state.getActionList().get(0)).getExecutionCount()); } }
public void testExecuteSingleAction() { state.getActionList().add(new TestAction()); state.getTransitionSet().add(new Transition(on("success"), to("finish"))); state.enter(context); assertEquals(1, ((TestAction) state.getActionList().get(0)).getExecutionCount()); }
public void testSetActionWithResultType() throws Exception { SetModel setModel = new SetModel("flowScope.stringArray", "intArray"); setModel.setType("java.lang.String[]"); model.setOnStartActions(asList(setModel)); model.setStates(asList(new ViewStateModel("view"))); Flow flow = getFlow(model); AnnotatedAction action = (AnnotatedAction) flow.getStartActionList().get(0); MockRequestContext context = new MockRequestContext(flow); context.getFlowScope().put("intArray", new int[] { 1, 2 }); action.execute(context); String[] expected = (String[]) context.getFlowScope().get("stringArray"); assertEquals("1", expected[0]); assertEquals("2", expected[1]); }
public void testSetActionWithImplicitTypeConversion() throws Exception { SetModel setModel = new SetModel("testBean.stringArray", "intArray"); model.setOnStartActions(asList(setModel)); ViewStateModel state = new ViewStateModel("view"); model.setStates(asList(state)); Flow flow = getFlow(model); AnnotatedAction action = (AnnotatedAction) flow.getStartActionList().get(0); MockRequestContext context = new MockRequestContext(flow); context.getFlowScope().put("testBean", new TestBean()); context.getFlowScope().put("intArray", new int[] { 1, 2 }); action.execute(context); TestBean expected = (TestBean) context.getFlowScope().get("testBean"); assertEquals("1", expected.stringArray[0]); assertEquals("2", expected.stringArray[1]); }
public void testEvaluateActionWithELExpression() throws Exception { EvaluateModel evaluateModel = new EvaluateModel("testBean.getIntegers()"); evaluateModel.setResult("flowScope.stringArray"); evaluateModel.setResultType("java.lang.String[]"); model.setOnStartActions(asList(evaluateModel)); model.setStates(asList(new ViewStateModel("view"))); Flow flow = getFlow(model); AnnotatedAction action = (AnnotatedAction) flow.getStartActionList().get(0); MockRequestContext context = new MockRequestContext(flow); context.getFlowScope().put("testBean", new TestBean()); action.execute(context); String[] expected = (String[]) context.getFlowScope().get("stringArray"); assertEquals("1", expected[0]); assertEquals("2", expected[1]); }
public void testEvaluateActionWithResultType() throws Exception { EvaluateModel evaluateModel = new EvaluateModel("testBean.getIntegers()"); evaluateModel.setResult("flowScope.stringArray"); evaluateModel.setResultType("java.lang.String[]"); model.setOnStartActions(asList(evaluateModel)); model.setStates(asList(new ViewStateModel("view"))); Flow flow = getFlow(model); AnnotatedAction action = (AnnotatedAction) flow.getStartActionList().get(0); MockRequestContext context = new MockRequestContext(flow); context.getFlowScope().put("testBean", new TestBean()); action.execute(context); String[] expected = (String[]) context.getFlowScope().get("stringArray"); assertEquals("1", expected[0]); assertEquals("2", expected[1]); }