Bug 5882: Wrong placement of deprecated annotation 59/38859/19
authorFilip Gregor <fgregor@cisco.com>
Fri, 13 May 2016 09:42:05 +0000 (11:42 +0200)
committerRobert Varga <nite@hq.sk>
Thu, 26 May 2016 11:46:55 +0000 (11:46 +0000)
Removed @Deprecated from generated Yang in javadoc
added deprecated annotation for generated getters
and typedefs

Change-Id: I251faabd0cdc051a646ead6f4bf65a17509b90c5
Signed-off-by: Filip Gregor <fgregor@cisco.com>
binding/mdsal-binding-generator-impl/src/main/java/org/opendaylight/yangtools/sal/binding/generator/impl/BindingGeneratorImpl.java
binding/mdsal-binding-generator-impl/src/main/java/org/opendaylight/yangtools/sal/binding/generator/impl/YangTemplate.xtend
binding/mdsal-binding-generator-impl/src/main/java/org/opendaylight/yangtools/sal/binding/yang/types/TypeProviderImpl.java
binding/mdsal-binding-java-api-generator/src/main/java/org/opendaylight/yangtools/sal/java/api/generator/BaseTemplate.xtend
binding/mdsal-binding-java-api-generator/src/main/java/org/opendaylight/yangtools/sal/java/api/generator/ClassTemplate.xtend
binding/mdsal-binding-java-api-generator/src/test/java/org/opendaylight/yangtools/sal/java/api/generator/test/CompilationTest.java
binding/mdsal-binding-java-api-generator/src/test/java/org/opendaylight/yangtools/sal/java/api/generator/test/CompilationTestUtils.java
binding/mdsal-binding-java-api-generator/src/test/resources/compilation/bug5882/foo.yang [new file with mode: 0644]

index ac2d728032ba8243fe383cca62c7aeceece5fd2c..90312bf53e312edd9f556c2974264897e05f8483 100644 (file)
@@ -102,7 +102,6 @@ import org.opendaylight.yangtools.yang.model.api.UsesNode;
 import org.opendaylight.yangtools.yang.model.api.type.BitsTypeDefinition;
 import org.opendaylight.yangtools.yang.model.api.type.EnumTypeDefinition;
 import org.opendaylight.yangtools.yang.model.api.type.UnionTypeDefinition;
-import org.opendaylight.yangtools.yang.model.util.BaseTypes;
 import org.opendaylight.yangtools.yang.model.util.DataNodeIterator;
 import org.opendaylight.yangtools.yang.model.util.ExtendedType;
 import org.opendaylight.yangtools.yang.model.util.SchemaContextUtil;
@@ -332,7 +331,7 @@ public class BindingGeneratorImpl implements BindingGenerator {
             final GeneratedTypeBuilder parent, final GeneratedTypeBuilder childOf, final ContainerSchemaNode node) {
         final GeneratedTypeBuilder genType = processDataSchemaNode(module, basePackageName, childOf, node);
         if (genType != null) {
-            constructGetter(parent, node.getQName().getLocalName(), node.getDescription(), genType);
+            constructGetter(parent, node.getQName().getLocalName(), node.getDescription(), genType, node.getStatus());
             resolveDataSchemaNodes(module, basePackageName, genType, genType, node.getChildNodes());
         }
     }
@@ -342,7 +341,7 @@ public class BindingGeneratorImpl implements BindingGenerator {
         final GeneratedTypeBuilder genType = processDataSchemaNode(module, basePackageName, childOf, node);
         if (genType != null) {
             constructGetter(parent, node.getQName().getLocalName(), node.getDescription(),
-                    Types.listTypeFor(genType));
+                    Types.listTypeFor(genType), node.getStatus());
 
             final List<String> listKeys = listKeys(node);
             final String packageName = packageNameForGeneratedType(basePackageName, node.getPath());
@@ -1171,7 +1170,7 @@ public class BindingGeneratorImpl implements BindingGenerator {
             final String packageName = packageNameForGeneratedType(basePackageName, choiceNode.getPath());
             final GeneratedTypeBuilder choiceTypeBuilder = addRawInterfaceDefinition(packageName, choiceNode);
             constructGetter(parent, choiceNode.getQName().getLocalName(),
-                    choiceNode.getDescription(), choiceTypeBuilder);
+                    choiceNode.getDescription(), choiceTypeBuilder, choiceNode.getStatus());
             choiceTypeBuilder.addImplementsType(typeForClass(DataContainer.class));
             annotateDeprecatedIfNecessary(choiceNode.getStatus(), choiceTypeBuilder);
             genCtx.get(module).addChildNodeType(choiceNode, choiceTypeBuilder);
@@ -1453,7 +1452,7 @@ public class BindingGeneratorImpl implements BindingGenerator {
             leafDesc = "";
         }
 
-        final MethodSignatureBuilder getter = constructGetter(typeBuilder, leafName, leafDesc, returnType);
+        final MethodSignatureBuilder getter = constructGetter(typeBuilder, leafName, leafDesc, returnType, leaf.getStatus());
         processContextRefExtension(leaf, getter, parentModule);
         return returnType;
     }
@@ -1656,7 +1655,7 @@ public class BindingGeneratorImpl implements BindingGenerator {
         }
 
         final ParameterizedType listType = Types.listTypeFor(returnType);
-        constructGetter(typeBuilder, nodeName.getLocalName(), node.getDescription(), listType);
+        constructGetter(typeBuilder, nodeName.getLocalName(), node.getDescription(), listType, node.getStatus());
         return true;
     }
 
@@ -1876,13 +1875,18 @@ public class BindingGeneratorImpl implements BindingGenerator {
      *            string with comment for the getter method
      * @param returnType
      *            type which represents the return type of the getter method
+     * @param status
+     *            status from yang file, for deprecated annotation
      * @return method signature builder which represents the getter method of
      *         <code>interfaceBuilder</code>
      */
     private static MethodSignatureBuilder constructGetter(final GeneratedTypeBuilder interfaceBuilder,
-            final String schemaNodeName, final String comment, final Type returnType) {
+            final String schemaNodeName, final String comment, final Type returnType, final Status status) {
         final MethodSignatureBuilder getMethod = interfaceBuilder
                 .addMethod(getterMethodName(schemaNodeName, returnType));
+        if (status == Status.DEPRECATED) {
+            getMethod.addAnnotation("", "Deprecated");
+        }
         getMethod.setComment(encodeAngleBrackets(comment));
         getMethod.setReturnType(returnType);
         return getMethod;
@@ -1948,7 +1952,7 @@ public class BindingGeneratorImpl implements BindingGenerator {
 
         if (genTOBuilder != null) {
             final GeneratedTransferObject genTO = genTOBuilder.toInstance();
-            constructGetter(typeBuilder, "key", "Returns Primary Key of Yang List Type", genTO);
+            constructGetter(typeBuilder, "key", "Returns Primary Key of Yang List Type", genTO, Status.CURRENT);
             genCtx.get(module).addGeneratedTOBuilder(genTOBuilder);
         }
     }
index 9c5ee67624f15b37e9d56d09b5234c3e090ab25e..7caa8536e0b1ce44b1a105c2445bebd8e186c812 100644 (file)
@@ -12,6 +12,7 @@ import java.util.Date
 import java.util.List
 import java.util.Map
 import java.util.Set
+import org.opendaylight.yangtools.yang.common.SimpleDateFormatUtil
 import org.opendaylight.yangtools.yang.model.api.AnyXmlSchemaNode
 import org.opendaylight.yangtools.yang.model.api.AugmentationSchema
 import org.opendaylight.yangtools.yang.model.api.ChoiceCaseNode
@@ -38,7 +39,6 @@ import org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode
 import org.opendaylight.yangtools.yang.model.api.UsesNode
 import org.opendaylight.yangtools.yang.model.api.type.EnumTypeDefinition
 import org.opendaylight.yangtools.yang.model.api.type.EnumTypeDefinition.EnumPair
-import org.opendaylight.yangtools.yang.common.SimpleDateFormatUtil
 
 class YangTemplate {
 
@@ -206,9 +206,6 @@ class YangTemplate {
     def private static writeRPC(RpcDefinition rpc) {
         var boolean isStatusDeprecated = rpc.status == Status::DEPRECATED
         '''
-            «IF isStatusDeprecated»
-            @deprecated - status DEPRECATED
-            «ENDIF»
             rpc «rpc.QName.localName» {
                 «IF !rpc.description.nullOrEmpty»
                     "«rpc.description»";
@@ -273,9 +270,6 @@ class YangTemplate {
     def private static writeNotification(NotificationDefinition notification) {
         var boolean isStatusDeprecated = notification.status == Status::DEPRECATED
         '''
-            «IF isStatusDeprecated»
-            @deprecated - status DEPRECATED
-            «ENDIF»
             notification «notification.QName.localName» {
                 «IF !notification.description.nullOrEmpty»
                 description
@@ -367,9 +361,6 @@ class YangTemplate {
     def private static writeTypeDefinition(TypeDefinition<?> typeDefinition) {
         var boolean isStatusDeprecated = typeDefinition.status == Status::DEPRECATED
         '''
-            «IF isStatusDeprecated»
-            @deprecated - status DEPRECATED
-            «ENDIF»
             type «typeDefinition.QName.localName»«IF !isStatusDeprecated»;«ELSE» {
                 status «typeDefinition.status»;
             }
@@ -460,12 +451,7 @@ class YangTemplate {
     }
 
     def private static writeExtension(ExtensionDefinition extensionDef) {
-        var boolean isStatusDeprecated = extensionDef.status == Status::DEPRECATED
-
         '''
-            «IF isStatusDeprecated»
-            @deprecated - status DEPRECATED
-            «ENDIF»
             extension «extensionDef.QName.localName» {
                 «IF !extensionDef.description.nullOrEmpty»
                 description
@@ -567,9 +553,6 @@ class YangTemplate {
     def private static writeGroupingDef(GroupingDefinition groupingDef) {
         var boolean isStatusDeprecated = groupingDef.status == Status::DEPRECATED
         '''
-            «IF isStatusDeprecated»
-            @deprecated - status DEPRECATED
-            «ENDIF»
             grouping «groupingDef.QName.localName» {
                 «IF !groupingDef.groupings.nullOrEmpty»
                     «writeGroupingDefs(groupingDef.groupings)»
@@ -590,9 +573,6 @@ class YangTemplate {
     def private static writeContSchemaNode(ContainerSchemaNode contSchemaNode) {
         var boolean isStatusDeprecated = contSchemaNode.status == Status::DEPRECATED
         '''
-            «IF isStatusDeprecated»
-            @deprecated - status DEPRECATED
-            «ENDIF»
             container «contSchemaNode.getQName.localName» {
                 «IF !contSchemaNode.childNodes.nullOrEmpty»
                 «writeDataSchemaNodes(contSchemaNode.childNodes)»
@@ -619,9 +599,6 @@ class YangTemplate {
     def private static writeAnyXmlSchemaNode(AnyXmlSchemaNode anyXmlSchemaNode) {
         var boolean isStatusDeprecated = anyXmlSchemaNode.status == Status::DEPRECATED
         '''
-            «IF isStatusDeprecated»
-            @deprecated - status DEPRECATED
-            «ENDIF»
             anyxml «anyXmlSchemaNode.getQName.localName»«IF !isStatusDeprecated»;«ELSE» {
                 status «anyXmlSchemaNode.status»;
             }
@@ -632,9 +609,6 @@ class YangTemplate {
     def private static writeLeafSchemaNode(LeafSchemaNode leafSchemaNode) {
         var boolean isStatusDeprecated = leafSchemaNode.status == Status::DEPRECATED
         '''
-            «IF isStatusDeprecated»
-            @deprecated - status DEPRECATED
-            «ENDIF»
             leaf «leafSchemaNode.getQName.localName» {
                 type «leafSchemaNode.type.getQName.localName»;
                 «IF isStatusDeprecated»
@@ -647,9 +621,6 @@ class YangTemplate {
     def private static writeLeafListSchemaNode(LeafListSchemaNode leafListSchemaNode) {
         var boolean isStatusDeprecated = leafListSchemaNode.status == Status::DEPRECATED
         '''
-            «IF isStatusDeprecated»
-            @deprecated - status DEPRECATED
-            «ENDIF»
             leaf-list «leafListSchemaNode.getQName.localName» {
                 type «leafListSchemaNode.type.getQName.localName»;
                 «IF isStatusDeprecated»
@@ -662,9 +633,6 @@ class YangTemplate {
     def private static writeChoiceCaseNode(ChoiceCaseNode choiceCaseNode) {
         var boolean isStatusDeprecated = choiceCaseNode.status == Status::DEPRECATED
         '''
-            «IF isStatusDeprecated»
-            @deprecated - status DEPRECATED
-            «ENDIF»
             case «choiceCaseNode.getQName.localName» {
                 «FOR childNode : choiceCaseNode.childNodes»
                     «writeDataSchemaNode(childNode)»
@@ -679,9 +647,6 @@ class YangTemplate {
     def private static writeChoiceNode(ChoiceSchemaNode choiceNode) {
         var boolean isStatusDeprecated = choiceNode.status == Status::DEPRECATED
         '''
-            «IF isStatusDeprecated»
-            @deprecated - status DEPRECATED
-            «ENDIF»
             choice «choiceNode.getQName.localName» {
                 «FOR child : choiceNode.cases»
                     «writeDataSchemaNode(child)»
@@ -697,9 +662,6 @@ class YangTemplate {
         var boolean isStatusDeprecated = listSchemaNode.status == Status::DEPRECATED
 
         '''
-            «IF isStatusDeprecated»
-            @deprecated - status DEPRECATED
-            «ENDIF»
             list «listSchemaNode.getQName.localName» {
                 key «FOR listKey : listSchemaNode.keyDefinition SEPARATOR " "»"«listKey.localName»"
                 «ENDFOR»
index 7b718e57fd1e3abef8e23f8f550f9b6069686012..bffb1c1f3ce6b16c33d743733a37562820e37520 100644 (file)
@@ -11,6 +11,7 @@ import static org.opendaylight.yangtools.binding.generator.util.BindingGenerator
 import static org.opendaylight.yangtools.yang.model.util.SchemaContextUtil.findDataSchemaNode;
 import static org.opendaylight.yangtools.yang.model.util.SchemaContextUtil.findDataSchemaNodeForRelativeXPath;
 import static org.opendaylight.yangtools.yang.model.util.SchemaContextUtil.findParentModule;
+
 import com.google.common.base.Preconditions;
 import com.google.common.base.Strings;
 import com.google.common.collect.ImmutableList;
@@ -65,6 +66,7 @@ import org.opendaylight.yangtools.yang.model.api.RevisionAwareXPath;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 import org.opendaylight.yangtools.yang.model.api.SchemaNode;
 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
+import org.opendaylight.yangtools.yang.model.api.Status;
 import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
 import org.opendaylight.yangtools.yang.model.api.type.BinaryTypeDefinition;
 import org.opendaylight.yangtools.yang.model.api.type.BitsTypeDefinition;
@@ -560,7 +562,7 @@ public final class TypeProviderImpl implements TypeProvider {
 
     /**
      * Converts <code>enumTypeDef</code> to
-     * {@link org.opendaylight.yangtools.sal.binding.model.api.Enumeration
+     * {@link Enumeration
      * enumeration}.
      *
      * @param enumTypeDef
@@ -820,6 +822,9 @@ public final class TypeProviderImpl implements TypeProvider {
         genTOBuilder.addEqualsIdentity(genPropBuilder);
         genTOBuilder.addHashIdentity(genPropBuilder);
         genTOBuilder.addToStringProperty(genPropBuilder);
+        if (typedef.getStatus() == Status.DEPRECATED) {
+            genTOBuilder.addAnnotation("", "Deprecated");
+        }
         if (javaType instanceof ConcreteType && "String".equals(javaType.getName()) && typedef.getBaseType() != null) {
             final List<String> regExps = resolveRegExpressionsFromTypedef(typedef);
             addStringRegExAsConstant(genTOBuilder, regExps);
@@ -1280,6 +1285,9 @@ public final class TypeProviderImpl implements TypeProvider {
         genTOBuilder.setTypedef(true);
         Restrictions r = BindingGeneratorUtil.getRestrictions(typedef);
         genTOBuilder.setRestrictions(r);
+        if (typedef.getStatus() == Status.DEPRECATED) {
+            genTOBuilder.addAnnotation("", "Deprecated");
+        }
 
         if (baseTypeDefForExtendedType(innerExtendedType) instanceof UnionTypeDefinition) {
             genTOBuilder.setIsUnion(true);
index eba6b3a39d908f59df263f28e5cf1b69ca179876..f39f7a3d1d573bb65d4ffa203e1e3a3ef6d194e3 100644 (file)
@@ -18,13 +18,13 @@ import java.util.StringTokenizer
 import java.util.regex.Pattern
 import org.opendaylight.yangtools.binding.generator.util.Types
 import org.opendaylight.yangtools.sal.binding.model.api.ConcreteType
+import org.opendaylight.yangtools.sal.binding.model.api.Constant
 import org.opendaylight.yangtools.sal.binding.model.api.GeneratedProperty
 import org.opendaylight.yangtools.sal.binding.model.api.GeneratedTransferObject
 import org.opendaylight.yangtools.sal.binding.model.api.GeneratedType
 import org.opendaylight.yangtools.sal.binding.model.api.MethodSignature
 import org.opendaylight.yangtools.sal.binding.model.api.Restrictions
 import org.opendaylight.yangtools.sal.binding.model.api.Type
-import org.opendaylight.yangtools.sal.binding.model.api.Constant
 import org.opendaylight.yangtools.yang.common.QName
 
 abstract class BaseTemplate {
index 8dec19fc92f6a56d94a470ba8b7304f788e2cb1e..6e1875a632e0665f2349bb5c5c35232511524459 100644 (file)
@@ -113,6 +113,7 @@ class ClassTemplate extends BaseTemplate {
      */
     def protected generateBody(boolean isInnerClass) '''
         «wrapToDocumentation(formatDataForJavaDoc(type))»
+        «annotationDeclaration»
         «generateClassDeclaration(isInnerClass)» {
             «suidDeclaration»
             «innerClassesDeclarations»
@@ -417,6 +418,14 @@ class ClassTemplate extends BaseTemplate {
         «ENDIF»
     '''
 
+    def protected annotationDeclaration() '''
+        «IF genTO.getAnnotations != null»
+            «FOR e : genTO.getAnnotations»
+                @«e.getName»
+            «ENDFOR»
+        «ENDIF»
+    '''
+
     /**
      * Template method which generates JAVA constants.
      *
index 74cd9019ef46ec185e3bcc4cebf04ceed064b3fa..583efac18ce77ae588480939f0ad96994d69bcf2 100644 (file)
@@ -8,6 +8,7 @@
 package org.opendaylight.yangtools.sal.java.api.generator.test;
 
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertTrue;
 
 import com.google.common.base.Predicate;
@@ -572,17 +573,57 @@ public class CompilationTest extends BaseCompilationTest {
     }
 
     @Test
-    public void testBug5788() throws Exception {
-        final File sourcesOutputDir = new File(CompilationTestUtils.GENERATOR_OUTPUT_PATH + CompilationTestUtils.FS + "bug5788");
+    public void testBug5882() throws Exception {
+        final File sourcesOutputDir = new File(CompilationTestUtils.GENERATOR_OUTPUT_PATH + CompilationTestUtils.FS + "bug5882");
         assertTrue("Failed to create test file '" + sourcesOutputDir + "'", sourcesOutputDir.mkdir());
-        final File compiledOutputDir = new File(CompilationTestUtils.COMPILER_OUTPUT_PATH + CompilationTestUtils.FS + "bug5788");
+        final File compiledOutputDir = new File(CompilationTestUtils.COMPILER_OUTPUT_PATH + CompilationTestUtils.FS + "bug5882");
         assertTrue("Failed to create test file '" + compiledOutputDir + "'", compiledOutputDir.mkdir());
-
-        generateTestSources("/compilation/bug5788", sourcesOutputDir);
+        generateTestSources("/compilation/bug5882", sourcesOutputDir);
 
         // Test if sources are compilable
         CompilationTestUtils.testCompilation(sourcesOutputDir, compiledOutputDir);
 
+        final File parent = new File(sourcesOutputDir, CompilationTestUtils.NS_BUG5882);
+        assertTrue(new File(parent, "FooData.java").exists());
+        assertTrue(new File(parent, "TypedefCurrent.java").exists());
+        assertTrue(new File(parent, "TypedefDeprecated.java").exists());
+
+        final String pkg = CompilationTestUtils.BASE_PKG + ".urn.yang.foo.rev160102";
+        final ClassLoader loader = new URLClassLoader(new URL[] { compiledOutputDir.toURI().toURL() });
+        final Class cls = loader.loadClass(pkg + ".FooData");
+        final Class clsContainer = loader.loadClass(pkg + ".ContainerMain");
+        final Class clsTypedefDepr = loader.loadClass(pkg + ".TypedefDeprecated");
+        final Class clsTypedefCur = loader.loadClass(pkg + ".TypedefCurrent");
+        final Class clsGroupingDepr = loader.loadClass(pkg + ".GroupingDeprecated");
+        final Class clsGroupingCur = loader.loadClass(pkg + ".GroupingCurrent");
+        final Class clsTypeDef1 = loader.loadClass(pkg + ".Typedef1");
+        final Class clsTypeDef2 = loader.loadClass(pkg + ".Typedef2");
+        final Class clsTypeDef3 = loader.loadClass(pkg + ".Typedef3");
+        assertTrue(clsTypedefDepr.getAnnotations()[0].toString().contains("Deprecated"));
+        assertTrue(clsTypedefCur.getAnnotations().length == 0);
+        assertTrue(clsGroupingDepr.getAnnotations()[0].toString().contains("Deprecated"));
+        assertTrue(clsGroupingCur.getAnnotations().length == 0);
+        assertTrue(clsTypeDef1.getAnnotations().length == 0);
+        assertTrue(clsTypeDef3.getAnnotations().length == 0);
+        assertTrue(clsTypeDef2.getAnnotations()[0].toString().contains("Deprecated"));
+
+        /*methods inside container*/
+        assertTrue(clsContainer.getMethod("getContainerMainLeafDepr").isAnnotationPresent(Deprecated.class));
+        assertTrue(clsContainer.getMethod("getContainerMainListDepr").isAnnotationPresent(Deprecated.class));
+        assertTrue(clsContainer.getMethod("getContainerMainChoiceDepr").isAnnotationPresent(Deprecated.class));
+        assertFalse(clsContainer.getMethod("getContainerMainLeafCurrent").isAnnotationPresent(Deprecated.class));
+        assertFalse(clsContainer.getMethod("getContainerMainListCurrent").isAnnotationPresent(Deprecated.class));
+        assertFalse(clsContainer.getMethod("getContainerMainChoiceCur").isAnnotationPresent(Deprecated.class));
+
+        /*methods inside module*/
+        assertTrue(cls.getMethod("getContainerMainLeafDepr").isAnnotationPresent(Deprecated.class));
+        assertTrue(cls.getMethod("getContainerMainListDepr").isAnnotationPresent(Deprecated.class));
+        assertTrue(cls.getMethod("getContainerMainChoiceDepr").isAnnotationPresent(Deprecated.class));
+        assertFalse(cls.getMethod("getContainerMainLeafCurrent").isAnnotationPresent(Deprecated.class));
+        assertFalse(cls.getMethod("getContainerMainListCurrent").isAnnotationPresent(Deprecated.class));
+        assertFalse(cls.getMethod("getContainerMainChoiceCur").isAnnotationPresent(Deprecated.class));
+        assertTrue(cls.getMethod("getLeafDeprecated").isAnnotationPresent(Deprecated.class));
+
         CompilationTestUtils.cleanUp(sourcesOutputDir, compiledOutputDir);
     }
 
index a442b23026097b7084df3c12eadfb4e885bc324e..8fc981f155b7ece2ac6b2917c4f1328e721af3d0 100644 (file)
@@ -11,6 +11,7 @@ import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
+
 import java.io.File;
 import java.io.FileNotFoundException;
 import java.lang.reflect.Constructor;
@@ -41,12 +42,12 @@ public class CompilationTestUtils {
     static final File COMPILER_OUTPUT_DIR = new File(COMPILER_OUTPUT_PATH);
 
     static final String AUGMENTATION = "interface org.opendaylight.yangtools.yang.binding.Augmentation";
-
     static final String BASE_PATH = "org" + FS + "opendaylight" + FS + "yang" + FS + "gen" + FS + "v1";
     static final String NS_TEST = BASE_PATH + FS + "urn" + FS + "opendaylight" + FS + "test" + FS + "rev131008";
     static final String NS_FOO = BASE_PATH + FS + "urn" + FS + "opendaylight" + FS + "foo" + FS + "rev131008";
     static final String NS_BAR = BASE_PATH + FS + "urn" + FS + "opendaylight" + FS + "bar" + FS + "rev131008";
     static final String NS_BAZ = BASE_PATH + FS + "urn" + FS + "opendaylight" + FS + "baz" + FS + "rev131008";
+    static final String NS_BUG5882 = BASE_PATH + FS + "urn" + FS + "yang" + FS + "foo" + FS + "rev160102";
 
     /**
      * Method to clean resources. It is manually called at the end of each test
diff --git a/binding/mdsal-binding-java-api-generator/src/test/resources/compilation/bug5882/foo.yang b/binding/mdsal-binding-java-api-generator/src/test/resources/compilation/bug5882/foo.yang
new file mode 100644 (file)
index 0000000..e77ac96
--- /dev/null
@@ -0,0 +1,201 @@
+module foo {
+    namespace "urn:yang.foo";
+    prefix "foo";
+
+    revision "2016-01-02" {
+    }
+
+    typedef typedef1 {
+        type typedef-deprecated;
+        description "current";
+    }
+
+    typedef typedef2 {
+        status deprecated;
+        type typedef1;
+        description "deprecated";
+    }
+
+    typedef typedef3 {
+        type typedef2;
+        description "current";
+    }
+
+    typedef typedef-deprecated {
+        status deprecated;
+        type string;
+        description "deprecated";
+    }
+
+    typedef typedef-current {
+        status current;
+        type uint8 {
+            range "0 .. 100";
+        }
+        description "current";
+    }
+
+    container container-main {
+        leaf container-main-leaf-depr {
+            status deprecated;
+            type string;
+        }
+
+        leaf container-main-leaf-current {
+            type typedef-current;
+        }
+
+        list container-main-list-depr {
+            status deprecated;
+            key "test";
+            leaf test {
+                type int8;
+            }
+        }
+
+        list container-main-list-current {
+            key "test";
+            leaf test {
+                type int8;
+            }
+        }
+
+        choice container-main-choice-depr {
+            status deprecated;
+            case depCase {
+            status deprecated;
+                leaf one {
+                    type string;
+                }
+            }
+            case depLeaf {
+                leaf one {
+                status deprecated;
+                    type string;
+                }
+            }
+            case cur {
+                leaf two {
+                    type string;
+                }
+            }
+        }
+
+        choice container-main-choice-cur {
+            case depCase {
+            status deprecated;
+                leaf one {
+                    type string;
+                }
+            }
+            case depLeaf {
+                leaf one {
+                status deprecated;
+                    type string;
+                }
+            }
+            case cur {
+                leaf two {
+                    type string;
+                }
+            }
+        }
+    }
+
+    leaf container-main-leaf-depr {
+        status deprecated;
+        type string;
+    }
+
+    leaf container-main-leaf-current {
+        type typedef-current;
+    }
+
+    list container-main-list-depr {
+        status deprecated;
+        key "test";
+        leaf test {
+            type int8;
+        }
+    }
+
+    list container-main-list-current {
+        key "test";
+        leaf test {
+            type int8;
+        }
+    }
+
+    choice container-main-choice-depr {
+        status deprecated;
+        case depCase {
+        status deprecated;
+            leaf one {
+                type string;
+            }
+        }
+        case depLeaf {
+            leaf one {
+            status deprecated;
+                type string;
+            }
+        }
+        case cur {
+            leaf two {
+                type string;
+            }
+        }
+    }
+
+    choice container-main-choice-cur {
+        case depCase {
+        status deprecated;
+            leaf one {
+                type string;
+            }
+        }
+        case depLeaf {
+            leaf one {
+            status deprecated;
+                type string;
+            }
+        }
+        case cur {
+            leaf two {
+                type string;
+            }
+        }
+    }
+
+    leaf leaf-deprecated {
+        status deprecated;
+        type typedef-deprecated;
+    }
+
+    leaf leaf-current {
+        type typedef-current;
+    }
+
+    grouping grouping-deprecated {
+        status deprecated;
+        leaf leaf-deprecated {
+            status deprecated;
+            type typedef-deprecated;
+        }
+
+        leaf leaf-current {
+            type typedef-current;
+        }
+    }
+
+    grouping grouping-current {
+        leaf leaf-deprecated {
+            status deprecated;
+            type typedef-deprecated;
+        }
+
+        leaf leaf-current {
+            type typedef-current;
+        }
+    }
+}
\ No newline at end of file