Search in sources :

Example 6 with InternationalAddress

use of org.drools.modelcompiler.domain.InternationalAddress in project drools by kiegroup.

the class OOPathTest method testSimpleOOPathCast2.

@Test
public void testSimpleOOPathCast2() {
    final String str = "import org.drools.modelcompiler.domain.*;\n" + "global java.util.List list\n" + "\n" + "rule R when\n" + "  Man( $name : name, $italy: /address#InternationalAddress[ state == \"Italy\" ] )\n" + "then\n" + "  list.add( $name );\n" + "end\n";
    KieSession ksession = getKieSession(str);
    final List<String> list = new ArrayList<>();
    ksession.setGlobal("list", list);
    final Man bob = new Man("Bob", 40);
    bob.setAddress(new InternationalAddress("Via Verdi", "Italy"));
    ksession.insert(bob);
    ksession.fireAllRules();
    Assertions.assertThat(list).containsExactlyInAnyOrder("Bob");
}
Also used : InternationalAddress(org.drools.modelcompiler.domain.InternationalAddress) ArrayList(java.util.ArrayList) KieSession(org.kie.api.runtime.KieSession) Man(org.drools.modelcompiler.domain.Man) Test(org.junit.Test)

Aggregations

InternationalAddress (org.drools.modelcompiler.domain.InternationalAddress)6 Test (org.junit.Test)6 KieSession (org.kie.api.runtime.KieSession)6 ArrayList (java.util.ArrayList)4 Man (org.drools.modelcompiler.domain.Man)4 BaseModelTest (org.drools.modelcompiler.BaseModelTest)2 Person (org.drools.modelcompiler.domain.Person)2 List (java.util.List)1 Assertions (org.assertj.core.api.Assertions)1 FlowDSL.accFunction (org.drools.model.FlowDSL.accFunction)1 FlowDSL.accumulate (org.drools.model.FlowDSL.accumulate)1 FlowDSL.and (org.drools.model.FlowDSL.and)1 FlowDSL.declarationOf (org.drools.model.FlowDSL.declarationOf)1 FlowDSL.expr (org.drools.model.FlowDSL.expr)1 FlowDSL.from (org.drools.model.FlowDSL.from)1 FlowDSL.globalOf (org.drools.model.FlowDSL.globalOf)1 FlowDSL.input (org.drools.model.FlowDSL.input)1 FlowDSL.on (org.drools.model.FlowDSL.on)1 FlowDSL.query (org.drools.model.FlowDSL.query)1 FlowDSL.reactiveFrom (org.drools.model.FlowDSL.reactiveFrom)1