use of org.drools.testcoverage.common.model.Message in project drools by kiegroup.
the class OOPathCepTest method populateAndVerifyEventCase.
private void populateAndVerifyEventCase(final EntryPoint entryPoint) {
final Message helloMessage = new Message("Hello");
final MessageEvent helloEvent = new MessageEvent(MessageEvent.Type.sent, helloMessage);
entryPoint.insert(helloEvent);
final MessageEvent anotherEvent = new MessageEvent(MessageEvent.Type.sent, new Message("Not a hello"));
entryPoint.insert(anotherEvent);
this.kieSession.fireAllRules();
Assertions.assertThat(this.messages).containsExactlyInAnyOrder(helloMessage);
}
use of org.drools.testcoverage.common.model.Message in project drools by kiegroup.
the class OOPathCepTest method testTemporalOperatorCoincidesWithOOPath.
@Test
public void testTemporalOperatorCoincidesWithOOPath() {
final String drl = "import org.drools.testcoverage.common.model.Message;\n" + "import org.drools.testcoverage.common.model.MessageEvent;\n" + "global java.util.List events\n" + "global java.util.List messages\n" + "\n" + "declare org.drools.testcoverage.common.model.MessageEvent\n" + " @role( event )\n" + "end\n" + "rule R when\n" + " ev1: MessageEvent( /msg[ message == 'Ping' ] )\n" + " ev2: MessageEvent( $message: /msg[ message == 'Pong' ], this coincides[1s] ev1 )\n" + "then\n" + " messages.add( $message );\n" + "end\n";
final KieBase kieBase = KieBaseUtil.getKieBaseAndBuildInstallModuleFromDrl(MODULE_GROUP_ID, kieBaseTestConfiguration, drl);
final SessionPseudoClock clock = this.initKieSessionWithPseudoClock(kieBase);
this.insertEventAndAdvanceClock(new MessageEvent(MessageEvent.Type.sent, new Message("Pong")), clock, 2);
this.insertEvent(new MessageEvent(MessageEvent.Type.sent, new Message("Ping")));
this.kieSession.fireAllRules();
Assertions.assertThat(this.messages).as("The first sequence of events should NOT make the rule fire").isEmpty();
final Message pongMessage = this.insertEvent(new MessageEvent(MessageEvent.Type.sent, new Message("Pong")));
this.kieSession.fireAllRules();
Assertions.assertThat(this.messages).as("The last event should make the rule fire").containsExactlyInAnyOrder(pongMessage);
}
Aggregations