use of org.drools.core.audit.event.LogEvent 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"));
}
}
}
Aggregations