@Test public void cogEventIsRaisedAndMaintained() { assertEquals(0, testSubscriber.numAbnormalEventRaise); assertEquals(0, testSubscriber.numAbnormalEventMaintain); assertEquals(0, testSubscriber.numAbnormalEventLower); for (int i=0; i<BehaviourManagerImpl.RAISE_EVENT_SCORE_THRESHOLD - 1; i++) { behaviourManager.abnormalBehaviourDetected(CourseOverGroundEvent.class, track); assertEquals(0, testSubscriber.numAbnormalEventRaise); assertEquals(0, testSubscriber.numAbnormalEventMaintain); assertEquals(0, testSubscriber.numAbnormalEventLower); } behaviourManager.abnormalBehaviourDetected(CourseOverGroundEvent.class, track); assertEquals(1, testSubscriber.numAbnormalEventRaise); assertEquals(0, testSubscriber.numAbnormalEventMaintain); assertEquals(0, testSubscriber.numAbnormalEventLower); for (int i=1; i<100; i++) { behaviourManager.abnormalBehaviourDetected(CourseOverGroundEvent.class, track); assertEquals(1, testSubscriber.numAbnormalEventRaise); assertEquals(i, testSubscriber.numAbnormalEventMaintain); assertEquals(0, testSubscriber.numAbnormalEventLower); } }
@Override public void abnormalBehaviourDetected(Class<? extends Event> eventClass, Track track, Track... otherTracks) { if (!getEventRaised(eventClass, track)) { int score = getEventScore(eventClass, track); if (score < RAISE_EVENT_SCORE_THRESHOLD) { score++; if (score == RAISE_EVENT_SCORE_THRESHOLD) { setEventRaised(eventClass, track, true); setEventScore(eventClass, track, 0); setEventCertaintyOnCurrentPositionReport(eventClass, track); fireRaiseEvent(eventClass, track, otherTracks); } else { setEventScore(eventClass, track, score); setEventCertaintyOnCurrentPositionReport(eventClass, track); } } } else { setEventScore(eventClass, track, 0); setEventCertaintyOnCurrentPositionReport(eventClass, track); fireMaintainEvent(eventClass, track); } }
BehaviourManagerImpl implements BehaviourManager { @Override public void abnormalBehaviourDetected(Class<? extends Event> eventClass, Track track, Track... otherTracks) { if (!getEventRaised(eventClass, track)) { int score = getEventScore(eventClass, track); if (score < RAISE_EVENT_SCORE_THRESHOLD) { score++; if (score == RAISE_EVENT_SCORE_THRESHOLD) { setEventRaised(eventClass, track, true); setEventScore(eventClass, track, 0); setEventCertaintyOnCurrentPositionReport(eventClass, track); fireRaiseEvent(eventClass, track, otherTracks); } else { setEventScore(eventClass, track, score); setEventCertaintyOnCurrentPositionReport(eventClass, track); } } } else { setEventScore(eventClass, track, 0); setEventCertaintyOnCurrentPositionReport(eventClass, track); fireMaintainEvent(eventClass, track); } } }
BehaviourManagerImpl implements BehaviourManager { @Override public void abnormalBehaviourDetected(Class<? extends Event> eventClass, Track track, Track... otherTracks) { if (!getEventRaised(eventClass, track)) { int score = getEventScore(eventClass, track); if (score < RAISE_EVENT_SCORE_THRESHOLD) { score++; if (score == RAISE_EVENT_SCORE_THRESHOLD) { setEventRaised(eventClass, track, true); setEventScore(eventClass, track, 0); setEventCertaintyOnCurrentPositionReport(eventClass, track); fireRaiseEvent(eventClass, track, otherTracks); } else { setEventScore(eventClass, track, score); setEventCertaintyOnCurrentPositionReport(eventClass, track); } } } else { setEventScore(eventClass, track, 0); setEventCertaintyOnCurrentPositionReport(eventClass, track); fireMaintainEvent(eventClass, track); } } @Inject  BehaviourManagerImpl(EventEmittingTracker trackingService); }
BehaviourManagerImpl implements BehaviourManager { @Override public void abnormalBehaviourDetected(Class<? extends Event> eventClass, Track track, Track... otherTracks) { if (!getEventRaised(eventClass, track)) { int score = getEventScore(eventClass, track); if (score < RAISE_EVENT_SCORE_THRESHOLD) { score++; if (score == RAISE_EVENT_SCORE_THRESHOLD) { setEventRaised(eventClass, track, true); setEventScore(eventClass, track, 0); setEventCertaintyOnCurrentPositionReport(eventClass, track); fireRaiseEvent(eventClass, track, otherTracks); } else { setEventScore(eventClass, track, score); setEventCertaintyOnCurrentPositionReport(eventClass, track); } } } else { setEventScore(eventClass, track, 0); setEventCertaintyOnCurrentPositionReport(eventClass, track); fireMaintainEvent(eventClass, track); } } @Inject  BehaviourManagerImpl(EventEmittingTracker trackingService); @Override void abnormalBehaviourDetected(Class<? extends Event> eventClass, Track track, Track... otherTracks); @Override void normalBehaviourDetected(Class<? extends Event> eventClass, Track track); @Override void trackStaleDetected(Class<? extends Event> eventClass, Track track); @Override void registerSubscriber(Object subscriber); @Override EventCertainty getEventCertaintyAtCurrentPosition(Class<? extends Event> eventClass, Track track); @Subscribe @SuppressWarnings("unused") void listen(DeadEvent event); static String getEventRaisedKey(Class<? extends Event> eventClass); static String getScoreKey(Class<? extends Event> eventClass); static String getEventCertaintyKey(Class<? extends Event> eventClass); }
BehaviourManagerImpl implements BehaviourManager { @Override public void abnormalBehaviourDetected(Class<? extends Event> eventClass, Track track, Track... otherTracks) { if (!getEventRaised(eventClass, track)) { int score = getEventScore(eventClass, track); if (score < RAISE_EVENT_SCORE_THRESHOLD) { score++; if (score == RAISE_EVENT_SCORE_THRESHOLD) { setEventRaised(eventClass, track, true); setEventScore(eventClass, track, 0); setEventCertaintyOnCurrentPositionReport(eventClass, track); fireRaiseEvent(eventClass, track, otherTracks); } else { setEventScore(eventClass, track, score); setEventCertaintyOnCurrentPositionReport(eventClass, track); } } } else { setEventScore(eventClass, track, 0); setEventCertaintyOnCurrentPositionReport(eventClass, track); fireMaintainEvent(eventClass, track); } } @Inject  BehaviourManagerImpl(EventEmittingTracker trackingService); @Override void abnormalBehaviourDetected(Class<? extends Event> eventClass, Track track, Track... otherTracks); @Override void normalBehaviourDetected(Class<? extends Event> eventClass, Track track); @Override void trackStaleDetected(Class<? extends Event> eventClass, Track track); @Override void registerSubscriber(Object subscriber); @Override EventCertainty getEventCertaintyAtCurrentPosition(Class<? extends Event> eventClass, Track track); @Subscribe @SuppressWarnings("unused") void listen(DeadEvent event); static String getEventRaisedKey(Class<? extends Event> eventClass); static String getScoreKey(Class<? extends Event> eventClass); static String getEventCertaintyKey(Class<? extends Event> eventClass);  }