Search in sources :

Example 1 with KeyD

use of com.salaboy.model.KeyD in project jBPM5-Developer-Guide by Salaboy.

the class EventsTesterJFrame method onKeyDjButtonKeyPressed.

private void onKeyDjButtonKeyPressed(java.awt.event.KeyEvent evt) {
    if (evt.getKeyCode() == KeyEvent.VK_D) {
        ksession.insert(new KeyD());
        ksession.fireAllRules();
        outjTextPane.setText(outjTextPane.getText() + " >>> Key D Pressed!\n");
        keyDjButton.setBackground(new java.awt.Color(51, 255, 0));
        keyDjButton.setForeground(new java.awt.Color(51, 204, 0));
        keyDjButton.setText("[ Key D ]");
        keyDjButton.setOpaque(true);
    }
}
Also used : KeyD(com.salaboy.model.KeyD)

Example 2 with KeyD

use of com.salaboy.model.KeyD in project jBPM5-Developer-Guide by Salaboy.

the class MyFirstDrools5FusionRulesTest method testPatternDetectionEvents.

@Test
public void testPatternDetectionEvents() {
    StatefulKnowledgeSession ksession = createKnowledgeSession();
    SessionPseudoClock clock = ksession.getSessionClock();
    int fired = 0;
    // Initial time 0s -> t0
    ksession.insert(new KeyA());
    fired = ksession.fireAllRules();
    clock.advanceTime(15, TimeUnit.MILLISECONDS);
    assertEquals(0, fired);
    ksession.insert(new KeyS());
    fired = ksession.fireAllRules();
    clock.advanceTime(15, TimeUnit.MILLISECONDS);
    assertEquals(0, fired);
    ksession.insert(new KeyD());
    fired = ksession.fireAllRules();
    clock.advanceTime(15, TimeUnit.MILLISECONDS);
    assertEquals(1, fired);
    ksession.dispose();
}
Also used : KeyA(com.salaboy.model.KeyA) SessionPseudoClock(org.drools.time.SessionPseudoClock) KeyD(com.salaboy.model.KeyD) StatefulKnowledgeSession(org.drools.runtime.StatefulKnowledgeSession) KeyS(com.salaboy.model.KeyS) Test(org.junit.Test)

Aggregations

KeyD (com.salaboy.model.KeyD)2 KeyA (com.salaboy.model.KeyA)1 KeyS (com.salaboy.model.KeyS)1 StatefulKnowledgeSession (org.drools.runtime.StatefulKnowledgeSession)1 SessionPseudoClock (org.drools.time.SessionPseudoClock)1 Test (org.junit.Test)1