use of com.salaboy.model.KeyA in project jBPM5-Developer-Guide by Salaboy.
the class EventsTesterJFrame method onKeyAjButtonKeyPressed.
//GEN-LAST:event_keySjButtonActionPerformed
private void onKeyAjButtonKeyPressed(java.awt.event.KeyEvent evt) {
if (evt.getKeyCode() == KeyEvent.VK_A) {
ksession.insert(new KeyA());
ksession.fireAllRules();
outjTextPane.setText(outjTextPane.getText() + " >>> Key A Pressed!\n");
keyAjButton.setBackground(new java.awt.Color(51, 255, 0));
keyAjButton.setForeground(new java.awt.Color(51, 204, 0));
keyAjButton.setText("[ Key A ]");
keyAjButton.setOpaque(true);
evt.consume();
}
}
use of com.salaboy.model.KeyA 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();
}
use of com.salaboy.model.KeyA in project jBPM5-Developer-Guide by Salaboy.
the class MyFirstDrools5FusionRulesTest method testSimpleEvents.
@Test
public void testSimpleEvents() {
StatefulKnowledgeSession ksession = createKnowledgeSession();
// Uncomment to see all the logs
// KnowledgeRuntimeLoggerFactory.newConsoleLogger(ksession);
// We have our Session, now let's play with our Events
SessionPseudoClock clock = ksession.getSessionClock();
int fired = 0;
// Initial time 0s -> t0
ksession.insert(new KeyA());
fired = ksession.fireAllRules();
clock.advanceTime(2, TimeUnit.SECONDS);
assertEquals(0, fired);
// t1 -> 2s
ksession.insert(new KeyA());
fired = ksession.fireAllRules();
clock.advanceTime(2, TimeUnit.SECONDS);
assertEquals(0, fired);
// t2 -> 4s
ksession.insert(new KeyA());
fired = ksession.fireAllRules();
clock.advanceTime(2, TimeUnit.SECONDS);
assertEquals(0, fired);
// t3 -> 6s
ksession.insert(new KeyA());
fired = ksession.fireAllRules();
clock.advanceTime(2, TimeUnit.SECONDS);
assertEquals(1, fired);
// t4 -> 8s
ksession.insert(new KeyA());
fired = ksession.fireAllRules();
assertEquals(1, fired);
ksession.dispose();
}
Aggregations