use of org.finos.legend.pure.m2.dsl.mapping.serialization.grammar.v1.OperationParser in project legend-pure by finos.
the class TestEmbeddedGrammar method testEmbeddedMappingWithIds.
@Test
public void testEmbeddedMappingWithIds() {
Loader.parseM3("import other::*;\n" + "import meta::pure::mapping::*;\n" + "\n" + "Class other::Person\n" + "{\n" + " name:String[1];\n" + " firm:Firm[1];\n" + " address:Address[0..1];\n" + "}\n" + "Class other::Firm\n" + "{\n" + " legalName:String[1];\n" + " employees:Person[1];\n" + " address:Address[1];\n" + "}\n" + "Class other::Address\n" + "{\n" + " line1:String[1];\n" + "}\n" + " function meta::pure::router::operations::union(o:OperationSetImplementation[1]):SetImplementation[*]\n" + " {\n" + " $o.parameters.setImplementation;\n" + " }\n" + "###Relational\n" + "Database mapping::db(\n" + " Table employeeFirmDenormTable\n" + " (\n" + " id INT PRIMARY KEY,\n" + " name VARCHAR(200),\n" + " firmId INT,\n" + " legalName VARCHAR(200),\n" + " address VARCHAR(200)\n" + " )\n" + " Table employeeFirmDenormTable2\n" + " (\n" + " id INT PRIMARY KEY,\n" + " name VARCHAR(200),\n" + " firmId INT,\n" + " legalName VARCHAR(200),\n" + " address VARCHAR(200)\n" + " )\n" + ")\n" + "###Mapping\n" + "import other::*;\n" + "import mapping::*;\n" + "Mapping mappingPackage::myMapping\n" + "(\n" + " Person[per1]: Relational\n" + " {\n" + " name : [db]employeeFirmDenormTable.name,\n" + " firm\n" + " (\n" + " ~primaryKey ([db]employeeFirmDenormTable.legalName)\n" + " legalName : [db]employeeFirmDenormTable.legalName,\n" + " address\n" + " (\n" + " line1: [db]employeeFirmDenormTable.address\n" + " )\n" + " ),\n" + " address\n" + " (\n" + " line1: [db]employeeFirmDenormTable.address\n" + " )\n" + " }\n" + " Person[per2]: Relational\n" + " {\n" + " name : [db]employeeFirmDenormTable2.name,\n" + " firm\n" + " (\n" + " ~primaryKey ([db]employeeFirmDenormTable2.legalName)\n" + " legalName : [db]employeeFirmDenormTable2.legalName,\n" + " address\n" + " (\n" + " line1: [db]employeeFirmDenormTable2.address\n" + " )\n" + " ),\n" + " address\n" + " (\n" + " line1: [db]employeeFirmDenormTable2.address\n" + " )\n" + " }\n" + " *Person : Operation\n" + " {\n" + " meta::pure::router::operations::union_OperationSetImplementation_1__SetImplementation_MANY_( per1, per2 ) \n" + " }\n" + ")\n", this.repository, new ParserLibrary(Lists.immutable.with(new M3AntlrParser(), new MappingParser(), new RelationalParser(), new OperationParser())), ValidationType.DEEP, VoidM3M4StateListener.VOID_M3_M4_STATE_LISTENER, this.context);
this.runtime.compile();
CoreInstance mapping = this.graphWalker.getMapping("mappingPackage::myMapping");
assertNotNull(mapping);
assertEquals(9, this.graphWalker.getClassMappings(mapping).size());
CoreInstance personMapping = this.graphWalker.getClassMappingById(mapping, "per1");
validatePersonMapping(personMapping, "employeeFirmDenormTable");
CoreInstance personMapping2 = this.graphWalker.getClassMappingById(mapping, "per2");
validatePersonMapping(personMapping2, "employeeFirmDenormTable2");
}
Aggregations