use of org.camunda.bpm.engine.impl.HistoricProcessInstanceQueryImpl in project camunda-bpm-platform by camunda.
the class RestartProcessInstanceRestServiceTest method testRestartProcessInstanceWithHistoricProcessInstanceQueryAsync.
@Test
public void testRestartProcessInstanceWithHistoricProcessInstanceQueryAsync() {
when(historyServiceMock.createHistoricProcessInstanceQuery()).thenReturn(new HistoricProcessInstanceQueryImpl());
HashMap<String, Object> json = new HashMap<String, Object>();
List<Map<String, Object>> instructions = new ArrayList<Map<String, Object>>();
instructions.add(ModificationInstructionBuilder.startBefore().activityId("activityId").getJson());
json.put("instructions", instructions);
HistoricProcessInstanceQueryDto query = new HistoricProcessInstanceQueryDto();
query.setProcessInstanceBusinessKey("businessKey");
json.put("historicProcessInstanceQuery", query);
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(runtimeServiceMock).restartProcessInstances(MockProvider.EXAMPLE_PROCESS_DEFINITION_ID);
verify(builderMock).startBeforeActivity("activityId");
verify(builderMock).historicProcessInstanceQuery(query.toQuery(processEngine));
verify(builderMock).executeAsync();
}
use of org.camunda.bpm.engine.impl.HistoricProcessInstanceQueryImpl in project camunda-bpm-platform by camunda.
the class RestartProcessInstanceRestServiceTest method testRestartProcessInstanceWithHistoricProcessInstanceQuerySync.
@Test
public void testRestartProcessInstanceWithHistoricProcessInstanceQuerySync() {
when(historyServiceMock.createHistoricProcessInstanceQuery()).thenReturn(new HistoricProcessInstanceQueryImpl());
HashMap<String, Object> json = new HashMap<String, Object>();
List<Map<String, Object>> instructions = new ArrayList<Map<String, Object>>();
instructions.add(ModificationInstructionBuilder.startBefore().activityId("activityId").getJson());
json.put("instructions", instructions);
HistoricProcessInstanceQueryDto query = new HistoricProcessInstanceQueryDto();
query.setProcessInstanceBusinessKey("businessKey");
json.put("historicProcessInstanceQuery", query);
given().pathParam("id", MockProvider.EXAMPLE_PROCESS_DEFINITION_ID).contentType(ContentType.JSON).body(json).then().expect().statusCode(Status.NO_CONTENT.getStatusCode()).when().post(RESTART_PROCESS_INSTANCE_URL);
verify(runtimeServiceMock).restartProcessInstances(MockProvider.EXAMPLE_PROCESS_DEFINITION_ID);
verify(builderMock).startBeforeActivity("activityId");
verify(builderMock).historicProcessInstanceQuery(query.toQuery(processEngine));
verify(builderMock).execute();
}
use of org.camunda.bpm.engine.impl.HistoricProcessInstanceQueryImpl in project camunda-bpm-platform by camunda.
the class RestartProcessInstanceRestServiceTest method testRestartProcessInstanceWithoutProcessInstanceIdsSync.
@Test
public void testRestartProcessInstanceWithoutProcessInstanceIdsSync() {
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.NO_CONTENT.getStatusCode()).when().post(RESTART_PROCESS_INSTANCE_URL);
verify(builderMock).startBeforeActivity("activityId");
verify(builderMock).historicProcessInstanceQuery(query.toQuery(processEngine));
verify(builderMock).execute();
verifyNoMoreInteractions(builderMock);
}
use of org.camunda.bpm.engine.impl.HistoricProcessInstanceQueryImpl in project camunda-bpm-platform by camunda.
the class AbstractUpdateProcessInstancesSuspendStateCmd method collectProcessInstanceIds.
protected Collection<String> collectProcessInstanceIds() {
HashSet<String> allProcessInstanceIds = new HashSet<String>();
List<String> processInstanceIds = builder.getProcessInstanceIds();
if (processInstanceIds != null) {
allProcessInstanceIds.addAll(processInstanceIds);
}
ProcessInstanceQueryImpl processInstanceQuery = (ProcessInstanceQueryImpl) builder.getProcessInstanceQuery();
if (processInstanceQuery != null) {
allProcessInstanceIds.addAll(processInstanceQuery.listIds());
}
HistoricProcessInstanceQueryImpl historicProcessInstanceQuery = (HistoricProcessInstanceQueryImpl) builder.getHistoricProcessInstanceQuery();
if (historicProcessInstanceQuery != null) {
allProcessInstanceIds.addAll(historicProcessInstanceQuery.listIds());
}
return allProcessInstanceIds;
}
use of org.camunda.bpm.engine.impl.HistoricProcessInstanceQueryImpl 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);
}
Aggregations