Added test cases for each .proto file to ensure
[controller.git] / opendaylight / md-sal / sal-protocolbuffer-encoding / src / main / java / org / opendaylight / controller / cluster / datastore / node / utils / NodeIdentifierWithPredicatesGenerator.java
index 86430a57b3043efed53153862c573bc0994ddc0d..6d3a26ad77fe73889ecfe4ae77a5b6259dcec94a 100644 (file)
@@ -1,7 +1,17 @@
+/*
+ *
+ *  Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ *  This program and the accompanying materials are made available under the
+ *  terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ *  and is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ */
+
 package org.opendaylight.controller.cluster.datastore.node.utils;
 
 import org.opendaylight.yangtools.yang.common.QName;
-import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.impl.codec.TypeDefinitionAwareCodec;
 import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode;
@@ -19,15 +29,16 @@ public class NodeIdentifierWithPredicatesGenerator{
     private final boolean doesMatch;
     private final ListSchemaNode listSchemaNode;
 
-    public NodeIdentifierWithPredicatesGenerator(String id){
-        this(id, null);
-    }
-
-    public NodeIdentifierWithPredicatesGenerator(String id, ListSchemaNode schemaNode){
+    public NodeIdentifierWithPredicatesGenerator(String id, DataSchemaNode schemaNode){
         this.id = id;
         matcher = pattern.matcher(this.id);
         doesMatch = matcher.matches();
-        this.listSchemaNode = schemaNode;
+
+        if(schemaNode instanceof  ListSchemaNode){
+            this.listSchemaNode = (ListSchemaNode) schemaNode;
+        } else {
+            this.listSchemaNode = null;
+        }
     }
 
 
@@ -35,7 +46,7 @@ public class NodeIdentifierWithPredicatesGenerator{
         return doesMatch;
     }
 
-    public InstanceIdentifier.NodeIdentifierWithPredicates getPathArgument(){
+    public YangInstanceIdentifier.NodeIdentifierWithPredicates getPathArgument(){
         final String group = matcher.group(2);
         final String[] keyValues = group.split(",");
         Map<QName, Object> nameValues = new HashMap<>();
@@ -52,7 +63,7 @@ public class NodeIdentifierWithPredicatesGenerator{
             }
         }
 
-        return new InstanceIdentifier.NodeIdentifierWithPredicates(QNameFactory.create(matcher.group(1)), nameValues);
+        return new YangInstanceIdentifier.NodeIdentifierWithPredicates(QNameFactory.create(matcher.group(1)), nameValues);
     }