@Test public void testAisTargetNull(){ TargetInfo targetInfo = Mockito.mock(TargetInfo.class); Mockito.when(targetInfo.getAisTarget()).thenReturn(null); LastReportFilter filter = new LastReportFilter(Duration.ZERO); 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);  }