Search in sources :

Example 6 with RoutingMessage

use of org.drools.compiler.RoutingMessage in project drools by kiegroup.

the class StrEvaluatorTest method testStrLengthEquals.

@Test
public void testStrLengthEquals() throws Exception {
    KieBase kbase = readKnowledgeBase();
    KieSession ksession = createKnowledgeSession(kbase);
    List list = new ArrayList();
    ksession.setGlobal("list", list);
    RoutingMessage m = new RoutingMessage();
    m.setRoutingValue("R1:messageBody:R2");
    ksession.insert(m);
    ksession.fireAllRules();
    assertEquals(6, list.size());
    assertTrue(list.contains("Message length is 17"));
}
Also used : KieBase(org.kie.api.KieBase) ArrayList(java.util.ArrayList) KieSession(org.kie.api.runtime.KieSession) ArrayList(java.util.ArrayList) List(java.util.List) RoutingMessage(org.drools.compiler.RoutingMessage) Test(org.junit.Test)

Example 7 with RoutingMessage

use of org.drools.compiler.RoutingMessage in project drools by kiegroup.

the class StrEvaluatorTest method testStrLengthNoEquals.

@Test
public void testStrLengthNoEquals() throws Exception {
    KieBase kbase = readKnowledgeBase();
    KieSession ksession = createKnowledgeSession(kbase);
    List list = new ArrayList();
    ksession.setGlobal("list", list);
    RoutingMessage m = new RoutingMessage();
    m.setRoutingValue("messageBody");
    ksession.insert(m);
    ksession.fireAllRules();
    assertTrue(list.size() == 3);
    assertTrue(((String) list.get(0)).equals("Message length is not 17"));
    assertTrue(((String) list.get(1)).equals("Message does not start with R2"));
    assertTrue(((String) list.get(2)).equals("Message does not end with R1"));
}
Also used : KieBase(org.kie.api.KieBase) ArrayList(java.util.ArrayList) KieSession(org.kie.api.runtime.KieSession) ArrayList(java.util.ArrayList) List(java.util.List) RoutingMessage(org.drools.compiler.RoutingMessage) Test(org.junit.Test)

Aggregations

RoutingMessage (org.drools.compiler.RoutingMessage)7 Test (org.junit.Test)7 KieBase (org.kie.api.KieBase)7 KieSession (org.kie.api.runtime.KieSession)7 ArrayList (java.util.ArrayList)6 List (java.util.List)6