public void testStateEnteringWithSecurity() { SecurityFlowExecutionListener listener = new SecurityFlowExecutionListener(); RequestContext context = new MockRequestContext(); Flow flow = new Flow("flow"); ViewState state = new ViewState(flow, "view", new StubViewFactory()); SecurityRule rule = getSecurityRuleAllAuthorized(); state.getAttributes().put(SecurityRule.SECURITY_ATTRIBUTE_NAME, rule); configureSecurityContext(); listener.stateEntering(context, state); }
public void testSmartValidatorWithClassHint() { ViewState state = new ViewState(requestContext.getRootFlow(), "state2", new StubViewFactory()); state.getAttributes().put("validationHints", new StaticExpression(new Object[] { Model.State1.class })); requestContext.setCurrentState(state); LegacyModelValidator validator = new LegacyModelValidator(); ExtendedModel model = new ExtendedModel(); ValidationHelper helper = new ValidationHelper(model, requestContext, eventId, modelName, null, codesResolver, null); helper.setValidator(validator); helper.validate(); assertTrue(validator.fallbackInvoked); assertTrue(validator.hints.length > 0); assertEquals(Model.State1.class, validator.hints[0]); }
public void testSmartValidatorWithHintResolution() { ViewState state = new ViewState(requestContext.getRootFlow(), "state2", new StubViewFactory()); state.getAttributes().put("validationHints", new StaticExpression("State1")); requestContext.setCurrentState(state); LegacyModelValidator validator = new LegacyModelValidator(); ExtendedModel model = new ExtendedModel(); ValidationHelper helper = new ValidationHelper(model, requestContext, eventId, modelName, null, codesResolver, null); helper.setValidator(validator); helper.validate(); assertTrue(validator.fallbackInvoked); assertTrue(validator.hints.length > 0); assertEquals(Model.State1.class, validator.hints[0]); }