use of org.camunda.bpm.engine.rest.dto.runtime.SetJobRetriesByProcessDto 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));
}
use of org.camunda.bpm.engine.rest.dto.runtime.SetJobRetriesByProcessDto in project camunda-bpm-platform by camunda.
the class ProcessInstanceRestServiceInteractionTest method testSetRetriesByProcessAsyncHistoricQueryBasedWithBadRequestQuery.
@Test
public void testSetRetriesByProcessAsyncHistoricQueryBasedWithBadRequestQuery() {
doThrow(new BadUserRequestException("jobIds is empty")).when(mockManagementService).setJobRetriesAsync(eq(new ArrayList<String>()), eq((ProcessInstanceQuery) null), anyInt());
SetJobRetriesByProcessDto body = new SetJobRetriesByProcessDto();
body.setRetries(MockProvider.EXAMPLE_JOB_RETRIES);
given().contentType(ContentType.JSON).body(body).then().expect().statusCode(Status.BAD_REQUEST.getStatusCode()).when().post(SET_JOB_RETRIES_ASYNC_HIST_QUERY_URL);
}
use of org.camunda.bpm.engine.rest.dto.runtime.SetJobRetriesByProcessDto in project camunda-bpm-platform by camunda.
the class ProcessInstanceRestServiceInteractionTest method testSetRetriesByProcessAsyncHistoricQueryBasedWithProcessInstanceIds.
@Test
public void testSetRetriesByProcessAsyncHistoricQueryBasedWithProcessInstanceIds() {
Batch batchEntity = MockProvider.createMockBatch();
when(mockManagementService.setJobRetriesAsync(anyListOf(String.class), eq((ProcessInstanceQuery) null), anyInt())).thenReturn(batchEntity);
SetJobRetriesByProcessDto body = new SetJobRetriesByProcessDto();
body.setRetries(MockProvider.EXAMPLE_JOB_RETRIES);
body.setProcessInstances(Arrays.asList(MockProvider.EXAMPLE_PROCESS_INSTANCE_ID));
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)), eq((ProcessInstanceQuery) null), eq(MockProvider.EXAMPLE_JOB_RETRIES));
}
use of org.camunda.bpm.engine.rest.dto.runtime.SetJobRetriesByProcessDto 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));
}
use of org.camunda.bpm.engine.rest.dto.runtime.SetJobRetriesByProcessDto 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);
}
Aggregations