Search in sources :

Example 36 with HistoricProcessInstanceQuery

use of org.camunda.bpm.engine.history.HistoricProcessInstanceQuery in project camunda-bpm-platform by camunda.

the class HistoricProcessInstanceRestServiceQueryTest method testProcessQueryUnfinishedAsPost.

@Test
public void testProcessQueryUnfinishedAsPost() {
    List<HistoricProcessInstance> mockedHistoricProcessInstances = MockProvider.createMockRunningHistoricProcessInstances();
    HistoricProcessInstanceQuery mockedhistoricProcessInstanceQuery = mock(HistoricProcessInstanceQuery.class);
    when(mockedhistoricProcessInstanceQuery.list()).thenReturn(mockedHistoricProcessInstances);
    when(processEngine.getHistoryService().createHistoricProcessInstanceQuery()).thenReturn(mockedhistoricProcessInstanceQuery);
    Map<String, Boolean> body = new HashMap<String, Boolean>();
    body.put("unfinished", true);
    Response response = given().contentType(POST_JSON_CONTENT_TYPE).body(body).then().expect().statusCode(Status.OK.getStatusCode()).when().post(HISTORIC_PROCESS_INSTANCE_RESOURCE_URL);
    InOrder inOrder = inOrder(mockedhistoricProcessInstanceQuery);
    inOrder.verify(mockedhistoricProcessInstanceQuery).unfinished();
    inOrder.verify(mockedhistoricProcessInstanceQuery).list();
    String content = response.asString();
    List<String> instances = from(content).getList("");
    Assert.assertEquals("There should be one process instance returned.", 1, instances.size());
    Assert.assertNotNull("The returned process instance should not be null.", instances.get(0));
    String returnedProcessInstanceId = from(content).getString("[0].id");
    String returnedEndTime = from(content).getString("[0].endTime");
    Assert.assertEquals(MockProvider.EXAMPLE_PROCESS_INSTANCE_ID, returnedProcessInstanceId);
    Assert.assertEquals(null, returnedEndTime);
}
Also used : Response(com.jayway.restassured.response.Response) InOrder(org.mockito.InOrder) HistoricProcessInstanceQuery(org.camunda.bpm.engine.history.HistoricProcessInstanceQuery) HashMap(java.util.HashMap) HistoricProcessInstance(org.camunda.bpm.engine.history.HistoricProcessInstance) Matchers.containsString(org.hamcrest.Matchers.containsString) Test(org.junit.Test) AbstractRestServiceTest(org.camunda.bpm.engine.rest.AbstractRestServiceTest)

Example 37 with HistoricProcessInstanceQuery

use of org.camunda.bpm.engine.history.HistoricProcessInstanceQuery in project camunda-bpm-platform by camunda.

the class HistoricProcessInstanceRestServiceQueryTest method testProcessQueryUnfinished.

@Test
public void testProcessQueryUnfinished() {
    List<HistoricProcessInstance> mockedHistoricProcessInstances = MockProvider.createMockRunningHistoricProcessInstances();
    HistoricProcessInstanceQuery mockedhistoricProcessInstanceQuery = mock(HistoricProcessInstanceQuery.class);
    when(mockedhistoricProcessInstanceQuery.list()).thenReturn(mockedHistoricProcessInstances);
    when(processEngine.getHistoryService().createHistoricProcessInstanceQuery()).thenReturn(mockedhistoricProcessInstanceQuery);
    Response response = given().queryParam("unfinished", true).then().expect().statusCode(Status.OK.getStatusCode()).when().get(HISTORIC_PROCESS_INSTANCE_RESOURCE_URL);
    InOrder inOrder = inOrder(mockedhistoricProcessInstanceQuery);
    inOrder.verify(mockedhistoricProcessInstanceQuery).unfinished();
    inOrder.verify(mockedhistoricProcessInstanceQuery).list();
    String content = response.asString();
    List<String> instances = from(content).getList("");
    Assert.assertEquals("There should be one process instance returned.", 1, instances.size());
    Assert.assertNotNull("The returned process instance should not be null.", instances.get(0));
    String returnedProcessInstanceId = from(content).getString("[0].id");
    String returnedEndTime = from(content).getString("[0].endTime");
    Assert.assertEquals(MockProvider.EXAMPLE_PROCESS_INSTANCE_ID, returnedProcessInstanceId);
    Assert.assertEquals(null, returnedEndTime);
}
Also used : Response(com.jayway.restassured.response.Response) InOrder(org.mockito.InOrder) HistoricProcessInstanceQuery(org.camunda.bpm.engine.history.HistoricProcessInstanceQuery) HistoricProcessInstance(org.camunda.bpm.engine.history.HistoricProcessInstance) Matchers.containsString(org.hamcrest.Matchers.containsString) Test(org.junit.Test) AbstractRestServiceTest(org.camunda.bpm.engine.rest.AbstractRestServiceTest)

Example 38 with HistoricProcessInstanceQuery

use of org.camunda.bpm.engine.history.HistoricProcessInstanceQuery 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);
}
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)

Example 39 with HistoricProcessInstanceQuery

use of org.camunda.bpm.engine.history.HistoricProcessInstanceQuery in project camunda-bpm-platform by camunda.

the class ExternalTaskRestServiceInteractionTest method testSetRetriesForExternalTasksAsyncWithProcessInstanceQuery.

@Test
public void testSetRetriesForExternalTasksAsyncWithProcessInstanceQuery() {
    when(runtimeServiceMock.createProcessInstanceQuery()).thenReturn(new ProcessInstanceQueryImpl());
    ProcessInstanceQueryDto processInstanceQuery = new ProcessInstanceQueryDto();
    processInstanceQuery.setProcessDefinitionId(EXAMPLE_PROCESS_DEFINITION_ID);
    Map<String, Object> parameters = new HashMap<String, Object>();
    parameters.put("retries", "5");
    parameters.put("processInstanceQuery", processInstanceQuery);
    given().contentType(POST_JSON_CONTENT_TYPE).body(parameters).then().expect().statusCode(Status.OK.getStatusCode()).when().post(RETRIES_EXTERNAL_TASKS_ASYNC_URL);
    ArgumentCaptor<ProcessInstanceQuery> queryCapture = ArgumentCaptor.forClass(ProcessInstanceQuery.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(queryCapture.capture());
    verify(updateRetriesBuilder).historicProcessInstanceQuery(null);
    verify(updateRetriesBuilder).setAsync(5);
    verifyNoMoreInteractions(updateRetriesBuilder);
    ProcessInstanceQueryImpl actualQuery = (ProcessInstanceQueryImpl) queryCapture.getValue();
    assertThat(actualQuery).isNotNull();
    assertThat(actualQuery.getProcessDefinitionId()).isEqualTo(EXAMPLE_PROCESS_DEFINITION_ID);
}
Also used : HistoricProcessInstanceQuery(org.camunda.bpm.engine.history.HistoricProcessInstanceQuery) ProcessInstanceQuery(org.camunda.bpm.engine.runtime.ProcessInstanceQuery) HashMap(java.util.HashMap) ProcessInstanceQueryImpl(org.camunda.bpm.engine.impl.ProcessInstanceQueryImpl) HistoricProcessInstanceQueryImpl(org.camunda.bpm.engine.impl.HistoricProcessInstanceQueryImpl) ProcessInstanceQueryDto(org.camunda.bpm.engine.rest.dto.runtime.ProcessInstanceQueryDto) HistoricProcessInstanceQueryDto(org.camunda.bpm.engine.rest.dto.history.HistoricProcessInstanceQueryDto) Matchers.anyString(org.mockito.Matchers.anyString) Test(org.junit.Test)

Example 40 with HistoricProcessInstanceQuery

use of org.camunda.bpm.engine.history.HistoricProcessInstanceQuery in project camunda-bpm-platform by camunda.

the class ExternalTaskRestServiceInteractionTest method testSetRetriesWithProcessInstanceQuery.

@Test
public void testSetRetriesWithProcessInstanceQuery() {
    when(runtimeServiceMock.createProcessInstanceQuery()).thenReturn(new ProcessInstanceQueryImpl());
    ProcessInstanceQueryDto processInstanceQuery = new ProcessInstanceQueryDto();
    processInstanceQuery.setProcessDefinitionId(EXAMPLE_PROCESS_DEFINITION_ID);
    Map<String, Object> parameters = new HashMap<String, Object>();
    parameters.put("retries", "5");
    parameters.put("processInstanceQuery", processInstanceQuery);
    given().contentType(POST_JSON_CONTENT_TYPE).body(parameters).then().expect().statusCode(Status.NO_CONTENT.getStatusCode()).when().put(RETRIES_EXTERNAL_TASK_SYNC_URL);
    ArgumentCaptor<ProcessInstanceQuery> queryCapture = ArgumentCaptor.forClass(ProcessInstanceQuery.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(queryCapture.capture());
    verify(updateRetriesBuilder).historicProcessInstanceQuery(null);
    verify(updateRetriesBuilder).set(5);
    verifyNoMoreInteractions(updateRetriesBuilder);
    ProcessInstanceQueryImpl actualQuery = (ProcessInstanceQueryImpl) queryCapture.getValue();
    assertThat(actualQuery).isNotNull();
    assertThat(actualQuery.getProcessDefinitionId()).isEqualTo(EXAMPLE_PROCESS_DEFINITION_ID);
}
Also used : HistoricProcessInstanceQuery(org.camunda.bpm.engine.history.HistoricProcessInstanceQuery) ProcessInstanceQuery(org.camunda.bpm.engine.runtime.ProcessInstanceQuery) HashMap(java.util.HashMap) ProcessInstanceQueryImpl(org.camunda.bpm.engine.impl.ProcessInstanceQueryImpl) HistoricProcessInstanceQueryImpl(org.camunda.bpm.engine.impl.HistoricProcessInstanceQueryImpl) ProcessInstanceQueryDto(org.camunda.bpm.engine.rest.dto.runtime.ProcessInstanceQueryDto) HistoricProcessInstanceQueryDto(org.camunda.bpm.engine.rest.dto.history.HistoricProcessInstanceQueryDto) Matchers.anyString(org.mockito.Matchers.anyString) Test(org.junit.Test)

Aggregations

HistoricProcessInstanceQuery (org.camunda.bpm.engine.history.HistoricProcessInstanceQuery)71 Test (org.junit.Test)29 HistoricProcessInstance (org.camunda.bpm.engine.history.HistoricProcessInstance)25 Batch (org.camunda.bpm.engine.batch.Batch)16 HistoricProcessInstanceQueryDto (org.camunda.bpm.engine.rest.dto.history.HistoricProcessInstanceQueryDto)14 HashMap (java.util.HashMap)12 ProcessInstanceQuery (org.camunda.bpm.engine.runtime.ProcessInstanceQuery)11 Deployment (org.camunda.bpm.engine.test.Deployment)11 RequiredHistoryLevel (org.camunda.bpm.engine.test.RequiredHistoryLevel)10 ProcessInstance (org.camunda.bpm.engine.runtime.ProcessInstance)9 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)8 Matchers.anyString (org.mockito.Matchers.anyString)8 ArrayList (java.util.ArrayList)7 AbstractRestServiceTest (org.camunda.bpm.engine.rest.AbstractRestServiceTest)7 Response (com.jayway.restassured.response.Response)6 BadUserRequestException (org.camunda.bpm.engine.BadUserRequestException)6 HistoricBatch (org.camunda.bpm.engine.batch.history.HistoricBatch)6 ExternalTask (org.camunda.bpm.engine.externaltask.ExternalTask)4 HistoricProcessInstanceQueryImpl (org.camunda.bpm.engine.impl.HistoricProcessInstanceQueryImpl)4 InvalidRequestException (org.camunda.bpm.engine.rest.exception.InvalidRequestException)4