Beispiel #1
0
        public async Task TestNestedProjUsingObjectModel()
        {
            CdmCorpusDefinition corpus = TestHelper.GetLocalCorpus(testsSubpath, "TestNestedProjUsingObjectModel");

            corpus.Storage.Mount("local", new LocalAdapter(TestHelper.GetActualOutputFolderPath(testsSubpath, "TestNestedProjUsingObjectModel")));
            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 ExcludeAttributes operation
            CdmOperationExcludeAttributes excludeAttrsOp = corpus.MakeObject <CdmOperationExcludeAttributes>(CdmObjectType.OperationExcludeAttributesDef);

            excludeAttrsOp.ExcludeAttributes = new List <string>()
            {
                "id", "date"
            };
            projection.Operations.Add(excludeAttrsOp);

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

            projectionEntityRef.ExplicitReference = projection;

            // Create another projection that uses the previous projection as its source
            CdmProjection projection2 = corpus.MakeObject <CdmProjection>(CdmObjectType.ProjectionDef);

            projection2.Source = projectionEntityRef;

            // Create an ExcludeAttributes operation
            CdmOperationExcludeAttributes excludeAttrsOp2 = corpus.MakeObject <CdmOperationExcludeAttributes>(CdmObjectType.OperationExcludeAttributesDef);

            excludeAttrsOp2.ExcludeAttributes = new List <string>()
            {
                "value"
            };
            projection2.Operations.Add(excludeAttrsOp2);

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

            projectionEntityRef2.ExplicitReference = projection2;

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

            entityAttribute.Entity = projectionEntityRef2;
            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 ExcludeAttributes operations
            // Original set of attributes: ["id", "name", "value", "date"]
            // Excluded attributes: ["id", "date"], ["value"]
            Assert.AreEqual(1, resolvedEntity.Attributes.Count);
            Assert.AreEqual("name", (resolvedEntity.Attributes[0] as CdmTypeAttributeDefinition).Name);
        }
Beispiel #2
0
        /// <summary>
        /// This method runs the tests with a set expected attributes & attribute context values and validated the actual result
        /// </summary>
        /// <param name="testName"></param>
        /// <param name="sourceEntityName"></param>
        /// <param name="expectedContext_*">expected attribute context object - for each resolution option combination</param>
        /// <param name="expected_*">expected attribute object - for each resolution option combination</param>
        /// <returns></returns>
        protected static async Task RunTestWithValues(
            string testName,
            string sourceEntityName,

            AttributeContextExpectedValue expectedContext_default,
            AttributeContextExpectedValue expectedContext_normalized,
            AttributeContextExpectedValue expectedContext_referenceOnly,
            AttributeContextExpectedValue expectedContext_structured,
            AttributeContextExpectedValue expectedContext_normalized_structured,
            AttributeContextExpectedValue expectedContext_referenceOnly_normalized,
            AttributeContextExpectedValue expectedContext_referenceOnly_structured,
            AttributeContextExpectedValue expectedContext_referenceOnly_normalized_structured,

            List <AttributeExpectedValue> expected_default,
            List <AttributeExpectedValue> expected_normalized,
            List <AttributeExpectedValue> expected_referenceOnly,
            List <AttributeExpectedValue> expected_structured,
            List <AttributeExpectedValue> expected_normalized_structured,
            List <AttributeExpectedValue> expected_referenceOnly_normalized,
            List <AttributeExpectedValue> expected_referenceOnly_structured,
            List <AttributeExpectedValue> expected_referenceOnly_normalized_structured,
            bool updateExpectedOutput = false
            )
        {
            try
            {
                string testInputPath    = TestHelper.GetInputFolderPath(TestsSubpath, testName);
                string testActualPath   = TestHelper.GetActualOutputFolderPath(TestsSubpath, testName);
                string testExpectedPath = TestHelper.GetExpectedOutputFolderPath(TestsSubpath, testName);
                string corpusPath       = testInputPath.Substring(0, testInputPath.Length - "/Input".Length);
                testActualPath = Path.GetFullPath(testActualPath);

                CdmCorpusDefinition corpus = new CdmCorpusDefinition();
                corpus.SetEventCallback(new EventCallback {
                    Invoke = CommonDataModelLoader.ConsoleStatusReport
                }, CdmStatusLevel.Warning);
                corpus.Storage.Mount("local", new LocalAdapter(corpusPath));
                corpus.Storage.Mount("cdm", new LocalAdapter(SchemaDocsPath));
                corpus.Storage.DefaultNamespace = "local";

                string outFolderPath          = corpus.Storage.AdapterPathToCorpusPath(testActualPath) + "/"; // interesting 'bug'
                CdmFolderDefinition outFolder = await corpus.FetchObjectAsync <CdmFolderDefinition>(outFolderPath);

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

                Assert.IsTrue(srcEntityDef != null);

                var resOpt = new ResolveOptions
                {
                    WrtDoc     = srcEntityDef.InDocument,
                    Directives = new AttributeResolutionDirectiveSet(new HashSet <string> {
                    })
                };

                CdmEntityDefinition resolvedEntityDef = null;
                string outputEntityName     = string.Empty;
                string outputEntityFileName = string.Empty;
                string entityFileName       = string.Empty;


                if (expectedContext_default != null && expected_default != null)
                {
                    entityFileName       = "d";
                    resOpt.Directives    = new AttributeResolutionDirectiveSet(new HashSet <string> {
                    });
                    outputEntityName     = $"{sourceEntityName}_R_{entityFileName}";
                    outputEntityFileName = $"{outputEntityName}.cdm.json";
                    resolvedEntityDef    = await srcEntityDef.CreateResolvedEntityAsync(outputEntityName, resOpt, outFolder);
                    await SaveActualEntityAndValidateWithExpected(Path.Combine(testExpectedPath, outputEntityFileName), resolvedEntityDef, updateExpectedOutput);
                }

                if (expectedContext_normalized != null && expected_normalized != null)
                {
                    entityFileName    = "n";
                    resOpt.Directives = new AttributeResolutionDirectiveSet(new HashSet <string> {
                        "normalized"
                    });
                    outputEntityName     = $"{sourceEntityName}_R_{entityFileName}";
                    outputEntityFileName = $"{outputEntityName}.cdm.json";
                    resolvedEntityDef    = await srcEntityDef.CreateResolvedEntityAsync(outputEntityName, resOpt, outFolder);
                    await SaveActualEntityAndValidateWithExpected(Path.Combine(testExpectedPath, outputEntityFileName), resolvedEntityDef, updateExpectedOutput);
                }

                if (expectedContext_referenceOnly != null && expected_referenceOnly != null)
                {
                    entityFileName    = "ro";
                    resOpt.Directives = new AttributeResolutionDirectiveSet(new HashSet <string> {
                        "referenceOnly"
                    });
                    outputEntityName     = $"{sourceEntityName}_R_{entityFileName}";
                    outputEntityFileName = $"{outputEntityName}.cdm.json";
                    resolvedEntityDef    = await srcEntityDef.CreateResolvedEntityAsync(outputEntityName, resOpt, outFolder);
                    await SaveActualEntityAndValidateWithExpected(Path.Combine(testExpectedPath, outputEntityFileName), resolvedEntityDef, updateExpectedOutput);
                }

                if (expectedContext_structured != null && expected_structured != null)
                {
                    entityFileName    = "s";
                    resOpt.Directives = new AttributeResolutionDirectiveSet(new HashSet <string> {
                        "structured"
                    });
                    outputEntityName     = $"{sourceEntityName}_R_{entityFileName}";
                    outputEntityFileName = $"{outputEntityName}.cdm.json";
                    resolvedEntityDef    = await srcEntityDef.CreateResolvedEntityAsync(outputEntityName, resOpt, outFolder);
                    await SaveActualEntityAndValidateWithExpected(Path.Combine(testExpectedPath, outputEntityFileName), resolvedEntityDef, updateExpectedOutput);
                }

                if (expectedContext_normalized_structured != null && expected_normalized_structured != null)
                {
                    entityFileName    = "n_s";
                    resOpt.Directives = new AttributeResolutionDirectiveSet(new HashSet <string> {
                        "normalized", "structured"
                    });
                    outputEntityName     = $"{sourceEntityName}_R_{entityFileName}";
                    outputEntityFileName = $"{outputEntityName}.cdm.json";
                    resolvedEntityDef    = await srcEntityDef.CreateResolvedEntityAsync(outputEntityName, resOpt, outFolder);
                    await SaveActualEntityAndValidateWithExpected(Path.Combine(testExpectedPath, outputEntityFileName), resolvedEntityDef, updateExpectedOutput);
                }

                if (expectedContext_referenceOnly_normalized != null && expected_referenceOnly_normalized != null)
                {
                    entityFileName    = "ro_n";
                    resOpt.Directives = new AttributeResolutionDirectiveSet(new HashSet <string> {
                        "referenceOnly", "normalized"
                    });
                    outputEntityName     = $"{sourceEntityName}_R_{entityFileName}";
                    outputEntityFileName = $"{outputEntityName}.cdm.json";
                    resolvedEntityDef    = await srcEntityDef.CreateResolvedEntityAsync(outputEntityName, resOpt, outFolder);
                    await SaveActualEntityAndValidateWithExpected(Path.Combine(testExpectedPath, outputEntityFileName), resolvedEntityDef, updateExpectedOutput);
                }

                if (expectedContext_referenceOnly_structured != null && expected_referenceOnly_structured != null)
                {
                    entityFileName    = "ro_s";
                    resOpt.Directives = new AttributeResolutionDirectiveSet(new HashSet <string> {
                        "referenceOnly", "structured"
                    });
                    outputEntityName     = $"{sourceEntityName}_R_{entityFileName}";
                    outputEntityFileName = $"{outputEntityName}.cdm.json";
                    resolvedEntityDef    = await srcEntityDef.CreateResolvedEntityAsync(outputEntityName, resOpt, outFolder);
                    await SaveActualEntityAndValidateWithExpected(Path.Combine(testExpectedPath, outputEntityFileName), resolvedEntityDef, updateExpectedOutput);
                }

                if (expectedContext_referenceOnly_normalized_structured != null && expected_referenceOnly_normalized_structured != null)
                {
                    entityFileName    = "ro_n_s";
                    resOpt.Directives = new AttributeResolutionDirectiveSet(new HashSet <string> {
                        "referenceOnly", "normalized", "structured"
                    });
                    outputEntityName     = $"{sourceEntityName}_R_{entityFileName}";
                    outputEntityFileName = $"{outputEntityName}.cdm.json";
                    resolvedEntityDef    = await srcEntityDef.CreateResolvedEntityAsync(outputEntityName, resOpt, outFolder);
                    await SaveActualEntityAndValidateWithExpected(Path.Combine(testExpectedPath, outputEntityFileName), resolvedEntityDef, updateExpectedOutput);
                }
            }
            catch (Exception e)
            {
                Assert.Fail(e.Message);
            }
        }
        private static async Task RunTest(string testName, string sourceEntityName)
        {
            try
            {
                string testInputPath          = TestHelper.GetInputFolderPath(testsSubpath, testName);
                string testExpectedOutputPath = TestHelper.GetExpectedOutputFolderPath(testsSubpath, testName);
                string testActualOutputPath   = TestHelper.GetActualOutputFolderPath(testsSubpath, testName);

                CdmCorpusDefinition corpus = new CdmCorpusDefinition();
                corpus.SetEventCallback(new Utilities.EventCallback {
                    Invoke = CommonDataModelLoader.ConsoleStatusReport
                }, CdmStatusLevel.Warning);
                corpus.Storage.Mount("localInput", new LocalAdapter(testInputPath));
                corpus.Storage.Mount("localExpectedOutput", new LocalAdapter(testExpectedOutputPath));
                corpus.Storage.Mount("localActualOutput", new LocalAdapter(testActualOutputPath));
                corpus.Storage.Mount("cdm", new LocalAdapter(SchemaDocsPath));
                corpus.Storage.DefaultNamespace = "localInput";

                CdmEntityDefinition srcEntityDef = await corpus.FetchObjectAsync <CdmEntityDefinition>($"localInput:/{sourceEntityName}.cdm.json/{sourceEntityName}") as CdmEntityDefinition;

                Assert.IsTrue(srcEntityDef != null);

                var resOpt = new ResolveOptions
                {
                    WrtDoc     = srcEntityDef.InDocument,
                    Directives = new AttributeResolutionDirectiveSet(new HashSet <string> {
                    })
                };

                CdmFolderDefinition actualOutputFolder = await corpus.FetchObjectAsync <CdmFolderDefinition>("localActualOutput:/") as CdmFolderDefinition;

                CdmEntityDefinition resolvedEntityDef = null;
                string outputEntityFileName           = string.Empty;
                string entityFileName = string.Empty;

                entityFileName       = "default";
                resOpt.Directives    = new AttributeResolutionDirectiveSet(new HashSet <string> {
                });
                outputEntityFileName = $"{sourceEntityName}_Resolved_{entityFileName}.cdm.json";
                resolvedEntityDef    = await srcEntityDef.CreateResolvedEntityAsync(outputEntityFileName, resOpt, actualOutputFolder);

                if (await resolvedEntityDef.InDocument.SaveAsAsync(outputEntityFileName, false, new CopyOptions()))
                {
                    ValidateOutput(outputEntityFileName, testExpectedOutputPath, testActualOutputPath);
                }

                entityFileName    = "referenceOnly";
                resOpt.Directives = new AttributeResolutionDirectiveSet(new HashSet <string> {
                    "referenceOnly"
                });
                outputEntityFileName = $"{sourceEntityName}_Resolved_{entityFileName}.cdm.json";
                resolvedEntityDef    = await srcEntityDef.CreateResolvedEntityAsync(outputEntityFileName, resOpt, actualOutputFolder);

                if (await resolvedEntityDef.InDocument.SaveAsAsync(outputEntityFileName, false, new CopyOptions()))
                {
                    ValidateOutput(outputEntityFileName, testExpectedOutputPath, testActualOutputPath);
                }

                entityFileName    = "normalized";
                resOpt.Directives = new AttributeResolutionDirectiveSet(new HashSet <string> {
                    "normalized"
                });
                outputEntityFileName = $"{sourceEntityName}_Resolved_{entityFileName}.cdm.json";
                resolvedEntityDef    = await srcEntityDef.CreateResolvedEntityAsync(outputEntityFileName, resOpt, actualOutputFolder);

                if (await resolvedEntityDef.InDocument.SaveAsAsync(outputEntityFileName, false, new CopyOptions()))
                {
                    ValidateOutput(outputEntityFileName, testExpectedOutputPath, testActualOutputPath);
                }

                entityFileName    = "structured";
                resOpt.Directives = new AttributeResolutionDirectiveSet(new HashSet <string> {
                    "structured"
                });
                outputEntityFileName = $"{sourceEntityName}_Resolved_{entityFileName}.cdm.json";
                resolvedEntityDef    = await srcEntityDef.CreateResolvedEntityAsync(outputEntityFileName, resOpt, actualOutputFolder);

                if (await resolvedEntityDef.InDocument.SaveAsAsync(outputEntityFileName, false, new CopyOptions()))
                {
                    ValidateOutput(outputEntityFileName, testExpectedOutputPath, testActualOutputPath);
                }

                entityFileName    = "referenceOnly_normalized";
                resOpt.Directives = new AttributeResolutionDirectiveSet(new HashSet <string> {
                    "referenceOnly", "normalized"
                });
                outputEntityFileName = $"{sourceEntityName}_Resolved_{entityFileName}.cdm.json";
                resolvedEntityDef    = await srcEntityDef.CreateResolvedEntityAsync(outputEntityFileName, resOpt, actualOutputFolder);

                if (await resolvedEntityDef.InDocument.SaveAsAsync(outputEntityFileName, false, new CopyOptions()))
                {
                    ValidateOutput(outputEntityFileName, testExpectedOutputPath, testActualOutputPath);
                }

                entityFileName    = "referenceOnly_normalized";
                resOpt.Directives = new AttributeResolutionDirectiveSet(new HashSet <string> {
                    "referenceOnly", "normalized"
                });
                outputEntityFileName = $"{sourceEntityName}_Resolved_{entityFileName}.cdm.json";
                resolvedEntityDef    = await srcEntityDef.CreateResolvedEntityAsync(outputEntityFileName, resOpt, actualOutputFolder);

                if (await resolvedEntityDef.InDocument.SaveAsAsync(outputEntityFileName, false, new CopyOptions()))
                {
                    ValidateOutput(outputEntityFileName, testExpectedOutputPath, testActualOutputPath);
                }

                entityFileName    = "referenceOnly_structured";
                resOpt.Directives = new AttributeResolutionDirectiveSet(new HashSet <string> {
                    "referenceOnly", "structured"
                });
                outputEntityFileName = $"{sourceEntityName}_Resolved_{entityFileName}.cdm.json";
                resolvedEntityDef    = await srcEntityDef.CreateResolvedEntityAsync(outputEntityFileName, resOpt, actualOutputFolder);

                if (await resolvedEntityDef.InDocument.SaveAsAsync(outputEntityFileName, false, new CopyOptions()))
                {
                    ValidateOutput(outputEntityFileName, testExpectedOutputPath, testActualOutputPath);
                }

                entityFileName    = "normalized_structured";
                resOpt.Directives = new AttributeResolutionDirectiveSet(new HashSet <string> {
                    "normalized", "structured"
                });
                outputEntityFileName = $"{sourceEntityName}_Resolved_{entityFileName}.cdm.json";
                resolvedEntityDef    = await srcEntityDef.CreateResolvedEntityAsync(outputEntityFileName, resOpt, actualOutputFolder);

                if (await resolvedEntityDef.InDocument.SaveAsAsync(outputEntityFileName, false, new CopyOptions()))
                {
                    ValidateOutput(outputEntityFileName, testExpectedOutputPath, testActualOutputPath);
                }

                entityFileName    = "referenceOnly_normalized_structured";
                resOpt.Directives = new AttributeResolutionDirectiveSet(new HashSet <string> {
                    "referenceOnly", "normalized", "structured"
                });
                outputEntityFileName = $"{sourceEntityName}_Resolved_{entityFileName}.cdm.json";
                resolvedEntityDef    = await srcEntityDef.CreateResolvedEntityAsync(outputEntityFileName, resOpt, actualOutputFolder);

                if (await resolvedEntityDef.InDocument.SaveAsAsync(outputEntityFileName, false, new CopyOptions()))
                {
                    ValidateOutput(outputEntityFileName, testExpectedOutputPath, testActualOutputPath);
                }
            }
            catch (Exception e)
            {
                Assert.Fail(e.Message);
            }
        }
Beispiel #4
0
        public async Task TestConditionalProjUsingObjectModel()
        {
            CdmCorpusDefinition corpus = TestHelper.GetLocalCorpus(testsSubpath, "TestConditionalProjUsingObjectModel");

            corpus.Storage.Mount("local", new LocalAdapter(TestHelper.GetActualOutputFolderPath(testsSubpath, "TestConditionalProjUsingObjectModel")));
            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 'referenceOnly'
            CdmProjection projection = ProjectionTestUtils.CreateProjection(corpus, localRoot);

            projection.Condition = "referenceOnly==true";

            // Create an ExcludeAttributes operation
            CdmOperationExcludeAttributes excludeAttrsOp = corpus.MakeObject <CdmOperationExcludeAttributes>(CdmObjectType.OperationExcludeAttributesDef);

            excludeAttrsOp.ExcludeAttributes.Add("id");
            excludeAttrsOp.ExcludeAttributes.Add("date");
            projection.Operations.Add(excludeAttrsOp);

            // 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);

            resOpt.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 ExcludeAttributes operation
            // Original set of attributes: ["id", "name", "value", "date"]
            // Excluded attributes: ["id", "date"]
            Assert.AreEqual(2, resolvedEntityWithReferenceOnly.Attributes.Count);
            Assert.AreEqual("name", (resolvedEntityWithReferenceOnly.Attributes[0] as CdmTypeAttributeDefinition).Name);
            Assert.AreEqual("value", (resolvedEntityWithReferenceOnly.Attributes[1] 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 ExcludeAttributes operation
            // Original set of attributes: ["id", "name", "value", "date"]
            // Excluded attributes: none, condition was false
            Assert.AreEqual(4, resolvedEntityWithStructured.Attributes.Count);
            Assert.AreEqual("id", (resolvedEntityWithStructured.Attributes[0] as CdmTypeAttributeDefinition).Name);
            Assert.AreEqual("name", (resolvedEntityWithStructured.Attributes[1] as CdmTypeAttributeDefinition).Name);
            Assert.AreEqual("value", (resolvedEntityWithStructured.Attributes[2] as CdmTypeAttributeDefinition).Name);
            Assert.AreEqual("date", (resolvedEntityWithStructured.Attributes[3] as CdmTypeAttributeDefinition).Name);
        }
Beispiel #5
0
        public async Task TestResolvedAttributeLimit()
        {
            CdmCorpusDefinition corpus = TestHelper.GetLocalCorpus(testsSubpath, "TestResolvedAttributeLimit");

            CdmEntityDefinition mainEntity = await corpus.FetchObjectAsync <CdmEntityDefinition>("local:/mainEntity.cdm.json/mainEntity");

            ResolveOptions resOpt = new ResolveOptions {
                WrtDoc = mainEntity.InDocument, Directives = new AttributeResolutionDirectiveSet(new HashSet <string> {
                    "normalized", "referenceOnly"
                })
            };

            // if attribute limit is reached, entity should be null
            resOpt.ResolvedAttributeLimit = 4;
            var resEnt = await mainEntity.CreateResolvedEntityAsync($"{mainEntity.EntityName}_zeroAtts", resOpt);

            Assert.IsNull(resEnt);

            // when the attribute limit is set to null, there should not be a limit on the possible number of attributes
            resOpt.ResolvedAttributeLimit = null;
            resOpt.Directives             = new AttributeResolutionDirectiveSet(new HashSet <string> {
                "normalized", "referenceOnly"
            });
            var ras = mainEntity.FetchResolvedAttributes(resOpt);

            resEnt = await mainEntity.CreateResolvedEntityAsync($"{mainEntity.EntityName}_normalized_referenceOnly", resOpt);

            // there are 5 total attributes
            Assert.AreEqual(ras.ResolvedAttributeCount, 5);
            Assert.AreEqual(ras.Set.Count, 5);
            Assert.AreEqual(mainEntity.Attributes.Count, 3);
            // there are 2 attributes grouped in an entity attribute
            // and 2 attributes grouped in an attribute group
            Assert.AreEqual(((mainEntity.Attributes[2] as CdmAttributeGroupReference).ExplicitReference as CdmAttributeGroupDefinition).Members.Count, 2);

            // using the default limit number
            resOpt = new ResolveOptions {
                WrtDoc = mainEntity.InDocument, Directives = new AttributeResolutionDirectiveSet(new HashSet <string> {
                    "normalized", "referenceOnly"
                })
            };
            ras    = mainEntity.FetchResolvedAttributes(resOpt);
            resEnt = await mainEntity.CreateResolvedEntityAsync($"{mainEntity.EntityName}_normalized_referenceOnly", resOpt);

            // there are 5 total attributes
            Assert.AreEqual(ras.ResolvedAttributeCount, 5);
            Assert.AreEqual(ras.Set.Count, 5);
            Assert.AreEqual(mainEntity.Attributes.Count, 3);
            // there are 2 attributes grouped in an entity attribute
            // and 2 attributes grouped in an attribute group
            Assert.AreEqual(((mainEntity.Attributes[2] as CdmAttributeGroupReference).ExplicitReference as CdmAttributeGroupDefinition).Members.Count, 2);

            resOpt.Directives = new AttributeResolutionDirectiveSet(new HashSet <string> {
                "normalized", "structured"
            });
            ras    = mainEntity.FetchResolvedAttributes(resOpt);
            resEnt = await mainEntity.CreateResolvedEntityAsync($"{mainEntity.EntityName}_normalized_structured", resOpt);

            // there are 5 total attributes
            Assert.AreEqual(ras.ResolvedAttributeCount, 5);
            // the attribute count is different because one attribute is a group that contains two different attributes
            Assert.AreEqual(ras.Set.Count, 4);
            Assert.AreEqual(mainEntity.Attributes.Count, 3);
            // again there are 2 attributes grouped in an entity attribute
            // and 2 attributes grouped in an attribute group
            Assert.AreEqual(((mainEntity.Attributes[2] as CdmAttributeGroupReference).ExplicitReference as CdmAttributeGroupDefinition).Members.Count, 2);
        }
Beispiel #6
0
        private async Task CustomizeEntities(CdmCorpusDefinition cdmCorpus)
        {
            // Open the default manifest at the root, used later when done
            // This method turns relative corpus paths into absolute ones in case we are in some sub-folders and don't know it
            var manifest = await cdmCorpus.FetchObjectAsync <CdmManifestDefinition>("default.manifest.cdm.json");

            Console.WriteLine("Define new extension");

            // First we will make a new document right in the same folder as the manifest
            var docAbs = cdmCorpus.MakeObject <CdmDocumentDefinition>(CdmObjectType.DocumentDef, "MobileCareTeam.cdm.json");

            // Import the cdm description of the original so the symbols will resolve
            docAbs.Imports.Add("cdm:/core/applicationCommon/foundationCommon/crmCommon/accelerators/healthCare/electronicMedicalRecords/CareTeam.cdm.json", null);

            // We will make a new trait to identify things that are known to be temporary, used later
            // In theory this would be defined somewhere central so it can be shared
            var traitTemp = docAbs.Definitions.Add(CdmObjectType.TraitDef, "means.temporary") as CdmTraitDefinition;

            // Extends the standard 'means' base trait
            traitTemp.ExtendsTrait = cdmCorpus.MakeObject <CdmTraitReference>(CdmObjectType.TraitRef, "means", true);
            // Add a parameter for the expected duration in days
            var param = cdmCorpus.MakeObject <CdmParameterDefinition>(CdmObjectType.ParameterDef, "estimatedDays");

            // By not using "true" on the last arg, this becomes an real reference object in the json. go look at the difference from "means" when this is done
            param.DataTypeRef  = cdmCorpus.MakeObject <CdmDataTypeReference>(CdmObjectType.DataTypeRef, "integer");
            param.DefaultValue = "30";
            traitTemp.Parameters.Add(param);

            // Make an entity definition and add it to the list of definitions in the document.
            CdmEntityDefinition entAbs = docAbs.Definitions.Add(CdmObjectType.EntityDef, "MobileCareTeam") as CdmEntityDefinition;

            // This entity extends the standard
            // This function with 'true' will make a simple reference to the base
            entAbs.ExtendsEntity = cdmCorpus.MakeObject <CdmEntityReference>(CdmObjectType.EntityRef, "CareTeam", true);

            // and we will add an attribute
            CdmTypeAttributeDefinition attNew = cdmCorpus.MakeObject <CdmTypeAttributeDefinition>(CdmObjectType.TypeAttributeDef, "currentCity");

            // The attribute is a type is 'City" this is one of the predefined semantic types in meanings.cdm.json
            attNew.DataType    = cdmCorpus.MakeObject <CdmDataTypeReference>(CdmObjectType.DataTypeRef, "city", true);
            attNew.Description = "The current city where the mobile care team is working.";

            // also apply our fancy new 'temporary' trait. they stay in a city for 90 days on average
            CdmTraitReference tr = cdmCorpus.MakeObject <CdmTraitReference>(CdmObjectType.TraitRef, "means.temporary");

            tr.Arguments.Add("estimatedDays", "90");
            attNew.AppliedTraits.Add(tr);

            // Add attribute to the entity
            entAbs.Attributes.Add(attNew);

            // The entity abstract definition is done, add the document to the corpus in the root folder and then save that doc
            cdmCorpus.Storage.FetchRootFolder("local").Documents.Add(docAbs);

            // next step is to remove all of the guesswork out of decoding the entity shape by 'resolving' it to a relational by reference shape
            Console.WriteLine("Make a local 'resolved' copy");

            // Now resolve it
            // Made the entity and document have a different name to avoid conflicts in this folder
            var entFlat = await entAbs.CreateResolvedEntityAsync("LocalMobileCareTeam");

            // Now just add the pointer into our manifest.
            Console.WriteLine("Add to manifest");
            manifest.Entities.Add(entFlat);

            // This function will update all of the fileStatus times in the manifest
            // await manifest.RefreshAsync(null);

            // Save the manifest along with linked definition files.
            await manifest.SaveAsAsync("default-resolved.manifest.cdm.json", true);
        }
        public async Task TestConditionalProjUsingObjectModel()
        {
            string testName               = nameof(TestConditionalProjUsingObjectModel);
            CdmCorpusDefinition corpus    = TestHelper.GetLocalCorpus(testsSubpath, testName);
            CdmFolderDefinition localRoot = corpus.Storage.FetchRootFolder("local");

            corpus.Storage.Mount("traitGroup", new LocalAdapter(traitGroupFilePath));

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

            entity.InDocument.Imports.Add("traitGroup:/TraitGroup.cdm.json");

            // 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";
            projection.RunSequentially = true;

            // Create an AlterTraits operation
            CdmOperationAlterTraits alterTraitsOp_1 = corpus.MakeObject <CdmOperationAlterTraits>(CdmObjectType.OperationAlterTraitsDef);

            alterTraitsOp_1.TraitsToAdd = new List <CdmTraitReferenceBase>();
            alterTraitsOp_1.TraitsToAdd.Add(corpus.MakeRef <CdmTraitReference>(CdmObjectType.TraitRef, "means.TraitG100", true));
            alterTraitsOp_1.TraitsToAdd.Add(corpus.MakeRef <CdmTraitGroupReference>(CdmObjectType.TraitGroupRef, "JobTitleBase", true));
            alterTraitsOp_1.TraitsToRemove = new List <CdmTraitReferenceBase>();
            alterTraitsOp_1.TraitsToRemove.Add(corpus.MakeRef <CdmTraitReference>(CdmObjectType.TraitRef, "means.TraitG300", true));
            projection.Operations.Add(alterTraitsOp_1);

            CdmOperationAlterTraits alterTraitsOp_2 = corpus.MakeObject <CdmOperationAlterTraits>(CdmObjectType.OperationAlterTraitsDef);

            alterTraitsOp_2.TraitsToAdd = new List <CdmTraitReferenceBase>();
            var traitG4 = corpus.MakeRef <CdmTraitReference>(CdmObjectType.TraitRef, "means.TraitG4", true);

            traitG4.Arguments.Add("precision", "5");
            traitG4.Arguments.Add("scale", "15");
            alterTraitsOp_2.TraitsToAdd.Add(traitG4);
            alterTraitsOp_2.ApplyTo = new List <string>()
            {
                "name"
            };
            projection.Operations.Add(alterTraitsOp_2);

            // 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"
                })
            };
            CdmEntityDefinition resolvedEntityWithReferenceOnly = await entity.CreateResolvedEntityAsync($"Resolved_{entity.EntityName}.cdm.json", resOpt, localRoot);

            // Original set of attributes: ["name", "age", "address", "phoneNumber", "email"]
            // Condition not met, no traits are added
            Assert.AreEqual(4, resolvedEntityWithReferenceOnly.Attributes.Count);
            ValidateTrait((CdmTypeAttributeDefinition)resolvedEntityWithReferenceOnly.Attributes[0], "id", doesNotExist: true);
            ValidateTrait((CdmTypeAttributeDefinition)resolvedEntityWithReferenceOnly.Attributes[1], "name", doesNotExist: true);
            ValidateTrait((CdmTypeAttributeDefinition)resolvedEntityWithReferenceOnly.Attributes[2], "value", doesNotExist: true);
            ValidateTrait((CdmTypeAttributeDefinition)resolvedEntityWithReferenceOnly.Attributes[3], "date", doesNotExist: true);

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

            // Original set of attributes: ["name", "age", "address", "phoneNumber", "email"]
            // Condition met, new traits are added
            Assert.AreEqual(4, resolvedEntityWithStructured.Attributes.Count);
            ValidateTrait((CdmTypeAttributeDefinition)resolvedEntityWithStructured.Attributes[0], "id");
            ValidateTrait((CdmTypeAttributeDefinition)resolvedEntityWithStructured.Attributes[1], "name", true);
            ValidateTrait((CdmTypeAttributeDefinition)resolvedEntityWithStructured.Attributes[2], "value");
            ValidateTrait((CdmTypeAttributeDefinition)resolvedEntityWithStructured.Attributes[3], "date");
        }
Beispiel #8
0
        static async Task Main(string[] args)
        {
            // Make a corpus, the corpus is the collection of all documents and folders created or discovered while navigating objects and paths
            var cdmCorpus = new CdmCorpusDefinition();

            Console.WriteLine("Configure storage adapters");

            // Configure storage adapters to point at the target local manifest location and at the fake public standards
            string pathFromExeToExampleRoot = "../../../../../../";

            // Mount is as a local device.
            cdmCorpus.Storage.Mount("local", new LocalAdapter(pathFromExeToExampleRoot + "3-customize-entities"));
            cdmCorpus.Storage.DefaultNamespace = "local"; // local is our default. so any paths that start out navigating without a device tag will assume local

            // Mount it as the 'cdm' device, not the default so must use "cdm:/folder" to get there
            cdmCorpus.Storage.Mount("cdm", new LocalAdapter(pathFromExeToExampleRoot + "example-public-standards"));

            // Example how to mount to the ADLS.
            // cdmCorpus.Storage.Mount("adls",
            //    new ADLSAdapter(
            // "<ACCOUNT-NAME>.dfs.core.windows.net", // Hostname.
            // "/<FILESYSTEM-NAME>", // Root.
            // "72f988bf-86f1-41af-91ab-2d7cd011db47",  // Tenant ID.
            // "<CLIENT-ID>",  // Client ID.
            // "<CLIENT-SECRET>" // Client secret.
            // ));

            // Open the default manifest at the root, used later when done
            // This method turns relative corpus paths into absolute ones in case we are in some sub-folders and don't know it
            var manifest = await cdmCorpus.FetchObjectAsync <CdmManifestDefinition>("default.manifest.cdm.json");

            Console.WriteLine("Define new extension");

            // First we will make a new document right in the same folder as the manifest
            var docAbs = cdmCorpus.MakeObject <CdmDocumentDefinition>(CdmObjectType.DocumentDef, "MobileCareTeam.cdm.json");

            // Import the cdm description of the original so the symbols will resolve
            docAbs.Imports.Add("cdm:/core/applicationCommon/foundationCommon/crmCommon/accelerators/healthCare/electronicMedicalRecords/CareTeam.cdm.json", null);

            // We will make a new trait to identify things that are known to be temporary, used later
            // In theory this would be defined somewhere central so it can be shared
            var traitTemp = docAbs.Definitions.Add(CdmObjectType.TraitDef, "means.temporary") as CdmTraitDefinition;

            // Extends the standard 'means' base trait
            traitTemp.ExtendsTrait = cdmCorpus.MakeObject <CdmTraitReference>(CdmObjectType.TraitRef, "means", true);
            // Add a parameter for the expected duration in days
            var param = cdmCorpus.MakeObject <CdmParameterDefinition>(CdmObjectType.ParameterDef, "estimatedDays");

            // By not using "true" on the last arg, this becomes an real reference object in the json. go look at the difference from "means" when this is done
            param.DataTypeRef  = cdmCorpus.MakeObject <CdmDataTypeReference>(CdmObjectType.DataTypeRef, "integer");
            param.DefaultValue = "30";
            traitTemp.Parameters.Add(param);

            // Make an entity definition and add it to the list of definitions in the document.
            CdmEntityDefinition entAbs = docAbs.Definitions.Add(CdmObjectType.EntityDef, "MobileCareTeam") as CdmEntityDefinition;

            // This entity extends the standard
            // This function with 'true' will make a simple reference to the base
            entAbs.ExtendsEntity = cdmCorpus.MakeObject <CdmEntityReference>(CdmObjectType.EntityRef, "CareTeam", true);

            // and we will add an attribute
            CdmTypeAttributeDefinition attNew = cdmCorpus.MakeObject <CdmTypeAttributeDefinition>(CdmObjectType.TypeAttributeDef, "currentCity");

            // The attribute is a type is 'City" this is one of the predefined semantic types in meanings.cdm.json
            attNew.DataType    = cdmCorpus.MakeObject <CdmDataTypeReference>(CdmObjectType.DataTypeRef, "city", true);
            attNew.Description = "The current city where the mobile care team is working";

            // also apply our fancy new 'temporary' trait. they stay in a city for 90 days on average
            CdmTraitReference tr = cdmCorpus.MakeObject <CdmTraitReference>(CdmObjectType.TraitRef, "means.temporary");

            tr.Arguments.Add("estimatedDays", "90");
            attNew.AppliedTraits.Add(tr);

            // Add attribute to the entity
            entAbs.Attributes.Add(attNew);

            // The entity abstract definition is done, add the document to the corpus in the root folder and then save that doc
            cdmCorpus.Storage.FetchRootFolder("local").Documents.Add(docAbs);

            // next step is to remove all of the guesswork out of decoding the entity shape by 'resolving' it to a relational by reference shape
            Console.WriteLine("Make a local 'resolved' copy");

            // Now resolve it
            // Made the entity and document have a different name to avoid conflicts in this folder
            var entFlat = await entAbs.CreateResolvedEntityAsync("LocalMobileCareTeam");

            // Now just add the pointer into our manifest.
            Console.WriteLine("Add to manifest");
            manifest.Entities.Add(entFlat);

            // This function will update all of the fileStatus times in the manifest
            // await manifest.RefreshFileStatus();

            // Save the manifest along with linked definition files
            await manifest.SaveAsAsync("default-resolved.manifest.cdm.json", true);
        }
        public async Task TestConditionalProjUsingObjectModel()
        {
            string testName               = nameof(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 AddArtifactAttribute operation
            CdmOperationAddArtifactAttribute addArtifactAttributeOp = corpus.MakeObject <CdmOperationAddArtifactAttribute>(CdmObjectType.OperationAddArtifactAttributeDef);

            addArtifactAttributeOp.NewAttribute = corpus.MakeObject <CdmTypeAttributeDefinition>(CdmObjectType.TypeAttributeDef, "newName");
            ((CdmTypeAttributeDefinition)addArtifactAttributeOp.NewAttribute).DataType = corpus.MakeRef <CdmDataTypeReference>(CdmObjectType.DataTypeRef, "string", true);
            projection.Operations.Add(addArtifactAttributeOp);

            // 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);

            // 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);

            // Original set of attributes: ["id", "name", "value", "date"]
            // Condition met, keep attributes in flat list and add the new attribute "newName" all attributes at the end
            Assert.AreEqual(5, resolvedEntityWithStructured.Attributes.Count);
            Assert.AreEqual("id", (resolvedEntityWithStructured.Attributes[0] as CdmTypeAttributeDefinition).Name);
            Assert.AreEqual("name", (resolvedEntityWithStructured.Attributes[1] as CdmTypeAttributeDefinition).Name);
            Assert.AreEqual("value", (resolvedEntityWithStructured.Attributes[2] as CdmTypeAttributeDefinition).Name);
            Assert.AreEqual("date", (resolvedEntityWithStructured.Attributes[3] as CdmTypeAttributeDefinition).Name);
            Assert.AreEqual("newName", (resolvedEntityWithStructured.Attributes[4] as CdmTypeAttributeDefinition).Name);
        }
Beispiel #10
0
        public async Task TestConditionalProjUsingObjectModel()
        {
            string testName               = "TestConditionalProjUsingObjectModel";
            CdmCorpusDefinition corpus    = ProjectionTestUtils.GetCorpus(testName, testsSubpath);
            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 = this.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);
        }