protected internal virtual HistoricCaseInstance queryHistoricCaseInstance(string caseInstanceId) { HistoricCaseInstance historicCaseInstance = historicQuery().caseInstanceId(caseInstanceId).singleResult(); assertNotNull(historicCaseInstance); return(historicCaseInstance); }
public virtual void testRetrieveCaseDefinitionName() { // given string id = createCaseInstance("oneTaskCase").Id; // when HistoricCaseInstance caseInstance = historyService.createHistoricCaseInstanceQuery().caseInstanceId(id).singleResult(); // then assertEquals("One Task Case", caseInstance.CaseDefinitionName); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void terminateCaseExecutionWithAuthenticatedTenant() public virtual void terminateCaseExecutionWithAuthenticatedTenant() { identityService.setAuthentication("user", null, Arrays.asList(TENANT_ONE)); caseService.terminateCaseExecution(caseInstanceId); HistoricCaseInstance historicCaseInstance = HistoricCaseInstance; assertThat(historicCaseInstance, notNullValue()); assertThat(historicCaseInstance.Terminated, @is(true)); }
public virtual void testCaseInstanceProperties() { CaseInstance caseInstance = createCaseInstance(); HistoricCaseInstance historicInstance = queryHistoricCaseInstance(caseInstance.Id); // assert case instance properties are set correctly assertEquals(caseInstance.Id, historicInstance.Id); assertEquals(caseInstance.BusinessKey, historicInstance.BusinessKey); assertEquals(caseInstance.CaseDefinitionId, historicInstance.CaseDefinitionId); }
public virtual void testHistoricCaseInstanceDates() { // create test dates long duration = 72 * 3600 * 1000; DateTime created = ClockUtil.CurrentTime; DateTime closed = new DateTime(created.Ticks + duration); // create instance ClockUtil.CurrentTime = created; string caseInstanceId = createCaseInstance().Id; terminate(caseInstanceId); // close instance ClockUtil.CurrentTime = closed; close(caseInstanceId); HistoricCaseInstance historicCaseInstance = queryHistoricCaseInstance(caseInstanceId); // read historic dates ignoring milliseconds DateTime createTime = historicCaseInstance.CreateTime; DateTime closeTime = historicCaseInstance.CloseTime; long? durationInMillis = historicCaseInstance.DurationInMillis; assertDateSimilar(created, createTime); assertDateSimilar(closed, closeTime); // test that duration is as expected with a maximal difference of one second assertTrue(durationInMillis.Value >= duration); assertTrue(durationInMillis.Value < duration + 1000); // test queries DateTime beforeCreate = new DateTime(created.Ticks - 3600 * 1000); DateTime afterClose = new DateTime(closed.Ticks + 3600 * 1000); assertCount(1, historicQuery().createdAfter(beforeCreate)); assertCount(0, historicQuery().createdAfter(closed)); assertCount(0, historicQuery().createdBefore(beforeCreate)); assertCount(1, historicQuery().createdBefore(closed)); assertCount(0, historicQuery().createdBefore(beforeCreate).createdAfter(closed)); assertCount(1, historicQuery().closedAfter(created)); assertCount(0, historicQuery().closedAfter(afterClose)); assertCount(0, historicQuery().closedBefore(created)); assertCount(1, historicQuery().closedBefore(afterClose)); assertCount(0, historicQuery().closedBefore(created).closedAfter(afterClose)); assertCount(1, historicQuery().closedBefore(afterClose).closedAfter(created)); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void terminateCaseExecutionDisabledTenantCheck() public virtual void terminateCaseExecutionDisabledTenantCheck() { identityService.setAuthentication("user", null, null); processEngineConfiguration.TenantCheckEnabled = false; caseService.terminateCaseExecution(caseInstanceId); HistoricCaseInstance historicCaseInstance = HistoricCaseInstance; assertThat(historicCaseInstance, notNullValue()); assertThat(historicCaseInstance.Terminated, @is(true)); }
public virtual void testQueryBySuperCaseInstanceId() { string superCaseInstanceId = caseService.createCaseInstanceByKey("oneCaseTaskCase").Id; HistoricCaseInstanceQuery query = historyService.createHistoricCaseInstanceQuery().superCaseInstanceId(superCaseInstanceId); assertEquals(1, query.list().size()); assertEquals(1, query.count()); HistoricCaseInstance caseInstance = query.singleResult(); assertEquals(superCaseInstanceId, caseInstance.SuperCaseInstanceId); assertNull(caseInstance.SuperProcessInstanceId); }
public virtual void testCreateUser() { string userId = "test"; identityService.AuthenticatedUserId = userId; string caseInstanceId = createCaseInstance().Id; HistoricCaseInstance historicCaseInstance = queryHistoricCaseInstance(caseInstanceId); assertEquals(userId, historicCaseInstance.CreateUserId); assertCount(1, historicQuery().createdBy(userId)); identityService.AuthenticatedUserId = null; }
public virtual void testSuperCaseInstance() { string caseInstanceId = createCaseInstanceByKey("oneCaseTaskCase").Id; queryCaseExecutionByActivityId("PI_CaseTask_1").Id; HistoricCaseInstance historicCaseInstance = historicQuery().superCaseInstanceId(caseInstanceId).singleResult(); assertNotNull(historicCaseInstance); assertEquals(caseInstanceId, historicCaseInstance.SuperCaseInstanceId); string superCaseInstanceId = historicQuery().subCaseInstanceId(historicCaseInstance.Id).singleResult().Id; assertEquals(caseInstanceId, superCaseInstanceId); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void closeCaseInstanceWithAuthenticatedTenant() public virtual void closeCaseInstanceWithAuthenticatedTenant() { caseService.completeCaseExecution(caseInstanceId); identityService.setAuthentication("user", null, Arrays.asList(TENANT_ONE)); caseService.closeCaseInstance(caseInstanceId); identityService.clearAuthentication(); HistoricCaseInstance historicCaseInstance = HistoricCaseInstance; assertThat(historicCaseInstance, notNullValue()); assertThat(historicCaseInstance.Closed, @is(true)); }
public virtual void testQueryBySuperProcessInstanceId() { string superProcessInstanceId = runtimeService.startProcessInstanceByKey("subProcessQueryTest").Id; HistoricCaseInstanceQuery query = historyService.createHistoricCaseInstanceQuery().superProcessInstanceId(superProcessInstanceId); assertEquals(1, query.list().size()); assertEquals(1, query.count()); HistoricCaseInstance subCaseInstance = query.singleResult(); assertNotNull(subCaseInstance); assertEquals(superProcessInstanceId, subCaseInstance.SuperProcessInstanceId); assertNull(subCaseInstance.SuperCaseInstanceId); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void closeCaseInstanceDisabledTenantCheck() public virtual void closeCaseInstanceDisabledTenantCheck() { caseService.completeCaseExecution(caseInstanceId); identityService.setAuthentication("user", null, null); processEngineConfiguration.TenantCheckEnabled = false; caseService.closeCaseInstance(caseInstanceId); identityService.clearAuthentication(); HistoricCaseInstance historicCaseInstance = HistoricCaseInstance; assertThat(historicCaseInstance, notNullValue()); assertThat(historicCaseInstance.Closed, @is(true)); }
public virtual void testCaseInstanceStates() { string caseInstanceId = createCaseInstance().Id; HistoricCaseInstance historicCaseInstance = queryHistoricCaseInstance(caseInstanceId); assertTrue(historicCaseInstance.Active); assertCount(1, historicQuery().active()); assertCount(1, historicQuery().notClosed()); // start empty stage to complete case instance string stageExecutionId = queryCaseExecutionByActivityId("PI_Stage_1").Id; manualStart(stageExecutionId); historicCaseInstance = queryHistoricCaseInstance(caseInstanceId); assertTrue(historicCaseInstance.Completed); assertCount(1, historicQuery().completed()); assertCount(1, historicQuery().notClosed()); // reactive and terminate case instance reactivate(caseInstanceId); terminate(caseInstanceId); historicCaseInstance = queryHistoricCaseInstance(caseInstanceId); assertTrue(historicCaseInstance.Terminated); assertCount(1, historicQuery().terminated()); assertCount(1, historicQuery().notClosed()); // reactive and suspend case instance reactivate(caseInstanceId); suspend(caseInstanceId); historicCaseInstance = queryHistoricCaseInstance(caseInstanceId); // not public API assertTrue(((HistoricCaseInstanceEntity)historicCaseInstance).Suspended); // assertCount(1, historicQuery().suspended()); assertCount(1, historicQuery().notClosed()); // close case instance close(caseInstanceId); historicCaseInstance = queryHistoricCaseInstance(caseInstanceId); assertTrue(historicCaseInstance.Closed); assertCount(1, historicQuery().closed()); assertCount(0, historicQuery().notClosed()); }
public virtual void testDeleteHistoricCaseInstance() { CaseInstance caseInstance = createCaseInstance(); string caseInstanceId = caseInstance.Id; HistoricCaseInstance historicInstance = queryHistoricCaseInstance(caseInstanceId); assertNotNull(historicInstance); try { // should not be able to delete historic case instance cause the case instance is still running historyService.deleteHistoricCaseInstance(historicInstance.Id); fail("Exception expected"); } catch (NullValueException) { // expected } terminate(caseInstanceId); close(caseInstanceId); identityService.AuthenticatedUserId = "testUser"; historyService.deleteHistoricCaseInstance(historicInstance.Id); identityService.clearAuthentication(); if (processEngineConfiguration.HistoryLevel.Id >= org.camunda.bpm.engine.impl.history.HistoryLevel_Fields.HISTORY_LEVEL_FULL.Id) { // a user operation log should have been created assertEquals(1, historyService.createUserOperationLogQuery().count()); UserOperationLogEntry entry = historyService.createUserOperationLogQuery().singleResult(); assertEquals(org.camunda.bpm.engine.history.UserOperationLogEntry_Fields.CATEGORY_OPERATOR, entry.Category); assertEquals(EntityTypes.CASE_INSTANCE, entry.EntityType); assertEquals(org.camunda.bpm.engine.history.UserOperationLogEntry_Fields.OPERATION_TYPE_DELETE_HISTORY, entry.OperationType); assertEquals(caseInstanceId, entry.CaseInstanceId); assertNull(entry.Property); assertNull(entry.OrgValue); assertNull(entry.NewValue); } assertCount(0, historicQuery()); }
public virtual object execute(CommandContext commandContext) { ensureNotNull("caseInstanceId", caseInstanceId); // Check if case instance is still running HistoricCaseInstance instance = commandContext.HistoricCaseInstanceManager.findHistoricCaseInstance(caseInstanceId); ensureNotNull("No historic case instance found with id: " + caseInstanceId, "instance", instance); foreach (CommandChecker checker in commandContext.ProcessEngineConfiguration.CommandCheckers) { checker.checkDeleteHistoricCaseInstance(instance); } ensureNotNull("Case instance is still running, cannot delete historic case instance: " + caseInstanceId, "instance.getCloseTime()", instance.CloseTime); commandContext.OperationLogManager.logCaseInstanceOperation(org.camunda.bpm.engine.history.UserOperationLogEntry_Fields.OPERATION_TYPE_DELETE_HISTORY, caseInstanceId, Collections.singletonList(PropertyChange.EMPTY_CHANGE)); commandContext.HistoricCaseInstanceManager.deleteHistoricCaseInstancesByIds(Arrays.asList(caseInstanceId)); return(null); }
public static HistoricCaseInstanceDto fromHistoricCaseInstance(HistoricCaseInstance historicCaseInstance) { HistoricCaseInstanceDto dto = new HistoricCaseInstanceDto(); dto.id = historicCaseInstance.Id; dto.businessKey = historicCaseInstance.BusinessKey; dto.caseDefinitionId = historicCaseInstance.CaseDefinitionId; dto.caseDefinitionKey = historicCaseInstance.CaseDefinitionKey; dto.caseDefinitionName = historicCaseInstance.CaseDefinitionName; dto.createTime = historicCaseInstance.CreateTime; dto.closeTime = historicCaseInstance.CloseTime; dto.durationInMillis = historicCaseInstance.DurationInMillis; dto.createUserId = historicCaseInstance.CreateUserId; dto.superCaseInstanceId = historicCaseInstance.SuperCaseInstanceId; dto.superProcessInstanceId = historicCaseInstance.SuperProcessInstanceId; dto.tenantId = historicCaseInstance.TenantId; dto.active = historicCaseInstance.Active; dto.completed = historicCaseInstance.Completed; dto.terminated = historicCaseInstance.Terminated; dto.closed = historicCaseInstance.Closed; return(dto); }
public virtual void testQuerySorting() { string oneCaseInstanceId = createCaseInstanceByKey("oneTaskCase", "oneBusinessKey").Id; string twoCaseInstanceId = createCaseInstanceByKey("twoTaskCase", "twoBusinessKey").Id; // terminate and close case instances => close time and duration is set terminate(oneCaseInstanceId); close(oneCaseInstanceId); // set time ahead to get different durations ClockUtil.CurrentTime = DateTimeUtil.now().plusHours(1).toDate(); terminate(twoCaseInstanceId); close(twoCaseInstanceId); HistoricCaseInstance oneCaseInstance = queryHistoricCaseInstance(oneCaseInstanceId); HistoricCaseInstance twoCaseInstance = queryHistoricCaseInstance(twoCaseInstanceId); // sort by case instance ids string property = "id"; //JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET: //ORIGINAL LINE: List<? extends Comparable> sortedList = Arrays.asList(oneCaseInstance.getId(), twoCaseInstance.getId()); IList <IComparable> sortedList = new IList <IComparable> { oneCaseInstance.Id, twoCaseInstance.Id }; sortedList.Sort(); IList <HistoricCaseInstance> instances = historicQuery().orderByCaseInstanceId().asc().list(); assertEquals(2, instances.Count); assertThat(instances, contains(hasProperty(property, equalTo(sortedList[0])), hasProperty(property, equalTo(sortedList[1])))); instances = historicQuery().orderByCaseInstanceId().desc().list(); assertEquals(2, instances.Count); assertThat(instances, contains(hasProperty(property, equalTo(sortedList[1])), hasProperty(property, equalTo(sortedList[0])))); // sort by case definition ids property = "caseDefinitionId"; //JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET: //ORIGINAL LINE: sortedList = Arrays.asList(oneCaseInstance.getCaseDefinitionId(), twoCaseInstance.getCaseDefinitionId()); sortedList = new IList <IComparable> { oneCaseInstance.CaseDefinitionId, twoCaseInstance.CaseDefinitionId }; sortedList.Sort(); instances = historicQuery().orderByCaseDefinitionId().asc().list(); assertEquals(2, instances.Count); assertThat(instances, contains(hasProperty(property, equalTo(sortedList[0])), hasProperty(property, equalTo(sortedList[1])))); instances = historicQuery().orderByCaseDefinitionId().desc().list(); assertEquals(2, instances.Count); assertThat(instances, contains(hasProperty(property, equalTo(sortedList[1])), hasProperty(property, equalTo(sortedList[0])))); // sort by business keys property = "businessKey"; //JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET: //ORIGINAL LINE: sortedList = Arrays.asList(oneCaseInstance.getBusinessKey(), twoCaseInstance.getBusinessKey()); sortedList = new IList <IComparable> { oneCaseInstance.BusinessKey, twoCaseInstance.BusinessKey }; sortedList.Sort(); instances = historicQuery().orderByCaseInstanceBusinessKey().asc().list(); assertEquals(2, instances.Count); assertThat(instances, contains(hasProperty(property, equalTo(sortedList[0])), hasProperty(property, equalTo(sortedList[1])))); instances = historicQuery().orderByCaseInstanceBusinessKey().desc().list(); assertEquals(2, instances.Count); assertThat(instances, contains(hasProperty(property, equalTo(sortedList[1])), hasProperty(property, equalTo(sortedList[0])))); // sort by create time property = "createTime"; //JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET: //ORIGINAL LINE: sortedList = Arrays.asList(oneCaseInstance.getCreateTime(), twoCaseInstance.getCreateTime()); sortedList = new IList <IComparable> { oneCaseInstance.CreateTime, twoCaseInstance.CreateTime }; sortedList.Sort(); instances = historicQuery().orderByCaseInstanceCreateTime().asc().list(); assertEquals(2, instances.Count); assertThat(instances, contains(hasProperty(property, equalTo(sortedList[0])), hasProperty(property, equalTo(sortedList[1])))); instances = historicQuery().orderByCaseInstanceCreateTime().desc().list(); assertEquals(2, instances.Count); assertThat(instances, contains(hasProperty(property, equalTo(sortedList[1])), hasProperty(property, equalTo(sortedList[0])))); // sort by close time property = "closeTime"; //JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET: //ORIGINAL LINE: sortedList = Arrays.asList(oneCaseInstance.getCloseTime(), twoCaseInstance.getCloseTime()); sortedList = new IList <IComparable> { oneCaseInstance.CloseTime, twoCaseInstance.CloseTime }; sortedList.Sort(); instances = historicQuery().orderByCaseInstanceCloseTime().asc().list(); assertEquals(2, instances.Count); assertThat(instances, contains(hasProperty(property, equalTo(sortedList[0])), hasProperty(property, equalTo(sortedList[1])))); instances = historicQuery().orderByCaseInstanceCloseTime().desc().list(); assertEquals(2, instances.Count); assertThat(instances, contains(hasProperty(property, equalTo(sortedList[1])), hasProperty(property, equalTo(sortedList[0])))); // sort by duration property = "durationInMillis"; //JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET: //ORIGINAL LINE: sortedList = Arrays.asList(oneCaseInstance.getDurationInMillis(), twoCaseInstance.getDurationInMillis()); sortedList = new IList <IComparable> { oneCaseInstance.DurationInMillis, twoCaseInstance.DurationInMillis }; sortedList.Sort(); instances = historicQuery().orderByCaseInstanceDuration().asc().list(); assertEquals(2, instances.Count); assertThat(instances, contains(hasProperty(property, equalTo(sortedList[0])), hasProperty(property, equalTo(sortedList[1])))); instances = historicQuery().orderByCaseInstanceDuration().desc().list(); assertEquals(2, instances.Count); assertThat(instances, contains(hasProperty(property, equalTo(sortedList[1])), hasProperty(property, equalTo(sortedList[0])))); }