### Question:
MemoryCassandraInstanceDao implements CassandraInstanceDao { @Override public void delete(String ringName, CassandraInstance instance) { LOG.info("Deleting instance: {}", instance); if (rings.containsKey(ringName)) { rings.get(ringName).remove(instance.getId()); } } MemoryCassandraInstanceDao(); @VisibleForTesting  MemoryCassandraInstanceDao(
      ConcurrentMap<String, Map<Integer, CassandraInstance>> rings); @Override ImmutableSet<CassandraInstance> findAll(String ring); @Override @Nullable CassandraInstance findById(String ring, int id); @Override void save(String ringName, CassandraInstance instance); @Override void delete(String ringName, CassandraInstance instance);  }### Answer:
@Test public void delete() { CassandraInstance instance = createMock(CassandraInstance.class); @SuppressWarnings("unchecked") Map<Integer, CassandraInstance> instanceMap = createMock(Map.class); expect(instance.getId()).andStubReturn(CASSANDRA_ID); expect(rings.containsKey(RING_NAME)).andStubReturn(true); expect(rings.get(RING_NAME)).andStubReturn(instanceMap); expect(instanceMap.remove(CASSANDRA_ID)).andStubReturn(null); replayAll(); dao.delete(RING_NAME, instance); }