@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 testDeleteProcessDefinitionsByNotExistingIds() { // then thrown.expect(NotFoundException.class); thrown.expectMessage("No process definition found"); // when repositoryService.deleteProcessDefinitions() .byIds("not existing", "also not existing") .delete(); }
@Test public void testDeleteProcessDefinitionsByIdIsNull() { // then thrown.expect(NullValueException.class); thrown.expectMessage("cannot be null"); // when repositoryService.deleteProcessDefinitions() .byIds(null) .delete(); }
@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(); }
@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)); }
@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 testDeleteProcessDefinitionsByNotExistingKey() { // then thrown.expect(NotFoundException.class); thrown.expectMessage("No process definition found"); // when repositoryService.deleteProcessDefinitions() .byKey("no existing key") .withoutTenantId() .delete(); }
@Test public void testDeleteProcessDefinitionsByKeyIsNull() { // then thrown.expect(NullValueException.class); thrown.expectMessage("cannot be null"); // when repositoryService.deleteProcessDefinitions() .byKey(null) .withoutTenantId() .delete(); }
@Test public void testMixedSubscriptionsWhenDeletingProcessDefinitionsInOneTransactionById2() { // given second version without condition String definitionId1 = deployProcess(SINGLE_CONDITIONAL_XML); String definitionId2 = deployModel(MODEL_WITHOUT_CONDITION); String definitionId3 = deployProcess(SINGLE_CONDITIONAL_XML); // when repositoryService.deleteProcessDefinitions() .byIds(definitionId1, definitionId2, definitionId3) .delete(); // then assertEquals(0, runtimeService.createEventSubscriptionQuery().count()); }
@Test public void testMixedSubscriptionsWhenDeletingProcessDefinitionsInOneTransactionById3() { // given third version without condition String definitionId1 = deployProcess(SINGLE_MESSAGE_START_EVENT_XML); String definitionId2 = deployProcess(SINGLE_MESSAGE_START_EVENT_XML); String definitionId3 = deployModel(MODEL_WITHOUT_MESSAGE); // when repositoryService.deleteProcessDefinitions() .byIds(definitionId1, definitionId2, definitionId3) .delete(); // then assertEquals(0, runtimeService.createEventSubscriptionQuery().count()); }
@Test public void testMixedSubscriptionsWhenDeletingProcessDefinitionsInOneTransactionById1() { // given first version without condition String definitionId1 = deployModel(MODEL_WITHOUT_CONDITION); String definitionId2 = deployProcess(SINGLE_CONDITIONAL_XML); String definitionId3 = deployProcess(SINGLE_CONDITIONAL_XML); // when repositoryService.deleteProcessDefinitions() .byIds(definitionId1, definitionId2, definitionId3) .delete(); // then assertEquals(0, runtimeService.createEventSubscriptionQuery().count()); }
@Test public void testMixedSubscriptionsWhenDeletingProcessDefinitionsInOneTransactionById3() { // given third version without condition String definitionId1 = deployProcess(SINGLE_CONDITIONAL_XML); String definitionId2 = deployProcess(SINGLE_CONDITIONAL_XML); String definitionId3 = deployModel(MODEL_WITHOUT_CONDITION); // when repositoryService.deleteProcessDefinitions() .byIds(definitionId1, definitionId2, definitionId3) .delete(); // then assertEquals(0, runtimeService.createEventSubscriptionQuery().count()); }
@Test public void testSubscriptionsWhenDeletingProcessDefinitionsInOneTransactionByIdReverseOrder() { // given String definitionId1 = deployProcess(SINGLE_MESSAGE_START_EVENT_XML); String definitionId2 = deployProcess(SINGLE_MESSAGE_START_EVENT_XML); String definitionId3 = deployProcess(SINGLE_MESSAGE_START_EVENT_XML); // when repositoryService.deleteProcessDefinitions() .byIds(definitionId3, definitionId2, definitionId1) .delete(); // then assertEquals(0, runtimeService.createEventSubscriptionQuery().count()); }
@Test public void testMixedSubscriptionsWhenDeletingProcessDefinitionsInOneTransactionById1() { // given first version without condition String definitionId1 = deployModel(MODEL_WITHOUT_MESSAGE); String definitionId2 = deployProcess(SINGLE_MESSAGE_START_EVENT_XML); String definitionId3 = deployProcess(SINGLE_MESSAGE_START_EVENT_XML); // when repositoryService.deleteProcessDefinitions() .byIds(definitionId1, definitionId2, definitionId3) .delete(); // then assertEquals(0, runtimeService.createEventSubscriptionQuery().count()); }
@Test public void testMixedSubscriptionsWhenDeletingProcessDefinitionsInOneTransactionById2() { // given second version without condition String definitionId1 = deployProcess(SINGLE_MESSAGE_START_EVENT_XML); String definitionId2 = deployModel(MODEL_WITHOUT_MESSAGE); String definitionId3 = deployProcess(SINGLE_MESSAGE_START_EVENT_XML); // when repositoryService.deleteProcessDefinitions() .byIds(definitionId1, definitionId2, definitionId3) .delete(); // then assertEquals(0, runtimeService.createEventSubscriptionQuery().count()); }
@Test public void testSubscriptionsWhenDeletingProcessDefinitionsInOneTransactionByIdOrdered() { // given String definitionId1 = deployProcess(SINGLE_MESSAGE_START_EVENT_XML); String definitionId2 = deployProcess(SINGLE_MESSAGE_START_EVENT_XML); String definitionId3 = deployProcess(SINGLE_MESSAGE_START_EVENT_XML); // when repositoryService.deleteProcessDefinitions() .byIds(definitionId1, definitionId2, definitionId3) .delete(); // then assertEquals(0, runtimeService.createEventSubscriptionQuery().count()); }
@Test public void testSubscriptionsWhenDeletingProcessDefinitionsInOneTransactionByIdOrdered() { // given String definitionId1 = deployProcess(SINGLE_CONDITIONAL_XML); String definitionId2 = deployProcess(SINGLE_CONDITIONAL_XML); String definitionId3 = deployProcess(SINGLE_CONDITIONAL_XML); // when repositoryService.deleteProcessDefinitions() .byIds(definitionId1, definitionId2, definitionId3) .delete(); // then assertEquals(0, runtimeService.createEventSubscriptionQuery().count()); }
@Test public void testSubscriptionsWhenDeletingProcessDefinitionsInOneTransactionByIdReverseOrder() { // given String definitionId1 = deployProcess(SINGLE_CONDITIONAL_XML); String definitionId2 = deployProcess(SINGLE_CONDITIONAL_XML); String definitionId3 = deployProcess(SINGLE_CONDITIONAL_XML); // when repositoryService.deleteProcessDefinitions() .byIds(definitionId3, definitionId2, definitionId1) .delete(); // then assertEquals(0, runtimeService.createEventSubscriptionQuery().count()); }
@Test public void testMixedSubscriptionsWhenDeletingTwoProcessDefinitionsInOneTransaction1() { // given first version without condition String definitionId1 = deployModel(MODEL_WITHOUT_CONDITION); String definitionId2 = deployProcess(SINGLE_CONDITIONAL_XML); String definitionId3 = deployProcess(SINGLE_CONDITIONAL_XML); // when repositoryService.deleteProcessDefinitions() .byIds(definitionId2, definitionId3) .delete(); // then assertEquals(0, runtimeService.createEventSubscriptionQuery().count()); assertEquals(definitionId1, repositoryService.createProcessDefinitionQuery().singleResult().getId()); }
@Test public void testMixedSubscriptionsWhenDeletingTwoProcessDefinitionsInOneTransaction3() { // given third version without condition String definitionId1 = deployProcess(SINGLE_MESSAGE_START_EVENT_XML); String definitionId2 = deployProcess(SINGLE_MESSAGE_START_EVENT_XML); String definitionId3 = deployModel(MODEL_WITHOUT_MESSAGE); // when repositoryService.deleteProcessDefinitions() .byIds(definitionId2, definitionId3) .delete(); // then assertEquals(1, runtimeService.createEventSubscriptionQuery().count()); assertEquals(definitionId1, ((EventSubscriptionEntity) runtimeService.createEventSubscriptionQuery().singleResult()).getConfiguration()); }