org.camunda.bpm.engine.repository.Deployment Java Examples
The following examples show how to use
org.camunda.bpm.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: DeploymentAuthorizationTest.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
public void testClearAuthorizationOnDeleteDeployment() { // given createGrantAuthorization(DEPLOYMENT, ANY, userId, CREATE); Deployment deployment = repositoryService .createDeployment() .addClasspathResource(FIRST_RESOURCE) .deploy(); String deploymentId = deployment.getId(); AuthorizationQuery query = authorizationService .createAuthorizationQuery() .userIdIn(userId) .resourceId(deploymentId); Authorization authorization = query.singleResult(); assertNotNull(authorization); // when repositoryService.deleteDeployment(deploymentId); authorization = query.singleResult(); assertNull(authorization); deleteDeployment(deploymentId); }
Example #2
Source File: UserOperationLogDeploymentTest.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
public void testDeleteProcessDefinitiontWithoutCascadingShouldKeepCreateUserOperationLog() { // given Deployment deployment = repositoryService .createDeployment() .name(DEPLOYMENT_NAME) .addModelInstance(RESOURCE_NAME, createProcessWithServiceTask(PROCESS_KEY)) .deploy(); ProcessDefinition procDef = repositoryService.createProcessDefinitionQuery() .deploymentId(deployment.getId()) .singleResult(); UserOperationLogQuery query = historyService .createUserOperationLogQuery() .operationType(UserOperationLogEntry.OPERATION_TYPE_CREATE); assertEquals(1, query.count()); // when repositoryService.deleteProcessDefinition(procDef.getId()); // then assertEquals(1, query.count()); }
Example #3
Source File: InstanceList.java From camunda-bpm-platform-osgi with Apache License 2.0 | 6 votes |
@Override protected Object doExecute() throws Exception { if (processDefinitionId != null) { printProcessInfo(processDefinitionId); } else { //search for the last deployment List<Deployment> deployments = engine.getRepositoryService().createDeploymentQuery().orderByDeploymenTime().desc().listPage(0, 1); Deployment lastDeployment = deployments.get(0); System.out.println("Process instance for the last deployment: " + lastDeployment.getId()); //iterate over the process definitions for (ProcessDefinition process : engine.getRepositoryService().createProcessDefinitionQuery().deploymentId(lastDeployment.getId()) .list()) { System.out.println("\nInstances for the process definition: " + process.getId()); printProcessInfo(process.getId()); } } return null; }
Example #4
Source File: DeploymentRestServiceQueryTest.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
@Test public void testDeploymentWithoutTenantId() { Deployment mockDeployment = MockProvider.createMockDeployment(null); mockedQuery = setUpMockDeploymentQuery(Collections.singletonList(mockDeployment)); Response response = given() .queryParam("withoutTenantId", true) .then().expect() .statusCode(Status.OK.getStatusCode()) .when() .get(DEPLOYMENT_QUERY_URL); verify(mockedQuery).withoutTenantId(); verify(mockedQuery).list(); String content = response.asString(); List<String> definitions = from(content).getList(""); assertThat(definitions).hasSize(1); String returnedTenantId1 = from(content).getString("[0].tenantId"); assertThat(returnedTenantId1).isEqualTo(null); }
Example #5
Source File: ProcessDefinitionQueryTest.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
@Test @org.camunda.bpm.engine.test.Deployment(resources={"org/camunda/bpm/engine/test/api/repository/failingProcessCreateOneIncident.bpmn20.xml"}) public void testQueryByIncidentMessage() { assertThat(repositoryService.createProcessDefinitionQuery() .processDefinitionKey("failingProcess") .count()).isEqualTo(1); ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("failingProcess"); testRule.waitForJobExecutorToProcessAllJobs(); List<Incident> incidentList = runtimeService.createIncidentQuery().list(); assertThat(incidentList.size()).isEqualTo(1); Incident incident = runtimeService.createIncidentQuery().processInstanceId(processInstance.getId()).singleResult(); ProcessDefinitionQuery query = repositoryService .createProcessDefinitionQuery() .incidentMessage(incident.getIncidentMessage()); verifyQueryResults(query, 1); }
Example #6
Source File: MultiTenancyTimerStartEventTest.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
@Test public void deleteJobsWhileUndeployment() { Deployment deploymentForTenantOne = testRule.deployForTenant(TENANT_ONE, PROCESS); Deployment deploymentForTenantTwo = testRule.deployForTenant(TENANT_TWO, PROCESS); JobQuery query = managementService.createJobQuery(); assertThat(query.tenantIdIn(TENANT_ONE).count(), is(1L)); assertThat(query.tenantIdIn(TENANT_TWO).count(), is(1L)); repositoryService.deleteDeployment(deploymentForTenantOne.getId(), true); assertThat(query.tenantIdIn(TENANT_ONE).count(), is(0L)); assertThat(query.tenantIdIn(TENANT_TWO).count(), is(1L)); repositoryService.deleteDeployment(deploymentForTenantTwo.getId(), true); assertThat(query.tenantIdIn(TENANT_ONE).count(), is(0L)); assertThat(query.tenantIdIn(TENANT_TWO).count(), is(0L)); }
Example #7
Source File: TransactionListenerThreadContextTest.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
public void testTxListenersInvokeAsync() { BpmnModelInstance process = Bpmn.createExecutableProcess("testProcess") .startEvent() .camundaAsyncBefore() .camundaAsyncAfter() .endEvent() .done(); Deployment deployment = repositoryService.createDeployment() .addModelInstance("testProcess.bpmn", process) .deploy(); ProcessInstance pi = runtimeService.startProcessInstanceByKey("testProcess"); waitForJobExecutorToProcessAllJobs(6000); assertProcessEnded(pi.getId()); repositoryService.deleteDeployment(deployment.getId(), true); }
Example #8
Source File: CallingTaskItemHandler.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
protected void initializeCallableElement(CmmnElement element, CmmnActivity activity, CmmnHandlerContext context) { Deployment deployment = context.getDeployment(); String deploymentId = null; if (deployment != null) { deploymentId = deployment.getId(); } BaseCallableElement callableElement = createCallableElement(); callableElement.setDeploymentId(deploymentId); // set callableElement on behavior CallingTaskActivityBehavior behavior = (CallingTaskActivityBehavior) activity.getActivityBehavior(); behavior.setCallableElement(callableElement); // definition key initializeDefinitionKey(element, activity, context, callableElement); // binding initializeBinding(element, activity, context, callableElement); // version initializeVersion(element, activity, context, callableElement); // tenant-id initializeTenantId(element, activity, context, callableElement); }
Example #9
Source File: MultiTenancyDeploymentCmdsTenantCheckTest.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
@Test public void redeployForTheSameAuthenticatedTenant() { Deployment deploymentOne = repositoryService.createDeployment() .addModelInstance("emptyProcess.bpmn", emptyProcess) .addModelInstance("startEndProcess.bpmn", startEndProcess) .tenantId(TENANT_ONE) .deploy(); identityService.setAuthentication("user", null, Arrays.asList(TENANT_ONE)); repositoryService.createDeployment() .addDeploymentResources(deploymentOne.getId()) .tenantId(TENANT_ONE) .deploy(); DeploymentQuery query = repositoryService.createDeploymentQuery(); assertThat(query.count(), is(2L)); assertThat(query.tenantIdIn(TENANT_ONE).count(), is(2L)); }
Example #10
Source File: EmbeddedProcessApplicationTest.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
public void testDeployWithTenantIds() { registerProcessEngine(); TestApplicationWithTenantId processApplication = new TestApplicationWithTenantId(); processApplication.deploy(); List<Deployment> deployments = repositoryService .createDeploymentQuery() .orderByTenantId() .asc() .list(); assertEquals(2, deployments.size()); assertEquals("tenant1", deployments.get(0).getTenantId()); assertEquals("tenant2", deployments.get(1).getTenantId()); processApplication.undeploy(); }
Example #11
Source File: UpgradedDBDropper.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
public void cleanDatabase(ProcessEngine engine) { // delete all deployments RepositoryService repositoryService = engine.getRepositoryService(); List<Deployment> deployments = repositoryService .createDeploymentQuery() .list(); for (Deployment deployment : deployments) { repositoryService.deleteDeployment(deployment.getId(), true); } // drop DB ((ProcessEngineImpl)engine).getProcessEngineConfiguration() .getCommandExecutorTxRequired() .execute(new Command<Void>() { public Void execute(CommandContext commandContext) { commandContext.getDbSqlSession().dbSchemaDrop(); return null; } }); engine.close(); }
Example #12
Source File: MultiTenancyDeploymentCmdsTenantCheckTest.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
@Test public void redeployForDifferentAuthenticatedTenantsDisabledTenantCheck() { Deployment deploymentOne = repositoryService.createDeployment() .addModelInstance("emptyProcess.bpmn", emptyProcess) .addModelInstance("startEndProcess.bpmn", startEndProcess) .tenantId(TENANT_ONE) .deploy(); identityService.setAuthentication("user", null, null); processEngineConfiguration.setTenantCheckEnabled(false); repositoryService.createDeployment() .addDeploymentResources(deploymentOne.getId()) .tenantId(TENANT_TWO) .deploy(); DeploymentQuery query = repositoryService.createDeploymentQuery(); assertThat(query.count(), is(2L)); assertThat(query.tenantIdIn(TENANT_ONE).count(), is(1L)); assertThat(query.tenantIdIn(TENANT_TWO).count(), is(1L)); }
Example #13
Source File: JobDefinitionCreationAndDeletionWithParseListenerTest.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
@Test public void testDeleteNonExistingAndCreateNewJobDefinitionWithParseListener() { //given String modelFileName = "jobCreationWithinParseListener.bpmn20.xml"; InputStream in = JobDefinitionCreationWithParseListenerTest.class.getResourceAsStream(modelFileName); DeploymentBuilder builder = engineRule.getRepositoryService().createDeployment().addInputStream(modelFileName, in); //when the asyncBefore is set to false and the asyncAfter to true in the parse listener Deployment deployment = builder.deploy(); engineRule.manageDeployment(deployment); //then there exists one job definition JobDefinitionQuery query = engineRule.getManagementService().createJobDefinitionQuery(); JobDefinition jobDef = query.singleResult(); assertNotNull(jobDef); assertEquals(jobDef.getProcessDefinitionKey(), "oneTaskProcess"); assertEquals(jobDef.getActivityId(), "servicetask1"); assertEquals(jobDef.getJobConfiguration(), MessageJobDeclaration.ASYNC_AFTER); }
Example #14
Source File: RedeploymentRegistrationTest.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
@Test public void registrationFoundFromPreviousDefinition() { // given ProcessApplicationReference reference = processApplication.getReference(); Deployment deployment1 = repositoryService .createDeployment(reference) .name(DEPLOYMENT_NAME) .addClasspathResource(resource1) .deploy(); // when Deployment deployment2 = repositoryService .createDeployment() .name(DEPLOYMENT_NAME) .addDeploymentResources(deployment1.getId()) .deploy(); String definitionId = getLatestDefinitionIdByKey(definitionKey1); // then assertEquals(reference, getProcessApplicationForDefinition(definitionId)); // and the reference is not cached assertNull(getProcessApplicationForDeployment(deployment2.getId())); }
Example #15
Source File: ProcessApplicationDeploymentTest.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
@Test public void testUnregisterProcessApplicationOnDeploymentDeletion() { // given a deployment with a process application registration Deployment deployment = testRule.deploy(repositoryService .createDeployment() .addModelInstance("process.bpmn", Bpmn.createExecutableProcess("foo").done())); // and a process application registration managementService.registerProcessApplication(deployment.getId(), processApplication.getReference()); // when deleting the deploymen repositoryService.deleteDeployment(deployment.getId(), true); // then the registration is removed assertNull(managementService.getProcessApplicationForDeployment(deployment.getId())); }
Example #16
Source File: JobDefinitionCreationWithParseListenerTest.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
@Test public void testCreateJobDefinitionWithParseListenerAndAsyncInXml() { //given the asyncBefore is set in the xml String modelFileName = "jobAsyncBeforeCreationWithinParseListener.bpmn20.xml"; InputStream in = JobDefinitionCreationWithParseListenerTest.class.getResourceAsStream(modelFileName); DeploymentBuilder builder = engineRule.getRepositoryService().createDeployment().addInputStream(modelFileName, in); //when the asyncBefore is set in the parse listener Deployment deployment = builder.deploy(); engineRule.manageDeployment(deployment); //then there exists only one job definition JobDefinitionQuery query = engineRule.getManagementService().createJobDefinitionQuery(); JobDefinition jobDef = query.singleResult(); assertNotNull(jobDef); assertEquals(jobDef.getProcessDefinitionKey(), "oneTaskProcess"); assertEquals(jobDef.getActivityId(), "servicetask1"); }
Example #17
Source File: UserOperationLogDeploymentTest.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
public void testDeleteDeploymentCascadingShouldKeepCreateUserOperationLog() { // given Deployment deployment = repositoryService .createDeployment() .name(DEPLOYMENT_NAME) .addModelInstance(RESOURCE_NAME, createProcessWithServiceTask(PROCESS_KEY)) .deploy(); UserOperationLogQuery query = historyService .createUserOperationLogQuery() .operationType(UserOperationLogEntry.OPERATION_TYPE_CREATE); assertEquals(1, query.count()); // when repositoryService.deleteDeployment(deployment.getId(), true); // then assertEquals(1, query.count()); }
Example #18
Source File: RedeploymentTest.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
@Test public void testRedeploySetDeploymentSourceProperty() { // given BpmnModelInstance model = createProcessWithServiceTask(PROCESS_KEY); Deployment deployment1 = testRule.deploy(repositoryService .createDeployment() .name(DEPLOYMENT_NAME) .source("my-deployment-source") .addModelInstance(RESOURCE_NAME, model)); assertEquals("my-deployment-source", deployment1.getSource()); // when Deployment deployment2 = testRule.deploy(repositoryService .createDeployment() .name(DEPLOYMENT_NAME) .addDeploymentResources(deployment1.getId()) .source("my-another-deployment-source")); // then assertNotNull(deployment2); assertEquals("my-another-deployment-source", deployment2.getSource()); }
Example #19
Source File: ProcessEngineTestRule.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
public ProcessDefinition deployForTenantAndGetDefinition(String tenant, String classpathResource) { Deployment deployment = deploy(createDeploymentBuilder().tenantId(tenant), Collections.<BpmnModelInstance>emptyList(), Collections.singletonList(classpathResource)); return processEngineRule.getRepositoryService() .createProcessDefinitionQuery() .deploymentId(deployment.getId()) .singleResult(); }
Example #20
Source File: MultiTenancyDeploymentCmdsTenantCheckTest.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
@Test public void failToGetResourceAsStreamByIdNoAuthenticatedTenant() { Deployment deployment = testRule.deployForTenant(TENANT_ONE, emptyProcess); Resource resource = repositoryService.getDeploymentResources(deployment.getId()).get(0); identityService.setAuthentication("user", null, null); // declare expected exception thrown.expect(ProcessEngineException.class); thrown.expectMessage("Cannot get the deployment"); repositoryService.getResourceAsStreamById(deployment.getId(), resource.getId()); }
Example #21
Source File: DeploymentResourceImpl.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
public DeploymentDto getDeployment() { RepositoryService repositoryService = getProcessEngine().getRepositoryService(); Deployment deployment = repositoryService.createDeploymentQuery().deploymentId(deploymentId).singleResult(); if (deployment == null) { throw new InvalidRequestException(Status.NOT_FOUND, "Deployment with id '" + deploymentId + "' does not exist"); } return DeploymentDto.fromDeployment(deployment); }
Example #22
Source File: MultiTenancyDeploymentCmdsTenantCheckTest.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
@Test public void getDeploymentResourceNamesDisabledTenantCheck() { Deployment deploymentOne = testRule.deployForTenant(TENANT_ONE, emptyProcess); Deployment deploymentTwo = testRule.deployForTenant(TENANT_TWO, startEndProcess); processEngineConfiguration.setTenantCheckEnabled(false); identityService.setAuthentication("user", null, null); List<String> deploymentResourceNames = repositoryService.getDeploymentResourceNames(deploymentOne.getId()); assertThat(deploymentResourceNames, hasSize(1)); deploymentResourceNames = repositoryService.getDeploymentResourceNames(deploymentTwo.getId()); assertThat(deploymentResourceNames, hasSize(1)); }
Example #23
Source File: RedeploymentRegistrationTest.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
@Test public void registrationFoundFromSameDeployment() { // given // first deployment ProcessApplicationReference reference1 = processApplication.getReference(); Deployment deployment1 = repositoryService .createDeployment(reference1) .name(DEPLOYMENT_NAME) .addClasspathResource(resource1) .addClasspathResource(resource2) .deploy(); // second deployment repositoryService .createDeployment() .name(DEPLOYMENT_NAME) .addClasspathResource(resource1) .deploy(); repositoryService .createDeployment() .name(DEPLOYMENT_NAME) .addClasspathResource(resource2) .deploy(); // when repositoryService .createDeployment() .name(DEPLOYMENT_NAME) .addDeploymentResources(deployment1.getId()) .deploy(); String firstDefinitionId = getLatestDefinitionIdByKey(definitionKey1); String secondDefinitionId = getLatestDefinitionIdByKey(definitionKey1); // then assertEquals(reference1, getProcessApplicationForDefinition(firstDefinitionId)); assertEquals(reference1, getProcessApplicationForDefinition(secondDefinitionId)); }
Example #24
Source File: SetJobRetriesBatchAuthorizationTest.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
@Override @Before public void deployProcesses() { Deployment deploy = testHelper.deploy(DEFINITION_XML); sourceDefinition = engineRule.getRepositoryService() .createProcessDefinitionQuery().deploymentId(deploy.getId()).singleResult(); processInstance = engineRule.getRuntimeService().startProcessInstanceById(sourceDefinition.getId()); processInstance2 = engineRule.getRuntimeService().startProcessInstanceById(sourceDefinition.getId()); }
Example #25
Source File: ProcessDefinitionQueryTest.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
@Test @org.camunda.bpm.engine.test.Deployment(resources={ "org/camunda/bpm/engine/test/api/repository/failingProcessCreateOneIncident.bpmn20.xml", "org/camunda/bpm/engine/test/api/repository/VersionTagTest.testParsingVersionTag.bpmn20.xml" }) public void testQueryOrderByVersionTag() { List<ProcessDefinition> processDefinitionList = repositoryService.createProcessDefinitionQuery() .versionTagLike("ver%tag%") .orderByVersionTag() .asc() .list(); assertThat(processDefinitionList.get(1).getVersionTag()).isEqualTo("ver_tag_2"); }
Example #26
Source File: JobDefinitionDeletionWithParseListenerTest.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
@Test public void testDeleteJobDefinitionWithParseListenerAndAsyncInXml() { //given the asyncBefore is set in the xml String modelFileName = "jobAsyncBeforeCreationWithinParseListener.bpmn20.xml"; InputStream in = JobDefinitionCreationWithParseListenerTest.class.getResourceAsStream(modelFileName); DeploymentBuilder builder = engineRule.getRepositoryService().createDeployment().addInputStream(modelFileName, in); //when the asyncBefore is set to false in the parse listener Deployment deployment = builder.deploy(); engineRule.manageDeployment(deployment); //then there exists no job definition JobDefinitionQuery query = engineRule.getManagementService().createJobDefinitionQuery(); assertNull(query.singleResult()); }
Example #27
Source File: ProcessDefinitionQueryTest.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
@Test @org.camunda.bpm.engine.test.Deployment(resources={"org/camunda/bpm/engine/test/api/repository/failingProcessCreateOneIncident.bpmn20.xml"}) public void testQueryByVersionTag() { assertThat(repositoryService.createProcessDefinitionQuery() .versionTag("ver_tag_2") .count()).isEqualTo(1); }
Example #28
Source File: MultiTenancyDeploymentCmdsTenantCheckTest.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
@Test public void getResourceAsStreamWithAuthenticatedTenant() { Deployment deployment = testRule.deployForTenant(TENANT_ONE, emptyProcess); Resource resource = repositoryService.getDeploymentResources(deployment.getId()).get(0); identityService.setAuthentication("user", null, Arrays.asList(TENANT_ONE)); InputStream inputStream = repositoryService.getResourceAsStream(deployment.getId(), resource.getName()); assertThat(inputStream, notNullValue()); }
Example #29
Source File: MultiTenancyDeploymentCmdsTenantCheckTest.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
@Test public void failToDeleteDeploymentNoAuthenticatedTenant() { Deployment deployment = testRule.deployForTenant(TENANT_ONE, emptyProcess); identityService.setAuthentication("user", null, null); // declare expected exception thrown.expect(ProcessEngineException.class); thrown.expectMessage("Cannot delete the deployment"); repositoryService.deleteDeployment(deployment.getId()); }
Example #30
Source File: ScriptTaskTest.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
@org.camunda.bpm.engine.test.Deployment public void testPreviousTaskShouldNotHandleException(){ try { runtimeService.startProcessInstanceByKey("process"); fail(); } // since the NVE extends the ProcessEngineException we have to handle it // separately catch (NullValueException nve) { fail("Shouldn't have received NullValueException"); } catch (ProcessEngineException e) { assertThat(e.getMessage(), containsString("Invalid format")); } }