Search in sources :

Example 1 with HistoricActivityInstance

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);
}
Also used : HistoricActivityInstanceQuery(org.camunda.bpm.engine.history.HistoricActivityInstanceQuery) ArrayList(java.util.ArrayList) HistoricActivityInstance(org.camunda.bpm.engine.history.HistoricActivityInstance)

Example 2 with HistoricActivityInstance

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;
}
Also used : HistoricActivityInstance(org.camunda.bpm.engine.history.HistoricActivityInstance)

Example 3 with HistoricActivityInstance

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);
}
Also used : Response(com.jayway.restassured.response.Response) HistoricActivityInstanceQuery(org.camunda.bpm.engine.history.HistoricActivityInstanceQuery) InOrder(org.mockito.InOrder) Matchers.containsString(org.hamcrest.Matchers.containsString) HistoricActivityInstance(org.camunda.bpm.engine.history.HistoricActivityInstance) Test(org.junit.Test) AbstractRestServiceTest(org.camunda.bpm.engine.rest.AbstractRestServiceTest)

Example 4 with HistoricActivityInstance

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);
}
Also used : Response(com.jayway.restassured.response.Response) HistoricActivityInstanceQuery(org.camunda.bpm.engine.history.HistoricActivityInstanceQuery) InOrder(org.mockito.InOrder) HashMap(java.util.HashMap) Matchers.containsString(org.hamcrest.Matchers.containsString) HistoricActivityInstance(org.camunda.bpm.engine.history.HistoricActivityInstance) Test(org.junit.Test) AbstractRestServiceTest(org.camunda.bpm.engine.rest.AbstractRestServiceTest)

Example 5 with HistoricActivityInstance

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;
}
Also used : HistoricActivityInstance(org.camunda.bpm.engine.history.HistoricActivityInstance)

Aggregations

HistoricActivityInstance (org.camunda.bpm.engine.history.HistoricActivityInstance)80 Deployment (org.camunda.bpm.engine.test.Deployment)56 ProcessInstance (org.camunda.bpm.engine.runtime.ProcessInstance)45 HistoricProcessInstance (org.camunda.bpm.engine.history.HistoricProcessInstance)24 Task (org.camunda.bpm.engine.task.Task)19 Test (org.junit.Test)17 HistoricActivityInstanceQuery (org.camunda.bpm.engine.history.HistoricActivityInstanceQuery)13 HashMap (java.util.HashMap)12 RequiredHistoryLevel (org.camunda.bpm.engine.test.RequiredHistoryLevel)8 ProcessDefinition (org.camunda.bpm.engine.repository.ProcessDefinition)6 Date (java.util.Date)5 HistoricDetail (org.camunda.bpm.engine.history.HistoricDetail)5 MigrationPlan (org.camunda.bpm.engine.migration.MigrationPlan)5 HistoricTaskInstance (org.camunda.bpm.engine.history.HistoricTaskInstance)4 ArrayList (java.util.ArrayList)3 HistoryService (org.camunda.bpm.engine.HistoryService)3 HistoricVariableUpdate (org.camunda.bpm.engine.history.HistoricVariableUpdate)3 Response (com.jayway.restassured.response.Response)2 HistoricVariableInstance (org.camunda.bpm.engine.history.HistoricVariableInstance)2 HistoricVariableInstanceQuery (org.camunda.bpm.engine.history.HistoricVariableInstanceQuery)2