Search in sources :

Example 1 with Batch

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

the class BatchRestServiceImpl method getBatches.

public List<BatchDto> getBatches(UriInfo uriInfo, Integer firstResult, Integer maxResults) {
    BatchQueryDto queryDto = new BatchQueryDto(getObjectMapper(), uriInfo.getQueryParameters());
    BatchQuery query = queryDto.toQuery(getProcessEngine());
    List<Batch> matchingBatches;
    if (firstResult != null || maxResults != null) {
        matchingBatches = executePaginatedQuery(query, firstResult, maxResults);
    } else {
        matchingBatches = query.list();
    }
    List<BatchDto> batchResults = new ArrayList<BatchDto>();
    for (Batch matchingBatch : matchingBatches) {
        batchResults.add(BatchDto.fromBatch(matchingBatch));
    }
    return batchResults;
}
Also used : Batch(org.camunda.bpm.engine.batch.Batch) ArrayList(java.util.ArrayList) BatchDto(org.camunda.bpm.engine.rest.dto.batch.BatchDto) BatchQuery(org.camunda.bpm.engine.batch.BatchQuery) BatchQueryDto(org.camunda.bpm.engine.rest.dto.batch.BatchQueryDto)

Example 2 with Batch

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

the class RestartProcessInstanceRestServiceTest method setUpRuntimeData.

@Before
public void setUpRuntimeData() {
    runtimeServiceMock = mock(RuntimeService.class);
    when(processEngine.getRuntimeService()).thenReturn(runtimeServiceMock);
    historyServiceMock = mock(HistoryService.class);
    when(processEngine.getHistoryService()).thenReturn(historyServiceMock);
    builderMock = mock(RestartProcessInstanceBuilder.class);
    when(builderMock.startAfterActivity(anyString())).thenReturn(builderMock);
    when(builderMock.startBeforeActivity(anyString())).thenReturn(builderMock);
    when(builderMock.startTransition(anyString())).thenReturn(builderMock);
    when(builderMock.processInstanceIds(anyListOf(String.class))).thenReturn(builderMock);
    when(builderMock.historicProcessInstanceQuery(any(HistoricProcessInstanceQuery.class))).thenReturn(builderMock);
    when(builderMock.skipCustomListeners()).thenReturn(builderMock);
    when(builderMock.skipIoMappings()).thenReturn(builderMock);
    when(builderMock.initialSetOfVariables()).thenReturn(builderMock);
    when(builderMock.withoutBusinessKey()).thenReturn(builderMock);
    Batch batchMock = createMockBatch();
    when(builderMock.executeAsync()).thenReturn(batchMock);
    when(runtimeServiceMock.restartProcessInstances(anyString())).thenReturn(builderMock);
}
Also used : HistoricProcessInstanceQuery(org.camunda.bpm.engine.history.HistoricProcessInstanceQuery) RuntimeService(org.camunda.bpm.engine.RuntimeService) Batch(org.camunda.bpm.engine.batch.Batch) MockProvider.createMockBatch(org.camunda.bpm.engine.rest.helper.MockProvider.createMockBatch) HistoryService(org.camunda.bpm.engine.HistoryService) RestartProcessInstanceBuilder(org.camunda.bpm.engine.runtime.RestartProcessInstanceBuilder) Matchers.anyString(org.mockito.Matchers.anyString) Before(org.junit.Before)

Example 3 with Batch

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

the class MigrationRestServiceInteractionTest method executeMigrationPlanAsyncSkipListeners.

@Test
public void executeMigrationPlanAsyncSkipListeners() {
    Batch batchMock = createMockBatch();
    when(migrationPlanExecutionBuilderMock.executeAsync()).thenReturn(batchMock);
    Map<String, Object> migrationExecution = new MigrationExecutionDtoBuilder().migrationPlan(EXAMPLE_PROCESS_DEFINITION_ID, ANOTHER_EXAMPLE_PROCESS_DEFINITION_ID).instruction(EXAMPLE_ACTIVITY_ID, ANOTHER_EXAMPLE_ACTIVITY_ID).done().processInstances(EXAMPLE_PROCESS_INSTANCE_ID).skipCustomListeners(true).build();
    given().contentType(POST_JSON_CONTENT_TYPE).body(migrationExecution).then().expect().statusCode(Status.OK.getStatusCode()).when().post(EXECUTE_MIGRATION_ASYNC_URL);
    verifyMigrationPlanAsyncExecutionInteraction(migrationExecution);
}
Also used : MigrationExecutionDtoBuilder(org.camunda.bpm.engine.rest.util.migration.MigrationExecutionDtoBuilder) MockProvider.createMockBatch(org.camunda.bpm.engine.rest.helper.MockProvider.createMockBatch) Batch(org.camunda.bpm.engine.batch.Batch) Matchers.anyString(org.mockito.Matchers.anyString) Test(org.junit.Test)

Example 4 with Batch

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

the class ModificationRestServiceInteractionTest method setUpRuntimeData.

@Before
public void setUpRuntimeData() {
    runtimeServiceMock = mock(RuntimeService.class);
    when(processEngine.getRuntimeService()).thenReturn(runtimeServiceMock);
    modificationBuilderMock = mock(ModificationBuilder.class);
    when(modificationBuilderMock.cancelAllForActivity(anyString())).thenReturn(modificationBuilderMock);
    when(modificationBuilderMock.startAfterActivity(anyString())).thenReturn(modificationBuilderMock);
    when(modificationBuilderMock.startBeforeActivity(anyString())).thenReturn(modificationBuilderMock);
    when(modificationBuilderMock.startTransition(anyString())).thenReturn(modificationBuilderMock);
    when(modificationBuilderMock.processInstanceIds(anyListOf(String.class))).thenReturn(modificationBuilderMock);
    Batch batchMock = createMockBatch();
    when(modificationBuilderMock.executeAsync()).thenReturn(batchMock);
    when(runtimeServiceMock.createModification(anyString())).thenReturn(modificationBuilderMock);
}
Also used : RuntimeService(org.camunda.bpm.engine.RuntimeService) Batch(org.camunda.bpm.engine.batch.Batch) MockProvider.createMockBatch(org.camunda.bpm.engine.rest.helper.MockProvider.createMockBatch) ModificationBuilder(org.camunda.bpm.engine.runtime.ModificationBuilder) Matchers.anyString(org.mockito.Matchers.anyString) Before(org.junit.Before)

Example 5 with Batch

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

the class ProcessInstanceRestServiceInteractionTest method testSetRetriesByProcessAsync.

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

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