@Test public void testReceiveEvent() { receiver.receiveEvent(event); Mockito.verify(receiver).receiveEvent(event); }
@Override public synchronized void receiveEvent(LoggableEvent event) { byte[] prevHash = lastHashByKey.get(event.getKey()); byte[] newHash = hash(event.getData()); boolean changed = (prevHash == null || !Arrays.equals(prevHash, newHash)); if (changed) { nextReceiver.receiveEvent(event); lastHashByKey.put(event.getKey(), newHash); } }
EventDeduplicater implements EventReceiver { @Override public synchronized void receiveEvent(LoggableEvent event) { byte[] prevHash = lastHashByKey.get(event.getKey()); byte[] newHash = hash(event.getData()); boolean changed = (prevHash == null || !Arrays.equals(prevHash, newHash)); if (changed) { nextReceiver.receiveEvent(event); lastHashByKey.put(event.getKey(), newHash); } } }
EventDeduplicater implements EventReceiver { @Override public synchronized void receiveEvent(LoggableEvent event) { byte[] prevHash = lastHashByKey.get(event.getKey()); byte[] newHash = hash(event.getData()); boolean changed = (prevHash == null || !Arrays.equals(prevHash, newHash)); if (changed) { nextReceiver.receiveEvent(event); lastHashByKey.put(event.getKey(), newHash); } } EventDeduplicater(EventReceiver nextReceiver); }
EventDeduplicater implements EventReceiver { @Override public synchronized void receiveEvent(LoggableEvent event) { byte[] prevHash = lastHashByKey.get(event.getKey()); byte[] newHash = hash(event.getData()); boolean changed = (prevHash == null || !Arrays.equals(prevHash, newHash)); if (changed) { nextReceiver.receiveEvent(event); lastHashByKey.put(event.getKey(), newHash); } } EventDeduplicater(EventReceiver nextReceiver); @Override synchronized void receiveEvent(LoggableEvent event); @Override void close(); }
EventDeduplicater implements EventReceiver { @Override public synchronized void receiveEvent(LoggableEvent event) { byte[] prevHash = lastHashByKey.get(event.getKey()); byte[] newHash = hash(event.getData()); boolean changed = (prevHash == null || !Arrays.equals(prevHash, newHash)); if (changed) { nextReceiver.receiveEvent(event); lastHashByKey.put(event.getKey(), newHash); } } EventDeduplicater(EventReceiver nextReceiver); @Override synchronized void receiveEvent(LoggableEvent event); @Override void close();  }