final StatefulKnowledgeSession ksession = this.createKSession();
WorkingMemoryEntryPoint checkInEventsEP = ksession.getWorkingMemoryEntryPoint("check-in-sensors");
//Init the LuggageManager
LuggageManager luggageManager = new LuggageManager();
ksession.setGlobal("luggageManager", luggageManager);
//Init the AlertSystem
AlertSystem alertSystem = new AlertSystem();
ksession.setGlobal("alertSystem", alertSystem);
//flight code
String flightCode = "AR 1435";
//Luggage registration
Luggage luggage = luggageManager.registerNewLuggage();
LuggageReceptionEvent luggageReceptionEvent = new LuggageReceptionEvent(luggage,flightCode);
ksession.insert(luggage);
ksession.insert(luggageReceptionEvent);
clock.advanceTime(3, TimeUnit.MINUTES);
ksession.fireAllRules();
//no alert should be fired 3 minutes after the luggage was received
assertEquals(0, alertSystem.getAlertCount());
//the luggage's location should be FRONT-DESK
assertEquals(Luggage.Location.FRONT_DESK, luggage.getLocation());
clock.advanceTime(3, TimeUnit.MINUTES);
ksession.fireAllRules();
//3 minutes later, the LUGGAGE_NOT_CHECKED_IN_ON_TIME alert should be fired
assertEquals(1, alertSystem.getAlertCount());
assertEquals(1, alertSystem.getAlertCount(AlertType.LUGGAGE_NOT_CHECKED_IN_ON_TIME));
//the luggage's location should be FRONT-DESK
assertEquals(Luggage.Location.FRONT_DESK, luggage.getLocation());
///////////////////////////////////////////
alertSystem.clearAllAlerts();
//A new Luggage is dispatched
luggage = luggageManager.registerNewLuggage();
luggageReceptionEvent = new LuggageReceptionEvent(luggage,flightCode);
ksession.insert(luggage);
ksession.insert(luggageReceptionEvent);
//the luggage's location should be FRONT-DESK