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 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 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); }
public void testDisabledPaEnvScriptCaching() { // given processEngineConfiguration.setEnableFetchScriptEngineFromProcessApplication(false); 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); assertNull(environmentScripts.get(SCRIPT_LANGUAGE)); repositoryService.deleteDeployment(deployment.getId(), true); processEngineConfiguration.setEnableFetchScriptEngineFromProcessApplication(true); }
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 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); }
@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())); }
@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 testDisableFetchScriptEngineFromProcessApplication() { // when processEngineConfiguration.setEnableFetchScriptEngineFromProcessApplication(false); EmbeddedProcessApplication processApplication = new EmbeddedProcessApplication(); ProcessApplicationDeployment deployment = repositoryService.createDeployment(processApplication.getReference()) .addClasspathResource(PROCESS_PATH) .deploy(); // when ScriptEngine engine = getScriptEngineFromPa(SCRIPT_LANGUAGE, processApplication); // then assertNotNull(engine); assertEquals(engine, getScriptEngineFromPa(SCRIPT_LANGUAGE, processApplication)); // not cached in pa assertFalse(engine.equals(processApplication.getScriptEngineForName(SCRIPT_LANGUAGE, true))); repositoryService.deleteDeployment(deployment.getId(), true); processEngineConfiguration.setEnableFetchScriptEngineFromProcessApplication(true); }
public void testFetchScriptEngineFromPaDisableCaching() { // then processEngineConfiguration.setEnableScriptEngineCaching(false); getScriptingEngines().setEnableScriptEngineCaching(false); EmbeddedProcessApplication processApplication = new EmbeddedProcessApplication(); ProcessApplicationDeployment deployment = repositoryService.createDeployment(processApplication.getReference()) .addClasspathResource(PROCESS_PATH) .deploy(); // when ScriptEngine engine = getScriptEngineFromPa(SCRIPT_LANGUAGE, processApplication); // then assertNotNull(engine); assertFalse(engine.equals(getScriptEngineFromPa(SCRIPT_LANGUAGE, processApplication))); // not cached in pa assertFalse(engine.equals(processApplication.getScriptEngineForName(SCRIPT_LANGUAGE, false))); repositoryService.deleteDeployment(deployment.getId(), true); processEngineConfiguration.setEnableScriptEngineCaching(true); getScriptingEngines().setEnableScriptEngineCaching(true); }
public void testVariableInstanceQuery() { ProcessApplicationDeployment deployment = repositoryService.createDeployment(processApplication.getReference()) .addClasspathResource("org/camunda/bpm/engine/test/api/oneTaskProcess.bpmn20.xml") .deploy(); VariableMap variables = Variables.createVariables().putValue("my-variable", "a-value"); ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("oneTaskProcess", variables); // variable instance query List<VariableInstance> result = runtimeService.createVariableInstanceQuery().list(); assertEquals(1, result.size()); VariableInstance variableInstance = result.get(0); assertEquals("my-variable", variableInstance.getName()); // get variable assertNotNull(runtimeService.getVariable(processInstance.getId(), "my-variable")); // get variable local assertNotNull(runtimeService.getVariableLocal(processInstance.getId(), "my-variable")); repositoryService.deleteDeployment(deployment.getId(), true); }
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); }
public void testFetchScriptEngineFromPaEnableCaching() { // then EmbeddedProcessApplication processApplication = new EmbeddedProcessApplication(); ProcessApplicationDeployment deployment = repositoryService.createDeployment(processApplication.getReference()) .addClasspathResource(PROCESS_PATH) .deploy(); // when ScriptEngine engine = getScriptEngineFromPa(SCRIPT_LANGUAGE, processApplication); // then assertNotNull(engine); assertEquals(engine, getScriptEngineFromPa(SCRIPT_LANGUAGE, processApplication)); // cached in pa assertEquals(engine, processApplication.getScriptEngineForName(SCRIPT_LANGUAGE, true)); repositoryService.deleteDeployment(deployment.getId(), true); }
public void testOverwriteDeploymentSource() { 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") .source("my-source") .addModelInstance("process.bpmn", model) .deploy(); assertEquals("my-source", deploymentQuery.deploymentName("first-deployment-with-a-source").singleResult().getSource()); deleteDeployments(deployment); }
public void testCmmnDisabled() { ProcessApplicationDeployment deployment = repositoryService.createDeployment(processApplication.getReference()) .addClasspathResource("org/camunda/bpm/engine/test/api/oneTaskProcess.bpmn20.xml") .deploy(); // process is deployed: ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().singleResult(); assertNotNull(processDefinition); assertEquals(1, processDefinition.getVersion()); try { repositoryService.createCaseDefinitionQuery().singleResult(); fail("Cmmn Disabled: It should not be possible to query for a case definition."); } catch (Exception e) { // expected } 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())); }
@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())); }
public void testDeploymentSourceShouldBeNull() { String key = "process"; BpmnModelInstance model = Bpmn.createExecutableProcess(key).done(); DeploymentQuery deploymentQuery = repositoryService.createDeploymentQuery(); Deployment deployment1 = repositoryService .createDeployment() .name("first-deployment-without-a-source") .addModelInstance("process.bpmn", model) .deploy(); assertNull(deploymentQuery.deploymentName("first-deployment-without-a-source").singleResult().getSource()); Deployment deployment2 = repositoryService .createDeployment(processApplication.getReference()) .name("second-deployment-with-a-source") .source(null) .addModelInstance("process.bpmn", model) .deploy(); assertNull(deploymentQuery.deploymentName("second-deployment-with-a-source").singleResult().getSource()); deleteDeployments(deployment1, deployment2); }
public void testDeploymentSourceShouldNotBeNull() { String key = "process"; BpmnModelInstance model = Bpmn.createExecutableProcess(key).done(); DeploymentQuery deploymentQuery = repositoryService.createDeploymentQuery(); Deployment deployment1 = repositoryService .createDeployment() .name("first-deployment-without-a-source") .source("my-first-deployment-source") .addModelInstance("process.bpmn", model) .deploy(); assertEquals("my-first-deployment-source", deploymentQuery.deploymentName("first-deployment-without-a-source").singleResult().getSource()); Deployment deployment2 = repositoryService .createDeployment(processApplication.getReference()) .name("second-deployment-with-a-source") .source("my-second-deployment-source") .addModelInstance("process.bpmn", model) .deploy(); assertEquals("my-second-deployment-source", deploymentQuery.deploymentName("second-deployment-with-a-source").singleResult().getSource()); deleteDeployments(deployment1, deployment2); }