use of org.camunda.bpm.engine.rest.dto.history.HistoricProcessInstanceQueryDto 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);
}
use of org.camunda.bpm.engine.rest.dto.history.HistoricProcessInstanceQueryDto in project camunda-bpm-platform by camunda.
the class ProcessInstanceRestServiceInteractionTest method testSetRetriesByProcessAsyncWithQuery.
@Test
public void testSetRetriesByProcessAsyncWithQuery() {
Batch batchEntity = MockProvider.createMockBatch();
when(mockManagementService.setJobRetriesAsync(anyListOf(String.class), any(ProcessInstanceQuery.class), anyInt())).thenReturn(batchEntity);
Map<String, Object> messageBodyJson = new HashMap<String, Object>();
messageBodyJson.put(RETRIES, 5);
HistoricProcessInstanceQueryDto query = new HistoricProcessInstanceQueryDto();
messageBodyJson.put("processInstanceQuery", query);
Response response = given().contentType(ContentType.JSON).body(messageBodyJson).then().expect().statusCode(Status.OK.getStatusCode()).when().post(SET_JOB_RETRIES_ASYNC_URL);
verifyBatchJson(response.asString());
verify(mockManagementService, times(1)).setJobRetriesAsync(eq((List<String>) null), any(ProcessInstanceQuery.class), Mockito.eq(5));
}
use of org.camunda.bpm.engine.rest.dto.history.HistoricProcessInstanceQueryDto in project camunda-bpm-platform by camunda.
the class RestartProcessInstanceRestServiceTest method testRestartProcessInstanceWithoutProcessInstanceIdsAsync.
@Test
public void testRestartProcessInstanceWithoutProcessInstanceIdsAsync() {
when(historyServiceMock.createHistoricProcessInstanceQuery()).thenReturn(new HistoricProcessInstanceQueryImpl());
Map<String, Object> json = new HashMap<String, Object>();
List<Map<String, Object>> instructions = new ArrayList<Map<String, Object>>();
HistoricProcessInstanceQueryDto query = new HistoricProcessInstanceQueryDto();
query.setFinished(true);
json.put("historicProcessInstanceQuery", query);
instructions.add(ModificationInstructionBuilder.startBefore().activityId("activityId").getJson());
json.put("instructions", instructions);
given().pathParam("id", MockProvider.EXAMPLE_PROCESS_DEFINITION_ID).contentType(ContentType.JSON).body(json).then().expect().statusCode(Status.OK.getStatusCode()).when().post(RESTART_PROCESS_INSTANCE_ASYNC_URL);
verify(builderMock).startBeforeActivity("activityId");
verify(builderMock).historicProcessInstanceQuery(query.toQuery(processEngine));
verify(builderMock).executeAsync();
verifyNoMoreInteractions(builderMock);
}
use of org.camunda.bpm.engine.rest.dto.history.HistoricProcessInstanceQueryDto in project camunda-bpm-platform by camunda.
the class JobRestServiceInteractionTest method testSetRetriesAsyncWithQuery.
@Test
public void testSetRetriesAsyncWithQuery() {
Batch batchEntity = MockProvider.createMockBatch();
when(mockManagementService.setJobRetriesAsync(anyListOf(String.class), any(JobQuery.class), anyInt())).thenReturn(batchEntity);
Map<String, Object> messageBodyJson = new HashMap<String, Object>();
messageBodyJson.put(RETRIES, 5);
HistoricProcessInstanceQueryDto query = new HistoricProcessInstanceQueryDto();
messageBodyJson.put("jobQuery", query);
Response response = given().contentType(ContentType.JSON).body(messageBodyJson).then().expect().statusCode(Status.OK.getStatusCode()).when().post(JOBS_SET_RETRIES_URL);
verifyBatchJson(response.asString());
verify(mockManagementService, times(1)).setJobRetriesAsync(eq((List<String>) null), any(JobQuery.class), Mockito.eq(5));
}
use of org.camunda.bpm.engine.rest.dto.history.HistoricProcessInstanceQueryDto in project camunda-bpm-platform by camunda.
the class JobRestServiceInteractionTest method testSetRetriesWithNegativeRetries.
@Test
public void testSetRetriesWithNegativeRetries() {
doThrow(new BadUserRequestException("retries are negative")).when(mockManagementService).setJobRetriesAsync(anyListOf(String.class), any(JobQuery.class), eq(-1));
Map<String, Object> messageBodyJson = new HashMap<String, Object>();
messageBodyJson.put(RETRIES, -1);
HistoricProcessInstanceQueryDto query = new HistoricProcessInstanceQueryDto();
messageBodyJson.put("jobQuery", query);
given().contentType(ContentType.JSON).body(messageBodyJson).then().expect().statusCode(Status.BAD_REQUEST.getStatusCode()).when().post(JOBS_SET_RETRIES_URL);
}
Aggregations