public void ShouldBuildCompleteSourceElementTree()
        {
            var mappingFileName = TestUtils.PathToTestResource(@"XSDImporterTest\mapping\mapForceSourceElementTreeTests\BuildCompleteSourceElementTree\mapping.mfd");
            var mapForceMapping = LinqToXmlMapForceMappingImporter.ImportFromFiles(mappingFileName);

            var          xsdFileName  = TestUtils.PathToTestResource(@"XSDImporterTest\mapping\mapForceSourceElementTreeTests\BuildCompleteSourceElementTree\source.xsd");
            XmlSchemaSet xmlSchemaSet = new XmlSchemaSet();

            xmlSchemaSet.Add(XmlSchema.Read(XmlReader.Create(xsdFileName), null));

            var person              = new SourceItem("Person", null, XsdObjectType.Element, null);
            var personNameElement   = new SourceItem("Name", null, XsdObjectType.Element, null);
            var personNameAttribute = new SourceItem("Name", null, XsdObjectType.Attribute, null);
            var personHomeAddress   = new SourceItem("HomeAddress", null, XsdObjectType.Element, null);
            var addressTown         = new SourceItem("Town", null, XsdObjectType.Element, null);

            person.AddChild(personNameElement);
            person.AddChild(personHomeAddress);
            person.AddChild(personNameAttribute);
            personHomeAddress.AddChild(addressTown);

            var sourceElementTree = new MapForceSourceItemTree(mapForceMapping, xmlSchemaSet);

            AssertTreesAreEqual(person, sourceElementTree.RootSourceItem, string.Empty);
        }
 public void CreateExpectedSourceElementTree()
 {
     ccRepository       = CctsRepositoryFactory.CreateCctsRepository(new MappingTestRepository());
     ccLibrary          = ccRepository.GetCcLibraryByPath((Path)"test" / "bLibrary" / "CCLibrary");
     accParty           = ccLibrary.GetAccByName("Party");
     bccPartyName       = accParty.Bccs.First(bcc => bcc.Name == "Name");
     asccPartyResidence = accParty.Asccs.First(ascc => ascc.Name == "Residence");
     mapForceMapping    = LinqToXmlMapForceMappingImporter.ImportFromFiles(TestUtils.PathToTestResource(@"XSDImporterTest\mapping\TargetElementStoreTests\mapping.mfd"));
 }
Ejemplo n.º 3
0
        private SchemaMapping CreateSchemaMapping(string mappingFileName, string xsdFileName)
        {
            var mapForceMapping = LinqToXmlMapForceMappingImporter.ImportFromFiles(mappingFileName);

            XmlSchemaSet xmlSchemaSet = new XmlSchemaSet();

            xmlSchemaSet.Add(XmlSchema.Read(XmlReader.Create(xsdFileName), null));

            return(new SchemaMapping(mapForceMapping, xmlSchemaSet, ccl, cctsRepository));
        }
        public void TestCreateSourceElementTree()
        {
            var          xsdFileName  = TestUtils.PathToTestResource(@"XSDImporterTest\mapping\mapForceSourceElementTreeTests\CreateSourceElementTree\source.xsd");
            XmlSchemaSet xmlSchemaSet = new XmlSchemaSet();

            xmlSchemaSet.Add(XmlSchema.Read(XmlReader.Create(xsdFileName), null));

            var mapForceMapping = LinqToXmlMapForceMappingImporter.ImportFromFiles(TestUtils.PathToTestResource(@"XSDImporterTest\mapping\mapForceSourceElementTreeTests\CreateSourceElementTree\mapping.mfd"));

            var expectedAddress = new SourceItem("Address", null, XsdObjectType.Element, null);
            var expectedTown    = new SourceItem("Town", null, XsdObjectType.Element, null);

            expectedAddress.AddChild(expectedTown);

            AssertTreesAreEqual(expectedAddress, new MapForceSourceItemTree(mapForceMapping, xmlSchemaSet).RootSourceItem, string.Empty);
        }
        public void TestImportSchemaComponents()
        {
            string mappingFile = TestUtils.PathToTestResource(@"XSDImporterTest\mapping\MapForceMappingImporterTests\MapForceMappingImporter_ImportSchemaComponents_Test.mfd");

            MapForceMapping expectedMapping = new MapForceMapping(new List <SchemaComponent>
            {
                new SchemaComponent("CoreComponent_1.xsd", "{}Address", new Namespace[0],
                                    new Entry("Address", InputOutputKey.None, XsdObjectType.Element,
                                              new[]
                {
                    new Entry((string)"CityName", InputOutputKey.Input(null, CCCityNameKey), XsdObjectType.Element),
                })
                                    ),
                new SchemaComponent("Invoice.xsd", "{http://www.ebinterface.at/schema/3p0/}Address", new[] { new Namespace("http://www.ebinterface.at/schema/3p0/"), },
                                    new Entry("Address", InputOutputKey.None, XsdObjectType.Element,
                                              new[]
                {
                    new Entry((string)"Town", InputOutputKey.Output(null, EbInterfaceTownKey), XsdObjectType.Element),
                })),
            },
                                                                  new List <ConstantComponent>(),
                                                                  new List <FunctionComponent>(),
                                                                  new Graph(new[]
            {
                new Vertex(EbInterfaceTownKey, new[]
                {
                    new Edge("72603008", CCCityNameKey, null),
                }, null),
            }));

            MapForceMapping mapping = LinqToXmlMapForceMappingImporter.ImportFromFiles(mappingFile);

            Console.WriteLine("----------------------------------------------------");
            Console.WriteLine("Expected mapping: ");
            expectedMapping.PrettyPrint(Console.Out, "  ");
            Console.WriteLine("----------------------------------------------------");
            Console.WriteLine("Imported mapping: ");
            mapping.PrettyPrint(Console.Out, "  ");
            Console.WriteLine("----------------------------------------------------");

            Assert.AreEqual(expectedMapping, mapping);
        }
        public void ShouldBuildCompleteSourceItemTreeForUbl()
        {
            var mappingFileNames = new List <string> {
                "ubl2cll_1_1.mfd", "ubl2cll_2_1.mfd", "ubl2cll_3_1.mfd", "ubl2cll_4_1.mfd", "ubl2cll_5_1.mfd", "ubl2cll_6_1.mfd", "ubl2cll_7_1.mfd", "ubl2cll_8_1.mfd", "ubl2cll_9_1.mfd", "ubl2cll_10_1.mfd", "ubl2cll_11_1.mfd", "ubl2cll_12_1.mfd", "ubl2cll_13_1.mfd"
            };
            var mappingFiles = new List <string>();

            foreach (var mappingFile in mappingFileNames)
            {
                mappingFiles.Add(TestUtils.PathToTestResource(@"XSDImporterTest\mapping\MappingImporterTests\mapping_ubl_to_ccl\" + mappingFile));
            }

            var mapForceMapping = LinqToXmlMapForceMappingImporter.ImportFromFiles(mappingFiles.ToArray());

            XmlSchemaSet xmlSchemaSet = new XmlSchemaSet();

            xmlSchemaSet.Add(XmlSchema.Read(XmlReader.Create(TestUtils.PathToTestResource(@"XSDImporterTest\mapping\MappingImporterTests\mapping_ubl_to_ccl\invoice\maindoc\UBL-Invoice-2.0.xsd")), null));

            new MapForceSourceItemTree(mapForceMapping, xmlSchemaSet);
        }
        public void TestImportSchemaComponentsWithMappingFunctionSplit()
        {
            string mappingFile = TestUtils.PathToTestResource(@"XSDImporterTest\mapping\MapForceMappingImporterTests\mapping_simple_element_and_attributes_to_acc_with_mapping_function_split\mapping.mfd");

            const string ebInterfaceStreetKey = "72359800";
            const string ebInterfaceTownKey   = "72359696";

            const string cclBuildingNumberKey = "72345456";
            const string cclCityNameKey       = "72355472";
            const string cclStreetNameKey     = "72345296";

            const string splitFunctionNameConstantKey = "69602728";

            const string splitFunctionNameKey    = "72342768";
            const string splitFunctionInputKey   = "72455912";
            const string splitFunctionOutputKey1 = "72357424";
            const string splitFunctionOutputKey2 = "72357888";

            MapForceMapping expectedMapping = new MapForceMapping(new List <SchemaComponent>
            {
                new SchemaComponent("source.xsd", "{http://www.ebinterface.at/schema/3p0/}Address", new[] { new Namespace("http://www.ebinterface.at/schema/3p0/"), },
                                    new Entry("Address", InputOutputKey.None, XsdObjectType.Element,
                                              new[]
                {
                    new Entry((string)"Street", InputOutputKey.Output(null, ebInterfaceStreetKey), XsdObjectType.Element),
                    new Entry((string)"Town", InputOutputKey.Output(null, ebInterfaceTownKey), XsdObjectType.Element),
                })
                                    ),
                new SchemaComponent("target.xsd", "{ccts.org}Address", new[] { new Namespace("ccts.org"), },
                                    new Entry("Address", InputOutputKey.None, XsdObjectType.Element,
                                              new[]
                {
                    new Entry((string)"BuildingNumber", InputOutputKey.Input(null, cclBuildingNumberKey), XsdObjectType.Element),
                    new Entry((string)"CityName", InputOutputKey.Input(null, cclCityNameKey), XsdObjectType.Element),
                    new Entry((string)"StreetName", InputOutputKey.Input(null, cclStreetNameKey), XsdObjectType.Element),
                })),
            },
                                                                  new List <ConstantComponent>
            {
                new ConstantComponent("split1", InputOutputKey.Output(null, splitFunctionNameConstantKey))
            },
                                                                  new List <FunctionComponent>
            {
                new FunctionComponent("split", InputOutputKey.Input(null, splitFunctionNameKey), new [] { InputOutputKey.Input(null, splitFunctionInputKey) }, new [] { InputOutputKey.Output(null, splitFunctionOutputKey1), InputOutputKey.Output(null, splitFunctionOutputKey2) }),
            },
                                                                  new Graph(new[]
            {
                new Vertex(splitFunctionNameConstantKey, new[]
                {
                    new Edge("72352528", splitFunctionNameKey, null),
                }, null),
                new Vertex(splitFunctionOutputKey1, new[]
                {
                    new Edge("72363680", cclStreetNameKey, null),
                }, null),
                new Vertex(splitFunctionOutputKey2, new[]
                {
                    new Edge("72363864", cclBuildingNumberKey, null),
                }, null),
                new Vertex(ebInterfaceTownKey, new[]
                {
                    new Edge("72363312", cclCityNameKey, null),
                }, null),
                new Vertex(ebInterfaceStreetKey, new[]
                {
                    new Edge("72363496", splitFunctionInputKey, null),
                }, null),
            }));

            MapForceMapping mapping = LinqToXmlMapForceMappingImporter.ImportFromFiles(mappingFile);

            Console.WriteLine("----------------------------------------------------");
            Console.WriteLine("Expected mapping: ");
            expectedMapping.PrettyPrint(Console.Out, "  ");
            Console.WriteLine("----------------------------------------------------");
            Console.WriteLine("Imported mapping: ");
            mapping.PrettyPrint(Console.Out, "  ");
            Console.WriteLine("----------------------------------------------------");

            Assert.AreEqual(expectedMapping, mapping);
        }
Ejemplo n.º 8
0
        public void Diff_map_force_mappings_with_explicit_element_mappings()
        {
            #region Prepare Diff

            var repo = new Repository();
            repo.OpenFile(TestUtils.PathToTestResource(@"XSDImporterTest\mapping\MappingImporterTests\mapping_ubl_to_ccl\Repository-with-CDTs-and-CCs.eap"));

            var mappingFileNames = new List <string> {
                "ubl2cll_1_1.mfd", "ubl2cll_2_1.mfd", "ubl2cll_3_1.mfd", "ubl2cll_4_1.mfd", "ubl2cll_5_1.mfd", "ubl2cll_6_1.mfd", "ubl2cll_7_1.mfd", "ubl2cll_8_1.mfd", "ubl2cll_9_1.mfd", "ubl2cll_10_1.mfd", "ubl2cll_11_1.mfd", "ubl2cll_12_1.mfd", "ubl2cll_13_1.mfd"
            };
            var mappingFiles = new List <string>();

            foreach (var mappingFile in mappingFileNames)
            {
                mappingFiles.Add(TestUtils.PathToTestResource(@"XSDImporterTest\mapping\MappingImporterTests\mapping_ubl_to_ccl\" + mappingFile));
            }

            Console.Out.WriteLine("Starting mapping");
            var repository = CctsRepositoryFactory.CreateCctsRepository(repo);
            var ccLib      = repository.GetCcLibraries().FirstOrDefault();


            var mapForceMapping = LinqToXmlMapForceMappingImporter.ImportFromFiles(mappingFiles.ToArray());

            XmlSchemaSet xmlSchemaSet = new XmlSchemaSet();
            xmlSchemaSet.Add(XmlSchema.Read(XmlReader.Create(TestUtils.PathToTestResource(@"XSDImporterTest\mapping\MappingImporterTests\mapping_ubl_to_ccl\invoice\maindoc\UBL-Invoice-2.0.xsd")), null));

            #endregion

            SchemaMapping schemaMapping = new SchemaMapping(mapForceMapping, xmlSchemaSet, ccLib, repository);

            HashSet <string> edgeDescriptions = schemaMapping.EdgeDescriptions;

            TextWriter writer = new StreamWriter(TestUtils.PathToTestResource(@"XSDImporterTest\mapping\MappingImporterTests\mapping_ubl_to_ccl\") + "edgeDescriptions.txt");
            writer.WriteLine("#edges: " + edgeDescriptions.Count);
            foreach (string edgeDescription in edgeDescriptions)
            {
                writer.WriteLine(edgeDescription);
            }
            writer.Close();


            HashSet <string> mappingDescriptions = schemaMapping.MappingDescriptions;

            writer = new StreamWriter(TestUtils.PathToTestResource(@"XSDImporterTest\mapping\MappingImporterTests\mapping_ubl_to_ccl\") + "mappingDescriptions.txt");
            writer.WriteLine("#mappings: " + mappingDescriptions.Count);
            foreach (string mappingDescription in mappingDescriptions)
            {
                writer.WriteLine(mappingDescription);
            }
            writer.Close();


            writer = new StreamWriter(TestUtils.PathToTestResource(@"XSDImporterTest\mapping\MappingImporterTests\mapping_ubl_to_ccl\") + "missing_mappingDescriptions.txt");
            HashSet <string> missingMappingDescriptions = new HashSet <string>(edgeDescriptions);
            missingMappingDescriptions.ExceptWith(mappingDescriptions);

            foreach (string mappingDescription in missingMappingDescriptions)
            {
                writer.WriteLine(mappingDescription);
            }
            writer.Close();

            writer = new StreamWriter(TestUtils.PathToTestResource(@"XSDImporterTest\mapping\MappingImporterTests\mapping_ubl_to_ccl\") + "missing_edgeDescriptions.txt");
            HashSet <string> missingEdgeDescriptions = new HashSet <string>(mappingDescriptions);
            missingEdgeDescriptions.ExceptWith(edgeDescriptions);

            foreach (string mappingDescription in missingEdgeDescriptions)
            {
                writer.WriteLine(mappingDescription);
            }
            writer.Close();
        }