Search in sources :

Example 1 with WorkingMemoryConsoleLogger

use of org.drools.core.audit.WorkingMemoryConsoleLogger in project drools by kiegroup.

the class FirstOrderLogicTest method testExists3.

@Test
public void testExists3() throws Exception {
    KieBase kbase = loadKnowledgeBase("test_Exists_JBRULES_2810.drl");
    KieSession ksession = createKnowledgeSession(kbase);
    WorkingMemoryConsoleLogger logger = new WorkingMemoryConsoleLogger(ksession);
    ksession.fireAllRules();
    ksession.dispose();
}
Also used : WorkingMemoryConsoleLogger(org.drools.core.audit.WorkingMemoryConsoleLogger) KieBase(org.kie.api.KieBase) KieSession(org.kie.api.runtime.KieSession) Test(org.junit.Test)

Example 2 with WorkingMemoryConsoleLogger

use of org.drools.core.audit.WorkingMemoryConsoleLogger in project drools by kiegroup.

the class MapConstraintTest method testMapNullConstraint.

@Test
public void testMapNullConstraint() throws Exception {
    final KieBase kbase = loadKnowledgeBase("test_mapNullConstraints.drl");
    final KieSession ksession = createKnowledgeSession(kbase);
    final org.kie.api.event.rule.AgendaEventListener ael = mock(org.kie.api.event.rule.AgendaEventListener.class);
    ksession.addEventListener(ael);
    new WorkingMemoryConsoleLogger((WorkingMemory) ksession);
    final Map addresses = new HashMap();
    addresses.put("home", new Address("home street"));
    final Person bob = new Person("Bob");
    bob.setNamedAddresses(addresses);
    ksession.insert(bob);
    ksession.fireAllRules();
    final ArgumentCaptor<AfterMatchFiredEvent> arg = ArgumentCaptor.forClass(org.kie.api.event.rule.AfterMatchFiredEvent.class);
    verify(ael, times(4)).afterMatchFired(arg.capture());
    org.kie.api.event.rule.AfterMatchFiredEvent aaf = arg.getAllValues().get(0);
    assertThat(aaf.getMatch().getRule().getName(), is("1. home != null"));
    aaf = arg.getAllValues().get(1);
    assertThat(aaf.getMatch().getRule().getName(), is("2. not home == null"));
    aaf = arg.getAllValues().get(2);
    assertThat(aaf.getMatch().getRule().getName(), is("7. work == null"));
    aaf = arg.getAllValues().get(3);
    assertThat(aaf.getMatch().getRule().getName(), is("8. not work != null"));
}
Also used : Address(org.drools.compiler.Address) HashMap(java.util.HashMap) AfterMatchFiredEvent(org.kie.api.event.rule.AfterMatchFiredEvent) WorkingMemoryConsoleLogger(org.drools.core.audit.WorkingMemoryConsoleLogger) KieBase(org.kie.api.KieBase) AfterMatchFiredEvent(org.kie.api.event.rule.AfterMatchFiredEvent) KieSession(org.kie.api.runtime.KieSession) HashMap(java.util.HashMap) Map(java.util.Map) Person(org.drools.compiler.Person) Test(org.junit.Test)

Aggregations

WorkingMemoryConsoleLogger (org.drools.core.audit.WorkingMemoryConsoleLogger)2 Test (org.junit.Test)2 KieBase (org.kie.api.KieBase)2 KieSession (org.kie.api.runtime.KieSession)2 HashMap (java.util.HashMap)1 Map (java.util.Map)1 Address (org.drools.compiler.Address)1 Person (org.drools.compiler.Person)1 AfterMatchFiredEvent (org.kie.api.event.rule.AfterMatchFiredEvent)1