org.camunda.bpm.engine.RuntimeService Java Examples
The following examples show how to use
org.camunda.bpm.engine.RuntimeService.
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: TestBPMModule.java From Orienteer with Apache License 2.0 | 8 votes |
@Test @Deployment(resources = { "example-sequence.bpmn" }) public void testCorrelateByVariables() { RuntimeService runtimeService = processEngineRule.getRuntimeService(); Map<String, Object> vars = new HashMap<String, Object>(); vars.put("testString", "testVarString"); vars.put("testBoolean", new Boolean(true)); vars.put("testLong", new Long(15)); ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("Process_1", vars); assertProcessNotEnded(processInstance.getId()); runtimeService.createMessageCorrelation("Message-Request") .processInstanceVariableEquals("testString", "testVarString").correlate(); assertProcessNotEnded(processInstance.getId()); runtimeService.createMessageCorrelation(null).processInstanceVariableEquals("testString", "NonExisting") .correlateAll(); assertProcessNotEnded(processInstance.getId()); runtimeService.createMessageCorrelation(null).processInstanceVariableEquals("testString", "testVarString") .correlate(); assertProcessEnded(processInstance.getId()); }
Example #2
Source File: VariableInstanceQueryForOracleTest.java From camunda-bpm-platform with Apache License 2.0 | 7 votes |
@Test public void testQueryWhen1001InstancesActive() { // given Assume.assumeTrue(engineRule.getProcessEngineConfiguration().getDatabaseType().equals("oracle")); RuntimeService runtimeService = engineRule.getRuntimeService(); testRule.deploy(ProcessModels.TWO_TASKS_PROCESS); String[] ids = new String[1001]; // when for (int i = 0; i < 1001; i++) { ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("Process", Variables.createVariables().putValue("foo", "bar")); String activityInstanceId = runtimeService.getActivityInstance(processInstance.getId()).getId(); ids[i] = activityInstanceId; } // then List<VariableInstance> variables = engineRule.getRuntimeService().createVariableInstanceQuery() .activityInstanceIdIn(ids).list(); assertEquals(1001, variables.size()); }
Example #3
Source File: VariableInstanceQueryForOracleTest.java From camunda-bpm-platform with Apache License 2.0 | 7 votes |
@Test public void testQueryWhen1000InstancesActive() { // given Assume.assumeTrue(engineRule.getProcessEngineConfiguration().getDatabaseType().equals("oracle")); RuntimeService runtimeService = engineRule.getRuntimeService(); testRule.deploy(ProcessModels.TWO_TASKS_PROCESS); String[] ids = new String[1000]; // when for (int i = 0; i < 1000; i++) { ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("Process", Variables.createVariables().putValue("foo", "bar")); String activityInstanceId = runtimeService.getActivityInstance(processInstance.getId()).getId(); ids[i] = activityInstanceId; } // then List<VariableInstance> variables = engineRule.getRuntimeService().createVariableInstanceQuery() .activityInstanceIdIn(ids).list(); assertEquals(1000, variables.size()); }
Example #4
Source File: VariableInstanceQueryForOracleTest.java From camunda-bpm-platform with Apache License 2.0 | 7 votes |
@Test public void testQueryWhen1InstanceActive() { // given Assume.assumeTrue(engineRule.getProcessEngineConfiguration().getDatabaseType().equals("oracle")); RuntimeService runtimeService = engineRule.getRuntimeService(); testRule.deploy(ProcessModels.TWO_TASKS_PROCESS); // when ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("Process", Variables.createVariables().putValue("foo", "bar")); String activityInstanceId = runtimeService.getActivityInstance(processInstance.getId()).getId(); // then List<VariableInstance> variables = engineRule.getRuntimeService().createVariableInstanceQuery() .activityInstanceIdIn(activityInstanceId).list(); assertEquals(1, variables.size()); }
Example #5
Source File: OSGiELTenantIntegrationTest.java From camunda-bpm-platform-osgi with Apache License 2.0 | 7 votes |
@Test public void tenantSubprocessShouldBeResolved() throws InterruptedException { Hashtable<String, String> properties = new Hashtable<String, String>(); properties.put("processExpression", "calledElementTenantIdProvider"); MockedCalledElementTenantIdProvider service = new MockedCalledElementTenantIdProvider("t1"); ctx.registerService(MockedCalledElementTenantIdProvider.class, service, properties); RuntimeService runtimeService = processEngine.getRuntimeService(); runtimeService.startProcessInstanceByKey("tenantParentProcess"); ProcessInstance processInstance = processEngine.getRuntimeService().createProcessInstanceQuery() .processDefinitionKey("Process_1").singleResult(); assertThat(processInstance.isEnded(), is(false)); Task task = processEngine.getTaskService().createTaskQuery().singleResult(); assertThat(task.getName(), is("specific tenant task")); }
Example #6
Source File: MockedProcessEngineProvider.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
private void mockServices(ProcessEngine engine) { RepositoryService repoService = mock(RepositoryService.class); IdentityService identityService = mock(IdentityService.class); TaskService taskService = mock(TaskService.class); RuntimeService runtimeService = mock(RuntimeService.class); FormService formService = mock(FormService.class); HistoryService historyService = mock(HistoryService.class); ManagementService managementService = mock(ManagementService.class); CaseService caseService = mock(CaseService.class); FilterService filterService = mock(FilterService.class); ExternalTaskService externalTaskService = mock(ExternalTaskService.class); when(engine.getRepositoryService()).thenReturn(repoService); when(engine.getIdentityService()).thenReturn(identityService); when(engine.getTaskService()).thenReturn(taskService); when(engine.getRuntimeService()).thenReturn(runtimeService); when(engine.getFormService()).thenReturn(formService); when(engine.getHistoryService()).thenReturn(historyService); when(engine.getManagementService()).thenReturn(managementService); when(engine.getCaseService()).thenReturn(caseService); when(engine.getFilterService()).thenReturn(filterService); when(engine.getExternalTaskService()).thenReturn(externalTaskService); }
Example #7
Source File: MessageCorrelationMockExample.java From camunda-bpm-mockito with Apache License 2.0 | 6 votes |
@Test public void mock_messageCorrelation() { // setup mock final RuntimeService runtimeService = mock(RuntimeService.class); final MessageCorrelationBuilder correlation = ProcessExpressions.mockMessageCorrelation(runtimeService, "MESSAGE_NAME"); final MyCorrelator serviceUnderTest = new MyCorrelator(runtimeService, "my-business-key", "value-1"); // execute correlation, e.g. in a class under test (service, delegate, whatever) serviceUnderTest.correlate(); // verify verify(correlation).correlate(); verify(correlation).processDefinitionId("some_process_id"); verify(correlation).processInstanceBusinessKey("my-business-key"); verify(correlation).setVariable("myVar1", "value-1"); verify(runtimeService).createMessageCorrelation("MESSAGE_NAME"); verifyNoMoreInteractions(correlation); verifyNoMoreInteractions(runtimeService); }
Example #8
Source File: MigrationRestServiceInteractionTest.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
@Before public void setUpRuntimeData() { runtimeServiceMock = mock(RuntimeService.class); when(processEngine.getRuntimeService()).thenReturn(runtimeServiceMock); migrationPlanBuilderMock = new MockMigrationPlanBuilder() .sourceProcessDefinitionId(EXAMPLE_PROCESS_DEFINITION_ID) .targetProcessDefinitionId(ANOTHER_EXAMPLE_PROCESS_DEFINITION_ID) .instruction(EXAMPLE_ACTIVITY_ID, ANOTHER_EXAMPLE_ACTIVITY_ID) .instruction(ANOTHER_EXAMPLE_ACTIVITY_ID, EXAMPLE_ACTIVITY_ID) .builder(); when(runtimeServiceMock.createMigrationPlan(eq(EXAMPLE_PROCESS_DEFINITION_ID), eq(ANOTHER_EXAMPLE_PROCESS_DEFINITION_ID))) .thenReturn(migrationPlanBuilderMock); migrationPlanExecutionBuilderMock = mock(MigrationPlanExecutionBuilder.class); when(migrationPlanExecutionBuilderMock.processInstanceIds(anyListOf(String.class))).thenReturn(migrationPlanExecutionBuilderMock); when(runtimeServiceMock.newMigration(any(MigrationPlan.class))).thenReturn(migrationPlanExecutionBuilderMock); }
Example #9
Source File: ProcessInstanceRestServiceImpl.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
@Override public BatchDto deleteAsync(DeleteProcessInstancesDto dto) { RuntimeService runtimeService = getProcessEngine().getRuntimeService(); ProcessInstanceQuery processInstanceQuery = null; if (dto.getProcessInstanceQuery() != null) { processInstanceQuery = dto.getProcessInstanceQuery().toQuery(getProcessEngine()); } Batch batch = null; try { batch = runtimeService.deleteProcessInstancesAsync(dto.getProcessInstanceIds(), processInstanceQuery, dto.getDeleteReason(), dto.isSkipCustomListeners(), dto.isSkipSubprocesses()); return BatchDto.fromBatch(batch); } catch (BadUserRequestException e) { throw new InvalidRequestException(Status.BAD_REQUEST, e.getMessage()); } }
Example #10
Source File: TestBPMModule.java From Orienteer with Apache License 2.0 | 6 votes |
@Test @Deployment(resources = { "loop.bpmn" }) public void testLoop() { RuntimeService runtimeService = processEngineRule.getRuntimeService(); ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("Process_1"); for (int i = 0; i < 2; i++) { runtimeService.createMessageCorrelation("continue").processInstanceId(processInstance.getId()) .correlateAll(); if (i % 10 == 0) { LOG.info("Iteration: " + i); } } runtimeService.createMessageCorrelation("stop").processInstanceId(processInstance.getId()).correlateAll(); assertProcessEnded(processInstance.getId()); }
Example #11
Source File: OSGiELTenantIntegrationTest.java From camunda-bpm-platform-osgi with Apache License 2.0 | 6 votes |
@Test public void defaultSubprocessShouldBeResolvedForNullTenant() throws InterruptedException { Hashtable<String, String> properties = new Hashtable<String, String>(); properties.put("processExpression", "calledElementTenantIdProvider"); MockedCalledElementTenantIdProvider service = new MockedCalledElementTenantIdProvider(null); ctx.registerService(MockedCalledElementTenantIdProvider.class, service, properties); RuntimeService runtimeService = processEngine.getRuntimeService(); runtimeService.createProcessInstanceByKey("tenantParentProcess") .execute(); // check if default sub process is called (tenant id = null) ProcessInstance subProcessInstance = runtimeService.createProcessInstanceQuery() .processDefinitionKey("Process_1").singleResult(); assertNull(subProcessInstance.getTenantId()); }
Example #12
Source File: MigrationRestServiceImpl.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
public MigrationPlanDto generateMigrationPlan(MigrationPlanGenerationDto generationDto) { RuntimeService runtimeService = processEngine.getRuntimeService(); String sourceProcessDefinitionId = generationDto.getSourceProcessDefinitionId(); String targetProcessDefinitionId = generationDto.getTargetProcessDefinitionId(); try { MigrationInstructionsBuilder instructionsBuilder = runtimeService.createMigrationPlan(sourceProcessDefinitionId, targetProcessDefinitionId) .mapEqualActivities(); if (generationDto.isUpdateEventTriggers()) { instructionsBuilder = instructionsBuilder.updateEventTriggers(); } MigrationPlan migrationPlan = instructionsBuilder.build(); return MigrationPlanDto.from(migrationPlan); } catch (BadUserRequestException e) { throw new InvalidRequestException(Status.BAD_REQUEST, e, e.getMessage()); } }
Example #13
Source File: DeleteProcessInstancesJobHandler.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
@Override public void execute(BatchJobConfiguration configuration, ExecutionEntity execution, CommandContext commandContext, String tenantId) { ByteArrayEntity configurationEntity = commandContext .getDbEntityManager() .selectById(ByteArrayEntity.class, configuration.getConfigurationByteArrayId()); DeleteProcessInstanceBatchConfiguration batchConfiguration = readConfiguration(configurationEntity.getBytes()); boolean initialLegacyRestrictions = commandContext.isRestrictUserOperationLogToAuthenticatedUsers(); commandContext.disableUserOperationLog(); commandContext.setRestrictUserOperationLogToAuthenticatedUsers(true); try { RuntimeService runtimeService = commandContext.getProcessEngineConfiguration().getRuntimeService(); if(batchConfiguration.isFailIfNotExists()) { runtimeService.deleteProcessInstances(batchConfiguration.getIds(), batchConfiguration.deleteReason, batchConfiguration.isSkipCustomListeners(), true, batchConfiguration.isSkipSubprocesses()); } else { runtimeService.deleteProcessInstancesIfExists(batchConfiguration.getIds(), batchConfiguration.deleteReason, batchConfiguration.isSkipCustomListeners(), true, batchConfiguration.isSkipSubprocesses()); } } finally { commandContext.enableUserOperationLog(); commandContext.setRestrictUserOperationLogToAuthenticatedUsers(initialLegacyRestrictions); } commandContext.getByteArrayManager().delete(configurationEntity); }
Example #14
Source File: RestartProcessInstanceRestServiceTest.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
@Before public void setUpRuntimeData() { runtimeServiceMock = mock(RuntimeService.class); when(processEngine.getRuntimeService()).thenReturn(runtimeServiceMock); historyServiceMock = mock(HistoryService.class); when(processEngine.getHistoryService()).thenReturn(historyServiceMock); builderMock = mock(RestartProcessInstanceBuilder.class); when(builderMock.startAfterActivity(anyString())).thenReturn(builderMock); when(builderMock.startBeforeActivity(anyString())).thenReturn(builderMock); when(builderMock.startTransition(anyString())).thenReturn(builderMock); when(builderMock.processInstanceIds(anyListOf(String.class))).thenReturn(builderMock); when(builderMock.historicProcessInstanceQuery(any(HistoricProcessInstanceQuery.class))).thenReturn(builderMock); when(builderMock.skipCustomListeners()).thenReturn(builderMock); when(builderMock.skipIoMappings()).thenReturn(builderMock); when(builderMock.initialSetOfVariables()).thenReturn(builderMock); when(builderMock.withoutBusinessKey()).thenReturn(builderMock); Batch batchMock = createMockBatch(); when(builderMock.executeAsync()).thenReturn(batchMock); when(runtimeServiceMock.restartProcessInstances(anyString())).thenReturn(builderMock); }
Example #15
Source File: SetExternalTasksRetriesTest.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
protected void deployTestProcesses() { org.camunda.bpm.engine.repository.Deployment deployment = engineRule.getRepositoryService().createDeployment() .addClasspathResource("org/camunda/bpm/engine/test/api/externaltask/oneExternalTaskProcess.bpmn20.xml") .addClasspathResource("org/camunda/bpm/engine/test/api/externaltask/externalTaskPriorityExpression.bpmn20.xml") .deploy(); engineRule.manageDeployment(deployment); RuntimeService runtimeService = engineRule.getRuntimeService(); if (processInstanceIds == null) { processInstanceIds = new ArrayList<>(); } for (int i = 0; i < 4; i++) { processInstanceIds.add(runtimeService.startProcessInstanceByKey(PROCESS_DEFINITION_KEY, i + "").getId()); } processInstanceIds.add(runtimeService.startProcessInstanceByKey(PROCESS_DEFINITION_KEY_2).getId()); }
Example #16
Source File: ProcessInstanceQueryTest.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
/** * Setup starts 4 process instances of oneTaskProcess * and 1 instance of otherOneTaskProcess */ @Before public void deployTestProcesses() throws Exception { org.camunda.bpm.engine.repository.Deployment deployment = engineRule.getRepositoryService().createDeployment() .addClasspathResource("org/camunda/bpm/engine/test/api/runtime/oneTaskProcess.bpmn20.xml") .addClasspathResource("org/camunda/bpm/engine/test/api/runtime/otherOneTaskProcess.bpmn20.xml") .deploy(); engineRule.manageDeployment(deployment); RuntimeService runtimeService = engineRule.getRuntimeService(); processInstanceIds = new ArrayList<>(); for (int i = 0; i < 4; i++) { processInstanceIds.add(runtimeService.startProcessInstanceByKey(PROCESS_DEFINITION_KEY, i + "").getId()); } processInstanceIds.add(runtimeService.startProcessInstanceByKey(PROCESS_DEFINITION_KEY_2, "businessKey_123").getId()); }
Example #17
Source File: MockedProcessEngineProvider.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
private void mockServices(ProcessEngine engine) { RepositoryService repoService = mock(RepositoryService.class); IdentityService identityService = mock(IdentityService.class); TaskService taskService = mock(TaskService.class); RuntimeService runtimeService = mock(RuntimeService.class); FormService formService = mock(FormService.class); HistoryService historyService = mock(HistoryService.class); ManagementService managementService = mock(ManagementService.class); CaseService caseService = mock(CaseService.class); FilterService filterService = mock(FilterService.class); ExternalTaskService externalTaskService = mock(ExternalTaskService.class); when(engine.getRepositoryService()).thenReturn(repoService); when(engine.getIdentityService()).thenReturn(identityService); when(engine.getTaskService()).thenReturn(taskService); when(engine.getRuntimeService()).thenReturn(runtimeService); when(engine.getFormService()).thenReturn(formService); when(engine.getHistoryService()).thenReturn(historyService); when(engine.getManagementService()).thenReturn(managementService); when(engine.getCaseService()).thenReturn(caseService); when(engine.getFilterService()).thenReturn(filterService); when(engine.getExternalTaskService()).thenReturn(externalTaskService); }
Example #18
Source File: BatchMigrationHelper.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
public Batch migrateProcessInstancesAsync(int numberOfProcessInstances, ProcessDefinition sourceProcessDefinition, ProcessDefinition targetProcessDefinition) { RuntimeService runtimeService = engineRule.getRuntimeService(); List<String> processInstanceIds = new ArrayList<String>(numberOfProcessInstances); for (int i = 0; i < numberOfProcessInstances; i++) { processInstanceIds.add( runtimeService.startProcessInstanceById(sourceProcessDefinition.getId()).getId()); } MigrationPlan migrationPlan = engineRule.getRuntimeService() .createMigrationPlan(sourceProcessDefinition.getId(), targetProcessDefinition.getId()) .mapEqualActivities() .build(); return runtimeService.newMigration(migrationPlan).processInstanceIds(processInstanceIds).executeAsync(); }
Example #19
Source File: VariableInstanceQueryForOracleTest.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
@Test public void testQueryWhen2001InstancesActive() { // given Assume.assumeTrue(engineRule.getProcessEngineConfiguration().getDatabaseType().equals("oracle")); RuntimeService runtimeService = engineRule.getRuntimeService(); testRule.deploy(ProcessModels.TWO_TASKS_PROCESS); String[] ids = new String[2001]; // when for (int i = 0; i < 2001; i++) { ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("Process", Variables.createVariables().putValue("foo", "bar")); String activityInstanceId = runtimeService.getActivityInstance(processInstance.getId()).getId(); ids[i] = activityInstanceId; } // then List<VariableInstance> variables = engineRule.getRuntimeService().createVariableInstanceQuery() .activityInstanceIdIn(ids).list(); assertEquals(2001, variables.size()); }
Example #20
Source File: ModificationRestServiceInteractionTest.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
@Before public void setUpRuntimeData() { runtimeServiceMock = mock(RuntimeService.class); when(processEngine.getRuntimeService()).thenReturn(runtimeServiceMock); modificationBuilderMock = mock(ModificationBuilder.class); when(modificationBuilderMock.cancelAllForActivity(anyString())).thenReturn(modificationBuilderMock); when(modificationBuilderMock.startAfterActivity(anyString())).thenReturn(modificationBuilderMock); when(modificationBuilderMock.startBeforeActivity(anyString())).thenReturn(modificationBuilderMock); when(modificationBuilderMock.startTransition(anyString())).thenReturn(modificationBuilderMock); when(modificationBuilderMock.processInstanceIds(anyListOf(String.class))).thenReturn(modificationBuilderMock); Batch batchMock = createMockBatch(); when(modificationBuilderMock.executeAsync()).thenReturn(batchMock); when(runtimeServiceMock.createModification(anyString())).thenReturn(modificationBuilderMock); }
Example #21
Source File: MigrationIncidentTest.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
@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 #22
Source File: ExecutionResourceImpl.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
@Override public ExecutionDto getExecution() { RuntimeService runtimeService = engine.getRuntimeService(); Execution execution = runtimeService.createExecutionQuery().executionId(executionId).singleResult(); if (execution == null) { throw new InvalidRequestException(Status.NOT_FOUND, "Execution with id " + executionId + " does not exist"); } return ExecutionDto.fromExecution(execution); }
Example #23
Source File: MessageEventSubscriptionResource.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
@Override public EventSubscriptionDto getEventSubscription() { RuntimeService runtimeService = engine.getRuntimeService(); EventSubscription eventSubscription = runtimeService.createEventSubscriptionQuery() .executionId(executionId).eventName(messageName).eventType(MESSAGE_EVENT_TYPE).singleResult(); if (eventSubscription == null) { String errorMessage = String.format("Message event subscription for execution %s named %s does not exist", executionId, messageName); throw new InvalidRequestException(Status.NOT_FOUND, errorMessage); } return EventSubscriptionDto.fromEventSubscription(eventSubscription); }
Example #24
Source File: MyTaskFormHandler.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
public void submitFormVariables(VariableMap properties, VariableScope variableScope) { ProcessEngineConfigurationImpl processEngineConfiguration = Context.getProcessEngineConfiguration(); IdentityService identityService = processEngineConfiguration.getIdentityService(); RuntimeService runtimeService = processEngineConfiguration.getRuntimeService(); logAuthentication(identityService); logInstancesCount(runtimeService); }
Example #25
Source File: MyFormFieldValidator.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
public boolean validate(Object submittedValue, FormFieldValidatorContext validatorContext) { ProcessEngineConfigurationImpl processEngineConfiguration = Context.getProcessEngineConfiguration(); IdentityService identityService = processEngineConfiguration.getIdentityService(); RuntimeService runtimeService = processEngineConfiguration.getRuntimeService(); logAuthentication(identityService); logInstancesCount(runtimeService); return true; }
Example #26
Source File: TestBPMModule.java From Orienteer with Apache License 2.0 | 5 votes |
@Test @Deployment(resources = { "example-simple.bpmn" }) public void testEndProcessByCancelMessageSimple() { RuntimeService runtimeService = processEngineRule.getRuntimeService(); ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("Process_1"); assertProcessNotEnded(processInstance.getId()); runtimeService.createMessageCorrelation("Message-Approve").processInstanceId(processInstance.getId()) .correlate(); assertProcessEnded(processInstance.getId()); }
Example #27
Source File: AbstractEmptyBodyFilterTest.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
@Before public void setUpHttpClientAndRuntimeData() { client = HttpClients.createDefault(); reqConfig = RequestConfig.custom().setConnectTimeout(3 * 60 * 1000).setSocketTimeout(10 * 60 * 1000).build(); ProcessDefinition mockDefinition = MockProvider.createMockDefinition(); runtimeServiceMock = mock(RuntimeService.class); when(processEngine.getRuntimeService()).thenReturn(runtimeServiceMock); mockInstantiationBuilder = mock(ProcessInstantiationBuilder.class); when(mockInstantiationBuilder.setVariables(any(Map.class))).thenReturn(mockInstantiationBuilder); when(mockInstantiationBuilder.businessKey(anyString())).thenReturn(mockInstantiationBuilder); when(mockInstantiationBuilder.caseInstanceId(anyString())).thenReturn(mockInstantiationBuilder); when(runtimeServiceMock.createProcessInstanceById(anyString())).thenReturn(mockInstantiationBuilder); ProcessInstanceWithVariables resultInstanceWithVariables = MockProvider.createMockInstanceWithVariables(); when(mockInstantiationBuilder.executeWithVariablesInReturn(anyBoolean(), anyBoolean())).thenReturn(resultInstanceWithVariables); ProcessDefinitionQuery processDefinitionQueryMock = mock(ProcessDefinitionQuery.class); when(processDefinitionQueryMock.processDefinitionKey(MockProvider.EXAMPLE_PROCESS_DEFINITION_KEY)).thenReturn(processDefinitionQueryMock); when(processDefinitionQueryMock.withoutTenantId()).thenReturn(processDefinitionQueryMock); when(processDefinitionQueryMock.latestVersion()).thenReturn(processDefinitionQueryMock); when(processDefinitionQueryMock.singleResult()).thenReturn(mockDefinition); RepositoryService repositoryServiceMock = mock(RepositoryService.class); when(processEngine.getRepositoryService()).thenReturn(repositoryServiceMock); when(repositoryServiceMock.createProcessDefinitionQuery()).thenReturn(processDefinitionQueryMock); }
Example #28
Source File: BatchMigrationTest.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
@Test public void testBatchCreationWithProcessInstanceQuery() { RuntimeService runtimeService = engineRule.getRuntimeService(); int processInstanceCount = 15; ProcessDefinition sourceProcessDefinition = migrationRule.deployAndGetDefinition(ProcessModels.ONE_TASK_PROCESS); ProcessDefinition targetProcessDefinition = migrationRule.deployAndGetDefinition(ProcessModels.ONE_TASK_PROCESS); for (int i = 0; i < processInstanceCount; i++) { runtimeService.startProcessInstanceById(sourceProcessDefinition.getId()); } MigrationPlan migrationPlan = engineRule.getRuntimeService() .createMigrationPlan(sourceProcessDefinition.getId(), targetProcessDefinition.getId()) .mapEqualActivities() .build(); ProcessInstanceQuery sourceProcessInstanceQuery = runtimeService.createProcessInstanceQuery().processDefinitionId(sourceProcessDefinition.getId()); assertEquals(processInstanceCount, sourceProcessInstanceQuery.count()); // when Batch batch = runtimeService.newMigration(migrationPlan) .processInstanceQuery(sourceProcessInstanceQuery) .executeAsync(); // then a batch is created assertBatchCreated(batch, processInstanceCount); }
Example #29
Source File: BatchMigrationTest.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
@Test public void testBatchCreationWithOverlappingProcessInstanceIdsAndQuery() { RuntimeService runtimeService = engineRule.getRuntimeService(); int processInstanceCount = 15; ProcessDefinition sourceProcessDefinition = migrationRule.deployAndGetDefinition(ProcessModels.ONE_TASK_PROCESS); ProcessDefinition targetProcessDefinition = migrationRule.deployAndGetDefinition(ProcessModels.ONE_TASK_PROCESS); List<String> processInstanceIds = new ArrayList<String>(); for (int i = 0; i < processInstanceCount; i++) { processInstanceIds.add( runtimeService.startProcessInstanceById(sourceProcessDefinition.getId()).getId() ); } MigrationPlan migrationPlan = engineRule.getRuntimeService() .createMigrationPlan(sourceProcessDefinition.getId(), targetProcessDefinition.getId()) .mapEqualActivities() .build(); ProcessInstanceQuery sourceProcessInstanceQuery = runtimeService.createProcessInstanceQuery().processDefinitionId(sourceProcessDefinition.getId()); assertEquals(processInstanceCount, sourceProcessInstanceQuery.count()); // when Batch batch = runtimeService.newMigration(migrationPlan) .processInstanceIds(processInstanceIds) .processInstanceQuery(sourceProcessInstanceQuery) .executeAsync(); // then a batch is created assertBatchCreated(batch, processInstanceCount); }
Example #30
Source File: MigrationIncidentTest.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
@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()); }