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);
}
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;
}
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);
}
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);
}
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);
}
Aggregations