From fc011b75e80f32fceb1bf27a3f0ba1b5608e6266 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jaroslav=20T=C3=B3th?= Date: Mon, 12 Aug 2019 16:38:38 +0200 Subject: [PATCH] Fixed wrong exception types MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit - 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 Signed-off-by: Robert Varga (cherry picked from commit d30aa7c5024c62e90cac699d1d243940cb3f0ded) --- .../YangInstanceIdentifierDeserializer.java | 87 ++++++++++--------- .../YangInstanceIdentifierSerializer.java | 11 +-- .../impl/RestconfSchemaServiceTest.java | 2 +- .../utils/parser/ParserIdentifierTest.java | 8 +- ...angInstanceIdentifierDeserializerTest.java | 46 +++++----- .../YangInstanceIdentifierSerializerTest.java | 9 +- 6 files changed, 85 insertions(+), 78 deletions(-) diff --git a/restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/utils/parser/YangInstanceIdentifierDeserializer.java b/restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/utils/parser/YangInstanceIdentifierDeserializer.java index e9986d0c44..2a2181c02b 100644 --- a/restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/utils/parser/YangInstanceIdentifierDeserializer.java +++ b/restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/utils/parser/YangInstanceIdentifierDeserializer.java @@ -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 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 keys = listSchemaNode.getKeyDefinition().iterator(); final ImmutableMap.Builder 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 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> typedef = null; + 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 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 '/'."); } } diff --git a/restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/utils/parser/YangInstanceIdentifierSerializer.java b/restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/utils/parser/YangInstanceIdentifierSerializer.java index e618c1f90c..dcd5abbf28 100644 --- a/restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/utils/parser/YangInstanceIdentifierSerializer.java +++ b/restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/utils/parser/YangInstanceIdentifierSerializer.java @@ -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; } diff --git a/restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/services/simple/impl/RestconfSchemaServiceTest.java b/restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/services/simple/impl/RestconfSchemaServiceTest.java index 667925bfaf..c711cdd4ca 100644 --- a/restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/services/simple/impl/RestconfSchemaServiceTest.java +++ b/restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/services/simple/impl/RestconfSchemaServiceTest.java @@ -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); } } diff --git a/restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/utils/parser/ParserIdentifierTest.java b/restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/utils/parser/ParserIdentifierTest.java index 133d9a137c..d5f3568b6b 100644 --- a/restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/utils/parser/ParserIdentifierTest.java +++ b/restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/utils/parser/ParserIdentifierTest.java @@ -215,21 +215,21 @@ public class ParserIdentifierTest { } /** - * Negative test with invalid test identifier. Test should fail with IllegalArgumentException. + * Negative test with invalid test identifier. Test should fail with RestconfDocumentedException. */ @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 IllegalArgumentException. + * should fail with RestconfDocumentedException. */ @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)); } diff --git a/restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/utils/parser/YangInstanceIdentifierDeserializerTest.java b/restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/utils/parser/YangInstanceIdentifierDeserializerTest.java index 89582330f1..58e6a44e8a 100644 --- a/restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/utils/parser/YangInstanceIdentifierDeserializerTest.java +++ b/restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/utils/parser/YangInstanceIdentifierDeserializerTest.java @@ -287,91 +287,91 @@ public class YangInstanceIdentifierDeserializerTest { /** * Negative test when identifier is not followed by slash or equals. Test is expected to fail with - * IllegalArgumentException. + * RestconfDocumentedException. */ @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 IllegalArgumentException. + * is expected to fail with RestconfDocumentedException. */ @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 IllegalArgumentException. + * Test is expected to fail with RestconfDocumentedException. */ @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 IllegalArgumentException. + * is expected to fail with RestconfDocumentedException. */ @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 IllegalArgumentException. + * identifier. Test is expected to fail with RestconfDocumentedException. */ @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 QName when identifier is empty (example: '/'). Test is expected to fail - * with IllegalArgumentException. + * with RestconfDocumentedException. */ @Test public void prepareQnameEmptyIdentifierNegativeTest() { - this.thrown.expect(IllegalArgumentException.class); + this.thrown.expect(RestconfDocumentedException.class); YangInstanceIdentifierDeserializer.create(this.schemaContext, "/"); } /** * Negative test of creating QName when in identifier there is another sign than colon or equals. - * Test is expected to fail with IllegalArgumentException. + * Test is expected to fail with RestconfDocumentedException. */ @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 QName when it is not possible to find module for specified prefix. Test is - * expected to fail with IllegalArgumentException. + * expected to fail with RestconfDocumentedException. */ @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 QName when after prefix and colon there is not parsable identifier as - * local name. Test is expected to fail with IllegalArgumentException. + * local name. Test is expected to fail with RestconfDocumentedException. */ @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 IllegalArgumentException. + * fail with RestconfDocumentedException. */ @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 - * IllegalArgumentException. + * RestconfDocumentedException. */ @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,"); } diff --git a/restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/utils/parser/YangInstanceIdentifierSerializerTest.java b/restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/utils/parser/YangInstanceIdentifierSerializerTest.java index d7fc380a0b..36ee08edc3 100644 --- a/restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/utils/parser/YangInstanceIdentifierSerializerTest.java +++ b/restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/utils/parser/YangInstanceIdentifierSerializerTest.java @@ -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 - * IllegalArgumentException and error message is compared to expected error message. + * RestconfDocumentedException 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 YangInstanceIdentifier are defined in two different * modules by using augmentation. Augmented node in data supplied for serialization has wrong namespace. - * IllegalArgumentException is expected because augmented node is defined in other module than its + * RestconfDocumentedException 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); } } -- 2.36.6