Search in sources :

Example 1 with TestEvent

use of org.drools.testcoverage.common.model.TestEvent in project drools by kiegroup.

the class StarImportTest method starImportedFactAlsoDeclaredInDRL.

/**
 * Tests that rule fires if supplied with a fact that is imported using
 * "star" import.
 *
 * See BZ 973264.
 */
@Test
public void starImportedFactAlsoDeclaredInDRL() throws Exception {
    session.setGlobal("LOGGER", LOGGER);
    AgendaEventListener ael = mock(AgendaEventListener.class);
    session.addEventListener(ael);
    List<Command<?>> commands = new ArrayList<Command<?>>();
    commands.add(getCommands().newInsert(new TestEvent(1, "event 1", 0)));
    commands.add(getCommands().newFireAllRules());
    session.execute(getCommands().newBatchExecution(commands, null));
    // the rule should have fired exactly once
    try {
        verify(ael, times(1)).afterMatchFired(any(AfterMatchFiredEvent.class));
    } catch (WantedButNotInvoked e) {
        Assertions.fail("The rule does not fire. For more information see BZ 973264", e);
    }
}
Also used : Command(org.kie.api.command.Command) TestEvent(org.drools.testcoverage.common.model.TestEvent) ArrayList(java.util.ArrayList) AgendaEventListener(org.kie.api.event.rule.AgendaEventListener) AfterMatchFiredEvent(org.kie.api.event.rule.AfterMatchFiredEvent) WantedButNotInvoked(org.mockito.exceptions.verification.WantedButNotInvoked) KieSessionTest(org.drools.testcoverage.common.KieSessionTest) Test(org.junit.Test)

Aggregations

ArrayList (java.util.ArrayList)1 KieSessionTest (org.drools.testcoverage.common.KieSessionTest)1 TestEvent (org.drools.testcoverage.common.model.TestEvent)1 Test (org.junit.Test)1 Command (org.kie.api.command.Command)1 AfterMatchFiredEvent (org.kie.api.event.rule.AfterMatchFiredEvent)1 AgendaEventListener (org.kie.api.event.rule.AgendaEventListener)1 WantedButNotInvoked (org.mockito.exceptions.verification.WantedButNotInvoked)1