@Test public void testNoAnalysisDoneForInsufficientData() { Track track = new Track(219000606); CellChangedEvent event = new CellChangedEvent(track, null); context.checking(new Expectations() {{ oneOf(behaviourManager).registerSubscriber(with(any(ShipTypeAndSizeAnalysis.class))); }}); final ShipTypeAndSizeAnalysis analysis = new ShipTypeAndSizeAnalysis(configuration, statisticsService, statisticsRepository, trackingService, eventRepository, behaviourManager); context.checking(new Expectations() {{ ignoring(statisticsService).incAnalysisStatistics(with(ShipTypeAndSizeAnalysis.class.getSimpleName()), with(any(String.class))); oneOf(trackingService).registerSubscriber(analysis); }}); analysis.start(); analysis.onCellIdChanged(event); context.assertIsSatisfied(); context.checking(new Expectations() {{ ignoring(statisticsService).incAnalysisStatistics(with(ShipTypeAndSizeAnalysis.class.getSimpleName()), with(any(String.class))); }}); event.getTrack().setProperty(Track.CELL_ID, 123L); analysis.onCellIdChanged(event); context.assertIsSatisfied(); context.checking(new Expectations() {{ ignoring(statisticsService).incAnalysisStatistics(with(ShipTypeAndSizeAnalysis.class.getSimpleName()), with(any(String.class))); oneOf(statisticsRepository).getStatisticData("ShipTypeAndSizeStatistic", 123L); oneOf(behaviourManager).normalBehaviourDetected(ShipSizeOrTypeEvent.class, track); }}); track.update(msg5); analysis.onCellIdChanged(event); context.assertIsSatisfied(); }
@AllowConcurrentEvents @Subscribe public void onCellIdChanged(CellChangedEvent trackEvent) { statisticsService.incAnalysisStatistics(getAnalysisName(), "Events received"); Track track = trackEvent.getTrack(); if (isClassB.test(track) || isUnknownTypeOrSize.test(track) || isFishingVessel.test(track) || isSmallVessel.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; } Long cellId = (Long) track.getProperty(Track.CELL_ID); Integer shipType = track.getShipType(); Integer shipLength = track.getVesselLength(); if (cellId == null) { statisticsService.incAnalysisStatistics(getAnalysisName(), "Unknown mmsi"); return; } if (shipType == null) { statisticsService.incAnalysisStatistics(getAnalysisName(), "Unknown ship type"); return; } if (shipLength == null) { statisticsService.incAnalysisStatistics(getAnalysisName(), "Unknown ship length"); return; } if (shipLength < SHIP_LENGTH_MIN) { statisticsService.incAnalysisStatistics(getAnalysisName(), "LOA < " + SHIP_LENGTH_MIN); return; } int shipTypeKey = Categorizer.mapShipTypeToCategory(shipType) - 1; int shipLengthKey = Categorizer.mapShipLengthToCategory(shipLength) - 1; if (isAbnormalCellForShipTypeAndSize(cellId, shipTypeKey, shipLengthKey)) { getBehaviourManager().abnormalBehaviourDetected(ShipSizeOrTypeEvent.class, track); } else { getBehaviourManager().normalBehaviourDetected(ShipSizeOrTypeEvent.class, track); } }
ShipTypeAndSizeAnalysis extends StatisticBasedAnalysis { @AllowConcurrentEvents @Subscribe public void onCellIdChanged(CellChangedEvent trackEvent) { statisticsService.incAnalysisStatistics(getAnalysisName(), "Events received"); Track track = trackEvent.getTrack(); if (isClassB.test(track) || isUnknownTypeOrSize.test(track) || isFishingVessel.test(track) || isSmallVessel.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; } Long cellId = (Long) track.getProperty(Track.CELL_ID); Integer shipType = track.getShipType(); Integer shipLength = track.getVesselLength(); if (cellId == null) { statisticsService.incAnalysisStatistics(getAnalysisName(), "Unknown mmsi"); return; } if (shipType == null) { statisticsService.incAnalysisStatistics(getAnalysisName(), "Unknown ship type"); return; } if (shipLength == null) { statisticsService.incAnalysisStatistics(getAnalysisName(), "Unknown ship length"); return; } if (shipLength < SHIP_LENGTH_MIN) { statisticsService.incAnalysisStatistics(getAnalysisName(), "LOA < " + SHIP_LENGTH_MIN); return; } int shipTypeKey = Categorizer.mapShipTypeToCategory(shipType) - 1; int shipLengthKey = Categorizer.mapShipLengthToCategory(shipLength) - 1; if (isAbnormalCellForShipTypeAndSize(cellId, shipTypeKey, shipLengthKey)) { getBehaviourManager().abnormalBehaviourDetected(ShipSizeOrTypeEvent.class, track); } else { getBehaviourManager().normalBehaviourDetected(ShipSizeOrTypeEvent.class, track); } } }
ShipTypeAndSizeAnalysis extends StatisticBasedAnalysis { @AllowConcurrentEvents @Subscribe public void onCellIdChanged(CellChangedEvent trackEvent) { statisticsService.incAnalysisStatistics(getAnalysisName(), "Events received"); Track track = trackEvent.getTrack(); if (isClassB.test(track) || isUnknownTypeOrSize.test(track) || isFishingVessel.test(track) || isSmallVessel.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; } Long cellId = (Long) track.getProperty(Track.CELL_ID); Integer shipType = track.getShipType(); Integer shipLength = track.getVesselLength(); if (cellId == null) { statisticsService.incAnalysisStatistics(getAnalysisName(), "Unknown mmsi"); return; } if (shipType == null) { statisticsService.incAnalysisStatistics(getAnalysisName(), "Unknown ship type"); return; } if (shipLength == null) { statisticsService.incAnalysisStatistics(getAnalysisName(), "Unknown ship length"); return; } if (shipLength < SHIP_LENGTH_MIN) { statisticsService.incAnalysisStatistics(getAnalysisName(), "LOA < " + SHIP_LENGTH_MIN); return; } int shipTypeKey = Categorizer.mapShipTypeToCategory(shipType) - 1; int shipLengthKey = Categorizer.mapShipLengthToCategory(shipLength) - 1; if (isAbnormalCellForShipTypeAndSize(cellId, shipTypeKey, shipLengthKey)) { getBehaviourManager().abnormalBehaviourDetected(ShipSizeOrTypeEvent.class, track); } else { getBehaviourManager().normalBehaviourDetected(ShipSizeOrTypeEvent.class, track); } } @Inject  ShipTypeAndSizeAnalysis(Configuration configuration, AppStatisticsService statisticsService, StatisticDataRepository statisticsRepository, EventEmittingTracker trackingService, EventRepository eventRepository, BehaviourManager behaviourManager); }
ShipTypeAndSizeAnalysis extends StatisticBasedAnalysis { @AllowConcurrentEvents @Subscribe public void onCellIdChanged(CellChangedEvent trackEvent) { statisticsService.incAnalysisStatistics(getAnalysisName(), "Events received"); Track track = trackEvent.getTrack(); if (isClassB.test(track) || isUnknownTypeOrSize.test(track) || isFishingVessel.test(track) || isSmallVessel.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; } Long cellId = (Long) track.getProperty(Track.CELL_ID); Integer shipType = track.getShipType(); Integer shipLength = track.getVesselLength(); if (cellId == null) { statisticsService.incAnalysisStatistics(getAnalysisName(), "Unknown mmsi"); return; } if (shipType == null) { statisticsService.incAnalysisStatistics(getAnalysisName(), "Unknown ship type"); return; } if (shipLength == null) { statisticsService.incAnalysisStatistics(getAnalysisName(), "Unknown ship length"); return; } if (shipLength < SHIP_LENGTH_MIN) { statisticsService.incAnalysisStatistics(getAnalysisName(), "LOA < " + SHIP_LENGTH_MIN); return; } int shipTypeKey = Categorizer.mapShipTypeToCategory(shipType) - 1; int shipLengthKey = Categorizer.mapShipLengthToCategory(shipLength) - 1; if (isAbnormalCellForShipTypeAndSize(cellId, shipTypeKey, shipLengthKey)) { getBehaviourManager().abnormalBehaviourDetected(ShipSizeOrTypeEvent.class, track); } else { getBehaviourManager().normalBehaviourDetected(ShipSizeOrTypeEvent.class, track); } } @Inject  ShipTypeAndSizeAnalysis(Configuration configuration, AppStatisticsService statisticsService, StatisticDataRepository statisticsRepository, EventEmittingTracker trackingService, EventRepository eventRepository, BehaviourManager behaviourManager); @Override String toString(); @AllowConcurrentEvents @Subscribe void onCellIdChanged(CellChangedEvent trackEvent); @AllowConcurrentEvents @Subscribe void onTrackStale(TrackStaleEvent trackEvent); @Subscribe void onAbnormalEventRaise(AbnormalEventRaise behaviourEvent); @Subscribe void onAbnormalEventMaintain(AbnormalEventMaintain behaviourEvent); @Subscribe void onAbnormalEventLower(AbnormalEventLower behaviourEvent); }
ShipTypeAndSizeAnalysis extends StatisticBasedAnalysis { @AllowConcurrentEvents @Subscribe public void onCellIdChanged(CellChangedEvent trackEvent) { statisticsService.incAnalysisStatistics(getAnalysisName(), "Events received"); Track track = trackEvent.getTrack(); if (isClassB.test(track) || isUnknownTypeOrSize.test(track) || isFishingVessel.test(track) || isSmallVessel.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; } Long cellId = (Long) track.getProperty(Track.CELL_ID); Integer shipType = track.getShipType(); Integer shipLength = track.getVesselLength(); if (cellId == null) { statisticsService.incAnalysisStatistics(getAnalysisName(), "Unknown mmsi"); return; } if (shipType == null) { statisticsService.incAnalysisStatistics(getAnalysisName(), "Unknown ship type"); return; } if (shipLength == null) { statisticsService.incAnalysisStatistics(getAnalysisName(), "Unknown ship length"); return; } if (shipLength < SHIP_LENGTH_MIN) { statisticsService.incAnalysisStatistics(getAnalysisName(), "LOA < " + SHIP_LENGTH_MIN); return; } int shipTypeKey = Categorizer.mapShipTypeToCategory(shipType) - 1; int shipLengthKey = Categorizer.mapShipLengthToCategory(shipLength) - 1; if (isAbnormalCellForShipTypeAndSize(cellId, shipTypeKey, shipLengthKey)) { getBehaviourManager().abnormalBehaviourDetected(ShipSizeOrTypeEvent.class, track); } else { getBehaviourManager().normalBehaviourDetected(ShipSizeOrTypeEvent.class, track); } } @Inject  ShipTypeAndSizeAnalysis(Configuration configuration, AppStatisticsService statisticsService, StatisticDataRepository statisticsRepository, EventEmittingTracker trackingService, EventRepository eventRepository, BehaviourManager behaviourManager); @Override String toString(); @AllowConcurrentEvents @Subscribe void onCellIdChanged(CellChangedEvent trackEvent); @AllowConcurrentEvents @Subscribe void onTrackStale(TrackStaleEvent trackEvent); @Subscribe void onAbnormalEventRaise(AbnormalEventRaise behaviourEvent); @Subscribe void onAbnormalEventMaintain(AbnormalEventMaintain behaviourEvent); @Subscribe void onAbnormalEventLower(AbnormalEventLower behaviourEvent);  }