### Question:
StatisticsScanner implements InternalScanner { @Override public void close() throws IOException { boolean async = getConfig().getBoolean(COMMIT_STATS_ASYNC, DEFAULT_COMMIT_STATS_ASYNC); StatisticsCollectionRunTracker collectionTracker = getStatsCollectionRunTracker(config); StatisticsScannerCallable callable = createCallable(); if (isConnectionClosed()) { LOGGER.debug("Not updating table statistics because the server is stopping/stopped"); return; } if (!async) { callable.call(); } else { collectionTracker.runTask(callable); } } StatisticsScanner(StatisticsCollector tracker, StatisticsWriter stats, RegionCoprocessorEnvironment env,
            InternalScanner delegate, ImmutableBytesPtr family); @Override boolean next(List<Cell> result); @Override boolean next(List<Cell> result, ScannerContext scannerContext); @Override void close();  }### Answer:
@Test public void testCheckRegionServerStoppingOnClose() throws Exception { when(conn.isClosed()).thenReturn(true); when(conn.isAborted()).thenReturn(false); mockScanner.close(); verify(conn).isClosed(); verify(callable, never()).call(); verify(runTracker, never()).runTask(callable); }
@Test public void testCheckRegionServerStoppedOnClose() throws Exception { when(conn.isClosed()).thenReturn(false); when(conn.isAborted()).thenReturn(true); mockScanner.close(); verify(conn).isClosed(); verify(conn).isAborted(); verify(callable, never()).call(); verify(runTracker, never()).runTask(callable); }