@Test public void save_existingRing() { 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.put(CASSANDRA_ID, instance)).andStubReturn(null); replayAll(); dao.save(RING_NAME, instance); }
@Override public void save(String ringName, CassandraInstance instance) { LOG.info("Saving instance: {}", instance); if (!rings.containsKey(ringName)) { rings.put(ringName, Maps.<Integer, CassandraInstance>newHashMap()); } rings.get(ringName).put(instance.getId(), instance); }
MemoryCassandraInstanceDao implements CassandraInstanceDao { @Override public void save(String ringName, CassandraInstance instance) { LOG.info("Saving instance: {}", instance); if (!rings.containsKey(ringName)) { rings.put(ringName, Maps.<Integer, CassandraInstance>newHashMap()); } rings.get(ringName).put(instance.getId(), instance); } }
MemoryCassandraInstanceDao implements CassandraInstanceDao { @Override public void save(String ringName, CassandraInstance instance) { LOG.info("Saving instance: {}", instance); if (!rings.containsKey(ringName)) { rings.put(ringName, Maps.<Integer, CassandraInstance>newHashMap()); } rings.get(ringName).put(instance.getId(), instance); } MemoryCassandraInstanceDao(); @VisibleForTesting  MemoryCassandraInstanceDao(
      ConcurrentMap<String, Map<Integer, CassandraInstance>> rings); }
MemoryCassandraInstanceDao implements CassandraInstanceDao { @Override public void save(String ringName, CassandraInstance instance) { LOG.info("Saving instance: {}", instance); if (!rings.containsKey(ringName)) { rings.put(ringName, Maps.<Integer, CassandraInstance>newHashMap()); } rings.get(ringName).put(instance.getId(), instance); } 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); }
MemoryCassandraInstanceDao implements CassandraInstanceDao { @Override public void save(String ringName, CassandraInstance instance) { LOG.info("Saving instance: {}", instance); if (!rings.containsKey(ringName)) { rings.put(ringName, Maps.<Integer, CassandraInstance>newHashMap()); } rings.get(ringName).put(instance.getId(), instance); } 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);  }