From ef4102da1765316e954649878b360cd99a8c7bd7 Mon Sep 17 00:00:00 2001 From: Jakub Toth Date: Wed, 12 Oct 2016 18:59:33 +0200 Subject: [PATCH] Bug 6931 - Fix unsupported specific type of leaf * add value to YangInstanceIdentifier as type of leaf * converting of value of leaf to String in YangInstanceIdentifierSerializer * fix tests according to parsing value of leaf by type Change-Id: I4796b0b116b46d57b9c302bb828beab692f40ed3 Signed-off-by: Jakub Toth --- .../YangInstanceIdentifierDeserializer.java | 109 ++++++++++++++++-- .../YangInstanceIdentifierSerializer.java | 2 +- .../restconf/parser/IdentifierCodecTest.java | 6 +- ...angInstanceIdentifierDeserializerTest.java | 92 ++++++++------- 4 files changed, 146 insertions(+), 63 deletions(-) diff --git a/restconf/sal-rest-connector/src/main/java/org/opendaylight/restconf/parser/builder/YangInstanceIdentifierDeserializer.java b/restconf/sal-rest-connector/src/main/java/org/opendaylight/restconf/parser/builder/YangInstanceIdentifierDeserializer.java index 00c3a2cd82..89315be515 100644 --- a/restconf/sal-rest-connector/src/main/java/org/opendaylight/restconf/parser/builder/YangInstanceIdentifierDeserializer.java +++ b/restconf/sal-rest-connector/src/main/java/org/opendaylight/restconf/parser/builder/YangInstanceIdentifierDeserializer.java @@ -15,10 +15,13 @@ import java.util.Iterator; import java.util.LinkedList; import java.util.List; import org.opendaylight.netconf.md.sal.rest.common.RestconfValidationUtils; +import org.opendaylight.netconf.sal.rest.impl.RestUtil; +import org.opendaylight.netconf.sal.restconf.impl.RestCodec; import org.opendaylight.netconf.sal.restconf.impl.RestconfError; import org.opendaylight.restconf.utils.RestconfConstants; import org.opendaylight.restconf.utils.parser.builder.ParserBuilderConstants; import org.opendaylight.restconf.utils.schema.context.RestconfSchemaUtil; +import org.opendaylight.yangtools.concepts.Codec; import org.opendaylight.yangtools.yang.common.QName; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument; @@ -26,9 +29,16 @@ import org.opendaylight.yangtools.yang.data.util.DataSchemaContextNode; import org.opendaylight.yangtools.yang.data.util.DataSchemaContextTree; import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode; import org.opendaylight.yangtools.yang.model.api.DataSchemaNode; +import org.opendaylight.yangtools.yang.model.api.IdentitySchemaNode; +import org.opendaylight.yangtools.yang.model.api.LeafListSchemaNode; +import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode; import org.opendaylight.yangtools.yang.model.api.ListSchemaNode; import org.opendaylight.yangtools.yang.model.api.Module; import org.opendaylight.yangtools.yang.model.api.SchemaContext; +import org.opendaylight.yangtools.yang.model.api.TypeDefinition; +import org.opendaylight.yangtools.yang.model.api.type.IdentityrefTypeDefinition; +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 @@ -63,7 +73,7 @@ public final class YangInstanceIdentifierDeserializer { // this is the last identifier (input is consumed) or end of identifier (slash) if (allCharsConsumed(variables) - || currentChar(variables.getOffset(), variables.getData()) == RestconfConstants.SLASH) { + || (currentChar(variables.getOffset(), variables.getData()) == RestconfConstants.SLASH)) { prepareIdentifier(qname, path, variables); path.add(variables.getCurrent().getIdentifier()); } else if (currentChar(variables.getOffset(), @@ -96,8 +106,8 @@ public final class YangInstanceIdentifierDeserializer { skipCurrentChar(variables); // read key value separated by comma - while (keys.hasNext() && !allCharsConsumed(variables) && currentChar(variables.getOffset(), - variables.getData()) != RestconfConstants.SLASH) { + while (keys.hasNext() && !allCharsConsumed(variables) && (currentChar(variables.getOffset(), + variables.getData()) != RestconfConstants.SLASH)) { // empty key value if (currentChar(variables.getOffset(), variables.getData()) == ParserBuilderConstants.Deserializer.COMMA) { @@ -116,12 +126,22 @@ public final class YangInstanceIdentifierDeserializer { ); // parse value - values.put(keys.next(), findAndParsePercentEncoded(nextIdentifierFromNextSequence( - ParserBuilderConstants.Deserializer.IDENTIFIER_PREDICATE, variables))); + final QName key = keys.next(); + DataSchemaNode leafSchemaNode = null; + if (dataSchemaNode instanceof ListSchemaNode) { + leafSchemaNode = ((ListSchemaNode) dataSchemaNode).getDataChildByName(key); + } else if (dataSchemaNode instanceof LeafListSchemaNode) { + leafSchemaNode = dataSchemaNode; + } + final String value = findAndParsePercentEncoded(nextIdentifierFromNextSequence( + ParserBuilderConstants.Deserializer.IDENTIFIER_PREDICATE, variables)); + final Object valueByType = prepareValueByType(leafSchemaNode, value, variables); + values.put(key, valueByType); + // skip comma - if (keys.hasNext() && !allCharsConsumed(variables) && currentChar( - variables.getOffset(), variables.getData()) == ParserBuilderConstants.Deserializer.COMMA) { + if (keys.hasNext() && !allCharsConsumed(variables) && (currentChar( + variables.getOffset(), variables.getData()) == ParserBuilderConstants.Deserializer.COMMA)) { skipCurrentChar(variables); } } @@ -129,7 +149,7 @@ public final class YangInstanceIdentifierDeserializer { // the last key is considered to be empty if (keys.hasNext()) { if (allCharsConsumed(variables) - || currentChar(variables.getOffset(), variables.getData()) == RestconfConstants.SLASH) { + || (currentChar(variables.getOffset(), variables.getData()) == RestconfConstants.SLASH)) { values.put(keys.next(), ParserBuilderConstants.Deserializer.EMPTY_STRING); } @@ -145,6 +165,70 @@ public final class YangInstanceIdentifierDeserializer { path.add(new YangInstanceIdentifier.NodeIdentifierWithPredicates(qname, values.build())); } + private static Object prepareValueByType(final DataSchemaNode schemaNode, final String value, + final MainVarsWrapper vars) { + Object decoded = null; + + TypeDefinition> typedef = null; + if (schemaNode instanceof LeafListSchemaNode) { + typedef = ((LeafListSchemaNode) schemaNode).getType(); + } else { + typedef = ((LeafSchemaNode) schemaNode).getType(); + } + final TypeDefinition baseType = RestUtil.resolveBaseTypeFrom(typedef); + if (baseType instanceof LeafrefTypeDefinition) { + typedef = SchemaContextUtil.getBaseTypeForLeafRef((LeafrefTypeDefinition) baseType, vars.getSchemaContext(), + schemaNode); + } + final Codec codec = RestCodec.from(typedef, null); + decoded = codec.deserialize(value); + if (decoded == null) { + if ((baseType instanceof IdentityrefTypeDefinition)) { + decoded = toQName(value, schemaNode, vars.getSchemaContext()); + } + } + return decoded; + } + + private static Object toQName(final String value, final DataSchemaNode schemaNode, + final SchemaContext schemaContext) { + final String moduleName = toModuleName(value); + final String nodeName = toNodeName(value); + final Module module = schemaContext.findModuleByName(moduleName, null); + for (final IdentitySchemaNode identitySchemaNode : module.getIdentities()) { + final QName qName = identitySchemaNode.getQName(); + if (qName.getLocalName().equals(nodeName)) { + return qName; + } + } + return QName.create(schemaNode.getQName().getNamespace(), schemaNode.getQName().getRevision(), value); + } + + private static String toNodeName(final String str) { + final int idx = str.indexOf(':'); + if (idx == -1) { + return str; + } + + if (str.indexOf(':', idx + 1) != -1) { + return str; + } + + return str.substring(idx + 1); + } + + private static String toModuleName(final String str) { + final int idx = str.indexOf(':'); + if (idx == -1) { + return null; + } + + if (str.indexOf(':', idx + 1) != -1) { + return null; + } + + return str.substring(0, idx); + } private static QName prepareQName(final MainVarsWrapper variables) { checkValid( @@ -173,8 +257,8 @@ public final class YangInstanceIdentifierDeserializer { variables.getOffset()); localName = nextIdentifierFromNextSequence(ParserBuilderConstants.Deserializer.IDENTIFIER, variables); - if (!allCharsConsumed(variables) && currentChar - (variables.getOffset(), variables.getData()) == ParserBuilderConstants.Deserializer.EQUAL) { + if (!allCharsConsumed(variables) && (currentChar + (variables.getOffset(), variables.getData()) == ParserBuilderConstants.Deserializer.EQUAL)) { return getQNameOfDataSchemaNode(localName, variables); } else { final Module module = moduleForPrefix(prefix, variables.getSchemaContext()); @@ -215,8 +299,9 @@ public final class YangInstanceIdentifierDeserializer { RestconfError.ErrorTag.MISSING_ATTRIBUTE, "Value missing for: " + qname ); - - path.add(new YangInstanceIdentifier.NodeWithValue<>(qname, findAndParsePercentEncoded(value))); + final DataSchemaNode dataSchemaNode = variables.getCurrent().getDataSchemaNode(); + final Object valueByType = prepareValueByType(dataSchemaNode, findAndParsePercentEncoded(value), variables); + path.add(new YangInstanceIdentifier.NodeWithValue<>(qname, valueByType)); } private static void prepareIdentifier(final QName qname, final List path, diff --git a/restconf/sal-rest-connector/src/main/java/org/opendaylight/restconf/parser/builder/YangInstanceIdentifierSerializer.java b/restconf/sal-rest-connector/src/main/java/org/opendaylight/restconf/parser/builder/YangInstanceIdentifierSerializer.java index 538dbdc3d4..8176b0fe2f 100644 --- a/restconf/sal-rest-connector/src/main/java/org/opendaylight/restconf/parser/builder/YangInstanceIdentifierSerializer.java +++ b/restconf/sal-rest-connector/src/main/java/org/opendaylight/restconf/parser/builder/YangInstanceIdentifierSerializer.java @@ -98,7 +98,7 @@ public final class YangInstanceIdentifierSerializer { path.append(arg.getNodeType().getLocalName()); path.append(ParserBuilderConstants.Deserializer.EQUAL); - String value = ((NodeWithValue) arg).getValue(); + String value = String.valueOf(((NodeWithValue) arg).getValue()); if (Serializer.PERCENT_ENCODE_CHARS.matchesAnyOf(value)) { value = parsePercentEncodeChars(value); } diff --git a/restconf/sal-rest-connector/src/test/java/org/opendaylight/restconf/parser/IdentifierCodecTest.java b/restconf/sal-rest-connector/src/test/java/org/opendaylight/restconf/parser/IdentifierCodecTest.java index 5e0e266cac..e1cdd8ba6b 100644 --- a/restconf/sal-rest-connector/src/test/java/org/opendaylight/restconf/parser/IdentifierCodecTest.java +++ b/restconf/sal-rest-connector/src/test/java/org/opendaylight/restconf/parser/IdentifierCodecTest.java @@ -10,7 +10,6 @@ package org.opendaylight.restconf.parser; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; - import org.junit.Before; import org.junit.Test; import org.opendaylight.controller.md.sal.rest.common.TestRestconfUtils; @@ -25,6 +24,7 @@ public class IdentifierCodecTest { private static final String URI_WITH_LIST_AND_LEAF = "list-test:top/list1=%2C%27" + '"' + "%3A" + '"' + "%20%2F,,foo/list2=a,b/result"; private static final String URI_WITH_LEAF_LIST = "list-test:top/Y=x%3Ay"; + private static final String URI_WITH_INT_VAL_LEAF_LIST = "list-test:top/Y=4"; private SchemaContext schemaContext; @@ -56,11 +56,11 @@ public class IdentifierCodecTest { @Test public void codecLeafListTest() { final YangInstanceIdentifier dataYangII = IdentifierCodec.deserialize( - this.URI_WITH_LEAF_LIST, this.schemaContext); + this.URI_WITH_INT_VAL_LEAF_LIST, this.schemaContext); final String serializedDataYangII = IdentifierCodec.serialize(dataYangII, this.schemaContext); assertEquals("Failed codec deserialization and serialization test", - this.URI_WITH_LEAF_LIST, serializedDataYangII); + this.URI_WITH_INT_VAL_LEAF_LIST, serializedDataYangII); } /** diff --git a/restconf/sal-rest-connector/src/test/java/org/opendaylight/restconf/parser/builder/YangInstanceIdentifierDeserializerTest.java b/restconf/sal-rest-connector/src/test/java/org/opendaylight/restconf/parser/builder/YangInstanceIdentifierDeserializerTest.java index 43b9b218a9..e6d24ec251 100644 --- a/restconf/sal-rest-connector/src/test/java/org/opendaylight/restconf/parser/builder/YangInstanceIdentifierDeserializerTest.java +++ b/restconf/sal-rest-connector/src/test/java/org/opendaylight/restconf/parser/builder/YangInstanceIdentifierDeserializerTest.java @@ -11,14 +11,12 @@ package org.opendaylight.restconf.parser.builder; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; - import com.google.common.collect.Iterables; import com.google.common.collect.Sets; import java.util.Iterator; import java.util.LinkedHashMap; import java.util.Map; import org.junit.Before; -import org.junit.Ignore; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; @@ -43,7 +41,7 @@ public class YangInstanceIdentifierDeserializerTest { @Before public void init() throws Exception { - schemaContext = TestRestconfUtils.loadSchemaContext("/restconf/parser/deserializer"); + this.schemaContext = TestRestconfUtils.loadSchemaContext("/restconf/parser/deserializer"); } /** @@ -53,7 +51,7 @@ public class YangInstanceIdentifierDeserializerTest { @Test public void deserializeContainerTest() { final Iterable result = YangInstanceIdentifierDeserializer - .create(schemaContext, "deserializer-test:contA"); + .create(this.schemaContext, "deserializer-test:contA"); assertEquals("Result does not contains expected number of path arguments", 1, Iterables.size(result)); assertEquals("Not expected path argument", @@ -68,7 +66,7 @@ public class YangInstanceIdentifierDeserializerTest { @Test public void deserializeContainerWithLeafTest() { final Iterable result = YangInstanceIdentifierDeserializer - .create(schemaContext, "deserializer-test:contA/leaf-A"); + .create(this.schemaContext, "deserializer-test:contA/leaf-A"); assertEquals("Result does not contains expected number of path arguments", 2, Iterables.size(result)); @@ -88,7 +86,7 @@ public class YangInstanceIdentifierDeserializerTest { @Test public void deserializeContainerWithListWithLeafListTest() { final Iterable result = YangInstanceIdentifierDeserializer - .create(schemaContext, "deserializer-test:contA/list-A=100/leaf-list-AA=instance"); + .create(this.schemaContext, "deserializer-test:contA/list-A=100/leaf-list-AA=instance"); assertEquals("Result does not contains expected number of path arguments", 5, Iterables.size(result)); @@ -126,7 +124,7 @@ public class YangInstanceIdentifierDeserializerTest { @Test public void deserializeListWithNoKeysTest() { final Iterable result = YangInstanceIdentifierDeserializer - .create(schemaContext, "deserializer-test:list-no-key"); + .create(this.schemaContext, "deserializer-test:list-no-key"); assertEquals("Result does not contains expected number of path arguments", 2, Iterables.size(result)); @@ -148,7 +146,7 @@ public class YangInstanceIdentifierDeserializerTest { @Test public void deserializeListWithOneKeyTest() { final Iterable result = YangInstanceIdentifierDeserializer - .create(schemaContext, "deserializer-test:list-one-key=value"); + .create(this.schemaContext, "deserializer-test:list-one-key=value"); assertEquals("Result does not contains expected number of path arguments", 2, Iterables.size(result)); @@ -176,7 +174,7 @@ public class YangInstanceIdentifierDeserializerTest { values.put(QName.create(list, "enabled"), false); final Iterable result = YangInstanceIdentifierDeserializer - .create(schemaContext, "deserializer-test:list-multiple-keys=value,100,false"); + .create(this.schemaContext, "deserializer-test:list-multiple-keys=value,100,false"); assertEquals("Result does not contains expected number of path arguments", 2, Iterables.size(result)); @@ -197,7 +195,7 @@ public class YangInstanceIdentifierDeserializerTest { @Test public void deserializeLeafListTest() { final Iterable result = YangInstanceIdentifierDeserializer - .create(schemaContext, "deserializer-test:leaf-list-0=true"); + .create(this.schemaContext, "deserializer-test:leaf-list-0=true"); assertEquals("Result does not contains expected number of path arguments", 2, Iterables.size(result)); @@ -217,7 +215,7 @@ public class YangInstanceIdentifierDeserializerTest { */ @Test public void deserializeEmptyDataTest() { - final Iterable result = YangInstanceIdentifierDeserializer.create(schemaContext, ""); + final Iterable result = YangInstanceIdentifierDeserializer.create(this.schemaContext, ""); assertTrue("Empty result expected", Iterables.isEmpty(result)); } @@ -227,7 +225,7 @@ public class YangInstanceIdentifierDeserializerTest { */ @Test public void deserializeNullSchemaContextNegativeTest() { - thrown.expect(NullPointerException.class); + this.thrown.expect(NullPointerException.class); YangInstanceIdentifierDeserializer.create(null, "deserializer-test:contA"); } @@ -237,8 +235,8 @@ public class YangInstanceIdentifierDeserializerTest { */ @Test public void nullDataNegativeNegativeTest() { - thrown.expect(NullPointerException.class); - YangInstanceIdentifierDeserializer.create(schemaContext, null); + this.thrown.expect(NullPointerException.class); + YangInstanceIdentifierDeserializer.create(this.schemaContext, null); } /** @@ -247,8 +245,8 @@ public class YangInstanceIdentifierDeserializerTest { */ @Test public void deserializeBadCharMissingSlashOrEqualNegativeTest() { - thrown.expect(IllegalArgumentException.class); - YangInstanceIdentifierDeserializer.create(schemaContext, "deserializer-test:cont*leaf-A"); + this.thrown.expect(IllegalArgumentException.class); + YangInstanceIdentifierDeserializer.create(this.schemaContext, "deserializer-test:cont*leaf-A"); } /** @@ -257,8 +255,8 @@ public class YangInstanceIdentifierDeserializerTest { */ @Test public void validArgIdentifierContainerEndsWithSlashNegativeTest() { - thrown.expect(IllegalArgumentException.class); - YangInstanceIdentifierDeserializer.create(schemaContext, "deserializer-test:contA/"); + this.thrown.expect(IllegalArgumentException.class); + YangInstanceIdentifierDeserializer.create(this.schemaContext, "deserializer-test:contA/"); } /** @@ -267,8 +265,8 @@ public class YangInstanceIdentifierDeserializerTest { */ @Test public void validArgIdentifierListEndsWithSlashLNegativeTest() { - thrown.expect(IllegalArgumentException.class); - YangInstanceIdentifierDeserializer.create(schemaContext, "deserializer-test:list-one-key=value/"); + this.thrown.expect(IllegalArgumentException.class); + YangInstanceIdentifierDeserializer.create(this.schemaContext, "deserializer-test:list-one-key=value/"); } /** @@ -277,8 +275,8 @@ public class YangInstanceIdentifierDeserializerTest { */ @Test public void prepareQnameEmptyIdentifierNegativeTest() { - thrown.expect(IllegalArgumentException.class); - YangInstanceIdentifierDeserializer.create(schemaContext, "/"); + this.thrown.expect(IllegalArgumentException.class); + YangInstanceIdentifierDeserializer.create(this.schemaContext, "/"); } /** @@ -287,8 +285,8 @@ public class YangInstanceIdentifierDeserializerTest { */ @Test public void prepareQnameTwoSlashesNegativeTest() { - thrown.expect(IllegalArgumentException.class); - YangInstanceIdentifierDeserializer.create(schemaContext, "deserializer-test:contA//leaf-A"); + this.thrown.expect(IllegalArgumentException.class); + YangInstanceIdentifierDeserializer.create(this.schemaContext, "deserializer-test:contA//leaf-A"); } /** @@ -297,8 +295,8 @@ public class YangInstanceIdentifierDeserializerTest { */ @Test public void prepareQnameBuildPathNegativeTest() { - thrown.expect(IllegalArgumentException.class); - YangInstanceIdentifierDeserializer.create(schemaContext, "deserializer-test*contA"); + this.thrown.expect(IllegalArgumentException.class); + YangInstanceIdentifierDeserializer.create(this.schemaContext, "deserializer-test*contA"); } /** @@ -307,8 +305,8 @@ public class YangInstanceIdentifierDeserializerTest { */ @Test public void prepareQnameNotExistingPrefixNegativeTest() { - thrown.expect(IllegalArgumentException.class); - YangInstanceIdentifierDeserializer.create(schemaContext, "not-existing:contA"); + this.thrown.expect(IllegalArgumentException.class); + YangInstanceIdentifierDeserializer.create(this.schemaContext, "not-existing:contA"); } /** @@ -317,8 +315,8 @@ public class YangInstanceIdentifierDeserializerTest { */ @Test public void prepareQnameNotValidPrefixAndLocalNameNegativeTest() { - thrown.expect(IllegalArgumentException.class); - YangInstanceIdentifierDeserializer.create(schemaContext, "deserializer-test:*not-parsable-identifier"); + this.thrown.expect(IllegalArgumentException.class); + YangInstanceIdentifierDeserializer.create(this.schemaContext, "deserializer-test:*not-parsable-identifier"); } /** @@ -327,8 +325,8 @@ public class YangInstanceIdentifierDeserializerTest { */ @Test public void prepareQnameErrorParsingNegativeTest() { - thrown.expect(StringIndexOutOfBoundsException.class); - YangInstanceIdentifierDeserializer.create(schemaContext, "deserializer-test:"); + this.thrown.expect(StringIndexOutOfBoundsException.class); + YangInstanceIdentifierDeserializer.create(this.schemaContext, "deserializer-test:"); } /** @@ -339,7 +337,7 @@ public class YangInstanceIdentifierDeserializerTest { @Test public void prepareQnameNotValidContainerNameNegativeTest() { try { - YangInstanceIdentifierDeserializer.create(schemaContext, "deserializer-test:contA/leafB"); + YangInstanceIdentifierDeserializer.create(this.schemaContext, "deserializer-test:contA/leafB"); fail("Test should fail due to unknown child node in container"); } catch (final RestconfDocumentedException e) { assertEquals("Not expected error type", @@ -359,7 +357,7 @@ public class YangInstanceIdentifierDeserializerTest { @Test public void prepareQnameNotValidListNameNegativeTest() { try { - YangInstanceIdentifierDeserializer.create(schemaContext, "deserializer-test:list-no-key/disabled=false"); + YangInstanceIdentifierDeserializer.create(this.schemaContext, "deserializer-test:list-no-key/disabled=false"); fail("Test should fail due to unknown child node in list"); } catch (final RestconfDocumentedException e) { assertEquals("Not expected error type", @@ -377,8 +375,8 @@ public class YangInstanceIdentifierDeserializerTest { */ @Test public void prepareIdentifierNotKeyedEntryNegativeTest() { - thrown.expect(IllegalArgumentException.class); - YangInstanceIdentifierDeserializer.create(schemaContext, "deserializer-test:list-one-key"); + this.thrown.expect(IllegalArgumentException.class); + YangInstanceIdentifierDeserializer.create(this.schemaContext, "deserializer-test:list-one-key"); } /** @@ -387,8 +385,8 @@ public class YangInstanceIdentifierDeserializerTest { */ @Test public void deserializeKeysEndsWithComaNegativeTest() { - thrown.expect(IllegalArgumentException.class); - YangInstanceIdentifierDeserializer.create( schemaContext, + this.thrown.expect(IllegalArgumentException.class); + YangInstanceIdentifierDeserializer.create( this.schemaContext, "deserializer-test:list-multiple-keys=value,100,false,"); } @@ -405,7 +403,7 @@ public class YangInstanceIdentifierDeserializerTest { values.put(QName.create(list, "enabled"), ""); final Iterable result = YangInstanceIdentifierDeserializer.create( - schemaContext, "deserializer-test:list-multiple-keys=%3Afoo,,/string-value"); + this.schemaContext, "deserializer-test:list-multiple-keys=%3Afoo,,/string-value"); assertEquals("Result does not contains expected number of path arguments", 3, Iterables.size(result)); @@ -435,7 +433,7 @@ public class YangInstanceIdentifierDeserializerTest { public void notAllListKeysEncodedNegativeTest() { try { YangInstanceIdentifierDeserializer.create( - schemaContext, "deserializer-test:list-multiple-keys=%3Afoo/string-value"); + this.schemaContext, "deserializer-test:list-multiple-keys=%3Afoo/string-value"); fail("Test should fail due to missing list key values"); } catch (final RestconfDocumentedException e) { assertEquals("Not expected error type", @@ -453,16 +451,16 @@ public class YangInstanceIdentifierDeserializerTest { */ @Test public void percentEncodedKeyEndsWithNoPercentEncodedChars() { - final String URI = "deserializer-test:list-multiple-keys=%3Afoo,bar%3A,foo%3Abar"; + final String URI = "deserializer-test:list-multiple-keys=%3Afoo,1,true"; final YangInstanceIdentifier result = YangInstanceIdentifier.create( - YangInstanceIdentifierDeserializer.create(schemaContext, URI)); + YangInstanceIdentifierDeserializer.create(this.schemaContext, URI)); final Iterator> resultListKeys = ((YangInstanceIdentifier.NodeIdentifierWithPredicates) result.getLastPathArgument()).getKeyValues().entrySet().iterator(); assertEquals(":foo", resultListKeys.next().getValue()); - assertEquals("bar:", resultListKeys.next().getValue()); - assertEquals("foo:bar", resultListKeys.next().getValue()); + assertEquals(new Short("1"), resultListKeys.next().getValue()); + assertEquals(true, resultListKeys.next().getValue()); } /** @@ -477,7 +475,7 @@ public class YangInstanceIdentifierDeserializerTest { values.put(QName.create(list, "enabled"), ""); final Iterable result = YangInstanceIdentifierDeserializer - .create(schemaContext, "deserializer-test:list-multiple-keys=,,"); + .create(this.schemaContext, "deserializer-test:list-multiple-keys=,,"); assertEquals("Result does not contains expected number of path arguments", 2, Iterables.size(result)); @@ -499,7 +497,7 @@ public class YangInstanceIdentifierDeserializerTest { @Test public void leafListMissingKeyNegativeTest() { try { - YangInstanceIdentifierDeserializer.create(schemaContext, "deserializer-test:leaf-list-0="); + YangInstanceIdentifierDeserializer.create(this.schemaContext, "deserializer-test:leaf-list-0="); fail("Test should fail due to missing instance value"); } catch (final RestconfDocumentedException e) { assertEquals("Not expected error type", @@ -517,7 +515,7 @@ public class YangInstanceIdentifierDeserializerTest { @Test public void deserializePartInOtherModuleTest() { final Iterable result = YangInstanceIdentifierDeserializer.create( - schemaContext, "deserializer-test-included:augmented-list=100/augmented-leaf"); + this.schemaContext, "deserializer-test-included:augmented-list=100/augmented-leaf"); assertEquals("Result does not contains expected number of path arguments", 4, Iterables.size(result)); -- 2.36.6