public JobDefinitionQuery jobDefinitionQuery() { ProcessInstance instance = processInstance(); return managementService.createJobDefinitionQuery() .processDefinitionId(instance.getProcessDefinitionId()); }
public static ProcessInstance createAnotherMockInstance() { ProcessInstance mock = mock(ProcessInstance.class); when(mock.getId()).thenReturn(ANOTHER_EXAMPLE_PROCESS_INSTANCE_ID); when(mock.getBusinessKey()).thenReturn(EXAMPLE_PROCESS_INSTANCE_BUSINESS_KEY); when(mock.getProcessDefinitionId()).thenReturn(EXAMPLE_PROCESS_DEFINITION_ID); when(mock.getProcessInstanceId()).thenReturn(ANOTHER_EXAMPLE_PROCESS_INSTANCE_ID); when(mock.isSuspended()).thenReturn(EXAMPLE_PROCESS_INSTANCE_IS_SUSPENDED); when(mock.isEnded()).thenReturn(EXAMPLE_PROCESS_INSTANCE_IS_ENDED); return mock; }
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 void testActivityStatistics() { ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("SingleTaskProcess"); ActivityStatisticsQuery query = managementService.createActivityStatisticsQuery(processInstance.getProcessDefinitionId()); assertThat(query.count(), is(1L)); }
public void testQueryAuthenticatedTenantForActivityStatistics() { identityService.setAuthentication("user", null, Arrays.asList(TENANT_ONE)); ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("SingleTaskProcess"); ActivityStatisticsQuery query = managementService.createActivityStatisticsQuery(processInstance.getProcessDefinitionId()); assertThat(query.count(), is(1L)); }
@Test public void testGetStartFormVariablesWithNoAuthenticatedTenant() { engineRule.getIdentityService().setAuthentication("aUserId", null); thrown.expect(ProcessEngineException.class); thrown.expectMessage("Cannot get the process definition '" + instance.getProcessDefinitionId() +"' because it belongs to no authenticated tenant."); engineRule.getFormService().getStartFormVariables(instance.getProcessDefinitionId()); }
@Test @Deployment(resources = {ONE_TASK_PROCESS}) public void testQueryProcessDefinitionOperationsById() { // given process = runtimeService.startProcessInstanceByKey("oneTaskProcess"); // when repositoryService.suspendProcessDefinitionById(process.getProcessDefinitionId(), true, null); repositoryService.activateProcessDefinitionById(process.getProcessDefinitionId(), true, null); // then assertEquals(0, query().entityType(PROCESS_DEFINITION).count()); }
protected void checkProcessDefinitionMessageCorrelationResult(MessageCorrelationResult result, String startActivityId, String processDefinitionId) { assertNotNull(result); assertNotNull(result.getProcessInstance().getId()); assertEquals(MessageCorrelationResultType.ProcessDefinition, result.getResultType()); assertTrue(result.getProcessInstance().getProcessDefinitionId().contains(processDefinitionId)); }
@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/messageStartEvent.bpmn20.xml") @Test public void testStartProcessInstanceByMessageWithEarlierVersionOfProcessDefinition() { String deploymentId = repositoryService.createDeployment().addClasspathResource("org/camunda/bpm/engine/test/api/runtime/messageStartEvent_version2.bpmn20.xml").deploy().getId(); ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().processDefinitionVersion(1).singleResult(); ProcessInstance processInstance = runtimeService.startProcessInstanceByMessageAndProcessDefinitionId("startMessage", processDefinition.getId()); assertThat(processInstance, is(notNullValue())); assertThat(processInstance.getProcessDefinitionId(), is(processDefinition.getId())); // clean up repositoryService.deleteDeployment(deploymentId, true); }
@Deployment(resources={"org/camunda/bpm/engine/test/api/task/TaskQueryTest.testProcessDefinition.bpmn20.xml"}) public void testProcessDefinitionId() throws Exception { ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("oneTaskProcess"); List<Task> tasks = taskService.createTaskQuery().processDefinitionId(processInstance.getProcessDefinitionId()).list(); assertEquals(1, tasks.size()); assertEquals(processInstance.getId(), tasks.get(0).getProcessInstanceId()); assertEquals(0, taskService.createTaskQuery().processDefinitionId("unexisting").count()); }
@Test public void testGetStartFormKeyWithNoAuthenticatedTenant() { testRule.deployForTenant(TENANT_ONE, "org/camunda/bpm/engine/test/api/authorization/formKeyProcess.bpmn20.xml"); String processDefinitionId = runtimeService.startProcessInstanceByKey(PROCESS_DEFINITION_KEY).getProcessDefinitionId(); identityService.setAuthentication("aUserId", null); thrown.expect(ProcessEngineException.class); thrown.expectMessage("Cannot get the process definition '" + processDefinitionId + "' because it belongs to no authenticated tenant."); formService.getStartFormKey(processDefinitionId); }
@Test public void testGetStartFormKeyWithDisabledTenantCheck() { testRule.deployForTenant(TENANT_ONE, "org/camunda/bpm/engine/test/api/authorization/formKeyProcess.bpmn20.xml"); String processDefinitionId = runtimeService.startProcessInstanceByKey(PROCESS_DEFINITION_KEY).getProcessDefinitionId(); identityService.setAuthentication("aUserId", null); processEngineConfiguration.setTenantCheckEnabled(false); // then assertEquals("aStartFormKey", formService.getStartFormKey(processDefinitionId)); }
@Test @Deployment(resources={"org/camunda/bpm/engine/test/api/runtime/oneFailingServiceProcess.bpmn20.xml"}) public void testQueryByProcessDefinitionId() { startProcessInstance(PROCESS_DEFINITION_KEY); ProcessInstance pi = runtimeService.createProcessInstanceQuery().singleResult(); HistoricIncidentQuery query = historyService.createHistoricIncidentQuery() .processDefinitionId(pi.getProcessDefinitionId()); assertEquals(1, query.list().size()); assertEquals(1, query.count()); }
@Test public void testGetStartFormVariablesWithDisabledTenantCheck() { engineRule.getIdentityService().setAuthentication("aUserId", null); engineRule.getProcessEngineConfiguration().setTenantCheckEnabled(false); assertEquals(4, engineRule.getFormService().getStartFormVariables(instance.getProcessDefinitionId()).size()); }
@Deployment(resources = "org/camunda/bpm/engine/test/bpmn/async/AsyncStartEventTest.testAsyncSubProcessStartEvent.bpmn") public void testAsyncSubProcessStartEventActivityInstance() { ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("process"); ActivityInstance tree = runtimeService.getActivityInstance(processInstance.getId()); assertThat(tree).hasStructure( describeActivityInstanceTree(processInstance.getProcessDefinitionId()) .beginScope("SubProcess_1") .transition("StartEvent_2") .done()); } }
@Deployment(resources = "org/camunda/bpm/engine/test/bpmn/event/escalation/EscalationEventTest.testThrowEscalationEventFromEmbeddedSubprocess.bpmn20.xml") public void testNonInterruptingEscalationBoundaryEvent(){ ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("escalationProcess"); // an escalation event is thrown from embedded subprocess and caught by non-interrupting boundary event on subprocess ActivityInstance tree = runtimeService.getActivityInstance(processInstance.getId()); assertThat(tree).hasStructure( describeActivityInstanceTree(processInstance.getProcessDefinitionId()) .activity("taskAfterCatchedEscalation") .beginScope("subProcess") .activity("taskInSubprocess") .done()); }
@Deployment @Test public void testActivityInstanceTreeForNestedAsyncBeforeStartEvent() { ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("oneTaskProcess"); ActivityInstance tree = runtimeService.getActivityInstance(processInstance.getId()); assertThat(tree).hasStructure( describeActivityInstanceTree(processInstance.getProcessDefinitionId()) .beginScope("subProcess") .transition("theSubProcessStart") .done()); }
@Deployment(resources = TRANSACTION_WITH_COMPENSATION_PROCESS) public void testCancelCompensatingTaskAndStartActivity() { ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("testProcess"); completeTasksInOrder("userTask"); ActivityInstance tree = runtimeService.getActivityInstance(processInstance.getId()); runtimeService.createProcessInstanceModification(processInstance.getId()).cancelActivityInstance(getInstanceIdForActivity(tree, "undoTask")) .startBeforeActivity("userTask").execute(); tree = runtimeService.getActivityInstance(processInstance.getId()); assertThat(tree).hasStructure(describeActivityInstanceTree(processInstance.getProcessDefinitionId()).beginScope("tx").activity("userTask").done()); completeTasksInOrder("userTask", "undoTask", "afterCancel"); assertProcessEnded(processInstance.getId()); }