[ONOS-4839] update file priority for translator and OP param file impl defect fix
Change-Id: Ieaef43f915996ed0a34dfa17c338ab612716b2bc
diff --git a/plugin/src/test/java/org/onosproject/yangutils/ietfyang/IetfYangFileTest.java b/plugin/src/test/java/org/onosproject/yangutils/ietfyang/IetfYangFileTest.java
index 7176760..7a1ab65 100644
--- a/plugin/src/test/java/org/onosproject/yangutils/ietfyang/IetfYangFileTest.java
+++ b/plugin/src/test/java/org/onosproject/yangutils/ietfyang/IetfYangFileTest.java
@@ -56,7 +56,7 @@
yangPluginConfig.setCodeGenDir("target/ietfyang/l3vpnservice/");
yangPluginConfig.setManagerCodeGenDir("target/ietfyang/l3vpnservice/");
- utilManager.translateToJava(utilManager.getYangFileInfoSet(), yangPluginConfig);
+ utilManager.translateToJava(yangPluginConfig);
deleteDirectory(userDir + "/target/ietfyang/");
}
diff --git a/plugin/src/test/java/org/onosproject/yangutils/plugin/manager/AugmentTranslatorTest.java b/plugin/src/test/java/org/onosproject/yangutils/plugin/manager/AugmentTranslatorTest.java
index 821a435..f502835 100644
--- a/plugin/src/test/java/org/onosproject/yangutils/plugin/manager/AugmentTranslatorTest.java
+++ b/plugin/src/test/java/org/onosproject/yangutils/plugin/manager/AugmentTranslatorTest.java
@@ -50,7 +50,7 @@
YangPluginConfig yangPluginConfig = new YangPluginConfig();
yangPluginConfig.setCodeGenDir("target/augmentTranslator/");
yangPluginConfig.setManagerCodeGenDir("target/augmentTranslator/");
- utilManager.translateToJava(utilManager.getYangFileInfoSet(), yangPluginConfig);
+ utilManager.translateToJava(yangPluginConfig);
deleteDirectory("target/augmentTranslator/");
}
diff --git a/plugin/src/test/java/org/onosproject/yangutils/plugin/manager/InterFileLinkingTest.java b/plugin/src/test/java/org/onosproject/yangutils/plugin/manager/InterFileLinkingTest.java
index 675fea6..8052f30 100644
--- a/plugin/src/test/java/org/onosproject/yangutils/plugin/manager/InterFileLinkingTest.java
+++ b/plugin/src/test/java/org/onosproject/yangutils/plugin/manager/InterFileLinkingTest.java
@@ -638,7 +638,7 @@
yangPluginConfig.setCodeGenDir("target/interfilewithusesreferringtype/");
yangPluginConfig.setManagerCodeGenDir("target/interfilewithusesreferringtype/");
- utilManager.translateToJava(utilManager.getYangFileInfoSet(), yangPluginConfig);
+ utilManager.translateToJava(yangPluginConfig);
deleteDirectory("target/interfilewithusesreferringtype/");
@@ -660,7 +660,7 @@
yangPluginConfig.setCodeGenDir("target/file1UsesFile2TypeDefFile3Type/");
yangPluginConfig.setManagerCodeGenDir("target/file1UsesFile2TypeDefFile3Type/");
- utilManager.translateToJava(utilManager.getYangFileInfoSet(), yangPluginConfig);
+ utilManager.translateToJava(yangPluginConfig);
deleteDirectory("target/file1UsesFile2TypeDefFile3Type/");
@@ -682,7 +682,7 @@
yangPluginConfig.setCodeGenDir("target/interfileietf/");
yangPluginConfig.setManagerCodeGenDir("target/interfileietf/");
- utilManager.translateToJava(utilManager.getYangFileInfoSet(), yangPluginConfig);
+ utilManager.translateToJava(yangPluginConfig);
deleteDirectory("target/interfileietf/");
@@ -704,7 +704,7 @@
yangPluginConfig.setCodeGenDir("target/usesInContainer/");
yangPluginConfig.setManagerCodeGenDir("target/usesInContainer/");
- utilManager.translateToJava(utilManager.getYangFileInfoSet(), yangPluginConfig);
+ utilManager.translateToJava(yangPluginConfig);
deleteDirectory("target/usesInContainer/");
@@ -726,7 +726,7 @@
yangPluginConfig.setCodeGenDir("target/groupingNodeSameAsModule/");
yangPluginConfig.setManagerCodeGenDir("target/groupingNodeSameAsModule/");
- utilManager.translateToJava(utilManager.getYangFileInfoSet(), yangPluginConfig);
+ utilManager.translateToJava(yangPluginConfig);
deleteDirectory("target/groupingNodeSameAsModule/");
diff --git a/plugin/src/test/java/org/onosproject/yangutils/plugin/manager/InterJarLinkerTest.java b/plugin/src/test/java/org/onosproject/yangutils/plugin/manager/InterJarLinkerTest.java
index 16962f2..94585a2 100644
--- a/plugin/src/test/java/org/onosproject/yangutils/plugin/manager/InterJarLinkerTest.java
+++ b/plugin/src/test/java/org/onosproject/yangutils/plugin/manager/InterJarLinkerTest.java
@@ -191,7 +191,7 @@
yangPluginConfig.setCodeGenDir(TARGET);
yangPluginConfig.setManagerCodeGenDir(TARGET);
- utilManager.translateToJava(utilManager.getYangFileInfoSet(), yangPluginConfig);
+ utilManager.translateToJava(yangPluginConfig);
testIfFlowClassifierFilesExists();
testIfPortPairFileDoesNotExist();
@@ -308,6 +308,7 @@
for (YangNode node : interJarResolvedNodes) {
YangFileInfo dependentFileInfo = new YangFileInfo();
+ node.setToTranslate(false);
dependentFileInfo.setRootNode(node);
dependentFileInfo.setForTranslator(false);
dependentFileInfo.setYangFileName(node.getName());
diff --git a/plugin/src/test/java/org/onosproject/yangutils/plugin/manager/ManagerCodeGeneratorTest.java b/plugin/src/test/java/org/onosproject/yangutils/plugin/manager/ManagerCodeGeneratorTest.java
index 817fb4e..c3b2fe7 100644
--- a/plugin/src/test/java/org/onosproject/yangutils/plugin/manager/ManagerCodeGeneratorTest.java
+++ b/plugin/src/test/java/org/onosproject/yangutils/plugin/manager/ManagerCodeGeneratorTest.java
@@ -44,7 +44,7 @@
@Test
public void processManagerTranslator() throws IOException, ParserException, MojoExecutionException {
- String searchDir = "src/test/resources/manager";
+ String searchDir = "src/test/resources/manager/singleChild";
utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(searchDir));
utilManager.parseYangFileInfoSet();
utilManager.createYangNodeSet();
@@ -54,7 +54,7 @@
yangPluginConfig.setCodeGenDir("target/manager/");
yangPluginConfig.setManagerCodeGenDir("target/manager/");
- utilManager.translateToJava(utilManager.getYangFileInfoSet(), yangPluginConfig);
+ utilManager.translateToJava(yangPluginConfig);
String file1 = "target/manager/org/onosproject/yang/gen/v1/test5/test/rev20160704/Test5Manager.java";
String file2 = "target/manager/org/onosproject/yang/gen/v1/test5/test/rev20160704/Test6Manager.java";
String file3 = "target/manager/org/onosproject/yang/gen/v1/test5/test/rev20160704/Test7Manager.java";
@@ -79,7 +79,7 @@
public void processManagerInDifferentPackageTranslator() throws IOException, ParserException,
MojoExecutionException {
- String searchDir = "src/test/resources/manager";
+ String searchDir = "src/test/resources/manager/singleChild";
utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(searchDir));
utilManager.parseYangFileInfoSet();
utilManager.createYangNodeSet();
@@ -87,10 +87,10 @@
YangPluginConfig yangPluginConfig = new YangPluginConfig();
yangPluginConfig.setCodeGenDir("target/manager/");
- yangPluginConfig.setManagerCodeGenDir("target/manager1/");
+ yangPluginConfig.setManagerCodeGenDir("target/manager/");
- utilManager.translateToJava(utilManager.getYangFileInfoSet(), yangPluginConfig);
- String file3 = "target/manager1/org/onosproject/yang/gen/v1/test5/test/rev20160704/Test7Manager.java";
+ utilManager.translateToJava(yangPluginConfig);
+ String file3 = "target/manager/org/onosproject/yang/gen/v1/test5/test/rev20160704/Test7Manager.java";
File manager3 = new File(file3);
assertThat(true, is(manager3.exists()));
@@ -98,4 +98,48 @@
deleteDirectory("target/manager/");
deleteDirectory("target/manager1/");
}
+
+ /**
+ * Checks manager translation in different package should not result in any exception.
+ *
+ * @throws MojoExecutionException
+ */
+ @Test
+ public void processManagerforMultiChildTranslator() throws IOException, ParserException,
+ MojoExecutionException {
+
+ String searchDir = "src/test/resources/manager/MultiChild";
+ utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(searchDir));
+ utilManager.parseYangFileInfoSet();
+ utilManager.createYangNodeSet();
+ utilManager.resolveDependenciesUsingLinker();
+
+ YangPluginConfig yangPluginConfig = new YangPluginConfig();
+ yangPluginConfig.setCodeGenDir("target/manager/");
+ yangPluginConfig.setManagerCodeGenDir("target/manager/");
+
+ utilManager.translateToJava(yangPluginConfig);
+ String file1 = "target/manager/org/onosproject/yang/gen/v1/test5/test/rev20160704/Test5Manager.java";
+
+ File manager1 = new File(file1);
+ assertThat(false, is(manager1.exists()));
+
+ String file2 = "target/manager/org/onosproject/yang/gen/v1/test5/test/rev20160704/Test6Manager.java";
+
+ File manager2 = new File(file2);
+ assertThat(false, is(manager2.exists()));
+
+ String file3 = "target/manager/org/onosproject/yang/gen/v1/test5/test/rev20160704/Test7Manager.java";
+
+ File manager3 = new File(file3);
+ assertThat(false, is(manager3.exists()));
+
+ String file4 = "target/manager/org/onosproject/yang/gen/v1/test8/test/rev20160704/Test8Manager.java";
+
+ File manager4 = new File(file4);
+ assertThat(true, is(manager4.exists()));
+
+ deleteDirectory("target/manager/");
+ deleteDirectory("target/manager1/");
+ }
}
diff --git a/plugin/src/test/resources/manager/MultiChild/module.yang b/plugin/src/test/resources/manager/MultiChild/module.yang
new file mode 100644
index 0000000..1c4637c
--- /dev/null
+++ b/plugin/src/test/resources/manager/MultiChild/module.yang
@@ -0,0 +1,18 @@
+module test5 {
+ namespace "test5:test";
+ prefix test ;
+
+ revision "2016-07-04" {
+ description "Initial revision.";
+ }
+ typedef typedef1 {
+ type int32;
+ }
+ typedef typedef2 {
+ type int32;
+ }
+ typedef typedef3 {
+ type int32;
+ }
+
+}
diff --git a/plugin/src/test/resources/manager/MultiChild/submodule.yang b/plugin/src/test/resources/manager/MultiChild/submodule.yang
new file mode 100644
index 0000000..92d7c21
--- /dev/null
+++ b/plugin/src/test/resources/manager/MultiChild/submodule.yang
@@ -0,0 +1,26 @@
+submodule test6 {
+
+ belongs-to "test5" {
+ prefix "test";
+ }
+
+ revision "2016-07-04" {
+ description "Initial revision.";
+ }
+ grouping grouping1 {
+ leaf leaf1 {
+ type int32;
+ }
+ }
+ grouping grouping2 {
+ leaf leaf1 {
+ type int32;
+ }
+ }
+
+ grouping grouping3 {
+ leaf leaf1 {
+ type int32;
+ }
+ }
+}
diff --git a/plugin/src/test/resources/manager/test.yang b/plugin/src/test/resources/manager/MultiChild/test.yang
similarity index 61%
copy from plugin/src/test/resources/manager/test.yang
copy to plugin/src/test/resources/manager/MultiChild/test.yang
index 7b2861c..036d78a 100644
--- a/plugin/src/test/resources/manager/test.yang
+++ b/plugin/src/test/resources/manager/MultiChild/test.yang
@@ -6,7 +6,13 @@
description "Initial revision.";
}
- leaf abc {
+ grouping grouping1 {
+ leaf leaf1 {
+ type int32;
+ }
+ }
+
+ typedef typedef3 {
type int32;
}
diff --git a/plugin/src/test/resources/manager/MultiChild/test2.yang b/plugin/src/test/resources/manager/MultiChild/test2.yang
new file mode 100644
index 0000000..b252c23
--- /dev/null
+++ b/plugin/src/test/resources/manager/MultiChild/test2.yang
@@ -0,0 +1,22 @@
+module test8 {
+ namespace "test8:test";
+ prefix test ;
+
+ revision "2016-07-04" {
+ description "Initial revision.";
+ }
+
+ grouping grouping1 {
+ leaf leaf1 {
+ type int32;
+ }
+ }
+
+ typedef typedef3 {
+ type int32;
+ }
+
+ container container2 {
+ }
+
+}
diff --git a/plugin/src/test/resources/manager/module.yang b/plugin/src/test/resources/manager/singleChild/module.yang
similarity index 87%
rename from plugin/src/test/resources/manager/module.yang
rename to plugin/src/test/resources/manager/singleChild/module.yang
index 212b171..5fb8a9b 100644
--- a/plugin/src/test/resources/manager/module.yang
+++ b/plugin/src/test/resources/manager/singleChild/module.yang
@@ -5,7 +5,7 @@
revision "2016-07-04" {
description "Initial revision.";
}
- typedef abc {
+ typedef typedef1 {
type int32;
}
diff --git a/plugin/src/test/resources/manager/submodule.yang b/plugin/src/test/resources/manager/singleChild/submodule.yang
similarity index 89%
rename from plugin/src/test/resources/manager/submodule.yang
rename to plugin/src/test/resources/manager/singleChild/submodule.yang
index 961147c..541b7dd 100644
--- a/plugin/src/test/resources/manager/submodule.yang
+++ b/plugin/src/test/resources/manager/singleChild/submodule.yang
@@ -7,7 +7,7 @@
revision "2016-07-04" {
description "Initial revision.";
}
- grouping abc {
+ grouping grouping1 {
leaf leaf1 {
type int32;
}
diff --git a/plugin/src/test/resources/manager/test.yang b/plugin/src/test/resources/manager/singleChild/test.yang
similarity index 81%
rename from plugin/src/test/resources/manager/test.yang
rename to plugin/src/test/resources/manager/singleChild/test.yang
index 7b2861c..483e00e 100644
--- a/plugin/src/test/resources/manager/test.yang
+++ b/plugin/src/test/resources/manager/singleChild/test.yang
@@ -6,8 +6,7 @@
description "Initial revision.";
}
- leaf abc {
- type int32;
+ container cont1 {
}
}