CounterGroup { public synchronized Long addAndGet(String name, Long delta) { return getCounter(name).addAndGet(delta); } 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 testAddAndGet() { long value = counterGroup.addAndGet("test", 13L); Assert.assertEquals(13, value); }