### Question:
SimonManagerMXBeanImpl implements SimonManagerMXBean { @Override public List<StopwatchSample> getIncrementStopwatchSamples(String namePattern, String key) { List<StopwatchSample> stopwatchSamples = new ArrayList<>(); for (Simon simon : manager.getSimons(SimonPattern.createForStopwatch(namePattern))) { Stopwatch stopwatch = (Stopwatch) simon; stopwatchSamples.add(new StopwatchSample(stopwatch.sampleIncrement(key))); } return stopwatchSamples; } 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 testGetIncrementStopwatchSamplesWithExistingSample() { String key = "key"; when(stopwatchA.sampleIncrement(key)).thenReturn(stopwatchSample(2)); List<StopwatchSample> samples = managerMXBean.getIncrementStopwatchSamples(STOPWATCH_PATTERN, key); assertEquals(samples.size(), 1); assertEquals(samples.get(0).getCounter(), 2); verify(stopwatchA).sampleIncrement(key); }
@Test public void testGetIncrementStopwatchSamplesWithoutPattern() { String key = "key"; when(stopwatchA.sampleIncrement(key)).thenReturn(stopwatchSample(3)); when(stopwatchB.sampleIncrement(key)).thenReturn(stopwatchSample(4)); List<StopwatchSample> samples = managerMXBean.getIncrementStopwatchSamples(key); assertEquals(samples.size(), 2); assertEquals(samples.get(0).getCounter(), 3); assertEquals(samples.get(1).getCounter(), 4); verify(stopwatchA).sampleIncrement(key); verify(stopwatchB).sampleIncrement(key); }