Bug 8910 - Binding v2 generator exception: Failed to find leafref target 02/61602/1
authorJie Han <han.jie@zte.com.cn>
Thu, 3 Aug 2017 05:46:21 +0000 (13:46 +0800)
committerJie Han <han.jie@zte.com.cn>
Mon, 14 Aug 2017 08:16:11 +0000 (16:16 +0800)
- this patch also fixs:
  Bug 8911 - Binding v2 generator exception: Type parameter MUST be specified and cannot be NULL
Change-Id: Icae8a5bb7b8d34d0a7fbcff49fa8f22cd06213e2
Signed-off-by: Jie Han <han.jie@zte.com.cn>
(cherry picked from commit 8edb40f990e40cd6f61a4f5eb0dae11a79f80663)

binding2/mdsal-binding2-generator-impl/src/main/java/org/opendaylight/mdsal/binding/javav2/generator/impl/ModuleToGenType.java
binding2/mdsal-binding2-generator-impl/src/test/resources/leafref/test-leafref.yang [new file with mode: 0644]
binding2/mdsal-binding2-generator-impl/src/test/resources/leafref/test-leafref2.yang [new file with mode: 0644]
binding2/mdsal-binding2-generator-impl/src/test/resources/leafref/test-leafref3.yang [new file with mode: 0644]

index 72eaa569ef6acb2957ed90606973a6bcb0481081..5ca5880d08e71fda585f386d3a4d91684350d550 100644 (file)
@@ -55,7 +55,6 @@ final class ModuleToGenType {
         genCtx = groupingsToGenTypes(module, module.getGroupings(), genCtx, schemaContext, verboseClassComments,
                 genTypeBuilders, typeProvider);
         genCtx = allIdentitiesToGenTypes(module, schemaContext, genCtx, verboseClassComments,  genTypeBuilders, typeProvider);
-        genCtx = notificationsToGenType(module, genCtx, schemaContext, genTypeBuilders, verboseClassComments, typeProvider);
 
         if (!module.getChildNodes().isEmpty()) {
             final GeneratedTypeBuilder moduleType = GenHelperUtil.moduleToDataType(module, genCtx, verboseClassComments);
@@ -67,6 +66,8 @@ final class ModuleToGenType {
             processUsesImplements(module, module, schemaContext, genCtx, BindingNamespaceType.Data);
         }
 
+        genCtx = notificationsToGenType(module, genCtx, schemaContext, genTypeBuilders, verboseClassComments, typeProvider);
+
         //after potential parent data schema nodes
         genCtx = actionsAndRPCMethodsToGenType(module, genCtx, schemaContext, verboseClassComments,
                 genTypeBuilders, typeProvider);
diff --git a/binding2/mdsal-binding2-generator-impl/src/test/resources/leafref/test-leafref.yang b/binding2/mdsal-binding2-generator-impl/src/test/resources/leafref/test-leafref.yang
new file mode 100644 (file)
index 0000000..f13cf26
--- /dev/null
@@ -0,0 +1,34 @@
+module test-leafref {
+
+    yang-version 1;
+    namespace "urn:opendaylight:params:xml:ns:yang:test:leafref";
+    prefix "test";
+
+    revision "2017-02-24" {
+        description "Initial revision of test model.";
+    }
+
+    container test-container {
+        list test-list {
+            leaf test-leaf {
+                type enumeration {
+                    enum enum1 {
+                        value 1;
+                    }
+                    enum enum2 {
+                        value 2;
+                    }
+                }
+            }
+        }
+    }
+
+    container test-leafref-container {
+        leaf test-leafref {
+            type leafref {
+                path "/test:test-container/test:test-list/test:test-leaf";
+            }
+        }
+    }
+
+}
diff --git a/binding2/mdsal-binding2-generator-impl/src/test/resources/leafref/test-leafref2.yang b/binding2/mdsal-binding2-generator-impl/src/test/resources/leafref/test-leafref2.yang
new file mode 100644 (file)
index 0000000..e3cbeb8
--- /dev/null
@@ -0,0 +1,34 @@
+module test-leafref2 {
+
+    yang-version 1;
+    namespace "urn:opendaylight:params:xml:ns:yang:test:leafref2";
+    prefix "test";
+
+    revision "2017-02-24" {
+        description "Initial revision of test model.";
+    }
+
+    container testContainer {
+        list testList {
+            leaf testLeaf {
+                type enumeration {
+                    enum enum1 {
+                        value 1;
+                    }
+                    enum enum2 {
+                        value 2;
+                    }
+                }
+            }
+        }
+    }
+
+    notification testLeafrefNotification {
+        leaf tesLeafref {
+            type leafref {
+                path "/test:testContainer/test:testList/test:testLeaf";
+            }
+        }
+    }
+
+}
\ No newline at end of file
diff --git a/binding2/mdsal-binding2-generator-impl/src/test/resources/leafref/test-leafref3.yang b/binding2/mdsal-binding2-generator-impl/src/test/resources/leafref/test-leafref3.yang
new file mode 100644 (file)
index 0000000..168e04b
--- /dev/null
@@ -0,0 +1,27 @@
+module test-leafref3 {
+
+    yang-version 1;
+    namespace "urn:opendaylight:params:xml:ns:yang:test";
+    prefix "test";
+
+    revision "2017-02-24" {
+        description "Initial revision of test model.";
+    }
+
+    container testContainer {
+        list testList {
+            leaf testLeaf {
+                type string;
+            }
+        }
+    }
+
+    notification testLeafrefNotification {
+        leaf tesLeafref {
+            type leafref {
+                path "/test:testContainer/test:testList/test:testLeaf";
+            }
+        }
+    }
+
+}
\ No newline at end of file