use of org.camunda.bpm.engine.history.HistoricActivityInstance in project camunda-bpm-platform by camunda.
the class ProcessEngineRestServiceTest method createHistoricActivityInstanceMock.
private void createHistoricActivityInstanceMock() {
List<HistoricActivityInstance> activities = new ArrayList<HistoricActivityInstance>();
HistoricActivityInstance mockInstance = MockProvider.createMockHistoricActivityInstance();
activities.add(mockInstance);
HistoricActivityInstanceQuery mockHistoricActivityInstanceQuery = mock(HistoricActivityInstanceQuery.class);
when(mockHistoricActivityInstanceQuery.list()).thenReturn(activities);
when(mockHistoryService.createHistoricActivityInstanceQuery()).thenReturn(mockHistoricActivityInstanceQuery);
}
use of org.camunda.bpm.engine.history.HistoricActivityInstance in project camunda-bpm-platform by camunda.
the class MockProvider method createMockRunningHistoricActivityInstance.
public static HistoricActivityInstance createMockRunningHistoricActivityInstance() {
HistoricActivityInstance mock = mock(HistoricActivityInstance.class);
when(mock.getId()).thenReturn(EXAMPLE_HISTORIC_ACTIVITY_INSTANCE_ID);
when(mock.getParentActivityInstanceId()).thenReturn(EXAMPLE_HISTORIC_ACTIVITY_INSTANCE_PARENT_ACTIVITY_INSTANCE_ID);
when(mock.getActivityId()).thenReturn(EXAMPLE_ACTIVITY_ID);
when(mock.getActivityName()).thenReturn(EXAMPLE_ACTIVITY_NAME);
when(mock.getActivityType()).thenReturn(EXAMPLE_ACTIVITY_TYPE);
when(mock.getProcessDefinitionId()).thenReturn(EXAMPLE_PROCESS_DEFINITION_ID);
when(mock.getProcessInstanceId()).thenReturn(EXAMPLE_PROCESS_INSTANCE_ID);
when(mock.getExecutionId()).thenReturn(EXAMPLE_EXECUTION_ID);
when(mock.getTaskId()).thenReturn(EXAMPLE_TASK_ID);
when(mock.getCalledProcessInstanceId()).thenReturn(EXAMPLE_HISTORIC_ACTIVITY_INSTANCE_CALLED_PROCESS_INSTANCE_ID);
when(mock.getCalledCaseInstanceId()).thenReturn(EXAMPLE_HISTORIC_ACTIVITY_INSTANCE_CALLED_CASE_INSTANCE_ID);
when(mock.getAssignee()).thenReturn(EXAMPLE_TASK_ASSIGNEE_NAME);
when(mock.getStartTime()).thenReturn(DateTimeUtil.parseDate(EXAMPLE_HISTORIC_ACTIVITY_INSTANCE_START_TIME));
when(mock.getEndTime()).thenReturn(null);
when(mock.getDurationInMillis()).thenReturn(null);
return mock;
}
use of org.camunda.bpm.engine.history.HistoricActivityInstance in project camunda-bpm-platform by camunda.
the class HistoricActivityInstanceRestServiceQueryTest method testUnfinishedHistoricActivityQuery.
@Test
public void testUnfinishedHistoricActivityQuery() {
List<HistoricActivityInstance> mockedHistoricActivityInstances = MockProvider.createMockRunningHistoricActivityInstances();
HistoricActivityInstanceQuery mockedhistoricActivityInstanceQuery = mock(HistoricActivityInstanceQuery.class);
when(mockedhistoricActivityInstanceQuery.list()).thenReturn(mockedHistoricActivityInstances);
when(processEngine.getHistoryService().createHistoricActivityInstanceQuery()).thenReturn(mockedhistoricActivityInstanceQuery);
Response response = given().queryParam("unfinished", true).then().expect().statusCode(Status.OK.getStatusCode()).when().get(HISTORIC_ACTIVITY_INSTANCE_RESOURCE_URL);
InOrder inOrder = inOrder(mockedhistoricActivityInstanceQuery);
inOrder.verify(mockedhistoricActivityInstanceQuery).unfinished();
inOrder.verify(mockedhistoricActivityInstanceQuery).list();
String content = response.asString();
List<String> instances = from(content).getList("");
Assert.assertEquals("There should be one activity instance returned.", 1, instances.size());
Assert.assertNotNull("The returned activity instance should not be null.", instances.get(0));
String returnedProcessDefinitionId = from(content).getString("[0].processDefinitionId");
String returnedActivityEndTime = from(content).getString("[0].endTime");
Assert.assertEquals(MockProvider.EXAMPLE_PROCESS_DEFINITION_ID, returnedProcessDefinitionId);
Assert.assertNull(returnedActivityEndTime);
}
use of org.camunda.bpm.engine.history.HistoricActivityInstance in project camunda-bpm-platform by camunda.
the class HistoricActivityInstanceRestServiceQueryTest method testUnfinishedHistoricActivityQueryAsPost.
@Test
public void testUnfinishedHistoricActivityQueryAsPost() {
List<HistoricActivityInstance> mockedHistoricActivityInstances = MockProvider.createMockRunningHistoricActivityInstances();
HistoricActivityInstanceQuery mockedhistoricActivityInstanceQuery = mock(HistoricActivityInstanceQuery.class);
when(mockedhistoricActivityInstanceQuery.list()).thenReturn(mockedHistoricActivityInstances);
when(processEngine.getHistoryService().createHistoricActivityInstanceQuery()).thenReturn(mockedhistoricActivityInstanceQuery);
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_ACTIVITY_INSTANCE_RESOURCE_URL);
InOrder inOrder = inOrder(mockedhistoricActivityInstanceQuery);
inOrder.verify(mockedhistoricActivityInstanceQuery).unfinished();
inOrder.verify(mockedhistoricActivityInstanceQuery).list();
String content = response.asString();
List<String> instances = from(content).getList("");
Assert.assertEquals("There should be one activity instance returned.", 1, instances.size());
Assert.assertNotNull("The returned activity instance should not be null.", instances.get(0));
String returnedProcessDefinitionId = from(content).getString("[0].processDefinitionId");
String returnedActivityEndTime = from(content).getString("[0].endTime");
Assert.assertEquals(MockProvider.EXAMPLE_PROCESS_DEFINITION_ID, returnedProcessDefinitionId);
Assert.assertNull(returnedActivityEndTime);
}
use of org.camunda.bpm.engine.history.HistoricActivityInstance in project camunda-bpm-platform by camunda.
the class MockProvider method createMockHistoricActivityInstance.
public static HistoricActivityInstance createMockHistoricActivityInstance(String tenantId) {
HistoricActivityInstance mock = mock(HistoricActivityInstance.class);
when(mock.getId()).thenReturn(EXAMPLE_HISTORIC_ACTIVITY_INSTANCE_ID);
when(mock.getParentActivityInstanceId()).thenReturn(EXAMPLE_HISTORIC_ACTIVITY_INSTANCE_PARENT_ACTIVITY_INSTANCE_ID);
when(mock.getActivityId()).thenReturn(EXAMPLE_ACTIVITY_ID);
when(mock.getActivityName()).thenReturn(EXAMPLE_ACTIVITY_NAME);
when(mock.getActivityType()).thenReturn(EXAMPLE_ACTIVITY_TYPE);
when(mock.getProcessDefinitionKey()).thenReturn(EXAMPLE_PROCESS_DEFINITION_KEY);
when(mock.getProcessDefinitionId()).thenReturn(EXAMPLE_PROCESS_DEFINITION_ID);
when(mock.getProcessInstanceId()).thenReturn(EXAMPLE_PROCESS_INSTANCE_ID);
when(mock.getExecutionId()).thenReturn(EXAMPLE_EXECUTION_ID);
when(mock.getTaskId()).thenReturn(EXAMPLE_TASK_ID);
when(mock.getCalledProcessInstanceId()).thenReturn(EXAMPLE_HISTORIC_ACTIVITY_INSTANCE_CALLED_PROCESS_INSTANCE_ID);
when(mock.getCalledCaseInstanceId()).thenReturn(EXAMPLE_HISTORIC_ACTIVITY_INSTANCE_CALLED_CASE_INSTANCE_ID);
when(mock.getAssignee()).thenReturn(EXAMPLE_TASK_ASSIGNEE_NAME);
when(mock.getStartTime()).thenReturn(DateTimeUtil.parseDate(EXAMPLE_HISTORIC_ACTIVITY_INSTANCE_START_TIME));
when(mock.getEndTime()).thenReturn(DateTimeUtil.parseDate(EXAMPLE_HISTORIC_ACTIVITY_INSTANCE_END_TIME));
when(mock.getDurationInMillis()).thenReturn(EXAMPLE_HISTORIC_ACTIVITY_INSTANCE_DURATION);
when(mock.isCanceled()).thenReturn(EXAMPLE_HISTORIC_ACTIVITY_INSTANCE_IS_CANCELED);
when(mock.isCompleteScope()).thenReturn(EXAMPLE_HISTORIC_ACTIVITY_INSTANCE_IS_COMPLETE_SCOPE);
when(mock.getTenantId()).thenReturn(tenantId);
return mock;
}
Aggregations