[ONOS-4829] Augmented data method generator implmentation.
Change-Id: I0cb68dd10a748e5b66eec0b832574f408a23ba5c
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 fcd2966..16962f2 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
@@ -206,7 +206,7 @@
File folder = new File(System.getProperty("user.dir") + SLASH + FLOW_CLASSIFIER_FOLDER);
File file = new File(System.getProperty("user.dir") + SLASH + FLOW_CLASSIFIER_MANAGER);
assertThat(true, is(folder.exists()));
- assertThat(false, is(file.exists()));
+ assertThat(true, is(file.exists()));
}
/**
diff --git a/plugin/src/test/java/org/onosproject/yangutils/plugin/manager/NotificationTranslatorTest.java b/plugin/src/test/java/org/onosproject/yangutils/plugin/manager/NotificationTranslatorTest.java
index 27b42e1..ac7e417 100644
--- a/plugin/src/test/java/org/onosproject/yangutils/plugin/manager/NotificationTranslatorTest.java
+++ b/plugin/src/test/java/org/onosproject/yangutils/plugin/manager/NotificationTranslatorTest.java
@@ -50,6 +50,7 @@
generateJavaCode(node, yangPluginConfig);
deleteDirectory("target/NotificationTest/");
+ deleteDirectory("target/NotificationTest1/");
}
// TODO enhance the test cases, after having a framework of translator test.
diff --git a/plugin/src/test/java/org/onosproject/yangutils/plugin/manager/YangXpathLinkerTest.java b/plugin/src/test/java/org/onosproject/yangutils/plugin/manager/YangXpathLinkerTest.java
index 5d1251a..7fcd7f1 100644
--- a/plugin/src/test/java/org/onosproject/yangutils/plugin/manager/YangXpathLinkerTest.java
+++ b/plugin/src/test/java/org/onosproject/yangutils/plugin/manager/YangXpathLinkerTest.java
@@ -26,7 +26,6 @@
import org.onosproject.yangutils.datamodel.YangNode;
import org.onosproject.yangutils.datamodel.YangReferenceResolver;
import org.onosproject.yangutils.datamodel.YangResolutionInfo;
-import org.onosproject.yangutils.linker.exceptions.LinkerException;
import org.onosproject.yangutils.linker.impl.YangLinkerManager;
import org.onosproject.yangutils.linker.impl.YangXpathLinker;
import org.onosproject.yangutils.utils.io.impl.YangFileScanner;
@@ -44,11 +43,12 @@
private YangLinkerManager linkerManager = new YangLinkerManager();
private static final String INTRA_FILE_PATH = "src/test/resources/xPathLinker/IntraFile/";
private static final String INTER_FILE_PATH = "src/test/resources/xPathLinker/InterFile/";
+ private static final String CASE_FILE_PATH = "src/test/resources/xPathLinker/Case/";
/**
* Unit test case for intra file linking for single level container.
*
- * @throws IOException when fails to do IO operations
+ * @throws IOException when fails to do IO operations
* @throws MojoExecutionException
*/
@Test
@@ -230,7 +230,7 @@
*
* @throws IOException when fails to do IO operations
*/
- @Test(expected = LinkerException.class)
+ @Test
public void processIntraFileLinkingInUsesSingleLevel() throws IOException {
utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(INTRA_FILE_PATH + "IntraSingleUses/"));
@@ -260,7 +260,7 @@
*
* @throws IOException when fails to do IO operations
*/
- @Test(expected = LinkerException.class)
+ @Test
public void processIntraFileLinkingInUsesMultiLevel() throws IOException {
utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(INTRA_FILE_PATH + "IntraMultiUses/"));
@@ -449,6 +449,9 @@
utilManager.createYangNodeSet();
linkerManager.createYangNodeSet(utilManager.getYangNodeSet());
linkerManager.addRefToYangFilesImportList(utilManager.getYangNodeSet());
+ linkerManager.linkSubModulesToParentModule(utilManager.getYangNodeSet());
+ linkerManager.addRefToYangFilesIncludeList(utilManager.getYangNodeSet());
+ linkerManager.processInterFileLinking(utilManager.getYangNodeSet());
YangNode targetNode = null;
String targetNodeName = null;
@@ -459,7 +462,7 @@
for (YangAugment augment : augments) {
targetNodeName = augment.getTargetNode().get(augment.getTargetNode().size() - 1).getNodeIdentifier()
.getName();
- targetNode = linker.processAugmentXpathLinking(augment.getTargetNode(), node);
+ targetNode = augment.getAugmentedNode();
}
}
@@ -481,7 +484,7 @@
linkerManager.linkSubModulesToParentModule(utilManager.getYangNodeSet());
linkerManager.addRefToYangFilesImportList(utilManager.getYangNodeSet());
linkerManager.addRefToYangFilesIncludeList(utilManager.getYangNodeSet());
-
+ linkerManager.processInterFileLinking(utilManager.getYangNodeSet());
YangNode targetNode = null;
String targetNodeName = null;
@@ -491,7 +494,7 @@
for (YangAugment augment : augments) {
targetNodeName = augment.getTargetNode().get(augment.getTargetNode().size() - 1).getNodeIdentifier()
.getName();
- targetNode = linker.processAugmentXpathLinking(augment.getTargetNode(), node);
+ targetNode = augment.getAugmentedNode();
}
}
@@ -523,7 +526,7 @@
for (YangAugment augment : augments) {
targetNodeName = augment.getTargetNode().get(augment.getTargetNode().size() - 1).getNodeIdentifier()
.getName();
- targetNode = linker.processAugmentXpathLinking(augment.getTargetNode(), node);
+ targetNode = augment.getAugmentedNode();
}
}
@@ -538,11 +541,11 @@
@Test
public void processInterFileLinkingInUsesInAugment() throws IOException {
- /* FIXME: when uses cloning is done test it.
utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(INTER_FILE_PATH + "InterSingleUses/"));
utilManager.parseYangFileInfoSet();
utilManager.createYangNodeSet();
linkerManager.createYangNodeSet(utilManager.getYangNodeSet());
+ linkerManager.linkSubModulesToParentModule(utilManager.getYangNodeSet());
linkerManager.addRefToYangFilesImportList(utilManager.getYangNodeSet());
linkerManager.addRefToYangFilesIncludeList(utilManager.getYangNodeSet());
linkerManager.processInterFileLinking(utilManager.getYangNodeSet());
@@ -555,13 +558,13 @@
for (YangAugment augment : augments) {
targetNodeName = augment.getTargetNode().get(augment.getTargetNode().size() - 1)
- .getNodeIdentifier().getName();
- targetNode = linker.processXpathLinking(augment.getTargetNode(), node);
+ .getNodeIdentifier().getName();
+ targetNode = augment.getAugmentedNode();
}
}
assertThat(true, is(targetNode.getName().equals(targetNodeName)));
- */
+
}
/**
@@ -569,7 +572,7 @@
*
* @throws IOException when fails to do IO operations
*/
- @Test(expected = LinkerException.class)
+ @Test
public void processInterFileLinkingInUsesMultiLevel() throws IOException {
utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(INTER_FILE_PATH + "InterMultiUses/"));
@@ -596,4 +599,72 @@
assertThat(true, is(targetNode.getName().equals(targetNodeName)));
}
+ /**
+ * Unit test case for inter file linking for multi level uses inside augment.
+ *
+ * @throws IOException when fails to do IO operations
+ */
+ @Test
+ public void processInterFileLinkingInMultipleSubmodules() throws IOException {
+
+ utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(CASE_FILE_PATH + "submodule/"));
+ utilManager.parseYangFileInfoSet();
+ utilManager.createYangNodeSet();
+ linkerManager.createYangNodeSet(utilManager.getYangNodeSet());
+ linkerManager.linkSubModulesToParentModule(utilManager.getYangNodeSet());
+ linkerManager.addRefToYangFilesImportList(utilManager.getYangNodeSet());
+ linkerManager.addRefToYangFilesIncludeList(utilManager.getYangNodeSet());
+ linkerManager.processInterFileLinking(utilManager.getYangNodeSet());
+
+ YangNode targetNode = null;
+ String targetNodeName = null;
+
+ for (YangNode node : utilManager.getYangNodeSet()) {
+ List<YangAugment> augments = linker.getListOfYangAugment(node);
+
+ for (YangAugment augment : augments) {
+ targetNodeName = augment.getTargetNode().get(augment.getTargetNode().size() - 1)
+ .getNodeIdentifier().getName();
+ targetNode = augment.getAugmentedNode();
+ }
+ }
+
+ assertThat(true, is(targetNode.getName().equals(targetNodeName)));
+
+ }
+
+ /**
+ * Unit test case for inter file linking for multi level uses inside augment.
+ *
+ * @throws IOException when fails to do IO operations
+ */
+ @Test
+ public void processInterFileLinkingInMultipleUses() throws IOException {
+
+ /** FIXME: once order of linking is done.
+ utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(CASE_FILE_PATH + "uses/"));
+ utilManager.parseYangFileInfoSet();
+ utilManager.createYangNodeSet();
+ linkerManager.createYangNodeSet(utilManager.getYangNodeSet());
+ linkerManager.linkSubModulesToParentModule(utilManager.getYangNodeSet());
+ linkerManager.addRefToYangFilesImportList(utilManager.getYangNodeSet());
+ linkerManager.addRefToYangFilesIncludeList(utilManager.getYangNodeSet());
+ linkerManager.processInterFileLinking(utilManager.getYangNodeSet());
+
+ YangNode targetNode = null;
+ String targetNodeName = null;
+
+ for (YangNode node : utilManager.getYangNodeSet()) {
+ List<YangAugment> augments = linker.getListOfYangAugment(node);
+
+ for (YangAugment augment : augments) {
+ targetNodeName = augment.getTargetNode().get(augment.getTargetNode().size() - 1)
+ .getNodeIdentifier().getName();
+ targetNode = augment.getAugmentedNode();
+ }
+ }
+
+ assertThat(true, is(targetNode.getName().equals(targetNodeName)));
+ */
+ }
}
diff --git a/plugin/src/test/java/org/onosproject/yangutils/translator/tojava/utils/JavaIdentifierSyntaxTest.java b/plugin/src/test/java/org/onosproject/yangutils/translator/tojava/utils/JavaIdentifierSyntaxTest.java
index bfde08d..bd598e4 100644
--- a/plugin/src/test/java/org/onosproject/yangutils/translator/tojava/utils/JavaIdentifierSyntaxTest.java
+++ b/plugin/src/test/java/org/onosproject/yangutils/translator/tojava/utils/JavaIdentifierSyntaxTest.java
@@ -113,8 +113,6 @@
private static final String BASE_DIR_PKG = "target.UnitTestCase.";
private static final String DIR_PATH = "exist1.exist2.exist3";
private static final String PKG_INFO = "package-info.java";
- private static final String BASE_PKG = "target/UnitTestCase";
- private static final String TEST_DATA_1 = "This is to append a text to the file first1\n";
/**
* Unit test for private constructor.
@@ -319,5 +317,6 @@
assertThat(true, is(doesPackageExist(strPath)));
createDir.delete();
deleteDirectory(createDir);
+ deleteDirectory(new File(BASE_DIR_PKG.replace(PERIOD, SLASH)));
}
}
diff --git a/plugin/src/test/java/org/onosproject/yangutils/utils/io/impl/FileSystemUtilTest.java b/plugin/src/test/java/org/onosproject/yangutils/utils/io/impl/FileSystemUtilTest.java
index 0198720..271036f 100644
--- a/plugin/src/test/java/org/onosproject/yangutils/utils/io/impl/FileSystemUtilTest.java
+++ b/plugin/src/test/java/org/onosproject/yangutils/utils/io/impl/FileSystemUtilTest.java
@@ -20,6 +20,8 @@
import java.io.IOException;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
+
+import org.apache.commons.io.FileUtils;
import org.junit.Test;
import static org.apache.commons.io.FileUtils.deleteDirectory;
@@ -84,5 +86,6 @@
appendFileContents(createFile, createSourceFile);
updateFileHandle(createFile, null, true);
deleteDirectory(dir);
+ FileUtils.deleteDirectory(new File(BASE_PKG));
}
}
diff --git a/plugin/src/test/java/org/onosproject/yangutils/utils/io/impl/YangIoUtilsTest.java b/plugin/src/test/java/org/onosproject/yangutils/utils/io/impl/YangIoUtilsTest.java
index e1b167d..6451e4d 100644
--- a/plugin/src/test/java/org/onosproject/yangutils/utils/io/impl/YangIoUtilsTest.java
+++ b/plugin/src/test/java/org/onosproject/yangutils/utils/io/impl/YangIoUtilsTest.java
@@ -67,7 +67,7 @@
addPackageInfo(dirPath, CHECK1, CREATE_PATH, false, getStubPluginConfig());
File filePath = new File(dirPath + File.separator + PKG_INFO);
assertThat(filePath.isFile(), is(true));
- FileUtils.deleteDirectory(dirPath);
+ FileUtils.deleteDirectory(new File(BASE_DIR));
}
/**
@@ -83,7 +83,7 @@
addPackageInfo(dirPath, CHECK1, PATH + CREATE_PATH, false, getStubPluginConfig());
File filePath = new File(dirPath + File.separator + PKG_INFO);
assertThat(filePath.isFile(), is(true));
- FileUtils.deleteDirectory(dirPath);
+ FileUtils.deleteDirectory(new File(BASE_DIR));
}
/**
@@ -99,7 +99,7 @@
addPackageInfo(dirPath, CHECK1, PATH + CREATE_PATH, true, getStubPluginConfig());
File filePath = new File(dirPath + File.separator + PKG_INFO);
assertThat(filePath.isFile(), is(true));
- FileUtils.deleteDirectory(dirPath);
+ FileUtils.deleteDirectory(new File(BASE_DIR));
}
/**
@@ -117,6 +117,7 @@
File filePath1 = new File(dirPath + File.separator + PKG_INFO);
assertThat(filePath1.isFile(), is(false));
FileUtils.deleteDirectory(dirPath);
+ FileUtils.deleteDirectory(new File(BASE_DIR));
}
/**
@@ -180,7 +181,7 @@
File dirPath = createDirectories(CREATE_PATH);
assertThat(dirPath.isDirectory(), is(true));
- FileUtils.deleteDirectory(dirPath);
+ FileUtils.deleteDirectory(new File(BASE_DIR));
}
/**