@Test public void applyExponentialBackOffToListOfDevicesWithCommunicationTimestampYoungerThan2HoursAnd2ConnectionFailures() { final List<Device> devices = new ArrayList<>(); devices.add(this.createDevice("device-08", DateTime.now(DateTimeZone.UTC).minusHours(2).plusMinutes(1).toDate(), 2)); final List<Device> filteredList = this.task.filterByExponentialBackOff(devices); assertThat(filteredList.size()).isEqualTo(0); }
public List<Device> filterByExponentialBackOff(final List<Device> devicesToFilter) { final Predicate<Device> hasNoConnectionFailure = d -> !d.hasConnectionFailures(); final Predicate<Device> hasLastConnectionFailureBeforeThreshold = d -> this.calculateThresholdForDevice(d); return devicesToFilter.stream().filter(hasNoConnectionFailure.or(hasLastConnectionFailureBeforeThreshold)) .collect(Collectors.<Device> toList()); }
EventRetrievalScheduledTask extends BaseTask implements Runnable { public List<Device> filterByExponentialBackOff(final List<Device> devicesToFilter) { final Predicate<Device> hasNoConnectionFailure = d -> !d.hasConnectionFailures(); final Predicate<Device> hasLastConnectionFailureBeforeThreshold = d -> this.calculateThresholdForDevice(d); return devicesToFilter.stream().filter(hasNoConnectionFailure.or(hasLastConnectionFailureBeforeThreshold)) .collect(Collectors.<Device> toList()); } }
EventRetrievalScheduledTask extends BaseTask implements Runnable { public List<Device> filterByExponentialBackOff(final List<Device> devicesToFilter) { final Predicate<Device> hasNoConnectionFailure = d -> !d.hasConnectionFailures(); final Predicate<Device> hasLastConnectionFailureBeforeThreshold = d -> this.calculateThresholdForDevice(d); return devicesToFilter.stream().filter(hasNoConnectionFailure.or(hasLastConnectionFailureBeforeThreshold)) .collect(Collectors.<Device> toList()); }  }
EventRetrievalScheduledTask extends BaseTask implements Runnable { public List<Device> filterByExponentialBackOff(final List<Device> devicesToFilter) { final Predicate<Device> hasNoConnectionFailure = d -> !d.hasConnectionFailures(); final Predicate<Device> hasLastConnectionFailureBeforeThreshold = d -> this.calculateThresholdForDevice(d); return devicesToFilter.stream().filter(hasNoConnectionFailure.or(hasLastConnectionFailureBeforeThreshold)) .collect(Collectors.<Device> toList()); }  @Override void run(); List<Device> filterByExponentialBackOff(final List<Device> devicesToFilter); }
EventRetrievalScheduledTask extends BaseTask implements Runnable { public List<Device> filterByExponentialBackOff(final List<Device> devicesToFilter) { final Predicate<Device> hasNoConnectionFailure = d -> !d.hasConnectionFailures(); final Predicate<Device> hasLastConnectionFailureBeforeThreshold = d -> this.calculateThresholdForDevice(d); return devicesToFilter.stream().filter(hasNoConnectionFailure.or(hasLastConnectionFailureBeforeThreshold)) .collect(Collectors.<Device> toList()); }  @Override void run(); List<Device> filterByExponentialBackOff(final List<Device> devicesToFilter);  }