示例#1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Deployment public void testOnlyTaskCompletionIsLogged()
        public virtual void testOnlyTaskCompletionIsLogged()
        {
            // given
            string processInstanceId = runtimeService.startProcessInstanceByKey("process").Id;

            string taskId = taskService.createTaskQuery().singleResult().Id;

            // when
            taskService.complete(taskId);

            // then
            assertTrue((bool?)runtimeService.getVariable(processInstanceId, "taskListenerCalled"));
            assertTrue((bool?)runtimeService.getVariable(processInstanceId, "serviceTaskCalled"));

            // Filter only task entities, as the process start is also recorded
            UserOperationLogQuery query = historyService.createUserOperationLogQuery().entityType(EntityTypes.TASK);

            assertEquals(1, query.count());

            UserOperationLogEntry log = query.singleResult();

            assertEquals("process", log.ProcessDefinitionKey);
            assertEquals(processInstanceId, log.ProcessInstanceId);
            assertEquals(deploymentId, log.DeploymentId);
            assertEquals(taskId, log.TaskId);
            assertEquals(org.camunda.bpm.engine.history.UserOperationLogEntry_Fields.OPERATION_TYPE_COMPLETE, log.OperationType);
            assertEquals(org.camunda.bpm.engine.history.UserOperationLogEntry_Fields.CATEGORY_TASK_WORKER, log.Category);
        }
示例#2
0
        public virtual void testCompleteCaseExecution()
        {
            // given
            string caseDefinitionId = repositoryService.createCaseDefinitionQuery().singleResult().Id;

            string caseInstanceId = caseService.withCaseDefinition(caseDefinitionId).create().Id;

            string humanTaskId = caseService.createCaseExecutionQuery().activityId("PI_HumanTask_1").singleResult().Id;

            // when
            caseService.withCaseExecution(humanTaskId).complete();

            // then
            UserOperationLogQuery query = queryOperationDetails(OPERATION_TYPE_COMPLETE);

            assertEquals(1, query.count());

            UserOperationLogEntry entry = query.singleResult();

            assertNotNull(entry);

            assertEquals(caseDefinitionId, entry.CaseDefinitionId);
            assertEquals(caseInstanceId, entry.CaseInstanceId);
            assertEquals(humanTaskId, entry.CaseExecutionId);
            assertEquals(deploymentId, entry.DeploymentId);

            assertFalse(Convert.ToBoolean(entry.OrgValue));
            assertTrue(Convert.ToBoolean(entry.NewValue));
            assertEquals(DELETE, entry.Property);
            assertEquals(org.camunda.bpm.engine.history.UserOperationLogEntry_Fields.CATEGORY_TASK_WORKER, entry.Category);
        }
示例#3
0
        public virtual void testCompositeBeanInteraction()
        {
            // given: a manually created task
            task = taskService.newTask();

            // then: save the task without any property change
            taskService.saveTask(task);

            // expect: no entry
            UserOperationLogQuery query  = queryOperationDetails(OPERATION_TYPE_CREATE);
            UserOperationLogEntry create = query.singleResult();

            assertNotNull(create);
            assertEquals(EntityTypes.TASK, create.EntityType);
            assertNull(create.OrgValue);
            assertNull(create.NewValue);
            assertNull(create.Property);
            assertEquals(org.camunda.bpm.engine.history.UserOperationLogEntry_Fields.CATEGORY_TASK_WORKER, create.Category);

            task.Assignee = "icke";
            task.Name     = "to do";

            // then: save the task again
            taskService.saveTask(task);

            // expect: two update entries with the same operation id
            IList <UserOperationLogEntry> entries = queryOperationDetails(OPERATION_TYPE_UPDATE).list();

            assertEquals(2, entries.Count);
            assertEquals(entries[0].OperationId, entries[1].OperationId);
            assertEquals(org.camunda.bpm.engine.history.UserOperationLogEntry_Fields.CATEGORY_TASK_WORKER, entries[0].Category);
            assertEquals(org.camunda.bpm.engine.history.UserOperationLogEntry_Fields.CATEGORY_TASK_WORKER, entries[1].Category);
        }
示例#4
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testWithoutAuthorization()
        public virtual void testWithoutAuthorization()
        {
            // given
            UserOperationLogQuery query = historyService.createUserOperationLogQuery().processDefinitionKey("timerBoundaryProcess").afterTimestamp(new DateTime(1549110000000l));

            // assume
            assertEquals(1L, query.count());
            UserOperationLogEntry entry = query.singleResult();

            engineRule.ProcessEngineConfiguration.AuthorizationEnabled = true;

            try
            {
                // when
                historyService.deleteUserOperationLogEntry(entry.Id);
                fail("Exception expected: It should not be possible to delete the user operation log");
            }
            catch (AuthorizationException e)
            {
                // then
                string message = e.Message;
                assertTrue(message.Contains(USER_ID));
                assertTrue(message.Contains(DELETE_HISTORY.Name));
                assertTrue(message.Contains(PROCESS_DEFINITION.resourceName()));
                assertTrue(message.Contains("timerBoundaryProcess"));
            }
        }
示例#5
0
        protected internal virtual void verifyVariableOperationAsserts(int countAssertValue, string operationType, string category)
        {
            UserOperationLogQuery logQuery = query().entityType(EntityTypes.VARIABLE).operationType(operationType);

            assertEquals(countAssertValue, logQuery.count());

            if (countAssertValue > 1)
            {
                IList <UserOperationLogEntry> logEntryList = logQuery.list();

                foreach (UserOperationLogEntry logEntry in logEntryList)
                {
                    assertEquals(process.ProcessDefinitionId, logEntry.ProcessDefinitionId);
                    assertEquals(process.ProcessInstanceId, logEntry.ProcessInstanceId);
                    assertEquals(category, logEntry.Category);
                }
            }
            else
            {
                UserOperationLogEntry logEntry = logQuery.singleResult();
                assertEquals(process.ProcessDefinitionId, logEntry.ProcessDefinitionId);
                assertEquals(process.ProcessInstanceId, logEntry.ProcessInstanceId);
                assertEquals(category, logEntry.Category);
            }
        }
示例#6
0
        public virtual void testSetJobDueDate()
        {
            // given a job
            runtimeService.startProcessInstanceByKey("asyncTaskProcess");
            Job job = managementService.createJobQuery().singleResult();

            // and set the job due date
            DateTime newDate = new DateTime(ClockUtil.CurrentTime.Ticks + 2 * 1000);

            managementService.setJobDuedate(job.Id, newDate);

            // then one op log entry is written
            UserOperationLogQuery query = historyService.createUserOperationLogQuery().operationType(org.camunda.bpm.engine.history.UserOperationLogEntry_Fields.OPERATION_TYPE_SET_DUEDATE);

            assertEquals(1, query.count());

            // assert details
            UserOperationLogEntry entry = query.singleResult();

            assertEquals(job.Id, entry.JobId);
            assertEquals(job.DeploymentId, entry.DeploymentId);
            assertEquals(job.JobDefinitionId, entry.JobDefinitionId);
            assertEquals("duedate", entry.Property);
            assertNull(entry.OrgValue);
            assertEquals(newDate, new DateTime(Convert.ToInt64(entry.NewValue)));
        }
示例#7
0
        protected internal virtual void verifyQueryResults(UserOperationLogQuery query, int countExpected)
        {
            assertEquals(countExpected, query.list().size());
            assertEquals(countExpected, query.count());

            if (countExpected == 1)
            {
                assertNotNull(query.singleResult());
            }
            else if (countExpected > 1)
            {
                verifySingleResultFails(query);
            }
            else if (countExpected == 0)
            {
                assertNull(query.singleResult());
            }
        }
示例#8
0
 protected internal virtual void verifySingleResultFails(UserOperationLogQuery query)
 {
     try
     {
         query.singleResult();
         fail();
     }
     catch (ProcessEngineException)
     {
     }
 }
示例#9
0
        public virtual void testUserOperationLogDeletion()
        {
            // given
            process = runtimeService.startProcessInstanceByKey("oneTaskProcess");
            runtimeService.setVariable(process.Id, "testVariable1", "THIS IS TESTVARIABLE!!!");

            // assume
            verifyVariableOperationAsserts(1, org.camunda.bpm.engine.history.UserOperationLogEntry_Fields.OPERATION_TYPE_SET_VARIABLE, org.camunda.bpm.engine.history.UserOperationLogEntry_Fields.CATEGORY_OPERATOR);
            UserOperationLogQuery query = query().entityType(EntityTypes.VARIABLE).operationType(org.camunda.bpm.engine.history.UserOperationLogEntry_Fields.OPERATION_TYPE_SET_VARIABLE);

            assertEquals(1, query.count());

            // when
            historyService.deleteUserOperationLogEntry(query.singleResult().Id);

            // then
            assertEquals(0, query.count());
        }
示例#10
0
        public virtual void testCaseInstanceId()
        {
            // create new task
            task = taskService.newTask();
            taskService.saveTask(task);

            UserOperationLogQuery query = queryOperationDetails(OPERATION_TYPE_UPDATE);

            assertEquals(0, query.count());

            // set case instance id and save task
            task.CaseInstanceId = "aCaseInstanceId";
            taskService.saveTask(task);

            assertEquals(1, query.count());

            UserOperationLogEntry entry = query.singleResult();

            assertNotNull(entry);

            assertNull(entry.OrgValue);
            assertEquals("aCaseInstanceId", entry.NewValue);
            assertEquals(CASE_INSTANCE_ID, entry.Property);

            // change case instance id and save task
            task.CaseInstanceId = "anotherCaseInstanceId";
            taskService.saveTask(task);

            assertEquals(2, query.count());

            IList <UserOperationLogEntry> entries = query.list();

            assertEquals(2, entries.Count);

            foreach (UserOperationLogEntry currentEntry in entries)
            {
                if (!currentEntry.Id.Equals(entry.Id))
                {
                    assertEquals("aCaseInstanceId", currentEntry.OrgValue);
                    assertEquals("anotherCaseInstanceId", currentEntry.NewValue);
                    assertEquals(CASE_INSTANCE_ID, currentEntry.Property);
                }
            }
        }
示例#11
0
        public virtual void testResolveTask()
        {
            startTestProcess();

            // then: resolve the task
            taskService.resolveTask(task.Id);

            // expect: one entry for the resolving
            UserOperationLogQuery query = queryOperationDetails(OPERATION_TYPE_RESOLVE);

            assertEquals(1, query.count());

            // assert: details
            UserOperationLogEntry log = query.singleResult();

            assertEquals(DelegationState.RESOLVED.ToString(), log.NewValue);
            assertEquals(org.camunda.bpm.engine.history.UserOperationLogEntry_Fields.CATEGORY_TASK_WORKER, log.Category);

            completeTestProcess();
        }
示例#12
0
        public virtual void testSetPriority()
        {
            startTestProcess();

            // then: set the priority of the task to 10
            taskService.setPriority(task.Id, 10);

            // expect: one entry for the priority update
            UserOperationLogQuery query = queryOperationDetails(OPERATION_TYPE_SET_PRIORITY);

            assertEquals(1, query.count());

            // assert: correct priority set
            UserOperationLogEntry userOperationLogEntry = query.singleResult();

            assertEquals(PRIORITY, userOperationLogEntry.Property);
            // note: 50 is the default task priority
            assertEquals(50, int.Parse(userOperationLogEntry.OrgValue));
            assertEquals(10, int.Parse(userOperationLogEntry.NewValue));
            // assert: correct category set
            assertEquals(org.camunda.bpm.engine.history.UserOperationLogEntry_Fields.CATEGORY_TASK_WORKER, userOperationLogEntry.Category);

            // move clock by 5 minutes
            DateTime date = DateTimeUtil.now().plusMinutes(5).toDate();

            ClockUtil.CurrentTime = date;

            // then: set priority again
            taskService.setPriority(task.Id, 75);

            // expect: one entry for the priority update
            query = queryOperationDetails(OPERATION_TYPE_SET_PRIORITY);
            assertEquals(2, query.count());

            // assert: correct priority set
            userOperationLogEntry = query.orderByTimestamp().asc().list().get(1);
            assertEquals(PRIORITY, userOperationLogEntry.Property);
            assertEquals(10, int.Parse(userOperationLogEntry.OrgValue));
            assertEquals(75, int.Parse(userOperationLogEntry.NewValue));
            assertEquals(org.camunda.bpm.engine.history.UserOperationLogEntry_Fields.CATEGORY_TASK_WORKER, userOperationLogEntry.Category);
        }
示例#13
0
        public virtual void testChangeTaskOwner()
        {
            startTestProcess();

            // then: change the task owner
            taskService.setOwner(task.Id, "icke");

            // expect: one entry for the owner change
            UserOperationLogQuery query = queryOperationDetails(OPERATION_TYPE_SET_OWNER);

            assertEquals(1, query.count());

            // assert: details
            UserOperationLogEntry change = query.singleResult();

            assertEquals(OWNER, change.Property);
            assertEquals("icke", change.NewValue);
            assertEquals(org.camunda.bpm.engine.history.UserOperationLogEntry_Fields.CATEGORY_TASK_WORKER, change.Category);

            completeTestProcess();
        }
示例#14
0
        public virtual void testClaimTask()
        {
            startTestProcess();

            // then: claim a new the task
            taskService.claim(task.Id, "icke");

            // expect: one entry for the claim
            UserOperationLogQuery query = queryOperationDetails(OPERATION_TYPE_CLAIM);

            assertEquals(1, query.count());

            // assert: details
            UserOperationLogEntry claim = query.singleResult();

            assertEquals(ASSIGNEE, claim.Property);
            assertEquals("icke", claim.NewValue);
            assertEquals(org.camunda.bpm.engine.history.UserOperationLogEntry_Fields.CATEGORY_TASK_WORKER, claim.Category);

            completeTestProcess();
        }
示例#15
0
        public virtual void testCreateAndCompleteTask()
        {
            startTestProcess();

            // expect: one entry for process instance creation,
            //         no entry for the task creation by process engine
            UserOperationLogQuery query = historyService.createUserOperationLogQuery();

            assertEquals(1, query.count());

            completeTestProcess();

            // expect: one entry for the task completion
            query = queryOperationDetails(OPERATION_TYPE_COMPLETE);
            assertEquals(1, query.count());
            UserOperationLogEntry complete = query.singleResult();

            assertEquals(DELETE, complete.Property);
            assertTrue(bool.Parse(complete.NewValue));
            assertEquals(org.camunda.bpm.engine.history.UserOperationLogEntry_Fields.CATEGORY_TASK_WORKER, complete.Category);
        }
示例#16
0
        public virtual void testAssignTask()
        {
            startTestProcess();

            // then: assign the task
            taskService.setAssignee(task.Id, "icke");

            // expect: one entry for the task assignment
            UserOperationLogQuery query = queryOperationDetails(OPERATION_TYPE_ASSIGN);

            assertEquals(1, query.count());

            // assert: details
            UserOperationLogEntry assign = query.singleResult();

            assertEquals(ASSIGNEE, assign.Property);
            assertEquals("icke", assign.NewValue);
            assertEquals(org.camunda.bpm.engine.history.UserOperationLogEntry_Fields.CATEGORY_TASK_WORKER, assign.Category);

            completeTestProcess();
        }
示例#17
0
        public virtual void testDeleteProcessDefinitionCascading()
        {
            // given
            Deployment deployment = repositoryService.createDeployment().name(DEPLOYMENT_NAME).addModelInstance(RESOURCE_NAME, createProcessWithServiceTask(PROCESS_KEY)).deploy();

            ProcessDefinition procDef = repositoryService.createProcessDefinitionQuery().deploymentId(deployment.Id).singleResult();

            UserOperationLogQuery query = historyService.createUserOperationLogQuery().operationType(org.camunda.bpm.engine.history.UserOperationLogEntry_Fields.OPERATION_TYPE_DELETE);

            // when
            repositoryService.deleteProcessDefinition(procDef.Id, true);

            // then
            assertEquals(1, query.count());

            UserOperationLogEntry log = query.singleResult();

            assertNotNull(log);

            assertEquals(EntityTypes.PROCESS_DEFINITION, log.EntityType);
            assertEquals(procDef.Id, log.ProcessDefinitionId);
            assertEquals(procDef.Key, log.ProcessDefinitionKey);
            assertEquals(deployment.Id, log.DeploymentId);

            assertEquals(org.camunda.bpm.engine.history.UserOperationLogEntry_Fields.OPERATION_TYPE_DELETE, log.OperationType);

            assertEquals("cascade", log.Property);
            assertFalse(Convert.ToBoolean(log.OrgValue));
            assertTrue(Convert.ToBoolean(log.NewValue));

            assertEquals(USER_ID, log.UserId);

            assertEquals(org.camunda.bpm.engine.history.UserOperationLogEntry_Fields.CATEGORY_OPERATOR, log.Category);

            assertNull(log.JobDefinitionId);
            assertNull(log.ProcessInstanceId);
            assertNull(log.CaseInstanceId);
            assertNull(log.CaseDefinitionId);
        }
示例#18
0
        public virtual void testDeleteTask()
        {
            // given: a single task
            task = taskService.newTask();
            taskService.saveTask(task);

            // then: delete the task
            taskService.deleteTask(task.Id, "duplicated");

            // expect: one entry for the deletion
            UserOperationLogQuery query = queryOperationDetails(OPERATION_TYPE_DELETE);

            assertEquals(1, query.count());

            // assert: details
            UserOperationLogEntry delete = query.singleResult();

            assertEquals(DELETE, delete.Property);
            assertFalse(bool.Parse(delete.OrgValue));
            assertTrue(bool.Parse(delete.NewValue));
            assertEquals(org.camunda.bpm.engine.history.UserOperationLogEntry_Fields.CATEGORY_TASK_WORKER, delete.Category);
        }
示例#19
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testWithDeleteHistoryPermissionOnAnyProcessDefinition()
        public virtual void testWithDeleteHistoryPermissionOnAnyProcessDefinition()
        {
            // given
            UserOperationLogQuery query = historyService.createUserOperationLogQuery().taskId("myTaskForUserOperationLogDel");

            // assume
            assertEquals(1, query.count());

            Authorization auth = authorizationService.createNewAuthorization(org.camunda.bpm.engine.authorization.Authorization_Fields.AUTH_TYPE_GRANT);

            auth.UserId      = USER_ID;
            auth.Permissions = new Permissions[] { Permissions.DELETE_HISTORY };
            auth.Resource    = Resources.PROCESS_DEFINITION;
            auth.ResourceId  = "*";

            authorizationService.saveAuthorization(auth);
            engineConfiguration.AuthorizationEnabled = true;

            // when
            historyService.deleteUserOperationLogEntry(query.singleResult().Id);

            // then
            assertNull(historyService.createUserOperationLogQuery().taskId("myTaskForUserOperationLogDel").singleResult());
        }
示例#20
0
        public virtual void testQueryProcessInstanceModificationOperation()
        {
            ProcessInstance processInstance   = runtimeService.startProcessInstanceByKey("oneTaskProcess");
            string          processInstanceId = processInstance.Id;

            ProcessDefinition definition = repositoryService.createProcessDefinitionQuery().singleResult();

            runtimeService.createProcessInstanceModification(processInstance.Id).startBeforeActivity("theTask").execute();

            UserOperationLogQuery logQuery = query().entityType(EntityTypes.PROCESS_INSTANCE).operationType(org.camunda.bpm.engine.history.UserOperationLogEntry_Fields.OPERATION_TYPE_MODIFY_PROCESS_INSTANCE);

            assertEquals(1, logQuery.count());
            UserOperationLogEntry logEntry = logQuery.singleResult();

            assertEquals(processInstanceId, logEntry.ProcessInstanceId);
            assertEquals(processInstance.ProcessDefinitionId, logEntry.ProcessDefinitionId);
            assertEquals(definition.Key, logEntry.ProcessDefinitionKey);
            assertEquals(org.camunda.bpm.engine.history.UserOperationLogEntry_Fields.OPERATION_TYPE_MODIFY_PROCESS_INSTANCE, logEntry.OperationType);
            assertEquals(EntityTypes.PROCESS_INSTANCE, logEntry.EntityType);
            assertNull(logEntry.Property);
            assertNull(logEntry.OrgValue);
            assertNull(logEntry.NewValue);
            assertEquals(org.camunda.bpm.engine.history.UserOperationLogEntry_Fields.CATEGORY_OPERATOR, logEntry.Category);
        }