### Question:
CountingPeerPruningFunction implements PeerPruning { @Override public boolean prunePeer(Peer peer) { Integer currentValue = countingOccurrences.putIfAbsent(peer, 1); if (currentValue != null) { if (currentValue + 1 >= numberOfOccurrences) { countingOccurrences.remove(peer); return true; } countingOccurrences.put(peer, currentValue + 1); } return false; } CountingPeerPruningFunction(int numberOfOccurrences); @Override boolean prunePeer(Peer peer);  }### Answer:
@Test void testPruning() { CountingPeerPruningFunction fn = new CountingPeerPruningFunction(3); Peer peer = new Peer() {}; assertFalse(fn.prunePeer(peer)); assertFalse(fn.prunePeer(peer)); assertTrue(fn.prunePeer(peer)); }