Search in sources :

Example 56 with HistoricProcessInstance

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

the class ProcessEngineRestServiceTest method createHistoricProcessInstanceMock.

private void createHistoricProcessInstanceMock() {
    List<HistoricProcessInstance> processes = new ArrayList<HistoricProcessInstance>();
    HistoricProcessInstance mockInstance = MockProvider.createMockHistoricProcessInstance();
    processes.add(mockInstance);
    HistoricProcessInstanceQuery mockHistoricProcessInstanceQuery = mock(HistoricProcessInstanceQuery.class);
    when(mockHistoricProcessInstanceQuery.list()).thenReturn(processes);
    when(mockHistoryService.createHistoricProcessInstanceQuery()).thenReturn(mockHistoricProcessInstanceQuery);
}
Also used : HistoricProcessInstanceQuery(org.camunda.bpm.engine.history.HistoricProcessInstanceQuery) HistoricProcessInstance(org.camunda.bpm.engine.history.HistoricProcessInstance) ArrayList(java.util.ArrayList)

Example 57 with HistoricProcessInstance

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

the class MockProvider method createMockHistoricProcessInstance.

public static HistoricProcessInstance createMockHistoricProcessInstance(String tenantId) {
    HistoricProcessInstance mock = mock(HistoricProcessInstance.class);
    when(mock.getId()).thenReturn(EXAMPLE_PROCESS_INSTANCE_ID);
    when(mock.getBusinessKey()).thenReturn(EXAMPLE_PROCESS_INSTANCE_BUSINESS_KEY);
    when(mock.getProcessDefinitionKey()).thenReturn(EXAMPLE_PROCESS_DEFINITION_KEY);
    when(mock.getProcessDefinitionName()).thenReturn(EXAMPLE_PROCESS_DEFINITION_NAME);
    when(mock.getProcessDefinitionVersion()).thenReturn(EXAMPLE_PROCESS_DEFINITION_VERSION);
    when(mock.getProcessDefinitionId()).thenReturn(EXAMPLE_PROCESS_DEFINITION_ID);
    when(mock.getDeleteReason()).thenReturn(EXAMPLE_HISTORIC_PROCESS_INSTANCE_DELETE_REASON);
    when(mock.getEndTime()).thenReturn(DateTimeUtil.parseDate(EXAMPLE_HISTORIC_PROCESS_INSTANCE_END_TIME));
    when(mock.getStartTime()).thenReturn(DateTimeUtil.parseDate(EXAMPLE_HISTORIC_PROCESS_INSTANCE_START_TIME));
    when(mock.getDurationInMillis()).thenReturn(EXAMPLE_HISTORIC_PROCESS_INSTANCE_DURATION_MILLIS);
    when(mock.getStartUserId()).thenReturn(EXAMPLE_HISTORIC_PROCESS_INSTANCE_START_USER_ID);
    when(mock.getStartActivityId()).thenReturn(EXAMPLE_HISTORIC_PROCESS_INSTANCE_START_ACTIVITY_ID);
    when(mock.getSuperProcessInstanceId()).thenReturn(EXAMPLE_HISTORIC_PROCESS_INSTANCE_SUPER_PROCESS_INSTANCE_ID);
    when(mock.getSuperCaseInstanceId()).thenReturn(EXAMPLE_HISTORIC_PROCESS_INSTANCE_SUPER_CASE_INSTANCE_ID);
    when(mock.getCaseInstanceId()).thenReturn(EXAMPLE_HISTORIC_PROCESS_INSTANCE_CASE_INSTANCE_ID);
    when(mock.getTenantId()).thenReturn(tenantId);
    when(mock.getState()).thenReturn(EXAMPLE_HISTORIC_PROCESS_INSTANCE_STATE);
    return mock;
}
Also used : HistoricProcessInstance(org.camunda.bpm.engine.history.HistoricProcessInstance)

Example 58 with HistoricProcessInstance

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

the class HistoricProcessInstanceRestServiceInteractionTest method testGetSingleInstance.

@Test
public void testGetSingleInstance() {
    HistoricProcessInstance mockInstance = MockProvider.createMockHistoricProcessInstance();
    HistoricProcessInstanceQuery sampleInstanceQuery = mock(HistoricProcessInstanceQuery.class);
    when(historyServiceMock.createHistoricProcessInstanceQuery()).thenReturn(sampleInstanceQuery);
    when(sampleInstanceQuery.processInstanceId(MockProvider.EXAMPLE_PROCESS_INSTANCE_ID)).thenReturn(sampleInstanceQuery);
    when(sampleInstanceQuery.singleResult()).thenReturn(mockInstance);
    Response response = given().pathParam("id", MockProvider.EXAMPLE_PROCESS_INSTANCE_ID).then().expect().statusCode(Status.OK.getStatusCode()).when().get(HISTORIC_SINGLE_PROCESS_INSTANCE_URL);
    String content = response.asString();
    String returnedProcessInstanceId = from(content).getString("id");
    String returnedProcessInstanceBusinessKey = from(content).getString("businessKey");
    String returnedProcessDefinitionId = from(content).getString("processDefinitionId");
    String returnedProcessDefinitionKey = from(content).getString("processDefinitionKey");
    String returnedStartTime = from(content).getString("startTime");
    String returnedEndTime = from(content).getString("endTime");
    long returnedDurationInMillis = from(content).getLong("durationInMillis");
    String returnedStartUserId = from(content).getString("startUserId");
    String returnedStartActivityId = from(content).getString("startActivityId");
    String returnedDeleteReason = from(content).getString(DELETE_REASON);
    String returnedSuperProcessInstanceId = from(content).getString("superProcessInstanceId");
    String returnedSuperCaseInstanceId = from(content).getString("superCaseInstanceId");
    String returnedCaseInstanceId = from(content).getString("caseInstanceId");
    String returnedTenantId = from(content).getString("tenantId");
    String returnedState = from(content).getString("state");
    Assert.assertEquals(MockProvider.EXAMPLE_PROCESS_INSTANCE_ID, returnedProcessInstanceId);
    Assert.assertEquals(MockProvider.EXAMPLE_PROCESS_INSTANCE_BUSINESS_KEY, returnedProcessInstanceBusinessKey);
    Assert.assertEquals(MockProvider.EXAMPLE_PROCESS_DEFINITION_ID, returnedProcessDefinitionId);
    Assert.assertEquals(MockProvider.EXAMPLE_PROCESS_DEFINITION_KEY, returnedProcessDefinitionKey);
    Assert.assertEquals(MockProvider.EXAMPLE_HISTORIC_PROCESS_INSTANCE_START_TIME, returnedStartTime);
    Assert.assertEquals(MockProvider.EXAMPLE_HISTORIC_PROCESS_INSTANCE_END_TIME, returnedEndTime);
    Assert.assertEquals(MockProvider.EXAMPLE_HISTORIC_PROCESS_INSTANCE_DURATION_MILLIS, returnedDurationInMillis);
    Assert.assertEquals(MockProvider.EXAMPLE_HISTORIC_PROCESS_INSTANCE_START_USER_ID, returnedStartUserId);
    Assert.assertEquals(MockProvider.EXAMPLE_HISTORIC_PROCESS_INSTANCE_START_ACTIVITY_ID, returnedStartActivityId);
    Assert.assertEquals(MockProvider.EXAMPLE_HISTORIC_PROCESS_INSTANCE_DELETE_REASON, returnedDeleteReason);
    Assert.assertEquals(MockProvider.EXAMPLE_HISTORIC_PROCESS_INSTANCE_SUPER_PROCESS_INSTANCE_ID, returnedSuperProcessInstanceId);
    Assert.assertEquals(MockProvider.EXAMPLE_HISTORIC_PROCESS_INSTANCE_SUPER_CASE_INSTANCE_ID, returnedSuperCaseInstanceId);
    Assert.assertEquals(MockProvider.EXAMPLE_HISTORIC_PROCESS_INSTANCE_CASE_INSTANCE_ID, returnedCaseInstanceId);
    Assert.assertEquals(MockProvider.EXAMPLE_TENANT_ID, returnedTenantId);
    Assert.assertEquals(MockProvider.EXAMPLE_HISTORIC_PROCESS_INSTANCE_STATE, returnedState);
}
Also used : Response(com.jayway.restassured.response.Response) HistoricProcessInstanceQuery(org.camunda.bpm.engine.history.HistoricProcessInstanceQuery) HistoricProcessInstance(org.camunda.bpm.engine.history.HistoricProcessInstance) Matchers.anyString(org.mockito.Matchers.anyString) Test(org.junit.Test) AbstractRestServiceTest(org.camunda.bpm.engine.rest.AbstractRestServiceTest)

Example 59 with HistoricProcessInstance

use of org.camunda.bpm.engine.history.HistoricProcessInstance 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 60 with HistoricProcessInstance

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

Aggregations

HistoricProcessInstance (org.camunda.bpm.engine.history.HistoricProcessInstance)113 Deployment (org.camunda.bpm.engine.test.Deployment)46 Test (org.junit.Test)37 ProcessInstance (org.camunda.bpm.engine.runtime.ProcessInstance)36 HistoricProcessInstanceQuery (org.camunda.bpm.engine.history.HistoricProcessInstanceQuery)25 Task (org.camunda.bpm.engine.task.Task)19 BpmnModelInstance (org.camunda.bpm.model.bpmn.BpmnModelInstance)18 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)17 ArrayList (java.util.ArrayList)15 Calendar (java.util.Calendar)12 ProcessDefinition (org.camunda.bpm.engine.repository.ProcessDefinition)12 GregorianCalendar (java.util.GregorianCalendar)11 HistoricActivityInstance (org.camunda.bpm.engine.history.HistoricActivityInstance)9 RequiredHistoryLevel (org.camunda.bpm.engine.test.RequiredHistoryLevel)9 HistoricProcessInstanceQueryDto (org.camunda.bpm.engine.rest.dto.history.HistoricProcessInstanceQueryDto)7 List (java.util.List)5 ProcessInstanceQuery (org.camunda.bpm.engine.runtime.ProcessInstanceQuery)5 Response (com.jayway.restassured.response.Response)4 Date (java.util.Date)4 HashMap (java.util.HashMap)4