public static ProcessInstance createMockInstance(String tenantId) { ProcessInstance mock = mock(ProcessInstance.class); when(mock.getId()).thenReturn(EXAMPLE_PROCESS_INSTANCE_ID); when(mock.getBusinessKey()).thenReturn(EXAMPLE_PROCESS_INSTANCE_BUSINESS_KEY); when(mock.getCaseInstanceId()).thenReturn(EXAMPLE_CASE_INSTANCE_ID); when(mock.getProcessDefinitionId()).thenReturn(EXAMPLE_PROCESS_DEFINITION_ID); when(mock.getProcessInstanceId()).thenReturn(EXAMPLE_PROCESS_INSTANCE_ID); when(mock.isSuspended()).thenReturn(EXAMPLE_PROCESS_INSTANCE_IS_SUSPENDED); when(mock.isEnded()).thenReturn(EXAMPLE_PROCESS_INSTANCE_IS_ENDED); when(mock.getTenantId()).thenReturn(tenantId); return mock; }
public ProcessInstanceDto(ProcessInstance instance) { this.id = instance.getId(); this.definitionId = instance.getProcessDefinitionId(); this.businessKey = instance.getBusinessKey(); this.caseInstanceId = instance.getCaseInstanceId(); this.ended = instance.isEnded(); this.suspended = instance.isSuspended(); this.tenantId = instance.getTenantId(); }
public ProcessInstanceDto(ProcessInstance instance) { this.id = instance.getId(); this.definitionId = instance.getProcessDefinitionId(); this.businessKey = instance.getBusinessKey(); this.caseInstanceId = instance.getCaseInstanceId(); this.ended = instance.isEnded(); this.suspended = instance.isSuspended(); this.tenantId = instance.getTenantId(); }
public void testStartProcessInstanceAndSetCaseInstanceId() { runtimeService.createProcessInstanceByKey(PROCESS_DEFINITION_KEY).caseInstanceId("caseInstanceId").execute(); ProcessInstance processInstance = runtimeService.createProcessInstanceQuery().singleResult(); assertThat(processInstance, is(notNullValue())); assertThat(processInstance.getCaseInstanceId(), is("caseInstanceId")); }
@Test @Deployment(resources = { "org/camunda/bpm/engine/test/api/runtime/superCase.cmmn", "org/camunda/bpm/engine/test/api/runtime/superProcessWithCallActivityInsideSubProcess.bpmn20.xml", "org/camunda/bpm/engine/test/api/runtime/subProcess.bpmn20.xml" }) public void testQueryByCaseInstanceIdHierarchy() { String caseInstanceId = caseService .withCaseDefinitionByKey("oneProcessTaskCase") .businessKey("aBusinessKey") .create() .getId(); ProcessInstanceQuery query = runtimeService.createProcessInstanceQuery(); query.caseInstanceId(caseInstanceId); assertEquals(2, query.count()); List<ProcessInstance> result = query.list(); assertEquals(2, result.size()); ProcessInstance firstProcessInstance = result.get(0); assertEquals(caseInstanceId, firstProcessInstance.getCaseInstanceId()); ProcessInstance secondProcessInstance = result.get(1); assertEquals(caseInstanceId, secondProcessInstance.getCaseInstanceId()); }
@Deployment(resources = "org/camunda/bpm/engine/test/api/oneTaskProcess.bpmn20.xml") @Test public void testStartByKeyWithCaseInstanceId() { String caseInstanceId = "aCaseInstanceId"; ProcessInstance firstInstance = runtimeService.startProcessInstanceByKey("oneTaskProcess", null, caseInstanceId); assertEquals(caseInstanceId, firstInstance.getCaseInstanceId()); // load process instance from db firstInstance = runtimeService .createProcessInstanceQuery() .processInstanceId(firstInstance.getId()) .singleResult(); assertNotNull(firstInstance); assertEquals(caseInstanceId, firstInstance.getCaseInstanceId()); // the second possibility to start a process instance ///////////////////////////////////////////// ProcessInstance secondInstance = runtimeService.startProcessInstanceByKey("oneTaskProcess", null, caseInstanceId, null); assertEquals(caseInstanceId, secondInstance.getCaseInstanceId()); // load process instance from db secondInstance = runtimeService .createProcessInstanceQuery() .processInstanceId(secondInstance.getId()) .singleResult(); assertNotNull(secondInstance); assertEquals(caseInstanceId, secondInstance.getCaseInstanceId()); }
@Deployment(resources = EXCLUSIVE_GATEWAY_PROCESS) public void testSingleActivityInstantiationSetCaseInstanceId() { // when ProcessInstance instance = runtimeService .createProcessInstanceByKey("exclusiveGateway") .caseInstanceId("caseInstanceId") .startBeforeActivity("task1") .execute(); // then assertNotNull(instance); assertEquals("caseInstanceId", instance.getCaseInstanceId()); }
@Test @Deployment(resources = { "org/camunda/bpm/engine/test/api/cmmn/oneProcessTaskCase.cmmn", "org/camunda/bpm/engine/test/api/oneTaskProcess.bpmn20.xml" }) public void testQueryByCaseInstanceId() { String caseInstanceId = caseService .withCaseDefinitionByKey("oneProcessTaskCase") .create() .getId(); ProcessInstanceQuery query = runtimeService.createProcessInstanceQuery(); query.caseInstanceId(caseInstanceId); assertEquals(1, query.count()); List<ProcessInstance> result = query.list(); assertEquals(1, result.size()); ProcessInstance processInstance = result.get(0); assertEquals(caseInstanceId, processInstance.getCaseInstanceId()); }
@Deployment(resources = "org/camunda/bpm/engine/test/api/oneTaskProcess.bpmn20.xml") @Test public void testStartByIdWithCaseInstanceId() { String processDefinitionId = repositoryService .createProcessDefinitionQuery() .processDefinitionKey("oneTaskProcess") .singleResult() .getId(); String caseInstanceId = "aCaseInstanceId"; ProcessInstance firstInstance = runtimeService.startProcessInstanceById(processDefinitionId, null, caseInstanceId); assertEquals(caseInstanceId, firstInstance.getCaseInstanceId()); // load process instance from db firstInstance = runtimeService .createProcessInstanceQuery() .processInstanceId(firstInstance.getId()) .singleResult(); assertNotNull(firstInstance); assertEquals(caseInstanceId, firstInstance.getCaseInstanceId()); // the second possibility to start a process instance ///////////////////////////////////////////// ProcessInstance secondInstance = runtimeService.startProcessInstanceById(processDefinitionId, null, caseInstanceId, null); assertEquals(caseInstanceId, secondInstance.getCaseInstanceId()); // load process instance from db secondInstance = runtimeService .createProcessInstanceQuery() .processInstanceId(secondInstance.getId()) .singleResult(); assertNotNull(secondInstance); assertEquals(caseInstanceId, secondInstance.getCaseInstanceId()); }
@Test public void shouldRestartProcessInstanceWithoutCaseInstanceId() { // given ProcessDefinition processDefinition = testRule.deployAndGetDefinition(ProcessModels.TWO_TASKS_PROCESS); ProcessInstance processInstance1 = runtimeService.startProcessInstanceByKey("Process", null, "caseInstanceId1"); ProcessInstance processInstance2 = runtimeService.startProcessInstanceByKey("Process", null, "caseInstanceId2"); runtimeService.deleteProcessInstance(processInstance1.getId(), "test"); runtimeService.deleteProcessInstance(processInstance2.getId(), "test"); // when Batch batch = runtimeService.restartProcessInstances(processDefinition.getId()) .startBeforeActivity("userTask1") .processInstanceIds(processInstance1.getId(), processInstance2.getId()) .executeAsync(); helper.completeBatch(batch); // then List<ProcessInstance> restartedProcessInstances = runtimeService.createProcessInstanceQuery().processDefinitionId(processDefinition.getId()).active().list(); ProcessInstance restartedProcessInstance1 = restartedProcessInstances.get(0); ProcessInstance restartedProcessInstance2 = restartedProcessInstances.get(1); assertNull(restartedProcessInstance1.getCaseInstanceId()); assertNull(restartedProcessInstance2.getCaseInstanceId()); }
@Deployment(resources={ "org/camunda/bpm/engine/test/api/cmmn/oneProcessTaskCase.cmmn", "org/camunda/bpm/engine/test/api/oneTaskProcess.bpmn20.xml" }) public void testStart() { // given String caseInstanceId = createCaseInstance(DEFINITION_KEY).getId(); ProcessInstance processInstance; // then processInstance = queryProcessInstance(); assertNotNull(processInstance); assertEquals(caseInstanceId, processInstance.getCaseInstanceId()); CaseExecution processTask = queryCaseExecutionByActivityId(PROCESS_TASK_KEY); assertTrue(processTask.isActive()); }
assertEquals(caseInstanceId, processInstance.getCaseInstanceId());
@Test public void shouldRestartProcessInstanceWithoutCaseInstanceId() { // given ProcessDefinition processDefinition = testRule.deployAndGetDefinition(ProcessModels.TWO_TASKS_PROCESS); ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("Process", null, "caseInstanceId"); runtimeService.deleteProcessInstance(processInstance.getId(), "test"); // when runtimeService.restartProcessInstances(processDefinition.getId()) .startBeforeActivity("userTask1") .processInstanceIds(processInstance.getId()) .execute(); // then ProcessInstance restartedProcessInstance = runtimeService.createProcessInstanceQuery().processDefinitionId(processDefinition.getId()).active().singleResult(); assertNull(restartedProcessInstance.getCaseInstanceId()); }
@Deployment(resources={ "org/camunda/bpm/engine/test/api/cmmn/oneProcessTaskCaseWithManualActivation.cmmn", "org/camunda/bpm/engine/test/api/oneTaskProcess.bpmn20.xml" }) public void testManualStart() { // given String caseInstanceId = createCaseInstance(DEFINITION_KEY).getId(); String processTaskId = queryCaseExecutionByActivityId(PROCESS_TASK_KEY).getId(); ProcessInstance processInstance = queryProcessInstance(); assertNull(processInstance); // when caseService .withCaseExecution(processTaskId) .manualStart(); // then processInstance = queryProcessInstance(); assertNotNull(processInstance); assertEquals(caseInstanceId, processInstance.getCaseInstanceId()); CaseExecution processTask = queryCaseExecutionByActivityId(PROCESS_TASK_KEY); assertTrue(processTask.isActive()); }
assertEquals(caseInstanceId, processInstance.getCaseInstanceId());
public ProcessInstanceDto(ProcessInstance instance) { this.id = instance.getId(); this.definitionId = instance.getProcessDefinitionId(); this.businessKey = instance.getBusinessKey(); this.caseInstanceId = instance.getCaseInstanceId(); this.ended = instance.isEnded(); this.suspended = instance.isSuspended(); this.tenantId = instance.getTenantId(); }
public void testStartProcessInstanceAndSetCaseInstanceId() { runtimeService.createProcessInstanceByKey(PROCESS_DEFINITION_KEY).caseInstanceId("caseInstanceId").execute(); ProcessInstance processInstance = runtimeService.createProcessInstanceQuery().singleResult(); assertThat(processInstance, is(notNullValue())); assertThat(processInstance.getCaseInstanceId(), is("caseInstanceId")); }
@Deployment(resources = EXCLUSIVE_GATEWAY_PROCESS) public void testSingleActivityInstantiationSetCaseInstanceId() { // when ProcessInstance instance = runtimeService .createProcessInstanceByKey("exclusiveGateway") .caseInstanceId("caseInstanceId") .startBeforeActivity("task1") .execute(); // then assertNotNull(instance); assertEquals("caseInstanceId", instance.getCaseInstanceId()); }
@Deployment(resources={ "org/camunda/bpm/engine/test/api/cmmn/oneProcessTaskCase.cmmn", "org/camunda/bpm/engine/test/api/oneTaskProcess.bpmn20.xml" }) public void testStart() { // given String caseInstanceId = createCaseInstance(DEFINITION_KEY).getId(); ProcessInstance processInstance; // then processInstance = queryProcessInstance(); assertNotNull(processInstance); assertEquals(caseInstanceId, processInstance.getCaseInstanceId()); CaseExecution processTask = queryCaseExecutionByActivityId(PROCESS_TASK_KEY); assertTrue(processTask.isActive()); }
@Test public void shouldRestartProcessInstanceWithoutCaseInstanceId() { // given ProcessDefinition processDefinition = testRule.deployAndGetDefinition(ProcessModels.TWO_TASKS_PROCESS); ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("Process", null, "caseInstanceId"); runtimeService.deleteProcessInstance(processInstance.getId(), "test"); // when runtimeService.restartProcessInstances(processDefinition.getId()) .startBeforeActivity("userTask1") .processInstanceIds(processInstance.getId()) .execute(); // then ProcessInstance restartedProcessInstance = runtimeService.createProcessInstanceQuery().processDefinitionId(processDefinition.getId()).active().singleResult(); assertNull(restartedProcessInstance.getCaseInstanceId()); }