Java Code Examples for org.flowable.engine.ProcessEngine#getTaskService()
The following examples show how to use
org.flowable.engine.ProcessEngine#getTaskService() .
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: SimpleSimulationRunTest.java From flowable-engine with Apache License 2.0 | 6 votes |
private void recordEvents() { Clock clock = new DefaultClockImpl(); clock.setCurrentTime(new Date(0)); ProcessEngineConfigurationImpl config = (ProcessEngineConfigurationImpl) ProcessEngineConfiguration.createProcessEngineConfigurationFromResourceDefault(); config.setClock(clock); ProcessEngine processEngine = (new RecordableProcessEngineFactory(config, listener)) .getObject(); processEngine.getRepositoryService().createDeployment().addClasspathResource(USERTASK_PROCESS).deploy(); EventRecorderTestUtils.increaseTime(clock); TaskService taskService = processEngine.getTaskService(); Map<String, Object> variables = new HashMap<>(); variables.put(TEST_VARIABLE, TEST_VALUE); processEngine.getRuntimeService().startProcessInstanceByKey("oneTaskProcess", "oneTaskProcessBusinessKey", variables); EventRecorderTestUtils.increaseTime(clock); Task task = taskService.createTaskQuery().taskDefinitionKey("userTask").singleResult(); taskService.complete(task.getId()); checkStatus(processEngine.getHistoryService()); EventRecorderTestUtils.closeProcessEngine(processEngine, listener); ProcessEngines.destroy(); }
Example 2
Source File: AbstractFlowableTestCase.java From flowable-engine with Apache License 2.0 | 5 votes |
@BeforeEach public final void initializeServices(ProcessEngine processEngine) { processEngineConfiguration = ((ProcessEngineImpl) processEngine).getProcessEngineConfiguration(); this.processEngine = processEngine; repositoryService = processEngine.getRepositoryService(); runtimeService = processEngine.getRuntimeService(); taskService = processEngine.getTaskService(); formService = processEngine.getFormService(); historyService = processEngine.getHistoryService(); identityService = processEngine.getIdentityService(); managementService = processEngine.getManagementService(); dynamicBpmnService = processEngine.getDynamicBpmnService(); processMigrationService = processEngine.getProcessMigrationService(); }
Example 3
Source File: FlowableJupiterTest.java From flowable-engine with Apache License 2.0 | 5 votes |
@Test @Deployment void extensionUsageExample(ProcessEngine processEngine) { RuntimeService runtimeService = processEngine.getRuntimeService(); runtimeService.startProcessInstanceByKey("extensionUsage"); TaskService taskService = processEngine.getTaskService(); org.flowable.task.api.Task task = taskService.createTaskQuery().singleResult(); assertThat(task.getName()).isEqualTo("My Task"); taskService.complete(task.getId()); assertThat(runtimeService.createProcessInstanceQuery().count()).isZero(); assertThat(processEngine.getName()).as("process engine name").isEqualTo(ProcessEngines.NAME_DEFAULT); }
Example 4
Source File: ProcessDefinitionCacheTest.java From flowable-engine with Apache License 2.0 | 4 votes |
public void testStartProcessInstanceByIdAfterReboot() { // In case this test is run in a test suite, previous engines might // have been initialized and cached. First we close the // existing process engines to make sure that the db is clean // and that there are no existing process engines involved. ProcessEngines.destroy(); // Creating the DB schema (without building a process engine) ProcessEngineConfigurationImpl processEngineConfiguration = new StandaloneInMemProcessEngineConfiguration(); processEngineConfiguration.setEngineName("reboot-test-schema"); processEngineConfiguration.setJdbcUrl("jdbc:h2:mem:activiti-reboot-test;DB_CLOSE_DELAY=1000"); processEngineConfiguration.setFlowable5CompatibilityEnabled(true); ProcessEngine schemaProcessEngine = processEngineConfiguration.buildProcessEngine(); // Create process engine and deploy test process StandaloneProcessEngineConfiguration standaloneProcessEngineConfiguration = new StandaloneProcessEngineConfiguration(); standaloneProcessEngineConfiguration.setEngineName("reboot-test"); standaloneProcessEngineConfiguration.setDatabaseSchemaUpdate(ProcessEngineConfiguration.DB_SCHEMA_UPDATE_FALSE); standaloneProcessEngineConfiguration.setJdbcUrl("jdbc:h2:mem:activiti-reboot-test;DB_CLOSE_DELAY=1000"); standaloneProcessEngineConfiguration.setAsyncExecutorActivate(false); standaloneProcessEngineConfiguration.setFlowable5CompatibilityEnabled(true); ProcessEngine processEngine = standaloneProcessEngineConfiguration.buildProcessEngine(); processEngine.getRepositoryService() .createDeployment() .deploymentProperty(DeploymentProperties.DEPLOY_AS_FLOWABLE5_PROCESS_DEFINITION, Boolean.TRUE) .addClasspathResource("org/activiti/engine/test/cache/originalProcess.bpmn20.xml") .deploy(); // verify existence of process definition List<ProcessDefinition> processDefinitions = processEngine .getRepositoryService() .createProcessDefinitionQuery() .list(); assertEquals(1, processDefinitions.size()); // Start a new Process instance ProcessInstance processInstance = processEngine.getRuntimeService().startProcessInstanceById(processDefinitions.get(0).getId()); String processInstanceId = processInstance.getId(); assertNotNull(processInstance); // Close the process engine processEngine.close(); assertNotNull(processEngine.getRuntimeService()); // Reboot the process engine standaloneProcessEngineConfiguration = new StandaloneProcessEngineConfiguration(); standaloneProcessEngineConfiguration.setEngineName("reboot-test"); standaloneProcessEngineConfiguration.setDatabaseSchemaUpdate(org.activiti.engine.ProcessEngineConfiguration.DB_SCHEMA_UPDATE_FALSE); standaloneProcessEngineConfiguration.setJdbcUrl("jdbc:h2:mem:activiti-reboot-test;DB_CLOSE_DELAY=1000"); standaloneProcessEngineConfiguration.setAsyncExecutorActivate(false); standaloneProcessEngineConfiguration.setFlowable5CompatibilityEnabled(true); processEngine = standaloneProcessEngineConfiguration.buildProcessEngine(); // Check if the existing process instance is still alive processInstance = processEngine .getRuntimeService() .createProcessInstanceQuery() .processInstanceId(processInstanceId) .singleResult(); assertNotNull(processInstance); // Complete the task. That will end the process instance TaskService taskService = processEngine.getTaskService(); org.flowable.task.api.Task task = taskService .createTaskQuery() .list() .get(0); taskService.complete(task.getId()); // Check if the process instance has really ended. This means that the process definition has // re-loaded into the process definition cache processInstance = processEngine .getRuntimeService() .createProcessInstanceQuery() .processInstanceId(processInstanceId) .singleResult(); assertNull(processInstance); // Extra check to see if a new process instance can be started as well processInstance = processEngine.getRuntimeService().startProcessInstanceById(processDefinitions.get(0).getId()); assertNotNull(processInstance); // close the process engine processEngine.close(); // Cleanup schema schemaProcessEngine.close(); }
Example 5
Source File: ProcessDefinitionCacheTest.java From flowable-engine with Apache License 2.0 | 4 votes |
public void testDeployRevisedProcessAfterDeleteOnOtherProcessEngine() { // Setup both process engines StandaloneProcessEngineConfiguration standaloneProcessEngineConfiguration = new StandaloneProcessEngineConfiguration(); standaloneProcessEngineConfiguration.setEngineName("reboot-test-schema"); standaloneProcessEngineConfiguration.setDatabaseSchemaUpdate(org.activiti.engine.ProcessEngineConfiguration.DB_SCHEMA_UPDATE_TRUE); standaloneProcessEngineConfiguration.setJdbcUrl("jdbc:h2:mem:activiti-process-cache-test;DB_CLOSE_DELAY=1000"); standaloneProcessEngineConfiguration.setAsyncExecutorActivate(false); standaloneProcessEngineConfiguration.setFlowable5CompatibilityEnabled(true); ProcessEngine processEngine1 = standaloneProcessEngineConfiguration.buildProcessEngine(); RepositoryService repositoryService1 = processEngine1.getRepositoryService(); StandaloneProcessEngineConfiguration standaloneProcessEngineConfiguration2 = new StandaloneProcessEngineConfiguration(); standaloneProcessEngineConfiguration2.setEngineName("reboot-test"); standaloneProcessEngineConfiguration2.setDatabaseSchemaUpdate(org.activiti.engine.ProcessEngineConfiguration.DB_SCHEMA_UPDATE_FALSE); standaloneProcessEngineConfiguration2.setJdbcUrl("jdbc:h2:mem:activiti-process-cache-test;DB_CLOSE_DELAY=1000"); standaloneProcessEngineConfiguration2.setAsyncExecutorActivate(false); standaloneProcessEngineConfiguration2.setFlowable5CompatibilityEnabled(true); ProcessEngine processEngine2 = standaloneProcessEngineConfiguration2.buildProcessEngine(); RepositoryService repositoryService2 = processEngine2.getRepositoryService(); RuntimeService runtimeService2 = processEngine2.getRuntimeService(); TaskService taskService2 = processEngine2.getTaskService(); // Deploy first version of process: start->originalTask->end on first process engine String deploymentId = repositoryService1.createDeployment() .addClasspathResource("org/activiti/engine/test/cache/originalProcess.bpmn20.xml") .deploymentProperty(DeploymentProperties.DEPLOY_AS_FLOWABLE5_PROCESS_DEFINITION, Boolean.TRUE) .deploy() .getId(); // Start process instance on second engine String processDefinitionId = repositoryService2.createProcessDefinitionQuery().singleResult().getId(); runtimeService2.startProcessInstanceById(processDefinitionId); org.flowable.task.api.Task task = taskService2.createTaskQuery().singleResult(); assertEquals("original task", task.getName()); // Delete the deployment on second process engine repositoryService2.deleteDeployment(deploymentId, true); assertEquals(0, repositoryService2.createDeploymentQuery().count()); assertEquals(0, runtimeService2.createProcessInstanceQuery().count()); // deploy a revised version of the process: start->revisedTask->end on first process engine // // Before the bugfix, this would set the cache on the first process engine, // but the second process engine still has the original process definition in his cache. // Since there is a deployment delete in between, the new generated process definition id is the same // as in the original deployment, making the second process engine using the old cached process definition. deploymentId = repositoryService1.createDeployment() .addClasspathResource("org/activiti/engine/test/cache/revisedProcess.bpmn20.xml") .deploymentProperty(DeploymentProperties.DEPLOY_AS_FLOWABLE5_PROCESS_DEFINITION, Boolean.TRUE) .deploy() .getId(); // Start process instance on second process engine -> must use revised process definition repositoryService2.createProcessDefinitionQuery().singleResult().getId(); runtimeService2.startProcessInstanceByKey("oneTaskProcess"); task = taskService2.createTaskQuery().singleResult(); assertEquals("revised task", task.getName()); // cleanup repositoryService1.deleteDeployment(deploymentId, true); processEngine1.close(); processEngine2.close(); }
Example 6
Source File: ProcessEngineServicesAutoConfiguration.java From flowable-engine with Apache License 2.0 | 4 votes |
@Bean @ConditionalOnMissingBean public TaskService taskServiceBean(ProcessEngine processEngine) { return processEngine.getTaskService(); }
Example 7
Source File: JPAFlowableEngineConfiguration.java From flowable-engine with Apache License 2.0 | 4 votes |
@Bean public TaskService taskService(ProcessEngine processEngine) { return processEngine.getTaskService(); }
Example 8
Source File: EngineConfiguration.java From flowable-engine with Apache License 2.0 | 4 votes |
@Bean public TaskService taskService(ProcessEngine processEngine) { return processEngine.getTaskService(); }
Example 9
Source File: SpringTransactionAndExceptionsTest.java From flowable-engine with Apache License 2.0 | 4 votes |
@Bean public TaskService taskService(ProcessEngine processEngine) { return processEngine.getTaskService(); }
Example 10
Source File: SpringJunitJupiterTest.java From flowable-engine with Apache License 2.0 | 4 votes |
@Bean public TaskService taskService(ProcessEngine processEngine) { return processEngine.getTaskService(); }
Example 11
Source File: ProcessDefinitionCacheTest.java From flowable-engine with Apache License 2.0 | 4 votes |
@Test public void testStartProcessInstanceByIdAfterReboot() { // In case this test is run in a test suite, previous engines might have been initialized and cached. First we close the // existing process engines to make sure that the db is clean and that there are no existing process engines involved. ProcessEngines.destroy(); // Creating the DB schema (without building a process engine) ProcessEngineConfigurationImpl processEngineConfiguration = new StandaloneInMemProcessEngineConfiguration(); processEngineConfiguration.setEngineName("reboot-test-schema"); processEngineConfiguration.setJdbcUrl("jdbc:h2:mem:activiti-reboot-test;DB_CLOSE_DELAY=1000"); ProcessEngine schemaProcessEngine = processEngineConfiguration.buildProcessEngine(); // Create process engine and deploy test process ProcessEngine processEngine = new StandaloneProcessEngineConfiguration().setEngineName("reboot-test").setDatabaseSchemaUpdate(ProcessEngineConfiguration.DB_SCHEMA_UPDATE_FALSE) .setJdbcUrl("jdbc:h2:mem:activiti-reboot-test;DB_CLOSE_DELAY=1000").setAsyncExecutorActivate(false).buildProcessEngine(); processEngine.getRepositoryService().createDeployment().addClasspathResource("org/flowable/engine/test/cache/originalProcess.bpmn20.xml").deploy(); // verify existence of process definition List<ProcessDefinition> processDefinitions = processEngine.getRepositoryService().createProcessDefinitionQuery().list(); assertEquals(1, processDefinitions.size()); // Start a new Process instance ProcessInstance processInstance = processEngine.getRuntimeService().startProcessInstanceById(processDefinitions.get(0).getId()); String processInstanceId = processInstance.getId(); assertNotNull(processInstance); // Close the process engine processEngine.close(); assertNotNull(processEngine.getRuntimeService()); // Reboot the process engine processEngine = new StandaloneProcessEngineConfiguration().setEngineName("reboot-test").setDatabaseSchemaUpdate(org.flowable.engine.ProcessEngineConfiguration.DB_SCHEMA_UPDATE_FALSE) .setJdbcUrl("jdbc:h2:mem:activiti-reboot-test;DB_CLOSE_DELAY=1000").setAsyncExecutorActivate(false).buildProcessEngine(); // Check if the existing process instance is still alive processInstance = processEngine.getRuntimeService().createProcessInstanceQuery().processInstanceId(processInstanceId).singleResult(); assertNotNull(processInstance); // Complete the task. That will end the process instance TaskService taskService = processEngine.getTaskService(); org.flowable.task.api.Task task = taskService.createTaskQuery().list().get(0); taskService.complete(task.getId()); // Check if the process instance has really ended. This means that the // process definition has re-loaded into the process definition cache processInstance = processEngine.getRuntimeService().createProcessInstanceQuery().processInstanceId(processInstanceId).singleResult(); assertNull(processInstance); // Extra check to see if a new process instance can be started as well processInstance = processEngine.getRuntimeService().startProcessInstanceById(processDefinitions.get(0).getId()); assertNotNull(processInstance); // close the process engine processEngine.close(); // Cleanup schema schemaProcessEngine.close(); }
Example 12
Source File: ProcessDefinitionCacheTest.java From flowable-engine with Apache License 2.0 | 4 votes |
@Test public void testDeployRevisedProcessAfterDeleteOnOtherProcessEngine() { // Setup both process engines ProcessEngine processEngine1 = new StandaloneProcessEngineConfiguration().setEngineName("reboot-test-schema") .setDatabaseSchemaUpdate(org.flowable.engine.ProcessEngineConfiguration.DB_SCHEMA_UPDATE_TRUE).setJdbcUrl("jdbc:h2:mem:activiti-process-cache-test;DB_CLOSE_DELAY=1000") .setAsyncExecutorActivate(false).buildProcessEngine(); RepositoryService repositoryService1 = processEngine1.getRepositoryService(); ProcessEngine processEngine2 = new StandaloneProcessEngineConfiguration().setEngineName("reboot-test") .setDatabaseSchemaUpdate(org.flowable.engine.ProcessEngineConfiguration.DB_SCHEMA_UPDATE_FALSE).setJdbcUrl("jdbc:h2:mem:activiti-process-cache-test;DB_CLOSE_DELAY=1000") .setAsyncExecutorActivate(false).buildProcessEngine(); RepositoryService repositoryService2 = processEngine2.getRepositoryService(); RuntimeService runtimeService2 = processEngine2.getRuntimeService(); TaskService taskService2 = processEngine2.getTaskService(); // Deploy first version of process: start->originalTask->end on first // process engine String deploymentId = repositoryService1.createDeployment().addClasspathResource("org/flowable/engine/test/cache/originalProcess.bpmn20.xml").deploy().getId(); // Start process instance on second engine String processDefinitionId = repositoryService2.createProcessDefinitionQuery().singleResult().getId(); runtimeService2.startProcessInstanceById(processDefinitionId); org.flowable.task.api.Task task = taskService2.createTaskQuery().singleResult(); assertEquals("original task", task.getName()); // Delete the deployment on second process engine repositoryService2.deleteDeployment(deploymentId, true); assertEquals(0, repositoryService2.createDeploymentQuery().count()); assertEquals(0, runtimeService2.createProcessInstanceQuery().count()); // deploy a revised version of the process: start->revisedTask->end on first process engine // // Before the bugfix, this would set the cache on the first process // engine, but the second process engine still has the original process // definition in his cache. Since there is a deployment delete in between, the new generated // process definition id is the same as in the original deployment, making the second process engine using // the old cached process definition. deploymentId = repositoryService1.createDeployment().addClasspathResource("org/flowable/engine/test/cache/revisedProcess.bpmn20.xml").deploy().getId(); // Start process instance on second process engine -> must use revised process definition repositoryService2.createProcessDefinitionQuery().singleResult().getId(); runtimeService2.startProcessInstanceByKey("oneTaskProcess"); task = taskService2.createTaskQuery().singleResult(); assertEquals("revised task", task.getName()); // cleanup repositoryService1.deleteDeployment(deploymentId, true); processEngine1.close(); processEngine2.close(); }
Example 13
Source File: BpmnEngineTestConfiguration.java From flowable-engine with Apache License 2.0 | 4 votes |
@Bean public TaskService taskService(ProcessEngine processEngine) { return processEngine.getTaskService(); }
Example 14
Source File: EngineConfiguration.java From flowable-engine with Apache License 2.0 | 4 votes |
@Bean public TaskService taskService(ProcessEngine processEngine) { return processEngine.getTaskService(); }