### Question:
VerbosePageCacheTracer extends DefaultPageCacheTracer { @Override public MajorFlushEvent beginFileFlush( PageSwapper swapper ) { String fileName = swapper.file().getName(); log.info( format( "Flushing file: '%s'.", fileName ) ); return new FileFlushEvent( fileName, flushedPages.get(), flushBytesWritten.get(), clock.nanos() ); } VerbosePageCacheTracer( Log log, SystemNanoClock clock ); @Override void mappedFile( File file ); @Override void unmappedFile( File file ); @Override MajorFlushEvent beginCacheFlush(); @Override MajorFlushEvent beginFileFlush( PageSwapper swapper );  }### Answer:
@Test public void traceFileFlush() { VerbosePageCacheTracer tracer = createTracer(); DummyPageSwapper swapper = new DummyPageSwapper( "fileToFlush", 1 ); try ( MajorFlushEvent fileToFlush = tracer.beginFileFlush( swapper ) ) { FlushEventOpportunity flushEventOpportunity = fileToFlush.flushEventOpportunity(); FlushEvent flushEvent = flushEventOpportunity.beginFlush( 1, 2, swapper ); flushEvent.addPagesFlushed( 100 ); flushEvent.addBytesWritten( ByteUnit.ONE_MEBI_BYTE ); flushEvent.done(); clock.forward( 1, TimeUnit.SECONDS ); FlushEvent flushEvent2 = flushEventOpportunity.beginFlush( 1, 2, swapper ); flushEvent2.addPagesFlushed( 10 ); flushEvent2.addBytesWritten( ByteUnit.ONE_MEBI_BYTE ); flushEvent2.done(); } logProvider.formattedMessageMatcher().assertContains( "Flushing file: 'fileToFlush'." ); logProvider.formattedMessageMatcher().assertContains( "'fileToFlush' flush completed. " + "Flushed 2.000MiB in 110 pages. Flush took: 1s. Average speed: 2.000MiB/s." ); }