Search in sources :

Example 1 with HistoricProcessInstanceQueryImpl

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();
}
Also used : HistoricProcessInstanceQueryDto(org.camunda.bpm.engine.rest.dto.history.HistoricProcessInstanceQueryDto) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Matchers.anyString(org.mockito.Matchers.anyString) HashMap(java.util.HashMap) Map(java.util.Map) HistoricProcessInstanceQueryImpl(org.camunda.bpm.engine.impl.HistoricProcessInstanceQueryImpl) Test(org.junit.Test)

Example 2 with HistoricProcessInstanceQueryImpl

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();
}
Also used : HistoricProcessInstanceQueryDto(org.camunda.bpm.engine.rest.dto.history.HistoricProcessInstanceQueryDto) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Matchers.anyString(org.mockito.Matchers.anyString) HashMap(java.util.HashMap) Map(java.util.Map) HistoricProcessInstanceQueryImpl(org.camunda.bpm.engine.impl.HistoricProcessInstanceQueryImpl) Test(org.junit.Test)

Example 3 with HistoricProcessInstanceQueryImpl

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);
}
Also used : HistoricProcessInstanceQueryDto(org.camunda.bpm.engine.rest.dto.history.HistoricProcessInstanceQueryDto) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Matchers.anyString(org.mockito.Matchers.anyString) HashMap(java.util.HashMap) Map(java.util.Map) HistoricProcessInstanceQueryImpl(org.camunda.bpm.engine.impl.HistoricProcessInstanceQueryImpl) Test(org.junit.Test)

Example 4 with HistoricProcessInstanceQueryImpl

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;
}
Also used : HistoricProcessInstanceQueryImpl(org.camunda.bpm.engine.impl.HistoricProcessInstanceQueryImpl) ProcessInstanceQueryImpl(org.camunda.bpm.engine.impl.ProcessInstanceQueryImpl) HashSet(java.util.HashSet) HistoricProcessInstanceQueryImpl(org.camunda.bpm.engine.impl.HistoricProcessInstanceQueryImpl)

Example 5 with HistoricProcessInstanceQueryImpl

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);
}
Also used : HistoricProcessInstanceQueryDto(org.camunda.bpm.engine.rest.dto.history.HistoricProcessInstanceQueryDto) HistoricProcessInstanceQuery(org.camunda.bpm.engine.history.HistoricProcessInstanceQuery) HashMap(java.util.HashMap) Matchers.anyString(org.mockito.Matchers.anyString) HistoricProcessInstanceQueryImpl(org.camunda.bpm.engine.impl.HistoricProcessInstanceQueryImpl) Test(org.junit.Test)

Aggregations

HistoricProcessInstanceQueryImpl (org.camunda.bpm.engine.impl.HistoricProcessInstanceQueryImpl)11 ArrayList (java.util.ArrayList)7 HashMap (java.util.HashMap)6 HistoricProcessInstanceQueryDto (org.camunda.bpm.engine.rest.dto.history.HistoricProcessInstanceQueryDto)6 Test (org.junit.Test)6 Matchers.anyString (org.mockito.Matchers.anyString)6 HashSet (java.util.HashSet)4 Map (java.util.Map)4 HistoricProcessInstance (org.camunda.bpm.engine.history.HistoricProcessInstance)2 HistoricProcessInstanceQuery (org.camunda.bpm.engine.history.HistoricProcessInstanceQuery)2 ProcessInstanceQueryImpl (org.camunda.bpm.engine.impl.ProcessInstanceQueryImpl)2 List (java.util.List)1 BadUserRequestException (org.camunda.bpm.engine.BadUserRequestException)1 CommandChecker (org.camunda.bpm.engine.impl.cfg.CommandChecker)1