use of org.finos.legend.pure.m2.dsl.mapping.serialization.grammar.v1.EnumerationMappingParser in project legend-pure by finos.
the class TestSimpleGrammar method testReferredEnumMappingFromIncludes.
@Test
public void testReferredEnumMappingFromIncludes() {
final String pureCode = "Enum TradeType\n" + "{\n" + " BUY,\n" + " SELL\n" + "}\n" + "Class Trade\n" + "{\n" + " type: TradeType[1];\n" + "}\n" + "\n" + "Class EquityTrade extends Trade\n" + "{\n" + " product: String[1];\n" + " quantity: Integer[1];\n" + "}\n" + "###Relational\n" + "\n" + "Database tradeDB\n" + "(\n" + " Table eqTradeTable\n" + " (\n" + " id INT PRIMARY KEY,\n" + " product VARCHAR(200),\n" + " type VARCHAR(10),\n" + " qty INTEGER\n" + " )\n" + ")\n" + "###Mapping\n" + "\n" + "Mapping tradeMapping1\n" + "(\n" + " TradeType: EnumerationMapping TradeSource1\n" + " {\n" + " BUY: ['BUY', 'B'],\n" + " SELL: ['SELL', 'S']\n" + " }\n" + ")\n" + "\n" + "Mapping tradeMapping2\n" + "(\n" + " include tradeMapping1\n" + "\n" + " TradeType: EnumerationMapping TradeSource2\n" + " {\n" + " BUY: ['CREDIT'],\n" + " SELL: ['DEBIT']\n" + " }\n" + ")\n" + "\n" + "Mapping tradeMapping3\n" + "(\n" + " include tradeMapping2\n" + "\n" + " EquityTrade: Relational\n" + " {\n" + " scope( [tradeDB] default.eqTradeTable)\n" + " (\n" + " product: product,\n" + " quantity: qty,\n" + " type : EnumerationMapping TradeSource1 : type\n" + " )\n" + " }\n" + ")\n" + "\n";
Loader.parseM3(pureCode, this.repository, new ParserLibrary(Lists.immutable.with(new M3AntlrParser(), new MappingParser(), new RelationalParser(), new EnumerationMappingParser())), ValidationType.DEEP, VoidM3M4StateListener.VOID_M3_M4_STATE_LISTENER, this.context);
this.runtime.compile();
}
use of org.finos.legend.pure.m2.dsl.mapping.serialization.grammar.v1.EnumerationMappingParser in project legend-pure by finos.
the class TestSimpleGrammar method testValidDuplicateEnumMapping.
@Test
public void testValidDuplicateEnumMapping() {
final String pureCode = "Enum TradeType\n" + "{\n" + " BUY,\n" + " SELL\n" + "}\n" + "###Mapping\n" + "Mapping tradeMapping\n" + "(\n" + " TradeType: EnumerationMapping TradeSource1\n" + " {\n" + " BUY: ['BUY', 'B'],\n" + " SELL: ['SELL', 'S']\n" + " }\n" + " TradeType: EnumerationMapping TradeSource2\n" + " {\n" + " BUY: ['CREDIT'],\n" + " SELL: ['DEBIT']\n" + " }\n" + ")\n";
Loader.parseM3(pureCode, this.repository, new ParserLibrary(Lists.immutable.with(new M3AntlrParser(), new MappingParser(), new RelationalParser(), new EnumerationMappingParser())), ValidationType.DEEP, VoidM3M4StateListener.VOID_M3_M4_STATE_LISTENER, this.context);
this.runtime.compile();
}
Aggregations