@Test public void executeModificationWithValidProcessInstanceQuerySync() { when(runtimeServiceMock.createProcessInstanceQuery()).thenReturn(new ProcessInstanceQueryImpl()); Map<String, Object> json = new HashMap<String, Object>(); List<Map<String, Object>> instructions = new ArrayList<Map<String, Object>>(); instructions.add(ModificationInstructionBuilder.startAfter().activityId("activityId").getJson()); json.put("processDefinitionId", "processDefinitionId"); ProcessInstanceQueryDto processInstanceQueryDto = new ProcessInstanceQueryDto(); processInstanceQueryDto.setBusinessKey("foo"); json.put("processInstanceQuery", processInstanceQueryDto); json.put("instructions", instructions); given() .contentType(ContentType.JSON) .body(json) .then() .expect() .statusCode(Status.NO_CONTENT.getStatusCode()) .when() .post(EXECUTE_MODIFICATION_SYNC_URL); verify(runtimeServiceMock, times(1)).createProcessInstanceQuery(); verify(modificationBuilderMock).startAfterActivity("activityId"); verify(modificationBuilderMock).processInstanceQuery(processInstanceQueryDto.toQuery(processEngine)); verify(modificationBuilderMock).execute(); }
@Test public void testNullProcessInstanceQuery() { try { runtimeService.createModification("processDefinitionId").startAfterActivity("user1").processInstanceQuery(null).execute(); fail("Should not succeed"); } catch (ProcessEngineException e) { assertThat(e.getMessage(), containsString("Process instance ids is empty")); } }
@Test public void testNullProcessInstanceQueryAsync() { try { runtimeService.createModification("processDefinitionId").startAfterActivity("user1").processInstanceQuery(null).executeAsync(); fail("Should not succeed"); } catch (ProcessEngineException e) { assertThat(e.getMessage(), containsString("Process instance ids is empty")); } }
@Test public void executeModificationWithValidProcessInstanceQueryAsync() { when(runtimeServiceMock.createProcessInstanceQuery()).thenReturn(new ProcessInstanceQueryImpl()); Map<String, Object> json = new HashMap<String, Object>(); List<Map<String, Object>> instructions = new ArrayList<Map<String, Object>>(); instructions.add(ModificationInstructionBuilder.startAfter().activityId("activityId").getJson()); ProcessInstanceQueryDto processInstanceQueryDto = new ProcessInstanceQueryDto(); processInstanceQueryDto.setBusinessKey("foo"); json.put("processInstanceQuery", processInstanceQueryDto); json.put("instructions", instructions); json.put("processDefinitionId", "processDefinitionId"); given() .contentType(ContentType.JSON) .body(json) .then() .expect() .statusCode(Status.OK.getStatusCode()) .when() .post(EXECUTE_MODIFICATION_ASYNC_URL); verify(runtimeServiceMock, times(1)).createProcessInstanceQuery(); verify(modificationBuilderMock).startAfterActivity("activityId"); verify(modificationBuilderMock).processInstanceQuery(processInstanceQueryDto.toQuery(processEngine)); verify(modificationBuilderMock).executeAsync(); }
private ModificationBuilder createModificationBuilder(ModificationDto dto) { ModificationBuilder builder = getProcessEngine().getRuntimeService().createModification(dto.getProcessDefinitionId()); if (dto.getInstructions() != null && !dto.getInstructions().isEmpty()) { dto.applyTo(builder, getProcessEngine(), objectMapper); } List<String> processInstanceIds = dto.getProcessInstanceIds(); builder.processInstanceIds(processInstanceIds); ProcessInstanceQueryDto processInstanceQueryDto = dto.getProcessInstanceQuery(); if (processInstanceQueryDto != null) { ProcessInstanceQuery processInstanceQuery = processInstanceQueryDto.toQuery(getProcessEngine()); builder.processInstanceQuery(processInstanceQuery); } if (dto.isSkipCustomListeners()) { builder.skipCustomListeners(); } if (dto.isSkipIoMappings()) { builder.skipIoMappings(); } return builder; }
private ModificationBuilder createModificationBuilder(ModificationDto dto) { ModificationBuilder builder = getProcessEngine().getRuntimeService().createModification(dto.getProcessDefinitionId()); if (dto.getInstructions() != null && !dto.getInstructions().isEmpty()) { dto.applyTo(builder, getProcessEngine(), objectMapper); } List<String> processInstanceIds = dto.getProcessInstanceIds(); builder.processInstanceIds(processInstanceIds); ProcessInstanceQueryDto processInstanceQueryDto = dto.getProcessInstanceQuery(); if (processInstanceQueryDto != null) { ProcessInstanceQuery processInstanceQuery = processInstanceQueryDto.toQuery(getProcessEngine()); builder.processInstanceQuery(processInstanceQuery); } if (dto.isSkipCustomListeners()) { builder.skipCustomListeners(); } if (dto.isSkipIoMappings()) { builder.skipIoMappings(); } return builder; }
@Test public void testBatchCreationWithProcessInstanceQuery() { int processInstanceCount = 15; DeploymentWithDefinitions deployment = testRule.deploy(instance); ProcessDefinition processDefinition = deployment.getDeployedProcessDefinitions().get(0); helper.startInstances("process1", 15); ProcessInstanceQuery processInstanceQuery = runtimeService.createProcessInstanceQuery().processDefinitionId(processDefinition.getId()); assertEquals(processInstanceCount, processInstanceQuery.count()); // when Batch batch = runtimeService .createModification(processDefinition.getId()) .startAfterActivity("user1") .processInstanceQuery(processInstanceQuery) .executeAsync(); // then a batch is created assertBatchCreated(batch, processInstanceCount); }
@Test public void testBatchCreationWithOverlappingProcessInstanceIdsAndQuery() { int processInstanceCount = 15; DeploymentWithDefinitions deployment = testRule.deploy(instance); ProcessDefinition processDefinition = deployment.getDeployedProcessDefinitions().get(0); List<String> processInstanceIds = helper.startInstances("process1", 15); ProcessInstanceQuery processInstanceQuery = runtimeService.createProcessInstanceQuery().processDefinitionId(processDefinition.getId()); assertEquals(processInstanceCount, processInstanceQuery.count()); // when Batch batch = runtimeService .createModification(processDefinition.getId()) .startTransition("seq") .processInstanceIds(processInstanceIds) .processInstanceQuery(processInstanceQuery) .executeAsync(); // then a batch is created assertBatchCreated(batch, processInstanceCount); }
@Test public void testNullProcessInstanceQueryAsync() { try { runtimeService.createModification("processDefinitionId").startAfterActivity("user1").processInstanceQuery(null).executeAsync(); fail("Should not succeed"); } catch (ProcessEngineException e) { assertThat(e.getMessage(), containsString("Process instance ids is empty")); } }
@Test public void testNullProcessInstanceQuery() { try { runtimeService.createModification("processDefinitionId").startAfterActivity("user1").processInstanceQuery(null).execute(); fail("Should not succeed"); } catch (ProcessEngineException e) { assertThat(e.getMessage(), containsString("Process instance ids is empty")); } }
private ModificationBuilder createModificationBuilder(ModificationDto dto) { ModificationBuilder builder = getProcessEngine().getRuntimeService().createModification(dto.getProcessDefinitionId()); if (dto.getInstructions() != null && !dto.getInstructions().isEmpty()) { dto.applyTo(builder, getProcessEngine(), objectMapper); } List<String> processInstanceIds = dto.getProcessInstanceIds(); builder.processInstanceIds(processInstanceIds); ProcessInstanceQueryDto processInstanceQueryDto = dto.getProcessInstanceQuery(); if (processInstanceQueryDto != null) { ProcessInstanceQuery processInstanceQuery = processInstanceQueryDto.toQuery(getProcessEngine()); builder.processInstanceQuery(processInstanceQuery); } if (dto.isSkipCustomListeners()) { builder.skipCustomListeners(); } if (dto.isSkipIoMappings()) { builder.skipIoMappings(); } return builder; }
@Test public void testBatchCreationWithProcessInstanceQuery() { int processInstanceCount = 15; DeploymentWithDefinitions deployment = testRule.deploy(instance); ProcessDefinition processDefinition = deployment.getDeployedProcessDefinitions().get(0); helper.startInstances("process1", 15); ProcessInstanceQuery processInstanceQuery = runtimeService.createProcessInstanceQuery().processDefinitionId(processDefinition.getId()); assertEquals(processInstanceCount, processInstanceQuery.count()); // when Batch batch = runtimeService .createModification(processDefinition.getId()) .startAfterActivity("user1") .processInstanceQuery(processInstanceQuery) .executeAsync(); // then a batch is created assertBatchCreated(batch, processInstanceCount); }
@Test public void testBatchCreationWithOverlappingProcessInstanceIdsAndQuery() { int processInstanceCount = 15; DeploymentWithDefinitions deployment = testRule.deploy(instance); ProcessDefinition processDefinition = deployment.getDeployedProcessDefinitions().get(0); List<String> processInstanceIds = helper.startInstances("process1", 15); ProcessInstanceQuery processInstanceQuery = runtimeService.createProcessInstanceQuery().processDefinitionId(processDefinition.getId()); assertEquals(processInstanceCount, processInstanceQuery.count()); // when Batch batch = runtimeService .createModification(processDefinition.getId()) .startTransition("seq") .processInstanceIds(processInstanceIds) .processInstanceQuery(processInstanceQuery) .executeAsync(); // then a batch is created assertBatchCreated(batch, processInstanceCount); }