@Test public void noEventIsRaisedWhenTrackIsFirstSeenLow() { PositionChangedEvent event = new PositionChangedEvent(track, null); track.update(track.getTimeOfLastPositionReport(), Position.create(56, 12), 45.0f, 0.4f, 45.0f); context.checking(new Expectations() {{ never(eventRepository).save(with(any(Event.class))); }}); analysis.start(); analysis.onSpeedOverGroundUpdated(event); context.assertIsSatisfied(); }
@AllowConcurrentEvents @Subscribe public void onSpeedOverGroundUpdated(PositionChangedEvent trackEvent) { Track track = trackEvent.getTrack(); Integer vesselLength = track.getVesselLength(); if (vesselLength != null && vesselLength < SHIP_LENGTH_MIN) { statisticsService.incAnalysisStatistics(getAnalysisName(), "LOA < " + SHIP_LENGTH_MIN); return; } if (!isSpeedOverGroundAvailable(track.getSpeedOverGround())) { return; } if (isClassB.test(track) || isUnknownTypeOrSize.test(track) || isFishingVessel.test(track) || isSpecialCraft.test(track) || isEngagedInTowing.test(track) ) { return; } if (isLastAisTrackingReportTooOld(track, track.getTimeOfLastPositionReport())) { LOG.debug("Skipping analysis: MMSI " + track.getMmsi() + " was predicted for too long."); return; } if (isVeryLongVessel.test(track) || (isCargoVessel.test(track) || isTankerVessel.test(track) || isPassengerVessel.test(track))) { performAnalysis(track); updateApplicationStatistics(); } }
SuddenSpeedChangeAnalysis extends Analysis { @AllowConcurrentEvents @Subscribe public void onSpeedOverGroundUpdated(PositionChangedEvent trackEvent) { Track track = trackEvent.getTrack(); Integer vesselLength = track.getVesselLength(); if (vesselLength != null && vesselLength < SHIP_LENGTH_MIN) { statisticsService.incAnalysisStatistics(getAnalysisName(), "LOA < " + SHIP_LENGTH_MIN); return; } if (!isSpeedOverGroundAvailable(track.getSpeedOverGround())) { return; } if (isClassB.test(track) || isUnknownTypeOrSize.test(track) || isFishingVessel.test(track) || isSpecialCraft.test(track) || isEngagedInTowing.test(track) ) { return; } if (isLastAisTrackingReportTooOld(track, track.getTimeOfLastPositionReport())) { LOG.debug("Skipping analysis: MMSI " + track.getMmsi() + " was predicted for too long."); return; } if (isVeryLongVessel.test(track) || (isCargoVessel.test(track) || isTankerVessel.test(track) || isPassengerVessel.test(track))) { performAnalysis(track); updateApplicationStatistics(); } } }
SuddenSpeedChangeAnalysis extends Analysis { @AllowConcurrentEvents @Subscribe public void onSpeedOverGroundUpdated(PositionChangedEvent trackEvent) { Track track = trackEvent.getTrack(); Integer vesselLength = track.getVesselLength(); if (vesselLength != null && vesselLength < SHIP_LENGTH_MIN) { statisticsService.incAnalysisStatistics(getAnalysisName(), "LOA < " + SHIP_LENGTH_MIN); return; } if (!isSpeedOverGroundAvailable(track.getSpeedOverGround())) { return; } if (isClassB.test(track) || isUnknownTypeOrSize.test(track) || isFishingVessel.test(track) || isSpecialCraft.test(track) || isEngagedInTowing.test(track) ) { return; } if (isLastAisTrackingReportTooOld(track, track.getTimeOfLastPositionReport())) { LOG.debug("Skipping analysis: MMSI " + track.getMmsi() + " was predicted for too long."); return; } if (isVeryLongVessel.test(track) || (isCargoVessel.test(track) || isTankerVessel.test(track) || isPassengerVessel.test(track))) { performAnalysis(track); updateApplicationStatistics(); } } @Inject  SuddenSpeedChangeAnalysis(Configuration configuration, AppStatisticsService statisticsService, EventEmittingTracker trackingService, EventRepository eventRepository); }
SuddenSpeedChangeAnalysis extends Analysis { @AllowConcurrentEvents @Subscribe public void onSpeedOverGroundUpdated(PositionChangedEvent trackEvent) { Track track = trackEvent.getTrack(); Integer vesselLength = track.getVesselLength(); if (vesselLength != null && vesselLength < SHIP_LENGTH_MIN) { statisticsService.incAnalysisStatistics(getAnalysisName(), "LOA < " + SHIP_LENGTH_MIN); return; } if (!isSpeedOverGroundAvailable(track.getSpeedOverGround())) { return; } if (isClassB.test(track) || isUnknownTypeOrSize.test(track) || isFishingVessel.test(track) || isSpecialCraft.test(track) || isEngagedInTowing.test(track) ) { return; } if (isLastAisTrackingReportTooOld(track, track.getTimeOfLastPositionReport())) { LOG.debug("Skipping analysis: MMSI " + track.getMmsi() + " was predicted for too long."); return; } if (isVeryLongVessel.test(track) || (isCargoVessel.test(track) || isTankerVessel.test(track) || isPassengerVessel.test(track))) { performAnalysis(track); updateApplicationStatistics(); } } @Inject  SuddenSpeedChangeAnalysis(Configuration configuration, AppStatisticsService statisticsService, EventEmittingTracker trackingService, EventRepository eventRepository); @Override String toString(); @AllowConcurrentEvents @Subscribe void onSpeedOverGroundUpdated(PositionChangedEvent trackEvent); @AllowConcurrentEvents @Subscribe void onTrackStale(TrackStaleEvent trackEvent); }
SuddenSpeedChangeAnalysis extends Analysis { @AllowConcurrentEvents @Subscribe public void onSpeedOverGroundUpdated(PositionChangedEvent trackEvent) { Track track = trackEvent.getTrack(); Integer vesselLength = track.getVesselLength(); if (vesselLength != null && vesselLength < SHIP_LENGTH_MIN) { statisticsService.incAnalysisStatistics(getAnalysisName(), "LOA < " + SHIP_LENGTH_MIN); return; } if (!isSpeedOverGroundAvailable(track.getSpeedOverGround())) { return; } if (isClassB.test(track) || isUnknownTypeOrSize.test(track) || isFishingVessel.test(track) || isSpecialCraft.test(track) || isEngagedInTowing.test(track) ) { return; } if (isLastAisTrackingReportTooOld(track, track.getTimeOfLastPositionReport())) { LOG.debug("Skipping analysis: MMSI " + track.getMmsi() + " was predicted for too long."); return; } if (isVeryLongVessel.test(track) || (isCargoVessel.test(track) || isTankerVessel.test(track) || isPassengerVessel.test(track))) { performAnalysis(track); updateApplicationStatistics(); } } @Inject  SuddenSpeedChangeAnalysis(Configuration configuration, AppStatisticsService statisticsService, EventEmittingTracker trackingService, EventRepository eventRepository); @Override String toString(); @AllowConcurrentEvents @Subscribe void onSpeedOverGroundUpdated(PositionChangedEvent trackEvent); @AllowConcurrentEvents @Subscribe void onTrackStale(TrackStaleEvent trackEvent);  }