org.flowable.engine.RuntimeService Java Examples
The following examples show how to use
org.flowable.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: MuleVMTest.java From flowable-engine with Apache License 2.0 | 6 votes |
@Test public void send() throws Exception { Assert.assertTrue(muleContext.isStarted()); ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine(); RepositoryService repositoryService = processEngine.getRepositoryService(); Deployment deployment = repositoryService.createDeployment() .addClasspathResource("org/activiti/mule/testVM.bpmn20.xml") .deploymentProperty(DeploymentProperties.DEPLOY_AS_FLOWABLE5_PROCESS_DEFINITION, Boolean.TRUE) .deploy(); RuntimeService runtimeService = processEngine.getRuntimeService(); ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("muleProcess"); Assert.assertFalse(processInstance.isEnded()); Object result = runtimeService.getVariable(processInstance.getProcessInstanceId(), "theVariable"); Assert.assertEquals(30, result); runtimeService.deleteProcessInstance(processInstance.getId(), "test"); processEngine.getHistoryService().deleteHistoricProcessInstance(processInstance.getId()); repositoryService.deleteDeployment(deployment.getId()); assertAndEnsureCleanDb(processEngine); ProcessEngines.destroy(); }
Example #2
Source File: ProcessWithFormTest.java From flowable-engine with Apache License 2.0 | 6 votes |
@Test public void completeTaskWithoutValidationOnConfiguration(ProcessEngineConfiguration processEngineConfiguration, RuntimeService runtimeService, TaskService taskService) { ((ProcessEngineConfigurationImpl) processEngineConfiguration).setFormFieldValidationEnabled(false); try { ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("oneTaskWithFormSideEffectProcess"); assertThat(SideEffectExecutionListener.getSideEffect()).isEqualTo(1); SideEffectExecutionListener.reset(); Task task = taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult(); FormRepositoryService formRepositoryService = FormEngines.getDefaultFormEngine().getFormRepositoryService(); FormDefinition formDefinition = formRepositoryService.createFormDefinitionQuery().formDefinitionKey("form1").singleResult(); taskService.completeTaskWithForm(task.getId(), formDefinition.getId(), "__COMPLETE", Collections.singletonMap("initiator", "someInitiator")); assertThat(SideEffectExecutionListener.getSideEffect()).isEqualTo(1); } finally { ((ProcessEngineConfigurationImpl) processEngineConfiguration).setFormFieldValidationEnabled(true); } }
Example #3
Source File: ProcessWithFormTest.java From flowable-engine with Apache License 2.0 | 6 votes |
@Test public void completeTaskWithoutValidationOnModelLevel(RuntimeService runtimeService, TaskService taskService, RepositoryService repositoryService) { Deployment deployment = repositoryService.createDeployment(). addString("oneTaskWithFormKeySideEffectProcess.bpmn20.xml", ONE_TASK_PROCESS. replace("START_EVENT_VALIDATION", "false"). replace("USER_TASK_VALIDATION", "false") ). deploy(); ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().deploymentId(deployment.getId()).singleResult(); ProcessInstance processInstance = runtimeService.startProcessInstanceWithForm(processDefinition.getId(),"__COMPLETE", Collections.emptyMap(), "oneTaskWithFormSideEffectProcess"); assertThat(SideEffectExecutionListener.getSideEffect()).isEqualTo(1); SideEffectExecutionListener.reset(); Task task = taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult(); FormRepositoryService formRepositoryService = FormEngines.getDefaultFormEngine().getFormRepositoryService(); FormDefinition formDefinition = formRepositoryService.createFormDefinitionQuery().formDefinitionKey("form1").singleResult(); taskService.completeTaskWithForm(task.getId(), formDefinition.getId(), "__COMPLETE", Collections.singletonMap("initiator", "someInitiator")); assertThat(SideEffectExecutionListener.getSideEffect()).isEqualTo(1); }
Example #4
Source File: DeployAppSubProcessEndListener.java From multiapps-controller with Apache License 2.0 | 6 votes |
private void setVariableInParentProcess(DelegateExecution execution, String variablePrefix, Object variableValue) { CloudApplicationExtended cloudApplication = VariableHandling.get(execution, Variables.APP_TO_PROCESS); if (cloudApplication == null) { throw new IllegalStateException(Messages.CANNOT_DETERMINE_CURRENT_APPLICATION); } String moduleName = cloudApplication.getModuleName(); if (moduleName == null) { throw new IllegalStateException(Messages.CANNOT_DETERMINE_MODULE_NAME); } String exportedVariableName = variablePrefix + moduleName; RuntimeService runtimeService = Context.getProcessEngineConfiguration() .getRuntimeService(); String superExecutionId = execution.getParentId(); Execution superExecutionResult = runtimeService.createExecutionQuery() .executionId(superExecutionId) .singleResult(); superExecutionId = superExecutionResult.getSuperExecutionId(); byte[] binaryJson = variableValue == null ? null : JsonUtil.toJsonBinary(variableValue); runtimeService.setVariable(superExecutionId, exportedVariableName, binaryJson); }
Example #5
Source File: CreateOrUpdateServiceEndListener.java From multiapps-controller with Apache License 2.0 | 6 votes |
@Override public void notify(DelegateExecution execution) { boolean isServiceUpdated = VariableHandling.get(execution, Variables.IS_SERVICE_UPDATED); String serviceName = VariableHandling.get(execution, Variables.SERVICE_TO_PROCESS_NAME); if (serviceName == null) { throw new IllegalStateException("Unable to determine service update status."); } String exportedVariableName = Constants.VAR_IS_SERVICE_UPDATED_VAR_PREFIX + serviceName; RuntimeService runtimeService = Context.getProcessEngineConfiguration() .getRuntimeService(); String superExecutionId = execution.getParentId(); Execution superExecutionResult = runtimeService.createExecutionQuery() .executionId(superExecutionId) .singleResult(); superExecutionId = superExecutionResult.getSuperExecutionId(); runtimeService.setVariable(superExecutionId, exportedVariableName, isServiceUpdated); }
Example #6
Source File: ProcessInstanceBuilderFormTest.java From flowable-engine with Apache License 2.0 | 6 votes |
@Test @Deployment(resources = { "org/flowable/form/engine/test/deployment/oneTaskProcess.bpmn20.xml", "org/flowable/form/engine/test/deployment/simpleInt.form" }) public void startProcessInstanceWithFormVariables() { RuntimeService runtimeService = flowableRule.getProcessEngine().getRuntimeService(); FormInfo formInfo = formRepositoryService.getFormModelByKey("simpleIntForm"); String procId = runtimeService.createProcessInstanceBuilder() .processDefinitionKey("oneTaskProcess") .formVariables(Collections.singletonMap("intVar", "42"), formInfo, "simple") .start() .getId(); assertThat(runtimeService.getVariables(procId)) .containsOnly( entry("intVar", 42L), entry("form_simpleIntForm_outcome", "simple") ); }
Example #7
Source File: FlowableRuleJunit4Test.java From flowable-engine with Apache License 2.0 | 6 votes |
@Test @Deployment(resources = { "org/flowable/engine/test/bpmn/async/AsyncTaskTest.testAsyncTask.bpmn20.xml" }) public void testWaitForJobs() { RuntimeService runtimeService = activitiRule.getRuntimeService(); ManagementService managementService = activitiRule.getManagementService(); // start process runtimeService.startProcessInstanceByKey("asyncTask"); // now there should be one job in the database: assertThat(managementService.createJobQuery().count()).isEqualTo(1); JobTestHelper.waitForJobExecutorToProcessAllJobs(activitiRule, 7000L, 500L); // the job is done assertThat(managementService.createJobQuery().count()).isZero(); }
Example #8
Source File: ActivitiRuleJunit4Test.java From flowable-engine with Apache License 2.0 | 6 votes |
@Test @Deployment(resources = { "org/activiti/engine/test/bpmn/async/AsyncTaskTest.testAsyncTask.bpmn20.xml" }) public void testWaitForJobs() { RuntimeService runtimeService = activitiRule.getRuntimeService(); ManagementService managementService = activitiRule.getManagementService(); // start process runtimeService.startProcessInstanceByKey("asyncTask"); // now there should be one job in the database: assertEquals(1, managementService.createJobQuery().count()); JobTestHelper.waitForJobExecutorToProcessAllJobs(activitiRule, 7000L, 500L); // the job is done assertEquals(0, managementService.createJobQuery().count()); }
Example #9
Source File: MuleVMTest.java From flowable-engine with Apache License 2.0 | 6 votes |
@Test public void send() throws Exception { Assert.assertTrue(muleContext.isStarted()); ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine(); RepositoryService repositoryService = processEngine.getRepositoryService(); Deployment deployment = repositoryService.createDeployment().addClasspathResource("org/flowable/mule/testVM.bpmn20.xml").deploy(); RuntimeService runtimeService = processEngine.getRuntimeService(); ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("muleProcess"); Assert.assertFalse(processInstance.isEnded()); Object result = runtimeService.getVariable(processInstance.getProcessInstanceId(), "theVariable"); Assert.assertEquals(30, result); runtimeService.deleteProcessInstance(processInstance.getId(), "test"); processEngine.getHistoryService().deleteHistoricProcessInstance(processInstance.getId()); repositoryService.deleteDeployment(deployment.getId()); assertAndEnsureCleanDb(processEngine); ProcessEngines.destroy(); }
Example #10
Source File: MuleHttpBasicAuthTest.java From flowable-engine with Apache License 2.0 | 6 votes |
@Test public void httpWithBasicAuth() throws Exception { Assert.assertTrue(muleContext.isStarted()); ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine(); Deployment deployment = processEngine.getRepositoryService().createDeployment().addClasspathResource("org/flowable/mule/testHttpBasicAuth.bpmn20.xml").deploy(); RuntimeService runtimeService = processEngine.getRuntimeService(); ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("muleProcess"); Assert.assertFalse(processInstance.isEnded()); Object result = runtimeService.getVariable(processInstance.getProcessInstanceId(), "theVariable"); Assert.assertEquals(10, result); runtimeService.deleteProcessInstance(processInstance.getId(), "test"); processEngine.getHistoryService().deleteHistoricProcessInstance(processInstance.getId()); processEngine.getRepositoryService().deleteDeployment(deployment.getId()); assertAndEnsureCleanDb(processEngine); ProcessEngines.destroy(); }
Example #11
Source File: Application.java From flowable-engine with Apache License 2.0 | 6 votes |
@Bean CommandLineRunner init( final AnalysingService analysingService, final RuntimeService runtimeService) { return new CommandLineRunner() { @Override public void run(String... strings) throws Exception { String integrationGatewayProcess = "integrationGatewayProcess"; runtimeService.startProcessInstanceByKey( integrationGatewayProcess, Collections.singletonMap("customerId", (Object) 232L)); System.out.println("projectId=" + analysingService.getStringAtomicReference().get()); } }; }
Example #12
Source File: IntegrationAutoConfigurationTest.java From flowable-engine with Apache License 2.0 | 6 votes |
@Test public void testLaunchingGatewayProcessDefinition() throws Exception { RepositoryService repositoryService = applicationContext.getBean(RepositoryService.class); RuntimeService runtimeService = applicationContext.getBean(RuntimeService.class); ProcessEngine processEngine = applicationContext.getBean(ProcessEngine.class); assertThat(processEngine).as("the process engine should not be null").isNotNull(); assertThat(repositoryService).as("we should have a default repositoryService included").isNotNull(); String integrationGatewayProcess = "integrationGatewayProcess"; List<ProcessDefinition> processDefinitionList = repositoryService.createProcessDefinitionQuery() .processDefinitionKey(integrationGatewayProcess) .list(); ProcessDefinition processDefinition = processDefinitionList.iterator().next(); assertThat(processDefinition.getKey()).isEqualTo(integrationGatewayProcess); Map<String, Object> vars = new HashMap<>(); vars.put("customerId", 232); ProcessInstance processInstance = runtimeService.startProcessInstanceByKey(integrationGatewayProcess, vars); assertThat(processInstance).as("the processInstance should not be null").isNotNull(); assertThat(applicationContext.getBean(Application.AnalysingService.class) .getStringAtomicReference().get()).isEqualTo(projectId); }
Example #13
Source File: MuleHttpTest.java From flowable-engine with Apache License 2.0 | 6 votes |
@Test public void http() throws Exception { Assert.assertTrue(muleContext.isStarted()); ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine(); Deployment deployment = processEngine.getRepositoryService().createDeployment().addClasspathResource("org/flowable/mule/testHttp.bpmn20.xml").deploy(); RuntimeService runtimeService = processEngine.getRuntimeService(); ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("muleProcess"); Assert.assertFalse(processInstance.isEnded()); Object result = runtimeService.getVariable(processInstance.getProcessInstanceId(), "theVariable"); Assert.assertEquals(20, result); runtimeService.deleteProcessInstance(processInstance.getId(), "test"); processEngine.getHistoryService().deleteHistoricProcessInstance(processInstance.getId()); processEngine.getRepositoryService().deleteDeployment(deployment.getId()); assertAndEnsureCleanDb(processEngine); ProcessEngines.destroy(); }
Example #14
Source File: MuleHttpTest.java From flowable-engine with Apache License 2.0 | 6 votes |
@Test public void http() throws Exception { Assert.assertTrue(muleContext.isStarted()); ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine(); Deployment deployment = processEngine.getRepositoryService().createDeployment() .addClasspathResource("org/activiti/mule/testHttp.bpmn20.xml") .deploymentProperty(DeploymentProperties.DEPLOY_AS_FLOWABLE5_PROCESS_DEFINITION, Boolean.TRUE) .deploy(); RuntimeService runtimeService = processEngine.getRuntimeService(); ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("muleProcess"); Assert.assertFalse(processInstance.isEnded()); Object result = runtimeService.getVariable(processInstance.getProcessInstanceId(), "theVariable"); Assert.assertEquals(20, result); runtimeService.deleteProcessInstance(processInstance.getId(), "test"); processEngine.getHistoryService().deleteHistoricProcessInstance(processInstance.getId()); processEngine.getRepositoryService().deleteDeployment(deployment.getId()); assertAndEnsureCleanDb(processEngine); ProcessEngines.destroy(); }
Example #15
Source File: MuleHttpBasicAuthTest.java From flowable-engine with Apache License 2.0 | 6 votes |
@Test public void httpWithBasicAuth() throws Exception { Assert.assertTrue(muleContext.isStarted()); ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine(); Deployment deployment = processEngine.getRepositoryService() .createDeployment() .addClasspathResource("org/activiti/mule/testHttpBasicAuth.bpmn20.xml") .deploymentProperty(DeploymentProperties.DEPLOY_AS_FLOWABLE5_PROCESS_DEFINITION, Boolean.TRUE) .deploy(); RuntimeService runtimeService = processEngine.getRuntimeService(); ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("muleProcess"); Assert.assertFalse(processInstance.isEnded()); Object result = runtimeService.getVariable(processInstance.getProcessInstanceId(), "theVariable"); Assert.assertEquals(10, result); runtimeService.deleteProcessInstance(processInstance.getId(), "test"); processEngine.getHistoryService().deleteHistoricProcessInstance(processInstance.getId()); processEngine.getRepositoryService().deleteDeployment(deployment.getId()); assertAndEnsureCleanDb(processEngine); ProcessEngines.destroy(); }
Example #16
Source File: HistoryServiceTaskLogTest.java From flowable-engine with Apache License 2.0 | 5 votes |
@Test @Deployment(resources = { "org/flowable/engine/test/api/runtime/oneTaskProcess.bpmn20.xml" }) public void logDeleteCandidateUser(RuntimeService runtimeService, TaskService taskService, HistoryService historyService, ManagementService managementService, ProcessEngineConfiguration processEngineConfiguration) { ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("oneTaskProcess"); Task task = taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult(); assertThat(processInstance).isNotNull(); assertThat(task).isNotNull(); taskService.addCandidateUser(task.getId(), "newCandidateUser"); try { taskService.deleteCandidateUser(task.getId(), "newCandidateUser"); if (HistoryTestHelper.isHistoricTaskLoggingEnabled(processEngineConfiguration)) { List<HistoricTaskLogEntry> logEntries = historyService.createHistoricTaskLogEntryQuery().taskId(task.getId()).list(); assertThat(logEntries).hasSize(3); logEntries = historyService.createHistoricTaskLogEntryQuery().taskId(task.getId()) .type("USER_TASK_IDENTITY_LINK_REMOVED") .list(); assertThat(logEntries).hasSize(1); assertThat(logEntries.get(0).getData()).contains( "\"type\":\"candidate\"", "\"userId\":\"newCandidateUser\"" ); } } finally { taskService.complete(task.getId()); deleteTaskWithLogEntries(taskService, managementService, processEngineConfiguration, task.getId()); } }
Example #17
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 #18
Source File: FlowableJupiterTest.java From flowable-engine with Apache License 2.0 | 5 votes |
@Test @Deployment(resources = { "org/flowable/engine/test/bpmn/async/AsyncTaskTest.testAsyncTask.bpmn20.xml" }) void testWaitForJobs(FlowableTestHelper testHelper, RuntimeService runtimeService, ManagementService managementService) { // start process runtimeService.startProcessInstanceByKey("asyncTask"); // now there should be one job in the database: assertThat(managementService.createJobQuery().count()).isEqualTo(1); testHelper.waitForJobExecutorToProcessAllJobs(7000L, 500L); // the job is done assertThat(managementService.createJobQuery().count()).isZero(); }
Example #19
Source File: FlowableRuleJunit4Test.java From flowable-engine with Apache License 2.0 | 5 votes |
@Test @Deployment public void ruleUsageExample() { RuntimeService runtimeService = activitiRule.getRuntimeService(); runtimeService.startProcessInstanceByKey("ruleUsage"); TaskService taskService = activitiRule.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(); }
Example #20
Source File: ProcessWithFormTest.java From flowable-engine with Apache License 2.0 | 5 votes |
@Test public void startProcessWithFormWithoutValidationOnConfiguration(ProcessEngineConfiguration processEngineConfiguration, RuntimeService runtimeService, RepositoryService repositoryService) { ((ProcessEngineConfigurationImpl) processEngineConfiguration).setFormFieldValidationEnabled(false); try { ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().processDefinitionKey("oneTaskWithFormSideEffectProcess") .singleResult(); ProcessInstance processInstance = runtimeService .startProcessInstanceWithForm(processDefinition.getId(), "COMPLETE", Collections.singletonMap("name", "nameValue"), "test"); assertThat(processInstance).isNotNull(); assertThat(SideEffectExecutionListener.getSideEffect()).isEqualTo(1); } finally { ((ProcessEngineConfigurationImpl) processEngineConfiguration).setFormFieldValidationEnabled(true); } }
Example #21
Source File: ProcessWithFormTest.java From flowable-engine with Apache License 2.0 | 5 votes |
@Test public void throwExceptionValidationOnStartProcess(RuntimeService runtimeService, RepositoryService repositoryService) { ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().processDefinitionKey("oneTaskWithFormSideEffectProcess") .singleResult(); assertThatThrownBy(() -> runtimeService.startProcessInstanceWithForm(processDefinition.getId(), "COMPLETE", Collections.singletonMap("name", "nameValue"), "test")) .isInstanceOf(RuntimeException.class) .hasMessageContaining("validation failed"); assertThat(SideEffectExecutionListener.getSideEffect()).isZero(); }
Example #22
Source File: HistoryServiceTaskLogTest.java From flowable-engine with Apache License 2.0 | 5 votes |
@Test @Deployment(resources = { "org/flowable/engine/test/api/runtime/oneTaskProcess.bpmn20.xml" }) public void logAddGroup(RuntimeService runtimeService, TaskService taskService, HistoryService historyService, ManagementService managementService, ProcessEngineConfiguration processEngineConfiguration) { ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("oneTaskProcess"); assertThat(processInstance).isNotNull(); Task task = taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult(); assertThat(task).isNotNull(); try { taskService.addGroupIdentityLink(task.getId(), "newCandidateGroup", IdentityLinkType.PARTICIPANT); if (HistoryTestHelper.isHistoricTaskLoggingEnabled(processEngineConfiguration)) { List<HistoricTaskLogEntry> logEntries = historyService.createHistoricTaskLogEntryQuery().taskId(task.getId()).list(); assertThat(logEntries).hasSize(2); logEntries = historyService.createHistoricTaskLogEntryQuery().taskId(task.getId()) .type("USER_TASK_IDENTITY_LINK_ADDED") .list(); assertThat(logEntries).hasSize(1); assertThat(logEntries.get(0).getData()).contains( "\"type\":\"participant\"", "\"groupId\":\"newCandidateGroup\"" ); } } finally { taskService.complete(task.getId()); deleteTaskWithLogEntries(taskService, managementService, processEngineConfiguration, task.getId()); } }
Example #23
Source File: BpmnEventRegistryEventConsumer.java From flowable-engine with Apache License 2.0 | 5 votes |
@Override protected void eventReceived(EventInstance eventInstance) { // Fetching the event subscriptions happens in one transaction, // executing them one per subscription. There is no overarching transaction. // The reason for this is that the handling of one event subscription // should not influence (i.e. roll back) the handling of another. Collection<CorrelationKey> correlationKeys = generateCorrelationKeys(eventInstance.getCorrelationParameterInstances()); List<EventSubscription> eventSubscriptions = findEventSubscriptions(ScopeTypes.BPMN, eventInstance, correlationKeys); RuntimeService runtimeService = processEngineConfiguration.getRuntimeService(); for (EventSubscription eventSubscription : eventSubscriptions) { handleEventSubscription(runtimeService, eventSubscription, eventInstance, correlationKeys); } }
Example #24
Source File: ProcessWithFormTest.java From flowable-engine with Apache License 2.0 | 5 votes |
@Test public void throwExceptionValidationOnStartProcessWithoutVariables(RuntimeService runtimeService, RepositoryService repositoryService) { ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().processDefinitionKey("oneTaskWithFormSideEffectProcess") .singleResult(); assertThatThrownBy(() -> runtimeService.startProcessInstanceWithForm(processDefinition.getId(), "COMPLETE", null, "test")) .isInstanceOf(RuntimeException.class) .hasMessageContaining("validation failed"); assertThat(SideEffectExecutionListener.getSideEffect()).isZero(); }
Example #25
Source File: ProcessWithFormTest.java From flowable-engine with Apache License 2.0 | 5 votes |
@Test public void throwExceptionValidationOnCompleteTask(RuntimeService runtimeService, TaskService taskService) { ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("oneTaskWithFormSideEffectProcess"); assertThat(SideEffectExecutionListener.getSideEffect()).isEqualTo(1); SideEffectExecutionListener.reset(); Task task = taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult(); FormRepositoryService formRepositoryService = FormEngines.getDefaultFormEngine().getFormRepositoryService(); FormDefinition formDefinition = formRepositoryService.createFormDefinitionQuery().formDefinitionKey("form1").singleResult(); assertThatThrownBy(() -> taskService.completeTaskWithForm(task.getId(), formDefinition.getId(), "__COMPLETE", Collections.emptyMap())) .isInstanceOf(FlowableException.class); assertThat(SideEffectExecutionListener.getSideEffect()).isZero(); }
Example #26
Source File: ProcessWithFormTest.java From flowable-engine with Apache License 2.0 | 5 votes |
@Test public void completeTaskWithoutValidationOnModelLevelExpression(ProcessEngineConfiguration processEngineConfiguration, RuntimeService runtimeService, TaskService taskService, RepositoryService repositoryService) { Deployment deployment = repositoryService.createDeployment(). addString("oneTaskWithFormKeySideEffectProcess.bpmn20.xml", ONE_TASK_PROCESS. replace("START_EVENT_VALIDATION", "${true}"). replace("USER_TASK_VALIDATION", "${allowValidation}") ). deploy(); ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().deploymentId(deployment.getId()).singleResult(); assertThatThrownBy(() -> runtimeService.startProcessInstanceWithForm(processDefinition.getId(), "__COMPLETE", Collections.singletonMap("allowValidation", Boolean.TRUE),"oneTaskWithFormSideEffectProcess")) .isInstanceOf(RuntimeException.class) .hasMessageContaining("validation failed"); assertThat(SideEffectExecutionListener.getSideEffect()).isZero(); ProcessInstance processInstance = runtimeService.startProcessInstanceByKey( "oneTaskWithFormSideEffectProcess", Collections.singletonMap("allowValidation", Boolean.TRUE) ); SideEffectExecutionListener.reset(); Task task = taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult(); FormRepositoryService formRepositoryService = FormEngines.getDefaultFormEngine().getFormRepositoryService(); FormDefinition formDefinition = formRepositoryService.createFormDefinitionQuery().formDefinitionKey("form1").singleResult(); assertThatThrownBy(() -> taskService.completeTaskWithForm(task.getId(), formDefinition.getId(), "__COMPLETE", Collections.singletonMap("initiator", "someInitiator"))) .isInstanceOf(RuntimeException.class); assertThat(SideEffectExecutionListener.getSideEffect()).isZero(); }
Example #27
Source File: SerializableVariablesDiabledTest.java From flowable-engine with Apache License 2.0 | 5 votes |
@Before public void setupServer() { if (serverUrlPrefix == null) { TestServer testServer = TestServerUtil.createAndStartServer(ObjectVariableSerializationDisabledApplicationConfiguration.class); serverUrlPrefix = testServer.getServerUrlPrefix(); this.repositoryService = testServer.getApplicationContext().getBean(RepositoryService.class); this.runtimeService = testServer.getApplicationContext().getBean(RuntimeService.class); this.identityService = testServer.getApplicationContext().getBean(IdentityService.class); this.taskService = testServer.getApplicationContext().getBean(TaskService.class); User user = identityService.newUser("kermit"); user.setFirstName("Kermit"); user.setLastName("the Frog"); user.setPassword("kermit"); identityService.saveUser(user); Group group = identityService.newGroup("admin"); group.setName("Administrators"); identityService.saveGroup(group); identityService.createMembership(user.getId(), group.getId()); this.testUserId = user.getId(); this.testGroupId = group.getId(); } }
Example #28
Source File: ProcessWithFormTest.java From flowable-engine with Apache License 2.0 | 5 votes |
@Test public void completeTaskWithoutValidationOnModelLevelBadExpression(ProcessEngineConfiguration processEngineConfiguration, RuntimeService runtimeService, TaskService taskService, RepositoryService repositoryService) { repositoryService.createDeployment(). addString("oneTaskWithFormKeySideEffectProcess.bpmn20.xml", ONE_TASK_PROCESS. replace("START_EVENT_VALIDATION", "true"). replace("USER_TASK_VALIDATION", "${BAD_EXPRESSION}") ). deploy(); ProcessInstance processInstance = runtimeService.startProcessInstanceByKey( "oneTaskWithFormSideEffectProcess", Collections.emptyMap() ); SideEffectExecutionListener.reset(); Task task = taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult(); FormRepositoryService formRepositoryService = FormEngines.getDefaultFormEngine().getFormRepositoryService(); FormDefinition formDefinition = formRepositoryService.createFormDefinitionQuery().formDefinitionKey("form1").singleResult(); assertThatThrownBy(() -> taskService.completeTaskWithForm(task.getId(), formDefinition.getId(), "__COMPLETE", Collections.singletonMap("initiator", "someInitiator"))) .isInstanceOf(FlowableException.class) .hasMessage("Unknown property used in expression: ${BAD_EXPRESSION}"); assertThat(SideEffectExecutionListener.getSideEffect()).isZero(); }
Example #29
Source File: ProcessWithFormTest.java From flowable-engine with Apache License 2.0 | 5 votes |
@Test public void completeTaskWithValidationOnModelLevelStringExpression(ProcessEngineConfiguration processEngineConfiguration, RuntimeService runtimeService, TaskService taskService, RepositoryService repositoryService) { repositoryService.createDeployment(). addString("oneTaskWithFormKeySideEffectProcess.bpmn20.xml", ONE_TASK_PROCESS. replace("START_EVENT_VALIDATION", "true"). replace("USER_TASK_VALIDATION", "${true}") ). deploy(); ProcessInstance processInstance = runtimeService.startProcessInstanceByKey( "oneTaskWithFormSideEffectProcess", Collections.emptyMap() ); SideEffectExecutionListener.reset(); Task task = taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult(); FormRepositoryService formRepositoryService = FormEngines.getDefaultFormEngine().getFormRepositoryService(); FormDefinition formDefinition = formRepositoryService.createFormDefinitionQuery().formDefinitionKey("form1").singleResult(); assertThatThrownBy(() -> taskService.completeTaskWithForm(task.getId(), formDefinition.getId(), "__COMPLETE", Collections.singletonMap("initiator", "someInitiator"))) .isInstanceOf(RuntimeException.class) .hasMessage("validation failed"); assertThat(SideEffectExecutionListener.getSideEffect()).isZero(); }
Example #30
Source File: HistoryServiceTaskLogTest.java From flowable-engine with Apache License 2.0 | 5 votes |
@Test @Deployment(resources = { "org/flowable/engine/test/api/runtime/oneTaskProcess.bpmn20.xml" }) public void logProcessTaskEvents(RuntimeService runtimeService, TaskService taskService, HistoryService historyService, ManagementService managementService, ProcessEngineConfiguration processEngineConfiguration) { ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("oneTaskProcess"); assertThat(processInstance).isNotNull(); Task task = taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult(); assertThat(task).isNotNull(); try { taskService.setAssignee(task.getId(), "newAssignee"); taskService.setOwner(task.getId(), "newOwner"); taskService.complete(task.getId()); if (HistoryTestHelper.isHistoricTaskLoggingEnabled(processEngineConfiguration)) { List<HistoricTaskLogEntry> logEntries = historyService.createHistoricTaskLogEntryQuery().taskId(task.getId()).list(); assertThat(logEntries).hasSize(4); HistoricTaskLogEntry logEntry = historyService.createHistoricTaskLogEntryQuery().taskId(task.getId()).type("USER_TASK_CREATED").singleResult(); assertThat(logEntry).isNotNull(); assertThat(logEntry.getProcessDefinitionId()).isEqualTo(processInstance.getProcessDefinitionId()); assertThat(logEntry.getExecutionId()).isEqualTo(task.getExecutionId()); assertThat(logEntry.getProcessInstanceId()).isEqualTo(processInstance.getId()); assertThat(historyService.createHistoricTaskLogEntryQuery().taskId(task.getId()).type("USER_TASK_ASSIGNEE_CHANGED").count()).isEqualTo(1); assertThat(historyService.createHistoricTaskLogEntryQuery().taskId(task.getId()).type("USER_TASK_OWNER_CHANGED").count()).isEqualTo(1); assertThat(historyService.createHistoricTaskLogEntryQuery().taskId(task.getId()).type("USER_TASK_COMPLETED").count()).isEqualTo(1); } } finally { deleteTaskWithLogEntries(taskService, managementService, processEngineConfiguration, task.getId()); } }