protected DeploymentBuilder addRedeploymentResources(DeploymentBuilder builder, RedeploymentDto redeployment) { builder.source(redeployment.getSource()); List<String> resourceIds = redeployment.getResourceIds(); List<String> resourceNames = redeployment.getResourceNames(); boolean isResourceIdListEmpty = resourceIds == null || resourceIds.isEmpty(); boolean isResourceNameListEmpty = resourceNames == null || resourceNames.isEmpty(); if (isResourceIdListEmpty && isResourceNameListEmpty) { builder.addDeploymentResources(deploymentId); } else { if (!isResourceIdListEmpty) { builder.addDeploymentResourcesById(deploymentId, resourceIds); } if (!isResourceNameListEmpty) { builder.addDeploymentResourcesByName(deploymentId, resourceNames); } } return builder; }
@Test public void testRedeployDeploymentWithoutTenantId() { when(mockDeployment.getTenantId()).thenReturn(null); Response response = given() .pathParam("id", MockProvider.EXAMPLE_DEPLOYMENT_ID) .contentType(POST_JSON_CONTENT_TYPE) .expect() .statusCode(Status.OK.getStatusCode()) .contentType(ContentType.JSON) .when() .post(REDEPLOY_DEPLOYMENT_URL); verify(mockDeploymentBuilder).addDeploymentResources(eq(MockProvider.EXAMPLE_DEPLOYMENT_ID)); verify(mockDeploymentBuilder, never()).tenantId(any(String.class)); verify(mockDeploymentBuilder).deployWithResult(); verifyDeployment(mockDeployment, response); }
protected DeploymentBuilder addRedeploymentResources(DeploymentBuilder builder, RedeploymentDto redeployment) { builder.source(redeployment.getSource()); List<String> resourceIds = redeployment.getResourceIds(); List<String> resourceNames = redeployment.getResourceNames(); boolean isResourceIdListEmpty = resourceIds == null || resourceIds.isEmpty(); boolean isResourceNameListEmpty = resourceNames == null || resourceNames.isEmpty(); if (isResourceIdListEmpty && isResourceNameListEmpty) { builder.addDeploymentResources(deploymentId); } else { if (!isResourceIdListEmpty) { builder.addDeploymentResourcesById(deploymentId, resourceIds); } if (!isResourceNameListEmpty) { builder.addDeploymentResourcesByName(deploymentId, resourceNames); } } return builder; }
@Test public void testRedeployDeploymentWithTenantId() { when(mockDeployment.getTenantId()).thenReturn(MockProvider.EXAMPLE_TENANT_ID); Response response = given() .pathParam("id", MockProvider.EXAMPLE_DEPLOYMENT_ID) .contentType(POST_JSON_CONTENT_TYPE) .expect() .statusCode(Status.OK.getStatusCode()) .contentType(ContentType.JSON) .when() .post(REDEPLOY_DEPLOYMENT_URL); verify(mockDeploymentBuilder).addDeploymentResources(eq(MockProvider.EXAMPLE_DEPLOYMENT_ID)); verify(mockDeploymentBuilder).tenantId(eq(MockProvider.EXAMPLE_TENANT_ID)); verify(mockDeploymentBuilder).deployWithResult(); verifyDeployment(mockDeployment, response); }
@Test public void testRedeployDeploymentWithoutRequestBody() { Response response = given() .pathParam("id", MockProvider.EXAMPLE_DEPLOYMENT_ID) .contentType(POST_JSON_CONTENT_TYPE) .expect() .statusCode(Status.OK.getStatusCode()) .contentType(ContentType.JSON) .when() .post(REDEPLOY_DEPLOYMENT_URL); verify(mockDeploymentBuilder).addDeploymentResources(eq(MockProvider.EXAMPLE_DEPLOYMENT_ID)); verify(mockDeploymentBuilder).nameFromDeployment(eq(MockProvider.EXAMPLE_DEPLOYMENT_ID)); verify(mockDeploymentBuilder, never()).addDeploymentResourceById(anyString(), anyString()); verify(mockDeploymentBuilder, never()).addDeploymentResourcesById(anyString(), anyListOf(String.class)); verify(mockDeploymentBuilder, never()).addDeploymentResourceByName(anyString(), anyString()); verify(mockDeploymentBuilder, never()).addDeploymentResourcesByName(anyString(), anyListOf(String.class)); verify(mockDeploymentBuilder, never()).source(anyString()); verify(mockDeploymentBuilder).deployWithResult(); verifyDeployment(mockDeployment, response); }
protected DeploymentWithDefinitions tryToRedeploy(RedeploymentDto redeployment) { RepositoryService repositoryService = getProcessEngine().getRepositoryService(); DeploymentBuilder builder = repositoryService.createDeployment(); builder.nameFromDeployment(deploymentId); String tenantId = getDeployment().getTenantId(); if (tenantId != null) { builder.tenantId(tenantId); } if (redeployment != null) { builder = addRedeploymentResources(builder, redeployment); } else { builder.addDeploymentResources(deploymentId); } return builder.deployWithResult(); }
@Test public void testRedeployDeploymentEmptyRequestBody() { Response response = given() .pathParam("id", MockProvider.EXAMPLE_DEPLOYMENT_ID) .contentType(POST_JSON_CONTENT_TYPE) .body("{}") .expect() .statusCode(Status.OK.getStatusCode()) .contentType(ContentType.JSON) .when() .post(REDEPLOY_DEPLOYMENT_URL); verify(mockDeploymentBuilder).addDeploymentResources(eq(MockProvider.EXAMPLE_DEPLOYMENT_ID)); verify(mockDeploymentBuilder).nameFromDeployment(eq(MockProvider.EXAMPLE_DEPLOYMENT_ID)); verify(mockDeploymentBuilder, never()).addDeploymentResourceById(anyString(), anyString()); verify(mockDeploymentBuilder, never()).addDeploymentResourcesById(eq(MockProvider.EXAMPLE_DEPLOYMENT_ID), anyListOf(String.class)); verify(mockDeploymentBuilder, never()).addDeploymentResourceByName(anyString(), anyString()); verify(mockDeploymentBuilder, never()).addDeploymentResourcesByName(eq(MockProvider.EXAMPLE_DEPLOYMENT_ID), anyListOf(String.class)); verify(mockDeploymentBuilder).source(null); verify(mockDeploymentBuilder).deployWithResult(); verifyDeployment(mockDeployment, response); }
protected DeploymentWithDefinitions tryToRedeploy(RedeploymentDto redeployment) { RepositoryService repositoryService = getProcessEngine().getRepositoryService(); DeploymentBuilder builder = repositoryService.createDeployment(); builder.nameFromDeployment(deploymentId); String tenantId = getDeployment().getTenantId(); if (tenantId != null) { builder.tenantId(tenantId); } if (redeployment != null) { builder = addRedeploymentResources(builder, redeployment); } else { builder.addDeploymentResources(deploymentId); } return builder.deployWithResult(); }
@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)); }
@Test public void redeployForDifferentAuthenticatedTenants() { Deployment deploymentOne = repositoryService.createDeployment() .addModelInstance("emptyProcess.bpmn", emptyProcess) .addModelInstance("startEndProcess.bpmn", startEndProcess) .tenantId(TENANT_ONE) .deploy(); identityService.setAuthentication("user", null, Arrays.asList(TENANT_TWO)); thrown.expect(ProcessEngineException.class); thrown.expectMessage("Cannot get the deployment"); repositoryService.createDeployment() .addDeploymentResources(deploymentOne.getId()) .tenantId(TENANT_TWO) .deploy(); }
@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)); }
public void testRedeployDeploymentDifferentName() { // given BpmnModelInstance model = createProcessWithServiceTask(PROCESS_KEY); Deployment deployment1 = repositoryService .createDeployment() .name(DEPLOYMENT_NAME) .addModelInstance(RESOURCE_NAME, model) .deploy(); assertEquals(DEPLOYMENT_NAME, deployment1.getName()); // when Deployment deployment2 = repositoryService .createDeployment() .name("my-another-deployment") .addDeploymentResources(deployment1.getId()) .deploy(); // then assertNotNull(deployment2); assertFalse(deployment1.getName().equals(deployment2.getName())); deleteDeployments(deployment1, deployment2); }
@Test @OperateOnDeployment("clientDeployment") public void testRedeployClassloading() { // given org.camunda.bpm.engine.repository.Deployment deployment = repositoryService.createDeploymentQuery().singleResult(); org.camunda.bpm.engine.repository.Deployment deployment2 = repositoryService .createDeployment() .nameFromDeployment(deployment.getId()) .addDeploymentResources(deployment.getId()) .deploy(); // when String id = runtimeService.startProcessInstanceByKey("process").getId(); // then Assert.assertTrue((Boolean) runtimeService.getVariable(id, "executed")); repositoryService.deleteDeployment(deployment2.getId(), true); } }
@Test public void registrationNotFoundByDeploymentId() { // given ProcessApplicationReference reference = processApplication.getReference(); Deployment deployment1 = repositoryService .createDeployment(reference) .name(DEPLOYMENT_NAME) .addClasspathResource(resource1) .deploy(); assertEquals(reference, getProcessApplicationForDeployment(deployment1.getId())); // when Deployment deployment2 = repositoryService .createDeployment() .name(DEPLOYMENT_NAME) .addDeploymentResources(deployment1.getId()) .deploy(); // then assertNull(getProcessApplicationForDeployment(deployment2.getId())); }
public void testRedeployDeploymentSourcePropertyNotSet() { // given BpmnModelInstance model = createProcessWithServiceTask(PROCESS_KEY); Deployment deployment1 = repositoryService .createDeployment() .name(DEPLOYMENT_NAME) .source("my-deployment-source") .addModelInstance(RESOURCE_NAME, model) .deploy(); assertEquals("my-deployment-source", deployment1.getSource()); // when Deployment deployment2 = repositoryService .createDeployment() .name(DEPLOYMENT_NAME) .addDeploymentResources(deployment1.getId()) .deploy(); // then assertNotNull(deployment2); assertNull(deployment2.getSource()); deleteDeployments(deployment1, deployment2); }
public void testRedeployDeploymentName() { // given BpmnModelInstance model = createProcessWithServiceTask(PROCESS_KEY); Deployment deployment1 = repositoryService .createDeployment() .name(DEPLOYMENT_NAME) .addModelInstance(RESOURCE_NAME, model) .deploy(); assertEquals(DEPLOYMENT_NAME, deployment1.getName()); // when Deployment deployment2 = repositoryService .createDeployment() .nameFromDeployment(deployment1.getId()) .addDeploymentResources(deployment1.getId()) .deploy(); // then assertNotNull(deployment2); assertEquals(deployment1.getName(), deployment2.getName()); deleteDeployments(deployment1, deployment2); }
public void testRedeploySetDeploymentSourceProperty() { // given BpmnModelInstance model = createProcessWithServiceTask(PROCESS_KEY); Deployment deployment1 = repositoryService .createDeployment() .name(DEPLOYMENT_NAME) .source("my-deployment-source") .addModelInstance(RESOURCE_NAME, model) .deploy(); assertEquals("my-deployment-source", deployment1.getSource()); // when Deployment deployment2 = repositoryService .createDeployment() .name(DEPLOYMENT_NAME) .addDeploymentResources(deployment1.getId()) .source("my-another-deployment-source") .deploy(); // then assertNotNull(deployment2); assertEquals("my-another-deployment-source", deployment2.getSource()); deleteDeployments(deployment1, deployment2); }
@Test public void definitionOnePreviousDeploymentWithPA() { // given MyEmbeddedProcessApplication application = new MyEmbeddedProcessApplication(); // first deployment Deployment deployment1 = repositoryService .createDeployment(application.getReference()) .name(DEPLOYMENT_NAME) .addClasspathResource(resource1) .deploy(); // second deployment Deployment deployment2 = repositoryService .createDeployment() .name(DEPLOYMENT_NAME) .addDeploymentResources(deployment1.getId()) .deploy(); assertEquals(2, testProvider.countDefinitionsByKey(definitionKey1)); // when testProvider.createInstanceByDefinitionKey(definitionKey1); // then assertTrue(application.isCalled()); deleteDeployments(deployment1, deployment2); }
@Test public void testDeleteProcessDefinitionAndRedeploy() { // given a deployment with two process definitions in one xml model file deployment = repositoryService.createDeployment() .addClasspathResource("org/camunda/bpm/engine/test/repository/twoProcesses.bpmn20.xml") .deploy(); ProcessDefinition processDefinitionOne = repositoryService.createProcessDefinitionQuery().processDefinitionKey("one").singleResult(); //one is deleted from the deployment repositoryService.deleteProcessDefinition(processDefinitionOne.getId()); //when the process definition is redeployed Deployment deployment2 = repositoryService.createDeployment() .name(DEPLOYMENT_NAME) .addDeploymentResources(deployment.getId()) .deploy(); //then there should exist three process definitions //two of the redeployment and the remaining one assertEquals(3, repositoryService.createProcessDefinitionQuery().count()); //clean up repositoryService.deleteDeployment(deployment2.getId(), true); }
public void testRedeployEnableDuplcateChecking() { // given ProcessDefinitionQuery query = repositoryService.createProcessDefinitionQuery(); BpmnModelInstance model1 = createProcessWithServiceTask(PROCESS_1_KEY); Deployment deployment1 = repositoryService .createDeployment() .name(DEPLOYMENT_NAME) .addModelInstance(RESOURCE_1_NAME, model1) .deploy(); verifyQueryResults(query.processDefinitionKey(PROCESS_1_KEY), 1); // when Deployment deployment2 = repositoryService .createDeployment() .name(DEPLOYMENT_NAME) .addDeploymentResources(deployment1.getId()) .enableDuplicateFiltering(true) .deploy(); assertEquals(deployment1.getId(), deployment2.getId()); verifyQueryResults(query.processDefinitionKey(PROCESS_1_KEY), 1); deleteDeployments(deployment1); }