use of org.camunda.bpm.engine.rest.dto.history.HistoricProcessInstanceQueryDto in project camunda-bpm-platform by camunda.
the class ExternalTaskRestServiceInteractionTest method testSetRetriesForExternalTasksAsyncWithHistoricProcessInstanceQuery.
@Test
public void testSetRetriesForExternalTasksAsyncWithHistoricProcessInstanceQuery() {
when(historyServiceMock.createHistoricProcessInstanceQuery()).thenReturn(new HistoricProcessInstanceQueryImpl());
HistoricProcessInstanceQueryDto query = new HistoricProcessInstanceQueryDto();
query.setProcessDefinitionId(EXAMPLE_PROCESS_DEFINITION_ID);
Map<String, Object> parameters = new HashMap<String, Object>();
parameters.put("retries", "5");
parameters.put("historicProcessInstanceQuery", query);
given().contentType(POST_JSON_CONTENT_TYPE).body(parameters).then().expect().statusCode(Status.OK.getStatusCode()).when().post(RETRIES_EXTERNAL_TASKS_ASYNC_URL);
ArgumentCaptor<HistoricProcessInstanceQuery> queryCapture = ArgumentCaptor.forClass(HistoricProcessInstanceQuery.class);
verify(externalTaskService).updateRetries();
verifyNoMoreInteractions(externalTaskService);
verify(updateRetriesBuilder).externalTaskIds((List<String>) null);
verify(updateRetriesBuilder).processInstanceIds((List<String>) null);
verify(updateRetriesBuilder).externalTaskQuery(null);
verify(updateRetriesBuilder).processInstanceQuery(null);
verify(updateRetriesBuilder).historicProcessInstanceQuery(queryCapture.capture());
verify(updateRetriesBuilder).setAsync(5);
verifyNoMoreInteractions(updateRetriesBuilder);
HistoricProcessInstanceQueryImpl actualQuery = (HistoricProcessInstanceQueryImpl) queryCapture.getValue();
assertThat(actualQuery).isNotNull();
assertThat(actualQuery.getProcessDefinitionId()).isEqualTo(EXAMPLE_PROCESS_DEFINITION_ID);
}
use of org.camunda.bpm.engine.rest.dto.history.HistoricProcessInstanceQueryDto in project camunda-bpm-platform by camunda.
the class HistoricProcessInstanceRestServiceInteractionTest method testDeleteAsyncWithQuery.
@Test
public void testDeleteAsyncWithQuery() {
Batch batchEntity = MockProvider.createMockBatch();
when(historyServiceMock.deleteHistoricProcessInstancesAsync(anyListOf(String.class), any(HistoricProcessInstanceQuery.class), anyString())).thenReturn(batchEntity);
Map<String, Object> messageBodyJson = new HashMap<String, Object>();
messageBodyJson.put(DELETE_REASON, TEST_DELETE_REASON);
HistoricProcessInstanceQueryDto query = new HistoricProcessInstanceQueryDto();
messageBodyJson.put("historicProcessInstanceQuery", query);
Response response = given().contentType(ContentType.JSON).body(messageBodyJson).then().expect().statusCode(Status.OK.getStatusCode()).when().post(DELETE_HISTORIC_PROCESS_INSTANCES_ASYNC_URL);
verifyBatchJson(response.asString());
verify(historyServiceMock, times(1)).deleteHistoricProcessInstancesAsync(eq((List<String>) null), any(HistoricProcessInstanceQuery.class), Mockito.eq(TEST_DELETE_REASON));
}
use of org.camunda.bpm.engine.rest.dto.history.HistoricProcessInstanceQueryDto in project camunda-bpm-platform by camunda.
the class ExternalTaskRestServiceInteractionTest method testSetRetriesWithHistoricProcessInstanceQuery.
@Test
public void testSetRetriesWithHistoricProcessInstanceQuery() {
when(historyServiceMock.createHistoricProcessInstanceQuery()).thenReturn(new HistoricProcessInstanceQueryImpl());
HistoricProcessInstanceQueryDto query = new HistoricProcessInstanceQueryDto();
query.setProcessDefinitionId(EXAMPLE_PROCESS_DEFINITION_ID);
Map<String, Object> parameters = new HashMap<String, Object>();
parameters.put("retries", "5");
parameters.put("historicProcessInstanceQuery", query);
given().contentType(POST_JSON_CONTENT_TYPE).body(parameters).then().expect().statusCode(Status.NO_CONTENT.getStatusCode()).when().put(RETRIES_EXTERNAL_TASK_SYNC_URL);
ArgumentCaptor<HistoricProcessInstanceQuery> queryCapture = ArgumentCaptor.forClass(HistoricProcessInstanceQuery.class);
verify(externalTaskService).updateRetries();
verifyNoMoreInteractions(externalTaskService);
verify(updateRetriesBuilder).externalTaskIds((List<String>) null);
verify(updateRetriesBuilder).processInstanceIds((List<String>) null);
verify(updateRetriesBuilder).externalTaskQuery(null);
verify(updateRetriesBuilder).processInstanceQuery(null);
verify(updateRetriesBuilder).historicProcessInstanceQuery(queryCapture.capture());
verify(updateRetriesBuilder).set(5);
verifyNoMoreInteractions(updateRetriesBuilder);
HistoricProcessInstanceQueryImpl actualQuery = (HistoricProcessInstanceQueryImpl) queryCapture.getValue();
assertThat(actualQuery).isNotNull();
assertThat(actualQuery.getProcessDefinitionId()).isEqualTo(EXAMPLE_PROCESS_DEFINITION_ID);
}
use of org.camunda.bpm.engine.rest.dto.history.HistoricProcessInstanceQueryDto in project camunda-bpm-platform by camunda.
the class ProcessInstanceRestServiceImpl method setRetriesByProcessHistoricQueryBased.
@Override
public BatchDto setRetriesByProcessHistoricQueryBased(SetJobRetriesByProcessDto setJobRetriesDto) {
List<String> processInstanceIds = new ArrayList<String>();
HistoricProcessInstanceQueryDto queryDto = setJobRetriesDto.getHistoricProcessInstanceQuery();
if (queryDto != null) {
HistoricProcessInstanceQuery query = queryDto.toQuery(getProcessEngine());
List<HistoricProcessInstance> historicProcessInstances = query.list();
for (HistoricProcessInstance historicProcessInstance : historicProcessInstances) {
processInstanceIds.add(historicProcessInstance.getId());
}
}
if (setJobRetriesDto.getProcessInstances() != null) {
processInstanceIds.addAll(setJobRetriesDto.getProcessInstances());
}
try {
ManagementService managementService = getProcessEngine().getManagementService();
Batch batch = managementService.setJobRetriesAsync(processInstanceIds, (ProcessInstanceQuery) null, setJobRetriesDto.getRetries());
return BatchDto.fromBatch(batch);
} catch (BadUserRequestException e) {
throw new InvalidRequestException(Status.BAD_REQUEST, e.getMessage());
}
}
use of org.camunda.bpm.engine.rest.dto.history.HistoricProcessInstanceQueryDto in project camunda-bpm-platform by camunda.
the class ProcessInstanceRestServiceImpl method deleteAsyncHistoricQueryBased.
@Override
public BatchDto deleteAsyncHistoricQueryBased(DeleteProcessInstancesDto deleteProcessInstancesDto) {
List<String> processInstanceIds = new ArrayList<String>();
HistoricProcessInstanceQueryDto queryDto = deleteProcessInstancesDto.getHistoricProcessInstanceQuery();
if (queryDto != null) {
HistoricProcessInstanceQuery query = queryDto.toQuery(getProcessEngine());
List<HistoricProcessInstance> historicProcessInstances = query.list();
for (HistoricProcessInstance historicProcessInstance : historicProcessInstances) {
processInstanceIds.add(historicProcessInstance.getId());
}
}
if (deleteProcessInstancesDto.getProcessInstanceIds() != null) {
processInstanceIds.addAll(deleteProcessInstancesDto.getProcessInstanceIds());
}
try {
RuntimeService runtimeService = getProcessEngine().getRuntimeService();
Batch batch = runtimeService.deleteProcessInstancesAsync(processInstanceIds, null, deleteProcessInstancesDto.getDeleteReason(), deleteProcessInstancesDto.isSkipCustomListeners(), deleteProcessInstancesDto.isSkipSubprocesses());
return BatchDto.fromBatch(batch);
} catch (BadUserRequestException e) {
throw new InvalidRequestException(Status.BAD_REQUEST, e.getMessage());
}
}
Aggregations