public void testPartialChangesResumePreviousVersionByDeploymentName() { BpmnModelInstance model1 = Bpmn.createExecutableProcess("process1").done(); BpmnModelInstance model2 = Bpmn.createExecutableProcess("process2").done(); // create initial deployment ProcessApplicationDeployment deployment1 = repositoryService.createDeployment(processApplication.getReference()) .name("deployment") .addModelInstance("process1.bpmn20.xml", model1) .deploy(); ProcessApplicationDeployment deployment2 = repositoryService.createDeployment(processApplication.getReference()) .name("deployment") .enableDuplicateFiltering(true) .resumePreviousVersions() .resumePreviousVersionsBy(ResumePreviousBy.RESUME_BY_DEPLOYMENT_NAME) .addModelInstance("process1.bpmn20.xml", model1) .addModelInstance("process2.bpmn20.xml", model2) .deploy(); ProcessApplicationRegistration registration = deployment2.getProcessApplicationRegistration(); assertEquals(2, registration.getDeploymentIds().size()); deleteDeployments(deployment1, deployment2); }
deploymentName = processApplication.getName(); deploymentBuilder.name(deploymentName); deploymentBuilder.tenantId(tenantId); deploymentBuilder.enableDuplicateFiltering(PropertyHelper.getBooleanProperty(processArchive.getProperties(), ProcessArchiveXml.PROP_IS_DEPLOY_CHANGED_ONLY, false)); deploymentBuilder.addInputStream(deploymentResource.getKey(), new ByteArrayInputStream(deploymentResource.getValue())); Collection<String> deploymentResourceNames = deploymentBuilder.getResourceNames(); if(!deploymentResourceNames.isEmpty()) { deployment = deploymentBuilder.deploy();
protected void enableResumingOfPreviousVersions(ProcessApplicationDeploymentBuilder deploymentBuilder) throws IllegalArgumentException { deploymentBuilder.resumePreviousVersions(); String resumePreviousBy = processArchive.getProperties().get(ProcessArchiveXml.PROP_RESUME_PREVIOUS_BY); if (resumePreviousBy == null) { deploymentBuilder.resumePreviousVersionsBy(ResumePreviousBy.RESUME_BY_PROCESS_DEFINITION_KEY); } else if (isValidValueForResumePreviousBy(resumePreviousBy)) { deploymentBuilder.resumePreviousVersionsBy(resumePreviousBy); } else { StringBuilder b = new StringBuilder(); b.append("Illegal value passed for property ").append(ProcessArchiveXml.PROP_RESUME_PREVIOUS_BY); b.append(". Value was ").append(resumePreviousBy); b.append(" expected ").append(ResumePreviousBy.RESUME_BY_DEPLOYMENT_NAME); b.append(" or ").append(ResumePreviousBy.RESUME_BY_PROCESS_DEFINITION_KEY).append("."); throw new IllegalArgumentException(b.toString()); } }
public void testProcessApplicationDeploymentNoChanges() { // create initial deployment ProcessApplicationDeployment deployment = repositoryService.createDeployment(processApplication.getReference()) .name("deployment") .addClasspathResource("org/camunda/bpm/engine/test/api/repository/version1.bpmn20.xml") .deploy(); assertThatOneProcessIsDeployed(); // deploy update with no changes: deployment = repositoryService.createDeployment(processApplication.getReference()) .name("deployment") .enableDuplicateFiltering(false) .addClasspathResource("org/camunda/bpm/engine/test/api/repository/version1.bpmn20.xml") .deploy(); // no changes assertThatOneProcessIsDeployed(); ProcessApplicationRegistration registration = deployment.getProcessApplicationRegistration(); Set<String> deploymentIds = registration.getDeploymentIds(); assertEquals(1, deploymentIds.size()); assertEquals(processEngine.getName(), registration.getProcessEngineName()); deleteDeployments(deployment); }
@Test public void registrationFoundFromDifferentDeployment() { // given // first deployment ProcessApplicationReference reference1 = processApplication.getReference(); Deployment deployment1 = repositoryService .createDeployment(reference1) .name(DEPLOYMENT_NAME) .addClasspathResource(resource1) .addClasspathResource(resource2) .deploy(); // second deployment ProcessApplicationReference reference2 = processApplication.getReference(); repositoryService .createDeployment(reference2) .name(DEPLOYMENT_NAME) .addClasspathResource(resource1) .deploy(); // when repositoryService .createDeployment() .name(DEPLOYMENT_NAME) .addDeploymentResources(deployment1.getId()) .deploy(); String firstDefinitionId = getLatestDefinitionIdByKey(definitionKey1); String secondDefinitionId = getLatestDefinitionIdByKey(definitionKey2); // then assertEquals(reference2, getProcessApplicationForDefinition(firstDefinitionId)); assertEquals(reference1, getProcessApplicationForDefinition(secondDefinitionId)); }
@Test public void registrationFoundByDeploymentId() { // given ProcessApplicationReference reference1 = processApplication.getReference(); Deployment deployment1 = repositoryService .createDeployment(reference1) .name(DEPLOYMENT_NAME) .addClasspathResource(resource1) .deploy(); assertEquals(reference1, getProcessApplicationForDeployment(deployment1.getId())); // when ProcessApplicationReference reference2 = processApplication.getReference(); Deployment deployment2 = repositoryService .createDeployment(reference2) .name(DEPLOYMENT_NAME) .addDeploymentResources(deployment1.getId()) .deploy(); // then assertEquals(reference2, getProcessApplicationForDeployment(deployment2.getId())); }
public void testDefaultDeploymentSource() { String key = "process"; BpmnModelInstance model = Bpmn.createExecutableProcess(key).done(); DeploymentQuery deploymentQuery = repositoryService.createDeploymentQuery(); Deployment deployment = repositoryService .createDeployment(processApplication.getReference()) .name("first-deployment-with-a-source") .addModelInstance("process.bpmn", model) .deploy(); assertEquals(ProcessApplicationDeployment.PROCESS_APPLICATION_DEPLOYMENT_SOURCE, deploymentQuery.deploymentName("first-deployment-with-a-source").singleResult().getSource()); deleteDeployments(deployment); }
repositoryService .createDeployment(reference2) .name(DEPLOYMENT_NAME) .addDeploymentResources(deployment1.getId()) .deploy();
public void testEnabledPaEnvScriptCaching() { // given EmbeddedProcessApplication processApplication = new EmbeddedProcessApplication(); ProcessApplicationDeployment deployment = repositoryService.createDeployment(processApplication.getReference()) .addClasspathResource(PROCESS_PATH) .deploy(); // when executeScript(processApplication); // then Map<String, List<ExecutableScript>> environmentScripts = processApplication.getEnvironmentScripts(); assertNotNull(environmentScripts); List<ExecutableScript> groovyEnvScripts = environmentScripts.get(SCRIPT_LANGUAGE); assertNotNull(groovyEnvScripts); assertFalse(groovyEnvScripts.isEmpty()); assertEquals(processEngineConfiguration.getEnvScriptResolvers().size(), groovyEnvScripts.size()); repositoryService.deleteDeployment(deployment.getId(), true); }
public void testEmptyDeployment() { try { repositoryService .createDeployment(processApplication.getReference()) .deploy(); fail("it should not be possible to deploy without deployment resources"); } catch (NotValidException e) { // expected } try { repositoryService .createDeployment() .deploy(); fail("it should not be possible to deploy without deployment resources"); } catch (NotValidException e) { // expected } }
public void testProcessApplicationDeploymentResumePreviousVersionsByDeploymentName() { // create initial deployment ProcessApplicationDeployment deployment1 = repositoryService.createDeployment(processApplication.getReference()) .name("deployment") .addClasspathResource("org/camunda/bpm/engine/test/api/repository/version1.bpmn20.xml") .deploy(); assertThatOneProcessIsDeployed(); // deploy update with changes: ProcessApplicationDeployment deployment2 = repositoryService.createDeployment(processApplication.getReference()) .name("deployment") .enableDuplicateFiltering(false) .resumePreviousVersions() .resumePreviousVersionsBy(ResumePreviousBy.RESUME_BY_DEPLOYMENT_NAME) .addClasspathResource("org/camunda/bpm/engine/test/api/repository/version2.bpmn20.xml") .deploy(); List<ProcessDefinition> processDefinitions = repositoryService.createProcessDefinitionQuery().orderByProcessDefinitionVersion().asc().list(); // now there are 2 process definitions deployed assertEquals(1, processDefinitions.get(0).getVersion()); assertEquals(2, processDefinitions.get(1).getVersion()); // old deployment was resumed ProcessApplicationRegistration registration = deployment2.getProcessApplicationRegistration(); Set<String> deploymentIds = registration.getDeploymentIds(); assertEquals(2, deploymentIds.size()); assertEquals(processEngine.getName(), registration.getProcessEngineName()); deleteDeployments(deployment1, deployment2); }
@Test public void registrationFoundFromDifferentDeployments() { // given // first deployment ProcessApplicationReference reference1 = processApplication.getReference(); Deployment deployment1 = repositoryService .createDeployment(reference1) .name(DEPLOYMENT_NAME + "-1") .addClasspathResource(resource1) .deploy(); // second deployment ProcessApplicationReference reference2 = processApplication.getReference(); repositoryService .createDeployment(reference2) .name(DEPLOYMENT_NAME + "-2") .addClasspathResource(resource2) .deploy(); // when repositoryService .createDeployment() .name(DEPLOYMENT_NAME) .addDeploymentResources(deployment1.getId()) .deploy(); String firstDefinitionId = getLatestDefinitionIdByKey(definitionKey1); String secondDefinitionId = getLatestDefinitionIdByKey(definitionKey2); // then assertEquals(reference1, getProcessApplicationForDefinition(firstDefinitionId)); assertEquals(reference2, getProcessApplicationForDefinition(secondDefinitionId)); }
protected void enableResumingOfPreviousVersions(ProcessApplicationDeploymentBuilder deploymentBuilder) throws IllegalArgumentException { deploymentBuilder.resumePreviousVersions(); String resumePreviousBy = processArchive.getProperties().get(ProcessArchiveXml.PROP_RESUME_PREVIOUS_BY); if (resumePreviousBy == null) { deploymentBuilder.resumePreviousVersionsBy(ResumePreviousBy.RESUME_BY_PROCESS_DEFINITION_KEY); } else if (isValidValueForResumePreviousBy(resumePreviousBy)) { deploymentBuilder.resumePreviousVersionsBy(resumePreviousBy); } else { StringBuilder b = new StringBuilder(); b.append("Illegal value passed for property ").append(ProcessArchiveXml.PROP_RESUME_PREVIOUS_BY); b.append(". Value was ").append(resumePreviousBy); b.append(" expected ").append(ResumePreviousBy.RESUME_BY_DEPLOYMENT_NAME); b.append(" or ").append(ResumePreviousBy.RESUME_BY_PROCESS_DEFINITION_KEY).append("."); throw new IllegalArgumentException(b.toString()); } }
@Test public void registrationFoundFromLatestDeployment() { // given ProcessApplicationReference reference1 = processApplication.getReference(); Deployment deployment1 = repositoryService .createDeployment(reference1) .name(DEPLOYMENT_NAME) .addClasspathResource(resource1) .deploy(); // when ProcessApplicationReference reference2 = processApplication.getReference(); Deployment deployment2 = repositoryService .createDeployment(reference2) .name(DEPLOYMENT_NAME) .addDeploymentResources(deployment1.getId()) .deploy(); String definitionId = getLatestDefinitionIdByKey(definitionKey1); // then assertEquals(reference2, getProcessApplicationForDefinition(definitionId)); assertEquals(reference2, getProcessApplicationForDeployment(deployment2.getId())); }
public void testCreateDeploymentPa() { // given EmbeddedProcessApplication application = new EmbeddedProcessApplication(); // when Deployment deployment = repositoryService .createDeployment(application.getReference()) .name(DEPLOYMENT_NAME) .addModelInstance(RESOURCE_NAME, createProcessWithServiceTask(PROCESS_KEY)) .deploy(); // then UserOperationLogEntry userOperationLogEntry = historyService.createUserOperationLogQuery().singleResult(); assertNotNull(userOperationLogEntry); assertEquals(EntityTypes.DEPLOYMENT, userOperationLogEntry.getEntityType()); assertEquals(deployment.getId(), userOperationLogEntry.getDeploymentId()); assertEquals(UserOperationLogEntry.OPERATION_TYPE_CREATE, userOperationLogEntry.getOperationType()); assertEquals("duplicateFilterEnabled", userOperationLogEntry.getProperty()); assertNull(userOperationLogEntry.getOrgValue()); assertFalse(Boolean.valueOf(userOperationLogEntry.getNewValue())); assertEquals(USER_ID, userOperationLogEntry.getUserId()); assertNull(userOperationLogEntry.getJobDefinitionId()); assertNull(userOperationLogEntry.getProcessInstanceId()); assertNull(userOperationLogEntry.getProcessDefinitionId()); assertNull(userOperationLogEntry.getProcessDefinitionKey()); assertNull(userOperationLogEntry.getCaseInstanceId()); assertNull(userOperationLogEntry.getCaseDefinitionId()); }
Deployment deployment2 = repositoryService .createDeployment(reference2) .name(DEPLOYMENT_NAME) .addDeploymentResources(deployment1.getId()) .deploy();
public void testSimpleProcessApplicationDeployment() { ProcessApplicationDeployment deployment = repositoryService.createDeployment(processApplication.getReference()) .addClasspathResource("org/camunda/bpm/engine/test/api/repository/version1.bpmn20.xml") .deploy(); // process is deployed: assertThatOneProcessIsDeployed(); // registration was performed: ProcessApplicationRegistration registration = deployment.getProcessApplicationRegistration(); Set<String> deploymentIds = registration.getDeploymentIds(); assertEquals(1, deploymentIds.size()); assertEquals(processEngine.getName(), registration.getProcessEngineName()); deleteDeployments(deployment); }
public void testPartialChangesResumePreviousVersion() { BpmnModelInstance model1 = Bpmn.createExecutableProcess("process1").done(); BpmnModelInstance model2 = Bpmn.createExecutableProcess("process2").done(); // create initial deployment ProcessApplicationDeployment deployment1 = repositoryService.createDeployment(processApplication.getReference()) .name("deployment") .addModelInstance("process1.bpmn20.xml", model1) .deploy(); ProcessApplicationDeployment deployment2 = repositoryService.createDeployment(processApplication.getReference()) .name("deployment") .enableDuplicateFiltering(true) .resumePreviousVersions() .addModelInstance("process1.bpmn20.xml", model1) .addModelInstance("process2.bpmn20.xml", model2) .deploy(); ProcessApplicationRegistration registration = deployment2.getProcessApplicationRegistration(); assertEquals(2, registration.getDeploymentIds().size()); deleteDeployments(deployment1, deployment2); }
public void testProcessApplicationDeploymentResumePreviousVersions() { // create initial deployment ProcessApplicationDeployment deployment1 = repositoryService.createDeployment(processApplication.getReference()) .name("deployment") .addClasspathResource("org/camunda/bpm/engine/test/api/repository/version1.bpmn20.xml") .deploy(); assertThatOneProcessIsDeployed(); // deploy update with changes: ProcessApplicationDeployment deployment2 = repositoryService.createDeployment(processApplication.getReference()) .name("deployment") .enableDuplicateFiltering(false) .resumePreviousVersions() .addClasspathResource("org/camunda/bpm/engine/test/api/repository/version2.bpmn20.xml") .deploy(); List<ProcessDefinition> processDefinitions = repositoryService.createProcessDefinitionQuery().orderByProcessDefinitionVersion().asc().list(); // now there are 2 process definitions deployed assertEquals(1, processDefinitions.get(0).getVersion()); assertEquals(2, processDefinitions.get(1).getVersion()); // old deployment was resumed ProcessApplicationRegistration registration = deployment2.getProcessApplicationRegistration(); Set<String> deploymentIds = registration.getDeploymentIds(); assertEquals(2, deploymentIds.size()); assertEquals(processEngine.getName(), registration.getProcessEngineName()); deleteDeployments(deployment1, deployment2); }
deploymentName = processApplication.getName(); deploymentBuilder.name(deploymentName); deploymentBuilder.tenantId(tenantId); deploymentBuilder.enableDuplicateFiltering(PropertyHelper.getBooleanProperty(processArchive.getProperties(), ProcessArchiveXml.PROP_IS_DEPLOY_CHANGED_ONLY, false)); deploymentBuilder.addInputStream(deploymentResource.getKey(), new ByteArrayInputStream(deploymentResource.getValue())); Collection<String> deploymentResourceNames = deploymentBuilder.getResourceNames(); if(!deploymentResourceNames.isEmpty()) { deployment = deploymentBuilder.deploy();