@Test void testNotificationHandling() throws InterruptedException { Pod pod = new PodBuilder().withNewMetadata().withName("foo").withNamespace("default").endMetadata().build(); ProcessorListener<Pod> listener = new ProcessorListener<>( new ResourceEventHandler<Pod>() { @Override public void onAdd(Pod obj) { assertEquals(pod, obj); addNotificationReceived = true; } @Override public void onUpdate(Pod oldObj, Pod newObj) { assertEquals(pod, newObj); updateNotificationReceived = true; } @Override public void onDelete(Pod obj, boolean deletedFinalStateUnknown) { assertEquals(pod, obj); deleteNotificationReceived = true; } }, 0); listener.add(new ProcessorListener.AddNotification<>(pod)); listener.add(new ProcessorListener.UpdateNotification<>(null, pod)); listener.add(new ProcessorListener.DeleteNotification<>(pod)); Thread listenerThread = new Thread(listener::run); listenerThread.setDaemon(true); listenerThread.start(); Thread.sleep(1000); assertTrue(addNotificationReceived); assertTrue(updateNotificationReceived); assertTrue(deleteNotificationReceived); }
public void add(Notification<T> obj) { Optional.ofNullable(obj).ifPresent(this.queue::add); }
ProcessorListener implements Runnable { public void add(Notification<T> obj) { Optional.ofNullable(obj).ifPresent(this.queue::add); } }
ProcessorListener implements Runnable { public void add(Notification<T> obj) { Optional.ofNullable(obj).ifPresent(this.queue::add); } ProcessorListener(ResourceEventHandler<T> handler, long resyncPeriodInMillis); }
ProcessorListener implements Runnable { public void add(Notification<T> obj) { Optional.ofNullable(obj).ifPresent(this.queue::add); } ProcessorListener(ResourceEventHandler<T> handler, long resyncPeriodInMillis); @Override void run(); void add(Notification<T> obj); void determineNextResync(ZonedDateTime now); boolean shouldResync(ZonedDateTime now); }
ProcessorListener implements Runnable { public void add(Notification<T> obj) { Optional.ofNullable(obj).ifPresent(this.queue::add); } ProcessorListener(ResourceEventHandler<T> handler, long resyncPeriodInMillis); @Override void run(); void add(Notification<T> obj); void determineNextResync(ZonedDateTime now); boolean shouldResync(ZonedDateTime now);  }