Example #1
0
        public virtual void testCaseDecisionInstanceProperties()
        {
            CaseInstance caseInstance = createCaseInstanceAndEvaluateDecision();

            CaseDefinition caseDefinition = repositoryService.createCaseDefinitionQuery().caseDefinitionId(caseInstance.CaseDefinitionId).singleResult();

            string decisionDefinitionId = repositoryService.createDecisionDefinitionQuery().decisionDefinitionKey(DECISION_DEFINITION_KEY).singleResult().Id;

            string activityInstanceId = historyService.createHistoricCaseActivityInstanceQuery().caseActivityId("PI_DecisionTask_1").singleResult().Id;

            HistoricDecisionInstance historicDecisionInstance = historyService.createHistoricDecisionInstanceQuery().singleResult();

            assertThat(historicDecisionInstance, @is(notNullValue()));
            assertThat(historicDecisionInstance.DecisionDefinitionId, @is(decisionDefinitionId));
            assertThat(historicDecisionInstance.DecisionDefinitionKey, @is(DECISION_DEFINITION_KEY));
            assertThat(historicDecisionInstance.DecisionDefinitionName, @is("sample decision"));

            assertThat(historicDecisionInstance.ProcessDefinitionKey, @is(nullValue()));
            assertThat(historicDecisionInstance.ProcessDefinitionId, @is(nullValue()));
            assertThat(historicDecisionInstance.ProcessInstanceId, @is(nullValue()));

            assertThat(historicDecisionInstance.CaseDefinitionKey, @is(caseDefinition.Key));
            assertThat(historicDecisionInstance.CaseDefinitionId, @is(caseDefinition.Id));
            assertThat(historicDecisionInstance.CaseInstanceId, @is(caseInstance.Id));

            assertThat(historicDecisionInstance.ActivityId, @is("PI_DecisionTask_1"));
            assertThat(historicDecisionInstance.ActivityInstanceId, @is(activityInstanceId));

            assertThat(historicDecisionInstance.EvaluationTime, @is(notNullValue()));
        }
Example #2
0
        public virtual void testManualActivationRuleEvaluatesDecision()
        {
            CaseInstance caseInstance = caseService.withCaseDefinitionByKey("case").setVariable("input1", null).setVariable("myBean", new DecisionServiceDelegate()).create();

            CaseDefinition caseDefinition = repositoryService.createCaseDefinitionQuery().caseDefinitionId(caseInstance.CaseDefinitionId).singleResult();

            string decisionDefinitionId = repositoryService.createDecisionDefinitionQuery().decisionDefinitionKey(DECISION_DEFINITION_KEY).singleResult().Id;

            string activityInstanceId = historyService.createHistoricCaseActivityInstanceQuery().caseActivityId("PI_HumanTask_1").singleResult().Id;

            HistoricDecisionInstance historicDecisionInstance = historyService.createHistoricDecisionInstanceQuery().singleResult();

            assertThat(historicDecisionInstance, @is(notNullValue()));
            assertThat(historicDecisionInstance.DecisionDefinitionId, @is(decisionDefinitionId));
            assertThat(historicDecisionInstance.DecisionDefinitionKey, @is(DECISION_DEFINITION_KEY));
            assertThat(historicDecisionInstance.DecisionDefinitionName, @is("sample decision"));

            // references to case instance should be set since the decision is evaluated while executing a case instance
            assertThat(historicDecisionInstance.ProcessDefinitionKey, @is(nullValue()));
            assertThat(historicDecisionInstance.ProcessDefinitionId, @is(nullValue()));
            assertThat(historicDecisionInstance.ProcessInstanceId, @is(nullValue()));
            assertThat(historicDecisionInstance.CaseDefinitionKey, @is(caseDefinition.Key));
            assertThat(historicDecisionInstance.CaseDefinitionId, @is(caseDefinition.Id));
            assertThat(historicDecisionInstance.CaseInstanceId, @is(caseInstance.Id));
            assertThat(historicDecisionInstance.ActivityId, @is("PI_HumanTask_1"));
            assertThat(historicDecisionInstance.ActivityInstanceId, @is(activityInstanceId));
            assertThat(historicDecisionInstance.EvaluationTime, @is(notNullValue()));
        }
Example #3
0
 protected internal virtual void ensureActivityInitialized()
 {
     if ((activity == null) && (!string.ReferenceEquals(activityId, null)))
     {
         Activity = CaseDefinition.findActivity(activityId);
     }
 }
Example #4
0
        protected internal virtual void provideTenantId(IDictionary <string, object> variables)
        {
            TenantIdProvider tenantIdProvider = Context.ProcessEngineConfiguration.TenantIdProvider;

            if (tenantIdProvider != null)
            {
                VariableMap    variableMap    = Variables.fromMap(variables);
                CaseDefinition caseDefinition = (CaseDefinition)CaseDefinition;

                TenantIdProviderCaseInstanceContext ctx = null;

                if (!string.ReferenceEquals(superExecutionId, null))
                {
                    ctx = new TenantIdProviderCaseInstanceContext(caseDefinition, variableMap, getSuperExecution());
                }
                else if (!string.ReferenceEquals(superCaseExecutionId, null))
                {
                    ctx = new TenantIdProviderCaseInstanceContext(caseDefinition, variableMap, SuperCaseExecution);
                }
                else
                {
                    ctx = new TenantIdProviderCaseInstanceContext(caseDefinition, variableMap);
                }

                tenantId = tenantIdProvider.provideTenantIdForCaseInstance(ctx);
            }
        }
        /// <summary>
        /// Build a list of all case definitions given a number of box
        /// </summary>
        /// <param name="iNumber">Number of items to fit in box</param>
        /// <returns></returns>
        public List <CaseDefinition> CaseDefinitions(int iNumber)
        {
            List <CaseDefinition> caseDefinitionList = new List <CaseDefinition>();

            foreach (PackArrangement arr in BoxArrangements(iNumber))
            {
                for (int i = 0; i < 3; ++i)
                {
                    for (int j = 0; j < 3; ++j)
                    {
                        if (j == i)
                        {
                            continue;
                        }

                        CaseDefinition caseDefinition = new CaseDefinition(arr, i, j);
                        if (caseDefinition.IsValid(_boxProperties, _caseOptimConstraintSet))
                        {
                            caseDefinitionList.Add(caseDefinition);
                        }
                    }
                }
            }
            return(caseDefinitionList);
        }
        /// <summary>
        /// Build a list of all case definitions given a number of box
        /// </summary>
        /// <param name="iNumber">Number of items to fit in box</param>
        /// <returns></returns>
        private List <CaseDefinition> CaseDefinitions(int iNumber)
        {
            // TODO: better as IEnumerable<>?
            var caseDefinitionList = new List <CaseDefinition>();

            foreach (PackArrangement arr in BoxArrangements(iNumber))
            {
                for (int i = 0; i < 3; ++i)
                {
                    for (int j = 0; j < 3; ++j)
                    {
                        if (j == i)
                        {
                            continue;
                        }

                        var caseDefinition = new CaseDefinition(arr, i, j);
                        if (caseDefinition.IsValid(_packable, _paramSetPackOptim))
                        {
                            caseDefinitionList.Add(caseDefinition);
                        }
                    }
                }
            }
            return(caseDefinitionList);
        }
Example #7
0
 protected TypedCaseFrame(CaseSchema schema)
 {
     Definition     = new CaseDefinitionBuilder(typeof(TCase), schema).Build();
     Schema         = schema ?? Definition.GetCaseSchema();
     IdGetter       = DynamicCodeUtils.GenerateGetter <TCase>(Definition.IdAttribute);
     SolutionGetter = DynamicCodeUtils.GenerateGetter <TCase>(Definition.SolutionAttribute);
     Getters        = GenerateGetters(Definition);
 }
Example #8
0
 public void ModifyHealthRisk(
     HealthRiskName name,
     CaseDefinition caseDefinition,
     HealthRiskNumber healthRiskNumber
     )
 {
     Apply(new HealthRiskModified(EventSourceId, name, caseDefinition, healthRiskNumber));
 }
Example #9
0
        public virtual void testDeployCaseDefinitionWithStringHistoryTimeToLive()
        {
            CaseDefinition caseDefinition    = repositoryService.createCaseDefinitionQuery().singleResult();
            int?           historyTimeToLive = caseDefinition.HistoryTimeToLive;

            assertNotNull(historyTimeToLive);
            assertEquals((int)historyTimeToLive, 5);
        }
Example #10
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void getCaseDefinitionWithAuthenticatedTenant()
        public virtual void getCaseDefinitionWithAuthenticatedTenant()
        {
            identityService.setAuthentication("user", null, Arrays.asList(TENANT_ONE));

            CaseDefinition definition = repositoryService.getCaseDefinition(caseDefinitionId);

            assertThat(definition.TenantId, @is(TENANT_ONE));
        }
Example #11
0
 public Case(TCase caseData, CaseSchema schema = null)
 {
     Data           = caseData ?? throw new ArgumentNullException(nameof(caseData));
     definition     = new CaseDefinitionBuilder(typeof(TCase), schema).Build();
     Schema         = schema ?? definition.GetCaseSchema();
     idGetter       = DynamicCodeUtils.GenerateGetter <TCase>(definition.IdAttribute);
     solutionGetter = DynamicCodeUtils.GenerateGetter <TCase>(definition.SolutionAttribute);
     getters        = GenerateGetters();
 }
Example #12
0
 public SwitchCaseModel(CaseDefinition caseItem, IdeCollection <IdeBaseItem> source) : base(source) //load
 {
     _case          = caseItem;
     BlockContainer = new BlockContainer(caseItem.linkList);
     BlockContainer.OnContainerChanged += (a, b) =>
     {
         _case.linkList = BlockContainer.BuildTemplateBlockDef(b);
     };
 }
Example #13
0
 public CaseClassMap(CaseDefinition definition)
 {
     MapAttribute(definition.IdAttribute);
     MapAttribute(definition.SolutionAttribute);
     foreach (var attribute in definition)
     {
         MapAttribute(attribute);
     }
 }
Example #14
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void getCaseDefinitionDisabledTenantCheck()
        public virtual void getCaseDefinitionDisabledTenantCheck()
        {
            processEngineConfiguration.TenantCheckEnabled = false;
            identityService.setAuthentication("user", null, null);

            CaseDefinition definition = repositoryService.getCaseDefinition(caseDefinitionId);

            assertThat(definition.TenantId, @is(TENANT_ONE));
        }
Example #15
0
 public ElseCaseModel(IdeCollection <IdeBaseItem> source) : base(source) //new
 {
     _case          = new CaseDefinition();
     BlockContainer = new BlockContainer();
     BlockContainer.OnContainerChanged += (a, b) =>
     {
         _case.linkList = BlockContainer.BuildTemplateBlockDef(b);
     };
     CanDragDrop = false;
 }
Example #16
0
        private static Delegate[] GenerateGetters(CaseDefinition definition)
        {
            var result = new Delegate[definition.Count];

            for (var i = 0; i < definition.Count; i++)
            {
                result[i] = DynamicCodeUtils.GenerateGetter <TCase>(definition[i]);
            }

            return(result);
        }
Example #17
0
 public ElseIfCaseModel(CaseDefinition caseItem, IdeCollection <IdeBaseItem> source) : base(source) //load
 {
     _case          = caseItem;
     _property      = (PropertyItemModel)CustomProperties.FirstOrDefault(x => ((PropertyItemModel)x)._property.Name == _case.property);
     BlockContainer = new BlockContainer(caseItem.linkList);
     BlockContainer.OnContainerChanged += (a, b) =>
     {
         _case.linkList = BlockContainer.BuildTemplateBlockDef(b);
     };
     Messenger.Default.Register <CustomPropertyChangedMessage>(this, action => CustomPropertyChanged(action));
 }
Example #18
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testDefinitionRetrieval_ByKeyAndTenantId()
        public virtual void testDefinitionRetrieval_ByKeyAndTenantId()
        {
            CaseDefinition mockDefinition = MockProvider.mockCaseDefinition().tenantId(MockProvider.EXAMPLE_TENANT_ID).build();

            UpRuntimeData = mockDefinition;

            given().pathParam("key", MockProvider.EXAMPLE_CASE_DEFINITION_KEY).pathParam("tenant-id", MockProvider.EXAMPLE_TENANT_ID).then().expect().statusCode(Status.OK.StatusCode).body("id", equalTo(MockProvider.EXAMPLE_CASE_DEFINITION_ID)).body("key", equalTo(MockProvider.EXAMPLE_CASE_DEFINITION_KEY)).body("category", equalTo(MockProvider.EXAMPLE_CASE_DEFINITION_CATEGORY)).body("name", equalTo(MockProvider.EXAMPLE_CASE_DEFINITION_NAME)).body("deploymentId", equalTo(MockProvider.EXAMPLE_DEPLOYMENT_ID)).body("version", equalTo(MockProvider.EXAMPLE_CASE_DEFINITION_VERSION)).body("resource", equalTo(MockProvider.EXAMPLE_CASE_DEFINITION_RESOURCE_NAME)).body("tenantId", equalTo(MockProvider.EXAMPLE_TENANT_ID)).when().get(SINGLE_CASE_DEFINITION_BY_KEY_AND_TENANT_ID_URL);

            verify(caseDefinitionQueryMock).tenantIdIn(MockProvider.EXAMPLE_TENANT_ID);
            verify(repositoryServiceMock).getCaseDefinition(MockProvider.EXAMPLE_CASE_DEFINITION_ID);
        }
Example #19
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void updateHistoryTimeToLiveWithAuthenticatedTenant()
        public virtual void updateHistoryTimeToLiveWithAuthenticatedTenant()
        {
            identityService.setAuthentication("user", null, Arrays.asList(TENANT_ONE));

            repositoryService.updateCaseDefinitionHistoryTimeToLive(caseDefinitionId, 6);

            CaseDefinition definition = repositoryService.getCaseDefinition(caseDefinitionId);

            assertThat(definition.TenantId, @is(TENANT_ONE));
            assertThat(definition.HistoryTimeToLive, @is(6));
        }
Example #20
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testCreateCaseInstanceByCaseDefinitionKeyAndTenantId()
        public virtual void testCreateCaseInstanceByCaseDefinitionKeyAndTenantId()
        {
            CaseDefinition mockDefinition = MockProvider.mockCaseDefinition().tenantId(MockProvider.EXAMPLE_TENANT_ID).build();

            UpRuntimeData = mockDefinition;

            given().pathParam("key", MockProvider.EXAMPLE_CASE_DEFINITION_KEY).pathParam("tenant-id", MockProvider.EXAMPLE_TENANT_ID).contentType(POST_JSON_CONTENT_TYPE).body(EMPTY_JSON_OBJECT).then().expect().statusCode(Status.OK.StatusCode).body("id", equalTo(MockProvider.EXAMPLE_CASE_INSTANCE_ID)).when().post(CREATE_INSTANCE_BY_KEY_AND_TENANT_ID_URL);

            verify(caseDefinitionQueryMock).tenantIdIn(MockProvider.EXAMPLE_TENANT_ID);
            verify(caseServiceMock).withCaseDefinition(MockProvider.EXAMPLE_CASE_DEFINITION_ID);
            verify(caseInstanceBuilder).create();
        }
Example #21
0
        private void createCaseDefinitionMock()
        {
            IList <CaseDefinition> caseDefinitions    = new List <CaseDefinition>();
            CaseDefinition         mockCaseDefinition = MockProvider.createMockCaseDefinition();

            caseDefinitions.Add(mockCaseDefinition);

            CaseDefinitionQuery mockCaseDefinitionQuery = mock(typeof(CaseDefinitionQuery));

            when(mockCaseDefinitionQuery.list()).thenReturn(caseDefinitions);
            when(mockRepoService.createCaseDefinitionQuery()).thenReturn(mockCaseDefinitionQuery);
        }
Example #22
0
 public SwitchCaseModel(IdeCollection <IdeBaseItem> source) : base(source) //new
 {
     _case = new CaseDefinition
     {
         value = ""
     };
     BlockContainer = new BlockContainer();
     BlockContainer.OnContainerChanged += (a, b) =>
     {
         _case.linkList = BlockContainer.BuildTemplateBlockDef(b);
     };
 }
Example #23
0
        public WriteCursor(ICaseFrame caseFrame)
        {
            if (caseFrame == null)
            {
                throw new ArgumentNullException(nameof(caseFrame));
            }

            cursor         = caseFrame.GetCaseCursor();
            definition     = new CaseDefinitionBuilder(typeof(TCase), cursor.Schema).Build();
            idSetter       = GenerateIdSetter();
            solutionSetter = GenerateSolutionSetter();
            setters        = GenerateSetters();
        }
Example #24
0
            private bool TryMatchCase(T Value, out CaseDefinition Match)
            {
                Match = null;
                foreach (var c in cases)
                {
                    if (comparer(c.Value, Value))
                    {
                        Match = c;
                        break;
                    }
                }

                return(Match != null);
            }
Example #25
0
        public virtual CaseDefinitionResource getCaseDefinitionByKeyAndTenantId(string caseDefinitionKey, string tenantId)
        {
            CaseDefinition caseDefinition = ProcessEngine.RepositoryService.createCaseDefinitionQuery().caseDefinitionKey(caseDefinitionKey).tenantIdIn(tenantId).latestVersion().singleResult();

            if (caseDefinition == null)
            {
                string errorMessage = string.Format("No matching case definition with key: {0} and tenant-id: {1}", caseDefinitionKey, tenantId);
                throw new RestException(Status.NOT_FOUND, errorMessage);
            }
            else
            {
                return(getCaseDefinitionById(caseDefinition.Id));
            }
        }
Example #26
0
        public virtual void testQueryByLatestWithoutTenantId()
        {
            // deploy a second version without tenant id
            deployment(CMMN);

            CaseDefinitionQuery query = repositoryService.createCaseDefinitionQuery().caseDefinitionKey(CASE_DEFINITION_KEY).latestVersion().withoutTenantId();

            assertThat(query.count(), @is(1L));

            CaseDefinition cDefinition = query.singleResult();

            assertThat(cDefinition.TenantId, @is(nullValue()));
            assertThat(cDefinition.Version, @is(2));
        }
Example #27
0
 public ElseIfCaseModel(IdeCollection <IdeBaseItem> source) : base(source) //new
 {
     _case = new CaseDefinition
     {
         value = ""
     };
     Property       = (PropertyItemModel)CustomProperties.First();
     BlockContainer = new BlockContainer();
     BlockContainer.OnContainerChanged += (a, b) =>
     {
         _case.linkList = BlockContainer.BuildTemplateBlockDef(b);
     };
     Messenger.Default.Register <CustomPropertyChangedMessage>(this, action => CustomPropertyChanged(action));
 }
Example #28
0
        public virtual void testPropagateTenantIdToTaskOnCreateCaseInstance()
        {
            deploymentForTenant(TENANT_ID, CMMN_FILE);

            CaseDefinition caseDefinition = repositoryService.createCaseDefinitionQuery().singleResult();

            caseService.createCaseInstanceById(caseDefinition.Id);

            Task task = taskService.createTaskQuery().taskName("A HumanTask").singleResult();

            assertThat(task, @is(notNullValue()));
            // inherit the tenant id from case instance
            assertThat(task.TenantId, @is(TENANT_ID));
        }
Example #29
0
        public virtual void testPropagateTenantIdToVariableInstanceOnCreateCaseInstance()
        {
            deploymentForTenant(TENANT_ID, CMMN_FILE);

            VariableMap variables = Variables.putValue("var", "test");

            CaseDefinition caseDefinition = repositoryService.createCaseDefinitionQuery().singleResult();

            caseService.createCaseInstanceById(caseDefinition.Id, variables);

            VariableInstance variableInstance = runtimeService.createVariableInstanceQuery().singleResult();

            assertThat(variableInstance, @is(notNullValue()));
            // inherit the tenant id from case instance
            assertThat(variableInstance.TenantId, @is(TENANT_ID));
        }
Example #30
0
 public SwitchCaseModel(SwitchCaseModel switchcase, IdeCollection <IdeBaseItem> source) : base(source) //copy
 {
     _case = new CaseDefinition()
     {
         linkList    = new List <LinkDefinition.LinkWrapper>(),
         contains    = switchcase._case.contains,
         value       = switchcase._case.value,
         switchBreak = switchcase._case.switchBreak
     };
     BlockContainer = new BlockContainer(switchcase.BlockContainer);
     BlockContainer.OnContainerChanged += (a, b) =>
     {
         _case.linkList = BlockContainer.BuildTemplateBlockDef(b);
     };
     _case.linkList = BlockContainer.BuildTemplateBlockDef(null);
 }