From a03b10df798adc83b6bbb1bb02bb58b75aad013e Mon Sep 17 00:00:00 2001 From: Robert Varga Date: Sat, 18 Nov 2023 05:34:04 +0100 Subject: [PATCH] Split up MediaTypes We really want two sets of independent constants: - plain Strings in restconf.api.MediaTypes - JAX-RS MediaTypes in restconf.nb.jaxrs JIRA: NETCONF-773 Change-Id: I11fcf0694bd2d7d3d8f75024b3aa5a43f84c6b31 Signed-off-by: Robert Varga --- .../restconf/api}/MediaTypes.java | 35 +----------- .../restconf/nb/jaxrs/JaxRsMediaTypes.java | 54 +++++++++++++++++++ .../restconf/nb/jaxrs/JaxRsRestconf.java | 2 +- .../JsonNormalizedNodeBodyWriter.java | 2 +- .../providers/JsonPatchStatusBodyWriter.java | 2 +- .../XmlNormalizedNodeBodyWriter.java | 2 +- .../providers/XmlPatchStatusBodyWriter.java | 2 +- .../RestconfDocumentedExceptionMapper.java | 16 +++--- .../RootResourceDiscoveryServiceImpl.java | 2 +- ...RestconfDocumentedExceptionMapperTest.java | 22 ++++---- 10 files changed, 81 insertions(+), 58 deletions(-) rename {restconf/restconf-nb/src/main/java/org/opendaylight/restconf/nb/rfc8040 => protocol/restconf-api/src/main/java/org/opendaylight/restconf/api}/MediaTypes.java (52%) create mode 100644 restconf/restconf-nb/src/main/java/org/opendaylight/restconf/nb/jaxrs/JaxRsMediaTypes.java diff --git a/restconf/restconf-nb/src/main/java/org/opendaylight/restconf/nb/rfc8040/MediaTypes.java b/protocol/restconf-api/src/main/java/org/opendaylight/restconf/api/MediaTypes.java similarity index 52% rename from restconf/restconf-nb/src/main/java/org/opendaylight/restconf/nb/rfc8040/MediaTypes.java rename to protocol/restconf-api/src/main/java/org/opendaylight/restconf/api/MediaTypes.java index 85269b6c08..258ae16678 100644 --- a/restconf/restconf-nb/src/main/java/org/opendaylight/restconf/nb/rfc8040/MediaTypes.java +++ b/protocol/restconf-api/src/main/java/org/opendaylight/restconf/api/MediaTypes.java @@ -5,13 +5,12 @@ * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ -package org.opendaylight.restconf.nb.rfc8040; +package org.opendaylight.restconf.api; -import javax.ws.rs.core.MediaType; import org.eclipse.jdt.annotation.NonNullByDefault; /** - * Media types we use in this implementation, in both {@link String} and {@link MediaType} form. + * Well-known RESTCONF media types. */ @NonNullByDefault public final class MediaTypes { @@ -21,60 +20,30 @@ public final class MediaTypes { * @see RFC6415, section 2 */ public static final String APPLICATION_XRD_XML = "application/xrd+xml"; - /** - * A {@code MediaType} constant representing {@value #APPLICATION_XRD_XML} media type. - * - * @see RFC6415, section 2 - */ - public static final MediaType APPLICATION_XRD_XML_TYPE = MediaType.valueOf(APPLICATION_XRD_XML); /** * A {@code String} constant representing {@value #APPLICATION_YANG_DATA_XML} media type. * * @see RFC8040, section 11.3.1 */ public static final String APPLICATION_YANG_DATA_XML = "application/yang-data+xml"; - /** - * A {@code MediaType} constant representing {@value #APPLICATION_YANG_DATA_XML} media type. - * - * @see RFC8040, section 11.3.1 - */ - public static final MediaType APPLICATION_YANG_DATA_XML_TYPE = MediaType.valueOf(APPLICATION_YANG_DATA_XML); /** * A {@code String} constant representing {@value #APPLICATION_YANG_DATA_JSON} media type. * * @see RFC8040, section 11.3.2 */ public static final String APPLICATION_YANG_DATA_JSON = "application/yang-data+json"; - /** - * A {@code MediaType} constant representing {@value #APPLICATION_YANG_DATA_JSON} media type. - * - * @see RFC8040, section 11.3.2 - */ - public static final MediaType APPLICATION_YANG_DATA_JSON_TYPE = MediaType.valueOf(APPLICATION_YANG_DATA_JSON); /** * A {@code String} constant representing {@value #APPLICATION_YANG_PATCH_XML} media type. * * @see RFC8072, section 4.2.1 */ public static final String APPLICATION_YANG_PATCH_XML = "application/yang-patch+xml"; - /** - * A {@code MediaType} constant representing {@value #APPLICATION_YANG_PATCH_XML} media type. - * - * @see RFC8072, section 4.2.1 - */ - public static final MediaType APPLICATION_YANG_PATCH_XML_TYPE = MediaType.valueOf(APPLICATION_YANG_PATCH_XML); /** * A {@code MediaType} constant representing {@value #APPLICATION_YANG_PATCH_JSON} media type. * * @see RFC8072, section 4.2.2 */ public static final String APPLICATION_YANG_PATCH_JSON = "application/yang-patch+json"; - /** - * A {@code MediaType} constant representing {@value #APPLICATION_YANG_PATCH_JSON} media type. - * - * @see RFC8072, section 4.2.2 - */ - public static final MediaType APPLICATION_YANG_PATCH_JSON_TYPE = MediaType.valueOf(APPLICATION_YANG_PATCH_JSON); private MediaTypes() { // Hidden on purpose diff --git a/restconf/restconf-nb/src/main/java/org/opendaylight/restconf/nb/jaxrs/JaxRsMediaTypes.java b/restconf/restconf-nb/src/main/java/org/opendaylight/restconf/nb/jaxrs/JaxRsMediaTypes.java new file mode 100644 index 0000000000..7f5e559a8a --- /dev/null +++ b/restconf/restconf-nb/src/main/java/org/opendaylight/restconf/nb/jaxrs/JaxRsMediaTypes.java @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2023 PANTHEON.tech, s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.restconf.nb.jaxrs; + +import javax.ws.rs.core.MediaType; +import org.eclipse.jdt.annotation.NonNullByDefault; +import org.opendaylight.restconf.api.MediaTypes; + +/** + * RESTCONF {@link MediaTypes}.expressed as JAX-RS {@link MediaType}. + */ +@NonNullByDefault +public final class JaxRsMediaTypes { + /** + * A {@code MediaType} constant representing {@value MediaTypes#APPLICATION_XRD_XML} media type. + * + * @see RFC6415, section 2 + */ + public static final MediaType APPLICATION_XRD_XML = MediaType.valueOf(MediaTypes.APPLICATION_XRD_XML); + /** + * A {@code MediaType} constant representing {@value MediaTypes#APPLICATION_YANG_DATA_XML} media type. + * + * @see RFC8040, section 11.3.1 + */ + public static final MediaType APPLICATION_YANG_DATA_XML = MediaType.valueOf(MediaTypes.APPLICATION_YANG_DATA_XML); + /** + * A {@code MediaType} constant representing {@value MediaTypes#APPLICATION_YANG_DATA_JSON} media type. + * + * @see RFC8040, section 11.3.2 + */ + public static final MediaType APPLICATION_YANG_DATA_JSON = MediaType.valueOf(MediaTypes.APPLICATION_YANG_DATA_JSON); + /** + * A {@code MediaType} constant representing {@value MediaTypes#APPLICATION_YANG_PATCH_XML} media type. + * + * @see RFC8072, section 4.2.1 + */ + public static final MediaType APPLICATION_YANG_PATCH_XML = MediaType.valueOf(MediaTypes.APPLICATION_YANG_PATCH_XML); + /** + * A {@code MediaType} constant representing {@value MediaTypes#APPLICATION_YANG_PATCH_JSON} media type. + * + * @see RFC8072, section 4.2.2 + */ + public static final MediaType APPLICATION_YANG_PATCH_JSON = + MediaType.valueOf(MediaTypes.APPLICATION_YANG_PATCH_JSON); + + private JaxRsMediaTypes() { + // Hidden on purpose + } +} diff --git a/restconf/restconf-nb/src/main/java/org/opendaylight/restconf/nb/jaxrs/JaxRsRestconf.java b/restconf/restconf-nb/src/main/java/org/opendaylight/restconf/nb/jaxrs/JaxRsRestconf.java index 169de2d6b6..d292b49fa7 100644 --- a/restconf/restconf-nb/src/main/java/org/opendaylight/restconf/nb/jaxrs/JaxRsRestconf.java +++ b/restconf/restconf-nb/src/main/java/org/opendaylight/restconf/nb/jaxrs/JaxRsRestconf.java @@ -33,10 +33,10 @@ import javax.ws.rs.core.Response; import javax.ws.rs.core.Response.Status; import javax.ws.rs.core.UriInfo; import org.eclipse.jdt.annotation.NonNull; +import org.opendaylight.restconf.api.MediaTypes; import org.opendaylight.restconf.common.errors.RestconfError; import org.opendaylight.restconf.common.errors.RestconfFuture; import org.opendaylight.restconf.common.patch.PatchStatusContext; -import org.opendaylight.restconf.nb.rfc8040.MediaTypes; import org.opendaylight.restconf.nb.rfc8040.ReadDataParams; import org.opendaylight.restconf.nb.rfc8040.databind.JsonChildBody; import org.opendaylight.restconf.nb.rfc8040.databind.JsonDataPostBody; diff --git a/restconf/restconf-nb/src/main/java/org/opendaylight/restconf/nb/rfc8040/jersey/providers/JsonNormalizedNodeBodyWriter.java b/restconf/restconf-nb/src/main/java/org/opendaylight/restconf/nb/rfc8040/jersey/providers/JsonNormalizedNodeBodyWriter.java index 6f2ae62170..d47dafd0a7 100644 --- a/restconf/restconf-nb/src/main/java/org/opendaylight/restconf/nb/rfc8040/jersey/providers/JsonNormalizedNodeBodyWriter.java +++ b/restconf/restconf-nb/src/main/java/org/opendaylight/restconf/nb/rfc8040/jersey/providers/JsonNormalizedNodeBodyWriter.java @@ -16,8 +16,8 @@ import javax.ws.rs.Produces; import javax.ws.rs.core.MediaType; import javax.ws.rs.ext.Provider; import org.eclipse.jdt.annotation.Nullable; +import org.opendaylight.restconf.api.MediaTypes; import org.opendaylight.restconf.api.query.PrettyPrintParam; -import org.opendaylight.restconf.nb.rfc8040.MediaTypes; import org.opendaylight.restconf.nb.rfc8040.jersey.providers.api.RestconfNormalizedNodeWriter; import org.opendaylight.restconf.nb.rfc8040.legacy.QueryParameters; import org.opendaylight.yangtools.yang.common.XMLNamespace; diff --git a/restconf/restconf-nb/src/main/java/org/opendaylight/restconf/nb/rfc8040/jersey/providers/JsonPatchStatusBodyWriter.java b/restconf/restconf-nb/src/main/java/org/opendaylight/restconf/nb/rfc8040/jersey/providers/JsonPatchStatusBodyWriter.java index 49a2f14be0..1b1d12528f 100644 --- a/restconf/restconf-nb/src/main/java/org/opendaylight/restconf/nb/rfc8040/jersey/providers/JsonPatchStatusBodyWriter.java +++ b/restconf/restconf-nb/src/main/java/org/opendaylight/restconf/nb/rfc8040/jersey/providers/JsonPatchStatusBodyWriter.java @@ -19,9 +19,9 @@ import javax.ws.rs.Produces; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.MultivaluedMap; import javax.ws.rs.ext.Provider; +import org.opendaylight.restconf.api.MediaTypes; import org.opendaylight.restconf.common.errors.RestconfError; import org.opendaylight.restconf.common.patch.PatchStatusContext; -import org.opendaylight.restconf.nb.rfc8040.MediaTypes; import org.opendaylight.yangtools.yang.data.codec.gson.JSONCodecFactorySupplier; import org.opendaylight.yangtools.yang.data.codec.gson.JsonWriterFactory; import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext; diff --git a/restconf/restconf-nb/src/main/java/org/opendaylight/restconf/nb/rfc8040/jersey/providers/XmlNormalizedNodeBodyWriter.java b/restconf/restconf-nb/src/main/java/org/opendaylight/restconf/nb/rfc8040/jersey/providers/XmlNormalizedNodeBodyWriter.java index 9ee1b4aced..d0018ee4f6 100644 --- a/restconf/restconf-nb/src/main/java/org/opendaylight/restconf/nb/rfc8040/jersey/providers/XmlNormalizedNodeBodyWriter.java +++ b/restconf/restconf-nb/src/main/java/org/opendaylight/restconf/nb/rfc8040/jersey/providers/XmlNormalizedNodeBodyWriter.java @@ -20,8 +20,8 @@ import javax.xml.stream.XMLOutputFactory; import javax.xml.stream.XMLStreamException; import javax.xml.stream.XMLStreamWriter; import org.eclipse.jdt.annotation.Nullable; +import org.opendaylight.restconf.api.MediaTypes; import org.opendaylight.restconf.api.query.PrettyPrintParam; -import org.opendaylight.restconf.nb.rfc8040.MediaTypes; import org.opendaylight.restconf.nb.rfc8040.jersey.providers.api.RestconfNormalizedNodeWriter; import org.opendaylight.restconf.nb.rfc8040.legacy.QueryParameters; import org.opendaylight.yangtools.yang.common.QName; diff --git a/restconf/restconf-nb/src/main/java/org/opendaylight/restconf/nb/rfc8040/jersey/providers/XmlPatchStatusBodyWriter.java b/restconf/restconf-nb/src/main/java/org/opendaylight/restconf/nb/rfc8040/jersey/providers/XmlPatchStatusBodyWriter.java index 2cf01f1d5a..4b186c53c6 100644 --- a/restconf/restconf-nb/src/main/java/org/opendaylight/restconf/nb/rfc8040/jersey/providers/XmlPatchStatusBodyWriter.java +++ b/restconf/restconf-nb/src/main/java/org/opendaylight/restconf/nb/rfc8040/jersey/providers/XmlPatchStatusBodyWriter.java @@ -20,9 +20,9 @@ import javax.ws.rs.ext.Provider; import javax.xml.stream.XMLOutputFactory; import javax.xml.stream.XMLStreamException; import javax.xml.stream.XMLStreamWriter; +import org.opendaylight.restconf.api.MediaTypes; import org.opendaylight.restconf.common.errors.RestconfError; import org.opendaylight.restconf.common.patch.PatchStatusContext; -import org.opendaylight.restconf.nb.rfc8040.MediaTypes; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.patch.rev170222.yang.patch.status.YangPatchStatus; import org.opendaylight.yangtools.yang.data.codec.xml.XmlCodecFactory; import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext; diff --git a/restconf/restconf-nb/src/main/java/org/opendaylight/restconf/nb/rfc8040/jersey/providers/errors/RestconfDocumentedExceptionMapper.java b/restconf/restconf-nb/src/main/java/org/opendaylight/restconf/nb/rfc8040/jersey/providers/errors/RestconfDocumentedExceptionMapper.java index 5177b1fff5..5b132223d5 100644 --- a/restconf/restconf-nb/src/main/java/org/opendaylight/restconf/nb/rfc8040/jersey/providers/errors/RestconfDocumentedExceptionMapper.java +++ b/restconf/restconf-nb/src/main/java/org/opendaylight/restconf/nb/rfc8040/jersey/providers/errors/RestconfDocumentedExceptionMapper.java @@ -31,7 +31,7 @@ import javax.ws.rs.ext.ExceptionMapper; import javax.ws.rs.ext.Provider; import org.opendaylight.restconf.common.errors.RestconfDocumentedException; import org.opendaylight.restconf.common.errors.RestconfError; -import org.opendaylight.restconf.nb.rfc8040.MediaTypes; +import org.opendaylight.restconf.nb.jaxrs.JaxRsMediaTypes; import org.opendaylight.restconf.nb.rfc8040.databind.DatabindProvider; import org.opendaylight.restconf.nb.rfc8040.legacy.ErrorTags; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.restconf.rev170126.errors.Errors; @@ -94,7 +94,7 @@ public final class RestconfDocumentedExceptionMapper implements ExceptionMapper< final ContainerNode errorsContainer = buildErrorsContainer(exception); final String serializedResponseBody; final MediaType responseMediaType = transformToResponseMediaType(getSupportedMediaType()); - if (MediaTypes.APPLICATION_YANG_DATA_JSON_TYPE.equals(responseMediaType)) { + if (JaxRsMediaTypes.APPLICATION_YANG_DATA_JSON.equals(responseMediaType)) { serializedResponseBody = serializeErrorsContainerToJson(errorsContainer); } else { serializedResponseBody = serializeErrorsContainerToXml(errorsContainer); @@ -319,9 +319,9 @@ public final class RestconfDocumentedExceptionMapper implements ExceptionMapper< */ private static MediaType transformToResponseMediaType(final MediaType mediaTypeBase) { if (isJsonCompatibleMediaType(mediaTypeBase)) { - return MediaTypes.APPLICATION_YANG_DATA_JSON_TYPE; + return JaxRsMediaTypes.APPLICATION_YANG_DATA_JSON; } else if (isXmlCompatibleMediaType(mediaTypeBase)) { - return MediaTypes.APPLICATION_YANG_DATA_XML_TYPE; + return JaxRsMediaTypes.APPLICATION_YANG_DATA_XML; } else { throw new IllegalStateException(String.format("Unexpected input media-type %s " + "- it should be JSON/XML compatible type.", mediaTypeBase)); @@ -334,14 +334,14 @@ public final class RestconfDocumentedExceptionMapper implements ExceptionMapper< private static boolean isJsonCompatibleMediaType(final MediaType mediaType) { return mediaType.isCompatible(MediaType.APPLICATION_JSON_TYPE) - || mediaType.isCompatible(MediaTypes.APPLICATION_YANG_DATA_JSON_TYPE) - || mediaType.isCompatible(MediaTypes.APPLICATION_YANG_PATCH_JSON_TYPE); + || mediaType.isCompatible(JaxRsMediaTypes.APPLICATION_YANG_DATA_JSON) + || mediaType.isCompatible(JaxRsMediaTypes.APPLICATION_YANG_PATCH_JSON); } private static boolean isXmlCompatibleMediaType(final MediaType mediaType) { return mediaType.isCompatible(MediaType.APPLICATION_XML_TYPE) - || mediaType.isCompatible(MediaTypes.APPLICATION_YANG_DATA_XML_TYPE) - || mediaType.isCompatible(MediaTypes.APPLICATION_YANG_PATCH_XML_TYPE); + || mediaType.isCompatible(JaxRsMediaTypes.APPLICATION_YANG_DATA_XML) + || mediaType.isCompatible(JaxRsMediaTypes.APPLICATION_YANG_PATCH_XML); } /** diff --git a/restconf/restconf-nb/src/main/java/org/opendaylight/restconf/nb/rfc8040/rests/services/impl/RootResourceDiscoveryServiceImpl.java b/restconf/restconf-nb/src/main/java/org/opendaylight/restconf/nb/rfc8040/rests/services/impl/RootResourceDiscoveryServiceImpl.java index 38268d0ba4..87105e7156 100644 --- a/restconf/restconf-nb/src/main/java/org/opendaylight/restconf/nb/rfc8040/rests/services/impl/RootResourceDiscoveryServiceImpl.java +++ b/restconf/restconf-nb/src/main/java/org/opendaylight/restconf/nb/rfc8040/rests/services/impl/RootResourceDiscoveryServiceImpl.java @@ -15,7 +15,7 @@ import javax.ws.rs.Produces; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import javax.ws.rs.core.Response.Status; -import org.opendaylight.restconf.nb.rfc8040.MediaTypes; +import org.opendaylight.restconf.api.MediaTypes; /** * Controller for determining the {@code Root Resource} of the RESTCONF API. This interface serves up a diff --git a/restconf/restconf-nb/src/test/java/org/opendaylight/restconf/nb/rfc8040/jersey/providers/errors/RestconfDocumentedExceptionMapperTest.java b/restconf/restconf-nb/src/test/java/org/opendaylight/restconf/nb/rfc8040/jersey/providers/errors/RestconfDocumentedExceptionMapperTest.java index 7218acfe89..0ba34f3ba5 100644 --- a/restconf/restconf-nb/src/test/java/org/opendaylight/restconf/nb/rfc8040/jersey/providers/errors/RestconfDocumentedExceptionMapperTest.java +++ b/restconf/restconf-nb/src/test/java/org/opendaylight/restconf/nb/rfc8040/jersey/providers/errors/RestconfDocumentedExceptionMapperTest.java @@ -29,7 +29,7 @@ import org.junit.runners.Parameterized.Parameter; import org.junit.runners.Parameterized.Parameters; import org.opendaylight.restconf.common.errors.RestconfDocumentedException; import org.opendaylight.restconf.common.errors.RestconfError; -import org.opendaylight.restconf.nb.rfc8040.MediaTypes; +import org.opendaylight.restconf.nb.jaxrs.JaxRsMediaTypes; import org.opendaylight.restconf.nb.rfc8040.databind.DatabindContext; import org.opendaylight.yangtools.yang.common.ErrorTag; import org.opendaylight.yangtools.yang.common.ErrorType; @@ -84,9 +84,9 @@ public class RestconfDocumentedExceptionMapperTest { "Mapping of the exception with one error entry but null status code. This status code should" + "be derived from single error entry; JSON output", new RestconfDocumentedException("Sample error message"), - mockHttpHeaders(MediaType.APPLICATION_JSON_TYPE, List.of(MediaTypes.APPLICATION_YANG_PATCH_JSON_TYPE)), + mockHttpHeaders(MediaType.APPLICATION_JSON_TYPE, List.of(JaxRsMediaTypes.APPLICATION_YANG_PATCH_JSON)), Response.status(Status.INTERNAL_SERVER_ERROR) - .type(MediaTypes.APPLICATION_YANG_DATA_JSON_TYPE) + .type(JaxRsMediaTypes.APPLICATION_YANG_DATA_JSON) .entity(""" { "errors": { @@ -107,9 +107,9 @@ public class RestconfDocumentedExceptionMapperTest { new RestconfDocumentedException("general message", new IllegalStateException("cause"), List.of( new RestconfError(ErrorType.APPLICATION, ErrorTag.BAD_ATTRIBUTE, "message 1"), new RestconfError(ErrorType.APPLICATION, ErrorTag.OPERATION_FAILED, "message 2"))), - mockHttpHeaders(MediaType.APPLICATION_JSON_TYPE, List.of(MediaTypes.APPLICATION_YANG_PATCH_XML_TYPE)), + mockHttpHeaders(MediaType.APPLICATION_JSON_TYPE, List.of(JaxRsMediaTypes.APPLICATION_YANG_PATCH_XML)), Response.status(Status.BAD_REQUEST) - .type(MediaTypes.APPLICATION_YANG_DATA_XML_TYPE) + .type(JaxRsMediaTypes.APPLICATION_YANG_DATA_XML) .entity(""" @@ -131,7 +131,7 @@ public class RestconfDocumentedExceptionMapperTest { sampleComplexError, mockHttpHeaders(MediaType.APPLICATION_JSON_TYPE, List.of( MediaType.APPLICATION_JSON_TYPE)), Response.status(Status.BAD_REQUEST) - .type(MediaTypes.APPLICATION_YANG_DATA_JSON_TYPE) + .type(JaxRsMediaTypes.APPLICATION_YANG_DATA_JSON) .entity(""" { "errors": { @@ -166,10 +166,10 @@ public class RestconfDocumentedExceptionMapperTest { { "Mapping of the exception with three entries and optional entries set: error app tag (the first error)," + " error info (the second error), and error path (the last error); XML output", - sampleComplexError, mockHttpHeaders(MediaTypes.APPLICATION_YANG_PATCH_JSON_TYPE, - List.of(MediaTypes.APPLICATION_YANG_DATA_XML_TYPE)), + sampleComplexError, mockHttpHeaders(JaxRsMediaTypes.APPLICATION_YANG_PATCH_JSON, + List.of(JaxRsMediaTypes.APPLICATION_YANG_DATA_XML)), Response.status(Status.BAD_REQUEST) - .type(MediaTypes.APPLICATION_YANG_DATA_XML_TYPE) + .type(JaxRsMediaTypes.APPLICATION_YANG_DATA_XML) .entity(""" @@ -217,7 +217,7 @@ public class RestconfDocumentedExceptionMapperTest { @Test public void testFormatingJson() throws JSONException { - assumeTrue(expectedResponse.getMediaType().equals(MediaTypes.APPLICATION_YANG_DATA_JSON_TYPE)); + assumeTrue(expectedResponse.getMediaType().equals(JaxRsMediaTypes.APPLICATION_YANG_DATA_JSON)); exceptionMapper.setHttpHeaders(httpHeaders); final Response response = exceptionMapper.toResponse(thrownException); @@ -237,7 +237,7 @@ public class RestconfDocumentedExceptionMapperTest { actualResponse, expectedResponse); assertEquals(errorMessage, expectedResponse.getStatus(), actualResponse.getStatus()); assertEquals(errorMessage, expectedResponse.getMediaType(), actualResponse.getMediaType()); - if (MediaTypes.APPLICATION_YANG_DATA_JSON_TYPE.equals(expectedResponse.getMediaType())) { + if (JaxRsMediaTypes.APPLICATION_YANG_DATA_JSON.equals(expectedResponse.getMediaType())) { JSONAssert.assertEquals(expectedResponse.getEntity().toString(), actualResponse.getEntity().toString(), true); } else { -- 2.36.6