Search in sources :

Example 1 with ActivationLogEvent

use of org.drools.core.audit.event.ActivationLogEvent in project drools by kiegroup.

the class WorkingMemoryLoggerTest method testLogAllBoundVariables.

@Test
public void testLogAllBoundVariables() throws Exception {
    // BZ-1271909
    final String drl = "import " + Message.class.getCanonicalName() + "\n" + "rule \"Hello World\" no-loop\n" + "    when\n" + "        $messageInstance : Message( $myMessage : message )\n" + "    then\n" + "        update($messageInstance);\n" + "end\n";
    final KieSession ksession = new KieHelper().addContent(drl, ResourceType.DRL).build().newKieSession();
    final WorkingMemoryInMemoryLogger logger = new WorkingMemoryInMemoryLogger((WorkingMemory) ksession);
    final Message message = new Message();
    message.setMessage("Hello World");
    ksession.insert(message);
    ksession.fireAllRules();
    for (final LogEvent logEvent : logger.getLogEvents()) {
        if (logEvent instanceof ActivationLogEvent) {
            assertTrue(((ActivationLogEvent) logEvent).getDeclarations().contains("$messageInstance"));
            assertTrue(((ActivationLogEvent) logEvent).getDeclarations().contains("$myMessage"));
        }
    }
}
Also used : WorkingMemoryInMemoryLogger(org.drools.core.audit.WorkingMemoryInMemoryLogger) Message(org.drools.compiler.Message) LogEvent(org.drools.core.audit.event.LogEvent) ActivationLogEvent(org.drools.core.audit.event.ActivationLogEvent) KieHelper(org.kie.internal.utils.KieHelper) KieSession(org.kie.api.runtime.KieSession) ActivationLogEvent(org.drools.core.audit.event.ActivationLogEvent) Test(org.junit.Test)

Aggregations

Message (org.drools.compiler.Message)1 WorkingMemoryInMemoryLogger (org.drools.core.audit.WorkingMemoryInMemoryLogger)1 ActivationLogEvent (org.drools.core.audit.event.ActivationLogEvent)1 LogEvent (org.drools.core.audit.event.LogEvent)1 Test (org.junit.Test)1 KieSession (org.kie.api.runtime.KieSession)1 KieHelper (org.kie.internal.utils.KieHelper)1