04-30-2012 04:27 AM
<?xml version="1.0" encoding="UTF-8"?>
<definitions xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:activiti="http://activiti.org/bpmn" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:omgdc="http://www.omg.org/spec/DD/20100524/DC" xmlns:omgdi="http://www.omg.org/spec/DD/20100524/DI" typeLanguage="http://www.w3.org/2001/XMLSchema" expressionLanguage="http://www.w3.org/1999/XPath" targetNamespace="http://appserver.successcharging.com/process">
<process id="customerRegistration" name="Customer registration">
<endEvent id="endevent" name="End"></endEvent>
<startEvent id="startevent" name="Start"></startEvent>
<parallelGateway id="parallelgatewayStartUserRegistrationLogic" name="parallelgatewayStartUserRegistrationLogic"></parallelGateway>
<parallelGateway id="parallelgatewayEndUserRegistrationLogic" name="parallelgatewayEndUserRegistrationLogic"></parallelGateway>
<userTask id="usertask4" name="Create customer record">
<extensionElements>
<activiti:taskListener event="create" expression="${wfProcessLogicRegisterCustomer.createCustomerRecord(execution)}"></activiti:taskListener>
<activiti:taskListener event="complete" expression="${wfProcessLogicRegisterCustomer.createCustomerRecord(execution)}"></activiti:taskListener>
</extensionElements>
</userTask>
<userTask id="usertask5" name="Register card">
<extensionElements>
<activiti:taskListener event="create" expression="${wfProcessLogicRegisterCustomer.registerCard(execution)}"></activiti:taskListener>
</extensionElements>
</userTask>
<userTask id="usertask6" name="Approve payment method">
<extensionElements>
<activiti:taskListener event="create" expression="${wfProcessLogicRegisterCustomer.approvePaymentMethod(execution)}"></activiti:taskListener>
</extensionElements>
</userTask>
<userTask id="createUserRecord" name="Create User Record">
<extensionElements>
<activiti:taskListener event="create" expression="${wfProcessLogicRegisterCustomer.createUserRecord(execution)}"></activiti:taskListener>
</extensionElements>
</userTask>
<sequenceFlow id="flow14" name="" sourceRef="parallelgatewayEndUserRegistrationLogic" targetRef="endevent"></sequenceFlow>
<sequenceFlow id="flowCreateCustomerReocrd" name="" sourceRef="parallelgatewayStartUserRegistrationLogic" targetRef="usertask4"></sequenceFlow>
<sequenceFlow id="flowRegisterCard" name="" sourceRef="parallelgatewayStartUserRegistrationLogic" targetRef="usertask5"></sequenceFlow>
<sequenceFlow id="flowApprovePaymentMehtod" name="" sourceRef="parallelgatewayStartUserRegistrationLogic" targetRef="usertask6"></sequenceFlow>
<sequenceFlow id="flowRegisterCardEnd" name="" sourceRef="usertask5" targetRef="parallelgatewayEndUserRegistrationLogic"></sequenceFlow>
<sequenceFlow id="flowApprovePaymentMethodEnd" name="" sourceRef="usertask6" targetRef="parallelgatewayEndUserRegistrationLogic"></sequenceFlow>
<sequenceFlow id="flowcreateCustomerRecordEnd" name="" sourceRef="usertask4" targetRef="parallelgatewayEndUserRegistrationLogic"></sequenceFlow>
<sequenceFlow id="flow15" name="" sourceRef="startevent" targetRef="createUserRecord"></sequenceFlow>
<sequenceFlow id="flow16" name="" sourceRef="createUserRecord" targetRef="parallelgatewayStartUserRegistrationLogic"></sequenceFlow>
</process>
<bpmndi:BPMNDiagram id="BPMNDiagram_customerRegistration">
<bpmndi:BPMNPlane bpmnElement="customerRegistration" id="BPMNPlane_customerRegistration">
<bpmndi:BPMNShape bpmnElement="endevent" id="BPMNShape_endevent">
<omgdc:Bounds height="35" width="35" x="1000" y="150"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="startevent" id="BPMNShape_startevent">
<omgdc:Bounds height="35" width="35" x="20" y="150"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="parallelgatewayStartUserRegistrationLogic" id="BPMNShape_parallelgatewayStartUserRegistrationLogic">
<omgdc:Bounds height="40" width="40" x="330" y="147"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="parallelgatewayEndUserRegistrationLogic" id="BPMNShape_parallelgatewayEndUserRegistrationLogic">
<omgdc:Bounds height="40" width="40" x="830" y="147"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="usertask4" id="BPMNShape_usertask4">
<omgdc:Bounds height="55" width="105" x="540" y="140"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="usertask5" id="BPMNShape_usertask5">
<omgdc:Bounds height="55" width="105" x="540" y="233"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="usertask6" id="BPMNShape_usertask6">
<omgdc:Bounds height="55" width="105" x="540" y="339"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="createUserRecord" id="BPMNShape_createUserRecord">
<omgdc:Bounds height="55" width="105" x="130" y="140"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge bpmnElement="flow14" id="BPMNEdge_flow14">
<omgdi:waypoint x="870" y="167"></omgdi:waypoint>
<omgdi:waypoint x="1000" y="167"></omgdi:waypoint>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="flowCreateCustomerReocrd" id="BPMNEdge_flowCreateCustomerReocrd">
<omgdi:waypoint x="370" y="167"></omgdi:waypoint>
<omgdi:waypoint x="540" y="167"></omgdi:waypoint>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="flowRegisterCard" id="BPMNEdge_flowRegisterCard">
<omgdi:waypoint x="350" y="187"></omgdi:waypoint>
<omgdi:waypoint x="350" y="260"></omgdi:waypoint>
<omgdi:waypoint x="540" y="260"></omgdi:waypoint>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="flowApprovePaymentMehtod" id="BPMNEdge_flowApprovePaymentMehtod">
<omgdi:waypoint x="350" y="187"></omgdi:waypoint>
<omgdi:waypoint x="350" y="366"></omgdi:waypoint>
<omgdi:waypoint x="540" y="366"></omgdi:waypoint>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="flowRegisterCardEnd" id="BPMNEdge_flowRegisterCardEnd">
<omgdi:waypoint x="645" y="260"></omgdi:waypoint>
<omgdi:waypoint x="850" y="260"></omgdi:waypoint>
<omgdi:waypoint x="850" y="187"></omgdi:waypoint>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="flowApprovePaymentMethodEnd" id="BPMNEdge_flowApprovePaymentMethodEnd">
<omgdi:waypoint x="645" y="366"></omgdi:waypoint>
<omgdi:waypoint x="850" y="366"></omgdi:waypoint>
<omgdi:waypoint x="850" y="187"></omgdi:waypoint>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="flowcreateCustomerRecordEnd" id="BPMNEdge_flowcreateCustomerRecordEnd">
<omgdi:waypoint x="645" y="167"></omgdi:waypoint>
<omgdi:waypoint x="830" y="167"></omgdi:waypoint>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="flow15" id="BPMNEdge_flow15">
<omgdi:waypoint x="55" y="167"></omgdi:waypoint>
<omgdi:waypoint x="130" y="167"></omgdi:waypoint>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="flow16" id="BPMNEdge_flow16">
<omgdi:waypoint x="235" y="167"></omgdi:waypoint>
<omgdi:waypoint x="330" y="167"></omgdi:waypoint>
</bpmndi:BPMNEdge>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
</definitions>
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = { "classpath:applicationContext/appserver-process-applicationContext*.xml" })
@TransactionConfiguration(transactionManager = "transactionManager", defaultRollback = false)
@Transactional
public class CustomerRegistrationBpmTest {
/**
* Logger for this class
*/
private static final Logger logger = Logger.getLogger(CustomerRegistrationBpmTest.class);
@Autowired
private RuntimeService runtimeService;
@Autowired
private TaskService taskService;
@Autowired
RepositoryService repositoryService;
@Before
public void before() throws Throwable {
if (logger.isDebugEnabled()) {
logger.debug("before() - start");
}
repositoryService.createDeployment().addClasspathResource("com/successcharging/appserver/process/activiti/CustomerRegistration.bpmn20.xml")
.deploy();
if (logger.isDebugEnabled()) {
logger.debug("before() - end");
}
}
@After
public void after() {
if (logger.isDebugEnabled()) {
logger.debug("after() - start");
}
for (Deployment deployment : repositoryService.createDeploymentQuery().list()) {
repositoryService.deleteDeployment(deployment.getId(), true);
}
if (logger.isDebugEnabled()) {
logger.debug("after() - end");
}
}
@Test
public void completeCreateUserTaskTest() {
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("customerRegistration");
// the process has paused
String procId = processInstance.getProcessInstanceId();
TaskQuery taskQuery = taskService.createTaskQuery();
List<Task> tasks =taskQuery.executionId(procId).list();
Assert.assertEquals("there should be 1 (one) task enqueued at this point.", 1,tasks.size());
Task t = tasks.iterator().next();
taskService.complete(t.getId());
tasks = taskQuery.processInstanceId(procId).list();
Assert.assertEquals("there should be 3 tasks enqueued at this point.",3, tasks.size() );
}
}
First assertion goes well tasks = taskQuery.processInstanceId(procId).list();
it return empty list04-30-2012 06:58 AM
Task t = tasks.iterator().next();
taskService.complete(t.getId());
// The next line is needed
taskQuery = taskService.createTaskQuery();
tasks = taskQuery.processInstanceId(procId).list();
Assert.assertEquals("there should be 3 tasks enqueued at this point.",
3, tasks.size());
Tags
Find what you came for
We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.