Search in sources :

Example 6 with Batch

use of org.camunda.bpm.engine.batch.Batch in project camunda-bpm-platform by camunda.

the class JobRestServiceInteractionTest method testSetRetriesAsync.

@Test
public void testSetRetriesAsync() {
    List<String> ids = Arrays.asList(MockProvider.EXAMPLE_PROCESS_INSTANCE_ID);
    Batch batchEntity = MockProvider.createMockBatch();
    when(mockManagementService.setJobRetriesAsync(anyListOf(String.class), any(JobQuery.class), anyInt())).thenReturn(batchEntity);
    Map<String, Object> messageBodyJson = new HashMap<String, Object>();
    messageBodyJson.put("jobIds", ids);
    messageBodyJson.put(RETRIES, 5);
    Response response = given().contentType(ContentType.JSON).body(messageBodyJson).then().expect().statusCode(Status.OK.getStatusCode()).when().post(JOBS_SET_RETRIES_URL);
    verifyBatchJson(response.asString());
    verify(mockManagementService, times(1)).setJobRetriesAsync(eq(ids), eq((JobQuery) null), eq(5));
}
Also used : Response(com.jayway.restassured.response.Response) Batch(org.camunda.bpm.engine.batch.Batch) HashMap(java.util.HashMap) JobQuery(org.camunda.bpm.engine.runtime.JobQuery) Matchers.anyString(org.mockito.Matchers.anyString) Test(org.junit.Test)

Example 7 with Batch

use of org.camunda.bpm.engine.batch.Batch in project camunda-bpm-platform by camunda.

the class ProcessInstanceRestServiceImpl method deleteAsync.

@Override
public BatchDto deleteAsync(DeleteProcessInstancesDto dto) {
    RuntimeService runtimeService = getProcessEngine().getRuntimeService();
    ProcessInstanceQuery processInstanceQuery = null;
    if (dto.getProcessInstanceQuery() != null) {
        processInstanceQuery = dto.getProcessInstanceQuery().toQuery(getProcessEngine());
    }
    Batch batch = null;
    try {
        batch = runtimeService.deleteProcessInstancesAsync(dto.getProcessInstanceIds(), processInstanceQuery, dto.getDeleteReason(), dto.isSkipCustomListeners(), dto.isSkipSubprocesses());
        return BatchDto.fromBatch(batch);
    } catch (BadUserRequestException e) {
        throw new InvalidRequestException(Status.BAD_REQUEST, e.getMessage());
    }
}
Also used : HistoricProcessInstanceQuery(org.camunda.bpm.engine.history.HistoricProcessInstanceQuery) ProcessInstanceQuery(org.camunda.bpm.engine.runtime.ProcessInstanceQuery) RuntimeService(org.camunda.bpm.engine.RuntimeService) Batch(org.camunda.bpm.engine.batch.Batch) InvalidRequestException(org.camunda.bpm.engine.rest.exception.InvalidRequestException) BadUserRequestException(org.camunda.bpm.engine.BadUserRequestException)

Example 8 with Batch

use of org.camunda.bpm.engine.batch.Batch in project camunda-bpm-platform by camunda.

the class HistoricDecisionInstanceRestServiceImpl method deleteAsync.

public BatchDto deleteAsync(DeleteHistoricDecisionInstancesDto dto) {
    HistoricDecisionInstanceQuery decisionInstanceQuery = null;
    if (dto.getHistoricDecisionInstanceQuery() != null) {
        decisionInstanceQuery = dto.getHistoricDecisionInstanceQuery().toQuery(processEngine);
    }
    try {
        List<String> historicDecisionInstanceIds = dto.getHistoricDecisionInstanceIds();
        String deleteReason = dto.getDeleteReason();
        Batch batch = processEngine.getHistoryService().deleteHistoricDecisionInstancesAsync(historicDecisionInstanceIds, decisionInstanceQuery, deleteReason);
        return BatchDto.fromBatch(batch);
    } catch (BadUserRequestException e) {
        throw new InvalidRequestException(Status.BAD_REQUEST, e.getMessage());
    }
}
Also used : Batch(org.camunda.bpm.engine.batch.Batch) InvalidRequestException(org.camunda.bpm.engine.rest.exception.InvalidRequestException) BadUserRequestException(org.camunda.bpm.engine.BadUserRequestException) HistoricDecisionInstanceQuery(org.camunda.bpm.engine.history.HistoricDecisionInstanceQuery)

Example 9 with Batch

use of org.camunda.bpm.engine.batch.Batch in project camunda-bpm-platform by camunda.

the class HistoricDecisionInstanceRestServiceInteractionTest method testDeleteAsyncWithIdsAndQuery.

@Test
public void testDeleteAsyncWithIdsAndQuery() {
    Batch batchEntity = MockProvider.createMockBatch();
    when(historyServiceMock.deleteHistoricDecisionInstancesAsync(anyListOf(String.class), any(HistoricDecisionInstanceQuery.class), anyString())).thenReturn(batchEntity);
    Map<String, Object> messageBodyJson = new HashMap<String, Object>();
    HistoricDecisionInstanceQueryDto query = new HistoricDecisionInstanceQueryDto();
    query.setDecisionDefinitionKey("decision");
    messageBodyJson.put("historicDecisionInstanceQuery", query);
    List<String> ids = Arrays.asList(MockProvider.EXAMPLE_DECISION_INSTANCE_ID);
    messageBodyJson.put("historicDecisionInstanceIds", ids);
    messageBodyJson.put("deleteReason", "a-delete-reason");
    Response response = given().contentType(ContentType.JSON).body(messageBodyJson).then().expect().statusCode(Status.OK.getStatusCode()).when().post(HISTORIC_DECISION_INSTANCES_DELETE_ASYNC_URL);
    verifyBatchJson(response.asString());
    verify(historyServiceMock, times(1)).deleteHistoricDecisionInstancesAsync(eq(ids), any(HistoricDecisionInstanceQuery.class), eq("a-delete-reason"));
}
Also used : Response(com.jayway.restassured.response.Response) Batch(org.camunda.bpm.engine.batch.Batch) HashMap(java.util.HashMap) Matchers.anyString(org.mockito.Matchers.anyString) HistoricDecisionInstanceQueryDto(org.camunda.bpm.engine.rest.dto.history.HistoricDecisionInstanceQueryDto) HistoricDecisionInstanceQuery(org.camunda.bpm.engine.history.HistoricDecisionInstanceQuery) Test(org.junit.Test) AbstractRestServiceTest(org.camunda.bpm.engine.rest.AbstractRestServiceTest)

Example 10 with Batch

use of org.camunda.bpm.engine.batch.Batch in project camunda-bpm-platform by camunda.

the class HistoricProcessInstanceRestServiceInteractionTest method testDeleteAsync.

@Test
public void testDeleteAsync() {
    List<String> ids = Arrays.asList(MockProvider.EXAMPLE_PROCESS_INSTANCE_ID);
    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("historicProcessInstanceIds", ids);
    messageBodyJson.put(DELETE_REASON, TEST_DELETE_REASON);
    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(ids), eq((HistoricProcessInstanceQuery) null), eq(TEST_DELETE_REASON));
}
Also used : Response(com.jayway.restassured.response.Response) HistoricProcessInstanceQuery(org.camunda.bpm.engine.history.HistoricProcessInstanceQuery) Batch(org.camunda.bpm.engine.batch.Batch) HashMap(java.util.HashMap) Matchers.anyString(org.mockito.Matchers.anyString) Test(org.junit.Test) AbstractRestServiceTest(org.camunda.bpm.engine.rest.AbstractRestServiceTest)

Aggregations

Batch (org.camunda.bpm.engine.batch.Batch)324 Test (org.junit.Test)286 HistoricBatch (org.camunda.bpm.engine.batch.history.HistoricBatch)125 ProcessDefinition (org.camunda.bpm.engine.repository.ProcessDefinition)95 Job (org.camunda.bpm.engine.runtime.Job)78 ProcessInstance (org.camunda.bpm.engine.runtime.ProcessInstance)64 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)32 Date (java.util.Date)28 JobDefinition (org.camunda.bpm.engine.management.JobDefinition)28 AbstractAsyncOperationsTest (org.camunda.bpm.engine.test.api.AbstractAsyncOperationsTest)26 HistoricProcessInstanceQuery (org.camunda.bpm.engine.history.HistoricProcessInstanceQuery)24 ArrayList (java.util.ArrayList)23 ProcessInstanceQuery (org.camunda.bpm.engine.runtime.ProcessInstanceQuery)19 ProcessEngineException (org.camunda.bpm.engine.ProcessEngineException)18 HistoricDecisionInstanceQuery (org.camunda.bpm.engine.history.HistoricDecisionInstanceQuery)17 ExternalTask (org.camunda.bpm.engine.externaltask.ExternalTask)16 ActivityInstance (org.camunda.bpm.engine.runtime.ActivityInstance)15 Deployment (org.camunda.bpm.engine.test.Deployment)15 ExpectedException (org.junit.rules.ExpectedException)14 Matchers.anyString (org.mockito.Matchers.anyString)14