### Question:
PeerStore implements ReadWriterStore<PeerId, Peer> { public void overwrite(List<Peer> peerList) { lock.lock(); try { for (int i = 1; i <= peerSize; i++) { byte[] indexKey = getIndexKey(i); byte[] key = db.get(indexKey); if (key != null) { db.delete(key); } } peerSize = 0L; peerList.forEach(peer -> put(peer.getPeerId(), peer)); } finally { lock.unlock(); } } PeerStore(DbSource<byte[], byte[]> dbSource); @Override void put(PeerId key, Peer value); @Override Peer get(PeerId key); @Override boolean contains(PeerId key); void overwrite(List<Peer> peerList); @Override void close(); void remove(PeerId key); List<String> getAll(); long size();  }### Answer:
@Test public void overwrite() { Peer p1 = Peer.valueOf("ynode: Peer p2 = Peer.valueOf("ynode: peerStore.put(p1.getPeerId(), p1); peerStore.put(p2.getPeerId(), p2); assertEquals(2, peerStore.getAll().size()); assertTrue(peerStore.contains(p1.getPeerId())); assertTrue(peerStore.contains(p2.getPeerId())); Peer p3 = Peer.valueOf("ynode: Peer p4 = Peer.valueOf("ynode: Peer p5 = Peer.valueOf("ynode: List<Peer> peerList = new ArrayList<>(); peerList.add(p3); peerList.add(p4); peerList.add(p5); peerStore.overwrite(peerList); assertEquals(3, peerStore.getAll().size()); assertFalse(peerStore.contains(p1.getPeerId())); assertFalse(peerStore.contains(p2.getPeerId())); assertTrue(peerStore.contains(p3.getPeerId())); assertTrue(peerStore.contains(p4.getPeerId())); assertTrue(peerStore.contains(p5.getPeerId())); }