DeltaFIFO implements Store<Object> { @Override public void resync() { lock.writeLock().lock(); try { if (this.knownObjects == null) { return; } List<String> keys = this.knownObjects.listKeys(); for (String key : keys) { syncKeyLocked(key); } } finally { lock.writeLock().unlock(); } } DeltaFIFO(Function<T, String> keyFunc, Store knownObjects); @Override void add(Object obj); @Override void update(Object obj); @Override void delete(Object obj); @Override void replace(List list, String resourceVersion); @Override void resync(); @Override List<String> listKeys(); @Override Object get(Object obj); @Override Deque<AbstractMap.SimpleEntry<DeltaType, Object>> getByKey(String key); @Override List<Object> list(); Deque<AbstractMap.SimpleEntry<DeltaType, Object>> pop(Consumer<Deque<AbstractMap.SimpleEntry<DeltaType, Object>>> func); boolean hasSynced(); @Override void isPopulated(boolean isPopulated);  }
@Test void testResync() { Pod foo1 = new PodBuilder().withNewMetadata().withName("foo1").withNamespace("default").endMetadata().build(); Cache cache = new Cache(); DeltaFIFO<Pod> deltaFIFO = new DeltaFIFO<>(Cache::deletionHandlingMetaNamespaceKeyFunc, cache); cache.add(foo1); deltaFIFO.resync(); Deque<AbstractMap.SimpleEntry<DeltaFIFO.DeltaType, Object>> deltas = deltaFIFO.getItems().get(Cache.deletionHandlingMetaNamespaceKeyFunc(foo1)); assertEquals(1, deltas.size()); assertEquals(foo1, deltas.peekLast().getValue()); assertEquals(DeltaFIFO.DeltaType.SYNCHRONIZATION, deltas.peekLast().getKey()); }