### Question:
ResultHandler extends MessageProcessingHandler { @Override public void onRecords( final BoltResult result, final boolean pull ) throws Exception { result.accept( new BoltResult.Visitor() { @Override public void visit( QueryResult.Record record ) throws Exception { if ( pull ) { messageWriter.write( new RecordMessage( record ) ); } } @Override public void addMetadata( String key, AnyValue value ) { onMetadata( key, value ); } } ); } ResultHandler( BoltResponseMessageWriter handler, BoltConnection connection, Log log ); @Override void onRecords( final BoltResult result, final boolean pull );  }### Answer:
@Test void shouldPullTheResult() throws Exception { BoltResponseMessageRecorder messageWriter = new BoltResponseMessageRecorder(); ResultHandler handler = new ResultHandler( messageWriter, mock( BoltConnection.class ), NullLog.getInstance() ); ImmutableRecord record1 = new ImmutableRecord( values( "a", "b", "c" ) ); ImmutableRecord record2 = new ImmutableRecord( values( "1", "2", "3" ) ); BoltResult result = new TestBoltResult( record1, record2 ); handler.onRecords( result, true ); handler.onFinish(); List<ResponseMessage> messages = messageWriter.asList(); assertThat( messages.size(), equalTo( 3 ) ); assertThat( messages.get( 0 ), equalTo( new RecordMessage( record1 ) ) ); assertThat( messages.get( 1 ), equalTo( new RecordMessage( record2 ) ) ); assertThat( messages.get( 2 ), instanceOf( SuccessMessage.class ) ); }
@Test void shouldDiscardTheResult() throws Exception { BoltResponseMessageRecorder messageWriter = new BoltResponseMessageRecorder(); ResultHandler handler = new ResultHandler( messageWriter, mock( BoltConnection.class ), NullLog.getInstance() ); ImmutableRecord record1 = new ImmutableRecord( values( "a", "b", "c" ) ); ImmutableRecord record2 = new ImmutableRecord( values( "1", "2", "3" ) ); BoltResult result = new TestBoltResult( record1, record2 ); handler.onRecords( result, false ); handler.onFinish(); List<ResponseMessage> messages = messageWriter.asList(); assertThat( messages.size(), equalTo( 1 ) ); assertThat( messages.get( 0 ), instanceOf( SuccessMessage.class ) ); }