Search in sources :

Example 16 with ProcessInstanceQueryDto

use of org.camunda.bpm.engine.rest.dto.runtime.ProcessInstanceQueryDto in project camunda-bpm-platform by camunda.

the class ProcessInstanceRestServiceInteractionTest method testDeleteAsyncWithQuery.

@Test
public void testDeleteAsyncWithQuery() {
    Map<String, Object> messageBodyJson = new HashMap<String, Object>();
    messageBodyJson.put("deleteReason", TEST_DELETE_REASON);
    ProcessInstanceQueryDto query = new ProcessInstanceQueryDto();
    messageBodyJson.put("processInstanceQuery", query);
    when(runtimeServiceMock.deleteProcessInstancesAsync(anyListOf(String.class), any(ProcessInstanceQuery.class), anyString(), anyBoolean(), anyBoolean())).thenReturn(new BatchEntity());
    given().contentType(ContentType.JSON).body(messageBodyJson).then().expect().statusCode(Status.OK.getStatusCode()).when().post(DELETE_PROCESS_INSTANCES_ASYNC_URL);
    verify(runtimeServiceMock, times(1)).deleteProcessInstancesAsync(anyListOf(String.class), Mockito.any(ProcessInstanceQuery.class), Mockito.eq(TEST_DELETE_REASON), Mockito.eq(false), Mockito.eq(false));
}
Also used : HistoricProcessInstanceQuery(org.camunda.bpm.engine.history.HistoricProcessInstanceQuery) ProcessInstanceQuery(org.camunda.bpm.engine.runtime.ProcessInstanceQuery) HashMap(java.util.HashMap) BatchEntity(org.camunda.bpm.engine.impl.batch.BatchEntity) ExampleVariableObject(org.camunda.bpm.engine.rest.helper.ExampleVariableObject) ProcessInstanceQueryDto(org.camunda.bpm.engine.rest.dto.runtime.ProcessInstanceQueryDto) HistoricProcessInstanceQueryDto(org.camunda.bpm.engine.rest.dto.history.HistoricProcessInstanceQueryDto) Test(org.junit.Test)

Example 17 with ProcessInstanceQueryDto

use of org.camunda.bpm.engine.rest.dto.runtime.ProcessInstanceQueryDto in project camunda-bpm-platform by camunda.

the class ProcessInstanceRestServiceInteractionTest method testSuspendProcessInstanceQuery.

@Test
public void testSuspendProcessInstanceQuery() {
    ProcessInstanceQueryDto query = new ProcessInstanceQueryDto();
    Map<String, Object> messageBodyJson = new HashMap<String, Object>();
    messageBodyJson.put("processInstanceQuery", 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).byProcessInstanceQuery(query.toQuery(processEngine));
    verify(mockUpdateProcessInstancesSuspensionStateBuilder).suspend();
}
Also used : HashMap(java.util.HashMap) ExampleVariableObject(org.camunda.bpm.engine.rest.helper.ExampleVariableObject) ProcessInstanceQueryDto(org.camunda.bpm.engine.rest.dto.runtime.ProcessInstanceQueryDto) HistoricProcessInstanceQueryDto(org.camunda.bpm.engine.rest.dto.history.HistoricProcessInstanceQueryDto) Test(org.junit.Test)

Example 18 with ProcessInstanceQueryDto

use of org.camunda.bpm.engine.rest.dto.runtime.ProcessInstanceQueryDto in project camunda-bpm-platform by camunda.

the class MigrationRestServiceInteractionTest method executeMigrationPlanAsyncWithProcessInstanceQuery.

@Test
public void executeMigrationPlanAsyncWithProcessInstanceQuery() {
    when(runtimeServiceMock.createProcessInstanceQuery()).thenReturn(new ProcessInstanceQueryImpl());
    ProcessInstanceQueryDto processInstanceQuery = new ProcessInstanceQueryDto();
    processInstanceQuery.setProcessDefinitionId(EXAMPLE_PROCESS_DEFINITION_ID);
    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).instruction(ANOTHER_EXAMPLE_ACTIVITY_ID, EXAMPLE_ACTIVITY_ID).done().processInstanceQuery(processInstanceQuery).build();
    given().contentType(POST_JSON_CONTENT_TYPE).body(migrationExecution).then().expect().statusCode(Status.OK.getStatusCode()).body("id", is(EXAMPLE_BATCH_ID)).body("type", is(EXAMPLE_BATCH_TYPE)).body("totalJobs", is(EXAMPLE_BATCH_TOTAL_JOBS)).body("batchJobsPerSeed", is(EXAMPLE_BATCH_JOBS_PER_SEED)).body("invocationsPerBatchJob", is(EXAMPLE_INVOCATIONS_PER_BATCH_JOB)).body("seedJobDefinitionId", is(EXAMPLE_SEED_JOB_DEFINITION_ID)).body("monitorJobDefinitionId", is(EXAMPLE_MONITOR_JOB_DEFINITION_ID)).body("batchJobDefinitionId", is(EXAMPLE_BATCH_JOB_DEFINITION_ID)).body("tenantId", is(EXAMPLE_TENANT_ID)).when().post(EXECUTE_MIGRATION_ASYNC_URL);
    verifyCreateMigrationPlanInteraction(migrationPlanBuilderMock, (Map<String, Object>) migrationExecution.get(MigrationExecutionDtoBuilder.PROP_MIGRATION_PLAN));
    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) ProcessInstanceQueryImpl(org.camunda.bpm.engine.impl.ProcessInstanceQueryImpl) ProcessInstanceQueryDto(org.camunda.bpm.engine.rest.dto.runtime.ProcessInstanceQueryDto) Matchers.anyString(org.mockito.Matchers.anyString) Test(org.junit.Test)

Example 19 with ProcessInstanceQueryDto

use of org.camunda.bpm.engine.rest.dto.runtime.ProcessInstanceQueryDto in project camunda-bpm-platform by camunda.

the class MigrationRestServiceInteractionTest method executeMigrationPlanWithProcessInstanceQuery.

@Test
public void executeMigrationPlanWithProcessInstanceQuery() {
    when(runtimeServiceMock.createProcessInstanceQuery()).thenReturn(new ProcessInstanceQueryImpl());
    ProcessInstanceQueryDto processInstanceQuery = new ProcessInstanceQueryDto();
    processInstanceQuery.setProcessDefinitionId(EXAMPLE_PROCESS_DEFINITION_ID);
    Map<String, Object> migrationExecution = new MigrationExecutionDtoBuilder().migrationPlan(EXAMPLE_PROCESS_DEFINITION_ID, ANOTHER_EXAMPLE_PROCESS_DEFINITION_ID).instruction(EXAMPLE_ACTIVITY_ID, ANOTHER_EXAMPLE_ACTIVITY_ID).instruction(ANOTHER_EXAMPLE_ACTIVITY_ID, EXAMPLE_ACTIVITY_ID).done().processInstanceQuery(processInstanceQuery).build();
    given().contentType(POST_JSON_CONTENT_TYPE).body(migrationExecution).then().expect().statusCode(Status.NO_CONTENT.getStatusCode()).when().post(EXECUTE_MIGRATION_URL);
    verifyCreateMigrationPlanInteraction(migrationPlanBuilderMock, (Map<String, Object>) migrationExecution.get(MigrationExecutionDtoBuilder.PROP_MIGRATION_PLAN));
    verifyMigrationPlanExecutionInteraction(migrationExecution);
}
Also used : MigrationExecutionDtoBuilder(org.camunda.bpm.engine.rest.util.migration.MigrationExecutionDtoBuilder) ProcessInstanceQueryImpl(org.camunda.bpm.engine.impl.ProcessInstanceQueryImpl) ProcessInstanceQueryDto(org.camunda.bpm.engine.rest.dto.runtime.ProcessInstanceQueryDto) Matchers.anyString(org.mockito.Matchers.anyString) Test(org.junit.Test)

Aggregations

ProcessInstanceQueryDto (org.camunda.bpm.engine.rest.dto.runtime.ProcessInstanceQueryDto)19 Test (org.junit.Test)15 HashMap (java.util.HashMap)13 HistoricProcessInstanceQueryDto (org.camunda.bpm.engine.rest.dto.history.HistoricProcessInstanceQueryDto)10 Matchers.anyString (org.mockito.Matchers.anyString)9 ProcessInstanceQueryImpl (org.camunda.bpm.engine.impl.ProcessInstanceQueryImpl)8 ExampleVariableObject (org.camunda.bpm.engine.rest.helper.ExampleVariableObject)7 ProcessInstanceQuery (org.camunda.bpm.engine.runtime.ProcessInstanceQuery)6 ArrayList (java.util.ArrayList)4 Map (java.util.Map)4 HistoricProcessInstanceQuery (org.camunda.bpm.engine.history.HistoricProcessInstanceQuery)4 BatchEntity (org.camunda.bpm.engine.impl.batch.BatchEntity)4 HistoricProcessInstanceQueryImpl (org.camunda.bpm.engine.impl.HistoricProcessInstanceQueryImpl)2 MigrationExecutionDtoBuilder (org.camunda.bpm.engine.rest.util.migration.MigrationExecutionDtoBuilder)2 BadUserRequestException (org.camunda.bpm.engine.BadUserRequestException)1 ExternalTaskService (org.camunda.bpm.engine.ExternalTaskService)1 Batch (org.camunda.bpm.engine.batch.Batch)1 ExternalTaskQuery (org.camunda.bpm.engine.externaltask.ExternalTaskQuery)1 MigrationPlan (org.camunda.bpm.engine.migration.MigrationPlan)1 MigrationPlanExecutionBuilder (org.camunda.bpm.engine.migration.MigrationPlanExecutionBuilder)1