### Question:
SizeBasedLogPruningStrategy implements CoreLogPruningStrategy, Visitor<SegmentFile,RuntimeException> { @Override public synchronized long getIndexToKeep( Segments segments ) { accumulatedSize = 0; file = null; segments.visitBackwards( this ); return file != null ? (file.header().prevIndex() + 1) : -1; } SizeBasedLogPruningStrategy( long bytesToKeep ); @Override synchronized long getIndexToKeep( Segments segments ); @Override boolean visit( SegmentFile segment );  }### Answer:
@Test public void indexToKeepTest() { int segmentFilesCount = 14; int bytesToKeep = 6; int expectedIndex = segmentFilesCount - bytesToKeep; files = createSegmentFiles( segmentFilesCount ); SizeBasedLogPruningStrategy sizeBasedLogPruningStrategy = new SizeBasedLogPruningStrategy( bytesToKeep ); long indexToKeep = sizeBasedLogPruningStrategy.getIndexToKeep( segments ); assertEquals( expectedIndex, indexToKeep ); }