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 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 testProcessApplicationDeploymentResumePreviousVersionsDifferentKeys() { // 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") .resumePreviousVersions() .addClasspathResource("org/camunda/bpm/engine/test/api/oneTaskProcess.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(1, processDefinitions.get(1).getVersion()); // and the old deployment was not resumed ProcessApplicationRegistration registration = deployment2.getProcessApplicationRegistration(); Set<String> deploymentIds = registration.getDeploymentIds(); assertEquals(1, deploymentIds.size()); assertEquals(deployment2.getId(), deploymentIds.iterator().next()); assertEquals(processEngine.getName(), registration.getProcessEngineName()); deleteDeployments(deployment1, deployment2); }
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 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 testProcessApplicationDeploymentNoResume() { // 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) .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 NOT resumed ProcessApplicationRegistration registration = deployment2.getProcessApplicationRegistration(); Set<String> deploymentIds = registration.getDeploymentIds(); assertEquals(1, deploymentIds.size()); assertEquals(processEngine.getName(), registration.getProcessEngineName()); 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); }
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 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); }
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 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 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 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); }
.createDeployment(application1.getReference()) .name(DEPLOYMENT_NAME) .addClasspathResource(resource1) .deploy(); .createDeployment(application2.getReference()) .name(DEPLOYMENT_NAME) .addClasspathResource(resource1) .deploy();
@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())); }
@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())); }
@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 registrationFoundOnlyForOneProcessDefinition() { // given // first deployment Deployment deployment1 = repositoryService .createDeployment() .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)); assertNull(getProcessApplicationForDefinition(secondDefinitionId)); }