Search in sources :

Example 1 with RuntimeTestScriptBuilder

use of org.finos.legend.pure.m3.RuntimeTestScriptBuilder in project legend-pure by finos.

the class TestMapping method testAddRemoveMappingWithInclude.

@Test
public void testAddRemoveMappingWithInclude() throws Exception {
    RuntimeVerifier.verifyOperationIsStable(new RuntimeTestScriptBuilder().createInMemorySources(Maps.immutable.with(SOURCE_ID, CLASS_PERSON_RELATIONAL_DATABASE, MAPPING_SOURCE_ID, MAPPING_CLASS_MAPPING_PERSON_RELATIONAL, USER_ID, MAPPING_MAPPING_WITH_INCLUDE)).compile(), new RuntimeTestScriptBuilder().deleteSources(Lists.fixedSize.of(USER_ID)).createInMemorySource(USER_ID, MAPPING_MAPPING_WITH_INCLUDE).compile(), this.runtime, this.functionExecution, Lists.fixedSize.<FunctionExecutionStateVerifier>of());
    this.setUpRuntime();
}
Also used : RuntimeTestScriptBuilder(org.finos.legend.pure.m3.RuntimeTestScriptBuilder) Test(org.junit.Test)

Example 2 with RuntimeTestScriptBuilder

use of org.finos.legend.pure.m3.RuntimeTestScriptBuilder in project legend-pure by finos.

the class TestPureRuntimeClassMapping method testMilestoningMappingUnbindStability.

@Test
public void testMilestoningMappingUnbindStability() {
    String modelTrade = "Class my::Trade{\n" + "   id:Integer[1];\n" + "   product:my::Product[1];\n" + "}";
    String modelProduct = "Class my::Product{\n" + "   id:Integer[1];\n" + "}";
    String modelProductTemporal = "Class <<temporal.businesstemporal>> my::Product{\n" + "   id:Integer[1];\n" + "}";
    String storeAndMapping = "###Mapping\n" + "import meta::relational::tests::*;\n" + "import my::*;\n" + "\n" + "Mapping myMapping\n" + "(\n" + "   Trade : Relational {id : [myDB] tradeTable.ID, product : [myDB] @trade_product} \n" + "   Product : Relational { id : [myDB] productTable.ID}\n" + ")\n" + "###Relational\n" + "Database myDB\n" + "(\n" + "   Table tradeTable(ID INT PRIMARY KEY, PRODID INT)\n" + "   Table productTable(ID INT PRIMARY KEY)\n" + "   \n" + "   Join trade_product(tradeTable.PRODID = productTable.ID)\n" + ")";
    String f = "function f():Any[0..1]{let m = myMapping}";
    RuntimeVerifier.verifyOperationIsStable(new RuntimeTestScriptBuilder().createInMemorySource("modelTrade.pure", modelTrade).createInMemorySource("modelProductTemporal.pure", modelProductTemporal).createInMemorySource("storeAndMapping.pure", storeAndMapping).createInMemorySource("f.pure", f).compile(), new RuntimeTestScriptBuilder().deleteSource("modelProductTemporal.pure").createInMemorySource("modelProduct.pure", modelProduct).compile().deleteSource("modelProduct.pure").createInMemorySource("modelProductTemporal.pure", modelProductTemporal).compile(), this.runtime, this.functionExecution, this.getAdditionalVerifiers());
}
Also used : RuntimeTestScriptBuilder(org.finos.legend.pure.m3.RuntimeTestScriptBuilder) Test(org.junit.Test)

Example 3 with RuntimeTestScriptBuilder

use of org.finos.legend.pure.m3.RuntimeTestScriptBuilder in project legend-pure by finos.

the class TestView method testGroupByIncrementalStoreAndMappingChange.

@Test
public void testGroupByIncrementalStoreAndMappingChange() {
    String viewDynaColName = "orderPnl";
    String groupByStore = GroupByStoreTemplate.format(GroupByStoreTemplate, viewDynaColName);
    String groupByMapping = GroupByMappingTemplate.format(GroupByMappingTemplate, viewDynaColName);
    String viewDynaColNameUpdated = "orderPnlUpdated";
    String groupByStoreUpdated = GroupByStoreTemplate.format(GroupByStoreTemplate, viewDynaColNameUpdated);
    String groupByMappingUpdated = GroupByMappingTemplate.format(GroupByMappingTemplate, viewDynaColNameUpdated);
    RuntimeVerifier.verifyOperationIsStable(new RuntimeTestScriptBuilder().createInMemorySources(Maps.mutable.with("store.pure", groupByStore, "model.pure", GroupByModel, "mapping.pure", groupByMapping)).compile(), new RuntimeTestScriptBuilder().updateSource("store.pure", groupByStoreUpdated).updateSource("mapping.pure", groupByMappingUpdated).compile().updateSource("store.pure", groupByStore).updateSource("mapping.pure", groupByMapping).compile(), this.runtime, this.functionExecution, Lists.fixedSize.<RuntimeVerifier.FunctionExecutionStateVerifier>of());
}
Also used : RuntimeVerifier(org.finos.legend.pure.m3.RuntimeVerifier) RuntimeTestScriptBuilder(org.finos.legend.pure.m3.RuntimeTestScriptBuilder) Test(org.junit.Test)

Example 4 with RuntimeTestScriptBuilder

use of org.finos.legend.pure.m3.RuntimeTestScriptBuilder in project legend-pure by finos.

the class TestView method testGroupByIncrementalModelChange.

@Test
public void testGroupByIncrementalModelChange() {
    String viewDynaColName = "orderPnl";
    String groupByStore = GroupByStoreTemplate.format(GroupByStoreTemplate, viewDynaColName);
    String groupByMapping = GroupByMappingTemplate.format(GroupByMappingTemplate, viewDynaColName);
    RuntimeVerifier.verifyOperationIsStable(new RuntimeTestScriptBuilder().createInMemorySources(Maps.mutable.with("store.pure", groupByStore, "model.pure", GroupByModel, "mapping.pure", groupByMapping)).compile(), new RuntimeTestScriptBuilder().updateSource("model.pure", GroupByModel + "\n\n\n").compile().updateSource("model.pure", GroupByModel).compile(), this.runtime, this.functionExecution, Lists.fixedSize.<RuntimeVerifier.FunctionExecutionStateVerifier>of());
}
Also used : RuntimeVerifier(org.finos.legend.pure.m3.RuntimeVerifier) RuntimeTestScriptBuilder(org.finos.legend.pure.m3.RuntimeTestScriptBuilder) Test(org.junit.Test)

Example 5 with RuntimeTestScriptBuilder

use of org.finos.legend.pure.m3.RuntimeTestScriptBuilder in project legend-pure by finos.

the class AbstractTestCompileValueSpecification method testExecuteCodeBlockIsStable.

private void testExecuteCodeBlockIsStable(String codeBlock, String expectedResult) {
    String escapedCode = codeBlock.replace("'", "\\\'").replace("\n", "");
    RuntimeVerifier.verifyOperationIsStable(new RuntimeTestScriptBuilder().createInMemorySource("exec1.pure", EXECUTE_CODE_BLOCK).createInMemorySource("source1.pure", "function meta::pure::functions::io::print(param:Any[*]):Nil[0]\n" + "{\n" + "    print($param, 1);\n" + "}\n" + "function meta::pure::functions::meta::reactivate(vs:ValueSpecification[1]):Any[*]\n" + "{\n" + "   meta::pure::functions::meta::reactivate($vs, ^Map<String, List<Any>>());\n" + "}\n" + "function doSomething():Any[*]\n{ " + codeBlock + "}").createInMemorySource("source2.pure", "function testOutsideCompileValSpec():Any[*]\n{ assert('" + expectedResult + "' == doSomething(), |'');}").createInMemorySource("source3.pure", "function test():Any[*]\n{ assert('" + expectedResult + "' == apps::pure::api::execution::compileAndExecuteCodeBlock('" + escapedCode + "'), |'');}").compile().executeFunction("testOutsideCompileValSpec():Any[*]"), new RuntimeTestScriptBuilder().executeFunction("test():Any[*]"), this.runtime, this.functionExecution, this.getAdditionalVerifiers());
}
Also used : RuntimeTestScriptBuilder(org.finos.legend.pure.m3.RuntimeTestScriptBuilder)

Aggregations

RuntimeTestScriptBuilder (org.finos.legend.pure.m3.RuntimeTestScriptBuilder)74 Test (org.junit.Test)71 RuntimeVerifier (org.finos.legend.pure.m3.RuntimeVerifier)16 CoreInstance (org.finos.legend.pure.m4.coreinstance.CoreInstance)2 RelationalGraphWalker (org.finos.legend.pure.m2.relational.RelationalGraphWalker)1 ToFix (org.finos.legend.pure.m3.tools.test.ToFix)1 Ignore (org.junit.Ignore)1