@Test public void testScoreXmlContentTypeInHeader() throws Exception { prepareRequestContextHeaderWithContextType(XML); assertThat(renderer.score(context, QueryResult.from(exception)), is(CONTENT_TYPE_HEADER + 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 atomXmlAcceptScore = scoreByMediaType(accept, ATOM_XML); int xmlAcceptScore = scoreByMediaType(accept, XML); int totalAcceptScore = max(atomXmlAcceptScore, xmlAcceptScore); int xmlContentTypeScore = scoreByContentType(requestContext, XML); int atomXmlContentTypeScore = scoreByContentType(requestContext, ATOM_XML); int totalContentTypeScore = max(xmlContentTypeScore, atomXmlContentTypeScore); int totalScore = max(totalAcceptScore, totalContentTypeScore); if (totalScore == WILDCARD_MATCH_SCORE || totalScore == DEFAULT_SCORE) { totalScore += PRIORITY_SCORE; } return totalScore > 0 ? (totalScore + ERROR_EXTRA_SCORE) : DEFAULT_SCORE; }
XMLErrorResponseRenderer 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 atomXmlAcceptScore = scoreByMediaType(accept, ATOM_XML); int xmlAcceptScore = scoreByMediaType(accept, XML); int totalAcceptScore = max(atomXmlAcceptScore, xmlAcceptScore); int xmlContentTypeScore = scoreByContentType(requestContext, XML); int atomXmlContentTypeScore = scoreByContentType(requestContext, ATOM_XML); int totalContentTypeScore = max(xmlContentTypeScore, atomXmlContentTypeScore); int totalScore = max(totalAcceptScore, totalContentTypeScore); if (totalScore == WILDCARD_MATCH_SCORE || totalScore == DEFAULT_SCORE) { totalScore += PRIORITY_SCORE; } return totalScore > 0 ? (totalScore + ERROR_EXTRA_SCORE) : DEFAULT_SCORE; } }
XMLErrorResponseRenderer 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 atomXmlAcceptScore = scoreByMediaType(accept, ATOM_XML); int xmlAcceptScore = scoreByMediaType(accept, XML); int totalAcceptScore = max(atomXmlAcceptScore, xmlAcceptScore); int xmlContentTypeScore = scoreByContentType(requestContext, XML); int atomXmlContentTypeScore = scoreByContentType(requestContext, ATOM_XML); int totalContentTypeScore = max(xmlContentTypeScore, atomXmlContentTypeScore); int totalScore = max(totalAcceptScore, totalContentTypeScore); if (totalScore == WILDCARD_MATCH_SCORE || totalScore == DEFAULT_SCORE) { totalScore += PRIORITY_SCORE; } return totalScore > 0 ? (totalScore + ERROR_EXTRA_SCORE) : DEFAULT_SCORE; }  }
XMLErrorResponseRenderer 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 atomXmlAcceptScore = scoreByMediaType(accept, ATOM_XML); int xmlAcceptScore = scoreByMediaType(accept, XML); int totalAcceptScore = max(atomXmlAcceptScore, xmlAcceptScore); int xmlContentTypeScore = scoreByContentType(requestContext, XML); int atomXmlContentTypeScore = scoreByContentType(requestContext, ATOM_XML); int totalContentTypeScore = max(xmlContentTypeScore, atomXmlContentTypeScore); int totalScore = max(totalAcceptScore, totalContentTypeScore); if (totalScore == WILDCARD_MATCH_SCORE || totalScore == DEFAULT_SCORE) { totalScore += PRIORITY_SCORE; } return totalScore > 0 ? (totalScore + 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); }
XMLErrorResponseRenderer 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 atomXmlAcceptScore = scoreByMediaType(accept, ATOM_XML); int xmlAcceptScore = scoreByMediaType(accept, XML); int totalAcceptScore = max(atomXmlAcceptScore, xmlAcceptScore); int xmlContentTypeScore = scoreByContentType(requestContext, XML); int atomXmlContentTypeScore = scoreByContentType(requestContext, ATOM_XML); int totalContentTypeScore = max(xmlContentTypeScore, atomXmlContentTypeScore); int totalScore = max(totalAcceptScore, totalContentTypeScore); if (totalScore == WILDCARD_MATCH_SCORE || totalScore == DEFAULT_SCORE) { totalScore += PRIORITY_SCORE; } return totalScore > 0 ? (totalScore + 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);  }