@Test void testDynamicNodeValidationInNotDynamicProcess() { RuleFlowProcess process = new RuleFlowProcess(); process.setId("org.drools.core.process"); process.setName("Dynamic Node Process"); process.setPackageName("org.mycomp.myprocess"); process.setDynamic(false); DynamicNode dynamicNode = new DynamicNode(); dynamicNode.setName("MyDynamicNode"); dynamicNode.setId(1); dynamicNode.setAutoComplete(false); process.addNode(dynamicNode); ProcessValidationError[] errors = validator.validateProcess(process); assertNotNull(errors); assertEquals(6, errors.length); assertEquals("Process has no start node.", errors[0].getMessage()); assertEquals("Process has no end node.", errors[1].getMessage()); assertEquals("Node 'MyDynamicNode' [1] Dynamic has no incoming connection", errors[2].getMessage()); assertEquals("Node 'MyDynamicNode' [1] Dynamic has no outgoing connection", errors[3].getMessage()); assertEquals("Node 'MyDynamicNode' [1] Dynamic has no completion condition set", errors[4].getMessage()); assertEquals("Node 'MyDynamicNode' [1] Has no connection to the start node.", errors[5].getMessage()); }
public ProcessValidationError[] validateProcess(final RuleFlowProcess process) { final List<ProcessValidationError> errors = new ArrayList<>(); if (process.getName() == null) { errors.add(new ProcessValidationErrorImpl(process, "Process has no name.")); } if (process.getId() == null || "".equals(process.getId())) { errors.add(new ProcessValidationErrorImpl(process, "Process has no id.")); } if (process.getStartNodes().isEmpty() && !process.isDynamic()) { errors.add(new ProcessValidationErrorImpl(process, "Process has no start node.")); } if (process.getEndNodes().isEmpty() && !process.isDynamic()) { errors.add(new ProcessValidationErrorImpl(process, "Process has no end node.")); } validateNodes(process.getNodes(), errors, process); validateVariables(errors, process); checkAllNodesConnectedToStart(process, process.isDynamic(), errors, process); return errors.toArray(new ProcessValidationError[errors.size()]); }
RuleFlowProcessValidator implements ProcessValidator { public ProcessValidationError[] validateProcess(final RuleFlowProcess process) { final List<ProcessValidationError> errors = new ArrayList<>(); if (process.getName() == null) { errors.add(new ProcessValidationErrorImpl(process, "Process has no name.")); } if (process.getId() == null || "".equals(process.getId())) { errors.add(new ProcessValidationErrorImpl(process, "Process has no id.")); } if (process.getStartNodes().isEmpty() && !process.isDynamic()) { errors.add(new ProcessValidationErrorImpl(process, "Process has no start node.")); } if (process.getEndNodes().isEmpty() && !process.isDynamic()) { errors.add(new ProcessValidationErrorImpl(process, "Process has no end node.")); } validateNodes(process.getNodes(), errors, process); validateVariables(errors, process); checkAllNodesConnectedToStart(process, process.isDynamic(), errors, process); return errors.toArray(new ProcessValidationError[errors.size()]); } }
RuleFlowProcessValidator implements ProcessValidator { public ProcessValidationError[] validateProcess(final RuleFlowProcess process) { final List<ProcessValidationError> errors = new ArrayList<>(); if (process.getName() == null) { errors.add(new ProcessValidationErrorImpl(process, "Process has no name.")); } if (process.getId() == null || "".equals(process.getId())) { errors.add(new ProcessValidationErrorImpl(process, "Process has no id.")); } if (process.getStartNodes().isEmpty() && !process.isDynamic()) { errors.add(new ProcessValidationErrorImpl(process, "Process has no start node.")); } if (process.getEndNodes().isEmpty() && !process.isDynamic()) { errors.add(new ProcessValidationErrorImpl(process, "Process has no end node.")); } validateNodes(process.getNodes(), errors, process); validateVariables(errors, process); checkAllNodesConnectedToStart(process, process.isDynamic(), errors, process); return errors.toArray(new ProcessValidationError[errors.size()]); } private  RuleFlowProcessValidator(); }
RuleFlowProcessValidator implements ProcessValidator { public ProcessValidationError[] validateProcess(final RuleFlowProcess process) { final List<ProcessValidationError> errors = new ArrayList<>(); if (process.getName() == null) { errors.add(new ProcessValidationErrorImpl(process, "Process has no name.")); } if (process.getId() == null || "".equals(process.getId())) { errors.add(new ProcessValidationErrorImpl(process, "Process has no id.")); } if (process.getStartNodes().isEmpty() && !process.isDynamic()) { errors.add(new ProcessValidationErrorImpl(process, "Process has no start node.")); } if (process.getEndNodes().isEmpty() && !process.isDynamic()) { errors.add(new ProcessValidationErrorImpl(process, "Process has no end node.")); } validateNodes(process.getNodes(), errors, process); validateVariables(errors, process); checkAllNodesConnectedToStart(process, process.isDynamic(), errors, process); return errors.toArray(new ProcessValidationError[errors.size()]); } private  RuleFlowProcessValidator(); static RuleFlowProcessValidator getInstance(); ProcessValidationError[] validateProcess(final RuleFlowProcess process); ProcessValidationError[] validateProcess(Process process); @Override boolean accept(Process process,
                          Resource resource); @Override boolean compilationSupported(); }
RuleFlowProcessValidator implements ProcessValidator { public ProcessValidationError[] validateProcess(final RuleFlowProcess process) { final List<ProcessValidationError> errors = new ArrayList<>(); if (process.getName() == null) { errors.add(new ProcessValidationErrorImpl(process, "Process has no name.")); } if (process.getId() == null || "".equals(process.getId())) { errors.add(new ProcessValidationErrorImpl(process, "Process has no id.")); } if (process.getStartNodes().isEmpty() && !process.isDynamic()) { errors.add(new ProcessValidationErrorImpl(process, "Process has no start node.")); } if (process.getEndNodes().isEmpty() && !process.isDynamic()) { errors.add(new ProcessValidationErrorImpl(process, "Process has no end node.")); } validateNodes(process.getNodes(), errors, process); validateVariables(errors, process); checkAllNodesConnectedToStart(process, process.isDynamic(), errors, process); return errors.toArray(new ProcessValidationError[errors.size()]); } private  RuleFlowProcessValidator(); static RuleFlowProcessValidator getInstance(); ProcessValidationError[] validateProcess(final RuleFlowProcess process); ProcessValidationError[] validateProcess(Process process); @Override boolean accept(Process process,
                          Resource resource); @Override boolean compilationSupported(); static final String ASSOCIATIONS; }