private void verifyStringParameterQueryInvocations() { Map<String, String> stringQueryParameters = getCompleteStringQueryParameters(); verify(mockedQuery).processInstanceId(stringQueryParameters.get("processInstanceId")); verify(mockedQuery).processInstanceBusinessKey(stringQueryParameters.get("processInstanceBusinessKey")); verify(mockedQuery).processInstanceBusinessKeyLike(stringQueryParameters.get("processInstanceBusinessKeyLike")); verify(mockedQuery).processDefinitionId(stringQueryParameters.get("processDefinitionId")); verify(mockedQuery).processDefinitionKey(stringQueryParameters.get("processDefinitionKey")); verify(mockedQuery).processDefinitionName(stringQueryParameters.get("processDefinitionName")); verify(mockedQuery).processDefinitionNameLike(stringQueryParameters.get("processDefinitionNameLike")); verify(mockedQuery).startedBy(stringQueryParameters.get("startedBy")); verify(mockedQuery).superProcessInstanceId(stringQueryParameters.get("superProcessInstanceId")); verify(mockedQuery).subProcessInstanceId(stringQueryParameters.get("subProcessInstanceId")); verify(mockedQuery).superCaseInstanceId(stringQueryParameters.get("superCaseInstanceId")); verify(mockedQuery).subCaseInstanceId(stringQueryParameters.get("subCaseInstanceId")); verify(mockedQuery).caseInstanceId(stringQueryParameters.get("caseInstanceId")); verify(mockedQuery).incidentType(stringQueryParameters.get("incidentType")); verify(mockedQuery).list(); }
private HistoricProcessInstance getHistoricProcessInstanceWithAssertion(ProcessDefinition processDefinition) { List<HistoricProcessInstance> entities = processEngineRule.getHistoryService().createHistoricProcessInstanceQuery() .processDefinitionId(processDefinition.getId()).list(); assertThat(entities, is(notNullValue())); assertThat(entities.size(), is(1)); return entities.get(0); }
query.processDefinitionId(processDefinitionId);
query.processDefinitionId(processDefinitionId);
@RequiredHistoryLevel(ProcessEngineConfiguration.HISTORY_FULL) public void testFailToRestartProcessInstanceAsyncWithOtherTenantIdByHistoricProcessInstanceQuery() { // given ProcessInstance processInstance = startAndDeleteProcessInstance(TENANT_ONE, PROCESS); HistoricProcessInstanceQuery query = historyService.createHistoricProcessInstanceQuery().processDefinitionId(processInstance.getProcessDefinitionId()); identityService.setAuthentication("user", null, Collections.singletonList(TENANT_TWO)); try { // when runtimeService.restartProcessInstances(processInstance.getProcessDefinitionId()) .startBeforeActivity("userTask") .historicProcessInstanceQuery(query) .executeAsync(); } catch (ProcessEngineException e) { assertThat(e.getMessage(), containsString("processInstanceIds is empty")); } }
@RequiredHistoryLevel(ProcessEngineConfiguration.HISTORY_FULL) public void testFailToRestartProcessInstanceSyncWithOtherTenantIdByHistoricProcessInstanceQuery() { // given ProcessInstance processInstance = startAndDeleteProcessInstance(TENANT_ONE, PROCESS); HistoricProcessInstanceQuery query = historyService.createHistoricProcessInstanceQuery().processDefinitionId(processInstance.getProcessDefinitionId()); identityService.setAuthentication("user", null, Collections.singletonList(TENANT_TWO)); try { // when runtimeService.restartProcessInstances(processInstance.getProcessDefinitionId()) .startBeforeActivity("userTask") .historicProcessInstanceQuery(query) .execute(); fail("expected exception"); } catch (BadUserRequestException e) { // then assertThat(e.getMessage(), containsString("processInstanceIds is empty")); } }
@RequiredHistoryLevel(ProcessEngineConfiguration.HISTORY_FULL) public void testRestartProcessInstanceSyncWithTenantIdByHistoricProcessInstanceQuery() { // given ProcessInstance processInstance = startAndDeleteProcessInstance(TENANT_ONE, PROCESS); HistoricProcessInstanceQuery query = historyService.createHistoricProcessInstanceQuery().processDefinitionId(processInstance.getProcessDefinitionId()); identityService.setAuthentication("user", null, Collections.singletonList(TENANT_ONE)); // when runtimeService.restartProcessInstances(processInstance.getProcessDefinitionId()) .startBeforeActivity("userTask") .historicProcessInstanceQuery(query) .execute(); // then ProcessInstance restartedInstance = runtimeService.createProcessInstanceQuery().active() .processDefinitionId(processInstance.getProcessDefinitionId()).singleResult(); assertNotNull(restartedInstance); assertEquals(restartedInstance.getTenantId(), TENANT_ONE); }
@Override protected HistoricProcessInstanceQuery historicProcessInstanceQuery() { return super.historicProcessInstanceQuery().processDefinitionId(actual.getId()); }
@RequiredHistoryLevel(ProcessEngineConfiguration.HISTORY_FULL) public void testRestartProcessInstanceAsyncWithTenantIdByHistoricProcessInstanceQuery() { // given ProcessInstance processInstance = startAndDeleteProcessInstance(TENANT_ONE, PROCESS); HistoricProcessInstanceQuery query = historyService.createHistoricProcessInstanceQuery().processDefinitionId(processInstance.getProcessDefinitionId()); identityService.setAuthentication("user", null, Collections.singletonList(TENANT_ONE)); // when Batch batch = runtimeService.restartProcessInstances(processInstance.getProcessDefinitionId()) .startBeforeActivity("userTask") .historicProcessInstanceQuery(query) .executeAsync(); batchHelper.completeBatch(batch); // then ProcessInstance restartedInstance = runtimeService.createProcessInstanceQuery().active() .processDefinitionId(processInstance.getProcessDefinitionId()).singleResult(); assertNotNull(restartedInstance); assertEquals(restartedInstance.getTenantId(), TENANT_ONE); }
@Test @RequiredHistoryLevel(ProcessEngineConfiguration.HISTORY_ACTIVITY) public void testMigrateHistoryProcessInstance() { //given HistoricProcessInstanceQuery sourceHistoryProcessInstanceQuery = historyService.createHistoricProcessInstanceQuery() .processDefinitionId(sourceProcessDefinition.getId()); HistoricProcessInstanceQuery targetHistoryProcessInstanceQuery = historyService.createHistoricProcessInstanceQuery() .processDefinitionId(targetProcessDefinition.getId()); //when assertEquals(1, sourceHistoryProcessInstanceQuery.count()); assertEquals(0, targetHistoryProcessInstanceQuery.count()); ProcessInstanceQuery sourceProcessInstanceQuery = runtimeService.createProcessInstanceQuery().processDefinitionId(sourceProcessDefinition.getId()); runtimeService.newMigration(migrationPlan) .processInstanceQuery(sourceProcessInstanceQuery) .execute(); //then assertEquals(0, sourceHistoryProcessInstanceQuery.count()); assertEquals(1, targetHistoryProcessInstanceQuery.count()); HistoricProcessInstance instance = targetHistoryProcessInstanceQuery.singleResult(); assertEquals(instance.getProcessDefinitionKey(), targetProcessDefinition.getKey()); }
@Override protected HistoricProcessInstanceQuery historicProcessInstanceQuery() { return super.historicProcessInstanceQuery().processDefinitionId(actual.getId()); }
@Override protected HistoricProcessInstanceQuery historicProcessInstanceQuery() { return super.historicProcessInstanceQuery().processDefinitionId(actual.getId()); }
assertEquals(1, historyService.createHistoricProcessInstanceQuery().processDefinitionId(processInstance.getProcessDefinitionId()).count()); assertEquals(1, historyService.createHistoricProcessInstanceQuery().processDefinitionKey("oneTaskProcess").count());
@Test public void testBatchCreationWithOverlappingProcessInstanceIdsAndQuery() { // given int processInstanceCount = 2; ProcessDefinition processDefinition = testRule.deployAndGetDefinition(ProcessModels.TWO_TASKS_PROCESS); ProcessInstance processInstance1 = runtimeService.startProcessInstanceByKey("Process"); ProcessInstance processInstance2 = runtimeService.startProcessInstanceByKey("Process"); runtimeService.deleteProcessInstance(processInstance1.getId(), "test"); runtimeService.deleteProcessInstance(processInstance2.getId(), "test"); // when HistoricProcessInstanceQuery processInstanceQuery = engineRule.getHistoryService() .createHistoricProcessInstanceQuery() .processDefinitionId(processDefinition.getId()); Batch batch = runtimeService .restartProcessInstances(processDefinition.getId()) .startTransition("flow1") .processInstanceIds(processInstance1.getId(), processInstance2.getId()) .historicProcessInstanceQuery(processInstanceQuery) .executeAsync(); helper.completeBatch(batch); // then List<ProcessInstance> restartedProcessInstances = engineRule.getRuntimeService().createProcessInstanceQuery().processDefinitionId(processDefinition.getId()).list(); assertEquals(restartedProcessInstances.size(), processInstanceCount); }
@Test public void shouldRestartProcessInstanceUsingHistoricProcessInstanceQuery() { // given ProcessDefinition processDefinition = testRule.deployAndGetDefinition(ProcessModels.TWO_TASKS_PROCESS); ProcessInstance processInstance1 = runtimeService.startProcessInstanceByKey("Process"); Task task1 = taskService.createTaskQuery().processInstanceId(processInstance1.getId()).active().singleResult(); ProcessInstance processInstance2 = runtimeService.startProcessInstanceByKey("Process"); Task task2 = taskService.createTaskQuery().processInstanceId(processInstance2.getId()).active().singleResult(); runtimeService.deleteProcessInstance(processInstance1.getId(), "test"); runtimeService.deleteProcessInstance(processInstance2.getId(), "test"); // when HistoricProcessInstanceQuery historicProcessInstanceQuery = engineRule.getHistoryService().createHistoricProcessInstanceQuery().processDefinitionId(processDefinition.getId()); Batch batch = runtimeService.restartProcessInstances(processDefinition.getId()) .startBeforeActivity("userTask1") .historicProcessInstanceQuery(historicProcessInstanceQuery) .executeAsync(); helper.completeBatch(batch); // then List<ProcessInstance> restartedProcessInstances = runtimeService.createProcessInstanceQuery().active().list(); ProcessInstance restartedProcessInstance = restartedProcessInstances.get(0); Task restartedTask = taskService.createTaskQuery().processInstanceId(restartedProcessInstance.getId()).active().singleResult(); Assert.assertEquals(task1.getTaskDefinitionKey(), restartedTask.getTaskDefinitionKey()); restartedProcessInstance = restartedProcessInstances.get(1); restartedTask = taskService.createTaskQuery().processInstanceId(restartedProcessInstance.getId()).active().singleResult(); Assert.assertEquals(task2.getTaskDefinitionKey(), restartedTask.getTaskDefinitionKey()); }
@Test public void shouldRestartProcessInstanceUsingHistoricProcessInstanceQuery() { // given ProcessDefinition processDefinition = testRule.deployAndGetDefinition(ProcessModels.TWO_TASKS_PROCESS); ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("Process"); runtimeService.deleteProcessInstance(processInstance.getId(), "test"); // when HistoricProcessInstanceQuery historicProcessInstanceQuery = engineRule.getHistoryService() .createHistoricProcessInstanceQuery() .processDefinitionId(processDefinition.getId()); runtimeService.restartProcessInstances(processDefinition.getId()) .startBeforeActivity("userTask1") .historicProcessInstanceQuery(historicProcessInstanceQuery) .execute(); // then ProcessInstance restartedProcessInstance = runtimeService.createProcessInstanceQuery().active().singleResult(); ActivityInstance updatedTree = runtimeService.getActivityInstance(restartedProcessInstance.getId()); assertNotNull(updatedTree); assertEquals(restartedProcessInstance.getId(), updatedTree.getProcessInstanceId()); assertThat(updatedTree).hasStructure( describeActivityInstanceTree( processDefinition.getId()) .activity("userTask1") .done()); }
private HistoricProcessInstance getHistoricProcessInstanceWithAssertion(ProcessDefinition processDefinition) { List<HistoricProcessInstance> entities = processEngineRule.getHistoryService().createHistoricProcessInstanceQuery() .processDefinitionId(processDefinition.getId()).list(); assertThat(entities, is(notNullValue())); assertThat(entities.size(), is(1)); return entities.get(0); }
@RequiredHistoryLevel(ProcessEngineConfiguration.HISTORY_FULL) public void testFailToRestartProcessInstanceSyncWithOtherTenantIdByHistoricProcessInstanceQuery() { // given ProcessInstance processInstance = startAndDeleteProcessInstance(TENANT_ONE, PROCESS); HistoricProcessInstanceQuery query = historyService.createHistoricProcessInstanceQuery().processDefinitionId(processInstance.getProcessDefinitionId()); identityService.setAuthentication("user", null, Collections.singletonList(TENANT_TWO)); try { // when runtimeService.restartProcessInstances(processInstance.getProcessDefinitionId()) .startBeforeActivity("userTask") .historicProcessInstanceQuery(query) .execute(); fail("expected exception"); } catch (BadUserRequestException e) { // then assertThat(e.getMessage(), containsString("processInstanceIds is empty")); } }
@RequiredHistoryLevel(ProcessEngineConfiguration.HISTORY_FULL) public void testRestartProcessInstanceSyncWithTenantIdByHistoricProcessInstanceQuery() { // given ProcessInstance processInstance = startAndDeleteProcessInstance(TENANT_ONE, PROCESS); HistoricProcessInstanceQuery query = historyService.createHistoricProcessInstanceQuery().processDefinitionId(processInstance.getProcessDefinitionId()); identityService.setAuthentication("user", null, Collections.singletonList(TENANT_ONE)); // when runtimeService.restartProcessInstances(processInstance.getProcessDefinitionId()) .startBeforeActivity("userTask") .historicProcessInstanceQuery(query) .execute(); // then ProcessInstance restartedInstance = runtimeService.createProcessInstanceQuery().active() .processDefinitionId(processInstance.getProcessDefinitionId()).singleResult(); assertNotNull(restartedInstance); assertEquals(restartedInstance.getTenantId(), TENANT_ONE); }
@RequiredHistoryLevel(ProcessEngineConfiguration.HISTORY_FULL) public void testRestartProcessInstanceAsyncWithTenantIdByHistoricProcessInstanceQuery() { // given ProcessInstance processInstance = startAndDeleteProcessInstance(TENANT_ONE, PROCESS); HistoricProcessInstanceQuery query = historyService.createHistoricProcessInstanceQuery().processDefinitionId(processInstance.getProcessDefinitionId()); identityService.setAuthentication("user", null, Collections.singletonList(TENANT_ONE)); // when Batch batch = runtimeService.restartProcessInstances(processInstance.getProcessDefinitionId()) .startBeforeActivity("userTask") .historicProcessInstanceQuery(query) .executeAsync(); batchHelper.completeBatch(batch); // then ProcessInstance restartedInstance = runtimeService.createProcessInstanceQuery().active() .processDefinitionId(processInstance.getProcessDefinitionId()).singleResult(); assertNotNull(restartedInstance); assertEquals(restartedInstance.getTenantId(), TENANT_ONE); }