MDSAL-302: make sure uses+augment works in RPCs 19/67619/2
authorRobert Varga <robert.varga@pantheon.tech>
Fri, 26 Jan 2018 12:24:54 +0000 (13:24 +0100)
committerRobert Varga <robert.varga@pantheon.tech>
Fri, 26 Jan 2018 16:39:58 +0000 (17:39 +0100)
Add missing callouts to generate uses augments for RPC input/output
nodes. This complements processing for data nodes and notifications.

Change-Id: I4f0d9fddce1e019c57b9a45874a45b22ffe6a15f
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
binding/mdsal-binding-generator-impl/src/main/java/org/opendaylight/mdsal/binding/generator/impl/BindingGeneratorImpl.java
binding/mdsal-binding-generator-impl/src/test/java/org/opendaylight/mdsal/binding/generator/impl/Mdsal302Test.java [new file with mode: 0644]
binding/mdsal-binding-generator-impl/src/test/resources/mdsal-302/mdsal-302.yang [new file with mode: 0644]

index 33bd1b18a7b85d69e45111a738a2c4689f439e93..7cc906cc5dc46f205cc4142d0640ffd6c7ce9c7a 100644 (file)
@@ -515,6 +515,7 @@ public class BindingGeneratorImpl implements BindingGenerator {
                 //in case of implicit RPC input (StatementSource.CONTEXT),
                 // stay compatible (no input argument generated)
                 if (input != null && isExplicitStatement(input)) {
+                    processUsesAugments(input, module);
                     final GeneratedTypeBuilder inType = addRawInterfaceDefinition(basePackageName, input, rpcName);
                     addImplementedInterfaceFromUses(input, inType);
                     inType.addImplementsType(DATA_OBJECT);
@@ -530,6 +531,7 @@ public class BindingGeneratorImpl implements BindingGenerator {
                 //in case of implicit RPC output (StatementSource.CONTEXT),
                 //stay compatible (Future<RpcResult<Void>> return type generated)
                 if (output != null && isExplicitStatement(output)) {
+                    processUsesAugments(output, module);
                     final GeneratedTypeBuilder outType = addRawInterfaceDefinition(basePackageName, output, rpcName);
                     addImplementedInterfaceFromUses(output, outType);
                     outType.addImplementsType(DATA_OBJECT);
diff --git a/binding/mdsal-binding-generator-impl/src/test/java/org/opendaylight/mdsal/binding/generator/impl/Mdsal302Test.java b/binding/mdsal-binding-generator-impl/src/test/java/org/opendaylight/mdsal/binding/generator/impl/Mdsal302Test.java
new file mode 100644 (file)
index 0000000..467f718
--- /dev/null
@@ -0,0 +1,32 @@
+/*
+ * Copyright (c) 2018 Pantheon Technologies, s.r.o. 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.mdsal.binding.generator.impl;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import java.io.FileNotFoundException;
+import java.net.URISyntaxException;
+import java.util.List;
+import org.junit.Test;
+import org.opendaylight.mdsal.binding.model.api.Type;
+import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
+import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
+
+public class Mdsal302Test {
+
+    @Test
+    public void bug4145Test() throws FileNotFoundException, ReactorException, URISyntaxException {
+        SchemaContext context = YangParserTestUtils.parseYangSource("/mdsal-302/mdsal-302.yang");
+
+        List<Type> generateTypes = new BindingGeneratorImpl(false).generateTypes(context);
+        assertNotNull(generateTypes);
+        assertEquals(15, generateTypes.size());
+    }
+}
diff --git a/binding/mdsal-binding-generator-impl/src/test/resources/mdsal-302/mdsal-302.yang b/binding/mdsal-binding-generator-impl/src/test/resources/mdsal-302/mdsal-302.yang
new file mode 100644 (file)
index 0000000..a6b8aa7
--- /dev/null
@@ -0,0 +1,44 @@
+module mdsal-302 {
+    namespace "mdsal-302";
+    prefix "augchoi";
+    revision 2018-01-25;
+
+    grouping some-grouping {
+        choice result {
+            case no-success {
+                container foo;
+            }
+        }
+    }
+
+    rpc some-rpc {
+        input {
+            uses some-grouping {
+                augment result {
+                    case success {
+                        container bar;
+                    }
+                }
+            }
+        }
+        output {
+            uses some-grouping {
+                augment result {
+                    case success {
+                        container bar;
+                    }
+                }
+            }
+        }
+    }
+
+    container some-cont {
+        uses some-grouping {
+            augment result {
+                case success {
+                    container bar;
+                }
+            }
+        }
+    }
+}