Java Code Examples for org.camunda.bpm.engine.RuntimeService#createIncident()

The following examples show how to use org.camunda.bpm.engine.RuntimeService#createIncident() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MigrationIncidentTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@Test
public void testCustomIncidentMigration() {
  // given
  RuntimeService runtimeService = engineRule.getRuntimeService();
  BpmnModelInstance instance1 = Bpmn.createExecutableProcess("process1").startEvent().userTask("u1").endEvent().done();
  BpmnModelInstance instance2 = Bpmn.createExecutableProcess("process2").startEvent().userTask("u2").endEvent().done();

  testHelper.deploy(instance1, instance2);

  ProcessInstance processInstance1 = runtimeService.startProcessInstanceByKey("process1");
  ProcessInstance processInstance2 = runtimeService.startProcessInstanceByKey("process2");

  MigrationPlan migrationPlan = runtimeService
      .createMigrationPlan(processInstance1.getProcessDefinitionId(), processInstance2.getProcessDefinitionId())
      .mapActivities("u1", "u2")
      .build();

  runtimeService.createIncident("custom", processInstance1.getId(), "foo");

  // when
  runtimeService.newMigration(migrationPlan).processInstanceIds(processInstance1.getId()).execute();

  // then
  Incident incident = runtimeService.createIncidentQuery().singleResult();
  assertEquals(processInstance2.getProcessDefinitionId(), incident.getProcessDefinitionId());
  assertEquals("custom", incident.getIncidentType());
  assertEquals(processInstance1.getId(), incident.getExecutionId());
}
 
Example 2
Source File: MigrationIncidentTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@Test
public void testCustomIncidentMigrationWithoutConfiguration() {
  // given
  RuntimeService runtimeService = engineRule.getRuntimeService();
  BpmnModelInstance instance1 = Bpmn.createExecutableProcess("process1").startEvent().userTask("u1").endEvent().done();
  BpmnModelInstance instance2 = Bpmn.createExecutableProcess("process2").startEvent().userTask("u2").endEvent().done();

  testHelper.deploy(instance1, instance2);

  ProcessInstance processInstance1 = runtimeService.startProcessInstanceByKey("process1");
  ProcessInstance processInstance2 = runtimeService.startProcessInstanceByKey("process2");

  MigrationPlan migrationPlan = runtimeService
      .createMigrationPlan(processInstance1.getProcessDefinitionId(), processInstance2.getProcessDefinitionId())
      .mapActivities("u1", "u2")
      .build();

  runtimeService.createIncident("custom", processInstance1.getId(), null);

  // when
  runtimeService.newMigration(migrationPlan).processInstanceIds(processInstance1.getId()).execute();

  // then
  Incident incident = runtimeService.createIncidentQuery().singleResult();
  assertEquals(processInstance2.getProcessDefinitionId(), incident.getProcessDefinitionId());
  assertEquals("custom", incident.getIncidentType());
  assertEquals(processInstance1.getId(), incident.getExecutionId());
}
 
Example 3
Source File: RuntimeServiceTest.java    From camunda-bpm-platform with Apache License 2.0 4 votes vote down vote up
@Override
public void execute(DelegateExecution execution) throws Exception {
  RuntimeService runtimeService = execution.getProcessEngineServices().getRuntimeService();
  runtimeService.createIncident("foo", execution.getId(), null);
}