@Test public void checkSupport() throws Exception { ContentNegotiator.checkSupport(ContentType.JSON, null, RepresentationType.ENTITY); ContentNegotiator.checkSupport(ContentType.TEXT_PLAIN, null, RepresentationType.VALUE); try { ContentNegotiator.checkSupport(ContentType.APPLICATION_SVG_XML, null, RepresentationType.ENTITY); fail("Exception expected."); } catch (final ContentNegotiatorException e) { assertEquals(ContentNegotiatorException.MessageKeys.UNSUPPORTED_CONTENT_TYPE, e.getMessageKey()); } ContentNegotiator.checkSupport(ContentType.create("a/b"), createCustomContentTypeSupport("a/b"), RepresentationType.ENTITY); ContentNegotiator.checkSupport(ContentType.create(ContentType.create("a/b"), "c", "d"), createCustomContentTypeSupport("a/b"), RepresentationType.ENTITY); try { ContentNegotiator.checkSupport(ContentType.create("a/b"), createCustomContentTypeSupport("a/b;c=d"), RepresentationType.ENTITY); fail("Exception expected."); } catch (final ContentNegotiatorException e) { assertEquals(ContentNegotiatorException.MessageKeys.UNSUPPORTED_CONTENT_TYPE, e.getMessageKey()); } }
public static void checkSupport(final ContentType contentType, final CustomContentTypeSupport customContentTypeSupport, final RepresentationType representationType) throws ContentNegotiatorException { for (ContentType supportedContentType : getSupportedContentTypes(customContentTypeSupport, representationType)) { if (AcceptType.fromContentType(supportedContentType).get(0).matches(contentType)) { return; } } throw new ContentNegotiatorException("unsupported content type: " + contentType, ContentNegotiatorException.MessageKeys.UNSUPPORTED_CONTENT_TYPE, contentType.toContentTypeString()); }
ContentNegotiator { public static void checkSupport(final ContentType contentType, final CustomContentTypeSupport customContentTypeSupport, final RepresentationType representationType) throws ContentNegotiatorException { for (ContentType supportedContentType : getSupportedContentTypes(customContentTypeSupport, representationType)) { if (AcceptType.fromContentType(supportedContentType).get(0).matches(contentType)) { return; } } throw new ContentNegotiatorException("unsupported content type: " + contentType, ContentNegotiatorException.MessageKeys.UNSUPPORTED_CONTENT_TYPE, contentType.toContentTypeString()); } }
ContentNegotiator { public static void checkSupport(final ContentType contentType, final CustomContentTypeSupport customContentTypeSupport, final RepresentationType representationType) throws ContentNegotiatorException { for (ContentType supportedContentType : getSupportedContentTypes(customContentTypeSupport, representationType)) { if (AcceptType.fromContentType(supportedContentType).get(0).matches(contentType)) { return; } } throw new ContentNegotiatorException("unsupported content type: " + contentType, ContentNegotiatorException.MessageKeys.UNSUPPORTED_CONTENT_TYPE, contentType.toContentTypeString()); } private  ContentNegotiator(); }
ContentNegotiator { public static void checkSupport(final ContentType contentType, final CustomContentTypeSupport customContentTypeSupport, final RepresentationType representationType) throws ContentNegotiatorException { for (ContentType supportedContentType : getSupportedContentTypes(customContentTypeSupport, representationType)) { if (AcceptType.fromContentType(supportedContentType).get(0).matches(contentType)) { return; } } throw new ContentNegotiatorException("unsupported content type: " + contentType, ContentNegotiatorException.MessageKeys.UNSUPPORTED_CONTENT_TYPE, contentType.toContentTypeString()); } private  ContentNegotiator(); static ContentType doContentNegotiation(final FormatOption formatOption, final ODataRequest request,
      final CustomContentTypeSupport customContentTypeSupport, final RepresentationType representationType); static void checkSupport(final ContentType contentType,
      final CustomContentTypeSupport customContentTypeSupport, final RepresentationType representationType); static boolean isSupported(final ContentType contentType,
      final CustomContentTypeSupport customContentTypeSupport,
      final RepresentationType representationType); }
ContentNegotiator { public static void checkSupport(final ContentType contentType, final CustomContentTypeSupport customContentTypeSupport, final RepresentationType representationType) throws ContentNegotiatorException { for (ContentType supportedContentType : getSupportedContentTypes(customContentTypeSupport, representationType)) { if (AcceptType.fromContentType(supportedContentType).get(0).matches(contentType)) { return; } } throw new ContentNegotiatorException("unsupported content type: " + contentType, ContentNegotiatorException.MessageKeys.UNSUPPORTED_CONTENT_TYPE, contentType.toContentTypeString()); } private  ContentNegotiator(); static ContentType doContentNegotiation(final FormatOption formatOption, final ODataRequest request,
      final CustomContentTypeSupport customContentTypeSupport, final RepresentationType representationType); static void checkSupport(final ContentType contentType,
      final CustomContentTypeSupport customContentTypeSupport, final RepresentationType representationType); static boolean isSupported(final ContentType contentType,
      final CustomContentTypeSupport customContentTypeSupport,
      final RepresentationType representationType);  }