### Question:
RecordScanner extends ConsistencyCheckerTask { @Override public void run() { statistics.reset(); if ( warmUpStores != null ) { for ( IterableStore store : warmUpStores ) { store.warmUpCache(); } } try { scan(); } finally { try { store.close(); } catch ( Exception e ) { progress.failed( e ); throw new RuntimeException( e ); } finally { processor.close(); progress.done(); } } statistics.print( name ); } RecordScanner( String name, Statistics statistics, int threads, BoundedIterable<RECORD> store,
            ProgressMonitorFactory.MultiPartBuilder builder, RecordProcessor<RECORD> processor,
            IterableStore... warmUpStores ); @Override void run();  }### Answer:
@Test void shouldProcessRecordsSequentiallyAndUpdateProgress() throws Exception { ProgressMonitorFactory.MultiPartBuilder progressBuilder = mock( ProgressMonitorFactory.MultiPartBuilder.class ); ProgressListener progressListener = mock( ProgressListener.class ); when( progressBuilder.progressForPart( anyString(), anyLong() ) ).thenReturn( progressListener ); @SuppressWarnings( "unchecked" ) BoundedIterable<Integer> store = mock( BoundedIterable.class ); when( store.iterator() ).thenReturn( asList( 42, 75, 192 ).iterator() ); @SuppressWarnings( "unchecked" ) RecordProcessor<Integer> recordProcessor = mock( RecordProcessor.class ); RecordScanner<Integer> scanner = new SequentialRecordScanner<>( "our test task", Statistics.NONE, 1, store, progressBuilder, recordProcessor ); scanner.run(); verifyProcessCloseAndDone( recordProcessor, store, progressListener ); }
@Test void shouldProcessRecordsParallelAndUpdateProgress() throws Exception { ProgressMonitorFactory.MultiPartBuilder progressBuilder = mock( ProgressMonitorFactory.MultiPartBuilder.class ); ProgressListener progressListener = mock( ProgressListener.class ); when( progressBuilder.progressForPart( anyString(), anyLong() ) ).thenReturn( progressListener ); @SuppressWarnings( "unchecked" ) BoundedIterable<Integer> store = mock( BoundedIterable.class ); when( store.iterator() ).thenReturn( asList( 42, 75, 192 ).iterator() ); @SuppressWarnings( "unchecked" ) RecordProcessor<Integer> recordProcessor = mock( RecordProcessor.class ); RecordScanner<Integer> scanner = new ParallelRecordScanner<>( "our test task", Statistics.NONE, 1, store, progressBuilder, recordProcessor, CacheAccess.EMPTY, QueueDistribution.ROUND_ROBIN ); scanner.run(); verifyProcessCloseAndDone( recordProcessor, store, progressListener ); }