@Test
public void testDynamicNodeValidationInDynamicProcess() throws Exception {

    RuleFlowProcess process = new RuleFlowProcess();
    process.setId("org.drools.core.process");
    process.setName("Dynamic Node Process");
    process.setPackageName("org.mycomp.myprocess");
    process.setDynamic(true);
    DynamicNode dynamicNode = new DynamicNode();
    dynamicNode.setName("MyDynamicNode");
    dynamicNode.setId(1);
    dynamicNode.setAutoComplete(false);
    dynamicNode.setCompletionExpression("completion-expression");
    process.addNode(dynamicNode);
    ProcessValidationError[] errors = validator.validateProcess(process);
    assertNotNull(errors);
    // if dynamic process no longer triggering incoming / outgoing connection errors for dynamic nodes
    assertEquals(0,
                 errors.length);
    // empty completion expression to trigger validation error
    process.removeNode(dynamicNode);
    DynamicNode dynamicNode2 = new DynamicNode();
    dynamicNode2.setName("MyDynamicNode");
    dynamicNode2.setId(1);
    dynamicNode2.setAutoComplete(false);
    dynamicNode2.setCompletionExpression("");
    process.addNode(dynamicNode2);
    ProcessValidationError[] errors2 = validator.validateProcess(process);
    assertNotNull(errors2);
    // autocomplete set to false and empty completion condition triggers error
    assertEquals(1,
                 errors2.length);
    assertEquals("Node 'MyDynamicNode' [1] Dynamic has no completion condition set",
                 errors2[0].getMessage());
}