@Test public void testLastReport24HoursOld(){ Date lastReport = new Date(System.currentTimeMillis() - 1000*3600*24); Duration duration = Duration.parse("P2D"); TargetInfo targetInfo = createTargetInfo(lastReport); LastReportFilter filter = new LastReportFilter(duration); Assert.assertFalse(filter.test(null, targetInfo)); }
public boolean test(AisPacketSource source, TargetInfo targetInfo) { if(targetInfo.getAisTarget() == null || targetInfo.getAisTarget().getLastReport() == null){ return false; } long currentTime = System.currentTimeMillis(); long ageInSeconds = (currentTime - targetInfo.getAisTarget().getLastReport().getTime()) / 1000; if(ageInSeconds < 0) { return ageInSeconds < duration.negated().getSeconds(); } return ageInSeconds > duration.getSeconds(); }
LastReportFilter implements BiPredicate<AisPacketSource, TargetInfo> { public boolean test(AisPacketSource source, TargetInfo targetInfo) { if(targetInfo.getAisTarget() == null || targetInfo.getAisTarget().getLastReport() == null){ return false; } long currentTime = System.currentTimeMillis(); long ageInSeconds = (currentTime - targetInfo.getAisTarget().getLastReport().getTime()) / 1000; if(ageInSeconds < 0) { return ageInSeconds < duration.negated().getSeconds(); } return ageInSeconds > duration.getSeconds(); } }
LastReportFilter implements BiPredicate<AisPacketSource, TargetInfo> { public boolean test(AisPacketSource source, TargetInfo targetInfo) { if(targetInfo.getAisTarget() == null || targetInfo.getAisTarget().getLastReport() == null){ return false; } long currentTime = System.currentTimeMillis(); long ageInSeconds = (currentTime - targetInfo.getAisTarget().getLastReport().getTime()) / 1000; if(ageInSeconds < 0) { return ageInSeconds < duration.negated().getSeconds(); } return ageInSeconds > duration.getSeconds(); } LastReportFilter(Duration duration); }
LastReportFilter implements BiPredicate<AisPacketSource, TargetInfo> { public boolean test(AisPacketSource source, TargetInfo targetInfo) { if(targetInfo.getAisTarget() == null || targetInfo.getAisTarget().getLastReport() == null){ return false; } long currentTime = System.currentTimeMillis(); long ageInSeconds = (currentTime - targetInfo.getAisTarget().getLastReport().getTime()) / 1000; if(ageInSeconds < 0) { return ageInSeconds < duration.negated().getSeconds(); } return ageInSeconds > duration.getSeconds(); } LastReportFilter(Duration duration); boolean test(AisPacketSource source, TargetInfo targetInfo); }
LastReportFilter implements BiPredicate<AisPacketSource, TargetInfo> { public boolean test(AisPacketSource source, TargetInfo targetInfo) { if(targetInfo.getAisTarget() == null || targetInfo.getAisTarget().getLastReport() == null){ return false; } long currentTime = System.currentTimeMillis(); long ageInSeconds = (currentTime - targetInfo.getAisTarget().getLastReport().getTime()) / 1000; if(ageInSeconds < 0) { return ageInSeconds < duration.negated().getSeconds(); } return ageInSeconds > duration.getSeconds(); } LastReportFilter(Duration duration); boolean test(AisPacketSource source, TargetInfo targetInfo);  }