// historic task instance query (mixed tasks) //////////////////////////////////// public virtual void testMixedQueryWithoutAuthorization() { // given startProcessInstanceByKey(PROCESS_KEY); startProcessInstanceByKey(PROCESS_KEY); startProcessInstanceByKey(PROCESS_KEY); startProcessInstanceByKey(MESSAGE_START_PROCESS_KEY); startProcessInstanceByKey(MESSAGE_START_PROCESS_KEY); startProcessInstanceByKey(MESSAGE_START_PROCESS_KEY); startProcessInstanceByKey(MESSAGE_START_PROCESS_KEY); createTask("one"); createTask("two"); createTask("three"); createTask("four"); createTask("five"); createCaseInstanceByKey(CASE_KEY); createCaseInstanceByKey(CASE_KEY); // when HistoricTaskInstanceQuery query = historyService.createHistoricTaskInstanceQuery(); // then verifyQueryResults(query, 7); deleteTask("one", true); deleteTask("two", true); deleteTask("three", true); deleteTask("four", true); deleteTask("five", true); }
public virtual void testMixedQueryWithReadHistoryPermissionOnAnyProcessDefinition() { // given startProcessInstanceByKey(PROCESS_KEY); startProcessInstanceByKey(PROCESS_KEY); startProcessInstanceByKey(PROCESS_KEY); startProcessInstanceByKey(MESSAGE_START_PROCESS_KEY); startProcessInstanceByKey(MESSAGE_START_PROCESS_KEY); startProcessInstanceByKey(MESSAGE_START_PROCESS_KEY); startProcessInstanceByKey(MESSAGE_START_PROCESS_KEY); createTask("one"); createTask("two"); createTask("three"); createTask("four"); createTask("five"); createCaseInstanceByKey(CASE_KEY); createCaseInstanceByKey(CASE_KEY); createGrantAuthorization(PROCESS_DEFINITION, ANY, userId, READ_HISTORY); // when HistoricTaskInstanceQuery query = historyService.createHistoricTaskInstanceQuery(); // then verifyQueryResults(query, 14); deleteTask("one", true); deleteTask("two", true); deleteTask("three", true); deleteTask("four", true); deleteTask("five", true); }
public virtual IList <HistoricTaskInstanceDto> queryHistoricTaskInstances(HistoricTaskInstanceQueryDto queryDto, int?firstResult, int?maxResults) { queryDto.ObjectMapper = objectMapper; HistoricTaskInstanceQuery query = queryDto.toQuery(processEngine); IList <HistoricTaskInstance> match; if (firstResult != null || maxResults != null) { match = executePaginatedQuery(query, firstResult, maxResults); } else { match = query.list(); } IList <HistoricTaskInstanceDto> result = new List <HistoricTaskInstanceDto>(); foreach (HistoricTaskInstance taskInstance in match) { HistoricTaskInstanceDto taskInstanceDto = HistoricTaskInstanceDto.fromHistoricTaskInstance(taskInstance); result.Add(taskInstanceDto); } return(result); }
public virtual void testDeleteHistoricTaskInstanceAfterDeletingDeployment() { // given string processInstanceId = startProcessInstanceByKey(PROCESS_KEY).Id; string taskId = selectSingleTask().Id; disableAuthorization(); taskService.complete(taskId); enableAuthorization(); createGrantAuthorization(PROCESS_DEFINITION, ANY, userId, DELETE_HISTORY); disableAuthorization(); repositoryService.deleteDeployment(deploymentId); enableAuthorization(); // when historyService.deleteHistoricTaskInstance(taskId); // then disableAuthorization(); HistoricTaskInstanceQuery query = historyService.createHistoricTaskInstanceQuery().taskId(taskId); verifyQueryResults(query, 0); enableAuthorization(); disableAuthorization(); historyService.deleteHistoricProcessInstance(processInstanceId); enableAuthorization(); }
public virtual void testCompleteProcessWithParallelGatewayAndSingleUserTask() { //given an already started process instance ProcessInstance oldInstance = rule.processInstance(); Assert.assertNotNull(oldInstance); //with one completed user task HistoricTaskInstanceQuery historicTaskQuery = rule.HistoryService.createHistoricTaskInstanceQuery().processInstanceId(oldInstance.Id).finished(); Assert.assertEquals(1, historicTaskQuery.count()); //and one waiting Task task = rule.taskQuery().singleResult(); Assert.assertNotNull(task); //when completing the user task rule.TaskService.complete(task.Id); //then there exists no more tasks Assert.assertEquals(0, rule.taskQuery().count()); //and two historic tasks Assert.assertEquals(2, historicTaskQuery.count()); //and the process instance is also completed rule.assertScenarioEnded(); }
public virtual void testQueryNoAuthenticatedTenants() { identityService.setAuthentication("user", null, null); HistoricTaskInstanceQuery query = historyService.createHistoricTaskInstanceQuery(); assertThat(query.count(), @is(0L)); }
public virtual void testQueryDisabledTenantCheck() { processEngineConfiguration.TenantCheckEnabled = false; identityService.setAuthentication("user", null, null); HistoricTaskInstanceQuery query = historyService.createHistoricTaskInstanceQuery(); assertThat(query.count(), @is(2L)); }
private void createHistoricTaskInstanceMock() { IList <HistoricTaskInstance> tasks = MockProvider.createMockHistoricTaskInstances(); HistoricTaskInstanceQuery query = mock(typeof(HistoricTaskInstanceQuery)); when(mockHistoryService.createHistoricTaskInstanceQuery()).thenReturn(query); when(query.list()).thenReturn(tasks); }
public virtual void testQueryByTenantId() { HistoricTaskInstanceQuery query = historyService.createHistoricTaskInstanceQuery().tenantIdIn(TENANT_ONE); assertThat(query.count(), @is(1L)); query = historyService.createHistoricTaskInstanceQuery().tenantIdIn(TENANT_TWO); assertThat(query.count(), @is(1L)); }
public virtual void testQueryAuthenticatedTenants() { identityService.setAuthentication("user", null, Arrays.asList(TENANT_ONE, TENANT_TWO)); HistoricTaskInstanceQuery query = historyService.createHistoricTaskInstanceQuery(); assertThat(query.count(), @is(2L)); assertThat(query.tenantIdIn(TENANT_ONE).count(), @is(1L)); assertThat(query.tenantIdIn(TENANT_TWO).count(), @is(1L)); }
public virtual void testQueryHistoricProcessWithParallelGateway() { //given an already finished process instance with parallel gateway and two user tasks HistoricProcessInstance historicProcessInstance = rule.historicProcessInstance(); //when query history HistoricTaskInstanceQuery historicTaskQuery = rule.HistoryService.createHistoricTaskInstanceQuery().processInstanceId(historicProcessInstance.Id); //then two historic user tasks are returned Assert.assertEquals(2, historicTaskQuery.count()); }
// historic task instance query (process task) ////////////////////////////////////////// public virtual void testSimpleQueryWithoutAuthorization() { // given startProcessInstanceByKey(PROCESS_KEY); // when HistoricTaskInstanceQuery query = historyService.createHistoricTaskInstanceQuery(); // then verifyQueryResults(query, 0); }
// historic task instance query (case task) /////////////////////////////////////// public virtual void testQueryAfterCaseTask() { // given createCaseInstanceByKey(CASE_KEY); // when HistoricTaskInstanceQuery query = historyService.createHistoricTaskInstanceQuery(); // then verifyQueryResults(query, 1); }
private IList <HistoricTaskInstance> executePaginatedQuery(HistoricTaskInstanceQuery query, int?firstResult, int?maxResults) { if (firstResult == null) { firstResult = 0; } if (maxResults == null) { maxResults = int.MaxValue; } return(query.listPage(firstResult, maxResults)); }
public virtual CountResultDto queryHistoricTaskInstancesCount(HistoricTaskInstanceQueryDto queryDto) { queryDto.ObjectMapper = objectMapper; HistoricTaskInstanceQuery query = queryDto.toQuery(processEngine); long count = query.count(); CountResultDto result = new CountResultDto(); result.Count = count; return(result); }
public virtual void testSimpleQueryWithReadHistoryPermissionOnProcessDefinition() { // given startProcessInstanceByKey(PROCESS_KEY); createGrantAuthorization(PROCESS_DEFINITION, PROCESS_KEY, userId, READ_HISTORY); // when HistoricTaskInstanceQuery query = historyService.createHistoricTaskInstanceQuery(); // then verifyQueryResults(query, 1); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void deleteHistoricTaskInstanceWithAuthenticatedTenant() public virtual void deleteHistoricTaskInstanceWithAuthenticatedTenant() { string taskId = createTaskForTenant(TENANT_ONE); identityService.setAuthentication("user", null, Arrays.asList(TENANT_ONE)); historyService.deleteHistoricTaskInstance(taskId); identityService.clearAuthentication(); HistoricTaskInstanceQuery query = historyService.createHistoricTaskInstanceQuery(); assertThat(query.count(), @is(0L)); }
// historic task instance query (standalone task) /////////////////////////////////////// public virtual void testQueryAfterStandaloneTask() { // given string taskId = "myTask"; createTask(taskId); // when HistoricTaskInstanceQuery query = historyService.createHistoricTaskInstanceQuery(); // then verifyQueryResults(query, 1); deleteTask(taskId, true); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void deleteHistoricTaskInstanceWithDisabledTenantCheck() public virtual void deleteHistoricTaskInstanceWithDisabledTenantCheck() { string taskIdOne = createTaskForTenant(TENANT_ONE); string taskIdTwo = createTaskForTenant(TENANT_TWO); identityService.setAuthentication("user", null, null); processEngineConfiguration.TenantCheckEnabled = false; historyService.deleteHistoricTaskInstance(taskIdOne); historyService.deleteHistoricTaskInstance(taskIdTwo); HistoricTaskInstanceQuery query = historyService.createHistoricTaskInstanceQuery(); assertThat(query.count(), @is(0L)); }
public virtual void testGroupTaskQuery() { // given runtimeService.startProcessInstanceByKey("oneTaskProcess"); string taskId = taskService.createTaskQuery().singleResult().Id; // if identityService.AuthenticatedUserId = "aAssignerId"; taskService.addCandidateUser(taskId, "aUserId"); taskService.addCandidateGroup(taskId, "aGroupId"); taskService.addCandidateGroup(taskId, "bGroupId"); Task taskOne = taskService.newTask("taskOne"); taskOne.Assignee = "aUserId"; taskService.saveTask(taskOne); Task taskTwo = taskService.newTask("taskTwo"); taskTwo.Assignee = "aUserId"; taskService.saveTask(taskTwo); Task taskThree = taskService.newTask("taskThree"); taskThree.Owner = "aUserId"; taskService.saveTask(taskThree); taskService.deleteCandidateGroup(taskId, "aGroupId"); taskService.deleteCandidateGroup(taskId, "bGroupId"); historyService.createHistoricTaskInstanceQuery(); // Query test HistoricTaskInstanceQuery query = historyService.createHistoricTaskInstanceQuery(); assertEquals(4, query.taskInvolvedUser("aUserId").count()); query = historyService.createHistoricTaskInstanceQuery(); assertEquals(1, query.taskHadCandidateUser("aUserId").count()); query = historyService.createHistoricTaskInstanceQuery(); assertEquals(1, query.taskHadCandidateGroup("aGroupId").count()); assertEquals(1, query.taskHadCandidateGroup("bGroupId").count()); assertEquals(0, query.taskInvolvedUser("aUserId").count()); query = historyService.createHistoricTaskInstanceQuery(); assertEquals(4, query.taskInvolvedUser("aUserId").count()); assertEquals(1, query.taskHadCandidateUser("aUserId").count()); assertEquals(1, query.taskInvolvedUser("aUserId").count()); // delete task taskService.deleteTask("taskOne", true); taskService.deleteTask("taskTwo", true); taskService.deleteTask("taskThree", true); }
public virtual void testDeleteProcessTaskWithDeleteHistoryPermissionOnAnyProcessDefinition() { // given startProcessInstanceByKey(PROCESS_KEY); string taskId = selectSingleTask().Id; createGrantAuthorization(PROCESS_DEFINITION, ANY, userId, DELETE_HISTORY); // when historyService.deleteHistoricTaskInstance(taskId); // then disableAuthorization(); HistoricTaskInstanceQuery query = historyService.createHistoricTaskInstanceQuery().taskId(taskId); verifyQueryResults(query, 0); enableAuthorization(); }
// delete historic task (standalone task) /////////////////////// public virtual void testDeleteStandaloneTask() { // given string taskId = "myTask"; createTask(taskId); // when historyService.deleteHistoricTaskInstance(taskId); // then disableAuthorization(); HistoricTaskInstanceQuery query = historyService.createHistoricTaskInstanceQuery().taskId(taskId); verifyQueryResults(query, 0); enableAuthorization(); deleteTask(taskId, true); }
public virtual void testQueryHistoricProcessWithParallelGateway() { //given an already started process instance ProcessInstance oldInstance = rule.processInstance(); Assert.assertNotNull(oldInstance); //with one completed user task HistoricTaskInstanceQuery historicTaskQuery = rule.HistoryService.createHistoricTaskInstanceQuery().processInstanceId(oldInstance.Id).finished(); Assert.assertEquals(1, historicTaskQuery.count()); //and one async service task Job job = rule.jobQuery().singleResult(); Assert.assertNotNull(job); //when job is executed rule.ManagementService.executeJob(job.Id); //then there exists no more tasks //and the process instance is also completed Assert.assertEquals(0, rule.taskQuery().count()); rule.assertScenarioEnded(); }
// 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 HistoricTaskInstanceQuery query = historyService.createHistoricTaskInstanceQuery(); // then verifyQueryResults(query, 3); disableAuthorization(); IList <HistoricProcessInstance> instances = historyService.createHistoricProcessInstanceQuery().list(); foreach (HistoricProcessInstance instance in instances) { historyService.deleteHistoricProcessInstance(instance.Id); } enableAuthorization(); }
public virtual void testQueryWithoutTenantId() { HistoricTaskInstanceQuery query = historyService.createHistoricTaskInstanceQuery(); assertThat(query.count(), @is(2L)); }
// helper //////////////////////////////////////////////////////// protected internal virtual void verifyQueryResults(HistoricTaskInstanceQuery 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 virtual void testQueryByNonExistingTenantId() { HistoricTaskInstanceQuery query = historyService.createHistoricTaskInstanceQuery().tenantIdIn("nonExisting"); assertThat(query.count(), @is(0L)); }