public void testBoundaryEventIncidentActivityId() { deployment(Bpmn.createExecutableProcess("process") .startEvent() .userTask("userTask") .endEvent() .moveToActivity("userTask") .boundaryEvent("boundaryEvent") .timerWithDuration("PT5S") .endEvent() .done()); // given runtimeService.startProcessInstanceByKey("process"); Job timerJob = managementService.createJobQuery().singleResult(); // when creating an incident managementService.setJobRetries(timerJob.getId(), 0); // then Incident incident = runtimeService.createIncidentQuery().singleResult(); assertNotNull(incident); assertEquals("boundaryEvent", incident.getActivityId()); }
.userTask("afterBoundary1") .endEvent() .moveToActivity(TASK_BEFORE_CONDITION_ID) .boundaryEvent() .cancelActivity(true)
@Test public void testAddErrorBoundaryEventToSubProcessAndThrowError() { // given ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(ProcessModels.SUBPROCESS_PROCESS); ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(modify(ProcessModels.SUBPROCESS_PROCESS) .endEventBuilder("subProcessEnd") .error(ERROR_CODE) // let the end event of the subprocess throw an error .moveToActivity("subProcess") .boundaryEvent().error(ERROR_CODE) .userTask(AFTER_BOUNDARY_TASK) .endEvent() .done() ); MigrationPlan migrationPlan = rule.getRuntimeService() .createMigrationPlan(sourceProcessDefinition.getId(), targetProcessDefinition.getId()) .mapActivities("subProcess", "subProcess") .mapActivities("userTask", "userTask") .build(); // when testHelper.createProcessInstanceAndMigrate(migrationPlan); // then it is possible to successfully complete the migrated instance testHelper.completeTask("userTask"); testHelper.completeTask(AFTER_BOUNDARY_TASK); testHelper.assertProcessEnded(testHelper.snapshotBeforeMigration.getProcessInstanceId()); }
@Test public void testAddEscalationBoundaryEventToSubProcessAndThrowEscalation() { // given ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(ProcessModels.SUBPROCESS_PROCESS); ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(modify(ProcessModels.SUBPROCESS_PROCESS) .endEventBuilder("subProcessEnd").escalation(ESCALATION_CODE) // let the end event of the subprocess escalate .moveToActivity("subProcess") .boundaryEvent().escalation(ESCALATION_CODE) // catch escalation with boundary event .userTask(AFTER_BOUNDARY_TASK) .endEvent() .done() ); MigrationPlan migrationPlan = rule.getRuntimeService() .createMigrationPlan(sourceProcessDefinition.getId(), targetProcessDefinition.getId()) .mapActivities("subProcess", "subProcess") .mapActivities("userTask", "userTask") .build(); // when testHelper.createProcessInstanceAndMigrate(migrationPlan); // then it is possible to successfully complete the migrated instance testHelper.completeTask("userTask"); testHelper.completeTask(AFTER_BOUNDARY_TASK); testHelper.assertProcessEnded(testHelper.snapshotBeforeMigration.getProcessInstanceId()); }
public void testAsyncAfterErrorEvent() { // given BpmnModelInstance instance = Bpmn.createExecutableProcess("process") .startEvent() .serviceTask("servTask") .camundaClass(ThrowBpmnErrorDelegate.class) .boundaryEvent() .camundaAsyncAfter(true) .camundaFailedJobRetryTimeCycle("R10/PT10S") .errorEventDefinition() .errorEventDefinitionDone() .serviceTask() .camundaClass("foo") .endEvent() .moveToActivity("servTask") .endEvent().done(); deployment(instance); runtimeService.startProcessInstanceByKey("process"); Job job = managementService.createJobQuery().singleResult(); // when job fails try { managementService.executeJob(job.getId()); } catch (Exception e) { // ignore } // then job = managementService.createJobQuery().singleResult(); Assert.assertEquals(9, job.getRetries()); }
@Test public void testRemoveExecutionSequence() { // given BpmnModelInstance modelInstance = Bpmn.createExecutableProcess("singleTaskProcess") .startEvent() .userTask("taskWithLocalVariables") .camundaExecutionListenerClass("start", TestLocalVariableExecutionListener.class) .camundaTaskListenerClass("delete", TestLocalVariableTaskListener.class) .boundaryEvent() .signal("interruptSignal") .endEvent() .moveToActivity("taskWithLocalVariables") .endEvent() .done(); testRule.deploy(modelInstance); ProcessInstance pi = processEngineRule.getRuntimeService() .startProcessInstanceByKey("singleTaskProcess"); Execution execution = processEngineRule.getRuntimeService() .createExecutionQuery() .variableValueEquals("localVar", "localVarVal") .singleResult(); // when assertNotNull(execution); assertEquals(pi.getId(), execution.getProcessInstanceId()); processEngineRule.getRuntimeService().signal(execution.getId()); // then (see #TestLocalVariableTaskListener::notify) }
.subProcessDone() .endEvent() .moveToActivity("subprocess") .boundaryEvent("boundary").error("anErrorCode") .userTask("userTaskAfterBoundaryEvent")
.condition(VAR_CONDITION) .endEvent() .moveToActivity(SUB_PROCESS_ID) .boundaryEvent() .condition(VAR_CONDITION)
public static void main(String[] args) { BpmnModelInstance model = Bpmn.createExecutableProcess("payment") .startEvent() .serviceTask().id("charge").name("Charge credit card").camundaClass(ChargeCreditCardAdapter.class.getName()) // .boundaryEvent().error() .serviceTask().name("Ask customer to update credit card").camundaExpression("#{true}") // noop .receiveTask().id("wait").name("Wait for new credit card data").message("CreditCardUpdated") .boundaryEvent().timerWithDuration("PT7D") // 7 days .endEvent().camundaExecutionListenerClass("end", PaymentFailedAdapter.class.getName()) .moveToActivity("wait").connectTo("charge") // loop back with new data .moveToActivity("charge") .endEvent().camundaExecutionListenerClass("end", PaymentCompletedAdapter.class.getName()) .done(); File file = new File("result.bpmn"); Bpmn.writeModelToFile(file, model); } }
.condition(VAR_CONDITION) .endEvent() .moveToActivity(SUB_PROCESS_ID) .boundaryEvent() .condition(VAR_CONDITION)
public void testBoundaryEventIncidentActivityId() { deployment(Bpmn.createExecutableProcess("process") .startEvent() .userTask("userTask") .endEvent() .moveToActivity("userTask") .boundaryEvent("boundaryEvent") .timerWithDuration("PT5S") .endEvent() .done()); // given runtimeService.startProcessInstanceByKey("process"); Job timerJob = managementService.createJobQuery().singleResult(); // when creating an incident managementService.setJobRetries(timerJob.getId(), 0); // then Incident incident = runtimeService.createIncidentQuery().singleResult(); assertNotNull(incident); assertEquals("boundaryEvent", incident.getActivityId()); }
.userTask("afterBoundary1") .endEvent() .moveToActivity(TASK_BEFORE_CONDITION_ID) .boundaryEvent() .cancelActivity(true)
@Test public void testAddErrorBoundaryEventToSubProcessAndThrowError() { // given ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(ProcessModels.SUBPROCESS_PROCESS); ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(modify(ProcessModels.SUBPROCESS_PROCESS) .endEventBuilder("subProcessEnd") .error(ERROR_CODE) // let the end event of the subprocess throw an error .moveToActivity("subProcess") .boundaryEvent().error(ERROR_CODE) .userTask(AFTER_BOUNDARY_TASK) .endEvent() .done() ); MigrationPlan migrationPlan = rule.getRuntimeService() .createMigrationPlan(sourceProcessDefinition.getId(), targetProcessDefinition.getId()) .mapActivities("subProcess", "subProcess") .mapActivities("userTask", "userTask") .build(); // when testHelper.createProcessInstanceAndMigrate(migrationPlan); // then it is possible to successfully complete the migrated instance testHelper.completeTask("userTask"); testHelper.completeTask(AFTER_BOUNDARY_TASK); testHelper.assertProcessEnded(testHelper.snapshotBeforeMigration.getProcessInstanceId()); }
@Test public void testAddEscalationBoundaryEventToSubProcessAndThrowEscalation() { // given ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(ProcessModels.SUBPROCESS_PROCESS); ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(modify(ProcessModels.SUBPROCESS_PROCESS) .endEventBuilder("subProcessEnd").escalation(ESCALATION_CODE) // let the end event of the subprocess escalate .moveToActivity("subProcess") .boundaryEvent().escalation(ESCALATION_CODE) // catch escalation with boundary event .userTask(AFTER_BOUNDARY_TASK) .endEvent() .done() ); MigrationPlan migrationPlan = rule.getRuntimeService() .createMigrationPlan(sourceProcessDefinition.getId(), targetProcessDefinition.getId()) .mapActivities("subProcess", "subProcess") .mapActivities("userTask", "userTask") .build(); // when testHelper.createProcessInstanceAndMigrate(migrationPlan); // then it is possible to successfully complete the migrated instance testHelper.completeTask("userTask"); testHelper.completeTask(AFTER_BOUNDARY_TASK); testHelper.assertProcessEnded(testHelper.snapshotBeforeMigration.getProcessInstanceId()); }
public void testAsyncAfterErrorEvent() { // given BpmnModelInstance instance = Bpmn.createExecutableProcess("process") .startEvent() .serviceTask("servTask") .camundaClass(ThrowBpmnErrorDelegate.class) .boundaryEvent() .camundaAsyncAfter(true) .camundaFailedJobRetryTimeCycle("R10/PT10S") .errorEventDefinition() .errorEventDefinitionDone() .serviceTask() .camundaClass("foo") .endEvent() .moveToActivity("servTask") .endEvent().done(); deployment(instance); runtimeService.startProcessInstanceByKey("process"); Job job = managementService.createJobQuery().singleResult(); // when job fails try { managementService.executeJob(job.getId()); } catch (Exception e) { // ignore } // then job = managementService.createJobQuery().singleResult(); Assert.assertEquals(9, job.getRetries()); }
@Test public void testRemoveExecutionSequence() { // given BpmnModelInstance modelInstance = Bpmn.createExecutableProcess("singleTaskProcess") .startEvent() .userTask("taskWithLocalVariables") .camundaExecutionListenerClass("start", TestLocalVariableExecutionListener.class) .camundaTaskListenerClass("delete", TestLocalVariableTaskListener.class) .boundaryEvent() .signal("interruptSignal") .endEvent() .moveToActivity("taskWithLocalVariables") .endEvent() .done(); testRule.deploy(modelInstance); ProcessInstance pi = processEngineRule.getRuntimeService() .startProcessInstanceByKey("singleTaskProcess"); Execution execution = processEngineRule.getRuntimeService() .createExecutionQuery() .variableValueEquals("localVar", "localVarVal") .singleResult(); // when assertNotNull(execution); assertEquals(pi.getId(), execution.getProcessInstanceId()); processEngineRule.getRuntimeService().signal(execution.getId()); // then (see #TestLocalVariableTaskListener::notify) }
.subProcessDone() .endEvent() .moveToActivity("subprocess") .boundaryEvent("boundary").error("anErrorCode") .userTask("userTaskAfterBoundaryEvent")
.condition(VAR_CONDITION) .endEvent() .moveToActivity(SUB_PROCESS_ID) .boundaryEvent() .condition(VAR_CONDITION)
.condition(VAR_CONDITION) .endEvent() .moveToActivity(SUB_PROCESS_ID) .boundaryEvent() .condition(VAR_CONDITION)