### Question:
PeerBucket { synchronized Peer replace(Peer last) { if (peers.isEmpty() || getLastPeer() != last) { return null; } if (replacements.isEmpty()) { dropPeer(last); return null; } Peer peerToBeReplaced = lastPeerOf(replacements); deleteReplacement(peerToBeReplaced); dropPeer(last); addPeer(peerToBeReplaced); return peerToBeReplaced; } PeerBucket(int depth); int getPeersCount(); synchronized void bump(Peer peer);  }### Answer:
@Test public void testReplace() { KademliaOptions.BUCKET_SIZE = 5; addPeerToBucket(32920, 32925); Peer randomPeer = Peer.valueOf("ynode: assertNull(bucket.replace(randomPeer)); assertEquals(5, bucket.getPeersCount()); assertTrue(getLastPeer(Peer.valueOf("ynode: assertNull(bucket.replace(bucket.getLastPeer())); assertEquals(4, bucket.getPeersCount()); assertTrue(getLastPeer(Peer.valueOf("ynode: addPeerToBucket(32924, 32930); assertEquals(5, bucket.getReplacements().size()); assertEquals(bucket.replace(bucket.getLastPeer()), Peer.valueOf("ynode: printList(bucket.getReplacements(), "replace"); printList(bucket.getPeers(), "p"); assertEquals(4, bucket.getReplacements().size()); assertTrue(getLastPeer(Peer.valueOf("ynode: }