@Test(expected = IllegalArgumentException.class) public void invalidContentNegotiatorCreationNullSupported() throws ODataException { ODataRequest request = Mockito.mock(ODataRequest.class); UriInfoImpl uriInfo = Mockito.mock(UriInfoImpl.class); final ContentType contentType = new ContentNegotiator().doContentNegotiation(request, uriInfo, null); assertNull(contentType); }
public ContentType doContentNegotiation(final ODataRequest odataRequest, final UriInfoImpl uriInfo, final List<String> supportedContentTypes) throws ODataException { validateNotNull(odataRequest, uriInfo, supportedContentTypes); if (uriInfo.isCount()) { return ContentType.TEXT_PLAIN_CS_UTF_8; } else if (uriInfo.isValue()) { if (uriInfo.getUriType() == UriType.URI5 || uriInfo.getUriType() == UriType.URI4) { return ContentType.TEXT_PLAIN_CS_UTF_8; } return doContentNegotiationForAcceptHeader(Arrays.asList("*/*"), ContentType.create(supportedContentTypes)); } if (uriInfo.getFormat() == null) { return doContentNegotiationForAcceptHeader(odataRequest.getAcceptHeaders(), ContentType .create(supportedContentTypes)); } else { return doContentNegotiationForFormat(uriInfo, ContentType.createAsCustom(supportedContentTypes)); } }
ContentNegotiator { public ContentType doContentNegotiation(final ODataRequest odataRequest, final UriInfoImpl uriInfo, final List<String> supportedContentTypes) throws ODataException { validateNotNull(odataRequest, uriInfo, supportedContentTypes); if (uriInfo.isCount()) { return ContentType.TEXT_PLAIN_CS_UTF_8; } else if (uriInfo.isValue()) { if (uriInfo.getUriType() == UriType.URI5 || uriInfo.getUriType() == UriType.URI4) { return ContentType.TEXT_PLAIN_CS_UTF_8; } return doContentNegotiationForAcceptHeader(Arrays.asList("*/*"), ContentType.create(supportedContentTypes)); } if (uriInfo.getFormat() == null) { return doContentNegotiationForAcceptHeader(odataRequest.getAcceptHeaders(), ContentType .create(supportedContentTypes)); } else { return doContentNegotiationForFormat(uriInfo, ContentType.createAsCustom(supportedContentTypes)); } } }
ContentNegotiator { public ContentType doContentNegotiation(final ODataRequest odataRequest, final UriInfoImpl uriInfo, final List<String> supportedContentTypes) throws ODataException { validateNotNull(odataRequest, uriInfo, supportedContentTypes); if (uriInfo.isCount()) { return ContentType.TEXT_PLAIN_CS_UTF_8; } else if (uriInfo.isValue()) { if (uriInfo.getUriType() == UriType.URI5 || uriInfo.getUriType() == UriType.URI4) { return ContentType.TEXT_PLAIN_CS_UTF_8; } return doContentNegotiationForAcceptHeader(Arrays.asList("*/*"), ContentType.create(supportedContentTypes)); } if (uriInfo.getFormat() == null) { return doContentNegotiationForAcceptHeader(odataRequest.getAcceptHeaders(), ContentType .create(supportedContentTypes)); } else { return doContentNegotiationForFormat(uriInfo, ContentType.createAsCustom(supportedContentTypes)); } }  }
ContentNegotiator { public ContentType doContentNegotiation(final ODataRequest odataRequest, final UriInfoImpl uriInfo, final List<String> supportedContentTypes) throws ODataException { validateNotNull(odataRequest, uriInfo, supportedContentTypes); if (uriInfo.isCount()) { return ContentType.TEXT_PLAIN_CS_UTF_8; } else if (uriInfo.isValue()) { if (uriInfo.getUriType() == UriType.URI5 || uriInfo.getUriType() == UriType.URI4) { return ContentType.TEXT_PLAIN_CS_UTF_8; } return doContentNegotiationForAcceptHeader(Arrays.asList("*/*"), ContentType.create(supportedContentTypes)); } if (uriInfo.getFormat() == null) { return doContentNegotiationForAcceptHeader(odataRequest.getAcceptHeaders(), ContentType .create(supportedContentTypes)); } else { return doContentNegotiationForFormat(uriInfo, ContentType.createAsCustom(supportedContentTypes)); } }  ContentType doContentNegotiation(final ODataRequest odataRequest, final UriInfoImpl uriInfo,
      final List<String> supportedContentTypes); }
ContentNegotiator { public ContentType doContentNegotiation(final ODataRequest odataRequest, final UriInfoImpl uriInfo, final List<String> supportedContentTypes) throws ODataException { validateNotNull(odataRequest, uriInfo, supportedContentTypes); if (uriInfo.isCount()) { return ContentType.TEXT_PLAIN_CS_UTF_8; } else if (uriInfo.isValue()) { if (uriInfo.getUriType() == UriType.URI5 || uriInfo.getUriType() == UriType.URI4) { return ContentType.TEXT_PLAIN_CS_UTF_8; } return doContentNegotiationForAcceptHeader(Arrays.asList("*/*"), ContentType.create(supportedContentTypes)); } if (uriInfo.getFormat() == null) { return doContentNegotiationForAcceptHeader(odataRequest.getAcceptHeaders(), ContentType .create(supportedContentTypes)); } else { return doContentNegotiationForFormat(uriInfo, ContentType.createAsCustom(supportedContentTypes)); } }  ContentType doContentNegotiation(final ODataRequest odataRequest, final UriInfoImpl uriInfo,
      final List<String> supportedContentTypes);  }