org.flowable.engine.repository.Deployment Java Examples
The following examples show how to use
org.flowable.engine.repository.Deployment.
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: CaseTaskTest.java From flowable-engine with Apache License 2.0 | 6 votes |
@Test @CmmnDeployment(resources = { "org/flowable/cmmn/test/CaseTaskTest.testCaseTask.cmmn" }) public void testCaseTaskIdVariableName() { Deployment deployment = processEngineRepositoryService.createDeployment() .addClasspathResource("org/flowable/cmmn/test/caseTaskProcess.bpmn20.xml") .deploy(); try { ProcessInstance processInstance = processEngineRuntimeService.startProcessInstanceByKey("caseTask"); processEngineTaskService.complete(processEngineTaskService.createTaskQuery().singleResult().getId()); CaseInstance caseInstance = cmmnRuntimeService.createCaseInstanceQuery().singleResult(); assertThat(processEngineRuntimeService.getVariable(processInstance.getId(), "myCaseInstanceId")).isEqualTo(caseInstance.getId()); } finally { processEngineRepositoryService.deleteDeployment(deployment.getId(), true); } }
Example #3
Source File: DeploymentResourceTest.java From flowable-engine with Apache License 2.0 | 6 votes |
/** * Test getting a single deployment. GET repository/deployments/{deploymentId} */ @Test @org.flowable.engine.test.Deployment(resources = { "org/flowable/rest/service/api/repository/oneTaskProcess.bpmn20.xml" }) public void testGetDeployment() throws Exception { Deployment existingDeployment = repositoryService.createDeploymentQuery().singleResult(); HttpGet httpGet = new HttpGet(SERVER_URL_PREFIX + RestUrls.createRelativeResourceUrl(RestUrls.URL_DEPLOYMENT, existingDeployment.getId())); CloseableHttpResponse response = executeRequest(httpGet, HttpStatus.SC_OK); JsonNode responseNode = objectMapper.readTree(response.getEntity().getContent()); closeResponse(response); assertThatJson(responseNode) .when(Option.IGNORING_EXTRA_FIELDS) .isEqualTo("{" + "id: '" + existingDeployment.getId() + "'," + "name: '" + existingDeployment.getName() + "'," + "url: '" + SERVER_URL_PREFIX + RestUrls.createRelativeResourceUrl(RestUrls.URL_DEPLOYMENT, existingDeployment.getId()) + "'," + "category: " + existingDeployment.getCategory() + "," + "deploymentTime: '${json-unit.any-string}'," + "tenantId: ''" + "}"); }
Example #4
Source File: SubProcessTest.java From flowable-engine with Apache License 2.0 | 6 votes |
@Test public void testSimpleSubProcess() { Deployment deployment = repositoryService.createDeployment().addClasspathResource("org/flowable/examples/bpmn/subprocess/SubProcessTest.fixSystemFailureProcess.bpmn20.xml").deploy(); // After staring the process, both tasks in the subprocess should be // active ProcessInstance pi = runtimeService.startProcessInstanceByKey("fixSystemFailure"); List<org.flowable.task.api.Task> tasks = taskService.createTaskQuery().processInstanceId(pi.getId()).orderByTaskName().asc().list(); // Tasks are ordered by name (see query) assertThat(tasks) .extracting(Task::getName) .containsExactly("Investigate hardware", "Investigate software"); // Completing both the tasks finishes the subprocess and enables the // task after the subprocess taskService.complete(tasks.get(0).getId()); taskService.complete(tasks.get(1).getId()); org.flowable.task.api.Task writeReportTask = taskService.createTaskQuery().processInstanceId(pi.getId()).singleResult(); assertThat(writeReportTask.getName()).isEqualTo("Write report"); // Clean up repositoryService.deleteDeployment(deployment.getId(), true); }
Example #5
Source File: ModelQueryTest.java From flowable-engine with Apache License 2.0 | 6 votes |
public void testByDeploymentId() { Deployment deployment = repositoryService.createDeployment().addString("test", "test") .deploymentProperty(DeploymentProperties.DEPLOY_AS_FLOWABLE5_PROCESS_DEFINITION, Boolean.TRUE) .deploy(); assertEquals(0, repositoryService.createModelQuery().deploymentId(deployment.getId()).count()); assertEquals(0, repositoryService.createModelQuery().deployed().count()); assertEquals(1, repositoryService.createModelQuery().notDeployed().count()); Model model = repositoryService.createModelQuery().singleResult(); model.setDeploymentId(deployment.getId()); repositoryService.saveModel(model); assertEquals(1, repositoryService.createModelQuery().deploymentId(deployment.getId()).count()); assertEquals(1, repositoryService.createModelQuery().deployed().count()); assertEquals(0, repositoryService.createModelQuery().notDeployed().count()); // Cleanup repositoryService.deleteDeployment(deployment.getId(), true); // After cleanup the model should still exist assertEquals(0, repositoryService.createDeploymentQuery().count()); assertEquals(0, repositoryService.createModelQuery().deploymentId(deployment.getId()).count()); assertEquals(1, repositoryService.createModelQuery().notDeployed().count()); assertEquals(1, repositoryService.createModelQuery().count()); }
Example #6
Source File: GetDeploymentResourceCmd.java From flowable-engine with Apache License 2.0 | 6 votes |
@Override public InputStream execute(CommandContext commandContext) { if (deploymentId == null) { throw new FlowableIllegalArgumentException("deploymentId is null"); } if (resourceName == null) { throw new FlowableIllegalArgumentException("resourceName is null"); } ResourceEntity resource = CommandContextUtil.getResourceEntityManager().findResourceByDeploymentIdAndResourceName(deploymentId, resourceName); if (resource == null) { if (CommandContextUtil.getDeploymentEntityManager(commandContext).findById(deploymentId) == null) { throw new FlowableObjectNotFoundException("deployment does not exist: " + deploymentId, Deployment.class); } else { throw new FlowableObjectNotFoundException("no resource found with name '" + resourceName + "' in deployment '" + deploymentId + "'", InputStream.class); } } return new ByteArrayInputStream(resource.getBytes()); }
Example #7
Source File: VariablesTest.java From flowable-engine with Apache License 2.0 | 6 votes |
@org.flowable.engine.test.Deployment public void testGetVariableAllVariableFetchingDefault() { // Testing it the default way, all using getVariable("someVar"); Map<String, Object> vars = generateVariables(); vars.put("testVar", "hello"); String processInstanceId = runtimeService.startProcessInstanceByKey("variablesFetchingTestProcess", vars).getId(); taskService.complete(taskService.createTaskQuery().taskName("Task A").singleResult().getId()); taskService.complete(taskService.createTaskQuery().taskName("Task B").singleResult().getId()); // Triggers service task invocation vars = runtimeService.getVariables(processInstanceId); assertEquals(51, vars.size()); String varValue = (String) runtimeService.getVariable(processInstanceId, "testVar"); assertEquals("HELLO world", varValue); }
Example #8
Source File: VariablesTest.java From flowable-engine with Apache License 2.0 | 6 votes |
@org.flowable.engine.test.Deployment public void testGetVariableInDelegateMixed3() { Map<String, Object> vars = generateVariables(); vars.put("testVar1", "one"); vars.put("testVar2", "two"); vars.put("testVar3", "three"); String processInstanceId = runtimeService.startProcessInstanceByKey("variablesFetchingTestProcess", vars).getId(); taskService.complete(taskService.createTaskQuery().taskName("Task A").singleResult().getId()); taskService.complete(taskService.createTaskQuery().taskName("Task B").singleResult().getId()); // Triggers service task invocation assertEquals("one-CHANGED", (String) runtimeService.getVariable(processInstanceId, "testVar1")); assertEquals("two-CHANGED", (String) runtimeService.getVariable(processInstanceId, "testVar2")); assertNull(runtimeService.getVariable(processInstanceId, "testVar3")); }
Example #9
Source File: ModelQueryTest.java From flowable-engine with Apache License 2.0 | 6 votes |
@Test public void testByDeploymentId() { Deployment deployment = repositoryService.createDeployment().addString("test", "test").deploy(); assertThat(repositoryService.createModelQuery().deploymentId(deployment.getId()).count()).isZero(); assertThat(repositoryService.createModelQuery().deployed().count()).isZero(); assertThat(repositoryService.createModelQuery().notDeployed().count()).isEqualTo(1); Model model = repositoryService.createModelQuery().singleResult(); model.setDeploymentId(deployment.getId()); repositoryService.saveModel(model); assertThat(repositoryService.createModelQuery().deploymentId(deployment.getId()).count()).isEqualTo(1); assertThat(repositoryService.createModelQuery().deployed().count()).isEqualTo(1); assertThat(repositoryService.createModelQuery().notDeployed().count()).isZero(); // Cleanup repositoryService.deleteDeployment(deployment.getId(), true); // After cleanup the model should still exist assertThat(repositoryService.createDeploymentQuery().count()).isZero(); assertThat(repositoryService.createModelQuery().deploymentId(deployment.getId()).count()).isZero(); assertThat(repositoryService.createModelQuery().notDeployed().count()).isEqualTo(1); assertThat(repositoryService.createModelQuery().count()).isEqualTo(1); }
Example #10
Source File: GetDecisionsForProcessDefinitionCmd.java From flowable-engine with Apache License 2.0 | 6 votes |
protected void addDecisionToCollection(List<DmnDecision> decisions, String decisionKey, ProcessDefinition processDefinition) { DmnDecisionQuery definitionQuery = dmnRepositoryService.createDecisionQuery().decisionKey(decisionKey); Deployment deployment = CommandContextUtil.getDeploymentEntityManager().findById(processDefinition.getDeploymentId()); if (deployment.getParentDeploymentId() != null) { List<DmnDeployment> dmnDeployments = dmnRepositoryService.createDeploymentQuery().parentDeploymentId(deployment.getParentDeploymentId()).list(); if (dmnDeployments != null && dmnDeployments.size() > 0) { definitionQuery.deploymentId(dmnDeployments.get(0).getId()); } else { definitionQuery.latestVersion(); } } else { definitionQuery.latestVersion(); } DmnDecision decision = definitionQuery.singleResult(); if (decision != null) { decisions.add(decision); } }
Example #11
Source File: CaseTaskTest.java From flowable-engine with Apache License 2.0 | 6 votes |
@Test @CmmnDeployment(resources = { "org/flowable/cmmn/test/CaseTaskTest.testCaseTask.cmmn" }) public void testCaseTaskIdVariableNameExpression() { Deployment deployment = processEngineRepositoryService.createDeployment() .addClasspathResource("org/flowable/cmmn/test/caseTaskProcessWithIdNameExpressions.bpmn20.xml") .deploy(); try { ProcessInstance processInstance = processEngineRuntimeService.createProcessInstanceBuilder() .processDefinitionKey("caseTask") .variable("counter", 1) .start(); processEngineTaskService.complete(processEngineTaskService.createTaskQuery().singleResult().getId()); CaseInstance caseInstance = cmmnRuntimeService.createCaseInstanceQuery().singleResult(); assertThat(processEngineRuntimeService.getVariable(processInstance.getId(), "myVariable-1")).isEqualTo(caseInstance.getId()); } finally { processEngineRepositoryService.deleteDeployment(deployment.getId(), true); } }
Example #12
Source File: Flowable6Test.java From flowable-engine with Apache License 2.0 | 6 votes |
@Test @org.flowable.engine.test.Deployment public void testScriptTask() { Map<String, Object> variableMap = new HashMap<>(); variableMap.put("a", 1); variableMap.put("b", 2); ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("oneTaskProcess", variableMap); assertNotNull(processInstance); assertFalse(processInstance.isEnded()); Number sumVariable = (Number) runtimeService.getVariable(processInstance.getId(), "sum"); assertEquals(3, sumVariable.intValue()); Execution execution = runtimeService.createExecutionQuery().processInstanceId(processInstance.getId()).onlyChildExecutions().singleResult(); assertNotNull(execution); runtimeService.trigger(execution.getId()); assertNull(runtimeService.createProcessInstanceQuery().processInstanceId(processInstance.getId()).singleResult()); }
Example #13
Source File: GetFormDefinitionsForProcessDefinitionCmd.java From flowable-engine with Apache License 2.0 | 6 votes |
protected void addFormDefinitionToCollection(List<FormDefinition> formDefinitions, String formKey, ProcessDefinition processDefinition) { FormDefinitionQuery formDefinitionQuery = formRepositoryService.createFormDefinitionQuery().formDefinitionKey(formKey); Deployment deployment = CommandContextUtil.getDeploymentEntityManager().findById(processDefinition.getDeploymentId()); if (deployment.getParentDeploymentId() != null) { List<FormDeployment> formDeployments = formRepositoryService.createDeploymentQuery().parentDeploymentId(deployment.getParentDeploymentId()).list(); if (formDeployments != null && formDeployments.size() > 0) { formDefinitionQuery.deploymentId(formDeployments.get(0).getId()); } else { formDefinitionQuery.latestVersion(); } } else { formDefinitionQuery.latestVersion(); } FormDefinition formDefinition = formDefinitionQuery.singleResult(); if (formDefinition != null) { formDefinitions.add(formDefinition); } }
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/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 #15
Source File: ProcessTaskTest.java From flowable-engine with Apache License 2.0 | 6 votes |
@Test @CmmnDeployment( resources = { "org/flowable/cmmn/test/ProcessTaskTest.testOneTaskProcessFallbackToDefaultTenantFalse.cmmn" }, tenantId = "flowable" ) public void testOneTaskProcessFallbackToDefaultTenantFalse() { Deployment deployment = this.processEngineRepositoryService.createDeployment(). addClasspathResource("org/flowable/cmmn/test/oneTaskProcess.bpmn20.xml"). deploy(); assertThatThrownBy(() -> startCaseInstanceWithOneTaskProcess("flowable")) .isInstanceOf(FlowableObjectNotFoundException.class) .hasMessage("Process definition with key 'oneTask' and tenantId 'flowable' was not found"); processEngineRepositoryService.deleteDeployment(deployment.getId(), true); }
Example #16
Source File: AbstractFlowableTestCase.java From flowable-engine with Apache License 2.0 | 6 votes |
protected void deleteDeployments() { boolean isAsyncHistoryEnabled = processEngineConfiguration.isAsyncHistoryEnabled(); HistoryManager asyncHistoryManager = null; if (isAsyncHistoryEnabled) { processEngineConfiguration.setAsyncHistoryEnabled(false); asyncHistoryManager = processEngineConfiguration.getHistoryManager(); processEngineConfiguration.setHistoryManager(new DefaultHistoryManager(processEngineConfiguration, processEngineConfiguration.getHistoryLevel(), processEngineConfiguration.isUsePrefixId())); } for (org.flowable.engine.repository.Deployment deployment : repositoryService.createDeploymentQuery().list()) { repositoryService.deleteDeployment(deployment.getId(), true); } if (isAsyncHistoryEnabled) { processEngineConfiguration.setAsyncHistoryEnabled(true); processEngineConfiguration.setHistoryManager(asyncHistoryManager); } }
Example #17
Source File: VerifyDatabaseOperationsTest.java From flowable-engine with Apache License 2.0 | 5 votes |
@AfterEach protected void tearDown() throws Exception { processEngineConfiguration.setBulkInsertEnabled(oldIsBulkInsertableValue); processEngineConfiguration.getPerformanceSettings().setEnableEagerExecutionTreeFetching(oldExecutionTreeFetchValue); processEngineConfiguration.getPerformanceSettings().setEnableExecutionRelationshipCounts(oldExecutionRelationshipCountValue); processEngineConfiguration.getPerformanceSettings().setEnableTaskRelationshipCounts(oldTaskRelationshipCountValue); TaskServiceConfiguration TaskServiceConfiguration = (TaskServiceConfiguration) processEngineConfiguration.getServiceConfigurations().get(EngineConfigurationConstants.KEY_TASK_SERVICE_CONFIG); TaskServiceConfiguration.setEnableTaskRelationshipCounts(oldTaskRelationshipCountValue); processEngineConfiguration.setEnableProcessDefinitionInfoCache(oldenableProcessDefinitionInfoCacheValue); ((AbstractHistoryManager) processEngineConfiguration.getHistoryManager()).setHistoryLevel(oldHistoryLevel); ((CommandExecutorImpl) processEngineConfiguration.getCommandExecutor()).setFirst(oldFirstCommandInterceptor); processEngineConfiguration.addSessionFactory(oldDbSqlSessionFactory); // Validate (cause this tended to be screwed up) List<HistoricActivityInstance> historicActivityInstances = historyService.createHistoricActivityInstanceQuery().list(); for (HistoricActivityInstance historicActivityInstance : historicActivityInstances) { assertThat(historicActivityInstance.getStartTime()).isNotNull(); assertThat(historicActivityInstance.getEndTime()).isNotNull(); } FlowableProfiler.getInstance().reset(); for (Deployment deployment : repositoryService.createDeploymentQuery().list()) { repositoryService.deleteDeployment(deployment.getId(), true); } assertThat(runtimeService.createActivityInstanceQuery().count()).isZero(); }
Example #18
Source File: ProcessDefinitionQueryTest.java From flowable-engine with Apache License 2.0 | 5 votes |
@Test public void testLocalizeProcessDefinition() { Deployment deployment = repositoryService.createDeployment().addClasspathResource("org/flowable/engine/test/repository/LocalizedProcess.bpmn20.xml") .addClasspathResource("org/flowable/engine/test/repository/LocalizedProcess.bpmn20.xml").deploy(); ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery() .processDefinitionKey("localizedProcess") .singleResult(); assertThat(processDefinition.getName()).isEqualTo("A localized process"); assertThat(processDefinition.getDescription()).isEqualTo("This a process that can be localized"); processDefinition = repositoryService.createProcessDefinitionQuery() .processDefinitionKey("localizedProcess") .locale("es") .singleResult(); assertThat(processDefinition.getName()).isEqualTo("Nombre del proceso"); assertThat(processDefinition.getDescription()).isEqualTo("DescripciĆ³n del proceso"); ObjectNode infoNode = dynamicBpmnService.getProcessDefinitionInfo(processDefinition.getId()); dynamicBpmnService.changeLocalizationName("en-GB", "localizedProcess", "The process name in 'en-GB'", infoNode); dynamicBpmnService.changeLocalizationDescription("en-GB", "localizedProcess", "The process description in 'en-GB'", infoNode); dynamicBpmnService.saveProcessDefinitionInfo(processDefinition.getId(), infoNode); processDefinition = repositoryService.createProcessDefinitionQuery() .processDefinitionKey("localizedProcess") .locale("en-GB") .singleResult(); assertThat(processDefinition.getName()).isEqualTo("The process name in 'en-GB'"); assertThat(processDefinition.getDescription()).isEqualTo("The process description in 'en-GB'"); repositoryService.deleteDeployment(deployment.getId()); }
Example #19
Source File: CaseTaskTest.java From flowable-engine with Apache License 2.0 | 5 votes |
@Test @CmmnDeployment(resources = { "org/flowable/cmmn/test/CaseTaskTest.testCaseTask.cmmn" }) public void testCaseTaskWithTerminatingSignalBoundaryEvent() { Deployment deployment = processEngineRepositoryService.createDeployment() .addClasspathResource("org/flowable/cmmn/test/caseTaskProcessWithTerminatingSignalBoundaryEvent.bpmn20.xml") .deploy(); try { // Arrange ProcessInstance processInstance = processEngineRuntimeService.startProcessInstanceByKey("terminateBySignalTestCase"); long numberOfActiveCaseInstances = cmmnRuntimeService.createCaseInstanceQuery() .count(); assertThat(numberOfActiveCaseInstances).isEqualTo(1); Execution myExternalSignalExecution = processEngineRuntimeService.createExecutionQuery() .processInstanceId(processInstance.getProcessInstanceId()) .signalEventSubscriptionName("myExternalSignal") .singleResult(); Execution caseTask1Execution = processEngineRuntimeService.createExecutionQuery().activityId("caseTask1").singleResult(); assertThat(caseTask1Execution.getReferenceId()).isNotNull(); assertThat(caseTask1Execution.getReferenceType()).isEqualTo(ReferenceTypes.EXECUTION_CHILD_CASE); CaseInstance caseInstance = cmmnRuntimeService.createCaseInstanceQuery().singleResult(); assertThat(caseInstance.getId()).isEqualTo(caseTask1Execution.getReferenceId()); // Act processEngineRuntimeService.signalEventReceived("myExternalSignal", myExternalSignalExecution.getId()); // Assert long numberOfActiveCaseInstancesAfterCompletion = cmmnRuntimeService.createCaseInstanceQuery() .count(); assertThat(numberOfActiveCaseInstancesAfterCompletion).isZero(); } finally { processEngineRepositoryService.deleteDeployment(deployment.getId(), true); } }
Example #20
Source File: CleanTestExecutionListener.java From flowable-engine with Apache License 2.0 | 5 votes |
@Override public void afterTestClass(TestContext testContext) throws Exception { RepositoryService repositoryService = testContext.getApplicationContext().getBean(RepositoryService.class); for (Deployment deployment : repositoryService.createDeploymentQuery().list()) { repositoryService.deleteDeployment(deployment.getId(), true); } }
Example #21
Source File: DeploymentResourceTest.java From flowable-engine with Apache License 2.0 | 5 votes |
/** * Test deleting a single deployment. DELETE repository/deployments/{deploymentId} */ @Test @org.flowable.engine.test.Deployment(resources = { "org/flowable/rest/service/api/repository/oneTaskProcess.bpmn20.xml" }) public void testDeleteDeployment() throws Exception { Deployment existingDeployment = repositoryService.createDeploymentQuery().singleResult(); assertThat(existingDeployment).isNotNull(); // Delete the deployment HttpDelete httpDelete = new HttpDelete(SERVER_URL_PREFIX + RestUrls.createRelativeResourceUrl(RestUrls.URL_DEPLOYMENT, existingDeployment.getId())); CloseableHttpResponse response = executeRequest(httpDelete, HttpStatus.SC_NO_CONTENT); closeResponse(response); existingDeployment = repositoryService.createDeploymentQuery().singleResult(); assertThat(existingDeployment).isNull(); }
Example #22
Source File: DynamicBpmnInjectionTest.java From flowable-engine with Apache License 2.0 | 5 votes |
@Test public void testInjectParallelSubProcessSimple() { deployOneTaskTestProcessWithCandidateStarterGroup(); Deployment deployment = repositoryService.createDeployment() .addClasspathResource("org/flowable/engine/test/bpmn/dynamic/dynamic_onetask.bpmn20.xml") .deploy(); deploymentIdsForAutoCleanup.add(deployment.getId()); ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("oneTaskProcess"); Task task = taskService.createTaskQuery().singleResult(); ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery() .processDefinitionKey("oneTaskV2") .singleResult(); DynamicEmbeddedSubProcessBuilder subProcessBuilder = new DynamicEmbeddedSubProcessBuilder() .id("customSubprocess") .processDefinitionId(processDefinition.getId()); dynamicBpmnService.injectParallelEmbeddedSubProcess(task.getId(), subProcessBuilder); processInstance = runtimeService.createProcessInstanceQuery().processInstanceId(processInstance.getId()).singleResult(); deploymentIdsForAutoCleanup.add(repositoryService.getProcessDefinition(processInstance.getProcessDefinitionId()).getDeploymentId()); // For auto-cleanup if (processEngineConfiguration.getPerformanceSettings().isEnableExecutionRelationshipCounts()) { Execution execution = runtimeService.createExecutionQuery().activityId("usertaskV2").singleResult(); assertEquals(1, ((CountingExecutionEntity) execution).getTaskCount()); } List<IdentityLink> identityLinks = repositoryService.getIdentityLinksForProcessDefinition(processInstance.getProcessDefinitionId()); assertEquals(1, identityLinks.size()); List<Task> tasks = taskService.createTaskQuery().processInstanceId(processInstance.getId()).list(); assertEquals(2, tasks.size()); for (Task t : tasks) { taskService.complete(t.getId()); } assertProcessEnded(processInstance.getId()); }
Example #23
Source File: DeploymentQueryTest.java From flowable-engine with Apache License 2.0 | 5 votes |
@Test public void testNativeQuery() { assertThat(managementService.getTableName(Deployment.class, false)).isEqualTo("ACT_RE_DEPLOYMENT"); assertEquals("ACT_RE_DEPLOYMENT", managementService.getTableName(DeploymentEntity.class, false)); String tableName = managementService.getTableName(Deployment.class); String baseQuerySql = "SELECT * FROM " + tableName; assertThat(repositoryService.createNativeDeploymentQuery().sql(baseQuerySql).list()).hasSize(2); assertThat(repositoryService.createNativeDeploymentQuery().sql(baseQuerySql + " where NAME_ = #{name}").parameter("name", "org/flowable/engine/test/repository/one.bpmn20.xml").list()).hasSize(1); // paging assertThat(repositoryService.createNativeDeploymentQuery().sql(baseQuerySql).listPage(0, 2)).hasSize(2); assertThat(repositoryService.createNativeDeploymentQuery().sql(baseQuerySql).listPage(1, 3)).hasSize(1); }
Example #24
Source File: SignalEventTest.java From flowable-engine with Apache License 2.0 | 5 votes |
@Test @CmmnDeployment(resources = { "org/flowable/cmmn/test/processTaskWithSignalListener.cmmn" }) public void testTerminateCaseInstanceWithSignal() { Deployment deployment = this.processEngineRepositoryService.createDeployment(). addClasspathResource("org/flowable/cmmn/test/signalProcess.bpmn20.xml"). deploy(); try { CaseInstance caseInstance = cmmnRuntimeService.createCaseInstanceBuilder().caseDefinitionKey("signalCase").start(); Task task = processEngineTaskService.createTaskQuery().caseInstanceIdWithChildren(caseInstance.getId()).singleResult(); assertThat(task).isNotNull(); assertThat(cmmnTaskService.createTaskQuery().caseInstanceId(caseInstance.getId()).count()).isZero(); EventSubscription eventSubscription = cmmnRuntimeService.createEventSubscriptionQuery().scopeId(caseInstance.getId()).singleResult(); assertThat(eventSubscription.getEventName()).isEqualTo("testSignal"); cmmnRuntimeService.terminateCaseInstance(caseInstance.getId()); assertThat(processEngineRuntimeService.createProcessInstanceQuery().processInstanceId(task.getProcessInstanceId()).count()).isZero(); assertThat(cmmnRuntimeService.createCaseInstanceQuery().caseInstanceId(caseInstance.getId()).count()).isZero(); } finally { processEngine.getRepositoryService().deleteDeployment(deployment.getId(), true); } }
Example #25
Source File: CallActivityTest.java From flowable-engine with Apache License 2.0 | 5 votes |
public void testInstantiateSubprocess() throws Exception { BpmnModel mainBpmnModel = loadBPMNModel(MAIN_PROCESS_RESOURCE); BpmnModel childBpmnModel = loadBPMNModel(CHILD_PROCESS_RESOURCE); Deployment childDeployment = processEngine.getRepositoryService() .createDeployment() .name("childProcessDeployment") .addBpmnModel("childProcess.bpmn20.xml", childBpmnModel) .deploymentProperty(DeploymentProperties.DEPLOY_AS_FLOWABLE5_PROCESS_DEFINITION, Boolean.TRUE) .deploy(); processEngine.getRepositoryService() .createDeployment() .name("masterProcessDeployment") .addBpmnModel("masterProcess.bpmn20.xml", mainBpmnModel) .deploymentProperty(DeploymentProperties.DEPLOY_AS_FLOWABLE5_PROCESS_DEFINITION, Boolean.TRUE) .deploy(); suspendProcessDefinitions(childDeployment); try { runtimeService.startProcessInstanceByKey("masterProcess"); fail("Exception expected"); } catch (FlowableException ae) { assertTextPresent("Cannot start process instance. Process definition Child Process", ae.getMessage()); } }
Example #26
Source File: AppResourceDeploymentTest.java From flowable-engine with Apache License 2.0 | 5 votes |
@Test public void testAppResourceWithProcessDefinition() { InputStream appInputStream = this.getClass().getClassLoader().getResourceAsStream("org/flowable/engine/test/api/app/test.app"); InputStream bpmnInputStream = this.getClass().getClassLoader().getResourceAsStream("org/flowable/engine/test/repository/one.bpmn20.xml"); Deployment deployment = repositoryService.createDeployment() .addInputStream("test.app", appInputStream) .addInputStream("one.bpmn20.xml", bpmnInputStream) .deploy(); ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().processDefinitionKey("one").singleResult(); assertEquals("one", processDefinition.getKey()); assertEquals(deployment.getId(), processDefinition.getDeploymentId()); Object appObject = repositoryService.getAppResourceObject(deployment.getId()); assertNotNull(appObject); assertTrue(appObject instanceof AppModel); AppModel appModel = (AppModel) appObject; assertEquals("testTheme", appModel.getTheme()); assertEquals("testIcon", appModel.getIcon()); appModel = repositoryService.getAppResourceModel(deployment.getId()); assertEquals("testTheme", appModel.getTheme()); assertEquals("testIcon", appModel.getIcon()); repositoryService.deleteDeployment(deployment.getId(), true); try { appObject = repositoryService.getAppResourceObject(deployment.getId()); fail("exception excepted"); } catch (Exception e) { // expected exception } }
Example #27
Source File: CaseTaskTest.java From flowable-engine with Apache License 2.0 | 5 votes |
@Test @CmmnDeployment(resources = { "org/flowable/cmmn/test/CaseTaskTest.testCaseTask.cmmn" }) public void testCaseTaskWithTwoCaseTasksWithTerminateEndEvent() { Deployment deployment = processEngineRepositoryService.createDeployment() .addClasspathResource("org/flowable/cmmn/test/caseTaskProcessWithTwoParallelCasesAndWithTerminateEndEventOnDifferentExecution.bpmn20.xml") .deploy(); try { // Arrange ProcessInstance processInstance = processEngineRuntimeService.startProcessInstanceByKey("terminateByEndEvent"); Task task = processEngineTaskService.createTaskQuery() .processInstanceId(processInstance.getProcessInstanceId()) .singleResult(); assertThat(task).isNotNull(); assertThat(task.getTaskDefinitionKey()).isEqualTo("formTask1"); long numberOfActiveCaseInstances = cmmnRuntimeService.createCaseInstanceQuery() .count(); assertThat(numberOfActiveCaseInstances).isEqualTo(2); Execution caseTask1Execution = processEngineRuntimeService.createExecutionQuery().activityId("caseTask1").singleResult(); assertThat(caseTask1Execution.getReferenceId()).isNotNull(); assertThat(caseTask1Execution.getReferenceType()).isEqualTo(ReferenceTypes.EXECUTION_CHILD_CASE); // Act processEngineTaskService.complete(task.getId()); // Assert long numberOfActiveCaseInstancesAfterCompletion = cmmnRuntimeService.createCaseInstanceQuery() .count(); assertThat(numberOfActiveCaseInstancesAfterCompletion).isZero(); } finally { processEngineRepositoryService.deleteDeployment(deployment.getId(), true); } }
Example #28
Source File: SpringAutoDeployTest.java From flowable-engine with Apache License 2.0 | 5 votes |
private void removeAllDeployments() { if (repositoryService != null) { for (Deployment deployment : repositoryService.createDeploymentQuery().list()) { repositoryService.deleteDeployment(deployment.getId(), true); } } }
Example #29
Source File: AbstractFlowableTestCase.java From flowable-engine with Apache License 2.0 | 5 votes |
/** * Creates and deploys the one task process. See {@link #createOneTaskTestProcess()}. * * @return The process definition id (NOT the process definition key) of deployed one task process. */ public String deployOneTaskTestProcess() { BpmnModel bpmnModel = createOneTaskTestProcess(); Deployment deployment = repositoryService.createDeployment() .addBpmnModel("oneTasktest.bpmn20.xml", bpmnModel).deploy(); deploymentIdsForAutoCleanup.add(deployment.getId()); // For auto-cleanup ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery() .deploymentId(deployment.getId()).singleResult(); return processDefinition.getId(); }
Example #30
Source File: CaseTaskTest.java From flowable-engine with Apache License 2.0 | 5 votes |
@Test @CmmnDeployment(resources = { "org/flowable/cmmn/test/CaseTaskTest.testCaseTask.cmmn" }) public void testCaseTasksInSubProcessWithTerminatingSignalBoundaryEvent() { Deployment deployment = processEngineRepositoryService.createDeployment() .addClasspathResource("org/flowable/cmmn/test/caseTasksInSubProcessWithTerminatingSignalBoundaryEvent.bpmn20.xml") .deploy(); try { // Arrange ProcessInstance processInstance = processEngineRuntimeService.startProcessInstanceByKey("terminateTwoCasesWithinSubprocessBySignalEvent"); long numberOfActiveCaseInstances = cmmnRuntimeService.createCaseInstanceQuery() .count(); assertThat(numberOfActiveCaseInstances).isEqualTo(2); Execution myExternalSignalExecution = processEngineRuntimeService.createExecutionQuery() .processInstanceId(processInstance.getProcessInstanceId()) .signalEventSubscriptionName("myExternalSignal") .singleResult(); Execution caseTask1Execution = processEngineRuntimeService.createExecutionQuery().activityId("caseTask1").singleResult(); assertThat(caseTask1Execution.getReferenceId()).isNotNull(); assertThat(caseTask1Execution.getReferenceType()).isEqualTo(ReferenceTypes.EXECUTION_CHILD_CASE); // Act processEngineRuntimeService.signalEventReceived("myExternalSignal", myExternalSignalExecution.getId()); // Assert long numberOfActiveCaseInstancesAfterCompletion = cmmnRuntimeService.createCaseInstanceQuery() .count(); assertThat(numberOfActiveCaseInstancesAfterCompletion).isZero(); } finally { processEngineRepositoryService.deleteDeployment(deployment.getId(), true); } }