JsonServiceDocumentRenderer extends ServiceDocumentRenderer { @Override public void render(ODataRequestContext requestContext, QueryResult data, ODataResponse.Builder responseBuilder) throws ODataException { LOG.debug("Start rendering entity(es) for request: {}", requestContext); JsonServiceDocumentWriter writer = new JsonServiceDocumentWriter(requestContext.getUri(), requestContext.getEntityDataModel()); String json = writer.buildJson(); try { responseBuilder .setContentType(JSON) .setHeader("OData-Version", AbstractRenderer.ODATA_VERSION_HEADER) .setBodyText(json, UTF_8.name()); } catch (UnsupportedEncodingException e) { throw new ODataSystemException(e); } LOG.debug("End rendering entity(es) for request: {}", requestContext); }  @Override int score(ODataRequestContext requestContext, QueryResult data); @Override void render(ODataRequestContext requestContext, QueryResult data, ODataResponse.Builder responseBuilder); @Override ChunkedActionRenderResult renderStart(ODataRequestContext requestContext, QueryResult result,
                                                 OutputStream outputStream);  }
@Test public void testRender() throws Exception { prepareRequestContextRender(GET, createODataUriForServiceDocument()); serviceDocumentRenderer.render(context, null, responseBuilder); responseBuilder.setStatus(OK); assertResponse(responseBuilder.build(), JSON, SERVICE_DOCUMENT); }
@Test(expected = ODataSystemException.class) public void testRenderException() throws ODataException, UnsupportedEncodingException { prepareRequestContextRenderException(GET, createODataUriForServiceDocument(JSON)); serviceDocumentRenderer.render(context, null, responseBuilderMock); }