### Question:
ExecutionResultSerializer { public void finish() { try { ensureDocumentOpen(); if ( currentState != State.ERRORS_WRITTEN ) { errors( Collections.emptyList() ); } out.writeEndObject(); out.flush(); } catch ( IOException e ) { loggedIOException( e ); } } ExecutionResultSerializer( OutputStream output, URI baseUri, LogProvider logProvider,
            TransitionalPeriodTransactionMessContainer container ); void transactionCommitUri( URI commitUri ); void statementResult( Result result, boolean includeStats, ResultDataContent... resultDataContents ); void notifications( Iterable<Notification> notifications ); void errors( Iterable<? extends Neo4jError> errors ); void transactionStatus( long expiryDate ); void finish();  }### Answer:
@Test public void shouldSerializeResponseWithNoCommitUriResultsOrErrors() throws Exception { ByteArrayOutputStream output = new ByteArrayOutputStream(); ExecutionResultSerializer serializer = getSerializerWith( output ); serializer.finish(); String result = output.toString( UTF_8.name() ); assertEquals( "{\"results\":[],\"errors\":[]}", result ); }
@Test public void shouldLogIOErrors() { IOException failure = new IOException(); OutputStream output = mock( OutputStream.class, new ThrowsException( failure ) ); AssertableLogProvider logProvider = new AssertableLogProvider(); ExecutionResultSerializer serializer = getSerializerWith( output, null, logProvider ); serializer.finish(); logProvider.assertExactly( AssertableLogProvider.inLog( ExecutionResultSerializer.class ).error( is( "Failed to generate JSON output." ), sameInstance( failure ) ) ); }
@Test public void shouldAbbreviateWellKnownIOErrors() { OutputStream output = mock( OutputStream.class, new ThrowsException( new IOException( "Broken pipe" ) ) ); AssertableLogProvider logProvider = new AssertableLogProvider(); ExecutionResultSerializer serializer = getSerializerWith( output, null, logProvider ); serializer.finish(); logProvider.assertExactly( AssertableLogProvider.inLog( ExecutionResultSerializer.class ) .error( "Unable to reply to request, because the client has closed the connection (Broken pipe)." ) ); }