X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Frestconf%2Fsal-rest-connector%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fsal%2Frestconf%2Fimpl%2Ftest%2FRestconfDocumentedExceptionMapperTest.java;h=a40da957936e4a1c714bba211dfd06bba5031be8;hb=fa9c8c2f3a2f762e311510c977932bcf5a7e933e;hp=f0b45ca1da17fe66e24c790e23ad9731d5aafc49;hpb=535539c42e6c506f3d709635780dff3f0856f905;p=netconf.git diff --git a/opendaylight/restconf/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/RestconfDocumentedExceptionMapperTest.java b/opendaylight/restconf/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/RestconfDocumentedExceptionMapperTest.java index f0b45ca1da..a40da95793 100644 --- a/opendaylight/restconf/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/RestconfDocumentedExceptionMapperTest.java +++ b/opendaylight/restconf/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/RestconfDocumentedExceptionMapperTest.java @@ -18,7 +18,6 @@ import static org.mockito.Matchers.any; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.reset; import static org.mockito.Mockito.when; -import com.google.common.collect.ImmutableMap; import com.google.common.collect.Maps; import com.google.common.io.ByteStreams; import com.google.gson.JsonArray; @@ -68,7 +67,6 @@ import org.opendaylight.netconf.sal.restconf.impl.RestconfError; import org.opendaylight.netconf.sal.restconf.impl.RestconfError.ErrorTag; import org.opendaylight.netconf.sal.restconf.impl.RestconfError.ErrorType; import org.w3c.dom.Document; -import org.w3c.dom.Element; import org.w3c.dom.Node; import org.w3c.dom.NodeList; @@ -85,60 +83,6 @@ public class RestconfDocumentedExceptionMapperTest extends JerseyTest { void verifyJson(JsonElement errorInfoElement); } - static class ComplexErrorInfoVerifier implements ErrorInfoVerifier { - - Map expErrorInfo; - - public ComplexErrorInfoVerifier(final Map expErrorInfo) { - this.expErrorInfo = expErrorInfo; - } - - @Override - public void verifyXML(final Node errorInfoNode) { - - final Map mutableExpMap = Maps.newHashMap(expErrorInfo); - final NodeList childNodes = errorInfoNode.getChildNodes(); - for (int i = 0; i < childNodes.getLength(); i++) { - final Node child = childNodes.item(i); - if (child instanceof Element) { - final String expValue = mutableExpMap.remove(child.getNodeName()); - assertNotNull("Found unexpected \"error-info\" child node: " + child.getNodeName(), expValue); - assertEquals("Text content for \"error-info\" child node " + child.getNodeName(), expValue, - child.getTextContent()); - } - } - - if (!mutableExpMap.isEmpty()) { - fail("Missing \"error-info\" child nodes: " + mutableExpMap); - } - } - - @Override - public void verifyJson(final JsonElement errorInfoElement) { - - assertTrue("\"error-info\" Json element is not an Object", errorInfoElement.isJsonObject()); - - final Map actualErrorInfo = Maps.newHashMap(); - for (final Entry entry : errorInfoElement.getAsJsonObject().entrySet()) { - final String leafName = entry.getKey(); - final JsonElement leafElement = entry.getValue(); - actualErrorInfo.put(leafName, leafElement.getAsString()); - } - - final Map mutableExpMap = Maps.newHashMap(expErrorInfo); - for (final Entry actual : actualErrorInfo.entrySet()) { - final String expValue = mutableExpMap.remove(actual.getKey()); - assertNotNull("Found unexpected \"error-info\" child node: " + actual.getKey(), expValue); - assertEquals("Text content for \"error-info\" child node " + actual.getKey(), expValue, - actual.getValue()); - } - - if (!mutableExpMap.isEmpty()) { - fail("Missing \"error-info\" child nodes: " + mutableExpMap); - } - } - } - static class SimpleErrorInfoVerifier implements ErrorInfoVerifier { String expTextContent; @@ -432,18 +376,16 @@ public class RestconfDocumentedExceptionMapperTest extends JerseyTest { } @Test - @Ignore // TODO : we are not supported "error-info" element yet public void testToJsonResponseWithErrorInfo() throws Exception { final String errorInfo = "
1.2.3.4
123"; testJsonResponse(new RestconfDocumentedException(new RestconfError(ErrorType.APPLICATION, ErrorTag.INVALID_VALUE, "mock error", "mock-app-tag", errorInfo)), Status.BAD_REQUEST, ErrorType.APPLICATION, ErrorTag.INVALID_VALUE, "mock error", "mock-app-tag", - new ComplexErrorInfoVerifier(ImmutableMap.of("session-id", "123", "address", "1.2.3.4"))); + new SimpleErrorInfoVerifier(errorInfo)); } @Test - @Ignore //TODO : we are not supporting "error-info" yet public void testToJsonResponseWithExceptionCause() throws Exception { final Exception cause = new Exception("mock exception cause"); @@ -634,18 +576,16 @@ public class RestconfDocumentedExceptionMapperTest extends JerseyTest { } @Test - @Ignore // TODO : we are not supporting "error-info" node yet public void testToXMLResponseWithErrorInfo() throws Exception { final String errorInfo = "
1.2.3.4
123"; testXMLResponse(new RestconfDocumentedException(new RestconfError(ErrorType.APPLICATION, ErrorTag.INVALID_VALUE, "mock error", "mock-app-tag", errorInfo)), Status.BAD_REQUEST, ErrorType.APPLICATION, ErrorTag.INVALID_VALUE, "mock error", "mock-app-tag", - new ComplexErrorInfoVerifier(ImmutableMap.of("session-id", "123", "address", "1.2.3.4"))); + new SimpleErrorInfoVerifier(errorInfo)); } @Test - @Ignore // TODO : we are not supporting "error-info" node yet public void testToXMLResponseWithExceptionCause() throws Exception { final Exception cause = new Exception("mock exception cause");