public void testExceptionHandlers() { FlowModel model = new FlowModel(); model.setStates(asList(new EndStateModel("state"))); model.setExceptionHandlers(asList(new ExceptionHandlerModel("exceptionHandler"))); FlowExecutionExceptionHandler handler = new FlowExecutionExceptionHandler() { public boolean canHandle(FlowExecutionException exception) { return true; } public void handle(FlowExecutionException exception, RequestControlContext context) { } }; FlowModelFlowBuilder builder = new FlowModelFlowBuilder(new StaticFlowModelHolder(model)); MockFlowBuilderContext context = new MockFlowBuilderContext("foo"); context.registerBean("exceptionHandler", handler); FlowAssembler assembler = new FlowAssembler(builder, context); Flow flow = assembler.assembleFlow(); assertEquals(1, flow.getExceptionHandlerSet().size()); }
public void testHandleException() { FlowExecutionExceptionHandlerSet handlerSet = new FlowExecutionExceptionHandlerSet(); handlerSet.add(new TestStateExceptionHandler(NullPointerException.class, "null")); handlerSet.add(new TestStateExceptionHandler(FlowExecutionException.class, "execution 1")); handlerSet.add(new TestStateExceptionHandler(FlowExecutionException.class, "execution 2")); assertEquals(3, handlerSet.size()); FlowExecutionException e = new FlowExecutionException("flowId", "stateId", "Test"); assertTrue(handlerSet.handleException(e, context)); assertFalse(context.getFlowScope().contains("null")); assertTrue(context.getFlowScope().contains("execution 1")); assertFalse(context.getFlowScope().contains("execution 2")); }