Search in sources :

Example 1 with HistoricProcessInstanceQueryDto

use of org.camunda.bpm.engine.rest.dto.history.HistoricProcessInstanceQueryDto in project camunda-bpm-platform by camunda.

the class ExternalTaskRestServiceImpl method updateRetries.

protected UpdateExternalTaskRetriesBuilder updateRetries(SetRetriesForExternalTasksDto retriesDto) {
    ExternalTaskService externalTaskService = getProcessEngine().getExternalTaskService();
    List<String> externalTaskIds = retriesDto.getExternalTaskIds();
    List<String> processInstanceIds = retriesDto.getProcessInstanceIds();
    ExternalTaskQuery externalTaskQuery = null;
    ProcessInstanceQuery processInstanceQuery = null;
    HistoricProcessInstanceQuery historicProcessInstanceQuery = null;
    ExternalTaskQueryDto externalTaskQueryDto = retriesDto.getExternalTaskQuery();
    if (externalTaskQueryDto != null) {
        externalTaskQuery = externalTaskQueryDto.toQuery(getProcessEngine());
    }
    ProcessInstanceQueryDto processInstanceQueryDto = retriesDto.getProcessInstanceQuery();
    if (processInstanceQueryDto != null) {
        processInstanceQuery = processInstanceQueryDto.toQuery(getProcessEngine());
    }
    HistoricProcessInstanceQueryDto historicProcessInstanceQueryDto = retriesDto.getHistoricProcessInstanceQuery();
    if (historicProcessInstanceQueryDto != null) {
        historicProcessInstanceQuery = historicProcessInstanceQueryDto.toQuery(getProcessEngine());
    }
    return externalTaskService.updateRetries().externalTaskIds(externalTaskIds).processInstanceIds(processInstanceIds).externalTaskQuery(externalTaskQuery).processInstanceQuery(processInstanceQuery).historicProcessInstanceQuery(historicProcessInstanceQuery);
}
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) ExternalTaskQuery(org.camunda.bpm.engine.externaltask.ExternalTaskQuery) HistoricProcessInstanceQuery(org.camunda.bpm.engine.history.HistoricProcessInstanceQuery) ExternalTaskQueryDto(org.camunda.bpm.engine.rest.dto.externaltask.ExternalTaskQueryDto) ExternalTaskService(org.camunda.bpm.engine.ExternalTaskService) ProcessInstanceQueryDto(org.camunda.bpm.engine.rest.dto.runtime.ProcessInstanceQueryDto) HistoricProcessInstanceQueryDto(org.camunda.bpm.engine.rest.dto.history.HistoricProcessInstanceQueryDto)

Example 2 with HistoricProcessInstanceQueryDto

use of org.camunda.bpm.engine.rest.dto.history.HistoricProcessInstanceQueryDto 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 3 with HistoricProcessInstanceQueryDto

use of org.camunda.bpm.engine.rest.dto.history.HistoricProcessInstanceQueryDto 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 4 with HistoricProcessInstanceQueryDto

use of org.camunda.bpm.engine.rest.dto.history.HistoricProcessInstanceQueryDto 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 5 with HistoricProcessInstanceQueryDto

use of org.camunda.bpm.engine.rest.dto.history.HistoricProcessInstanceQueryDto in project camunda-bpm-platform by camunda.

the class ProcessInstanceRestServiceInteractionTest method testSetRetriesByProcessWithNegativeRetries.

@Test
public void testSetRetriesByProcessWithNegativeRetries() {
    doThrow(new BadUserRequestException("retries are negative")).when(mockManagementService).setJobRetriesAsync(anyListOf(String.class), any(ProcessInstanceQuery.class), eq(-1));
    Map<String, Object> messageBodyJson = new HashMap<String, Object>();
    messageBodyJson.put(RETRIES, -1);
    HistoricProcessInstanceQueryDto query = new HistoricProcessInstanceQueryDto();
    messageBodyJson.put("processInstanceQuery", query);
    given().contentType(ContentType.JSON).body(messageBodyJson).then().expect().statusCode(Status.BAD_REQUEST.getStatusCode()).when().post(SET_JOB_RETRIES_ASYNC_URL);
}
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) HashMap(java.util.HashMap) ExampleVariableObject(org.camunda.bpm.engine.rest.helper.ExampleVariableObject) BadUserRequestException(org.camunda.bpm.engine.BadUserRequestException) Test(org.junit.Test)

Aggregations

HistoricProcessInstanceQueryDto (org.camunda.bpm.engine.rest.dto.history.HistoricProcessInstanceQueryDto)20 Test (org.junit.Test)17 HistoricProcessInstanceQuery (org.camunda.bpm.engine.history.HistoricProcessInstanceQuery)14 HashMap (java.util.HashMap)12 Matchers.anyString (org.mockito.Matchers.anyString)9 ProcessInstanceQuery (org.camunda.bpm.engine.runtime.ProcessInstanceQuery)8 ArrayList (java.util.ArrayList)7 Batch (org.camunda.bpm.engine.batch.Batch)7 HistoricProcessInstance (org.camunda.bpm.engine.history.HistoricProcessInstance)7 HistoricProcessInstanceQueryImpl (org.camunda.bpm.engine.impl.HistoricProcessInstanceQueryImpl)6 BadUserRequestException (org.camunda.bpm.engine.BadUserRequestException)5 Response (com.jayway.restassured.response.Response)4 Map (java.util.Map)4 List (java.util.List)3 SetJobRetriesByProcessDto (org.camunda.bpm.engine.rest.dto.runtime.SetJobRetriesByProcessDto)3 ExampleVariableObject (org.camunda.bpm.engine.rest.helper.ExampleVariableObject)3 BatchEntity (org.camunda.bpm.engine.impl.batch.BatchEntity)2 DeleteProcessInstancesDto (org.camunda.bpm.engine.rest.dto.runtime.batch.DeleteProcessInstancesDto)2 InvalidRequestException (org.camunda.bpm.engine.rest.exception.InvalidRequestException)2 JobQuery (org.camunda.bpm.engine.runtime.JobQuery)2