标签:
1.部署规则
2.开启流程
3.获取第一个excution执行对象
4.根据条件判断,下一个执行的Excution执行对象,并完成相应逻辑
package com.tabchanj.activiti.receive; import org.activiti.engine.runtime.Execution; import org.activiti.engine.runtime.ProcessInstance; import org.junit.Assert; import org.junit.Test; public class ReceiveTest extends BaseProcess { @Test public void testPss() throws Exception { // 部署规则 deploy("pss.bpmn"); // 开启流程 ProcessInstance pi = runService.startProcessInstanceByKey("pssID"); System.out.println("流程id:"+pi.getId()); //获取当前流程实例的id String pid = pi.getId(); //获取的id名为统计当日销售额ID的执行对象 Execution e1= runService.createExecutionQuery() .processInstanceId(pid) .activityId("统计当日销售额ID") .singleResult(); //使用断言,预期结果应该不为空 Assert.assertNotNull(e1); Double money =2888.8D; //将作为判断依据的流程变量money设置到流程变量中 runService.setVariable(e1.getId(), "money", money); //发出信号,当前节点执行完成 runService.signal(e1.getId()); //流程判断 if(money<1000){ Execution e2= runService.createExecutionQuery() .processInstanceId(pid) .activityId("给老板发短信ID") .singleResult(); Assert.assertNotNull(e2); System.out.println("短信:老板,今日小赚"+runService.getVariable(e2.getId(), "money")+"元"); runService.signal(e2.getId()); }else if(money>=10000){ Execution e3= runService.createExecutionQuery() .processInstanceId(pid) .activityId("给老板发邮件ID") .singleResult(); Assert.assertNotNull(e3); System.out.println("邮件:老板,今日豪赚"+money+"元"); runService.signal(e3.getId()); }else{ Execution e4= runService.createExecutionQuery() .processInstanceId(pid) .activityId("默认的ID") .singleResult(); Assert.assertNotNull(e4); System.out.println("默认:老板,今日赚"+money+"元"); runService.signal(e4.getId()); } //检查流程状态 Assert.assertNull(getProcessInstence(pid)); System.out.println("流程检查完毕"); } }
标签:
原文地址:http://www.cnblogs.com/tabchanj/p/5745123.html