Search in sources :

Example 6 with DeleteProcessInstancesDto

use of org.camunda.bpm.engine.rest.dto.runtime.batch.DeleteProcessInstancesDto in project camunda-bpm-platform by camunda.

the class ProcessInstanceRestServiceInteractionTest method testDeleteAsyncHistoricQueryBasedWithQueryAndProcessInstanceIds.

@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);
}
Also used : HistoricProcessInstanceQueryDto(org.camunda.bpm.engine.rest.dto.history.HistoricProcessInstanceQueryDto) HistoricProcessInstanceQuery(org.camunda.bpm.engine.history.HistoricProcessInstanceQuery) ProcessInstanceQuery(org.camunda.bpm.engine.runtime.ProcessInstanceQuery) HistoricProcessInstanceQuery(org.camunda.bpm.engine.history.HistoricProcessInstanceQuery) BatchEntity(org.camunda.bpm.engine.impl.batch.BatchEntity) HistoricProcessInstance(org.camunda.bpm.engine.history.HistoricProcessInstance) DeleteProcessInstancesDto(org.camunda.bpm.engine.rest.dto.runtime.batch.DeleteProcessInstancesDto) Test(org.junit.Test)

Example 7 with DeleteProcessInstancesDto

use of org.camunda.bpm.engine.rest.dto.runtime.batch.DeleteProcessInstancesDto in project camunda-bpm-platform by camunda.

the class ProcessInstanceRestServiceInteractionTest method testDeleteAsyncHistoricQueryBasedWithQuery.

@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);
}
Also used : HistoricProcessInstanceQueryDto(org.camunda.bpm.engine.rest.dto.history.HistoricProcessInstanceQueryDto) HistoricProcessInstanceQuery(org.camunda.bpm.engine.history.HistoricProcessInstanceQuery) ProcessInstanceQuery(org.camunda.bpm.engine.runtime.ProcessInstanceQuery) HistoricProcessInstanceQuery(org.camunda.bpm.engine.history.HistoricProcessInstanceQuery) BatchEntity(org.camunda.bpm.engine.impl.batch.BatchEntity) HistoricProcessInstance(org.camunda.bpm.engine.history.HistoricProcessInstance) DeleteProcessInstancesDto(org.camunda.bpm.engine.rest.dto.runtime.batch.DeleteProcessInstancesDto) Test(org.junit.Test)

Aggregations

HistoricProcessInstanceQuery (org.camunda.bpm.engine.history.HistoricProcessInstanceQuery)7 DeleteProcessInstancesDto (org.camunda.bpm.engine.rest.dto.runtime.batch.DeleteProcessInstancesDto)7 ProcessInstanceQuery (org.camunda.bpm.engine.runtime.ProcessInstanceQuery)7 Test (org.junit.Test)7 BatchEntity (org.camunda.bpm.engine.impl.batch.BatchEntity)6 HistoricProcessInstance (org.camunda.bpm.engine.history.HistoricProcessInstance)2 HistoricProcessInstanceQueryDto (org.camunda.bpm.engine.rest.dto.history.HistoricProcessInstanceQueryDto)2 BadUserRequestException (org.camunda.bpm.engine.BadUserRequestException)1