Fixed wrong exception types 29/87129/1
authorJaroslav Tóth <jtoth@frinx.io>
Mon, 12 Aug 2019 14:38:38 +0000 (16:38 +0200)
committerMartin Bugáň <martin.bugan@pantheon.tech>
Fri, 24 Jan 2020 13:25:48 +0000 (13:25 +0000)
- After implementation of exception mapper we can throw on error
  events RestconfDocumentedException that will be automatically
  mapped to response errors container.
- This patch changes IAE or NPE during serialization/deserialition
  of instance identifier to right RDE types - HTTP method invoked
  on non-existing/malformed IID will lead to returned errors
  container (compliancy against spec.) and not status code 500
  without any description.

Change-Id: I0982e89b90d4a254656b2b9dcdab87fcbb4a8103
Signed-off-by: Jaroslav Tóth <jtoth@frinx.io>
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit d30aa7c5024c62e90cac699d1d243940cb3f0ded)

restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/utils/parser/YangInstanceIdentifierDeserializer.java
restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/utils/parser/YangInstanceIdentifierSerializer.java
restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/services/simple/impl/RestconfSchemaServiceTest.java
restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/utils/parser/ParserIdentifierTest.java
restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/utils/parser/YangInstanceIdentifierDeserializerTest.java
restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/utils/parser/YangInstanceIdentifierSerializerTest.java

index e9986d0c4414dc7aecce2ad5c525613a06717efa..2a2181c02bb0b0dcb68ffbe78566b108e6e528f4 100644 (file)
@@ -7,7 +7,6 @@
  */
 package org.opendaylight.restconf.nb.rfc8040.utils.parser;
 
-import static com.google.common.base.Preconditions.checkArgument;
 import static java.util.Objects.requireNonNull;
 import static org.opendaylight.restconf.nb.rfc8040.utils.RestconfConstants.SLASH;
 import static org.opendaylight.restconf.nb.rfc8040.utils.parser.builder.ParserBuilderConstants.Deserializer.COLON;
@@ -31,7 +30,8 @@ import java.util.Iterator;
 import java.util.List;
 import java.util.Optional;
 import org.opendaylight.restconf.common.errors.RestconfDocumentedException;
-import org.opendaylight.restconf.common.errors.RestconfError;
+import org.opendaylight.restconf.common.errors.RestconfError.ErrorTag;
+import org.opendaylight.restconf.common.errors.RestconfError.ErrorType;
 import org.opendaylight.restconf.common.util.RestUtil;
 import org.opendaylight.restconf.common.util.RestconfSchemaUtil;
 import org.opendaylight.restconf.nb.rfc8040.codecs.RestCodec;
@@ -60,11 +60,12 @@ import org.opendaylight.yangtools.yang.model.api.type.LeafrefTypeDefinition;
 import org.opendaylight.yangtools.yang.model.util.SchemaContextUtil;
 
 /**
- * Deserializer for {@link String} to {@link YangInstanceIdentifier} for
- * restconf.
- *
+ * Deserializer for {@link String} to {@link YangInstanceIdentifier} for restconf.
  */
 public final class YangInstanceIdentifierDeserializer {
+    private static final String PARSING_FAILED_MESSAGE = "Could not parse Instance Identifier '%s'. "
+            + "Offset: '%d' : Reason: ";
+
     private final SchemaContext schemaContext;
     private final String data;
 
@@ -106,7 +107,7 @@ public final class YangInstanceIdentifierDeserializer {
                     prepareNodeWithValue(qname, path);
                 }
             } else {
-                throw new IllegalArgumentException("Bad char " + currentChar() + " on position " + offset + ".");
+                throw getParsingCharFailedException();
             }
         }
 
@@ -115,7 +116,7 @@ public final class YangInstanceIdentifierDeserializer {
 
     private void prepareNodeWithPredicates(final QName qname, final List<PathArgument> path,
             final ListSchemaNode listSchemaNode) {
-        checkValid(listSchemaNode != null, "Data schema node is null");
+        checkValid(listSchemaNode != null, ErrorTag.MALFORMED_MESSAGE, "Data schema node is null");
 
         final Iterator<QName> keys = listSchemaNode.getKeyDefinition().iterator();
         final ImmutableMap.Builder<QName, Object> values = ImmutableMap.builder();
@@ -134,22 +135,19 @@ public final class YangInstanceIdentifierDeserializer {
             }
 
             // check if next value is parsable
-            RestconfDocumentedException.throwIf(!IDENTIFIER_PREDICATE.matches(currentChar()), "",
-                    RestconfError.ErrorType.PROTOCOL, RestconfError.ErrorTag.MALFORMED_MESSAGE);
+            checkValid(IDENTIFIER_PREDICATE.matches(currentChar()), ErrorTag.MALFORMED_MESSAGE,
+                    "Value that starts with character %c is not parsable.", currentChar());
 
             // parse value
             final QName key = keys.next();
             Optional<DataSchemaNode> leafSchemaNode = listSchemaNode.findDataChildByName(key);
-            if (!leafSchemaNode.isPresent()) {
-                throw new RestconfDocumentedException("Schema not found for " + key,
-                        RestconfError.ErrorType.PROTOCOL, RestconfError.ErrorTag.BAD_ELEMENT);
-            }
+            RestconfDocumentedException.throwIf(!leafSchemaNode.isPresent(), ErrorType.PROTOCOL, ErrorTag.BAD_ELEMENT,
+                    "Schema not found for %s", key);
 
             final String value = findAndParsePercentEncoded(nextIdentifierFromNextSequence(IDENTIFIER_PREDICATE));
             final Object valueByType = prepareValueByType(leafSchemaNode.get(), value);
             values.put(key, valueByType);
 
-
             // skip comma
             if (keys.hasNext() && !allCharsConsumed() && currentChar() == COMMA) {
                 skipCurrentChar();
@@ -158,23 +156,21 @@ public final class YangInstanceIdentifierDeserializer {
 
         // the last key is considered to be empty
         if (keys.hasNext()) {
-            if (allCharsConsumed() || currentChar() == SLASH) {
-                values.put(keys.next(), EMPTY_STRING);
-            }
+            // at this point, it must be true that current char is '/' or all chars have already been consumed
+            values.put(keys.next(), EMPTY_STRING);
 
             // there should be no more missing keys
-            RestconfDocumentedException.throwIf(keys.hasNext(),
-                    RestconfError.ErrorType.PROTOCOL, RestconfError.ErrorTag.MISSING_ATTRIBUTE,
-                    "Key value missing for: %s", qname);
+            RestconfDocumentedException.throwIf(keys.hasNext(), ErrorType.PROTOCOL, ErrorTag.MISSING_ATTRIBUTE,
+                    "Cannot parse input identifier '%s'. Key value is missing for QName: %s", data, qname);
         }
 
-        path.add(new YangInstanceIdentifier.NodeIdentifierWithPredicates(qname, values.build()));
+        path.add(YangInstanceIdentifier.NodeIdentifierWithPredicates.of(qname, values.build()));
     }
 
     private Object prepareValueByType(final DataSchemaNode schemaNode, final String value) {
-        Object decoded = null;
+        Object decoded;
 
-        TypeDefinition<? extends TypeDefinition<?>> typedef = null;
+        TypeDefinition<? extends TypeDefinition<?>> typedef;
         if (schemaNode instanceof LeafListSchemaNode) {
             typedef = ((LeafListSchemaNode) schemaNode).getType();
         } else {
@@ -219,11 +215,12 @@ public final class YangInstanceIdentifierDeserializer {
                     return getQNameOfDataSchemaNode(localName);
                 } else {
                     final Module module = moduleForPrefix(prefix);
-                    checkArgument(module != null, "Failed to lookup prefix %s", prefix);
+                    RestconfDocumentedException.throwIf(module == null, ErrorType.PROTOCOL, ErrorTag.UNKNOWN_ELEMENT,
+                            "Failed to lookup for module with name '%s'.", prefix);
                     return QName.create(module.getQNameModule(), localName);
                 }
             default:
-                throw new IllegalArgumentException("Failed build path.");
+                throw getParsingCharFailedException();
         }
     }
 
@@ -232,11 +229,8 @@ public final class YangInstanceIdentifierDeserializer {
         final String value = nextIdentifierFromNextSequence(IDENTIFIER_PREDICATE);
 
         // exception if value attribute is missing
-        RestconfDocumentedException.throwIf(
-                value.isEmpty(),
-                RestconfError.ErrorType.PROTOCOL,
-                RestconfError.ErrorTag.MISSING_ATTRIBUTE,
-                "Value missing for: %s", qname);
+        RestconfDocumentedException.throwIf(value.isEmpty(), ErrorType.PROTOCOL, ErrorTag.MISSING_ATTRIBUTE,
+                "Cannot parse input identifier '%s' - value is missing for QName: %s.", data, qname);
         final DataSchemaNode dataSchemaNode = current.getDataSchemaNode();
         final Object valueByType = prepareValueByType(dataSchemaNode, findAndParsePercentEncoded(value));
         path.add(new YangInstanceIdentifier.NodeWithValue<>(qname, valueByType));
@@ -244,10 +238,10 @@ public final class YangInstanceIdentifierDeserializer {
 
     private void prepareIdentifier(final QName qname, final List<PathArgument> path) {
         final DataSchemaContextNode<?> currentNode = nextContextNode(qname, path);
-        if (currentNode == null) {
-            return;
+        if (currentNode != null) {
+            checkValid(!currentNode.isKeyedEntry(), ErrorTag.MISSING_ATTRIBUTE,
+                    "Entry '%s' requires key or value predicate to be present.", qname);
         }
-        checkValid(!currentNode.isKeyedEntry(), "Entry " + qname + " requires key or value predicate to be present");
     }
 
     @SuppressFBWarnings(value = "NP_NULL_ON_SOME_PATH",
@@ -271,7 +265,7 @@ public final class YangInstanceIdentifierDeserializer {
                 return null;
             }
         }
-        checkValid(current != null, qname + " is not correct schema node identifier.");
+        checkValid(current != null, ErrorTag.MALFORMED_MESSAGE, "'%s' is not correct schema node identifier.", qname);
         while (current.isMixin()) {
             path.add(current.getIdentifier());
             current = current.getChild(qname);
@@ -287,14 +281,25 @@ public final class YangInstanceIdentifierDeserializer {
         return offset == data.length();
     }
 
-    private void checkValid(final boolean condition, final String errorMsg) {
-        checkArgument(condition, "Could not parse Instance Identifier '%s'. Offset: %s : Reason: %s", data, offset,
-            errorMsg);
+    private void checkValid(final boolean condition, final ErrorTag errorTag, final String errorMsg,
+                            final Object... messageArgs) {
+        final Object[] allMessageArguments = new Object[messageArgs.length + 2];
+        allMessageArguments[0] = data;
+        allMessageArguments[1] = offset;
+        System.arraycopy(messageArgs, 0, allMessageArguments, 2, messageArgs.length);
+        RestconfDocumentedException.throwIf(!condition, ErrorType.PROTOCOL, errorTag,
+                PARSING_FAILED_MESSAGE + errorMsg, allMessageArguments);
     }
 
     private void checkValidIdentifierStart() {
-        checkValid(IDENTIFIER_FIRST_CHAR.matches(currentChar()),
-            "Identifier must start with character from set 'a-zA-Z_'");
+        checkValid(IDENTIFIER_FIRST_CHAR.matches(currentChar()), ErrorTag.MALFORMED_MESSAGE,
+                "Identifier must start with character from set 'a-zA-Z_'");
+    }
+
+    private RestconfDocumentedException getParsingCharFailedException() {
+        return new RestconfDocumentedException(String.format(PARSING_FAILED_MESSAGE, data, offset)
+                + String.format("Bad char '%c' on the current position.", currentChar()),
+                ErrorType.PROTOCOL, ErrorTag.MALFORMED_MESSAGE);
     }
 
     private char currentChar() {
@@ -316,7 +321,7 @@ public final class YangInstanceIdentifierDeserializer {
     private void validArg() {
         // every identifier except of the first MUST start with slash
         if (offset != 0) {
-            checkValid(SLASH == currentChar(), "Identifier must start with '/'.");
+            checkValid(SLASH == currentChar(), ErrorTag.MALFORMED_MESSAGE, "Identifier must start with '/'.");
 
             // skip consecutive slashes, users often assume restconf URLs behave just as HTTP does by squashing
             // multiple slashes into a single one
@@ -325,7 +330,7 @@ public final class YangInstanceIdentifierDeserializer {
             }
 
             // check if slash is not also the last char in identifier
-            checkValid(!allCharsConsumed(), "Identifier cannot end with '/'.");
+            checkValid(!allCharsConsumed(), ErrorTag.MALFORMED_MESSAGE, "Identifier cannot end with '/'.");
         }
     }
 
index e618c1f90c206d98e3b655d071dafc48d02ab547..dcd5abbf28106987a255c398bbe9d9cf039578de 100644 (file)
@@ -7,10 +7,12 @@
  */
 package org.opendaylight.restconf.nb.rfc8040.utils.parser;
 
-import com.google.common.base.Preconditions;
 import java.util.Iterator;
 import java.util.Locale;
 import java.util.Map.Entry;
+import org.opendaylight.restconf.common.errors.RestconfDocumentedException;
+import org.opendaylight.restconf.common.errors.RestconfError.ErrorTag;
+import org.opendaylight.restconf.common.errors.RestconfError.ErrorType;
 import org.opendaylight.restconf.nb.rfc8040.utils.RestconfConstants;
 import org.opendaylight.restconf.nb.rfc8040.utils.parser.builder.ParserBuilderConstants;
 import org.opendaylight.restconf.nb.rfc8040.utils.parser.builder.ParserBuilderConstants.Serializer;
@@ -58,10 +60,9 @@ public final class YangInstanceIdentifierSerializer {
 
             final PathArgument arg = data.getPathArguments().get(i);
             variables.setCurrent(variables.getCurrent().getChild(arg));
-
-            Preconditions.checkArgument(variables.getCurrent() != null,
-                    "Invalid input %s: schema for argument %s (after %s) not found", data, arg, path);
-
+            RestconfDocumentedException.throwIf(variables.getCurrent() == null, ErrorType.APPLICATION,
+                    ErrorTag.UNKNOWN_ELEMENT, "Invalid input '%s': schema for argument '%s' (after '%s') not found",
+                    data, arg, path);
             if (variables.getCurrent().isMixin()) {
                 continue;
             }
index 667925bfaf729453097519294aa51de87ba39663..c711cdd4ca2a133ded9440e3052b3e8b74ad8684 100644 (file)
@@ -418,7 +418,7 @@ public class RestconfSchemaServiceTest {
         when(this.mockContextHandler.get()).thenReturn(this.schemaContextWithMountPoints);
 
         // make test
-        this.thrown.expect(IllegalArgumentException.class);
+        this.thrown.expect(RestconfDocumentedException.class);
         this.schemaService.getSchema(NOT_EXISTING_MOUNT_POINT + TEST_MODULE_BEHIND_MOUNT_POINT);
     }
 }
index 133d9a137c926bed4b230bcec75ff12e2cedeb9f..d5f3568b6b1a0baf16307a83c48c52ad4d8175c1 100644 (file)
@@ -215,21 +215,21 @@ public class ParserIdentifierTest {
     }
 
     /**
-     * Negative test with invalid test identifier. Test should fail with <code>IllegalArgumentException</code>.
+     * Negative test with invalid test identifier. Test should fail with <code>RestconfDocumentedException</code>.
      */
     @Test
     public void toInstanceIdentifierInvalidIdentifierNegativeTest() {
-        this.thrown.expect(IllegalArgumentException.class);
+        this.thrown.expect(RestconfDocumentedException.class);
         ParserIdentifier.toInstanceIdentifier(INVALID_TEST_IDENT, this.schemaContext, Optional.empty());
     }
 
     /**
      * Negative test when identifier contains {@link RestconfConstants#MOUNT} but identifier part is not valid. Test
-     * should fail with <code>IllegalArgumentException</code>.
+     * should fail with <code>RestconfDocumentedException</code>.
      */
     @Test
     public void toInstanceIdentifierMountPointInvalidIdentifierNegativeTest() {
-        this.thrown.expect(IllegalArgumentException.class);
+        this.thrown.expect(RestconfDocumentedException.class);
         ParserIdentifier.toInstanceIdentifier(
                 INVALID_MOUNT_POINT_IDENT, this.schemaContext, Optional.of(this.mountPointService));
     }
index 89582330f1e5367c0d4e7b78c07325b922992601..58e6a44e8a6e23102994c6af8de7fef6acbab5e4 100644 (file)
@@ -287,91 +287,91 @@ public class YangInstanceIdentifierDeserializerTest {
 
     /**
      * Negative test when identifier is not followed by slash or equals. Test is expected to fail with
-     * <code>IllegalArgumentException</code>.
+     * <code>RestconfDocumentedException</code>.
      */
     @Test
     public void deserializeBadCharMissingSlashOrEqualNegativeTest() {
-        this.thrown.expect(IllegalArgumentException.class);
+        this.thrown.expect(RestconfDocumentedException.class);
         YangInstanceIdentifierDeserializer.create(this.schemaContext, "deserializer-test:cont*leaf-A");
     }
 
     /**
      * Negative test of validating identifier when there is a slash after container without next identifier. Test
-     * is expected to fail with <code>IllegalArgumentException</code>.
+     * is expected to fail with <code>RestconfDocumentedException</code>.
      */
     @Test
     public void validArgIdentifierContainerEndsWithSlashNegativeTest() {
-        this.thrown.expect(IllegalArgumentException.class);
+        this.thrown.expect(RestconfDocumentedException.class);
         YangInstanceIdentifierDeserializer.create(this.schemaContext, "deserializer-test:contA/");
     }
 
     /**
      * Negative test of validating identifier when there are multiple slashes after container without next identifier.
-     * Test is expected to fail with <code>IllegalArgumentException</code>.
+     * Test is expected to fail with <code>RestconfDocumentedException</code>.
      */
     @Test
     public void validArgIdentifierContainerEndsWithMultipleSlashesNegativeTest() {
-        this.thrown.expect(IllegalArgumentException.class);
+        this.thrown.expect(RestconfDocumentedException.class);
         YangInstanceIdentifierDeserializer.create(this.schemaContext, "deserializer-test:contA///");
     }
 
     /**
      * Negative test of validating identifier when there is a slash after list key values without next identifier. Test
-     * is expected to fail with <code>IllegalArgumentException</code>.
+     * is expected to fail with <code>RestconfDocumentedException</code>.
      */
     @Test
-    public void validArgIdentifierListEndsWithSlashNegativeTest() {
-        this.thrown.expect(IllegalArgumentException.class);
+    public void validArgIdentifierListEndsWithSlashLNegativeTest() {
+        this.thrown.expect(RestconfDocumentedException.class);
         YangInstanceIdentifierDeserializer.create(this.schemaContext, "deserializer-test:list-one-key=value/");
     }
 
     /**
      * Negative test of validating identifier when there are multiple slashes after list key values without next
-     * identifier. Test is expected to fail with <code>IllegalArgumentException</code>.
+     * identifier. Test is expected to fail with <code>RestconfDocumentedException</code>.
      */
     @Test
     public void validArgIdentifierListEndsWithSlashesNegativeTest() {
-        this.thrown.expect(IllegalArgumentException.class);
+        this.thrown.expect(RestconfDocumentedException.class);
         YangInstanceIdentifierDeserializer.create(this.schemaContext, "deserializer-test:list-one-key=value//");
     }
 
     /**
      * Negative test of creating <code>QName</code> when identifier is empty (example: '/'). Test is expected to fail
-     * with <code>IllegalArgumentException</code>.
+     * with <code>RestconfDocumentedException</code>.
      */
     @Test
     public void prepareQnameEmptyIdentifierNegativeTest() {
-        this.thrown.expect(IllegalArgumentException.class);
+        this.thrown.expect(RestconfDocumentedException.class);
         YangInstanceIdentifierDeserializer.create(this.schemaContext, "/");
     }
 
     /**
      * Negative test of creating <code>QName</code> when in identifier there is another sign than colon or equals.
-     * Test is expected to fail with <code>IllegalArgumentException</code>.
+     * Test is expected to fail with <code>RestconfDocumentedException</code>.
      */
     @Test
     public void prepareQnameBuildPathNegativeTest() {
-        this.thrown.expect(IllegalArgumentException.class);
+        this.thrown.expect(RestconfDocumentedException.class);
         YangInstanceIdentifierDeserializer.create(this.schemaContext, "deserializer-test*contA");
     }
 
     /**
      * Negative test of creating <code>QName</code> when it is not possible to find module for specified prefix. Test is
-     * expected to fail with <code>IllegalArgumentException</code>.
+     * expected to fail with <code>RestconfDocumentedException</code>.
      */
     @Test
     public void prepareQnameNotExistingPrefixNegativeTest() {
-        this.thrown.expect(IllegalArgumentException.class);
+        this.thrown.expect(RestconfDocumentedException.class);
         YangInstanceIdentifierDeserializer.create(this.schemaContext, "not-existing:contA");
     }
 
     /**
      * Negative test of creating <code>QName</code> when after prefix and colon there is not parsable identifier as
-     * local name. Test is expected to fail with <code>IllegalArgumentException</code>.
+     * local name. Test is expected to fail with <code>RestconfDocumentedException</code>.
      */
     @Test
     public void prepareQnameNotValidPrefixAndLocalNameNegativeTest() {
-        this.thrown.expect(IllegalArgumentException.class);
+        this.thrown.expect(RestconfDocumentedException.class);
         YangInstanceIdentifierDeserializer.create(this.schemaContext, "deserializer-test:*not-parsable-identifier");
     }
 
@@ -428,21 +428,21 @@ public class YangInstanceIdentifierDeserializerTest {
 
     /**
      * Negative test of getting next identifier when current node is keyed entry. Test is expected to
-     * fail with <code>IllegalArgumentException</code>.
+     * fail with <code>RestconfDocumentedException</code>.
      */
     @Test
     public void prepareIdentifierNotKeyedEntryNegativeTest() {
-        this.thrown.expect(IllegalArgumentException.class);
+        this.thrown.expect(RestconfDocumentedException.class);
         YangInstanceIdentifierDeserializer.create(this.schemaContext, "deserializer-test:list-one-key");
     }
 
     /**
      * Negative test when there is a comma also after the last key. Test is expected to fail with
-     * <code>IllegalArgumentException</code>.
+     * <code>RestconfDocumentedException</code>.
      */
     @Test
     public void deserializeKeysEndsWithComaNegativeTest() {
-        this.thrown.expect(IllegalArgumentException.class);
+        this.thrown.expect(RestconfDocumentedException.class);
         YangInstanceIdentifierDeserializer.create(this.schemaContext,
                 "deserializer-test:list-multiple-keys=value,100,false,");
     }
index d7fc380a0bd1ad831b765598ffad47557a26d99d..36ee08edc3daea01a230bf4cf2c88094c9707d3c 100644 (file)
@@ -18,6 +18,7 @@ import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.rules.ExpectedException;
+import org.opendaylight.restconf.common.errors.RestconfDocumentedException;
 import org.opendaylight.restconf.nb.rfc8040.TestRestconfUtils;
 import org.opendaylight.restconf.nb.rfc8040.utils.parser.builder.ParserBuilderConstants;
 import org.opendaylight.yangtools.yang.common.QName;
@@ -218,7 +219,7 @@ public class YangInstanceIdentifierSerializerTest {
 
     /**
      * Negative test when it is not possible to find child node of current node. Test is expected to fail with
-     * <code>IllegalArgumentException</code> and error message is compared to expected error message.
+     * <code>RestconfDocumentedException</code> and error message is compared to expected error message.
      */
     @Test
     public void serializeChildNodeNotFoundNegativeTest() {
@@ -227,7 +228,7 @@ public class YangInstanceIdentifierSerializerTest {
                 .node(QName.create("serializer:test", "2016-06-06", "not-existing-leaf"))
                 .build();
 
-        this.thrown.expect(IllegalArgumentException.class);
+        this.thrown.expect(RestconfDocumentedException.class);
         YangInstanceIdentifierSerializer.create(this.schemaContext, data);
     }
 
@@ -311,7 +312,7 @@ public class YangInstanceIdentifierSerializerTest {
     /**
      * Test of serialization when nodes in input <code>YangInstanceIdentifier</code> are defined in two different
      * modules by using augmentation. Augmented node in data supplied for serialization has wrong namespace.
-     * <code>IllegalArgumentException</code> is expected because augmented node is defined in other module than its
+     * <code>RestconfDocumentedException</code> is expected because augmented node is defined in other module than its
      * parent and will not be found.
      */
     @Test
@@ -327,7 +328,7 @@ public class YangInstanceIdentifierSerializerTest {
                 .node(child)
                 .build();
 
-        this.thrown.expect(IllegalArgumentException.class);
+        this.thrown.expect(RestconfDocumentedException.class);
         YangInstanceIdentifierSerializer.create(this.schemaContext, data);
     }
 }