Search in sources :

Example 11 with HistoricProcessInstanceQueryDto

use of org.camunda.bpm.engine.rest.dto.history.HistoricProcessInstanceQueryDto in project camunda-bpm-platform by camunda.

the class ProcessInstanceRestServiceInteractionTest method testSetRetriesByProcessAsyncHistoricQueryBasedWithQuery.

@Test
public void testSetRetriesByProcessAsyncHistoricQueryBasedWithQuery() {
    Batch batchEntity = MockProvider.createMockBatch();
    when(mockManagementService.setJobRetriesAsync(anyListOf(String.class), eq((ProcessInstanceQuery) null), anyInt())).thenReturn(batchEntity);
    HistoricProcessInstanceQuery mockedHistoricProcessInstanceQuery = mock(HistoricProcessInstanceQuery.class);
    when(historyServiceMock.createHistoricProcessInstanceQuery()).thenReturn(mockedHistoricProcessInstanceQuery);
    List<HistoricProcessInstance> historicProcessInstances = MockProvider.createMockRunningHistoricProcessInstances();
    when(mockedHistoricProcessInstanceQuery.list()).thenReturn(historicProcessInstances);
    SetJobRetriesByProcessDto body = new SetJobRetriesByProcessDto();
    body.setRetries(MockProvider.EXAMPLE_JOB_RETRIES);
    body.setHistoricProcessInstanceQuery(new HistoricProcessInstanceQueryDto());
    Response response = given().contentType(ContentType.JSON).body(body).then().expect().statusCode(Status.OK.getStatusCode()).when().post(SET_JOB_RETRIES_ASYNC_HIST_QUERY_URL);
    verifyBatchJson(response.asString());
    verify(mockManagementService, times(1)).setJobRetriesAsync(eq(Arrays.asList(MockProvider.EXAMPLE_PROCESS_INSTANCE_ID)), eq((ProcessInstanceQuery) null), eq(MockProvider.EXAMPLE_JOB_RETRIES));
}
Also used : Response(com.jayway.restassured.response.Response) HistoricProcessInstanceQueryDto(org.camunda.bpm.engine.rest.dto.history.HistoricProcessInstanceQueryDto) HistoricProcessInstanceQuery(org.camunda.bpm.engine.history.HistoricProcessInstanceQuery) ProcessInstanceQuery(org.camunda.bpm.engine.runtime.ProcessInstanceQuery) HistoricProcessInstanceQuery(org.camunda.bpm.engine.history.HistoricProcessInstanceQuery) Batch(org.camunda.bpm.engine.batch.Batch) HistoricProcessInstance(org.camunda.bpm.engine.history.HistoricProcessInstance) SetJobRetriesByProcessDto(org.camunda.bpm.engine.rest.dto.runtime.SetJobRetriesByProcessDto) Test(org.junit.Test)

Example 12 with HistoricProcessInstanceQueryDto

use of org.camunda.bpm.engine.rest.dto.history.HistoricProcessInstanceQueryDto in project camunda-bpm-platform by camunda.

the class ProcessInstanceRestServiceInteractionTest method testSuspendHistoricProcessInstanceQuery.

@Test
public void testSuspendHistoricProcessInstanceQuery() {
    HistoricProcessInstanceQueryDto query = new HistoricProcessInstanceQueryDto();
    Map<String, Object> messageBodyJson = new HashMap<String, Object>();
    messageBodyJson.put("historicProcessInstanceQuery", query);
    messageBodyJson.put("suspended", true);
    given().contentType(ContentType.JSON).body(messageBodyJson).then().expect().statusCode(Status.NO_CONTENT.getStatusCode()).when().put(PROCESS_INSTANCE_SUSPENDED_URL);
    verify(mockUpdateSuspensionStateSelectBuilder).byHistoricProcessInstanceQuery(any(HistoricProcessInstanceQuery.class));
    verify(mockUpdateProcessInstancesSuspensionStateBuilder).suspend();
}
Also used : HistoricProcessInstanceQueryDto(org.camunda.bpm.engine.rest.dto.history.HistoricProcessInstanceQueryDto) HistoricProcessInstanceQuery(org.camunda.bpm.engine.history.HistoricProcessInstanceQuery) HashMap(java.util.HashMap) ExampleVariableObject(org.camunda.bpm.engine.rest.helper.ExampleVariableObject) Test(org.junit.Test)

Example 13 with HistoricProcessInstanceQueryDto

use of org.camunda.bpm.engine.rest.dto.history.HistoricProcessInstanceQueryDto in project camunda-bpm-platform by camunda.

the class ProcessInstanceRestServiceInteractionTest method testDeleteAsyncHistoricQueryBasedWithQueryAndProcessInstanceIds.

@Test
public void testDeleteAsyncHistoricQueryBasedWithQueryAndProcessInstanceIds() {
    when(runtimeServiceMock.deleteProcessInstancesAsync(anyListOf(String.class), any(ProcessInstanceQuery.class), anyString(), anyBoolean(), anyBoolean())).thenReturn(new BatchEntity());
    HistoricProcessInstanceQuery mockedHistoricProcessInstanceQuery = mock(HistoricProcessInstanceQueryImpl.class);
    when(historyServiceMock.createHistoricProcessInstanceQuery()).thenReturn(mockedHistoricProcessInstanceQuery);
    List<HistoricProcessInstance> historicProcessInstances = MockProvider.createMockRunningHistoricProcessInstances();
    when(mockedHistoricProcessInstanceQuery.list()).thenReturn(historicProcessInstances);
    DeleteProcessInstancesDto body = new DeleteProcessInstancesDto();
    body.setHistoricProcessInstanceQuery(new HistoricProcessInstanceQueryDto());
    body.setProcessInstanceIds(Arrays.asList(MockProvider.ANOTHER_EXAMPLE_PROCESS_INSTANCE_ID));
    given().contentType(ContentType.JSON).body(body).then().expect().statusCode(Status.OK.getStatusCode()).when().post(DELETE_PROCESS_INSTANCES_ASYNC_HIST_QUERY_URL);
    verify(runtimeServiceMock, times(1)).deleteProcessInstancesAsync(Arrays.asList(MockProvider.EXAMPLE_PROCESS_INSTANCE_ID, MockProvider.ANOTHER_EXAMPLE_PROCESS_INSTANCE_ID), null, null, false, false);
}
Also used : HistoricProcessInstanceQueryDto(org.camunda.bpm.engine.rest.dto.history.HistoricProcessInstanceQueryDto) HistoricProcessInstanceQuery(org.camunda.bpm.engine.history.HistoricProcessInstanceQuery) ProcessInstanceQuery(org.camunda.bpm.engine.runtime.ProcessInstanceQuery) HistoricProcessInstanceQuery(org.camunda.bpm.engine.history.HistoricProcessInstanceQuery) BatchEntity(org.camunda.bpm.engine.impl.batch.BatchEntity) HistoricProcessInstance(org.camunda.bpm.engine.history.HistoricProcessInstance) DeleteProcessInstancesDto(org.camunda.bpm.engine.rest.dto.runtime.batch.DeleteProcessInstancesDto) Test(org.junit.Test)

Example 14 with HistoricProcessInstanceQueryDto

use of org.camunda.bpm.engine.rest.dto.history.HistoricProcessInstanceQueryDto in project camunda-bpm-platform by camunda.

the class ProcessInstanceRestServiceInteractionTest method testSetRetriesByProcessAsyncHistoricQueryBasedWithQueryAndProcessInstanceIds.

@Test
public void testSetRetriesByProcessAsyncHistoricQueryBasedWithQueryAndProcessInstanceIds() {
    Batch batchEntity = MockProvider.createMockBatch();
    when(mockManagementService.setJobRetriesAsync(anyListOf(String.class), eq((ProcessInstanceQuery) null), anyInt())).thenReturn(batchEntity);
    HistoricProcessInstanceQuery mockedHistoricProcessInstanceQuery = mock(HistoricProcessInstanceQuery.class);
    when(historyServiceMock.createHistoricProcessInstanceQuery()).thenReturn(mockedHistoricProcessInstanceQuery);
    List<HistoricProcessInstance> historicProcessInstances = MockProvider.createMockRunningHistoricProcessInstances();
    when(mockedHistoricProcessInstanceQuery.list()).thenReturn(historicProcessInstances);
    SetJobRetriesByProcessDto body = new SetJobRetriesByProcessDto();
    body.setRetries(MockProvider.EXAMPLE_JOB_RETRIES);
    body.setProcessInstances(Arrays.asList(MockProvider.ANOTHER_EXAMPLE_PROCESS_INSTANCE_ID));
    body.setHistoricProcessInstanceQuery(new HistoricProcessInstanceQueryDto());
    given().contentType(ContentType.JSON).body(body).then().expect().statusCode(Status.OK.getStatusCode()).when().post(SET_JOB_RETRIES_ASYNC_HIST_QUERY_URL);
    verify(mockManagementService, times(1)).setJobRetriesAsync(eq(Arrays.asList(MockProvider.EXAMPLE_PROCESS_INSTANCE_ID, MockProvider.ANOTHER_EXAMPLE_PROCESS_INSTANCE_ID)), eq((ProcessInstanceQuery) null), eq(MockProvider.EXAMPLE_JOB_RETRIES));
}
Also used : HistoricProcessInstanceQueryDto(org.camunda.bpm.engine.rest.dto.history.HistoricProcessInstanceQueryDto) HistoricProcessInstanceQuery(org.camunda.bpm.engine.history.HistoricProcessInstanceQuery) ProcessInstanceQuery(org.camunda.bpm.engine.runtime.ProcessInstanceQuery) HistoricProcessInstanceQuery(org.camunda.bpm.engine.history.HistoricProcessInstanceQuery) Batch(org.camunda.bpm.engine.batch.Batch) HistoricProcessInstance(org.camunda.bpm.engine.history.HistoricProcessInstance) SetJobRetriesByProcessDto(org.camunda.bpm.engine.rest.dto.runtime.SetJobRetriesByProcessDto) Test(org.junit.Test)

Example 15 with HistoricProcessInstanceQueryDto

use of org.camunda.bpm.engine.rest.dto.history.HistoricProcessInstanceQueryDto in project camunda-bpm-platform by camunda.

the class ProcessInstanceRestServiceInteractionTest method testSetRetriesByProcessAsyncHistoricQueryBasedWithNegativeRetries.

@Test
public void testSetRetriesByProcessAsyncHistoricQueryBasedWithNegativeRetries() {
    doThrow(new BadUserRequestException("retries are negative")).when(mockManagementService).setJobRetriesAsync(anyListOf(String.class), eq((ProcessInstanceQuery) null), eq(MockProvider.EXAMPLE_NEGATIVE_JOB_RETRIES));
    HistoricProcessInstanceQuery mockedHistoricProcessInstanceQuery = mock(HistoricProcessInstanceQuery.class);
    when(historyServiceMock.createHistoricProcessInstanceQuery()).thenReturn(mockedHistoricProcessInstanceQuery);
    List<HistoricProcessInstance> historicProcessInstances = MockProvider.createMockRunningHistoricProcessInstances();
    when(mockedHistoricProcessInstanceQuery.list()).thenReturn(historicProcessInstances);
    SetJobRetriesByProcessDto body = new SetJobRetriesByProcessDto();
    body.setRetries(MockProvider.EXAMPLE_NEGATIVE_JOB_RETRIES);
    body.setHistoricProcessInstanceQuery(new HistoricProcessInstanceQueryDto());
    given().contentType(ContentType.JSON).body(body).then().expect().statusCode(Status.BAD_REQUEST.getStatusCode()).when().post(SET_JOB_RETRIES_ASYNC_HIST_QUERY_URL);
}
Also used : HistoricProcessInstanceQueryDto(org.camunda.bpm.engine.rest.dto.history.HistoricProcessInstanceQueryDto) HistoricProcessInstanceQuery(org.camunda.bpm.engine.history.HistoricProcessInstanceQuery) ProcessInstanceQuery(org.camunda.bpm.engine.runtime.ProcessInstanceQuery) HistoricProcessInstanceQuery(org.camunda.bpm.engine.history.HistoricProcessInstanceQuery) HistoricProcessInstance(org.camunda.bpm.engine.history.HistoricProcessInstance) SetJobRetriesByProcessDto(org.camunda.bpm.engine.rest.dto.runtime.SetJobRetriesByProcessDto) BadUserRequestException(org.camunda.bpm.engine.BadUserRequestException) Test(org.junit.Test)

Aggregations

HistoricProcessInstanceQueryDto (org.camunda.bpm.engine.rest.dto.history.HistoricProcessInstanceQueryDto)20 Test (org.junit.Test)17 HistoricProcessInstanceQuery (org.camunda.bpm.engine.history.HistoricProcessInstanceQuery)14 HashMap (java.util.HashMap)12 Matchers.anyString (org.mockito.Matchers.anyString)9 ProcessInstanceQuery (org.camunda.bpm.engine.runtime.ProcessInstanceQuery)8 ArrayList (java.util.ArrayList)7 Batch (org.camunda.bpm.engine.batch.Batch)7 HistoricProcessInstance (org.camunda.bpm.engine.history.HistoricProcessInstance)7 HistoricProcessInstanceQueryImpl (org.camunda.bpm.engine.impl.HistoricProcessInstanceQueryImpl)6 BadUserRequestException (org.camunda.bpm.engine.BadUserRequestException)5 Response (com.jayway.restassured.response.Response)4 Map (java.util.Map)4 List (java.util.List)3 SetJobRetriesByProcessDto (org.camunda.bpm.engine.rest.dto.runtime.SetJobRetriesByProcessDto)3 ExampleVariableObject (org.camunda.bpm.engine.rest.helper.ExampleVariableObject)3 BatchEntity (org.camunda.bpm.engine.impl.batch.BatchEntity)2 DeleteProcessInstancesDto (org.camunda.bpm.engine.rest.dto.runtime.batch.DeleteProcessInstancesDto)2 InvalidRequestException (org.camunda.bpm.engine.rest.exception.InvalidRequestException)2 JobQuery (org.camunda.bpm.engine.runtime.JobQuery)2