### Question:
RepresentationFormatRepository { public OutputFormat outputFormat( List<MediaType> acceptable, URI baseUri, MultivaluedMap<String,String> requestHeaders ) { RepresentationFormat format = forHeaders( acceptable, requestHeaders ); if ( format == null ) { format = forMediaTypes( acceptable ); } if ( format == null ) { format = useDefault( acceptable ); } return new OutputFormat( format, baseUri, getExtensionManager() ); } RepresentationFormatRepository( AbstractNeoServer injectorProvider ); OutputFormat outputFormat( List<MediaType> acceptable, URI baseUri,
            MultivaluedMap<String,String> requestHeaders ); InputFormat inputFormat( MediaType type );  }### Answer:
@Test public void canProvideJsonOutputFormat() { OutputFormat format = repository.outputFormat( asList( MediaType.APPLICATION_JSON_TYPE ), null, null ); assertNotNull( format ); assertEquals( "\"test\"", format.assemble( ValueRepresentation.string( "test" ) ) ); }
@Test public void cannotProvideStreamingForOtherMediaTypes() throws Exception { final Response.ResponseBuilder responseBuilder = mock( Response.ResponseBuilder.class ); when( responseBuilder.entity( any(byte[].class) ) ).thenReturn( responseBuilder ); Mockito.verify( responseBuilder, never() ).entity( isA( StreamingOutput.class ) ); when( responseBuilder.type( ArgumentMatchers.<MediaType>any() ) ).thenReturn( responseBuilder ); when( responseBuilder.build() ).thenReturn( null ); OutputFormat format = repository.outputFormat( asList( MediaType.TEXT_HTML_TYPE ), new URI( "http: assertNotNull( format ); format.response( responseBuilder, new ExceptionRepresentation( new RuntimeException() ) ); }
@Test public void canProvideStreamingJsonOutputFormat() throws Exception { Response response = mock( Response.class ); final AtomicReference<StreamingOutput> ref = new AtomicReference<>(); final Response.ResponseBuilder responseBuilder = mockResponseBuilder( response, ref ); OutputFormat format = repository.outputFormat( asList( MediaType.APPLICATION_JSON_TYPE ), null, streamingHeader() ); assertNotNull( format ); Response returnedResponse = format.response( responseBuilder, new MapRepresentation( map( "a", "test" ) ) ); assertSame( response, returnedResponse ); StreamingOutput streamingOutput = ref.get(); ByteArrayOutputStream baos = new ByteArrayOutputStream(); streamingOutput.write( baos ); assertEquals( "{\"a\":\"test\"}", baos.toString() ); }