Search in sources :

Example 1 with KeyS

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

the class EventsTesterJFrame method onKeySjButtonKeyPressed.

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

Example 2 with KeyS

use of com.salaboy.model.KeyS 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

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