@Test public void testScoreJsonInHeader() throws Exception { prepareRequestContextHeader(JSON); assertThat(renderer.score(context, QueryResult.from(exception)), is(MAXIMUM_HEADER_SCORE + ERROR_EXTRA_SCORE)); }
@Override public int score(ODataRequestContext requestContext, QueryResult data) { if (data == null || data.getType() == NOTHING || data.getType() != EXCEPTION) { return DEFAULT_SCORE; } List<MediaType> accept = requestContext.getRequest().getAccept(); int jsonAcceptScore = scoreByMediaType(accept, JSON); int contentTypeScore = scoreByContentType(requestContext, JSON); int resultScore = max(jsonAcceptScore, contentTypeScore); return resultScore > 0 ? (resultScore + ERROR_EXTRA_SCORE) : DEFAULT_SCORE; }
JsonErrorResponseRenderer extends AbstractRenderer { @Override public int score(ODataRequestContext requestContext, QueryResult data) { if (data == null || data.getType() == NOTHING || data.getType() != EXCEPTION) { return DEFAULT_SCORE; } List<MediaType> accept = requestContext.getRequest().getAccept(); int jsonAcceptScore = scoreByMediaType(accept, JSON); int contentTypeScore = scoreByContentType(requestContext, JSON); int resultScore = max(jsonAcceptScore, contentTypeScore); return resultScore > 0 ? (resultScore + ERROR_EXTRA_SCORE) : DEFAULT_SCORE; } }
JsonErrorResponseRenderer extends AbstractRenderer { @Override public int score(ODataRequestContext requestContext, QueryResult data) { if (data == null || data.getType() == NOTHING || data.getType() != EXCEPTION) { return DEFAULT_SCORE; } List<MediaType> accept = requestContext.getRequest().getAccept(); int jsonAcceptScore = scoreByMediaType(accept, JSON); int contentTypeScore = scoreByContentType(requestContext, JSON); int resultScore = max(jsonAcceptScore, contentTypeScore); return resultScore > 0 ? (resultScore + ERROR_EXTRA_SCORE) : DEFAULT_SCORE; }  }
JsonErrorResponseRenderer extends AbstractRenderer { @Override public int score(ODataRequestContext requestContext, QueryResult data) { if (data == null || data.getType() == NOTHING || data.getType() != EXCEPTION) { return DEFAULT_SCORE; } List<MediaType> accept = requestContext.getRequest().getAccept(); int jsonAcceptScore = scoreByMediaType(accept, JSON); int contentTypeScore = scoreByContentType(requestContext, JSON); int resultScore = max(jsonAcceptScore, contentTypeScore); return resultScore > 0 ? (resultScore + ERROR_EXTRA_SCORE) : DEFAULT_SCORE; }  @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); }
JsonErrorResponseRenderer extends AbstractRenderer { @Override public int score(ODataRequestContext requestContext, QueryResult data) { if (data == null || data.getType() == NOTHING || data.getType() != EXCEPTION) { return DEFAULT_SCORE; } List<MediaType> accept = requestContext.getRequest().getAccept(); int jsonAcceptScore = scoreByMediaType(accept, JSON); int contentTypeScore = scoreByContentType(requestContext, JSON); int resultScore = max(jsonAcceptScore, contentTypeScore); return resultScore > 0 ? (resultScore + ERROR_EXTRA_SCORE) : DEFAULT_SCORE; }  @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);  }