@Override public Batch deleteProcessInstancesAsync(List<String> processInstanceIds, ProcessInstanceQuery processInstanceQuery, String deleteReason, boolean skipCustomListeners) { return deleteProcessInstancesAsync(processInstanceIds, processInstanceQuery, deleteReason, skipCustomListeners, false); }
@Override public Batch deleteProcessInstancesAsync(List<String> processInstanceIds, ProcessInstanceQuery processInstanceQuery, String deleteReason) { return deleteProcessInstancesAsync(processInstanceIds, processInstanceQuery, deleteReason, false); }
@Override public Batch deleteProcessInstancesAsync(List<String> processInstanceIds, ProcessInstanceQuery processInstanceQuery, String deleteReason) { return deleteProcessInstancesAsync(processInstanceIds, processInstanceQuery, deleteReason, false); }
@Override public Batch deleteProcessInstancesAsync(List<String> processInstanceIds, String deleteReason) { return deleteProcessInstancesAsync(processInstanceIds, null, deleteReason, false); }
@Override public Batch deleteProcessInstancesAsync(List<String> processInstanceIds, ProcessInstanceQuery processInstanceQuery, String deleteReason, boolean skipCustomListeners) { return deleteProcessInstancesAsync(processInstanceIds, processInstanceQuery, deleteReason, skipCustomListeners, false); }
@Override public Batch deleteProcessInstancesAsync(ProcessInstanceQuery processInstanceQuery, String deleteReason) { return deleteProcessInstancesAsync(null, processInstanceQuery, deleteReason, false); }
@Override public Batch deleteProcessInstancesAsync(ProcessInstanceQuery processInstanceQuery, String deleteReason) { return deleteProcessInstancesAsync(null, processInstanceQuery, deleteReason, false); }
@Override public Batch deleteProcessInstancesAsync(List<String> processInstanceIds, String deleteReason) { return deleteProcessInstancesAsync(processInstanceIds, null, deleteReason, false); }
@Test public void testDeleteAsyncWithSkipCustomListeners() { when(runtimeServiceMock.deleteProcessInstancesAsync(anyListOf(String.class), any(ProcessInstanceQuery.class), anyString(), anyBoolean(), anyBoolean())).thenReturn(new BatchEntity()); Map<String, Object> messageBodyJson = new HashMap<String, Object>(); messageBodyJson.put("deleteReason", TEST_DELETE_REASON); messageBodyJson.put("processInstanceIds", Arrays.asList("processInstanceId1", "processInstanceId2")); messageBodyJson.put("skipCustomListeners", true); given() .contentType(ContentType.JSON).body(messageBodyJson) .then().expect() .statusCode(Status.OK.getStatusCode()) .when().post(DELETE_PROCESS_INSTANCES_ASYNC_URL); verify(runtimeServiceMock).deleteProcessInstancesAsync(anyListOf(String.class), Mockito.any(ProcessInstanceQuery.class), Mockito.eq(TEST_DELETE_REASON), Mockito.eq(true), Mockito.eq(false)); }
@Test public void testDeleteAsync() { List<String> ids = Arrays.asList(MockProvider.EXAMPLE_PROCESS_INSTANCE_ID); when(runtimeServiceMock.deleteProcessInstancesAsync(anyListOf(String.class), any(ProcessInstanceQuery.class), anyString(), anyBoolean(), anyBoolean())).thenReturn(new BatchEntity()); Map<String, Object> messageBodyJson = new HashMap<String, Object>(); messageBodyJson.put("processInstanceIds", ids); messageBodyJson.put("deleteReason", TEST_DELETE_REASON); given() .contentType(ContentType.JSON).body(messageBodyJson) .then().expect() .statusCode(Status.OK.getStatusCode()) .when().post(DELETE_PROCESS_INSTANCES_ASYNC_URL); verify(runtimeServiceMock, times(1)).deleteProcessInstancesAsync(ids, null, TEST_DELETE_REASON, false, false); }
@Test public void testDeleteAsyncWithSkipSubprocesses() { when(runtimeServiceMock.deleteProcessInstancesAsync(anyListOf(String.class), any(ProcessInstanceQuery.class), anyString(), anyBoolean(), anyBoolean())).thenReturn(new BatchEntity()); Map<String, Object> messageBodyJson = new HashMap<String, Object>(); messageBodyJson.put("deleteReason", TEST_DELETE_REASON); messageBodyJson.put("processInstanceIds", Arrays.asList("processInstanceId1", "processInstanceId2")); messageBodyJson.put("skipSubprocesses", true); given() .contentType(ContentType.JSON).body(messageBodyJson) .then().expect() .statusCode(Status.OK.getStatusCode()) .when().post(DELETE_PROCESS_INSTANCES_ASYNC_URL); verify(runtimeServiceMock).deleteProcessInstancesAsync( anyListOf(String.class), Mockito.any(ProcessInstanceQuery.class), Mockito.eq(TEST_DELETE_REASON), Mockito.eq(false), Mockito.eq(true)); }
@Test public void testDeleteAsyncWithQuery() { Map<String, Object> messageBodyJson = new HashMap<String, Object>(); messageBodyJson.put("deleteReason", TEST_DELETE_REASON); ProcessInstanceQueryDto query = new ProcessInstanceQueryDto(); messageBodyJson.put("processInstanceQuery", query); when(runtimeServiceMock.deleteProcessInstancesAsync(anyListOf(String.class), any(ProcessInstanceQuery.class), anyString(), anyBoolean(), anyBoolean())).thenReturn(new BatchEntity()); given() .contentType(ContentType.JSON).body(messageBodyJson) .then().expect() .statusCode(Status.OK.getStatusCode()) .when().post(DELETE_PROCESS_INSTANCES_ASYNC_URL); verify(runtimeServiceMock, times(1)).deleteProcessInstancesAsync( anyListOf(String.class), Mockito.any(ProcessInstanceQuery.class), Mockito.eq(TEST_DELETE_REASON), Mockito.eq(false), Mockito.eq(false)); }
@Test public void testDeleteAsyncWithBadRequestQuery() { doThrow(new BadUserRequestException("process instance ids are empty")) .when(runtimeServiceMock).deleteProcessInstancesAsync(eq((List<String>) null), eq((ProcessInstanceQuery) null), anyString(), anyBoolean(), anyBoolean()); Map<String, Object> messageBodyJson = new HashMap<String, Object>(); messageBodyJson.put("deleteReason", TEST_DELETE_REASON); given() .contentType(ContentType.JSON).body(messageBodyJson) .then().expect() .statusCode(Status.BAD_REQUEST.getStatusCode()) .when().post(DELETE_PROCESS_INSTANCES_ASYNC_URL); }
@Test public void testDeleteAsyncHistoricQueryBasedWithProcessInstanceIds() { when(runtimeServiceMock.deleteProcessInstancesAsync( anyListOf(String.class), any(ProcessInstanceQuery.class), anyString(), anyBoolean(), anyBoolean())) .thenReturn(new BatchEntity()); DeleteProcessInstancesDto body = new DeleteProcessInstancesDto(); body.setProcessInstanceIds(Arrays.asList(MockProvider.EXAMPLE_PROCESS_INSTANCE_ID)); given() .contentType(ContentType.JSON).body(body) .then().expect() .statusCode(Status.OK.getStatusCode()) .when().post(DELETE_PROCESS_INSTANCES_ASYNC_HIST_QUERY_URL); verify(runtimeServiceMock, times(1)).deleteProcessInstancesAsync( Arrays.asList(MockProvider.EXAMPLE_PROCESS_INSTANCE_ID), null, null, false, false); }
@Test public void testDeleteAsyncHistoricQueryBasedWithoutQueryAndWithoutProcessInstanceIds() { doThrow(new BadUserRequestException("processInstanceIds is empty")) .when(runtimeServiceMock).deleteProcessInstancesAsync( anyListOf(String.class), eq((ProcessInstanceQuery) null), anyString(), anyBoolean(), anyBoolean()); given() .contentType(ContentType.JSON).body(new DeleteProcessInstancesDto()) .then().expect() .statusCode(Status.BAD_REQUEST.getStatusCode()) .when().post(DELETE_PROCESS_INSTANCES_ASYNC_HIST_QUERY_URL); verify(runtimeServiceMock, times(1)).deleteProcessInstancesAsync( new ArrayList<String>(), null, null, false, false); }
@Test public void testDeleteAsyncHistoricQueryBasedWithDeleteReason() { when(runtimeServiceMock.deleteProcessInstancesAsync( anyListOf(String.class), any(ProcessInstanceQuery.class), anyString(), anyBoolean(), anyBoolean())) .thenReturn(new BatchEntity()); DeleteProcessInstancesDto body = new DeleteProcessInstancesDto(); body.setDeleteReason(MockProvider.EXAMPLE_HISTORIC_PROCESS_INSTANCE_DELETE_REASON); given() .contentType(ContentType.JSON).body(body) .then().expect() .statusCode(Status.OK.getStatusCode()) .when().post(DELETE_PROCESS_INSTANCES_ASYNC_HIST_QUERY_URL); verify(runtimeServiceMock, times(1)).deleteProcessInstancesAsync( new ArrayList<String>(), null, MockProvider.EXAMPLE_HISTORIC_PROCESS_INSTANCE_DELETE_REASON, false, false); }
@Test public void testDeleteAsyncHistoricQueryBasedWithSkipSubprocesses() { when(runtimeServiceMock.deleteProcessInstancesAsync( anyListOf(String.class), any(ProcessInstanceQuery.class), anyString(), anyBoolean(), anyBoolean())) .thenReturn(new BatchEntity()); DeleteProcessInstancesDto body = new DeleteProcessInstancesDto(); body.setSkipSubprocesses(true); given() .contentType(ContentType.JSON).body(body) .then().expect() .statusCode(Status.OK.getStatusCode()) .when().post(DELETE_PROCESS_INSTANCES_ASYNC_HIST_QUERY_URL); verify(runtimeServiceMock, times(1)).deleteProcessInstancesAsync( new ArrayList<String>(), null, null, false, true); }
@Test public void testDeleteAsyncHistoricQueryBasedWithSkipCustomListenerTrue() { when(runtimeServiceMock.deleteProcessInstancesAsync( anyListOf(String.class), any(ProcessInstanceQuery.class), anyString(), anyBoolean(), anyBoolean())) .thenReturn(new BatchEntity()); DeleteProcessInstancesDto body = new DeleteProcessInstancesDto(); body.setSkipCustomListeners(true); given() .contentType(ContentType.JSON).body(body) .then().expect() .statusCode(Status.OK.getStatusCode()) .when().post(DELETE_PROCESS_INSTANCES_ASYNC_HIST_QUERY_URL); verify(runtimeServiceMock, times(1)).deleteProcessInstancesAsync( new ArrayList<String>(), null, null, true, false); }
@Test public void testDeleteAsyncHistoricQueryBasedWithQuery() { when(runtimeServiceMock.deleteProcessInstancesAsync( anyListOf(String.class), any(ProcessInstanceQuery.class), anyString(), anyBoolean(), anyBoolean())) .thenReturn(new BatchEntity()); HistoricProcessInstanceQuery mockedHistoricProcessInstanceQuery = mock(HistoricProcessInstanceQueryImpl.class); when(historyServiceMock.createHistoricProcessInstanceQuery()).thenReturn(mockedHistoricProcessInstanceQuery); List<HistoricProcessInstance> historicProcessInstances = MockProvider.createMockRunningHistoricProcessInstances(); when(mockedHistoricProcessInstanceQuery.list()).thenReturn(historicProcessInstances); DeleteProcessInstancesDto body = new DeleteProcessInstancesDto(); body.setHistoricProcessInstanceQuery(new HistoricProcessInstanceQueryDto()); given() .contentType(ContentType.JSON).body(body) .then().expect() .statusCode(Status.OK.getStatusCode()) .when().post(DELETE_PROCESS_INSTANCES_ASYNC_HIST_QUERY_URL); verify(runtimeServiceMock, times(1)).deleteProcessInstancesAsync( Arrays.asList(MockProvider.EXAMPLE_PROCESS_INSTANCE_ID), null, null, false, false); }
@Test public void testDeleteAsyncHistoricQueryBasedWithQueryAndProcessInstanceIds() { when(runtimeServiceMock.deleteProcessInstancesAsync( anyListOf(String.class), any(ProcessInstanceQuery.class), anyString(), anyBoolean(), anyBoolean())) .thenReturn(new BatchEntity()); HistoricProcessInstanceQuery mockedHistoricProcessInstanceQuery = mock(HistoricProcessInstanceQueryImpl.class); when(historyServiceMock.createHistoricProcessInstanceQuery()).thenReturn(mockedHistoricProcessInstanceQuery); List<HistoricProcessInstance> historicProcessInstances = MockProvider.createMockRunningHistoricProcessInstances(); when(mockedHistoricProcessInstanceQuery.list()).thenReturn(historicProcessInstances); DeleteProcessInstancesDto body = new DeleteProcessInstancesDto(); body.setHistoricProcessInstanceQuery(new HistoricProcessInstanceQueryDto()); body.setProcessInstanceIds(Arrays.asList(MockProvider.ANOTHER_EXAMPLE_PROCESS_INSTANCE_ID)); given() .contentType(ContentType.JSON).body(body) .then().expect() .statusCode(Status.OK.getStatusCode()) .when().post(DELETE_PROCESS_INSTANCES_ASYNC_HIST_QUERY_URL); verify(runtimeServiceMock, times(1)).deleteProcessInstancesAsync( Arrays.asList(MockProvider.EXAMPLE_PROCESS_INSTANCE_ID, MockProvider.ANOTHER_EXAMPLE_PROCESS_INSTANCE_ID), null, null, false, false); }