public static void assertProcessEnded(ProcessEngine processEngine, String processInstanceId) { ProcessInstance processInstance = processEngine .getRuntimeService() .createProcessInstanceQuery() .processInstanceId(processInstanceId) .singleResult(); if (processInstance!=null) { throw new AssertionFailedError("expected finished process instance '"+processInstanceId+"' but it was still in the db"); } } }
public void assertProcessEnded(final String processInstanceId) { ProcessInstance processInstance = processEngine .getRuntimeService() .createProcessInstanceQuery() .processInstanceId(processInstanceId) .singleResult(); if (processInstance!=null) { throw new AssertionFailedError("Expected finished process instance '"+processInstanceId+"' but it was still in the db"); } }
protected ProcessInstance queryProcessInstance() { return runtimeService .createProcessInstanceQuery() .singleResult(); }
private void createProcessInstanceMock() { ProcessInstance mockInstance = MockProvider.createMockInstance(); ProcessInstanceQuery mockInstanceQuery = mock(ProcessInstanceQuery.class); when(mockInstanceQuery.processInstanceId(eq(MockProvider.EXAMPLE_PROCESS_INSTANCE_ID))).thenReturn(mockInstanceQuery); when(mockInstanceQuery.singleResult()).thenReturn(mockInstance); when(mockRuntimeService.createProcessInstanceQuery()).thenReturn(mockInstanceQuery); }
@Override public ProcessInstanceDto getProcessInstance() { RuntimeService runtimeService = engine.getRuntimeService(); ProcessInstance instance = runtimeService.createProcessInstanceQuery().processInstanceId(processInstanceId).singleResult(); if (instance == null) { throw new InvalidRequestException(Status.NOT_FOUND, "Process instance with id " + processInstanceId + " does not exist"); } ProcessInstanceDto result = ProcessInstanceDto.fromProcessInstance(instance); return result; }
public void assertProcessEnded(String processInstanceId) { ProcessInstance processInstance = processEngine .getRuntimeService() .createProcessInstanceQuery() .processInstanceId(processInstanceId) .singleResult(); assertThat("Process instance with id " + processInstanceId + " is not finished", processInstance, is(nullValue())); }
@Test public void testQueryNoSpecificsSingleResult() { ProcessInstanceQuery query = runtimeService.createProcessInstanceQuery(); try { query.singleResult(); fail(); } catch (ProcessEngineException e) { // Exception is expected } }
@Deployment @Test public void testSetUpdateAndDeleteComplexVariable() { // when a process instance is started runtimeService.startProcessInstanceByKey("oneUserTaskProcess", Collections.<String, Object>singletonMap("var", new SimpleSerializableBean(10))); // then it should wait at the user task ProcessInstance processInstance = runtimeService.createProcessInstanceQuery().singleResult(); assertNotNull(processInstance); }
public void testStartProcessInstanceAtActivityByKeyWithoutTenantId() { deployment(PROCESS); deploymentForTenant(TENANT_ONE, PROCESS); runtimeService.createProcessInstanceByKey("testProcess") .processDefinitionWithoutTenantId() .startBeforeActivity("userTask") .execute(); ProcessInstanceQuery query = runtimeService.createProcessInstanceQuery(); assertThat(query.count(), is(1L)); assertThat(query.singleResult().getTenantId(), is(nullValue())); }
public void testPropagateTenantIdToProcessInstance() { deploymentForTenant(TENANT_ID, Bpmn.createExecutableProcess(PROCESS_DEFINITION_KEY) .startEvent() .userTask() .endEvent() .done()); startProcessInstance(PROCESS_DEFINITION_KEY); ProcessInstance processInstance = runtimeService.createProcessInstanceQuery().singleResult(); assertThat(processInstance, is(notNullValue())); // inherit the tenant id from process definition assertThat(processInstance.getTenantId(), is(TENANT_ID)); }
@Test public void testQueryByProcessDefinitionKeyMultipleResults() { ProcessInstanceQuery query = runtimeService.createProcessInstanceQuery().processDefinitionKey(PROCESS_DEFINITION_KEY); assertEquals(4, query.count()); assertEquals(4, query.list().size()); try { query.singleResult(); fail(); } catch (ProcessEngineException e) { // Exception is expected } }
@Override public String getProperty(Execution obj) { ProcessInstance processInstance = runtimeService.createProcessInstanceQuery() .processInstanceId(obj.getProcessInstanceId()).singleResult(); ProcessDefinition processDefinition = repositoryService.getProcessDefinition(processInstance.getProcessDefinitionId()); return processDefinition.getKey(); } });
@Deployment(resources = {"org/camunda/bpm/engine/test/api/runtime/superProcess.bpmn20.xml", "org/camunda/bpm/engine/test/api/runtime/subProcess.bpmn20.xml"}) @Test public void testQueryBySubProcessInstanceId() { ProcessInstance superProcessInstance = runtimeService.startProcessInstanceByKey("subProcessQueryTest"); ProcessInstance subProcessInstance = runtimeService.createProcessInstanceQuery().superProcessInstanceId(superProcessInstance.getId()).singleResult(); assertNotNull(subProcessInstance); assertEquals(superProcessInstance.getId(), runtimeService.createProcessInstanceQuery().subProcessInstanceId(subProcessInstance.getId()).singleResult().getId()); }
@Test @Deployment(resources = {"org/camunda/bpm/engine/test/api/cmmn/oneProcessTaskCase.cmmn"}) public void testQueryBySuperCaseInstanceId() { String superCaseInstanceId = caseService.createCaseInstanceByKey("oneProcessTaskCase").getId(); ProcessInstanceQuery query = runtimeService .createProcessInstanceQuery() .superCaseInstanceId(superCaseInstanceId); assertEquals(1, query.list().size()); assertEquals(1, query.count()); ProcessInstance subProcessInstance = query.singleResult(); assertNotNull(subProcessInstance); }
public void testSimpleQueryWithReadPermissionOnProcessInstance() { // given String processInstanceId = startProcessInstanceByKey(PROCESS_KEY).getId(); createGrantAuthorization(PROCESS_INSTANCE, processInstanceId, userId, READ); // when ProcessInstanceQuery query = runtimeService.createProcessInstanceQuery(); // then verifyQueryResults(query, 1); ProcessInstance instance = query.singleResult(); assertNotNull(instance); assertEquals(processInstanceId, instance.getId()); }
@Test @Deployment(resources={"org/camunda/bpm/engine/test/api/runtime/oneFailingServiceProcess.bpmn20.xml"}) public void testQueryByDeleted() { startProcessInstance(PROCESS_DEFINITION_KEY); String processInstanceId = runtimeService.createProcessInstanceQuery().singleResult().getId(); runtimeService.deleteProcessInstance(processInstanceId, null); HistoricIncidentQuery query = historyService.createHistoricIncidentQuery() .deleted(); assertEquals(1, query.list().size()); assertEquals(1, query.count()); }
@Deployment(resources={"org/camunda/bpm/engine/test/api/runtime/MessageCorrelationTest.testMessageStartEventCorrelation.bpmn20.xml"}) @Test public void testMessageStartEventCorrelationWithBusinessKeyUsingFluentCorrelateStartMessage() { final String businessKey = "aBusinessKey"; runtimeService.createMessageCorrelation("newInvoiceMessage") .processInstanceBusinessKey(businessKey) .correlateStartMessage(); ProcessInstance processInstance = runtimeService.createProcessInstanceQuery().singleResult(); assertNotNull(processInstance); assertEquals(businessKey, processInstance.getBusinessKey()); }
protected void checkBusinessKeyChanged(String newBusinessKeyValue) { ProcessInstance processInstance = runtimeService.createProcessInstanceQuery().processDefinitionKey(PROCESS_KEY).singleResult(); assertNotNull(processInstance); assertEquals(newBusinessKeyValue, processInstance.getBusinessKey()); HistoricProcessInstance historicInstance = historyService.createHistoricProcessInstanceQuery().singleResult(); assertNotNull(historicInstance); assertEquals(newBusinessKeyValue, historicInstance.getBusinessKey()); }
@Deployment public void testExecutionJobsParallel() { runtimeService.startProcessInstanceByKey("testProcess"); ExecutionEntity processInstance = (ExecutionEntity) runtimeService.createProcessInstanceQuery().singleResult(); assertEquals(0, processInstance.getCachedEntityStateRaw()); ExecutionEntity execution = (ExecutionEntity) runtimeService.createExecutionQuery().activityId("userTask").singleResult(); assertEquals(BitMaskUtil.getMaskForBit(ExecutionEntity.JOBS_STATE_BIT), execution.getCachedEntityStateRaw()); }
@Deployment(resources = { CALL_ACTIVITY_PARENT_PROCESS, CALL_ACTIVITY_CHILD_PROCESS }) public void FAILING_testCancelCallActivityInstance() { // given ProcessInstance parentprocess = runtimeService.startProcessInstanceByKey("parentprocess"); ProcessInstance subProcess = runtimeService.createProcessInstanceQuery().processDefinitionKey("subprocess").singleResult(); ActivityInstance subProcessActivityInst = runtimeService.getActivityInstance(subProcess.getId()); // when runtimeService.createProcessInstanceModification(subProcess.getId()).startBeforeActivity("childEnd", subProcess.getId()) .cancelActivityInstance(getInstanceIdForActivity(subProcessActivityInst, "innerTask")).execute(); // then assertProcessEnded(parentprocess.getId()); }