### Question:
DumpStore { void dumpHex( RECORD record, ByteBuffer buffer, long id, int size ) { printer.withLineNumberOffset( id * size ); if ( record.inUse() ) { printer.append( buffer ); } else if ( allZero( buffer ) ) { out.printf( ": all zeros @ 0x%x - 0x%x", id * size, (id + 1) * size ); } else { printer.append( buffer ); } out.printf( "%n" ); } protected  DumpStore( PrintStream out ); static void main( String... args ); final void dump( STORE store, IdRange[] ids );  }### Answer:
@Test void dumpStoreShouldPrintBufferWithContent() { ByteArrayOutputStream outStream = new ByteArrayOutputStream(); PrintStream out = new PrintStream( outStream ); DumpStore dumpStore = new DumpStore( out ); ByteBuffer buffer = ByteBuffer.allocate( 1024 ); for ( byte i = 0; i < 10; i++ ) { buffer.put( i ); } buffer.flip(); AbstractBaseRecord record = Mockito.mock( AbstractBaseRecord.class ); dumpStore.dumpHex( record, buffer, 2, 4 ); assertEquals( format( "@ 0x00000008: 00 01 02 03 04 05 06 07 08 09%n" ), outStream.toString() ); }
@Test void dumpStoreShouldPrintShorterMessageForAllZeroBuffer() { ByteArrayOutputStream outStream = new ByteArrayOutputStream(); PrintStream out = new PrintStream( outStream ); DumpStore dumpStore = new DumpStore( out ); ByteBuffer buffer = ByteBuffer.allocate( 1024 ); AbstractBaseRecord record = Mockito.mock( AbstractBaseRecord.class ); dumpStore.dumpHex( record, buffer, 2, 4 ); assertEquals( format( ": all zeros @ 0x8 - 0xc%n" ), outStream.toString() ); }