### Question:
LastSplitsCallback extends CallbackSkeleton { private LastSplits getLastSplits(Stopwatch stopwatch) { return (LastSplits) stopwatch.getAttribute(ATTR_NAME_LAST_SPLITS); } LastSplitsCallback();  LastSplitsCallback(int capacity); @Override void onSimonCreated(Simon simon); @Override void onStopwatchStop(Split split, StopwatchSample sample); @Override void onStopwatchAdd(Stopwatch stopwatch, Split split, StopwatchSample sample); boolean isLogEnabled(); void setLogEnabled(boolean logEnabled); static final String ATTR_NAME_LAST_SPLITS; }### Answer:
@Test public void testAddSplit() { addSplit(100L); addSplit(150L); addSplit(125L); addSplit(150L); LastSplits lastSplits = getLastSplits(); assertEquals(100L, lastSplits.getMin().longValue()); assertEquals(150L, lastSplits.getMax().longValue()); assertEquals((150 * 2 + 125 + 100) / 4L, lastSplits.getMean().longValue()); }
@Test public void testTrend() { addSplit(100L); addSplit(125L); addSplit(150L); LastSplits lastSplits = getLastSplits(); assertTrue(lastSplits.getTrend() > 0, "Positive trend"); resetManager(); addSplit(150L); addSplit(125L); addSplit(100L); lastSplits = getLastSplits(); assertTrue(lastSplits.getTrend() < 0, "Negative trend"); }