Search in sources :

Example 1 with ProductItem

use of org.drools.impact.analysis.integrationtests.domain.ProductItem in project drools by kiegroup.

the class SpecialUsageTest method testMapWithFunction.

@Test
public void testMapWithFunction() {
    String str = "package mypkg;\n" + "import " + ControlFact.class.getCanonicalName() + ";" + "import " + ProductItem.class.getCanonicalName() + ";" + "import static " + FunctionUtils.class.getCanonicalName() + ".convertMapToBigDecimal;" + "dialect \"mvel\"" + "rule R1 when\n" + "  $c : ControlFact()\n" + "then\n" + "  $c.mapData[\"Price\"] = \"100.0\";" + "  modify ($c) {mapData = $c.mapData};" + "end\n" + "rule R2 when\n" + "  ControlFact($price : convertMapToBigDecimal(mapData, \"Price\"))\n" + "  ProductItem(price == $price)\n" + "then\n" + "end\n";
    // runRule(str, new ControlFact(), new ProductItem("Product1", new BigDecimal("100.0")));
    AnalysisModel analysisModel = new ModelBuilder().build(str);
    ModelToGraphConverter converter = new ModelToGraphConverter();
    Graph graph = converter.toGraph(analysisModel);
    assertLink(graph, "mypkg.R1", "mypkg.R2", ReactivityType.UNKNOWN);
}
Also used : ModelBuilder(org.drools.impact.analysis.parser.ModelBuilder) Graph(org.drools.impact.analysis.graph.Graph) AnalysisModel(org.drools.impact.analysis.model.AnalysisModel) ModelToGraphConverter(org.drools.impact.analysis.graph.ModelToGraphConverter) ProductItem(org.drools.impact.analysis.integrationtests.domain.ProductItem) Test(org.junit.Test)

Aggregations

Graph (org.drools.impact.analysis.graph.Graph)1 ModelToGraphConverter (org.drools.impact.analysis.graph.ModelToGraphConverter)1 ProductItem (org.drools.impact.analysis.integrationtests.domain.ProductItem)1 AnalysisModel (org.drools.impact.analysis.model.AnalysisModel)1 ModelBuilder (org.drools.impact.analysis.parser.ModelBuilder)1 Test (org.junit.Test)1