Exemple #1
0
 //JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
 //ORIGINAL LINE: @After public void cleanUp()
 public virtual void cleanUp()
 {
     if (runtimeService.createProcessInstanceQuery().count() > 0)
     {
       runtimeService.deleteProcessInstance(runtimeService.createProcessInstanceQuery().singleResult().Id,null,true);
     }
 }
Exemple #2
0
        public virtual void testQueryDeleteVariableHistoryOperationOnHistoryInstance()
        {
            // given
            process = runtimeService.startProcessInstanceByKey("oneTaskProcess");
            runtimeService.setVariable(process.Id, "testVariable", "test");
            runtimeService.deleteProcessInstance(process.Id, "none");
            string variableInstanceId = historyService.createHistoricVariableInstanceQuery().singleResult().Id;

            // when
            historyService.deleteHistoricVariableInstance(variableInstanceId);

            // then
            verifyVariableOperationAsserts(org.camunda.bpm.engine.history.UserOperationLogEntry_Fields.OPERATION_TYPE_DELETE_HISTORY);
        }
Exemple #3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @After public void cleanUp()
        public virtual void cleanUp()
        {
            foreach (ProcessInstance processInstance in runtimeService.createProcessInstanceQuery().list())
            {
                runtimeService.deleteProcessInstance(processInstance.Id, "test ended", true);
            }
        }
Exemple #4
0
        protected internal virtual IList <string> setupHistory()
        {
            runtimeService.deleteProcessInstance(processInstance.Id, null);
            IList <string> historicProcessInstances = new List <string>();

            foreach (HistoricProcessInstance hpi in historyService.createHistoricProcessInstanceQuery().list())
            {
                historicProcessInstances.Add(hpi.Id);
            }
            return(historicProcessInstances);
        }
Exemple #5
0
        public virtual void testQueryByDeleted()
        {
            startProcessInstance(PROCESS_DEFINITION_KEY);

            string processInstanceId = runtimeService.createProcessInstanceQuery().singleResult().Id;

            runtimeService.deleteProcessInstance(processInstanceId, null);

            HistoricIncidentQuery query = historyService.createHistoricIncidentQuery().deleted();

            assertEquals(1, query.list().size());
            assertEquals(1, query.count());
        }
Exemple #6
0
        public virtual void testDeleteHistoricProcessInstanceIgnoreDeleteHistory()
        {
            // given
            processEngineConfiguration.DisabledPermissions = Arrays.asList(Permissions.DELETE_HISTORY.name());

            ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("oneTaskProcess");

            runtimeService.deleteProcessInstance(processInstance.Id, "any");
            authRule.enableAuthorization(USER_ID);

            engineRule.HistoryService.deleteHistoricProcessInstance(processInstance.Id);
            authRule.disableAuthorization();
            assertNull(engineRule.HistoryService.createHistoricProcessInstanceQuery().singleResult());
        }
Exemple #7
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testQueryByDeletionLog()
        public virtual void testQueryByDeletionLog()
        {
            // given
            ExternalTask task = startExternalTaskProcess();

            runtimeService.deleteProcessInstance(task.ProcessInstanceId, null);

            // when
            HistoricExternalTaskLog log = historyService.createHistoricExternalTaskLogQuery().deletionLog().singleResult();

            // then
            assertNotNull(log);
            assertThat(log.ExternalTaskId, @is(task.Id));
        }
Exemple #8
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testHistoricExternalTaskLogDeletedProperties()
        public virtual void testHistoricExternalTaskLogDeletedProperties()
        {
            // given
            ExternalTask task = startExternalTaskProcess();

            runtimeService.deleteProcessInstance(task.ProcessInstanceId, "Dummy reason for deletion!");

            // when
            HistoricExternalTaskLog log = historyService.createHistoricExternalTaskLogQuery().deletionLog().singleResult();

            // then
            assertHistoricLogPropertiesAreProperlySet(task, log);
            assertEquals(null, log.WorkerId);
            assertLogIsInDeletedState(log);
        }
Exemple #9
0
        public virtual void testQueryProcessInstanceOperationsById()
        {
            // given
            process = runtimeService.startProcessInstanceByKey("oneTaskProcess");

            // when
            runtimeService.suspendProcessInstanceById(process.Id);
            runtimeService.activateProcessInstanceById(process.Id);

            runtimeService.deleteProcessInstance(process.Id, "a delete reason");

            // then
            assertEquals(4, query().entityType(PROCESS_INSTANCE).count());

            UserOperationLogEntry deleteEntry = query().entityType(PROCESS_INSTANCE).processInstanceId(process.Id).operationType(OPERATION_TYPE_DELETE).singleResult();

            assertNotNull(deleteEntry);
            assertEquals(process.Id, deleteEntry.ProcessInstanceId);
            assertNotNull(deleteEntry.ProcessDefinitionId);
            assertEquals("oneTaskProcess", deleteEntry.ProcessDefinitionKey);
            assertEquals(org.camunda.bpm.engine.history.UserOperationLogEntry_Fields.CATEGORY_OPERATOR, deleteEntry.Category);

            UserOperationLogEntry suspendEntry = query().entityType(PROCESS_INSTANCE).processInstanceId(process.Id).operationType(OPERATION_TYPE_SUSPEND).singleResult();

            assertNotNull(suspendEntry);
            assertEquals(process.Id, suspendEntry.ProcessInstanceId);
            assertNotNull(suspendEntry.ProcessDefinitionId);
            assertEquals("oneTaskProcess", suspendEntry.ProcessDefinitionKey);

            assertEquals("suspensionState", suspendEntry.Property);
            assertEquals("suspended", suspendEntry.NewValue);
            assertNull(suspendEntry.OrgValue);
            assertEquals(org.camunda.bpm.engine.history.UserOperationLogEntry_Fields.CATEGORY_OPERATOR, suspendEntry.Category);

            UserOperationLogEntry activateEntry = query().entityType(PROCESS_INSTANCE).processInstanceId(process.Id).operationType(OPERATION_TYPE_ACTIVATE).singleResult();

            assertNotNull(activateEntry);
            assertEquals(process.Id, activateEntry.ProcessInstanceId);
            assertNotNull(activateEntry.ProcessDefinitionId);
            assertEquals("oneTaskProcess", activateEntry.ProcessDefinitionKey);

            assertEquals("suspensionState", activateEntry.Property);
            assertEquals("active", activateEntry.NewValue);
            assertNull(activateEntry.OrgValue);
            assertEquals(org.camunda.bpm.engine.history.UserOperationLogEntry_Fields.CATEGORY_OPERATOR, activateEntry.Category);
        }
Exemple #10
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testLogCreationAsync()
        public virtual void testLogCreationAsync()
        {
            // given
            ProcessDefinition processDefinition = testRule.deployAndGetDefinition(instance);

            rule.IdentityService.AuthenticatedUserId = "userId";

            ProcessInstance processInstance1 = runtimeService.startProcessInstanceByKey("process1");
            ProcessInstance processInstance2 = runtimeService.startProcessInstanceByKey("process1");

            runtimeService.deleteProcessInstance(processInstance1.Id, "test");
            runtimeService.deleteProcessInstance(processInstance2.Id, "test");

            // when
            runtimeService.restartProcessInstances(processDefinition.Id).startAfterActivity("user1").processInstanceIds(processInstance1.Id, processInstance2.Id).executeAsync();
            rule.IdentityService.clearAuthentication();

            // then
            IList <UserOperationLogEntry> opLogEntries = rule.HistoryService.createUserOperationLogQuery().operationType("RestartProcessInstance").list();

            Assert.assertEquals(2, opLogEntries.Count);

            IDictionary <string, UserOperationLogEntry> entries = asMap(opLogEntries);


            UserOperationLogEntry asyncEntry = entries["async"];

            Assert.assertNotNull(asyncEntry);
            Assert.assertEquals("ProcessInstance", asyncEntry.EntityType);
            Assert.assertEquals("RestartProcessInstance", asyncEntry.OperationType);
            Assert.assertEquals(processDefinition.Id, asyncEntry.ProcessDefinitionId);
            Assert.assertEquals(processDefinition.Key, asyncEntry.ProcessDefinitionKey);
            Assert.assertNull(asyncEntry.ProcessInstanceId);
            Assert.assertNull(asyncEntry.OrgValue);
            Assert.assertEquals("true", asyncEntry.NewValue);
            Assert.assertEquals(org.camunda.bpm.engine.history.UserOperationLogEntry_Fields.CATEGORY_OPERATOR, asyncEntry.Category);

            UserOperationLogEntry numInstancesEntry = entries["nrOfInstances"];

            Assert.assertNotNull(numInstancesEntry);
            Assert.assertEquals("ProcessInstance", numInstancesEntry.EntityType);
            Assert.assertEquals("RestartProcessInstance", numInstancesEntry.OperationType);
            Assert.assertEquals(processDefinition.Id, numInstancesEntry.ProcessDefinitionId);
            Assert.assertEquals(processDefinition.Key, numInstancesEntry.ProcessDefinitionKey);
            Assert.assertNull(numInstancesEntry.ProcessInstanceId);
            Assert.assertNull(numInstancesEntry.OrgValue);
            Assert.assertEquals("2", numInstancesEntry.NewValue);
            Assert.assertEquals(org.camunda.bpm.engine.history.UserOperationLogEntry_Fields.CATEGORY_OPERATOR, numInstancesEntry.Category);

            Assert.assertEquals(asyncEntry.OperationId, numInstancesEntry.OperationId);
        }
Exemple #11
0
        private void createLogEntriesThatShouldNotBeReturned(string processInstanceId)
        {
            ClockUtil.CurrentTime = DateTime.Now;

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

            // create and remove some links
            taskService.addCandidateUser(processTaskId, "er");
            taskService.deleteCandidateUser(processTaskId, "er");
            taskService.addCandidateGroup(processTaskId, "wir");
            taskService.deleteCandidateGroup(processTaskId, "wir");

            // assign and reassign the owner
            taskService.setOwner(processTaskId, "icke");

            // change priority of task
            taskService.setPriority(processTaskId, 10);

            // add and delete an attachment
            Attachment attachment = taskService.createAttachment("image/ico", processTaskId, processInstanceId, "favicon.ico", "favicon", "http://camunda.com/favicon.ico");

            taskService.deleteAttachment(attachment.Id);
            runtimeService.deleteProcessInstance(processInstanceId, "that's why");

            // create a standalone userTask
            Task userTask = taskService.newTask();

            userTask.Name = "to do";
            taskService.saveTask(userTask);

            // change some properties manually to create an update event
            ClockUtil.CurrentTime = DateTime.Now;
            userTask.Description  = "desc";
            userTask.Owner        = "icke";
            userTask.Assignee     = "er";
            userTask.DueDate      = DateTime.Now;
            taskService.saveTask(userTask);

            taskService.deleteTask(userTask.Id, true);
        }
Exemple #12
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @After public void cleanUp()
        public virtual void cleanUp()
        {
            IList <ProcessInstance> processInstances = runtimeService.createProcessInstanceQuery().list();

            foreach (ProcessInstance processInstance in processInstances)
            {
                runtimeService.deleteProcessInstance(processInstance.Id, null, true, true);
            }

            IList <Task> tasks = taskService.createTaskQuery().list();

            foreach (Task task in tasks)
            {
                taskService.deleteTask(task.Id, true);
            }

            IList <HistoricProcessInstance> historicProcessInstances = historyService.createHistoricProcessInstanceQuery().list();

            foreach (HistoricProcessInstance historicProcessInstance in historicProcessInstances)
            {
                historyService.deleteHistoricProcessInstance(historicProcessInstance.Id);
            }
        }
Exemple #13
0
        public virtual void deleteProcessInstance(bool skipCustomListeners, bool skipIoMappings, bool skipSubprocesses, bool failIfNotExists)
        {
            RuntimeService runtimeService = engine.RuntimeService;

            try
            {
                if (failIfNotExists)
                {
                    runtimeService.deleteProcessInstance(processInstanceId, null, skipCustomListeners, true, skipIoMappings, skipSubprocesses);
                }
                else
                {
                    runtimeService.deleteProcessInstanceIfExists(processInstanceId, null, skipCustomListeners, true, skipIoMappings, skipSubprocesses);
                }
            }
            catch (AuthorizationException e)
            {
                throw e;
            }
            catch (ProcessEngineException e)
            {
                throw new InvalidRequestException(Status.NOT_FOUND, e, "Process instance with id " + processInstanceId + " does not exist");
            }
        }