use of org.camunda.bpm.engine.history.HistoricProcessInstanceQuery 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.HistoricProcessInstanceQuery in project camunda-bpm-platform by camunda.
the class HistoricProcessInstanceRestServiceInteractionTest method testDeleteAsyncWithBadRequestQuery.
@Test
public void testDeleteAsyncWithBadRequestQuery() {
doThrow(new BadUserRequestException("process instance ids are empty")).when(historyServiceMock).deleteHistoricProcessInstancesAsync(eq((List<String>) null), eq((HistoricProcessInstanceQuery) null), anyString());
Map<String, Object> messageBodyJson = new HashMap<String, Object>();
messageBodyJson.put(DELETE_REASON, TEST_DELETE_REASON);
given().contentType(ContentType.JSON).body(messageBodyJson).then().expect().statusCode(Status.BAD_REQUEST.getStatusCode()).when().post(DELETE_HISTORIC_PROCESS_INSTANCES_ASYNC_URL);
}
use of org.camunda.bpm.engine.history.HistoricProcessInstanceQuery in project camunda-bpm-platform by camunda.
the class HistoricProcessInstanceRestServiceInteractionTest method testDeleteAsyncWithQuery.
@Test
public void testDeleteAsyncWithQuery() {
Batch batchEntity = MockProvider.createMockBatch();
when(historyServiceMock.deleteHistoricProcessInstancesAsync(anyListOf(String.class), any(HistoricProcessInstanceQuery.class), anyString())).thenReturn(batchEntity);
Map<String, Object> messageBodyJson = new HashMap<String, Object>();
messageBodyJson.put(DELETE_REASON, TEST_DELETE_REASON);
HistoricProcessInstanceQueryDto query = new HistoricProcessInstanceQueryDto();
messageBodyJson.put("historicProcessInstanceQuery", query);
Response response = given().contentType(ContentType.JSON).body(messageBodyJson).then().expect().statusCode(Status.OK.getStatusCode()).when().post(DELETE_HISTORIC_PROCESS_INSTANCES_ASYNC_URL);
verifyBatchJson(response.asString());
verify(historyServiceMock, times(1)).deleteHistoricProcessInstancesAsync(eq((List<String>) null), any(HistoricProcessInstanceQuery.class), Mockito.eq(TEST_DELETE_REASON));
}
use of org.camunda.bpm.engine.history.HistoricProcessInstanceQuery 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.HistoricProcessInstanceQuery in project camunda-bpm-platform by camunda.
the class HistoricProcessInstanceRestServiceQueryTest method setUpMockHistoricProcessInstanceQuery.
private HistoricProcessInstanceQuery setUpMockHistoricProcessInstanceQuery(List<HistoricProcessInstance> mockedHistoricProcessInstances) {
HistoricProcessInstanceQuery mockedhistoricProcessInstanceQuery = mock(HistoricProcessInstanceQuery.class);
when(mockedhistoricProcessInstanceQuery.list()).thenReturn(mockedHistoricProcessInstances);
when(mockedhistoricProcessInstanceQuery.count()).thenReturn((long) mockedHistoricProcessInstances.size());
when(processEngine.getHistoryService().createHistoricProcessInstanceQuery()).thenReturn(mockedhistoricProcessInstanceQuery);
return mockedhistoricProcessInstanceQuery;
}
Aggregations