Search in sources :

Example 36 with ModelBuilder

use of org.drools.impact.analysis.parser.ModelBuilder in project drools by kiegroup.

the class SpecialUsageTest method testBindVariableLiteralInsert.

@Test
public void testBindVariableLiteralInsert() {
    String str = "package mypkg;\n" + "import " + Address.class.getCanonicalName() + ";" + "import " + Person.class.getCanonicalName() + ";" + "rule R1 when\n" + "  Address(city == \"Tokyo\", $data : \"ABC\")\n" + "then\n" + "  Person person = new Person(\"John\");\n" + "  person.setLikes($data);\n" + "  insert(person);\n" + "end\n" + "rule R2 when\n" + "  $p : Person(likes == \"ABC\")\n" + "then\n" + "end\n";
    AnalysisModel analysisModel = new ModelBuilder().build(str);
    ModelToGraphConverter converter = new ModelToGraphConverter();
    Graph graph = converter.toGraph(analysisModel);
    assertLink(graph, "mypkg.R1", "mypkg.R2", ReactivityType.POSITIVE);
}
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) Person(org.drools.impact.analysis.integrationtests.domain.Person) Test(org.junit.Test)

Aggregations

Graph (org.drools.impact.analysis.graph.Graph)36 ModelToGraphConverter (org.drools.impact.analysis.graph.ModelToGraphConverter)36 AnalysisModel (org.drools.impact.analysis.model.AnalysisModel)36 ModelBuilder (org.drools.impact.analysis.parser.ModelBuilder)36 Test (org.junit.Test)34 Person (org.drools.impact.analysis.integrationtests.domain.Person)9 Address (org.drools.impact.analysis.integrationtests.domain.Address)5 ImpactAnalysisHelper (org.drools.impact.analysis.graph.ImpactAnalysisHelper)4 ControlFact (org.drools.impact.analysis.integrationtests.domain.ControlFact)3 GraphCollapsionHelper (org.drools.impact.analysis.graph.GraphCollapsionHelper)2 PropHolder (org.drools.impact.analysis.integrationtests.domain.PropHolder)2 BigDecimal (java.math.BigDecimal)1 ArrayList (java.util.ArrayList)1 Node (org.drools.impact.analysis.graph.Node)1 AbstractGraphTest (org.drools.impact.analysis.integrationtests.AbstractGraphTest)1 ProductItem (org.drools.impact.analysis.integrationtests.domain.ProductItem)1 LoanApplication (org.drools.impact.analysis.integrationtests.kogito.domain.LoanApplication)1