protected void logProcessDefinitionRegistrations(StringBuilder builder, List<ProcessDefinition> processDefinitions) { if(processDefinitions.isEmpty()) { builder.append("Deployment does not provide any process definitions."); } else { builder.append("Will execute process definitions "); builder.append("\n"); for (ProcessDefinition processDefinition : processDefinitions) { builder.append("\n"); builder.append(" "); builder.append(processDefinition.getKey()); builder.append("[version: "); builder.append(processDefinition.getVersion()); builder.append(", id: "); builder.append(processDefinition.getId()); builder.append("]"); } builder.append("\n"); } }
public ProcessDefinition build() { ProcessDefinition mockDefinition = mock(ProcessDefinition.class); when(mockDefinition.getId()).thenReturn(id); when(mockDefinition.getCategory()).thenReturn(category); when(mockDefinition.getName()).thenReturn(name); when(mockDefinition.getKey()).thenReturn(key); when(mockDefinition.getDescription()).thenReturn(description); when(mockDefinition.getVersion()).thenReturn(version); when(mockDefinition.getResourceName()).thenReturn(resource); when(mockDefinition.getDeploymentId()).thenReturn(deploymentId); when(mockDefinition.getDiagramResourceName()).thenReturn(diagram); when(mockDefinition.isSuspended()).thenReturn(suspended); when(mockDefinition.hasStartFormKey()).thenReturn(startFormKey); when(mockDefinition.getTenantId()).thenReturn(tenantId); when(mockDefinition.getVersionTag()).thenReturn(versionTag); when(mockDefinition.isStartableInTasklist()).thenReturn(isStartableInTasklist); return mockDefinition; } }
protected void logProcessDefinitionRegistrations(StringBuilder builder, List<ProcessDefinition> processDefinitions) { if(processDefinitions.isEmpty()) { builder.append("Deployment does not provide any process definitions."); } else { builder.append("Will execute process definitions "); builder.append("\n"); for (ProcessDefinition processDefinition : processDefinitions) { builder.append("\n"); builder.append(" "); builder.append(processDefinition.getKey()); builder.append("[version: "); builder.append(processDefinition.getVersion()); builder.append(", id: "); builder.append(processDefinition.getId()); builder.append("]"); } builder.append("\n"); } }
public static ProcessDefinitionDto fromProcessDefinition(ProcessDefinition definition) { ProcessDefinitionDto dto = new ProcessDefinitionDto(); dto.id = definition.getId(); dto.key = definition.getKey(); dto.category = definition.getCategory(); dto.description = definition.getDescription(); dto.name = definition.getName(); dto.version = definition.getVersion(); dto.resource = definition.getResourceName(); dto.deploymentId = definition.getDeploymentId(); dto.diagram = definition.getDiagramResourceName(); dto.suspended = definition.isSuspended(); dto.tenantId = definition.getTenantId(); dto.versionTag = definition.getVersionTag(); dto.historyTimeToLive = definition.getHistoryTimeToLive(); dto.isStartableInTasklist = definition.isStartableInTasklist(); return dto; }
public void testQueryByLatestNoTenantIdSet() { // deploy a second version for tenant one deploymentForTenant(TENANT_ONE, emptyProcess); ProcessDefinitionQuery query = repositoryService .createProcessDefinitionQuery() .processDefinitionKey(PROCESS_DEFINITION_KEY) .latestVersion(); // one definition for each tenant assertThat(query.count(), is(3L)); Map<String, ProcessDefinition> processDefinitionsForTenant = getProcessDefinitionsForTenant(query.list()); assertThat(processDefinitionsForTenant.get(TENANT_ONE).getVersion(), is(2)); assertThat(processDefinitionsForTenant.get(TENANT_TWO).getVersion(), is(1)); assertThat(processDefinitionsForTenant.get(null).getVersion(), is(1)); }
public static ProcessDefinitionDto fromProcessDefinition(ProcessDefinition definition) { ProcessDefinitionDto dto = new ProcessDefinitionDto(); dto.id = definition.getId(); dto.key = definition.getKey(); dto.category = definition.getCategory(); dto.description = definition.getDescription(); dto.name = definition.getName(); dto.version = definition.getVersion(); dto.resource = definition.getResourceName(); dto.deploymentId = definition.getDeploymentId(); dto.diagram = definition.getDiagramResourceName(); dto.suspended = definition.isSuspended(); dto.tenantId = definition.getTenantId(); dto.versionTag = definition.getVersionTag(); dto.historyTimeToLive = definition.getHistoryTimeToLive(); dto.isStartableInTasklist = definition.isStartableInTasklist(); return dto; }
/** * Creates a process definition query and checks that only one process with version 1 is present. */ private void assertThatOneProcessIsDeployed() { ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().singleResult(); assertThat(processDefinition, is(notNullValue())); assertEquals(1, processDefinition.getVersion()); }
public void testVersioning() throws InterruptedException { deployOnTwoConcurrentThreads( createDeploymentBuilder(), createDeploymentBuilder() ); // ensure that although both transactions were run concurrently, the process definitions have different versions List<ProcessDefinition> processDefinitions = repositoryService .createProcessDefinitionQuery() .orderByProcessDefinitionVersion() .asc() .list(); assertThat(processDefinitions.size(), is(2)); assertThat(processDefinitions.get(0).getVersion(), is(1)); assertThat(processDefinitions.get(1).getVersion(), is(2)); }
public void testQueryByLatestWithTenantIds() { // deploy a second version for tenant one deploymentForTenant(TENANT_ONE, emptyProcess); ProcessDefinitionQuery query = repositoryService .createProcessDefinitionQuery() .processDefinitionKey(PROCESS_DEFINITION_KEY) .latestVersion() .tenantIdIn(TENANT_ONE, TENANT_TWO); // one definition for each tenant assertThat(query.count(), is(2L)); Map<String, ProcessDefinition> processDefinitionsForTenant = getProcessDefinitionsForTenant(query.list()); assertThat(processDefinitionsForTenant.get(TENANT_ONE).getVersion(), is(2)); assertThat(processDefinitionsForTenant.get(TENANT_TWO).getVersion(), is(1)); }
public void testQueryByLatestWithTenantIdsIncludeDefinitionsWithoutTenantId() { // deploy a second version without tenant id deployment(emptyProcess); // deploy a third version for tenant one deploymentForTenant(TENANT_ONE, emptyProcess); deploymentForTenant(TENANT_ONE, emptyProcess); ProcessDefinitionQuery query = repositoryService .createProcessDefinitionQuery() .processDefinitionKey(PROCESS_DEFINITION_KEY) .latestVersion() .tenantIdIn(TENANT_ONE, TENANT_TWO) .includeProcessDefinitionsWithoutTenantId(); assertThat(query.count(), is(3L)); Map<String, ProcessDefinition> processDefinitionsForTenant = getProcessDefinitionsForTenant(query.list()); assertThat(processDefinitionsForTenant.get(TENANT_ONE).getVersion(), is(3)); assertThat(processDefinitionsForTenant.get(TENANT_TWO).getVersion(), is(1)); assertThat(processDefinitionsForTenant.get(null).getVersion(), is(2)); }
public void testQueryByLatestWithoutTenantId() { // deploy a second version without tenant id deployment(emptyProcess); ProcessDefinitionQuery query = repositoryService .createProcessDefinitionQuery() .processDefinitionKey(PROCESS_DEFINITION_KEY) .latestVersion() .withoutTenantId(); assertThat(query.count(), is(1L)); ProcessDefinition processDefinition = query.singleResult(); assertThat(processDefinition.getTenantId(), is(nullValue())); assertThat(processDefinition.getVersion(), is(2)); }
public void testQueryByLatestWithTenantId() { // deploy a second version for tenant one deploymentForTenant(TENANT_ONE, emptyProcess); ProcessDefinitionQuery query = repositoryService .createProcessDefinitionQuery() .processDefinitionKey(PROCESS_DEFINITION_KEY) .latestVersion() .tenantIdIn(TENANT_ONE); assertThat(query.count(), is(1L)); ProcessDefinition processDefinition = query.singleResult(); assertThat(processDefinition.getTenantId(), is(TENANT_ONE)); assertThat(processDefinition.getVersion(), is(2)); query = repositoryService .createProcessDefinitionQuery() .processDefinitionKey(PROCESS_DEFINITION_KEY) .latestVersion() .tenantIdIn(TENANT_TWO); assertThat(query.count(), is(1L)); processDefinition = query.singleResult(); assertThat(processDefinition.getTenantId(), is(TENANT_TWO)); assertThat(processDefinition.getVersion(), is(1)); }
public void testDeployIdenticalProcessDefinitions() { List<String> deploymentIds = new ArrayList<String>(); deploymentIds.add(deployProcessString(("<definitions " + NAMESPACE + " " + TARGET_NAMESPACE + ">" + " <process id='IDR' name='Insurance Damage Report' isExecutable='true' />" + "</definitions>"))); deploymentIds.add(deployProcessString(("<definitions " + NAMESPACE + " " + TARGET_NAMESPACE + ">" + " <process id='IDR' name='Insurance Damage Report' isExecutable='true' />" + "</definitions>"))); List<ProcessDefinition> processDefinitions = repositoryService .createProcessDefinitionQuery() .orderByProcessDefinitionKey().asc() .orderByProcessDefinitionVersion().desc() .list(); assertNotNull(processDefinitions); assertEquals(2, processDefinitions.size()); ProcessDefinition processDefinition = processDefinitions.get(0); assertEquals("IDR", processDefinition.getKey()); assertEquals("Insurance Damage Report", processDefinition.getName()); assertTrue(processDefinition.getId().startsWith("IDR:2")); assertEquals(2, processDefinition.getVersion()); processDefinition = processDefinitions.get(1); assertEquals("IDR", processDefinition.getKey()); assertEquals("Insurance Damage Report", processDefinition.getName()); assertTrue(processDefinition.getId().startsWith("IDR:1")); assertEquals(1, processDefinition.getVersion()); deleteDeployments(deploymentIds); }
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 execute(DelegateExecution execution) throws Exception { RepositoryService repoService = execution.getProcessEngineServices().getRepositoryService(); ProcessDefinition targetDefinition = repoService.createProcessDefinitionQuery().latestVersion().singleResult(); SetProcessDefinitionVersionCmd migrationCommand = new SetProcessDefinitionVersionCmd(execution.getProcessInstanceId(), targetDefinition.getVersion()); Context.getProcessEngineConfiguration().getCommandExecutorTxRequired().execute(migrationCommand); }
public static HalProcessDefinition fromProcessDefinition(ProcessDefinition processDefinition, ProcessEngine processEngine) { HalProcessDefinition halProcDef = new HalProcessDefinition(); halProcDef.id = processDefinition.getId(); halProcDef.key = processDefinition.getKey(); halProcDef.category = processDefinition.getCategory(); halProcDef.description = processDefinition.getDescription(); halProcDef.name = processDefinition.getName(); halProcDef.version = processDefinition.getVersion(); halProcDef.resource = processDefinition.getResourceName(); halProcDef.deploymentId = processDefinition.getDeploymentId(); halProcDef.diagram = processDefinition.getDiagramResourceName(); halProcDef.suspended = processDefinition.isSuspended(); halProcDef.contextPath = ApplicationContextPathUtil.getApplicationPathForDeployment(processEngine, processDefinition.getDeploymentId()); halProcDef.linker.createLink(REL_SELF, processDefinition.getId()); halProcDef.linker.createLink(REL_DEPLOYMENT, processDefinition.getDeploymentId()); halProcDef.linker.createLink(REL_DEPLOYMENT_RESOURCE, processDefinition.getDeploymentId(), processDefinition.getResourceName()); return halProcDef; }
public static HalProcessDefinition fromProcessDefinition(ProcessDefinition processDefinition, ProcessEngine processEngine) { HalProcessDefinition halProcDef = new HalProcessDefinition(); halProcDef.id = processDefinition.getId(); halProcDef.key = processDefinition.getKey(); halProcDef.category = processDefinition.getCategory(); halProcDef.description = processDefinition.getDescription(); halProcDef.name = processDefinition.getName(); halProcDef.version = processDefinition.getVersion(); halProcDef.resource = processDefinition.getResourceName(); halProcDef.deploymentId = processDefinition.getDeploymentId(); halProcDef.diagram = processDefinition.getDiagramResourceName(); halProcDef.suspended = processDefinition.isSuspended(); halProcDef.contextPath = ApplicationContextPathUtil.getApplicationPathForDeployment(processEngine, processDefinition.getDeploymentId()); halProcDef.linker.createLink(REL_SELF, processDefinition.getId()); halProcDef.linker.createLink(REL_DEPLOYMENT, processDefinition.getDeploymentId()); halProcDef.linker.createLink(REL_DEPLOYMENT_RESOURCE, processDefinition.getDeploymentId(), processDefinition.getResourceName()); return halProcDef; }
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); }
public void testUpdateEventSubscriptionOnDeployment(){ deploymentId = repositoryService.createDeployment() .addClasspathResource(SIGNAL_START_EVENT_PROCESS) .deploy().getId(); EventSubscription eventSubscription = runtimeService.createEventSubscriptionQuery().eventType("signal").singleResult(); assertNotNull(eventSubscription); assertEquals("alert", eventSubscription.getEventName()); // deploy a new version of the process with different signal name String newDeploymentId = repositoryService.createDeployment() .addClasspathResource(SIGNAL_START_EVENT_PROCESS_NEW_VERSION) .deploy().getId(); ProcessDefinition newProcessDefinition = repositoryService.createProcessDefinitionQuery().latestVersion().singleResult(); assertEquals(2, newProcessDefinition.getVersion()); List<EventSubscription> newEventSubscriptions = runtimeService.createEventSubscriptionQuery().eventType("signal").list(); // only one event subscription for the new version of the process definition assertEquals(1, newEventSubscriptions.size()); EventSubscriptionEntity newEventSubscription = (EventSubscriptionEntity) newEventSubscriptions.iterator().next(); assertEquals(newProcessDefinition.getId(), newEventSubscription.getConfiguration()); assertEquals("abort", newEventSubscription.getEventName()); // clean db repositoryService.deleteDeployment(newDeploymentId); }
public void testQueryByLatestAndName() { String firstDeployment = repositoryService .createDeployment() .addClasspathResource("org/camunda/bpm/engine/test/api/repository/first-process.bpmn20.xml") .deploy() .getId(); String secondDeployment = repositoryService .createDeployment() .addClasspathResource("org/camunda/bpm/engine/test/api/repository/first-process.bpmn20.xml") .deploy() .getId(); ProcessDefinitionQuery query = repositoryService.createProcessDefinitionQuery(); query .processDefinitionName("First Test Process") .latestVersion(); verifyQueryResults(query, 1); ProcessDefinition result = query.singleResult(); assertEquals("First Test Process", result.getName()); assertEquals(2, result.getVersion()); repositoryService.deleteDeployment(firstDeployment, true); repositoryService.deleteDeployment(secondDeployment, true); }