WorkflowEngineFactoryImpl implements WorkflowEngineFactory, InitializingBean { @SuppressWarnings("unchecked") @Override public <E extends WorkflowEngine> E newEngine(OrchestrationConfig config) { switch (config.getCapability()) { case STANDARD: return (E) new StandardWorkflowEngine(routeNodeService, routeHeaderService, parameterService, config); case BLANKET_APPROVAL: return (E) new BlanketApproveEngine(routeNodeService, routeHeaderService, parameterService, config); case SIMULATION: return (E) new SimulationEngine(routeNodeService, routeHeaderService, parameterService, config); } return null; }  @Override void afterPropertiesSet(); @SuppressWarnings("unchecked") @Override E newEngine(OrchestrationConfig config); RouteNodeService getRouteNodeService(); void setRouteNodeService(RouteNodeService routeNodeService); RouteHeaderService getRouteHeaderService(); void setRouteHeaderService(RouteHeaderService routeHeaderService); ParameterService getParameterService(); void setParameterService(ParameterService parameterService);  }
@Test public void standardEngineCreate() { OrchestrationConfig config = new OrchestrationConfig(EngineCapability.STANDARD); WorkflowEngine workflowEngine = factory.newEngine(config); assertNotNull(workflowEngine); assertFalse(workflowEngine instanceof BlanketApproveEngine); assertFalse(workflowEngine instanceof SimulationEngine); assertTrue(workflowEngine instanceof StandardWorkflowEngine); }
@Test public void blanketApproveEngineCreate() { OrchestrationConfig config = new OrchestrationConfig(EngineCapability.BLANKET_APPROVAL); WorkflowEngine workflowEngine = factory.newEngine(config); assertNotNull(workflowEngine); assertTrue(workflowEngine instanceof BlanketApproveEngine); assertFalse(workflowEngine instanceof SimulationEngine); }
@Test public void simulationEngineCreate() { OrchestrationConfig config = new OrchestrationConfig(EngineCapability.SIMULATION); WorkflowEngine workflowEngine = factory.newEngine(config); assertNotNull(workflowEngine); assertFalse(workflowEngine instanceof BlanketApproveEngine); assertTrue(workflowEngine instanceof SimulationEngine); }
@Test public void standardEngineRunPostProcessLogic() { OrchestrationConfig config = new OrchestrationConfig(EngineCapability.STANDARD, true); WorkflowEngine workflowEngine = factory.newEngine(config); assertTrue(((StandardWorkflowEngine)workflowEngine).isRunPostProcessorLogic()); }
@Test public void standardEngineDoNotRunPostProcessLogic() { OrchestrationConfig config = new OrchestrationConfig(EngineCapability.STANDARD, false); WorkflowEngine workflowEngine = factory.newEngine(config); assertFalse(((StandardWorkflowEngine)workflowEngine).isRunPostProcessorLogic()); }