assertEquals(1,((ITaskInstance) taskInstanceList.get(0)).getStepNumber().intValue());
List<IToken> tokenList = persistenceService.findTokensForProcessInstance(currentProcessInstance.getId(), null);
assertNotNull(tokenList);
assertEquals(1,tokenList.size());
IToken token = (IToken)tokenList.get(0);
assertEquals(1,token.getStepNumber().intValue());
List<IWorkItem> workItemList = persistenceService.findTodoWorkItems(CurrentUserAssignmentHandlerMock.ACTOR_ID, "Goods_Deliver_Process", "Goods_Deliver_Process.PaymentActivity.Payment_Task");
assertNotNull(workItemList);
assertEquals(1, workItemList.size());
assertEquals(new Integer(ITaskInstance.RUNNING), ((IWorkItem) workItemList.get(0)).getState());
final String paymentWorkItemId = ((IWorkItem) workItemList.get(0)).getId();
//----------------------------------------------------------------
System.out.println("--------------Complete Payment WorkItem ----------------");
transactionTemplate.execute(new TransactionCallbackWithoutResult() {
@Override
protected void doInTransactionWithoutResult(TransactionStatus arg0) {
try {
IWorkflowSession workflowSession = runtimeContext.getWorkflowSession();
IWorkItem paymentTaskWorkItem = workflowSession.findWorkItemById(paymentWorkItemId);
paymentTaskWorkItem.complete("testCompletePaymentWorkItem");
} catch (EngineException ex) {
Logger.getLogger(FireWorkflowEngineTest.class.getName()).log(Level.SEVERE, null, ex);
} catch (KernelException ex) {
Logger.getLogger(FireWorkflowEngineTest.class.getName()).log(Level.SEVERE, null, ex);
}
}
});
IWorkItem wi = persistenceService.findWorkItemById(paymentWorkItemId);
assertEquals(new Integer(IWorkItem.COMPLETED), wi.getState());
List<IToken> tokensList = persistenceService.findTokensForProcessInstance(currentProcessInstance.getId(), null);
assertNotNull(tokensList);
assertEquals(1, tokensList.size());
token = (IToken)tokensList.get(0);
assertEquals(2,token.getStepNumber().intValue());
List<IWorkItem> todoWorkItemsList = persistenceService.findTodoWorkItems(CurrentUserAssignmentHandlerMock.ACTOR_ID, "Goods_Deliver_Process", "Goods_Deliver_Process.PrepareGoodsTask");
assertNotNull(todoWorkItemsList);
assertEquals(1, todoWorkItemsList.size());
final String prepareGoodsWorkItemId = ((IWorkItem) todoWorkItemsList.get(0)).getId();
//----------------------------------------------------------------------------------
System.out.println("--------------Claim Prepare Goods WorkItem ----------------");
transactionTemplate.execute(new TransactionCallbackWithoutResult() {
@Override
protected void doInTransactionWithoutResult(TransactionStatus arg0) {
try {
IWorkflowSession workflowSession = runtimeContext.getWorkflowSession();
IWorkItem prepareGoodsWorkItem = workflowSession.findWorkItemById(prepareGoodsWorkItemId);
prepareGoodsWorkItem.claim();
} catch (EngineException ex) {
Logger.getLogger(FireWorkflowEngineTest.class.getName()).log(Level.SEVERE, null, ex);
} catch (KernelException ex) {
Logger.getLogger(FireWorkflowEngineTest.class.getName()).log(Level.SEVERE, null, ex);
}
}
});
wi = persistenceService.findWorkItemById(prepareGoodsWorkItemId);
assertEquals(new Integer(IWorkItem.RUNNING), wi.getState());
//-------------------------------------------------------------
System.out.println("--------------Complete Prepare Goods WorkItem ----------------");
transactionTemplate.execute(new TransactionCallbackWithoutResult() {
@Override
protected void doInTransactionWithoutResult(TransactionStatus arg0) {
try {
IWorkflowSession workflowSession = runtimeContext.getWorkflowSession();
IWorkItem prepareGoodsWorkItem = workflowSession.findWorkItemById(prepareGoodsWorkItemId);
prepareGoodsWorkItem.complete("testClaimPrepareGoodsWorkItem");
} catch (EngineException ex) {
Logger.getLogger(FireWorkflowEngineTest.class.getName()).log(Level.SEVERE, null, ex);
} catch (KernelException ex) {
Logger.getLogger(FireWorkflowEngineTest.class.getName()).log(Level.SEVERE, null, ex);
}
}
});
wi = persistenceService.findWorkItemById(prepareGoodsWorkItemId);
assertEquals(new Integer(IWorkItem.COMPLETED), wi.getState());
tokensList = persistenceService.findTokensForProcessInstance(currentProcessInstance.getId(), null);
assertNotNull(tokensList);
assertEquals(2, tokensList.size());
List<IToken> tokensListOnEndNode = persistenceService.findTokensForProcessInstance(currentProcessInstance.getId(), "Goods_Deliver_Process.EndNode1");
assertNotNull(tokensListOnEndNode);
assertEquals(1, tokensListOnEndNode.size());
IToken tokenOnEndNode = (IToken)tokensListOnEndNode.get(0);
if (mobile==null || mobile.equals("")){
assertEquals(Boolean.FALSE,tokenOnEndNode.isAlive());
}else{
assertEquals(Boolean.TRUE,tokenOnEndNode.isAlive());
}
todoWorkItemsList = persistenceService.findTodoWorkItems(CurrentUserAssignmentHandlerMock.ACTOR_ID, "Goods_Deliver_Process", "Goods_Deliver_Process.DeliverGoodsActivity.DeliverGoodsTask");
assertNotNull(todoWorkItemsList);
assertEquals(1, todoWorkItemsList.size());