@Test public void duplicateIdInDeployment() { String resourceName1 = "org/camunda/bpm/engine/test/dmn/deployment/DecisionDefinitionDeployerTest.testDuplicateIdInDeployment.dmn11.xml"; String resourceName2 = "org/camunda/bpm/engine/test/dmn/deployment/DecisionDefinitionDeployerTest.testDuplicateIdInDeployment2.dmn11.xml"; thrown.expect(ProcessEngineException.class); thrown.expectMessage("duplicateDecision"); repositoryService.createDeployment() .addClasspathResource(resourceName1) .addClasspathResource(resourceName2) .name("duplicateIds") .deploy(); }
@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(); }
public void run() { try { FileInputStream fis = new FileInputStream(new File(filename)); processEngine.getRepositoryService() .createDeployment() .addInputStream(filename, fis) .deploy(); } catch (FileNotFoundException e) { e.printStackTrace(); } }
protected static void deployModel(ProcessEngine processEngine, String deploymentName, String resourceName, BpmnModelInstance modelInstance) { processEngine.getRepositoryService() .createDeployment() .name(deploymentName) .addModelInstance(resourceName + ".bpmn20.xml", modelInstance) .deploy(); } }
public void run() { DeploymentBuilder deploymentbuilder = engine.getRepositoryService().createDeployment(); for(int i = 0; i < modelInstances.size(); i++) { deploymentbuilder.addModelInstance("process"+i+".bpmn", modelInstances.get(i)); } deploymentbuilder.deploy(); }
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); }
@Test public void deploymentWithDuplicateFilteringForSameTenant() { // given: a deployment with tenant ID createDeploymentBuilder() .enableDuplicateFiltering(false) .name("twice") .tenantId(TENANT_ONE) .deploy(); // if the same process is deployed with the same tenant ID again createDeploymentBuilder() .enableDuplicateFiltering(false) .name("twice") .tenantId(TENANT_ONE) .deploy(); // then it does not create a new deployment assertThat(repositoryService.createDeploymentQuery().count(), is(1L)); }
public void testDeployTwoProcessesWithDuplicateIdAtTheSameTime() { try { String bpmnResourceName = "org/camunda/bpm/engine/test/bpmn/deployment/BpmnDeploymentTest.testGetBpmnXmlFileThroughService.bpmn20.xml"; String bpmnResourceName2 = "org/camunda/bpm/engine/test/bpmn/deployment/BpmnDeploymentTest.testGetBpmnXmlFileThroughService2.bpmn20.xml"; repositoryService.createDeployment().enableDuplicateFiltering() .addClasspathResource(bpmnResourceName) .addClasspathResource(bpmnResourceName2) .name("duplicateAtTheSameTime").deploy(); fail(); } catch (Exception e) { // Verify that nothing is deployed assertEquals(0, repositoryService.createDeploymentQuery().count()); } }
@Test public void createDeploymentDisabledTenantCheck() { processEngineConfiguration.setTenantCheckEnabled(false); identityService.setAuthentication("user", null, null); repositoryService.createDeployment().addModelInstance("emptyProcessOne", emptyProcess).tenantId(TENANT_ONE).deploy(); repositoryService.createDeployment().addModelInstance("emptyProcessTwo", startEndProcess).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)); }
@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); }
private DeploymentBuilder extractDeploymentInformation(MultipartFormData payload) { DeploymentBuilder deploymentBuilder = getProcessEngine().getRepositoryService().createDeployment(); Set<String> partNames = payload.getPartNames(); for (String name : partNames) { FormPart part = payload.getNamedPart(name); if (!RESERVED_KEYWORDS.contains(name)) { deploymentBuilder.addInputStream(part.getFileName(), new ByteArrayInputStream(part.getBinaryContent())); } } FormPart deploymentName = payload.getNamedPart(DEPLOYMENT_NAME); if (deploymentName != null) { deploymentBuilder.name(deploymentName.getTextContent()); } FormPart deploymentSource = payload.getNamedPart(DEPLOYMENT_SOURCE); if (deploymentSource != null) { deploymentBuilder.source(deploymentSource.getTextContent()); } FormPart deploymentTenantId = payload.getNamedPart(TENANT_ID); if (deploymentTenantId != null) { deploymentBuilder.tenantId(deploymentTenantId.getTextContent()); } extractDuplicateFilteringForDeployment(payload, deploymentBuilder); return deploymentBuilder; }
@Before public void setUpRuntimeData() { mockRepositoryService = mock(RepositoryService.class); when(processEngine.getRepositoryService()).thenReturn(mockRepositoryService); mockDeployment = MockProvider.createMockDeployment(); mockDeploymentWithDefinitions = MockProvider.createMockDeploymentWithDefinitions(); mockDeploymentQuery = mock(DeploymentQuery.class); when(mockDeploymentQuery.deploymentId(EXAMPLE_DEPLOYMENT_ID)).thenReturn(mockDeploymentQuery); when(mockDeploymentQuery.singleResult()).thenReturn(mockDeployment); when(mockRepositoryService.createDeploymentQuery()).thenReturn(mockDeploymentQuery); mockDeploymentResources = MockProvider.createMockDeploymentResources(); when(mockRepositoryService.getDeploymentResources(eq(EXAMPLE_DEPLOYMENT_ID))).thenReturn(mockDeploymentResources); mockDeploymentResource = MockProvider.createMockDeploymentResource(); when(mockRepositoryService.getResourceAsStreamById(eq(EXAMPLE_DEPLOYMENT_ID), eq(EXAMPLE_DEPLOYMENT_RESOURCE_ID))).thenReturn(createMockDeploymentResourceBpmnData()); mockDeploymentBuilder = mock(DeploymentBuilder.class); when(mockRepositoryService.createDeployment()).thenReturn(mockDeploymentBuilder); when(mockDeploymentBuilder.addInputStream(anyString(), any(InputStream.class))).thenReturn(mockDeploymentBuilder); when(mockDeploymentBuilder.addDeploymentResourcesById(anyString(), anyListOf(String.class))).thenReturn(mockDeploymentBuilder); when(mockDeploymentBuilder.addDeploymentResourcesByName(anyString(), anyListOf(String.class))).thenReturn(mockDeploymentBuilder); when(mockDeploymentBuilder.source(anyString())).thenReturn(mockDeploymentBuilder); when(mockDeploymentBuilder.tenantId(anyString())).thenReturn(mockDeploymentBuilder); when(mockDeploymentBuilder.getResourceNames()).thenReturn(resourceNames); when(mockDeploymentBuilder.deployWithResult()).thenReturn(mockDeploymentWithDefinitions); }
public void testPropagateTenantIdToCandidateStarterUser() { // when org.camunda.bpm.engine.repository.Deployment deployment = repositoryService.createDeployment() .addClasspathResource(CANDIDATE_STARTER_USER) .tenantId(TENANT_ONE) .deploy(); // then List<HistoricIdentityLinkLog> historicLinks = historyService.createHistoricIdentityLinkLogQuery().list(); assertEquals(historicLinks.size(), 1); HistoricIdentityLinkLog historicLink = historicLinks.get(0); assertNotNull(historicLink.getTenantId()); assertEquals(TENANT_ONE, historicLink.getTenantId()); repositoryService.deleteDeployment(deployment.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())); }
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 testCreateCompleteCmmnDeployment() throws Exception { // given DeploymentWithDefinitions mockDeployment = MockProvider.createMockDeploymentWithDefinitions(); when(mockDeployment.getDeployedDecisionDefinitions()).thenReturn(null); when(mockDeployment.getDeployedProcessDefinitions()).thenReturn(null); when(mockDeployment.getDeployedDecisionRequirementsDefinitions()).thenReturn(null); when(mockDeploymentBuilder.deployWithResult()).thenReturn(mockDeployment); // when resourceNames.addAll(Arrays.asList("data", "more-data")); Response response = given() .multiPart("data", "unspecified", createMockDeploymentResourceByteData()) .multiPart("more-data", "unspecified", createMockDeploymentResourceBpmnData()) .multiPart("deployment-name", MockProvider.EXAMPLE_DEPLOYMENT_ID) .multiPart("enable-duplicate-filtering", "true") .expect() .statusCode(Status.OK.getStatusCode()) .when() .post(CREATE_DEPLOYMENT_URL); // then verifyCreatedCmmnDeployment(mockDeployment, response); verify(mockDeploymentBuilder).name(MockProvider.EXAMPLE_DEPLOYMENT_ID); verify(mockDeploymentBuilder).enableDuplicateFiltering(false); }
@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); } }
public void testDeployEmptyCaseDefinition() throws Exception { // given empty case model final CmmnModelInstance modelInstance = Cmmn.createEmptyModel(); org.camunda.bpm.model.cmmn.instance.Definitions definitions = modelInstance.newInstance(org.camunda.bpm.model.cmmn.instance.Definitions.class); definitions.setTargetNamespace("http://camunda.org/examples"); modelInstance.setDefinitions(definitions); // when case model is deployed DeploymentWithDefinitions deployment = repositoryService.createDeployment() .addModelInstance("foo.cmmn", modelInstance).deployWithResult(); deploymentIds.add(deployment.getId()); // then no case definition is deployed assertNull(deployment.getDeployedCaseDefinitions()); // and there exist not persisted case definition assertNull(repositoryService.createCaseDefinitionQuery().caseDefinitionResourceName("foo.cmmn").singleResult()); }
@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); }