### Question:
StopWatch extends ThresholdWatch implements StopWatchMBean { public void setElapsedTime(long elapsed) { setElapsedTime(elapsed, System.currentTimeMillis()); } StopWatch(String id);  StopWatch(String id, Configuration config); @SuppressWarnings("unused")  StopWatch(WatchDataSource watchDataSource, String id); void startTiming(); void stopTiming(); void stopTiming(String detail); void setElapsedTime(long elapsed); void setElapsedTime(long elapsed, String detail); void setElapsedTime(long elapsed, long now); void setElapsedTime(long elapsed, long now, String detail); long getStartTime(); void setStartTime(long startTime); static final String VIEW; }### Answer:
@Test public void testSetElapsedTime1() throws RemoteException { StopWatch watch = new StopWatch("watch"); List<Long> expected = new ArrayList<Long>(); checkData(expected, watch); for (int i = 0; i < 10; i++) { long value = Math.round(Math.random() * 100); watch.setElapsedTime(value); expected.add(value); checkData(expected, watch); } Utils.close(watch.getWatchDataSource()); }
@Test public void testSetElapsedTime2() throws RemoteException { StopWatch watch = new StopWatch("watch"); List<Long> expectedValues = new ArrayList<Long>(); List<Long> expectedStamps = new ArrayList<Long>(); checkData(expectedValues, expectedStamps, watch); for (int i = 0; i < 10; i++) { long value = Math.round(Math.random() * 100); long stamp = Math.round(Math.random() * 100); watch.setElapsedTime(value, stamp); expectedValues.add(value); expectedStamps.add(stamp); checkData(expectedValues, expectedStamps, watch); } Utils.close(watch.getWatchDataSource()); }