public virtual void testForkAndJoin() { // given HistoricActivityInstanceQuery query = historyService.createHistoricActivityInstanceQuery().orderPartiallyByOccurrence().asc(); // when string processInstanceId = runtimeService.startProcessInstanceByKey("process").Id; // then query.executionId(processInstanceId); verifyOrder(query, "theStart", "theService", "fork", "join", "theService4", "theEnd"); string firstExecutionId = historyService.createHistoricActivityInstanceQuery().activityId("theService1").singleResult().ExecutionId; string secondExecutionId = historyService.createHistoricActivityInstanceQuery().activityId("theService2").singleResult().ExecutionId; query.executionId(firstExecutionId); verifyOrder(query, "theService1", "join"); query.executionId(secondExecutionId); verifyOrder(query, "theService2", "theService3"); query = historyService.createHistoricActivityInstanceQuery().orderPartiallyByOccurrence().asc().orderByActivityId().asc(); verifyOrder(query, "theStart", "theService", "fork", "theService1", "theService2", "join", "theService3", "join", "theService4", "theEnd"); }
public virtual void testMigrateHistoryActivityInstance() { //given ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(ProcessModels.ONE_TASK_PROCESS); ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(modify(ProcessModels.ONE_TASK_PROCESS).changeElementId("Process", "Process2").changeElementId("userTask", "userTask2").changeElementName("userTask", "new activity name")); MigrationPlan migrationPlan = runtimeService.createMigrationPlan(sourceProcessDefinition.Id, targetProcessDefinition.Id).mapActivities("userTask", "userTask2").build(); ProcessInstance processInstance = runtimeService.startProcessInstanceById(sourceProcessDefinition.Id); HistoricActivityInstanceQuery sourceHistoryActivityInstanceQuery = historyService.createHistoricActivityInstanceQuery().processDefinitionId(sourceProcessDefinition.Id); HistoricActivityInstanceQuery targetHistoryActivityInstanceQuery = historyService.createHistoricActivityInstanceQuery().processDefinitionId(targetProcessDefinition.Id); //when assertEquals(2, sourceHistoryActivityInstanceQuery.count()); assertEquals(0, targetHistoryActivityInstanceQuery.count()); ProcessInstanceQuery sourceProcessInstanceQuery = runtimeService.createProcessInstanceQuery().processDefinitionId(sourceProcessDefinition.Id); runtimeService.newMigration(migrationPlan).processInstanceQuery(sourceProcessInstanceQuery).execute(); // then one instance of the start event still belongs to the source process // and one active user task instances is now migrated to the target process assertEquals(1, sourceHistoryActivityInstanceQuery.count()); assertEquals(1, targetHistoryActivityInstanceQuery.count()); HistoricActivityInstance instance = targetHistoryActivityInstanceQuery.singleResult(); assertMigratedTo(instance, targetProcessDefinition, "userTask2"); assertEquals("new activity name", instance.ActivityName); assertEquals(processInstance.Id, instance.ParentActivityInstanceId); assertEquals("userTask", instance.ActivityType); }
public virtual IList <HistoricActivityInstanceDto> queryHistoricActivityInstances(HistoricActivityInstanceQueryDto queryDto, int?firstResult, int?maxResults) { queryDto.ObjectMapper = objectMapper; HistoricActivityInstanceQuery query = queryDto.toQuery(processEngine); IList <HistoricActivityInstance> matchingHistoricActivityInstances; if (firstResult != null || maxResults != null) { matchingHistoricActivityInstances = executePaginatedQuery(query, firstResult, maxResults); } else { matchingHistoricActivityInstances = query.list(); } IList <HistoricActivityInstanceDto> historicActivityInstanceResults = new List <HistoricActivityInstanceDto>(); foreach (HistoricActivityInstance historicActivityInstance in matchingHistoricActivityInstances) { HistoricActivityInstanceDto resultHistoricActivityInstance = HistoricActivityInstanceDto.fromHistoricActivityInstance(historicActivityInstance); historicActivityInstanceResults.Add(resultHistoricActivityInstance); } return(historicActivityInstanceResults); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void testUnfinishedHistoricActivityQueryAsPost() public virtual void testUnfinishedHistoricActivityQueryAsPost() { IList <HistoricActivityInstance> mockedHistoricActivityInstances = MockProvider.createMockRunningHistoricActivityInstances(); HistoricActivityInstanceQuery mockedhistoricActivityInstanceQuery = mock(typeof(HistoricActivityInstanceQuery)); when(mockedhistoricActivityInstanceQuery.list()).thenReturn(mockedHistoricActivityInstances); when(processEngine.HistoryService.createHistoricActivityInstanceQuery()).thenReturn(mockedhistoricActivityInstanceQuery); IDictionary <string, bool> body = new Dictionary <string, bool>(); body["unfinished"] = true; Response response = given().contentType(POST_JSON_CONTENT_TYPE).body(body).then().expect().statusCode(Status.OK.StatusCode).when().post(HISTORIC_ACTIVITY_INSTANCE_RESOURCE_URL); InOrder inOrder = inOrder(mockedhistoricActivityInstanceQuery); inOrder.verify(mockedhistoricActivityInstanceQuery).unfinished(); inOrder.verify(mockedhistoricActivityInstanceQuery).list(); string content = response.asString(); IList <string> instances = from(content).getList(""); Assert.assertEquals("There should be one activity instance returned.", 1, instances.Count); Assert.assertNotNull("The returned activity instance should not be null.", instances[0]); string returnedProcessDefinitionId = from(content).getString("[0].processDefinitionId"); string returnedActivityEndTime = from(content).getString("[0].endTime"); Assert.assertEquals(MockProvider.EXAMPLE_PROCESS_DEFINITION_ID, returnedProcessDefinitionId); Assert.assertNull(returnedActivityEndTime); }
public virtual void testNonInterruptingBoundaryEvent() { // given HistoricActivityInstanceQuery query = historyService.createHistoricActivityInstanceQuery().orderPartiallyByOccurrence().asc(); // when string processInstanceId = runtimeService.startProcessInstanceByKey("process").Id; runtimeService.correlateMessage("newMessage"); runtimeService.correlateMessage("newMessage"); string taskId = taskService.createTaskQuery().singleResult().Id; taskService.complete(taskId); // then query.executionId(processInstanceId); verifyOrder(query, "theStart", "theService1", "theEnd1"); string taskExecutionId = historyService.createHistoricActivityInstanceQuery().activityId("theTask").singleResult().ExecutionId; query.executionId(taskExecutionId); verifyOrder(query, "theTask"); IList <HistoricActivityInstance> activityInstances = historyService.createHistoricActivityInstanceQuery().activityId("messageBoundary").list(); foreach (HistoricActivityInstance historicActivityInstance in activityInstances) { query.executionId(historicActivityInstance.ExecutionId); verifyOrder(query, "messageBoundary", "theServiceAfterMessage", "theEnd2"); } query = historyService.createHistoricActivityInstanceQuery().orderPartiallyByOccurrence().asc().orderByActivityId().asc(); verifyOrder(query, "theStart", "theService1", "messageBoundary", "theTask", "theServiceAfterMessage", "theEnd2", "messageBoundary", "theServiceAfterMessage", "theEnd2", "theEnd1"); }
public virtual void testQueryNoAuthenticatedTenants() { identityService.setAuthentication("user", null, null); HistoricActivityInstanceQuery query = historyService.createHistoricActivityInstanceQuery(); assertThat(query.count(), @is(0L)); }
public virtual void testQueryDisabledTenantCheck() { processEngineConfiguration.TenantCheckEnabled = false; identityService.setAuthentication("user", null, null); HistoricActivityInstanceQuery query = historyService.createHistoricActivityInstanceQuery(); assertThat(query.count(), @is(4L)); }
public virtual void testQueryAuthenticatedTenants() { identityService.setAuthentication("user", null, Arrays.asList(TENANT_ONE, TENANT_TWO)); HistoricActivityInstanceQuery query = historyService.createHistoricActivityInstanceQuery(); assertThat(query.count(), @is(4L)); assertThat(query.tenantIdIn(TENANT_ONE).count(), @is(2L)); assertThat(query.tenantIdIn(TENANT_TWO).count(), @is(2L)); }
public virtual void testQueryByTenantId() { HistoricActivityInstanceQuery query = historyService.createHistoricActivityInstanceQuery().tenantIdIn(TENANT_ONE); assertThat(query.count(), @is(2L)); query = historyService.createHistoricActivityInstanceQuery().tenantIdIn(TENANT_TWO); assertThat(query.count(), @is(2L)); }
public virtual void testSequence() { // given HistoricActivityInstanceQuery query = historyService.createHistoricActivityInstanceQuery().orderPartiallyByOccurrence().asc(); // when runtimeService.startProcessInstanceByKey("process"); // then verifyOrder(query, "theStart", "theService1", "theService2", "theEnd"); }
private HistoricActivityInstanceQuery setUpMockHistoricActivityInstanceQuery(IList <HistoricActivityInstance> mockedHistoricActivityInstances) { HistoricActivityInstanceQuery mockedhistoricActivityInstanceQuery = mock(typeof(HistoricActivityInstanceQuery)); when(mockedhistoricActivityInstanceQuery.list()).thenReturn(mockedHistoricActivityInstances); when(mockedhistoricActivityInstanceQuery.count()).thenReturn((long)mockedHistoricActivityInstances.Count); when(processEngine.HistoryService.createHistoricActivityInstanceQuery()).thenReturn(mockedhistoricActivityInstanceQuery); return(mockedhistoricActivityInstanceQuery); }
// historic activity instance query ///////////////////////////////// public virtual void testSimpleQueryWithoutAuthorization() { // given startProcessInstanceByKey(PROCESS_KEY); // when HistoricActivityInstanceQuery query = historyService.createHistoricActivityInstanceQuery(); // then verifyQueryResults(query, 0); }
public virtual void testLoop() { // given HistoricActivityInstanceQuery query = historyService.createHistoricActivityInstanceQuery().orderPartiallyByOccurrence().asc(); // when string processInstanceId = runtimeService.startProcessInstanceByKey("process").Id; // then query.executionId(processInstanceId); verifyOrder(query, "theStart", "theService1", "join", "theScript", "fork", "join", "theScript", "fork", "theService2", "theEnd"); }
private void createHistoricActivityInstanceMock() { IList <HistoricActivityInstance> activities = new List <HistoricActivityInstance>(); HistoricActivityInstance mockInstance = MockProvider.createMockHistoricActivityInstance(); activities.Add(mockInstance); HistoricActivityInstanceQuery mockHistoricActivityInstanceQuery = mock(typeof(HistoricActivityInstanceQuery)); when(mockHistoricActivityInstanceQuery.list()).thenReturn(activities); when(mockHistoryService.createHistoricActivityInstanceQuery()).thenReturn(mockHistoricActivityInstanceQuery); }
public virtual CountResultDto queryHistoricActivityInstancesCount(HistoricActivityInstanceQueryDto queryDto) { queryDto.ObjectMapper = objectMapper; HistoricActivityInstanceQuery query = queryDto.toQuery(processEngine); long count = query.count(); CountResultDto result = new CountResultDto(); result.Count = count; return(result); }
private IList <HistoricActivityInstance> executePaginatedQuery(HistoricActivityInstanceQuery query, int?firstResult, int?maxResults) { if (firstResult == null) { firstResult = 0; } if (maxResults == null) { maxResults = int.MaxValue; } return(query.listPage(firstResult, maxResults)); }
public virtual void testSimpleQueryWithReadHistoryPermissionOnAnyProcessDefinition() { // given startProcessInstanceByKey(PROCESS_KEY); createGrantAuthorization(PROCESS_DEFINITION, ANY, userId, READ_HISTORY); // when HistoricActivityInstanceQuery query = historyService.createHistoricActivityInstanceQuery(); // then verifyQueryResults(query, 2); }
protected internal virtual void verifyOrder(HistoricActivityInstanceQuery query, params string[] expectedOrder) { assertEquals(expectedOrder.Length, query.count()); IList <HistoricActivityInstance> activityInstances = query.list(); for (int i = 0; i < expectedOrder.Length; i++) { HistoricActivityInstance activityInstance = activityInstances[i]; string currentActivityId = activityInstance.ActivityId; string expectedActivityId = expectedOrder[i]; assertEquals(expectedActivityId, currentActivityId); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Deployment public void testInputMappings() public virtual void testInputMappings() { // given string processInstanceId = runtimeService.startProcessInstanceByKey("process").Id; HistoricActivityInstanceQuery activityInstanceQuery = historyService.createHistoricActivityInstanceQuery().processInstanceId(processInstanceId); string theService1Id = activityInstanceQuery.activityId("theService1").singleResult().Id; string theService2Id = activityInstanceQuery.activityId("theService2").singleResult().Id; string theTaskId = activityInstanceQuery.activityId("theTask").singleResult().Id; // when (1) HistoricVariableInstance firstVariable = historyService.createHistoricVariableInstanceQuery().variableName("firstInputVariable").singleResult(); // then (1) assertEquals(theService1Id, firstVariable.ActivityInstanceId); if (processEngineConfiguration.HistoryLevel.Id > ProcessEngineConfigurationImpl.HISTORYLEVEL_AUDIT) { HistoricDetail firstVariableDetail = historyService.createHistoricDetailQuery().variableUpdates().variableInstanceId(firstVariable.Id).singleResult(); assertEquals(theService1Id, firstVariableDetail.ActivityInstanceId); } // when (2) HistoricVariableInstance secondVariable = historyService.createHistoricVariableInstanceQuery().variableName("secondInputVariable").singleResult(); // then (2) assertEquals(theService2Id, secondVariable.ActivityInstanceId); if (processEngineConfiguration.HistoryLevel.Id > ProcessEngineConfigurationImpl.HISTORYLEVEL_AUDIT) { HistoricDetail secondVariableDetail = historyService.createHistoricDetailQuery().variableUpdates().variableInstanceId(secondVariable.Id).singleResult(); assertEquals(theService2Id, secondVariableDetail.ActivityInstanceId); } // when (3) HistoricVariableInstance thirdVariable = historyService.createHistoricVariableInstanceQuery().variableName("thirdInputVariable").singleResult(); // then (3) assertEquals(theTaskId, thirdVariable.ActivityInstanceId); if (processEngineConfiguration.HistoryLevel.Id > ProcessEngineConfigurationImpl.HISTORYLEVEL_AUDIT) { HistoricDetail thirdVariableDetail = historyService.createHistoricDetailQuery().variableUpdates().variableInstanceId(thirdVariable.Id).singleResult(); assertEquals(theTaskId, thirdVariableDetail.ActivityInstanceId); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void testTenantIdListParameter() public virtual void testTenantIdListParameter() { mockedQuery = setUpMockHistoricActivityInstanceQuery(createMockHistoricActivityInstancesTwoTenants()); Response response = given().queryParam("tenantIdIn", MockProvider.EXAMPLE_TENANT_ID_LIST).then().expect().statusCode(Status.OK.StatusCode).when().get(HISTORIC_ACTIVITY_INSTANCE_RESOURCE_URL); verify(mockedQuery).tenantIdIn(MockProvider.EXAMPLE_TENANT_ID, MockProvider.ANOTHER_EXAMPLE_TENANT_ID); verify(mockedQuery).list(); string content = response.asString(); IList <string> executions = from(content).getList(""); assertThat(executions).hasSize(2); string returnedTenantId1 = from(content).getString("[0].tenantId"); string returnedTenantId2 = from(content).getString("[1].tenantId"); assertThat(returnedTenantId1).isEqualTo(MockProvider.EXAMPLE_TENANT_ID); assertThat(returnedTenantId2).isEqualTo(MockProvider.ANOTHER_EXAMPLE_TENANT_ID); }
public virtual void testSequenceInsideSubProcess() { // given HistoricActivityInstanceQuery query = historyService.createHistoricActivityInstanceQuery().orderPartiallyByOccurrence().asc(); // when string processInstanceId = runtimeService.startProcessInstanceByKey("process").Id; // then query.executionId(processInstanceId); verifyOrder(query, "theStart", "theService1", "theService2", "theEnd"); string subProcessExecutionId = historyService.createHistoricActivityInstanceQuery().activityId("subProcess").singleResult().ExecutionId; query.executionId(subProcessExecutionId); verifyOrder(query, "subProcess", "innerStart", "innerService", "innerEnd"); query = historyService.createHistoricActivityInstanceQuery().orderPartiallyByOccurrence().asc(); verifyOrder(query, "theStart", "theService1", "subProcess", "innerStart", "innerService", "innerEnd", "theService2", "theEnd"); }
public virtual void testSequentialMultiInstance() { // given HistoricActivityInstanceQuery query = historyService.createHistoricActivityInstanceQuery().orderPartiallyByOccurrence().asc(); // when string processInstanceId = runtimeService.startProcessInstanceByKey("process").Id; // then query.executionId(processInstanceId); verifyOrder(query, "theStart", "theService1", "theService3", "theEnd"); string taskExecutionId = historyService.createHistoricActivityInstanceQuery().activityId("theService2").list().get(0).ExecutionId; query.executionId(taskExecutionId); verifyOrder(query, "theService2#multiInstanceBody", "theService2", "theService2"); query = historyService.createHistoricActivityInstanceQuery().orderPartiallyByOccurrence().asc(); verifyOrder(query, "theStart", "theService1", "theService2#multiInstanceBody", "theService2", "theService2", "theService3", "theEnd"); }
public virtual void testInterruptingBoundaryEvent() { // given HistoricActivityInstanceQuery query = historyService.createHistoricActivityInstanceQuery().orderPartiallyByOccurrence().asc(); // when string processInstanceId = runtimeService.startProcessInstanceByKey("process").Id; runtimeService.correlateMessage("newMessage"); // then verifyOrder(query, "theStart", "theService1", "theTask", "messageBoundary", "theServiceAfterMessage", "theEnd2"); query.executionId(processInstanceId); verifyOrder(query, "theStart", "theService1", "messageBoundary", "theServiceAfterMessage", "theEnd2"); string taskExecutionId = historyService.createHistoricActivityInstanceQuery().activityId("theTask").singleResult().ExecutionId; query.executionId(taskExecutionId); verifyOrder(query, "theTask"); }
public virtual void testCompleteProcessWithParallelGateway() { //given an already started process instance with one user task ProcessInstance oldInstance = rule.processInstance(); Assert.assertNotNull(oldInstance); Task task = rule.taskQuery().singleResult(); Assert.assertNotNull(task); //and completed service task HistoricActivityInstanceQuery historicActQuery = rule.HistoryService.createHistoricActivityInstanceQuery().activityType("serviceTask").processInstanceId(oldInstance.Id).finished(); Assert.assertEquals(1, historicActQuery.count()); //when completing the user task rule.TaskService.complete(task.Id); //then there exists no more tasks //and the process instance is also completed Assert.assertEquals(0, rule.taskQuery().count()); rule.assertScenarioEnded(); }
public virtual void testParallelMultiInstance() { // given HistoricActivityInstanceQuery query = historyService.createHistoricActivityInstanceQuery().orderPartiallyByOccurrence().asc(); // when string processInstanceId = runtimeService.startProcessInstanceByKey("process").Id; // then query.executionId(processInstanceId); verifyOrder(query, "theStart", "theService1", "theService3", "theEnd"); IList <HistoricActivityInstance> taskActivityInstances = historyService.createHistoricActivityInstanceQuery().activityId("theService2").list(); foreach (HistoricActivityInstance activityInstance in taskActivityInstances) { query.executionId(activityInstance.ExecutionId); verifyOrder(query, "theService2"); } query = historyService.createHistoricActivityInstanceQuery().orderPartiallyByOccurrence().asc(); verifyOrder(query, "theStart", "theService1", "theService2#multiInstanceBody", "theService2", "theService2", "theService3", "theEnd"); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void testTenantIdListPostParameter() public virtual void testTenantIdListPostParameter() { mockedQuery = setUpMockHistoricActivityInstanceQuery(createMockHistoricActivityInstancesTwoTenants()); IDictionary <string, object> queryParameters = new Dictionary <string, object>(); queryParameters["tenantIdIn"] = MockProvider.EXAMPLE_TENANT_ID_LIST.Split(",", true); Response response = given().contentType(POST_JSON_CONTENT_TYPE).body(queryParameters).expect().statusCode(Status.OK.StatusCode).when().post(HISTORIC_ACTIVITY_INSTANCE_RESOURCE_URL); verify(mockedQuery).tenantIdIn(MockProvider.EXAMPLE_TENANT_ID, MockProvider.ANOTHER_EXAMPLE_TENANT_ID); verify(mockedQuery).list(); string content = response.asString(); IList <string> executions = from(content).getList(""); assertThat(executions).hasSize(2); string returnedTenantId1 = from(content).getString("[0].tenantId"); string returnedTenantId2 = from(content).getString("[1].tenantId"); assertThat(returnedTenantId1).isEqualTo(MockProvider.EXAMPLE_TENANT_ID); assertThat(returnedTenantId2).isEqualTo(MockProvider.ANOTHER_EXAMPLE_TENANT_ID); }
// delete deployment (cascade = false) public virtual void testQueryAfterDeletingDeployment() { // given startProcessInstanceByKey(PROCESS_KEY); startProcessInstanceByKey(PROCESS_KEY); startProcessInstanceByKey(PROCESS_KEY); createGrantAuthorization(PROCESS_DEFINITION, PROCESS_KEY, userId, READ_HISTORY); disableAuthorization(); IList <Task> tasks = taskService.createTaskQuery().list(); foreach (Task task in tasks) { taskService.complete(task.Id); } enableAuthorization(); disableAuthorization(); repositoryService.deleteDeployment(deploymentId); enableAuthorization(); // when HistoricActivityInstanceQuery query = historyService.createHistoricActivityInstanceQuery(); // then verifyQueryResults(query, 9); disableAuthorization(); IList <HistoricProcessInstance> instances = historyService.createHistoricProcessInstanceQuery().list(); foreach (HistoricProcessInstance instance in instances) { historyService.deleteHistoricProcessInstance(instance.Id); } enableAuthorization(); }
public QueryResource <HistoricActivityInstanceQuery, HistoricActivityInstance> Query( HistoricActivityInstanceQuery query = null) => new QueryResource <HistoricActivityInstanceQuery, HistoricActivityInstance>( query, (q, f, m) => _api.GetList(q, f, m), q => _api.GetListCount(q));
// helper //////////////////////////////////////////////////////// protected internal virtual void verifyQueryResults(HistoricActivityInstanceQuery query, int countExpected) { //JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET: //ORIGINAL LINE: verifyQueryResults((org.camunda.bpm.engine.impl.AbstractQuery<?, ?>) query, countExpected); verifyQueryResults((AbstractQuery <object, ?>)query, countExpected); }
public QueryResource <HistoricActivityInstanceQuery, HistoricActivityInstance> Query(HistoricActivityInstanceQuery query = null) => new QueryResource <HistoricActivityInstanceQuery, HistoricActivityInstance>(_api, query);