public async Task TestCombineOpsProj()
        {
            string testName            = "TestCombineOpsProj";
            string entityName          = "NewPerson";
            CdmCorpusDefinition corpus = TestHelper.GetLocalCorpus(testsSubpath, testName);

            foreach (List <string> resOpt in resOptsCombinations)
            {
                await ProjectionTestUtils.LoadEntityForResolutionOptionAndSave(corpus, testName, testsSubpath, entityName, resOpt);
            }

            CdmEntityDefinition entity = await corpus.FetchObjectAsync <CdmEntityDefinition>($"local:/{entityName}.cdm.json/{entityName}");

            CdmEntityDefinition resolvedEntity = await ProjectionTestUtils.GetResolvedEntity(corpus, entity, new List <string> {
            });

            // Original set of attributes: ["name", "age", "address", "phoneNumber", "email"]
            // Included attributes: ["age", "phoneNumber"]
            CdmAttributeGroupDefinition attGroupDefinition = ProjectionTestUtils.ValidateAttributeGroup(resolvedEntity.Attributes, "PersonAttributeGroup", 3);

            Assert.AreEqual(5, attGroupDefinition.Members.Count);
            Assert.AreEqual("name", (attGroupDefinition.Members[0] as CdmTypeAttributeDefinition).Name);
            Assert.AreEqual("age", (attGroupDefinition.Members[1] as CdmTypeAttributeDefinition).Name);
            Assert.AreEqual("address", (attGroupDefinition.Members[2] as CdmTypeAttributeDefinition).Name);
            Assert.AreEqual("phoneNumber", (attGroupDefinition.Members[3] as CdmTypeAttributeDefinition).Name);
            Assert.AreEqual("email", (attGroupDefinition.Members[4] as CdmTypeAttributeDefinition).Name);

            // Check the attributes coming from the IncludeAttribute operation
            Assert.AreEqual("age", (resolvedEntity.Attributes[1] as CdmTypeAttributeDefinition).Name);
            Assert.AreEqual("phoneNumber", (resolvedEntity.Attributes[2] as CdmTypeAttributeDefinition).Name);
        }
        public async Task TestTypeAttributeProj()
        {
            string testName            = "TestTypeAttributeProj";
            string entityName          = "Person";
            CdmCorpusDefinition corpus = TestHelper.GetLocalCorpus(testsSubpath, testName);

            foreach (List <string> resOpt in resOptsCombinations)
            {
                await ProjectionTestUtils.LoadEntityForResolutionOptionAndSave(corpus, testName, testsSubpath, entityName, resOpt);
            }

            CdmEntityDefinition entity = await corpus.FetchObjectAsync <CdmEntityDefinition>($"local:/{entityName}.cdm.json/{entityName}");

            CdmEntityDefinition resolvedEntity = await ProjectionTestUtils.GetResolvedEntity(corpus, entity, new List <string> {
                "referenceOnly"
            });

            // Original set of attributes: ["name", "age", "address", "phoneNumber", "email"]
            // Add attribute group applied to "address"
            Assert.AreEqual(5, resolvedEntity.Attributes.Count);
            Assert.AreEqual("name", (resolvedEntity.Attributes[0] as CdmTypeAttributeDefinition).Name);
            Assert.AreEqual("age", (resolvedEntity.Attributes[1] as CdmTypeAttributeDefinition).Name);
            CdmAttributeGroupDefinition attGroupDefinition = ProjectionTestUtils.ValidateAttributeGroup(resolvedEntity.Attributes, "AddressAttributeGroup", 5, 2);

            Assert.AreEqual("address", (attGroupDefinition.Members[0] as CdmTypeAttributeDefinition).Name);
            Assert.AreEqual("phoneNumber", (resolvedEntity.Attributes[3] as CdmTypeAttributeDefinition).Name);
            Assert.AreEqual("email", (resolvedEntity.Attributes[4] as CdmTypeAttributeDefinition).Name);
        }
Esempio n. 3
0
        public async Task TestTypeAttribute()
        {
            string testName            = "TestTypeAttribute";
            string entityName          = "Person";
            CdmCorpusDefinition corpus = TestHelper.GetLocalCorpus(testsSubpath, testName);

            foreach (List <string> resOpt in resOptsCombinations)
            {
                await ProjectionTestUtils.LoadEntityForResolutionOptionAndSave(corpus, testName, testsSubpath, entityName, resOpt);
            }

            CdmEntityDefinition entity = await corpus.FetchObjectAsync <CdmEntityDefinition>($"local:/{entityName}.cdm.json/{entityName}");

            CdmEntityDefinition nonStructuredResolvedEntity = await ProjectionTestUtils.GetResolvedEntity(corpus, entity, new List <string> {
            });

            // Original set of attributes: [ "FavoriteTerms" ]
            // in non-structured form
            // addArtifactAttribute : { "Term key" , "insertAtTop": true }
            // Expand 1...2;
            // renameAttributes = { {m}_{o}_key, apply to "Term key" }
            // renameAttributes = { {m}_{o}_value, apply to "FavoriteTerms" }
            // alterTraits = { indicates.expansionInfo.mapKey(expansionName: "{a}", ordinal: "{o}") , apply to "Term key" , "argumentsContainWildcards" : true }
            // alterTraits = { has.expansionInfo.mapValue(expansionName: "{a}", ordinal: "{o}") , apply to "FavoriteTerms"  , "argumentsContainWildcards" : true }
            // addArtifactAttribute : number of favorite terms"
            // alterTraits = { indicates.expansionInfo.count(expansionName: "{a}") , apply to "number of favorite terms" , "argumentsContainWildcards" : true }
            Assert.AreEqual(5, nonStructuredResolvedEntity.Attributes.Count);
            ValidateAttributeTrait(nonStructuredResolvedEntity.Attributes[0] as CdmTypeAttributeDefinition, "Term key_1_key", 1, "FavoriteTerms", isKey: true);
            ValidateAttributeTrait(nonStructuredResolvedEntity.Attributes[1] as CdmTypeAttributeDefinition, "FavoriteTerms_1_value", 1, "FavoriteTerms");
            ValidateAttributeTrait(nonStructuredResolvedEntity.Attributes[2] as CdmTypeAttributeDefinition, "Term key_2_key", 2, "FavoriteTerms", isKey: true);
            ValidateAttributeTrait(nonStructuredResolvedEntity.Attributes[3] as CdmTypeAttributeDefinition, "FavoriteTerms_2_value", 2, "FavoriteTerms");
            Assert.AreEqual("number of favorite terms", (nonStructuredResolvedEntity.Attributes[4] as CdmTypeAttributeDefinition).Name);
            Assert.IsNotNull(nonStructuredResolvedEntity.Attributes[4].AppliedTraits.Item("indicates.expansionInfo.count"));
            Assert.AreEqual("FavoriteTerms", (nonStructuredResolvedEntity.Attributes[4].AppliedTraits.Item("indicates.expansionInfo.count") as CdmTraitReference).Arguments[0].Value);

            // Original set of attributes: [ "FavoriteTerms" ]
            // in structured form
            // alterTraits = { is.dataFormat.mapValue }
            // addArtifactAttribute : { "Favorite Terms Key" (with trait "is.dataFormat.mapKey")  , "insertAtTop": true }
            // addAttributeGroup: favorite Term Group
            // alterTraits = { is.dataFormat.map }
            CdmEntityDefinition structuredResolvedEntity = await ProjectionTestUtils.GetResolvedEntity(corpus, entity, new List <string> {
                "structured"
            });

            Assert.AreEqual(1, structuredResolvedEntity.Attributes.Count);
            CdmAttributeGroupDefinition attGroupDefinition = ProjectionTestUtils.ValidateAttributeGroup(structuredResolvedEntity.Attributes, "favorite Term Group");

            Assert.IsNotNull(attGroupDefinition.ExhibitsTraits.Item("is.dataFormat.map"));
            Assert.AreEqual("Favorite Terms Key", (attGroupDefinition.Members[0] as CdmTypeAttributeDefinition).Name);
            Assert.IsNotNull(attGroupDefinition.Members[0].AppliedTraits.Item("is.dataFormat.mapKey"));
            Assert.AreEqual("FavoriteTerms", (attGroupDefinition.Members[1] as CdmTypeAttributeDefinition).Name);
            Assert.IsNotNull(attGroupDefinition.Members[1].AppliedTraits.Item("is.dataFormat.mapValue"));
        }
Esempio n. 4
0
        public async Task TestEntityAttribute()
        {
            string testName            = "TestEntityAttribute";
            string entityName          = "ThreeMusketeers";
            CdmCorpusDefinition corpus = TestHelper.GetLocalCorpus(testsSubpath, testName);

            foreach (List <string> resOpt in resOptsCombinations)
            {
                await ProjectionTestUtils.LoadEntityForResolutionOptionAndSave(corpus, testName, testsSubpath, entityName, resOpt);
            }

            CdmEntityDefinition entity = await corpus.FetchObjectAsync <CdmEntityDefinition>($"local:/{entityName}.cdm.json/{entityName}");

            CdmEntityDefinition nonStructuredResolvedEntity = await ProjectionTestUtils.GetResolvedEntity(corpus, entity, new List <string> {
            });

            // Original set of attributes: ["name", "age", "address"]
            // in non-structured form
            // Expand 1...3;
            // renameFormat = {m}{o};
            // alterTraits = { has.expansionInfo.list(expansionName: "{a}", ordinal: "{o}", memberAttribute: "{mo}") , "argumentsContainWildcards" : true }
            // addArtifactAttribute : "personCount"
            // alterTraits = { indicates.expansionInfo.count(expansionName: "{a}") , apply to "personCount" , "argumentsContainWildcards" : true }
            Assert.AreEqual(10, nonStructuredResolvedEntity.Attributes.Count);
            ProjectionTestUtils.ValidateExpansionInfoTrait(nonStructuredResolvedEntity.Attributes[0] as CdmTypeAttributeDefinition, "name1", 1, "ThreePeople", "name");
            ProjectionTestUtils.ValidateExpansionInfoTrait(nonStructuredResolvedEntity.Attributes[1] as CdmTypeAttributeDefinition, "age1", 1, "ThreePeople", "age");
            ProjectionTestUtils.ValidateExpansionInfoTrait(nonStructuredResolvedEntity.Attributes[2] as CdmTypeAttributeDefinition, "address1", 1, "ThreePeople", "address");
            ProjectionTestUtils.ValidateExpansionInfoTrait(nonStructuredResolvedEntity.Attributes[3] as CdmTypeAttributeDefinition, "name2", 2, "ThreePeople", "name");
            ProjectionTestUtils.ValidateExpansionInfoTrait(nonStructuredResolvedEntity.Attributes[4] as CdmTypeAttributeDefinition, "age2", 2, "ThreePeople", "age");
            ProjectionTestUtils.ValidateExpansionInfoTrait(nonStructuredResolvedEntity.Attributes[5] as CdmTypeAttributeDefinition, "address2", 2, "ThreePeople", "address");
            ProjectionTestUtils.ValidateExpansionInfoTrait(nonStructuredResolvedEntity.Attributes[6] as CdmTypeAttributeDefinition, "name3", 3, "ThreePeople", "name");
            ProjectionTestUtils.ValidateExpansionInfoTrait(nonStructuredResolvedEntity.Attributes[7] as CdmTypeAttributeDefinition, "age3", 3, "ThreePeople", "age");
            ProjectionTestUtils.ValidateExpansionInfoTrait(nonStructuredResolvedEntity.Attributes[8] as CdmTypeAttributeDefinition, "address3", 3, "ThreePeople", "address");
            Assert.AreEqual("personCount", (nonStructuredResolvedEntity.Attributes[9] as CdmTypeAttributeDefinition).Name);
            Assert.AreEqual("indicates.expansionInfo.count", nonStructuredResolvedEntity.Attributes[9].AppliedTraits[1].NamedReference);
            Assert.AreEqual("ThreePeople", (nonStructuredResolvedEntity.Attributes[9].AppliedTraits[1] as CdmTraitReference).Arguments[0].Value);

            // Original set of attributes: ["name", "age", "address"]
            // in structured form
            // alterTraits = { is.dataFormat.list }
            // addAttributeGroup: favoriteMusketeers
            CdmEntityDefinition structuredResolvedEntity = await ProjectionTestUtils.GetResolvedEntity(corpus, entity, new List <string> {
                "structured"
            });

            Assert.AreEqual(1, structuredResolvedEntity.Attributes.Count);
            CdmAttributeGroupDefinition attGroupDefinition = ProjectionTestUtils.ValidateAttributeGroup(structuredResolvedEntity.Attributes, "favoriteMusketeers");

            Assert.IsNotNull(attGroupDefinition.ExhibitsTraits.Item("is.dataFormat.list"));
        }
        public async Task TestEntityAttributeProjUsingObjectModel()
        {
            string testName               = "TestEntityAttributeProjUsingObjectModel";
            CdmCorpusDefinition corpus    = TestHelper.GetLocalCorpus(testsSubpath, testName);
            CdmFolderDefinition localRoot = corpus.Storage.FetchRootFolder("local");

            // Create an entity
            CdmEntityDefinition entity = ProjectionTestUtils.CreateEntity(corpus, localRoot);

            // Create a projection
            CdmProjection projection = ProjectionTestUtils.CreateProjection(corpus, localRoot);

            // Create an AddAttributeGroup operation
            CdmOperationAddAttributeGroup addAttGroupOp = corpus.MakeObject <CdmOperationAddAttributeGroup>(CdmObjectType.OperationAddAttributeGroupDef);

            addAttGroupOp.AttributeGroupName = "PersonAttributeGroup";
            projection.Operations.Add(addAttGroupOp);

            // Create an entity reference to hold this projection
            CdmEntityReference projectionEntityRef = corpus.MakeObject <CdmEntityReference>(CdmObjectType.EntityRef, null);

            projectionEntityRef.ExplicitReference = projection;

            // Create an entity attribute that contains this projection and add this to the entity
            CdmEntityAttributeDefinition entityAttribute = corpus.MakeObject <CdmEntityAttributeDefinition>(CdmObjectType.EntityAttributeDef, "TestEntityAttribute");

            entityAttribute.Entity = projectionEntityRef;
            entity.Attributes.Add(entityAttribute);

            // Resolve the entity.
            CdmEntityDefinition resolvedEntity = await entity.CreateResolvedEntityAsync($"Resolved_{entity.EntityName}.cdm.json", null, localRoot);

            // Verify correctness of the resolved attributes after running the AddAttributeGroup operation
            // Original set of attributes: ["id", "name", "value", "date"]
            CdmAttributeGroupDefinition attGroupDefinition = ProjectionTestUtils.ValidateAttributeGroup(resolvedEntity.Attributes, "PersonAttributeGroup");

            Assert.AreEqual(4, attGroupDefinition.Members.Count);
            Assert.AreEqual("id", (attGroupDefinition.Members[0] as CdmTypeAttributeDefinition).Name);
            Assert.AreEqual("name", (attGroupDefinition.Members[1] as CdmTypeAttributeDefinition).Name);
            Assert.AreEqual("value", (attGroupDefinition.Members[2] as CdmTypeAttributeDefinition).Name);
            Assert.AreEqual("date", (attGroupDefinition.Members[3] as CdmTypeAttributeDefinition).Name);
        }
        public async Task TestMultipleOpProj()
        {
            string testName            = "TestMultipleOpProj";
            string entityName          = "NewPerson";
            CdmCorpusDefinition corpus = TestHelper.GetLocalCorpus(testsSubpath, testName);

            foreach (List <string> resOpt in resOptsCombinations)
            {
                await ProjectionTestUtils.LoadEntityForResolutionOptionAndSave(corpus, testName, testsSubpath, entityName, resOpt);
            }

            CdmEntityDefinition entity = await corpus.FetchObjectAsync <CdmEntityDefinition>($"local:/{entityName}.cdm.json/{entityName}");

            CdmEntityDefinition resolvedEntity = await ProjectionTestUtils.GetResolvedEntity(corpus, entity, new List <string> {
            });

            // Original set of attributes: ["name", "age", "address", "phoneNumber", "email"]
            // This will result in two attribute groups with the same set of attributes being generated
            CdmAttributeGroupDefinition attGroup1 = ProjectionTestUtils.ValidateAttributeGroup(resolvedEntity.Attributes, "PersonAttributeGroup", 2);

            Assert.AreEqual(5, attGroup1.Members.Count);
            Assert.AreEqual("name", (attGroup1.Members[0] as CdmTypeAttributeDefinition).Name);
            Assert.AreEqual("age", (attGroup1.Members[1] as CdmTypeAttributeDefinition).Name);
            Assert.AreEqual("address", (attGroup1.Members[2] as CdmTypeAttributeDefinition).Name);
            Assert.AreEqual("phoneNumber", (attGroup1.Members[3] as CdmTypeAttributeDefinition).Name);
            Assert.AreEqual("email", (attGroup1.Members[4] as CdmTypeAttributeDefinition).Name);

            CdmAttributeGroupDefinition attGroup2 = ProjectionTestUtils.ValidateAttributeGroup(resolvedEntity.Attributes, "SecondAttributeGroup", 2, 1);

            Assert.AreEqual(5, attGroup2.Members.Count);
            Assert.AreEqual("name", (attGroup2.Members[0] as CdmTypeAttributeDefinition).Name);
            Assert.AreEqual("age", (attGroup2.Members[1] as CdmTypeAttributeDefinition).Name);
            Assert.AreEqual("address", (attGroup2.Members[2] as CdmTypeAttributeDefinition).Name);
            Assert.AreEqual("phoneNumber", (attGroup2.Members[3] as CdmTypeAttributeDefinition).Name);
            Assert.AreEqual("email", (attGroup2.Members[4] as CdmTypeAttributeDefinition).Name);
        }
        public async Task TestConditionalProjUsingObjectModel()
        {
            string testName               = "TestConditionalProjUsingObjectModel";
            CdmCorpusDefinition corpus    = TestHelper.GetLocalCorpus(testsSubpath, testName);
            CdmFolderDefinition localRoot = corpus.Storage.FetchRootFolder("local");

            // Create an entity.
            CdmEntityDefinition entity = ProjectionTestUtils.CreateEntity(corpus, localRoot);

            // Create a projection with a condition that states the operation should only execute when the resolution directive is 'structured'.
            CdmProjection projection = ProjectionTestUtils.CreateProjection(corpus, localRoot);

            projection.Condition = "structured==true";

            // Create an AddAttributeGroup operation
            CdmOperationAddAttributeGroup addAttGroupOp = corpus.MakeObject <CdmOperationAddAttributeGroup>(CdmObjectType.OperationAddAttributeGroupDef);

            addAttGroupOp.AttributeGroupName = "PersonAttributeGroup";
            projection.Operations.Add(addAttGroupOp);

            // Create an entity reference to hold this projection.
            CdmEntityReference projectionEntityRef = corpus.MakeObject <CdmEntityReference>(CdmObjectType.EntityRef, null);

            projectionEntityRef.ExplicitReference = projection;

            // Create an entity attribute that contains this projection and add this to the entity.
            CdmEntityAttributeDefinition entityAttribute = corpus.MakeObject <CdmEntityAttributeDefinition>(CdmObjectType.EntityAttributeDef, "TestEntityAttribute");

            entityAttribute.Entity = projectionEntityRef;
            entity.Attributes.Add(entityAttribute);

            // Create resolution options with the 'referenceOnly' directive.
            ResolveOptions resOpt = new ResolveOptions(entity.InDocument)
            {
                Directives = new AttributeResolutionDirectiveSet(new HashSet <string> {
                    "referenceOnly"
                })
            };

            // Resolve the entity with 'referenceOnly'
            CdmEntityDefinition resolvedEntityWithReferenceOnly = await entity.CreateResolvedEntityAsync($"Resolved_{entity.EntityName}.cdm.json", resOpt, localRoot);

            // Verify correctness of the resolved attributes after running the AddAttributeGroup operation
            // Original set of attributes: ["id", "name", "value", "date"]
            // Condition not met, keep attributes in flat list
            Assert.AreEqual(4, resolvedEntityWithReferenceOnly.Attributes.Count);
            Assert.AreEqual("id", (resolvedEntityWithReferenceOnly.Attributes[0] as CdmTypeAttributeDefinition).Name);
            Assert.AreEqual("name", (resolvedEntityWithReferenceOnly.Attributes[1] as CdmTypeAttributeDefinition).Name);
            Assert.AreEqual("value", (resolvedEntityWithReferenceOnly.Attributes[2] as CdmTypeAttributeDefinition).Name);
            Assert.AreEqual("date", (resolvedEntityWithReferenceOnly.Attributes[3] as CdmTypeAttributeDefinition).Name);

            // Now resolve the entity with the 'structured' directive
            resOpt.Directives = new AttributeResolutionDirectiveSet(new HashSet <string> {
                "structured"
            });
            CdmEntityDefinition resolvedEntityWithStructured = await entity.CreateResolvedEntityAsync($"Resolved_{entity.EntityName}.cdm.json", resOpt, localRoot);

            // Verify correctness of the resolved attributes after running the AddAttributeGroup operation
            // Original set of attributes: ["id", "name", "value", "date"]
            // Condition met, put all attributes in an attribute group
            CdmAttributeGroupDefinition attGroupDefinition = ProjectionTestUtils.ValidateAttributeGroup(resolvedEntityWithStructured.Attributes, "PersonAttributeGroup");

            Assert.AreEqual(4, attGroupDefinition.Members.Count);
            Assert.AreEqual("id", (attGroupDefinition.Members[0] as CdmTypeAttributeDefinition).Name);
            Assert.AreEqual("name", (attGroupDefinition.Members[1] as CdmTypeAttributeDefinition).Name);
            Assert.AreEqual("value", (attGroupDefinition.Members[2] as CdmTypeAttributeDefinition).Name);
            Assert.AreEqual("date", (attGroupDefinition.Members[3] as CdmTypeAttributeDefinition).Name);
        }
Esempio n. 8
0
        public async Task TestEntityAttribute()
        {
            string testName            = "TestEntityAttribute";
            string entityName          = "ThreeMusketeers";
            CdmCorpusDefinition corpus = TestHelper.GetLocalCorpus(testsSubpath, testName);

            foreach (List <string> resOpt in resOptsCombinations)
            {
                await ProjectionTestUtils.LoadEntityForResolutionOptionAndSave(corpus, testName, testsSubpath, entityName, resOpt);
            }

            CdmEntityDefinition entity = await corpus.FetchObjectAsync <CdmEntityDefinition>($"local:/{entityName}.cdm.json/{entityName}");

            CdmEntityDefinition nonStructuredResolvedEntity = await ProjectionTestUtils.GetResolvedEntity(corpus, entity, new List <string> {
            });

            // Original set of attributes: ["name", "age", "address"]
            // in non-structured form
            // addArtifactAttribute : { "key" , "insertAtTop": true }
            // Expand 1...3;
            // renameAttributes = { {a}_{o}_key, apply to "key" }
            // renameAttributes = { {a}_{m}_{o}_value, apply to "name", "age", "address" }
            // alterTraits = { indicates.expansionInfo.mapKey(expansionName: "{a}", ordinal: "{o}") , apply to "key" , "argumentsContainWildcards" : true }
            // alterTraits = { has.expansionInfo.mapValue(expansionName: "{a}", ordinal: "{o}", memberAttribute: "{mo}") , apply to "name", "age", "address"  , "argumentsContainWildcards" : true }
            // addArtifactAttribute : "personCount"
            // alterTraits = { indicates.expansionInfo.count(expansionName: "{a}") , apply to "personCount" , "argumentsContainWildcards" : true }
            Assert.AreEqual(13, nonStructuredResolvedEntity.Attributes.Count);
            ValidateAttributeTrait(nonStructuredResolvedEntity.Attributes[0] as CdmTypeAttributeDefinition, "key_1_key", 1, "ThreePeople", isKey: true);
            ValidateAttributeTrait(nonStructuredResolvedEntity.Attributes[1] as CdmTypeAttributeDefinition, "ThreePeople_name_1_value", 1, "ThreePeople", "name");
            ValidateAttributeTrait(nonStructuredResolvedEntity.Attributes[2] as CdmTypeAttributeDefinition, "ThreePeople_age_1_value", 1, "ThreePeople", "age");
            ValidateAttributeTrait(nonStructuredResolvedEntity.Attributes[3] as CdmTypeAttributeDefinition, "ThreePeople_address_1_value", 1, "ThreePeople", "address");
            ValidateAttributeTrait(nonStructuredResolvedEntity.Attributes[4] as CdmTypeAttributeDefinition, "key_2_key", 2, "ThreePeople", isKey: true);
            ValidateAttributeTrait(nonStructuredResolvedEntity.Attributes[5] as CdmTypeAttributeDefinition, "ThreePeople_name_2_value", 2, "ThreePeople", "name");
            ValidateAttributeTrait(nonStructuredResolvedEntity.Attributes[6] as CdmTypeAttributeDefinition, "ThreePeople_age_2_value", 2, "ThreePeople", "age");
            ValidateAttributeTrait(nonStructuredResolvedEntity.Attributes[7] as CdmTypeAttributeDefinition, "ThreePeople_address_2_value", 2, "ThreePeople", "address");
            ValidateAttributeTrait(nonStructuredResolvedEntity.Attributes[8] as CdmTypeAttributeDefinition, "key_3_key", 3, "ThreePeople", isKey: true);
            ValidateAttributeTrait(nonStructuredResolvedEntity.Attributes[9] as CdmTypeAttributeDefinition, "ThreePeople_name_3_value", 3, "ThreePeople", "name");
            ValidateAttributeTrait(nonStructuredResolvedEntity.Attributes[10] as CdmTypeAttributeDefinition, "ThreePeople_age_3_value", 3, "ThreePeople", "age");
            ValidateAttributeTrait(nonStructuredResolvedEntity.Attributes[11] as CdmTypeAttributeDefinition, "ThreePeople_address_3_value", 3, "ThreePeople", "address");
            Assert.AreEqual("personCount", (nonStructuredResolvedEntity.Attributes[12] as CdmTypeAttributeDefinition).Name);
            Assert.IsNotNull(nonStructuredResolvedEntity.Attributes[12].AppliedTraits.Item("indicates.expansionInfo.count"));
            Assert.AreEqual("ThreePeople", (nonStructuredResolvedEntity.Attributes[12].AppliedTraits.Item("indicates.expansionInfo.count") as CdmTraitReference).Arguments[0].Value);

            // Original set of attributes: ["name", "age", "address"]
            // in structured form
            // addAttributeGroup: favorite people
            // alterTraits = { is.dataFormat.mapValue }
            // addArtifactAttribute : { "favorite People Key" (with trait "is.dataFormat.mapKey") , "insertAtTop": true }
            // addAttributeGroup: favorite People Group
            // alterTraits = { is.dataFormat.map }
            CdmEntityDefinition structuredResolvedEntity = await ProjectionTestUtils.GetResolvedEntity(corpus, entity, new List <string> {
                "structured"
            });

            Assert.AreEqual(1, structuredResolvedEntity.Attributes.Count);
            CdmAttributeGroupDefinition attGroupDefinition = ProjectionTestUtils.ValidateAttributeGroup(structuredResolvedEntity.Attributes, "favorite People Group");

            Assert.IsNotNull(attGroupDefinition.ExhibitsTraits.Item("is.dataFormat.map"));
            Assert.AreEqual("favorite People Key", (attGroupDefinition.Members[0] as CdmTypeAttributeDefinition).Name);
            Assert.IsNotNull(attGroupDefinition.Members[0].AppliedTraits.Item("is.dataFormat.mapKey"));
            Assert.AreEqual(CdmObjectType.AttributeGroupRef, attGroupDefinition.Members[1].ObjectType);
            CdmAttributeGroupReference innerAttGroupRef = attGroupDefinition.Members[1] as CdmAttributeGroupReference;

            Assert.IsNotNull(innerAttGroupRef.ExplicitReference);
            CdmAttributeGroupDefinition innerAttGroupDefinition = innerAttGroupRef.ExplicitReference as CdmAttributeGroupDefinition;

            Assert.AreEqual("favorite people", innerAttGroupDefinition.AttributeGroupName);
            Assert.IsNotNull(innerAttGroupDefinition.ExhibitsTraits.Item("is.dataFormat.mapValue"));
        }