CounterGroup { public synchronized Long incrementAndGet(String name) { return getCounter(name).incrementAndGet(); } 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 testIncrementAndGet() { long value = counterGroup.incrementAndGet("test"); Assert.assertEquals(1, value); }