### Question:
SimonManagerMXBeanImpl implements SimonManagerMXBean { @Override public List<CounterSample> getCounterSamples(String namePattern) { List<CounterSample> counterSamples = new ArrayList<>(); for (Simon simon : manager.getSimons(SimonPattern.createForCounter(namePattern))) { counterSamples.add(sampleCounter(simon)); } return counterSamples; } SimonManagerMXBeanImpl(Manager manager); @Override final void enable(); @Override final void disable(); @Override final boolean isEnabled(); @Override final String[] getSimonNames(); @Override final String[] getSimonNamesOrdered(); @Override final String getType(String name); @Override final SimonInfo[] getSimonInfos(); @Override final void clearManager(); @Override final void enableSimon(String name); @Override final void disableSimon(String name); @Override final void inheritState(String name); @Override final CounterSample getCounterSample(String name); @Override CounterSample getIncrementCounterSample(String name, String key); @Override List<CounterSample> getCounterSamples(String namePattern); @Override List<CounterSample> getIncrementCounterSamples(String namePattern, String key); @Override List<CounterSample> getCounterSamples(); @Override List<CounterSample> getIncrementCounterSamples(String key); @Override final StopwatchSample getStopwatchSample(String name); @Override StopwatchSample getIncrementStopwatchSample(String name, String key); @Override List<StopwatchSample> getStopwatchSamples(String namePattern); @Override List<StopwatchSample> getIncrementStopwatchSamples(String namePattern, String key); @Override List<StopwatchSample> getStopwatchSamples(); @Override List<StopwatchSample> getIncrementStopwatchSamples(String key); @Override final void printSimonTree();  }### Answer:
@Test public void testGetCounterSamples() { List<CounterSample> samples = managerMXBean.getCounterSamples(); assertEquals(samples.size(), 2); verify(counterA).sample(); verify(counterB).sample(); }
@Test public void testGetCounterSamplesForPattern() { List<CounterSample> samples = managerMXBean.getCounterSamples(COUNTER_PATTERN); verify(counterA).sample(); verify(counterB, times(0)).sample(); assertEquals(samples.size(), 1); assertEquals(samples.get(0).getCounter(), 1); }