[ONOS-5482][ONOS-5275] Yms Operation requirement Implementation in onos-yang-tools
Change-Id: I463ed105f85ca65a61ff251e5ca062903d465551
diff --git a/plugin/maven/src/test/java/org/onosproject/yangutils/plugin/manager/AugmentTranslatorTest.java b/plugin/maven/src/test/java/org/onosproject/yangutils/plugin/manager/AugmentTranslatorTest.java
index 9cd07b2..9ac1ad8 100644
--- a/plugin/maven/src/test/java/org/onosproject/yangutils/plugin/manager/AugmentTranslatorTest.java
+++ b/plugin/maven/src/test/java/org/onosproject/yangutils/plugin/manager/AugmentTranslatorTest.java
@@ -41,6 +41,7 @@
@Test
public void processAugmentTranslator() throws IOException, ParserException, MojoExecutionException {
+ deleteDirectory("target/augmentTranslator/");
String searchDir = "src/test/resources/augmentTranslator";
utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(searchDir));
utilManager.parseYangFileInfoSet();
diff --git a/plugin/maven/src/test/java/org/onosproject/yangutils/plugin/manager/ChoiceCaseTranslatorTest.java b/plugin/maven/src/test/java/org/onosproject/yangutils/plugin/manager/ChoiceCaseTranslatorTest.java
index 6ee1c71..7a1a8f6 100644
--- a/plugin/maven/src/test/java/org/onosproject/yangutils/plugin/manager/ChoiceCaseTranslatorTest.java
+++ b/plugin/maven/src/test/java/org/onosproject/yangutils/plugin/manager/ChoiceCaseTranslatorTest.java
@@ -16,14 +16,14 @@
package org.onosproject.yangutils.plugin.manager;
-import java.io.IOException;
-
import org.junit.Test;
import org.onosproject.yangutils.datamodel.YangNode;
import org.onosproject.yangutils.parser.exceptions.ParserException;
import org.onosproject.yangutils.parser.impl.YangUtilsParserManager;
import org.onosproject.yangutils.utils.io.YangPluginConfig;
+import java.io.IOException;
+
import static org.onosproject.yangutils.translator.tojava.JavaCodeGeneratorUtil.generateJavaCode;
import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.deleteDirectory;
@@ -40,6 +40,7 @@
@Test
public void processChoiceCaseTranslator() throws IOException, ParserException {
+ deleteDirectory("target/ChoiceCaseTestGenFile/");
YangNode node = manager.getDataModel("src/test/resources/ChoiceCaseTranslator.yang");
YangPluginConfig yangPluginConfig = new YangPluginConfig();
diff --git a/plugin/maven/src/test/java/org/onosproject/yangutils/plugin/manager/InterJarLinkerTest.java b/plugin/maven/src/test/java/org/onosproject/yangutils/plugin/manager/InterJarLinkerTest.java
index fb0f805..89f7439 100644
--- a/plugin/maven/src/test/java/org/onosproject/yangutils/plugin/manager/InterJarLinkerTest.java
+++ b/plugin/maven/src/test/java/org/onosproject/yangutils/plugin/manager/InterJarLinkerTest.java
@@ -79,17 +79,17 @@
public void processSingleJarLinking()
throws IOException, MojoExecutionException {
utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(YANG_FILES_DIR));
-
- int size1 = utilManager.getYangFileInfoSet().size();
+ Set<YangFileInfo> info = utilManager.getYangFileInfoSet();
+ int size1 = info.size();
utilManager.parseYangFileInfoSet();
mockJarFileProvider.provideTestJarFile(utilManager);
- utilManager.setYangFileInfoSet(removeFileInfoFromSet(utilManager.getYangFileInfoSet()));
+ utilManager.setYangFileInfoSet(removeFileInfoFromSet(info));
utilManager.resolveDependenciesUsingLinker();
- int size2 = utilManager.getYangFileInfoSet().size();
+ int size2 = info.size();
assertThat(true, is(size1 != size2));
- assertThat(true, is(parseFileInfoSet(utilManager.getYangFileInfoSet().iterator())));
+ assertThat(true, is(parseFileInfoSet(info.iterator())));
deleteDirectory(TARGET);
mockJarFileProvider.deleteTestSerFile(YANG_FILES_DIR);
@@ -106,17 +106,18 @@
throws IOException, MojoExecutionException {
utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(YANG_FILES_DIR));
- int size1 = utilManager.getYangFileInfoSet().size();
+ Set<YangFileInfo> info = utilManager.getYangFileInfoSet();
+ int size1 = info.size();
utilManager.parseYangFileInfoSet();
mockJarFileProvider.provideTestJarFile(utilManager);
- utilManager.setYangFileInfoSet(removeFileInfoFromSet(utilManager.getYangFileInfoSet()));
+ utilManager.setYangFileInfoSet(removeFileInfoFromSet(info));
utilManager.resolveDependenciesUsingLinker();
- int size2 = utilManager.getYangFileInfoSet().size();
+ int size2 = info.size();
assertThat(true, is(size1 != size2));
- assertThat(true, is(parseFileInfoSet(utilManager.getYangFileInfoSet().iterator())));
- assertThat(true, is(parseFileInfoSet(utilManager.getYangFileInfoSet().iterator())));
+ assertThat(true, is(parseFileInfoSet(info.iterator())));
+ assertThat(true, is(parseFileInfoSet(info.iterator())));
/*
* grouping flow-classifier {
@@ -134,7 +135,7 @@
*
*/
- Iterator<YangFileInfo> yangFileInfoIterator = utilManager.getYangFileInfoSet().iterator();
+ Iterator<YangFileInfo> yangFileInfoIterator = info.iterator();
YangFileInfo yangFileInfo = yangFileInfoIterator.next();
@@ -268,12 +269,13 @@
*/
void provideTestJarFile(YangUtilManager utilManager) throws IOException {
+ Set<YangFileInfo> info = utilManager.getYangFileInfoSet();
MavenProject project = new MavenProject();
- serializeDataModel(TARGET, utilManager.getYangFileInfoSet(), project, false);
+ serializeDataModel(TARGET, info, project, false);
createTestJar();
for (String file : getListOfTestJar(TARGET)) {
- addInterJarRootNodes(file, utilManager);
+ addInterJarRootNodes(file, info);
}
}
@@ -281,7 +283,8 @@
* Deletes serialized file.
*/
void deleteTestSerFile(String yangFileDir) {
- File ser = new File(System.getProperty("user.dir") + SLASH + yangFileDir + SLASH + SER_FILE_NAME);
+ File ser = new File(System.getProperty("user.dir") + SLASH + yangFileDir +
+ SLASH + SER_FILE_NAME);
ser.delete();
}
@@ -309,11 +312,11 @@
/**
* Adds data model nodes of jar to file info set.
*
- * @param jarFile jar file name
- * @param utilManager
+ * @param jarFile jar file name
+ * @param info file info
* @throws IOException when fails to do IO operations
*/
- private void addInterJarRootNodes(String jarFile, YangUtilManager utilManager) throws IOException {
+ private void addInterJarRootNodes(String jarFile, Set<YangFileInfo> info) throws IOException {
try {
List<YangNode> interJarResolvedNodes = parseJarFile(jarFile, TARGET);
@@ -323,7 +326,7 @@
dependentFileInfo.setRootNode(node);
dependentFileInfo.setForTranslator(false);
dependentFileInfo.setYangFileName(node.getName());
- utilManager.getYangFileInfoSet().add(dependentFileInfo);
+ info.add(dependentFileInfo);
}
} catch (IOException e) {
throw new IOException("failed to resolve in interjar scenario.");
diff --git a/plugin/maven/src/test/java/org/onosproject/yangutils/plugin/manager/RootClassGeneratorTest.java b/plugin/maven/src/test/java/org/onosproject/yangutils/plugin/manager/RootClassGeneratorTest.java
index 472f083..80fd438 100644
--- a/plugin/maven/src/test/java/org/onosproject/yangutils/plugin/manager/RootClassGeneratorTest.java
+++ b/plugin/maven/src/test/java/org/onosproject/yangutils/plugin/manager/RootClassGeneratorTest.java
@@ -38,6 +38,7 @@
@Test
public void rootClassGenTest() throws IOException, ParserException, MojoExecutionException {
+ deleteDirectory("target/manager/");
String searchDir = "src/test/resources/manager/singleChild";
utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(searchDir));
utilManager.parseYangFileInfoSet();
@@ -49,36 +50,20 @@
utilManager.translateToJava(yangPluginConfig);
String path = System.getProperty("user.dir") + "/target/manager/" +
- "org/onosproject/yang/gen/v1/test5/test/rev20160704/Test5.java";
- assertThat(true, is(!(new File(path)).exists()));
+ "org/onosproject/yang/gen/v1/single/test5/test/rev20160704" +
+ "/Test5.java";
+ assertThat(true, is((new File(path)).exists()));
path = System.getProperty("user.dir") + "/target/manager/" +
- "org/onosproject/yang/gen/v1/test5/test/rev20160704/Test7.java";
+ "org/onosproject/yang/gen/v1/single/test5/test/rev20160704" +
+ "/Test7.java";
assertThat(true, is((new File(path)).exists()));
deleteDirectory("target/manager/");
}
@Test
- public void rootClassNoGenTest() throws IOException, ParserException, MojoExecutionException {
- String searchDir = "src/test/resources/manager/nogen";
- utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(searchDir));
- utilManager.parseYangFileInfoSet();
- utilManager.createYangNodeSet();
- utilManager.resolveDependenciesUsingLinker();
-
- YangPluginConfig yangPluginConfig = new YangPluginConfig();
- yangPluginConfig.setCodeGenDir("target/manager/");
- utilManager.translateToJava(yangPluginConfig);
-
- String path = System.getProperty("user.dir") + "/target/manager/" +
- "org/onosproject/yang/gen/v1/test5/test/rev20160704/Test5.java";
-
- assertThat(true, is(!(new File(path)).exists()));
- deleteDirectory("target/manager/");
- }
-
- @Test
public void rootClassGenwithoutRevTest() throws IOException, ParserException, MojoExecutionException {
+ deleteDirectory("target/manager/");
String searchDir = "src/test/resources/manager/genwithoutrev";
utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(searchDir));
utilManager.parseYangFileInfoSet();
@@ -98,6 +83,7 @@
@Test
public void rootClassMethodGenTest() throws IOException, ParserException, MojoExecutionException {
+ deleteDirectory("target/manager/");
String searchDir = "src/test/resources/manager/MultiChild";
utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(searchDir));
utilManager.parseYangFileInfoSet();
@@ -109,15 +95,18 @@
utilManager.translateToJava(yangPluginConfig);
String path = System.getProperty("user.dir") + "/target/manager/" +
- "org/onosproject/yang/gen/v1/test5/test/rev20160704/Test5.java";
- assertThat(true, is(!(new File(path)).exists()));
+ "org/onosproject/yang/gen/v1/multi/test5/test/rev20160704" +
+ "/Test5.java";
+ assertThat(true, is((new File(path)).exists()));
path = System.getProperty("user.dir") + "/target/manager/" +
- "org/onosproject/yang/gen/v1/test5/test/rev20160704/Test7.java";
- assertThat(true, is(!(new File(path)).exists()));
+ "org/onosproject/yang/gen/v1/multi/test5/test/rev20160704" +
+ "/Test7.java";
+ assertThat(true, is((new File(path)).exists()));
path = System.getProperty("user.dir") + "/target/manager/" +
- "org/onosproject/yang/gen/v1/test8/test/rev20160704/Test8.java";
+ "org/onosproject/yang/gen/v1/multi/test8/test/rev20160704" +
+ "/Test8.java";
assertThat(true, is((new File(path)).exists()));
deleteDirectory("target/manager/");
diff --git a/plugin/maven/src/test/java/org/onosproject/yangutils/plugin/manager/TypeDefTranslatorTest.java b/plugin/maven/src/test/java/org/onosproject/yangutils/plugin/manager/TypeDefTranslatorTest.java
index 4ef664c..40e567d 100644
--- a/plugin/maven/src/test/java/org/onosproject/yangutils/plugin/manager/TypeDefTranslatorTest.java
+++ b/plugin/maven/src/test/java/org/onosproject/yangutils/plugin/manager/TypeDefTranslatorTest.java
@@ -16,14 +16,14 @@
package org.onosproject.yangutils.plugin.manager;
-import java.io.IOException;
-
import org.apache.maven.plugin.MojoExecutionException;
import org.junit.Test;
-import org.onosproject.yangutils.utils.io.YangPluginConfig;
import org.onosproject.yangutils.parser.exceptions.ParserException;
+import org.onosproject.yangutils.utils.io.YangPluginConfig;
import org.onosproject.yangutils.utils.io.impl.YangFileScanner;
+import java.io.IOException;
+
import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.deleteDirectory;
/**
@@ -76,4 +76,28 @@
}
+ /**
+ * Checks typedef translation should not result in any exception.
+ *
+ * @throws MojoExecutionException
+ */
+ @Test
+ public void processTypeDefWithUnionAndBitsTranslator() throws IOException,
+ ParserException, MojoExecutionException {
+
+ deleteDirectory("target/typedefTranslator/");
+ String searchDir = "src/test/resources/typedefTranslator/union";
+ utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(searchDir));
+ utilManager.parseYangFileInfoSet();
+ utilManager.createYangNodeSet();
+ utilManager.resolveDependenciesUsingLinker();
+
+ YangPluginConfig yangPluginConfig = new YangPluginConfig();
+ yangPluginConfig.setCodeGenDir("target/typedefTranslator/");
+ utilManager.translateToJava(yangPluginConfig);
+
+ //deleteDirectory("target/typedefTranslator/");
+
+ }
+
}
diff --git a/plugin/maven/src/test/java/org/onosproject/yangutils/plugin/manager/YangPluginUtilsTest.java b/plugin/maven/src/test/java/org/onosproject/yangutils/plugin/manager/YangPluginUtilsTest.java
index 891a280..b6769ce 100644
--- a/plugin/maven/src/test/java/org/onosproject/yangutils/plugin/manager/YangPluginUtilsTest.java
+++ b/plugin/maven/src/test/java/org/onosproject/yangutils/plugin/manager/YangPluginUtilsTest.java
@@ -16,14 +16,17 @@
package org.onosproject.yangutils.plugin.manager;
-import java.io.File;
-import java.io.IOException;
import org.apache.commons.io.FileUtils;
import org.apache.maven.project.MavenProject;
import org.junit.Test;
import org.sonatype.plexus.build.incremental.BuildContext;
import org.sonatype.plexus.build.incremental.DefaultBuildContext;
+import java.io.File;
+import java.io.IOException;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.core.Is.is;
import static org.onosproject.yangutils.plugin.manager.YangPluginUtils.addToCompilationRoot;
/**
@@ -41,9 +44,12 @@
MavenProject project = new MavenProject();
BuildContext context = new DefaultBuildContext();
- File sourceDir = new File(BASE_DIR + File.separator + "yang");
+ String dir = BASE_DIR + File.separator + "yang";
+ String path = System.getProperty("user.dir") + File.separator + dir;
+ File sourceDir = new File(dir);
sourceDir.mkdirs();
addToCompilationRoot(sourceDir.toString(), project, context);
+ assertThat(true, is(project.getCompileSourceRoots().contains(path)));
FileUtils.deleteDirectory(sourceDir);
}
}
diff --git a/plugin/maven/src/test/java/org/onosproject/yangutils/plugin/manager/YangXpathLinkerTest.java b/plugin/maven/src/test/java/org/onosproject/yangutils/plugin/manager/YangXpathLinkerTest.java
index cca5c3f..3d8ca0c 100644
--- a/plugin/maven/src/test/java/org/onosproject/yangutils/plugin/manager/YangXpathLinkerTest.java
+++ b/plugin/maven/src/test/java/org/onosproject/yangutils/plugin/manager/YangXpathLinkerTest.java
@@ -16,9 +16,6 @@
package org.onosproject.yangutils.plugin.manager;
-import java.io.IOException;
-import java.util.List;
-
import org.apache.maven.plugin.MojoExecutionException;
import org.junit.Test;
import org.onosproject.yangutils.datamodel.ResolvableType;
@@ -28,12 +25,16 @@
import org.onosproject.yangutils.datamodel.YangResolutionInfo;
import org.onosproject.yangutils.linker.impl.YangLinkerManager;
import org.onosproject.yangutils.linker.impl.YangXpathLinker;
-import org.onosproject.yangutils.utils.io.impl.YangFileScanner;
import org.onosproject.yangutils.utils.io.YangPluginConfig;
+import java.io.IOException;
+import java.util.List;
+
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.core.Is.is;
+import static org.onosproject.yangutils.linker.impl.XpathLinkingTypes.AUGMENT_LINKING;
import static org.onosproject.yangutils.linker.impl.YangLinkerUtils.updateFilePriority;
+import static org.onosproject.yangutils.utils.io.impl.YangFileScanner.getYangFiles;
import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.deleteDirectory;
/**
@@ -57,7 +58,7 @@
@Test
public void processIntraFileLinkingSingleLevel() throws IOException, MojoExecutionException {
- utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(INTRA_FILE_PATH + "IntraSingle/"));
+ utilManager.createYangFileInfoSet(getYangFiles(INTRA_FILE_PATH + "IntraSingle/"));
utilManager.parseYangFileInfoSet();
utilManager.createYangNodeSet();
utilManager.resolveDependenciesUsingLinker();
@@ -88,7 +89,7 @@
@Test
public void processIntraFileLinkingMultipleLevel() throws IOException {
- utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(INTRA_FILE_PATH + "IntraMulti/"));
+ utilManager.createYangFileInfoSet(getYangFiles(INTRA_FILE_PATH + "IntraMulti/"));
utilManager.parseYangFileInfoSet();
utilManager.createYangNodeSet();
@@ -101,7 +102,7 @@
for (YangAugment augment : augments) {
targetNodeName = augment.getTargetNode().get(augment.getTargetNode().size() - 1).getNodeIdentifier()
.getName();
- targetNode = linker.processAugmentXpathLinking(augment.getTargetNode(), node);
+ targetNode = linker.processXpathLinking(augment.getTargetNode(), node, AUGMENT_LINKING);
}
}
@@ -115,7 +116,7 @@
*/
@Test
public void processIntraFileLinkingInAugmentSingleLevel() throws IOException {
- utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(INTRA_FILE_PATH + "IntraSingleAugment/"));
+ utilManager.createYangFileInfoSet(getYangFiles(INTRA_FILE_PATH + "IntraSingleAugment/"));
utilManager.parseYangFileInfoSet();
utilManager.createYangNodeSet();
@@ -128,7 +129,7 @@
for (YangAugment augment : augments) {
targetNodeName = augment.getTargetNode().get(augment.getTargetNode().size() - 1).getNodeIdentifier()
.getName();
- targetNode = linker.processAugmentXpathLinking(augment.getTargetNode(), node);
+ targetNode = linker.processXpathLinking(augment.getTargetNode(), node, AUGMENT_LINKING);
}
}
@@ -142,7 +143,7 @@
*/
@Test
public void processIntraFileLinkingInAugmentMultiLevel() throws IOException {
- utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(INTRA_FILE_PATH + "IntraMultiAugment/"));
+ utilManager.createYangFileInfoSet(getYangFiles(INTRA_FILE_PATH + "IntraMultiAugment/"));
utilManager.parseYangFileInfoSet();
utilManager.createYangNodeSet();
linkerManager.createYangNodeSet(utilManager.getYangNodeSet());
@@ -159,7 +160,7 @@
for (YangAugment augment : augments) {
targetNodeName = augment.getTargetNode().get(augment.getTargetNode().size() - 1).getNodeIdentifier()
.getName();
- targetNode = linker.processAugmentXpathLinking(augment.getTargetNode(), node);
+ targetNode = linker.processXpathLinking(augment.getTargetNode(), node, AUGMENT_LINKING);
}
}
@@ -174,7 +175,7 @@
*/
@Test
public void processIntraFileLinkingInSubModuleSingleLevel() throws IOException {
- utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(INTRA_FILE_PATH + "IntraSingleSubModule/"));
+ utilManager.createYangFileInfoSet(getYangFiles(INTRA_FILE_PATH + "IntraSingleSubModule/"));
utilManager.parseYangFileInfoSet();
utilManager.createYangNodeSet();
linkerManager.createYangNodeSet(utilManager.getYangNodeSet());
@@ -190,7 +191,7 @@
for (YangAugment augment : augments) {
targetNodeName = augment.getTargetNode().get(augment.getTargetNode().size() - 1).getNodeIdentifier()
.getName();
- targetNode = linker.processAugmentXpathLinking(augment.getTargetNode(), node);
+ targetNode = linker.processXpathLinking(augment.getTargetNode(), node, AUGMENT_LINKING);
}
}
@@ -205,7 +206,7 @@
@Test
public void processIntraFileLinkingInSubModuleMultiLevel() throws IOException {
- utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(INTRA_FILE_PATH + "IntraMultiSubModule/"));
+ utilManager.createYangFileInfoSet(getYangFiles(INTRA_FILE_PATH + "IntraMultiSubModule/"));
utilManager.parseYangFileInfoSet();
utilManager.createYangNodeSet();
linkerManager.createYangNodeSet(utilManager.getYangNodeSet());
@@ -221,7 +222,7 @@
for (YangAugment augment : augments) {
targetNodeName = augment.getTargetNode().get(augment.getTargetNode().size() - 1).getNodeIdentifier()
.getName();
- targetNode = linker.processAugmentXpathLinking(augment.getTargetNode(), node);
+ targetNode = linker.processXpathLinking(augment.getTargetNode(), node, AUGMENT_LINKING);
}
}
@@ -236,7 +237,7 @@
@Test
public void processIntraFileLinkingInUsesSingleLevel() throws IOException {
- utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(INTRA_FILE_PATH + "IntraSingleUses/"));
+ utilManager.createYangFileInfoSet(getYangFiles(INTRA_FILE_PATH + "IntraSingleUses/"));
utilManager.parseYangFileInfoSet();
utilManager.createYangNodeSet();
linkerManager.createYangNodeSet(utilManager.getYangNodeSet());
@@ -252,7 +253,7 @@
for (YangAugment augment : augments) {
targetNodeName = augment.getTargetNode().get(augment.getTargetNode().size() - 1).getNodeIdentifier()
.getName();
- targetNode = linker.processAugmentXpathLinking(augment.getTargetNode(), node);
+ targetNode = linker.processXpathLinking(augment.getTargetNode(), node, AUGMENT_LINKING);
}
}
@@ -267,7 +268,7 @@
@Test
public void processIntraFileLinkingInUsesMultiLevel() throws IOException {
- utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(INTRA_FILE_PATH + "IntraMultiUses/"));
+ utilManager.createYangFileInfoSet(getYangFiles(INTRA_FILE_PATH + "IntraMultiUses/"));
utilManager.parseYangFileInfoSet();
utilManager.createYangNodeSet();
linkerManager.createYangNodeSet(utilManager.getYangNodeSet());
@@ -283,7 +284,7 @@
for (YangAugment augment : augments) {
targetNodeName = augment.getTargetNode().get(augment.getTargetNode().size() - 1).getNodeIdentifier()
.getName();
- targetNode = linker.processAugmentXpathLinking(augment.getTargetNode(), node);
+ targetNode = linker.processXpathLinking(augment.getTargetNode(), node, AUGMENT_LINKING);
}
}
@@ -298,7 +299,7 @@
@Test
public void processInterFileLinkingSingleLevel() throws IOException {
- utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(INTER_FILE_PATH + "InterSingle/"));
+ utilManager.createYangFileInfoSet(getYangFiles(INTER_FILE_PATH + "InterSingle/"));
utilManager.parseYangFileInfoSet();
utilManager.createYangNodeSet();
linkerManager.createYangNodeSet(utilManager.getYangNodeSet());
@@ -313,7 +314,7 @@
for (YangAugment augment : augments) {
targetNodeName = augment.getTargetNode().get(augment.getTargetNode().size() - 1).getNodeIdentifier()
.getName();
- targetNode = linker.processAugmentXpathLinking(augment.getTargetNode(), node);
+ targetNode = linker.processXpathLinking(augment.getTargetNode(), node, AUGMENT_LINKING);
}
}
@@ -328,7 +329,7 @@
@Test
public void processInterFileLinkingMultipleLevel() throws IOException {
- utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(INTER_FILE_PATH + "InterMulti/"));
+ utilManager.createYangFileInfoSet(getYangFiles(INTER_FILE_PATH + "InterMulti/"));
utilManager.parseYangFileInfoSet();
utilManager.createYangNodeSet();
linkerManager.createYangNodeSet(utilManager.getYangNodeSet());
@@ -343,7 +344,7 @@
for (YangAugment augment : augments) {
targetNodeName = augment.getTargetNode().get(augment.getTargetNode().size() - 1).getNodeIdentifier()
.getName();
- targetNode = linker.processAugmentXpathLinking(augment.getTargetNode(), node);
+ targetNode = linker.processXpathLinking(augment.getTargetNode(), node, AUGMENT_LINKING);
}
}
@@ -358,7 +359,7 @@
@Test
public void processInterFileLinkingInAugmentSingleLevel() throws IOException {
- utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(INTER_FILE_PATH + "InterSingleAugment/"));
+ utilManager.createYangFileInfoSet(getYangFiles(INTER_FILE_PATH + "InterSingleAugment/"));
utilManager.parseYangFileInfoSet();
utilManager.createYangNodeSet();
linkerManager.createYangNodeSet(utilManager.getYangNodeSet());
@@ -373,7 +374,7 @@
for (YangAugment augment : augments) {
targetNodeName = augment.getTargetNode().get(augment.getTargetNode().size() - 1).getNodeIdentifier()
.getName();
- targetNode = linker.processAugmentXpathLinking(augment.getTargetNode(), node);
+ targetNode = linker.processXpathLinking(augment.getTargetNode(), node, AUGMENT_LINKING);
}
}
@@ -388,7 +389,7 @@
@Test
public void processInterFileLinkingInAugmentMultiLevel() throws IOException {
- utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(INTER_FILE_PATH + "InterMultiAugment/"));
+ utilManager.createYangFileInfoSet(getYangFiles(INTER_FILE_PATH + "InterMultiAugment/"));
utilManager.parseYangFileInfoSet();
utilManager.createYangNodeSet();
linkerManager.createYangNodeSet(utilManager.getYangNodeSet());
@@ -403,7 +404,7 @@
for (YangAugment augment : augments) {
targetNodeName = augment.getTargetNode().get(augment.getTargetNode().size() - 1).getNodeIdentifier()
.getName();
- targetNode = linker.processAugmentXpathLinking(augment.getTargetNode(), node);
+ targetNode = linker.processXpathLinking(augment.getTargetNode(), node, AUGMENT_LINKING);
}
}
@@ -418,7 +419,7 @@
@Test
public void processMultiInterFileLinkingInAugmentSingleLevel() throws IOException {
- utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(INTER_FILE_PATH + "InterMultiFileAugment/"));
+ utilManager.createYangFileInfoSet(getYangFiles(INTER_FILE_PATH + "InterMultiFileAugment/"));
utilManager.parseYangFileInfoSet();
utilManager.createYangNodeSet();
linkerManager.createYangNodeSet(utilManager.getYangNodeSet());
@@ -433,7 +434,7 @@
for (YangAugment augment : augments) {
targetNodeName = augment.getTargetNode().get(augment.getTargetNode().size() - 1).getNodeIdentifier()
.getName();
- targetNode = linker.processAugmentXpathLinking(augment.getTargetNode(), node);
+ targetNode = linker.processXpathLinking(augment.getTargetNode(), node, AUGMENT_LINKING);
}
}
@@ -449,7 +450,7 @@
public void processMultiInterFileLinkingInAugmentMultiLevel() throws IOException {
utilManager
- .createYangFileInfoSet(YangFileScanner.getYangFiles(INTER_FILE_PATH + "InterMultiFileAugmentMulti/"));
+ .createYangFileInfoSet(getYangFiles(INTER_FILE_PATH + "InterMultiFileAugmentMulti/"));
utilManager.parseYangFileInfoSet();
utilManager.createYangNodeSet();
linkerManager.createYangNodeSet(utilManager.getYangNodeSet());
@@ -483,7 +484,7 @@
@Test
public void processInterFileLinkingInSubModuleSingleLevel() throws IOException {
- utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(INTER_FILE_PATH + "InterSingleSubModule/"));
+ utilManager.createYangFileInfoSet(getYangFiles(INTER_FILE_PATH + "InterSingleSubModule/"));
utilManager.parseYangFileInfoSet();
utilManager.createYangNodeSet();
linkerManager.createYangNodeSet(utilManager.getYangNodeSet());
@@ -516,7 +517,7 @@
@Test
public void processInterFileLinkingInSubModuleMultiLevel() throws IOException {
- utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(INTER_FILE_PATH + "InterMultiSubModule/"));
+ utilManager.createYangFileInfoSet(getYangFiles(INTER_FILE_PATH + "InterMultiSubModule/"));
utilManager.parseYangFileInfoSet();
utilManager.createYangNodeSet();
linkerManager.createYangNodeSet(utilManager.getYangNodeSet());
@@ -549,7 +550,7 @@
@Test
public void processInterFileLinkingInUsesInAugment() throws IOException {
- utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(INTER_FILE_PATH + "InterSingleUses/"));
+ utilManager.createYangFileInfoSet(getYangFiles(INTER_FILE_PATH + "InterSingleUses/"));
utilManager.parseYangFileInfoSet();
utilManager.createYangNodeSet();
linkerManager.createYangNodeSet(utilManager.getYangNodeSet());
@@ -584,7 +585,7 @@
@Test
public void processInterFileLinkingInUsesMultiLevel() throws IOException {
- utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(INTER_FILE_PATH + "InterMultiUses/"));
+ utilManager.createYangFileInfoSet(getYangFiles(INTER_FILE_PATH + "InterMultiUses/"));
utilManager.parseYangFileInfoSet();
utilManager.createYangNodeSet();
linkerManager.createYangNodeSet(utilManager.getYangNodeSet());
@@ -602,7 +603,7 @@
for (YangAugment augment : augments) {
targetNodeName = augment.getTargetNode().get(augment.getTargetNode().size() - 1).getNodeIdentifier()
.getName();
- targetNode = linker.processAugmentXpathLinking(augment.getTargetNode(), node);
+ targetNode = linker.processXpathLinking(augment.getTargetNode(), node, AUGMENT_LINKING);
}
}
@@ -617,7 +618,7 @@
@Test
public void processInterFileLinkingInMultipleSubmodules() throws IOException {
- utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(CASE_FILE_PATH + "submodule/"));
+ utilManager.createYangFileInfoSet(getYangFiles(CASE_FILE_PATH + "submodule/"));
utilManager.parseYangFileInfoSet();
utilManager.createYangNodeSet();
linkerManager.createYangNodeSet(utilManager.getYangNodeSet());
@@ -653,7 +654,7 @@
@Test
public void processInterFileLinkingInMultipleUses() throws IOException {
- utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(CASE_FILE_PATH + "uses/"));
+ utilManager.createYangFileInfoSet(getYangFiles(CASE_FILE_PATH + "uses/"));
utilManager.parseYangFileInfoSet();
utilManager.createYangNodeSet();
linkerManager.createYangNodeSet(utilManager.getYangNodeSet());
diff --git a/plugin/maven/src/test/java/org/onosproject/yangutils/translator/tojava/utils/MethodsGeneratorTest.java b/plugin/maven/src/test/java/org/onosproject/yangutils/translator/tojava/utils/MethodsGeneratorTest.java
index 6b20103..4de9402 100644
--- a/plugin/maven/src/test/java/org/onosproject/yangutils/translator/tojava/utils/MethodsGeneratorTest.java
+++ b/plugin/maven/src/test/java/org/onosproject/yangutils/translator/tojava/utils/MethodsGeneratorTest.java
@@ -99,13 +99,10 @@
private static final String SET = "setValue.set(0);\n";
private static final String UNION = " @Override\n" +
" public String toString() {\n" +
- " MoreObjects.ToStringHelper helper =" +
- " MoreObjects.toStringHelper(getClass())\n" +
- " .omitNullValues();\n" +
" if (setValue.get(0)) {\n" +
- " helper.add(\"string\", string);\n" +
+ " return string;\n" +
" }\n" +
- " return helper.toString();\n" +
+ " return null;\n" +
" }";
/**
@@ -259,7 +256,7 @@
JavaAttributeInfo testAttr = getTestAttribute();
List<YangType<?>> types = new ArrayList<>();
types.add(testAttr.getAttributeType());
- String method = getUnionToStringMethod(types);
+ String method = getUnionToStringMethod(types, CLASS_NAME);
assertThat(true, is(method.contains(UNION)));
}
diff --git a/plugin/maven/src/test/java/org/onosproject/yangutils/utils/io/impl/JavaDocGenTest.java b/plugin/maven/src/test/java/org/onosproject/yangutils/utils/io/impl/JavaDocGenTest.java
index dcb4a34..14c5134 100644
--- a/plugin/maven/src/test/java/org/onosproject/yangutils/utils/io/impl/JavaDocGenTest.java
+++ b/plugin/maven/src/test/java/org/onosproject/yangutils/utils/io/impl/JavaDocGenTest.java
@@ -34,7 +34,7 @@
import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.CONSTRUCTOR;
import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.DEFAULT_CONSTRUCTOR;
import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.GETTER_METHOD;
-import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.IMPL_CLASS;
+import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.DEFAULT_CLASS;
import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.INTERFACE;
import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.PACKAGE_INFO;
import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.SETTER_METHOD;
@@ -141,7 +141,7 @@
*/
@Test
public void implClassGenerationTest() {
- String implClassJavaDoc = getJavaDoc(IMPL_CLASS, TEST_NAME, false, null);
+ String implClassJavaDoc = getJavaDoc(DEFAULT_CLASS, TEST_NAME, false, null);
assertThat(true,
is(implClassJavaDoc.contains("Represents the implementation of")
&& implClassJavaDoc.contains(END_STRING)));
diff --git a/plugin/maven/src/test/resources/ChoiceCaseTranslator.yang b/plugin/maven/src/test/resources/ChoiceCaseTranslator.yang
index e8127ea..35cbf19 100644
--- a/plugin/maven/src/test/resources/ChoiceCaseTranslator.yang
+++ b/plugin/maven/src/test/resources/ChoiceCaseTranslator.yang
@@ -2,7 +2,7 @@
yang-version 1;
namespace http://huawei.com;
prefix Ant;
- container food {
+ notification food {
choice snack {
case sports-arena {
leaf pretzel {
diff --git a/plugin/maven/src/test/resources/manager/MultiChild/module.yang b/plugin/maven/src/test/resources/manager/MultiChild/module.yang
index 1c4637c..845380b 100644
--- a/plugin/maven/src/test/resources/manager/MultiChild/module.yang
+++ b/plugin/maven/src/test/resources/manager/MultiChild/module.yang
@@ -1,5 +1,5 @@
module test5 {
- namespace "test5:test";
+ namespace "multi:test5:test";
prefix test ;
revision "2016-07-04" {
diff --git a/plugin/maven/src/test/resources/manager/MultiChild/test.yang b/plugin/maven/src/test/resources/manager/MultiChild/test.yang
index 036d78a..2665267 100644
--- a/plugin/maven/src/test/resources/manager/MultiChild/test.yang
+++ b/plugin/maven/src/test/resources/manager/MultiChild/test.yang
@@ -1,5 +1,5 @@
module test7 {
- namespace "test5:test";
+ namespace "multi:test5:test";
prefix test ;
revision "2016-07-04" {
diff --git a/plugin/maven/src/test/resources/manager/MultiChild/test2.yang b/plugin/maven/src/test/resources/manager/MultiChild/test2.yang
index b252c23..c87022d 100644
--- a/plugin/maven/src/test/resources/manager/MultiChild/test2.yang
+++ b/plugin/maven/src/test/resources/manager/MultiChild/test2.yang
@@ -1,5 +1,5 @@
module test8 {
- namespace "test8:test";
+ namespace "multi:test8:test";
prefix test ;
revision "2016-07-04" {
diff --git a/plugin/maven/src/test/resources/manager/singleChild/module.yang b/plugin/maven/src/test/resources/manager/singleChild/module.yang
index 5fb8a9b..67f4bc9 100644
--- a/plugin/maven/src/test/resources/manager/singleChild/module.yang
+++ b/plugin/maven/src/test/resources/manager/singleChild/module.yang
@@ -1,5 +1,5 @@
module test5 {
- namespace "test5:test";
+ namespace "single:test5:test";
prefix test ;
revision "2016-07-04" {
diff --git a/plugin/maven/src/test/resources/manager/singleChild/test.yang b/plugin/maven/src/test/resources/manager/singleChild/test.yang
index 483e00e..2d13b4c 100644
--- a/plugin/maven/src/test/resources/manager/singleChild/test.yang
+++ b/plugin/maven/src/test/resources/manager/singleChild/test.yang
@@ -1,5 +1,5 @@
module test7 {
- namespace "test5:test";
+ namespace "single:test5:test";
prefix test ;
revision "2016-07-04" {
diff --git a/plugin/maven/src/test/resources/typedefTranslator/union/typedefs.yang b/plugin/maven/src/test/resources/typedefTranslator/union/typedefs.yang
new file mode 100644
index 0000000..4a3d150
--- /dev/null
+++ b/plugin/maven/src/test/resources/typedefTranslator/union/typedefs.yang
@@ -0,0 +1,52 @@
+module types {
+
+ namespace "yang:types";
+ prefix "types";
+ yang-version 1;
+
+ revision 2016-10-08;
+ typedef ip-address {
+ type union {
+ type ipv4-address;
+ type ipv6-address;
+ type leaf;
+ }
+ }
+
+ typedef ipv4-address {
+ type int32;
+ }
+
+ typedef ipv6-address {
+ type int32;
+ }
+
+ typedef port-number {
+ type bits {
+ bit disable-nagle {
+ position 0;
+ }
+ bit auto-sense-speed {
+ position 1;
+ }
+ bit Mb-only {
+ position 2;
+ }
+ }
+
+}
+
+
+ container con1 {
+ leaf abc {
+ type int32;
+ }
+ }
+
+ typedef leaf {
+ type leafref {
+ path "/con1/abc";
+ }
+ }
+
+}
diff --git a/plugin/maven/src/test/resources/xPathLinker/Case/uses/test2.yang b/plugin/maven/src/test/resources/xPathLinker/Case/uses/test2.yang
index e42101e..8e4dccf 100644
--- a/plugin/maven/src/test/resources/xPathLinker/Case/uses/test2.yang
+++ b/plugin/maven/src/test/resources/xPathLinker/Case/uses/test2.yang
@@ -53,7 +53,7 @@
}
}
- augment /group1/cont3/cont4 {
+ augment /cont5/cont6/cont3/cont4 {
container cont8 {
leaf leaf8 {
type int32;