@Override public void deleteProcessDefinitionsByKey(String processDefinitionKey, boolean cascade, boolean skipCustomListeners, boolean skipIoMappings) { RepositoryService repositoryService = processEngine.getRepositoryService(); DeleteProcessDefinitionsBuilder builder = repositoryService.deleteProcessDefinitions() .byKey(processDefinitionKey); deleteProcessDefinitions(builder, cascade, skipCustomListeners, skipIoMappings); }
@Override public void deleteProcessDefinition(String processDefinitionId, boolean cascade, boolean skipCustomListeners, boolean skipIoMappings) { DeleteProcessDefinitionsBuilder builder = deleteProcessDefinitions().byIds(processDefinitionId); if (cascade) { builder.cascade(); } if (skipCustomListeners) { builder.skipCustomListeners(); } if (skipIoMappings) { builder.skipIoMappings(); } builder.delete(); }
@Override public void deleteProcessDefinitionsByKey(String processDefinitionKey, boolean cascade, boolean skipCustomListeners, boolean skipIoMappings) { RepositoryService repositoryService = processEngine.getRepositoryService(); DeleteProcessDefinitionsBuilder builder = repositoryService.deleteProcessDefinitions() .byKey(processDefinitionKey); deleteProcessDefinitions(builder, cascade, skipCustomListeners, skipIoMappings); }
@Override public void deleteProcessDefinition(String processDefinitionId, boolean cascade, boolean skipCustomListeners, boolean skipIoMappings) { DeleteProcessDefinitionsBuilder builder = deleteProcessDefinitions().byIds(processDefinitionId); if (cascade) { builder.cascade(); } if (skipCustomListeners) { builder.skipCustomListeners(); } if (skipIoMappings) { builder.skipIoMappings(); } builder.delete(); }
@Override public void deleteProcessDefinitionsByKeyAndTenantId(String processDefinitionKey, boolean cascade, boolean skipCustomListeners, boolean skipIoMappings, String tenantId) { RepositoryService repositoryService = processEngine.getRepositoryService(); DeleteProcessDefinitionsBuilder builder = repositoryService.deleteProcessDefinitions() .byKey(processDefinitionKey) .withTenantId(tenantId); deleteProcessDefinitions(builder, cascade, skipCustomListeners, skipIoMappings); }
@Test public void testDeleteProcessDefinitionsByNotExistingIds() { // then thrown.expect(NotFoundException.class); thrown.expectMessage("No process definition found"); // when repositoryService.deleteProcessDefinitions() .byIds("not existing", "also not existing") .delete(); }
@Override public void deleteProcessDefinitionsByKeyAndTenantId(String processDefinitionKey, boolean cascade, boolean skipCustomListeners, boolean skipIoMappings, String tenantId) { RepositoryService repositoryService = processEngine.getRepositoryService(); DeleteProcessDefinitionsBuilder builder = repositoryService.deleteProcessDefinitions() .byKey(processDefinitionKey) .withTenantId(tenantId); deleteProcessDefinitions(builder, cascade, skipCustomListeners, skipIoMappings); }
@Test public void testDeleteProcessDefinitionsByIdIsNull() { // then thrown.expect(NullValueException.class); thrown.expectMessage("cannot be null"); // when repositoryService.deleteProcessDefinitions() .byIds(null) .delete(); }
@Test public void testDeleteDefinitionsByKeyNotExistingKey() { DeleteProcessDefinitionsBuilder builder = repositoryServiceMock.deleteProcessDefinitions() .byKey("NOT_EXISTING_KEY"); doThrow(new NotFoundException("No process definition found with key 'NOT_EXISTING_KEY'")).when(builder).delete(); given() .pathParam("key", "NOT_EXISTING_KEY") .expect() .statusCode(Status.NOT_FOUND.getStatusCode()) .body(containsString("No process definition found with key 'NOT_EXISTING_KEY'")) .when() .delete(SINGLE_PROCESS_DEFINITION_BY_KEY_DELETE_URL); }
@Test public void testDeleteProcessDefinitionsByIds() { // given for (int i = 0; i < 3; i++) { deployTwoProcessDefinitions(); } String[] processDefinitionIds = findProcessDefinitionIdsByKey("processOne"); // when repositoryService.deleteProcessDefinitions() .byIds(processDefinitionIds) .delete(); // then assertThat(repositoryService.createProcessDefinitionQuery().count(), is(3L)); }
@Test public void testDeleteDefinitionsByKey() { given() .pathParam("key", MockProvider.EXAMPLE_PROCESS_DEFINITION_KEY) .expect() .statusCode(Status.NO_CONTENT.getStatusCode()) .when() .delete(SINGLE_PROCESS_DEFINITION_BY_KEY_DELETE_URL); DeleteProcessDefinitionsBuilder builder = repositoryServiceMock.deleteProcessDefinitions() .byKey(MockProvider.EXAMPLE_PROCESS_DEFINITION_KEY); verify(builder).delete(); }
public void testDeleteProcessDefinitionsByIds() { // given for (int i = 0; i < 3; i++) { deploymentId = repositoryService.createDeployment() .addClasspathResource(PROCESS_PATH) .deploy().getId(); deploymentIds.add(deploymentId); } // when repositoryService.deleteProcessDefinitions() .byIds(findProcessDefinitionIdsByKey(PROCESS_KEY)) .delete(); // then assertUserOperationLogs(); }
@Test public void testDeleteDefinitionsByKeyNoPermissions() { DeleteProcessDefinitionsBuilder builder = repositoryServiceMock.deleteProcessDefinitions() .byKey(MockProvider.EXAMPLE_PROCESS_DEFINITION_KEY) .withTenantId(MockProvider.EXAMPLE_TENANT_ID); doThrow(new AuthorizationException("No permission to delete process definitions")).when(builder).delete(); given() .pathParam("key", MockProvider.EXAMPLE_PROCESS_DEFINITION_KEY) .pathParam("tenant-id", MockProvider.EXAMPLE_TENANT_ID) .expect() .statusCode(Status.FORBIDDEN.getStatusCode()) .body(containsString("No permission to delete process definitions")) .when() .delete(SINGLE_PROCESS_DEFINITION_BY_KEY_AND_TENANT_ID_DELETE_URL); }
@Test @Deployment(resources = SINGLE_CONDITIONAL_START_EVENT_XML) public void testStartInstanceAfterDeleteLatestProcessVersionByIds() { // given a deployed process // deploy second version of the process DeploymentWithDefinitions deployment = testRule.deploy(SINGLE_CONDITIONAL_XML); ProcessDefinition processDefinition = deployment.getDeployedProcessDefinitions().get(0); // delete it repositoryService.deleteProcessDefinitions() .byIds(processDefinition.getId()) .delete(); // when List<ProcessInstance> conditionInstances = runtimeService .createConditionEvaluation() .setVariable("foo", 1) .evaluateStartConditions(); // then assertEquals(1, conditionInstances.size()); assertNotNull(conditionInstances.get(0)); }
@Test public void testDeleteProcessDefinitionsByKey() { // given for (int i = 0; i < 3; i++) { deployTwoProcessDefinitions(); } // when repositoryService.deleteProcessDefinitions() .byKey("processOne") .withoutTenantId() .delete(); // then assertThat(repositoryService.createProcessDefinitionQuery().count(), is(3L)); }
public void testDeleteProcessDefinitionsByIdsCascading() { // given for (int i = 0; i < 3; i++) { deploymentId = repositoryService.createDeployment() .addClasspathResource(PROCESS_PATH) .deploy().getId(); deploymentIds.add(deploymentId); } // when repositoryService.deleteProcessDefinitions() .byIds(findProcessDefinitionIdsByKey(PROCESS_KEY)) .cascade() .delete(); // then assertUserOperationLogs(); }
@Test public void testDeleteProcessDefinitionsByNotExistingKey() { // then thrown.expect(NotFoundException.class); thrown.expectMessage("No process definition found"); // when repositoryService.deleteProcessDefinitions() .byKey("no existing key") .withoutTenantId() .delete(); }
@Test public void testDeleteProcessDefinitionsByIdsWithAuthenticatedTenant() { // given for (int i = 0; i < 3; i++) { deployProcessDefinitionWithTenant(); } String[] processDefinitionIds = findProcessDefinitionIdsByKey("process"); identityService.setAuthentication("user", null, Arrays.asList(TENANT_ONE)); // when repositoryService.deleteProcessDefinitions() .byIds(processDefinitionIds) .delete(); // then identityService.clearAuthentication(); assertThat(repositoryService.createProcessDefinitionQuery().count(), is(1L)); assertThat(repositoryService.createProcessDefinitionQuery().tenantIdIn(TENANT_ONE).count(), is(1L)); }
@Test public void testDeleteProcessDefinitionsByKeyIsNull() { // then thrown.expect(NullValueException.class); thrown.expectMessage("cannot be null"); // when repositoryService.deleteProcessDefinitions() .byKey(null) .withoutTenantId() .delete(); }
@Test public void testDeleteProcessDefinitionsByIdsWithCustomListenersSkipped() { // given IncrementCounterListener.counter = 0; for (int i = 0; i < 3; i++) { deployTwoProcessDefinitions(); } String[] processDefinitionIds = findProcessDefinitionIdsByKey("processOne"); runtimeService.startProcessInstanceByKey("processOne"); // when repositoryService.deleteProcessDefinitions() .byIds(processDefinitionIds) .cascade() .skipCustomListeners() .delete(); // then assertThat(IncrementCounterListener.counter, is(0)); }