Bug 6931 - Fix unsupported specific type of leaf 32/51632/2
authorJakub Toth <jatoth@cisco.com>
Wed, 12 Oct 2016 16:59:33 +0000 (18:59 +0200)
committerJakub Toth <jatoth@cisco.com>
Sat, 11 Feb 2017 01:33:04 +0000 (02:33 +0100)
  * 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 <jatoth@cisco.com>
restconf/sal-rest-connector/src/main/java/org/opendaylight/restconf/parser/builder/YangInstanceIdentifierDeserializer.java
restconf/sal-rest-connector/src/main/java/org/opendaylight/restconf/parser/builder/YangInstanceIdentifierSerializer.java
restconf/sal-rest-connector/src/test/java/org/opendaylight/restconf/parser/IdentifierCodecTest.java
restconf/sal-rest-connector/src/test/java/org/opendaylight/restconf/parser/builder/YangInstanceIdentifierDeserializerTest.java

index 00c3a2cd822e587233882dd83b690c5c10a8f2ee..89315be51594feae743a08ce1719fde50dac154d 100644 (file)
@@ -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<? extends 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<Object, Object> 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<PathArgument> path,
index 538dbdc3d40b84105b90d7f2a4bf5cef451d3f9a..8176b0fe2fab89e6c4755436d0e7a864a909f2db 100644 (file)
@@ -98,7 +98,7 @@ public final class YangInstanceIdentifierSerializer {
         path.append(arg.getNodeType().getLocalName());
         path.append(ParserBuilderConstants.Deserializer.EQUAL);
 
-        String value = ((NodeWithValue<String>) arg).getValue();
+        String value = String.valueOf(((NodeWithValue<String>) arg).getValue());
         if (Serializer.PERCENT_ENCODE_CHARS.matchesAnyOf(value)) {
             value = parsePercentEncodeChars(value);
         }
index 5e0e266cacba444c85beb7c3c5fb02d874872614..e1cdd8ba6bd4f6b605501d0d4a62ef2ea4586442 100644 (file)
@@ -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);
     }
 
     /**
index 43b9b218a9d15565320eb60702ff22357e9d6bae..e6d24ec2513c9e17a69c2050f597e81a694aec86 100644 (file)
@@ -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<YangInstanceIdentifier.PathArgument> 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<YangInstanceIdentifier.PathArgument> 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<YangInstanceIdentifier.PathArgument> 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<YangInstanceIdentifier.PathArgument> 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<YangInstanceIdentifier.PathArgument> 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<YangInstanceIdentifier.PathArgument> 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<YangInstanceIdentifier.PathArgument> 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<PathArgument> result = YangInstanceIdentifierDeserializer.create(schemaContext, "");
+        final Iterable<PathArgument> 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<YangInstanceIdentifier.PathArgument> 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<Map.Entry<QName, Object>> 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<YangInstanceIdentifier.PathArgument> 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<YangInstanceIdentifier.PathArgument> 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));