CounterGroup { public synchronized AtomicLong getCounter(String name) { if (!counters.containsKey(name)) { counters.put(name, new AtomicLong()); } return counters.get(name); } CounterGroup(); synchronized Long get(String name); synchronized Long incrementAndGet(String name); synchronized Long addAndGet(String name, Long delta); synchronized void add(CounterGroup counterGroup); synchronized void set(String name, Long value); synchronized AtomicLong getCounter(String name); @Override synchronized String toString(); synchronized String getName(); synchronized void setName(String name); synchronized HashMap<String, AtomicLong> getCounters(); synchronized void setCounters(HashMap<String, AtomicLong> counters);  }
@Test public void testGetCounter() { AtomicLong counter = counterGroup.getCounter("test"); Assert.assertNotNull(counter); Assert.assertEquals(0, counter.get()); }