I have created a TestCase to show the problem. It completes through to the end. 
Please let me know if you manage to find a solution/fix.

/**
  |  * [JBPM 3.2.1]
  |  * This TestCase should show that the when a variable it set to required,
  |  * the taskInstance is still able to complete, even when said variable is 
null.
  |  * Calling taskInstance.end() does not throw an exception.
  |  * 
  |  * @author dleerob
  |  *
  |  */
  | public class ProcessTest extends TestCase {
  | 
  |     public void testProcess() throws Exception {
  | 
  |      ProcessDefinition processDefinition = ProcessDefinition.parseXmlString(
  |           "<process-definition name='simple'>" +
  |           "  <start-state name='start'>" +
  |           "   <task name='Request For New Employee'>"+
  |           "     <controller>"+
  |           "       <variable name='IsReplacement' 
access='read,write,required'></variable>"+
  |           "     </controller>"+
  |           "    </task>"+
  |           "    <transition name='' to='Financial Director Approval 1' />" +
  |           "  </start-state>" +
  |           "  <task-node name='Financial Director Approval 1'>" +
  |           "    <task name='Financial Director Approval 1'>"+
  |           "      <controller>"+
  |           "        <variable name='Approved' 
access='read,write,required'></variable>"+
  |           "      </controller>"+
  |           "    </task>"+
  |           "    <transition name='' to='end' />" +
  |           "  </task-node>" +
  |           "  <end-state name='end' />" +
  |           "</process-definition>"
  |         );
  |                 
  |             assertNotNull("Definition should not be null", 
processDefinition);
  | 
  |             //create an instance of the process definition.
  |             ProcessInstance instance = new 
ProcessInstance(processDefinition);
  | 
  |             //create start task instance.
  |             TaskMgmtInstance taskMgmtInstance = 
instance.getTaskMgmtInstance();
  |             TaskInstance startTaskInstance = 
taskMgmtInstance.createStartTaskInstance();
  |             
  |             assertNotNull("Start Task Instance should not be null", 
startTaskInstance);
  |             assertEquals("Request For New Employee", 
startTaskInstance.getName());
  |             
  |             Token token = instance.getRootToken();
  |             assertSame(processDefinition.getNode("start"), token.getNode());
  |             
  |             //make sure our IsReplacement variable is null.
  |             assertNull("IsReplacement variable is 
null",startTaskInstance.getVariable("IsReplacement"));
  |             
  |             //ending the startTaskInstance should throw an exception if 
IsReplacement variable 
  |             //is null, as the variable is set to "required" in the process 
definition above,
  |             //but it doesn't seem to throw the exception.
  |             startTaskInstance.end();
  |             
  |             //this should never of happened.
  |             assertNull("IsReplacement variable is still 
null",startTaskInstance.getVariable("IsReplacement"));
  |             
  |             
  |             //I also want to test if the next task node isn't working 
properly
  |             //when saving required variables with a null value.
  |             //This way we rule out the possiblity that there is only
  |             //an error with the Start Task Instance.
  |             assertSame(processDefinition.getNode("Financial Director 
Approval 1"), token.getNode());
  | 
  |             TaskInstance financeDirectorApproval1TaskInstance = null;
  |             for(Iterator it = 
taskMgmtInstance.getTaskInstances().iterator();it.hasNext();) {
  |                     TaskInstance taskInstance = (TaskInstance)it.next();
  |                     if (taskInstance.getName().equals("Financial Director 
Approval 1")) {
  |                             financeDirectorApproval1TaskInstance = 
taskInstance;
  |                             break;
  |                     }
  |             }
  |             
  |             assertNotNull("Finance Director Approval Task Instance is not 
null", financeDirectorApproval1TaskInstance);
  |             
assertEquals(financeDirectorApproval1TaskInstance.getName(),"Financial Director 
Approval 1");
  |             
  |             //make sure our Approved variable is null.
  |             assertNull("Approved variable is 
null",financeDirectorApproval1TaskInstance.getVariable("Approved"));
  |             
  |             //ending the financeDirectorApproval1TaskInstance should throw 
an exception if 
  |             //Approved variable is null, as the variable is set to 
"required" in the process definition above,
  |             //but it doesn't seem to throw the exception.
  |             financeDirectorApproval1TaskInstance.end();
  |             
  |             //this should never of happened.
  |             assertNull("Approved variable is still 
null",startTaskInstance.getVariable("Approved"));
  |             
  |             assertSame(processDefinition.getNode("end"), token.getNode());
  |             
  |     }

View the original post : 
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4083972#4083972

Reply to the post : 
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4083972
_______________________________________________
jboss-user mailing list
[email protected]
https://lists.jboss.org/mailman/listinfo/jboss-user

Reply via email to