Search in sources :

Example 1 with SetJobRetriesByProcessDto

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));
}
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 2 with SetJobRetriesByProcessDto

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);
}
Also used : HistoricProcessInstanceQuery(org.camunda.bpm.engine.history.HistoricProcessInstanceQuery) ProcessInstanceQuery(org.camunda.bpm.engine.runtime.ProcessInstanceQuery) ArrayList(java.util.ArrayList) SetJobRetriesByProcessDto(org.camunda.bpm.engine.rest.dto.runtime.SetJobRetriesByProcessDto) BadUserRequestException(org.camunda.bpm.engine.BadUserRequestException) Test(org.junit.Test)

Example 3 with SetJobRetriesByProcessDto

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));
}
Also used : HistoricProcessInstanceQuery(org.camunda.bpm.engine.history.HistoricProcessInstanceQuery) ProcessInstanceQuery(org.camunda.bpm.engine.runtime.ProcessInstanceQuery) Batch(org.camunda.bpm.engine.batch.Batch) SetJobRetriesByProcessDto(org.camunda.bpm.engine.rest.dto.runtime.SetJobRetriesByProcessDto) Test(org.junit.Test)

Example 4 with SetJobRetriesByProcessDto

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));
}
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 5 with SetJobRetriesByProcessDto

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);
}
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

HistoricProcessInstanceQuery (org.camunda.bpm.engine.history.HistoricProcessInstanceQuery)5 SetJobRetriesByProcessDto (org.camunda.bpm.engine.rest.dto.runtime.SetJobRetriesByProcessDto)5 ProcessInstanceQuery (org.camunda.bpm.engine.runtime.ProcessInstanceQuery)5 Test (org.junit.Test)5 Batch (org.camunda.bpm.engine.batch.Batch)3 HistoricProcessInstance (org.camunda.bpm.engine.history.HistoricProcessInstance)3 HistoricProcessInstanceQueryDto (org.camunda.bpm.engine.rest.dto.history.HistoricProcessInstanceQueryDto)3 BadUserRequestException (org.camunda.bpm.engine.BadUserRequestException)2 Response (com.jayway.restassured.response.Response)1 ArrayList (java.util.ArrayList)1