_engine.completeWorkItem(anItem, "<data/>", false);
//should atumatically fire multi inst comp task ctop
//get mi attributes of f-leaf-c
List leafNetRunners = new Vector();
Set enabled = _workItemRepository.getEnabledWorkItems();
YMultiInstanceAttributes fLeafCMIAttributes = null;
Iterator iter = enabled.iterator();
while (iter.hasNext()) {
YWorkItem item = (YWorkItem) iter.next();
YNetRunner leafCRunner = _workItemRepository.getNetRunner(item.getCaseID());
if (leafNetRunners.size() == 0) {
fLeafCMIAttributes =
((YAtomicTask) leafCRunner.getNetElement("f-leaf-c"))
.getMultiInstanceAttributes();
}
leafNetRunners.add(leafCRunner);
//System.out.println("item "+item);
assertTrue(leafCRunner != null);
}
//fire all the enabled e-leaf-c nodes
while (_workItemRepository.getEnabledWorkItems().size() > 0) {
Vector v = new Vector(_workItemRepository.getEnabledWorkItems());
int temp = (int) Math.abs(Math.floor(Math.random() * v.size()));
anItem = (YWorkItem) v.get(temp);
assertEquals(anItem.getCaseID().getParent(), _idForTopNet);
assertTrue(anItem.getTaskID().equals("e-leaf-c"));
assertTrue(anItem.getStatus() == YWorkItem.statusEnabled);
//fire e-leaf-c
// _localWorklist.startOneWorkItemAndSetOthersToFired(anItem.getCaseID().toString(), anItem.getTaskID());
_engine.startWorkItem(anItem, "admin");
assertTrue("Item status ("+anItem.getStatus()+") should be is parent."
, anItem.getStatus() == YWorkItem.statusIsParent);
Set executingChildren = _workItemRepository.getExecutingWorkItems();
assertTrue(executingChildren.containsAll(anItem.getChildren()));
Thread.sleep(_sleepTime);
}
//complete e-leaf-c
while (_workItemRepository.getExecutingWorkItems().size() > 0) {
Vector v = new Vector(_workItemRepository.getExecutingWorkItems());
int temp = (int) Math.abs(Math.floor(Math.random() * v.size()));
anItem = (YWorkItem) v.get(temp);
// _localWorklist.setWorkItemToComplete(
// anItem.getCaseID().toString(), anItem.getTaskID(),"<data/>");
_engine.completeWorkItem(anItem, "<data/>", false);
assertTrue(_workItemRepository.getWorkItem(
anItem.getCaseID().toString(), anItem.getTaskID())
== null);
Thread.sleep(_sleepTime);
}
currWorkItems = _workItemRepository.getEnabledWorkItems();
assertTrue(currWorkItems.size() == _workItemRepository.getWorkItems().size());
// fire all the enabled f-leaf-c and g-leaf-c children
while (_workItemRepository.getEnabledWorkItems().size() > 0) {
Vector v = new Vector(_workItemRepository.getEnabledWorkItems());
int temp = (int) Math.abs(Math.floor(Math.random() * v.size()));
//System.out.println("v.size() : " + v.size() + " InstanceValidator: " + InstanceValidator);
anItem = (YWorkItem) v.get(temp);
assertTrue(anItem.getTaskID().equals("f-leaf-c")
|| anItem.getTaskID().equals("g-leaf-c"));
// _localWorklist.startOneWorkItemAndSetOthersToFired(
// anItem.getCaseID().toString(), anItem.getTaskID());
_engine.startWorkItem(anItem, "admin");
if (anItem.getTaskID().equals("g-leaf-c")) {
assertTrue(anItem.getChildren().size() == 1);
assertTrue(((YWorkItem) anItem.getChildren().iterator().next())
.getStatus() == YWorkItem.statusExecuting);
} else {
int numChildren = anItem.getChildren().size();
assertTrue(numChildren >= fLeafCMIAttributes.getMinInstances()
&& numChildren <= fLeafCMIAttributes.getMaxInstances());
}
Thread.sleep(_sleepTime);
}
//start all the fired f-leaf-c nodes
while (_workItemRepository.getFiredWorkItems().size() > 0) {