[ONOS-6960] Identity referred in sub-module of imported module.

Change-Id: I66bef7b5eec5859c94ecd0ced9bf139a32fa70f0
diff --git a/compiler/plugin/maven/src/test/java/org/onosproject/yang/compiler/plugin/maven/AugmentTranslatorTest.java b/compiler/plugin/maven/src/test/java/org/onosproject/yang/compiler/plugin/maven/AugmentTranslatorTest.java
index e233495..225b0c5 100644
--- a/compiler/plugin/maven/src/test/java/org/onosproject/yang/compiler/plugin/maven/AugmentTranslatorTest.java
+++ b/compiler/plugin/maven/src/test/java/org/onosproject/yang/compiler/plugin/maven/AugmentTranslatorTest.java
@@ -593,4 +593,35 @@
         YangPluginConfig.compileCode(COMP);
         deleteDirectory(DIR);
     }
+
+    /**
+     * Checks identity linked in sub-module of imported module.
+     *
+     * @throws IOException            if any error occurs during IO on files
+     * @throws ParserException        if any error occurs during parsing
+     * @throws MojoExecutionException if any mojo operation fail
+     */
+    @Test
+    public void processSubmoduleId() throws IOException,
+            ParserException, MojoExecutionException {
+
+        deleteDirectory(DIR);
+        String dir = "src/test/resources/identityinsubmod";
+
+        Set<Path> paths = new HashSet<>();
+        for (String file : getYangFiles(dir)) {
+            paths.add(Paths.get(file));
+        }
+
+        utilManager.createYangFileInfoSet(paths);
+        utilManager.parseYangFileInfoSet();
+        utilManager.createYangNodeSet();
+        utilManager.resolveDependenciesUsingLinker();
+
+        YangPluginConfig yangPluginConfig = new YangPluginConfig();
+        yangPluginConfig.setCodeGenDir(DIR);
+        utilManager.translateToJava(yangPluginConfig);
+        YangPluginConfig.compileCode(COMP);
+        deleteDirectory(DIR);
+    }
 }
diff --git a/compiler/plugin/maven/src/test/resources/identityinsubmod/module1.yang b/compiler/plugin/maven/src/test/resources/identityinsubmod/module1.yang
new file mode 100644
index 0000000..8dbcd30
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/identityinsubmod/module1.yang
@@ -0,0 +1,16 @@
+module module1 {
+
+    namespace "urn:ietf:params:xml:ns:aug:module:1";
+
+    prefix mod-a;
+
+    import module2 {
+        prefix mod2;
+    }
+
+    leaf name {
+        type identityref {
+            base mod2:BGP_ERROR_CODE;
+        }
+    }
+}
diff --git a/compiler/plugin/maven/src/test/resources/identityinsubmod/module2.yang b/compiler/plugin/maven/src/test/resources/identityinsubmod/module2.yang
new file mode 100644
index 0000000..5a2d85d
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/identityinsubmod/module2.yang
@@ -0,0 +1,8 @@
+module module2 {
+
+    namespace "urn:ietf:params:xml:ns:aug:module:2";
+
+    prefix mod-b;
+
+    include submodule2;
+}
diff --git a/compiler/plugin/maven/src/test/resources/identityinsubmod/submodule.yang b/compiler/plugin/maven/src/test/resources/identityinsubmod/submodule.yang
new file mode 100644
index 0000000..b6b8b10
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/identityinsubmod/submodule.yang
@@ -0,0 +1,9 @@
+submodule submodule2 {
+
+    belongs-to module2 {
+        prefix mod2;
+    }
+
+    identity BGP_ERROR_CODE {
+    }
+}