[ONOS-5178] Defect fix :No get/set for root node in generated service
Change-Id: I9d90068e4cdd3d35a9ee71fd1f00c4a635b191b7
diff --git a/plugin/src/test/java/org/onosproject/yangutils/parser/impl/listeners/RevisionListenerTest.java b/plugin/src/test/java/org/onosproject/yangutils/parser/impl/listeners/RevisionListenerTest.java
index fbeacc8..88c4278 100644
--- a/plugin/src/test/java/org/onosproject/yangutils/parser/impl/listeners/RevisionListenerTest.java
+++ b/plugin/src/test/java/org/onosproject/yangutils/parser/impl/listeners/RevisionListenerTest.java
@@ -16,17 +16,17 @@
package org.onosproject.yangutils.parser.impl.listeners;
-import java.io.IOException;
-import java.text.ParseException;
-import java.text.SimpleDateFormat;
import org.junit.Test;
import org.onosproject.yangutils.datamodel.YangModule;
import org.onosproject.yangutils.datamodel.YangNode;
import org.onosproject.yangutils.parser.exceptions.ParserException;
import org.onosproject.yangutils.parser.impl.YangUtilsParserManager;
+import java.io.IOException;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+
import static org.hamcrest.core.Is.is;
-import static org.hamcrest.core.IsNull.notNullValue;
import static org.junit.Assert.assertThat;
/**
@@ -75,7 +75,7 @@
public void processWithoutRevision() throws IOException, ParserException {
YangNode node = manager.getDataModel("src/test/resources/RevisionAbsence.yang");
- assertThat(((YangModule) node).getRevision().getRevDate(), notNullValue());
+ assertThat(true, is((node).getRevision() == null));
}
/**
@@ -85,6 +85,6 @@
public void processWithMultipleRevision() throws IOException, ParserException, ParseException {
YangNode node = manager.getDataModel("src/test/resources/MultipleRevision.yang");
- assertThat(((YangModule) node).getRevision().getRevDate(), is(simpleDateFormat.parse("2013-07-15")));
+ assertThat((node).getRevision().getRevDate(), is(simpleDateFormat.parse("2013-07-15")));
}
}
\ No newline at end of file
diff --git a/plugin/src/test/java/org/onosproject/yangutils/parser/impl/listeners/SubModuleListenerTest.java b/plugin/src/test/java/org/onosproject/yangutils/parser/impl/listeners/SubModuleListenerTest.java
index 6a53cbe..3210948 100644
--- a/plugin/src/test/java/org/onosproject/yangutils/parser/impl/listeners/SubModuleListenerTest.java
+++ b/plugin/src/test/java/org/onosproject/yangutils/parser/impl/listeners/SubModuleListenerTest.java
@@ -26,7 +26,6 @@
import java.io.IOException;
import static org.hamcrest.core.Is.is;
-import static org.hamcrest.core.IsNull.notNullValue;
import static org.junit.Assert.assertThat;
/**
@@ -109,7 +108,7 @@
// Checks for the version value in data model tree.
assertThat(yangNode.getBelongsTo().getPrefix(), is("On1"));
//Checks the revision with current date is created for empty revision statement.
- assertThat(((YangSubModule) node).getRevision().getRevDate(), notNullValue());
+ assertThat(true, is(node.getRevision() == null));
}
/**
diff --git a/plugin/src/test/java/org/onosproject/yangutils/plugin/manager/RootClassGeneratorTest.java b/plugin/src/test/java/org/onosproject/yangutils/plugin/manager/RootClassGeneratorTest.java
new file mode 100644
index 0000000..472f083
--- /dev/null
+++ b/plugin/src/test/java/org/onosproject/yangutils/plugin/manager/RootClassGeneratorTest.java
@@ -0,0 +1,125 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.yangutils.plugin.manager;
+
+import org.apache.maven.plugin.MojoExecutionException;
+import org.junit.Test;
+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.File;
+import java.io.IOException;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.core.Is.is;
+import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.deleteDirectory;
+
+/**
+ * Unit test case for root node's code generation.
+ */
+public class RootClassGeneratorTest {
+
+ private final YangUtilManager utilManager = new YangUtilManager();
+
+ @Test
+ public void rootClassGenTest() throws IOException, ParserException, MojoExecutionException {
+ String searchDir = "src/test/resources/manager/singleChild";
+ 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()));
+
+ path = System.getProperty("user.dir") + "/target/manager/" +
+ "org/onosproject/yang/gen/v1/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 {
+ String searchDir = "src/test/resources/manager/genwithoutrev";
+ 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/Test5.java";
+
+ assertThat(true, is((new File(path)).exists()));
+ deleteDirectory("target/manager/");
+ }
+
+ @Test
+ public void rootClassMethodGenTest() 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/");
+ 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()));
+
+ path = System.getProperty("user.dir") + "/target/manager/" +
+ "org/onosproject/yang/gen/v1/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";
+ assertThat(true, is((new File(path)).exists()));
+
+ deleteDirectory("target/manager/");
+ }
+}
diff --git a/plugin/src/test/java/org/onosproject/yangutils/plugin/manager/YangJavaModelUtilsTest.java b/plugin/src/test/java/org/onosproject/yangutils/plugin/manager/YangJavaModelUtilsTest.java
new file mode 100644
index 0000000..daaa074
--- /dev/null
+++ b/plugin/src/test/java/org/onosproject/yangutils/plugin/manager/YangJavaModelUtilsTest.java
@@ -0,0 +1,196 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.yangutils.plugin.manager;
+
+import org.apache.maven.plugin.MojoExecutionException;
+import org.junit.Test;
+import org.onosproject.yangutils.datamodel.YangNode;
+import org.onosproject.yangutils.parser.exceptions.ParserException;
+import org.onosproject.yangutils.plugin.manager.YangUtilManager;
+import org.onosproject.yangutils.utils.io.impl.YangFileScanner;
+
+import java.io.IOException;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.core.Is.is;
+import static org.onosproject.yangutils.translator.tojava.YangJavaModelUtils.isGetSetOfRootNodeRequired;
+import static org.onosproject.yangutils.translator.tojava.YangJavaModelUtils.isRootNodesCodeGenRequired;
+
+/**
+ * Unit test case for java model utils.
+ */
+public class YangJavaModelUtilsTest {
+
+
+ private final YangUtilManager utilManager = new YangUtilManager();
+
+ @Test
+ public void isRootNodeContainsOnlyAugmentTest() throws IOException,
+ ParserException, MojoExecutionException {
+ String searchDir = "src/test/resources/rootNode/onlyaugment";
+ utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(searchDir));
+ utilManager.parseYangFileInfoSet();
+ utilManager.createYangNodeSet();
+ utilManager.resolveDependenciesUsingLinker();
+
+ for (YangNode node : utilManager.getYangNodeSet()) {
+ if (node.getName().equals("test5")) {
+ assertThat(false, is(isGetSetOfRootNodeRequired(node)));
+ assertThat(true, is(isRootNodesCodeGenRequired(node)));
+ }
+ if (node.getName().equals("test6")) {
+ assertThat(true, is(isGetSetOfRootNodeRequired(node)));
+ assertThat(true, is(isRootNodesCodeGenRequired(node)));
+ }
+ }
+ }
+
+ @Test
+ public void isRootNodeCodeGenRequiredOnlyLeafTest() throws IOException
+ , ParserException, MojoExecutionException {
+ String searchDir = "src/test/resources/rootNode/onlyleaf";
+ utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(searchDir));
+ utilManager.parseYangFileInfoSet();
+ utilManager.createYangNodeSet();
+ utilManager.resolveDependenciesUsingLinker();
+
+ for (YangNode node : utilManager.getYangNodeSet()) {
+ if (node.getName().equals("test5")) {
+ assertThat(true, is(isGetSetOfRootNodeRequired(node)));
+ assertThat(true, is(isRootNodesCodeGenRequired(node)));
+ }
+ }
+ }
+
+ @Test
+ public void isRootNodeCodeGenRequiredOnlyLeafListTest() throws IOException
+ , ParserException, MojoExecutionException {
+ String searchDir = "src/test/resources/rootNode/onlyleaflist";
+ utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(searchDir));
+ utilManager.parseYangFileInfoSet();
+ utilManager.createYangNodeSet();
+ utilManager.resolveDependenciesUsingLinker();
+
+ for (YangNode node : utilManager.getYangNodeSet()) {
+ if (node.getName().equals("test5")) {
+ assertThat(true, is(isGetSetOfRootNodeRequired(node)));
+ assertThat(true, is(isRootNodesCodeGenRequired(node)));
+ }
+ }
+ }
+
+ @Test
+ public void isRootNodeCodeGenRequiredOnlyGroupingTest() throws IOException
+ , ParserException, MojoExecutionException {
+ String searchDir = "src/test/resources/rootNode/onlygrouping";
+ utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(searchDir));
+ utilManager.parseYangFileInfoSet();
+ utilManager.createYangNodeSet();
+ utilManager.resolveDependenciesUsingLinker();
+
+ for (YangNode node : utilManager.getYangNodeSet()) {
+ if (node.getName().equals("test5")) {
+ assertThat(true, is(isGetSetOfRootNodeRequired(node)));
+ assertThat(false, is(isRootNodesCodeGenRequired(node)));
+ }
+ if (node.getName().equals("test6")) {
+ assertThat(true, is(isGetSetOfRootNodeRequired(node)));
+ assertThat(false, is(isRootNodesCodeGenRequired(node)));
+ }
+ }
+ }
+
+
+ @Test
+ public void isRootNodeCodeGenRequiredOnlyTypeDefTest() throws IOException
+ , ParserException, MojoExecutionException {
+ String searchDir = "src/test/resources/rootNode/onlytypdef";
+ utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(searchDir));
+ utilManager.parseYangFileInfoSet();
+ utilManager.createYangNodeSet();
+ utilManager.resolveDependenciesUsingLinker();
+
+ for (YangNode node : utilManager.getYangNodeSet()) {
+ if (node.getName().equals("test5")) {
+ assertThat(false, is(isGetSetOfRootNodeRequired(node)));
+ assertThat(false, is(isRootNodesCodeGenRequired(node)));
+ }
+ if (node.getName().equals("test6")) {
+ assertThat(true, is(isGetSetOfRootNodeRequired(node)));
+ assertThat(false, is(isRootNodesCodeGenRequired(node)));
+ }
+ }
+ }
+
+ @Test
+ public void isRootNodeCodeGenRequiredNoGenTest() throws IOException
+ , ParserException, MojoExecutionException {
+ String searchDir = "src/test/resources/rootNode/nogen";
+ utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(searchDir));
+ utilManager.parseYangFileInfoSet();
+ utilManager.createYangNodeSet();
+ utilManager.resolveDependenciesUsingLinker();
+
+ for (YangNode node : utilManager.getYangNodeSet()) {
+ if (node.getName().equals("test5")) {
+ assertThat(false, is(isGetSetOfRootNodeRequired(node)));
+ assertThat(false, is(isRootNodesCodeGenRequired(node)));
+ }
+ }
+
+ }
+
+ @Test
+ public void isRootNodeCodeGenRequiredMixedTest() throws IOException
+ , ParserException, MojoExecutionException {
+ String searchDir = "src/test/resources/rootNode/mixed";
+ utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(searchDir));
+ utilManager.parseYangFileInfoSet();
+ utilManager.createYangNodeSet();
+ utilManager.resolveDependenciesUsingLinker();
+
+ for (YangNode node : utilManager.getYangNodeSet()) {
+ if (node.getName().equals("test5")) {
+ assertThat(false, is(isGetSetOfRootNodeRequired(node)));
+ assertThat(true, is(isRootNodesCodeGenRequired(node)));
+ }
+ if (node.getName().equals("test6")) {
+ assertThat(true, is(isGetSetOfRootNodeRequired(node)));
+ assertThat(true, is(isRootNodesCodeGenRequired(node)));
+ }
+ }
+
+ }
+
+ @Test
+ public void isRootNodeCodeGenRequiredTypedefGroupingTest() throws IOException
+ , ParserException, MojoExecutionException {
+ String searchDir = "src/test/resources/rootNode/typedefgrouping";
+ utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(searchDir));
+ utilManager.parseYangFileInfoSet();
+ utilManager.createYangNodeSet();
+ utilManager.resolveDependenciesUsingLinker();
+
+ for (YangNode node : utilManager.getYangNodeSet()) {
+ if (node.getName().equals("test5")) {
+ assertThat(true, is(isGetSetOfRootNodeRequired(node)));
+ assertThat(false, is(isRootNodesCodeGenRequired(node)));
+ }
+ }
+
+ }
+}
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 0e15913..ca0bfe9 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
@@ -23,9 +23,11 @@
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
+
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
+import org.onosproject.yangutils.datamodel.YangRevision;
import org.onosproject.yangutils.translator.exception.TranslatorException;
import org.onosproject.yangutils.utils.io.YangToJavaNamingConflictUtil;
@@ -128,8 +130,9 @@
* or constructor.
*/
@Test
- public void callPrivateConstructors() throws SecurityException, NoSuchMethodException, IllegalArgumentException,
- InstantiationException, IllegalAccessException, InvocationTargetException {
+ public void callPrivateConstructors()
+ throws SecurityException, NoSuchMethodException, IllegalArgumentException,
+ InstantiationException, IllegalAccessException, InvocationTargetException {
Class<?>[] classesToConstruct = {JavaIdentifierSyntax.class};
for (Class<?> clazz : classesToConstruct) {
@@ -143,48 +146,48 @@
* Unit test for root package generation with revision complexity.
*/
@Test
- public void getRootPackageTest() throws ParseException {
+ public void getRootPackageTest()
+ throws ParseException {
conflictResolver.setPrefixForIdentifier(null);
- Date date = simpleDateFormat.parse(DATE1);
- String rootPackage = getRootPackage((byte) 1, CHILD_PACKAGE, date, conflictResolver);
+ String rootPackage = getRootPackage((byte) 1, CHILD_PACKAGE, getYangRevision(DATE1), conflictResolver);
assertThat(rootPackage.equals(DEFAULT_BASE_PKG + PERIOD + VERSION_NUMBER
- + PERIOD + CHILD_WITH_PERIOD + PERIOD + DATE_WITH_REV1), is(true));
+ + PERIOD + CHILD_WITH_PERIOD + PERIOD + DATE_WITH_REV1), is(true));
}
/**
* Unit test for root package generation with invalid prefix.
*/
@Test
- public void getRootPackageWithInvalidPrefix() throws TranslatorException, ParseException {
+ public void getRootPackageWithInvalidPrefix()
+ throws TranslatorException, ParseException {
thrown.expect(TranslatorException.class);
thrown.expectMessage("The given prefix in pom.xml is invalid.");
conflictResolver.setPrefixForIdentifier(INVALID_PREFIX);
- Date date = simpleDateFormat.parse(DATE1);
- String rootPackage1 = getRootPackage((byte) 1, INVALID_NAME_SPACE_FOR_INVALID_PREFIX, date,
- conflictResolver);
+ String rootPackage1 = getRootPackage((byte) 1, INVALID_NAME_SPACE_FOR_INVALID_PREFIX, getYangRevision(DATE1),
+ conflictResolver);
}
/**
* Unit test for root package generation with special characters presence.
*/
@Test
- public void getRootPackageWithSpecialCharactersTest() throws ParseException {
+ public void getRootPackageWithSpecialCharactersTest()
+ throws ParseException {
conflictResolver.setPrefixForIdentifier(VALID_PREFIX);
- Date date = simpleDateFormat.parse(DATE1);
- String rootPackage = getRootPackage((byte) 1, INVALID_NAME_SPACE1, date, conflictResolver);
+ String rootPackage = getRootPackage((byte) 1, INVALID_NAME_SPACE1, getYangRevision(DATE1), conflictResolver);
assertThat(rootPackage.equals(DEFAULT_BASE_PKG + PERIOD + VERSION_NUMBER
- + PERIOD + VALID_NAME_SPACE1 + PERIOD + DATE_WITH_REV1), is(true));
+ + PERIOD + VALID_NAME_SPACE1 + PERIOD + DATE_WITH_REV1), is(true));
conflictResolver.setPrefixForIdentifier(null);
- String rootPackage1 = getRootPackage((byte) 1, INVALID_NAME_SPACE2, date, conflictResolver);
+ String rootPackage1 = getRootPackage((byte) 1, INVALID_NAME_SPACE2, getYangRevision(DATE1), conflictResolver);
assertThat(rootPackage1.equals(DEFAULT_BASE_PKG + PERIOD + VERSION_NUMBER
- + PERIOD + VALID_NAME_SPACE2 + PERIOD + DATE_WITH_REV1), is(true));
- String rootPackage2 = getRootPackage((byte) 1, INVALID_NAME_SPACE3, date, conflictResolver);
+ + PERIOD + VALID_NAME_SPACE2 + PERIOD + DATE_WITH_REV1), is(true));
+ String rootPackage2 = getRootPackage((byte) 1, INVALID_NAME_SPACE3, getYangRevision(DATE1), conflictResolver);
assertThat(rootPackage2.equals(DEFAULT_BASE_PKG + PERIOD + VERSION_NUMBER
- + PERIOD + VALID_NAME_SPACE4 + PERIOD + DATE_WITH_REV1), is(true));
+ + PERIOD + VALID_NAME_SPACE4 + PERIOD + DATE_WITH_REV1), is(true));
conflictResolver.setPrefixForIdentifier(INVALID_PREFIX1);
- String rootPackage3 = getRootPackage((byte) 1, INVALID_NAME_SPACE2, date, conflictResolver);
+ String rootPackage3 = getRootPackage((byte) 1, INVALID_NAME_SPACE2, getYangRevision(DATE1), conflictResolver);
assertThat(rootPackage3.equals(DEFAULT_BASE_PKG + PERIOD + VERSION_NUMBER
- + PERIOD + VALID_NAME_SPACE3 + PERIOD + DATE_WITH_REV1), is(true));
+ + PERIOD + VALID_NAME_SPACE3 + PERIOD + DATE_WITH_REV1), is(true));
}
@@ -192,12 +195,13 @@
* Unit test for root package generation without complexity in revision.
*/
@Test
- public void getRootPackageWithRevTest() throws ParseException {
+ public void getRootPackageWithRevTest()
+ throws ParseException {
Date date = simpleDateFormat.parse(DATE2);
- String rootPkgWithRev = getRootPackage((byte) 1, CHILD_PACKAGE, date, null);
+ String rootPkgWithRev = getRootPackage((byte) 1, CHILD_PACKAGE, getYangRevision(DATE2), null);
assertThat(rootPkgWithRev.equals(
DEFAULT_BASE_PKG + PERIOD + VERSION_NUMBER + PERIOD + CHILD_WITH_PERIOD + PERIOD + DATE_WITH_REV2),
- is(true));
+ is(true));
}
/**
@@ -265,7 +269,8 @@
* Unit test for getting the camel case along with the invalid prefix provided.
*/
@Test
- public void getCamelCaseWithInvalidPrefixTest() throws TranslatorException {
+ public void getCamelCaseWithInvalidPrefixTest()
+ throws TranslatorException {
thrown.expect(TranslatorException.class);
thrown.expectMessage("The given prefix in pom.xml is invalid.");
@@ -307,7 +312,8 @@
* @throws IOException when failed to create a test file
*/
@Test
- public void packageExistTest() throws IOException {
+ public void packageExistTest()
+ throws IOException {
String strPath = BASE_DIR_PKG + DIR_PATH;
File createDir = new File(strPath.replace(PERIOD, SLASH));
@@ -319,4 +325,14 @@
deleteDirectory(createDir);
deleteDirectory(new File(BASE_DIR_PKG.replace(PERIOD, SLASH)));
}
+
+ private YangRevision getYangRevision(String date) {
+ YangRevision revision = new YangRevision();
+ try {
+ revision.setRevDate(simpleDateFormat.parse(date));
+ } catch (ParseException e) {
+ e.printStackTrace();
+ }
+ return revision;
+ }
}
diff --git a/plugin/src/test/resources/manager/genwithoutrev/module.yang b/plugin/src/test/resources/manager/genwithoutrev/module.yang
new file mode 100644
index 0000000..bcc1cc7
--- /dev/null
+++ b/plugin/src/test/resources/manager/genwithoutrev/module.yang
@@ -0,0 +1,9 @@
+module test5 {
+ namespace "test5:test";
+ prefix test ;
+
+ leaf a-leaf {
+ type int32;
+ }
+
+}
diff --git a/plugin/src/test/resources/manager/nogen/module.yang b/plugin/src/test/resources/manager/nogen/module.yang
new file mode 100644
index 0000000..97d79b6
--- /dev/null
+++ b/plugin/src/test/resources/manager/nogen/module.yang
@@ -0,0 +1,9 @@
+module test5 {
+ namespace "test5:test";
+ prefix test ;
+
+ revision "2016-07-04" {
+ description "Initial revision.";
+ }
+
+}
diff --git a/plugin/src/test/resources/rootNode/mixed/module.yang b/plugin/src/test/resources/rootNode/mixed/module.yang
new file mode 100644
index 0000000..e3e5571
--- /dev/null
+++ b/plugin/src/test/resources/rootNode/mixed/module.yang
@@ -0,0 +1,21 @@
+module test5 {
+ namespace "test5:test";
+ prefix test ;
+
+ include test6;
+ revision "2016-07-04" {
+ description "Initial revision.";
+ }
+
+ augment /cont1 {
+ leaf cont1 {
+ type string;
+ }
+ }
+ augment /cont2 {
+ leaf cont2 {
+ type string;
+ }
+ }
+
+}
diff --git a/plugin/src/test/resources/rootNode/mixed/submodule.yang b/plugin/src/test/resources/rootNode/mixed/submodule.yang
new file mode 100644
index 0000000..e7c497e
--- /dev/null
+++ b/plugin/src/test/resources/rootNode/mixed/submodule.yang
@@ -0,0 +1,25 @@
+submodule test6 {
+
+ belongs-to "test5" {
+ prefix "test";
+ }
+
+ revision "2016-07-04" {
+ description "Initial revision.";
+ }
+
+ typedef typedef {
+ type int32;
+ }
+ container cont1 {
+ leaf leaf1 {
+ type int32;
+ }
+ }
+ container cont2 {
+ leaf leaf1 {
+ type int32;
+ }
+ }
+
+}
diff --git a/plugin/src/test/resources/rootNode/nogen/module.yang b/plugin/src/test/resources/rootNode/nogen/module.yang
new file mode 100644
index 0000000..97d79b6
--- /dev/null
+++ b/plugin/src/test/resources/rootNode/nogen/module.yang
@@ -0,0 +1,9 @@
+module test5 {
+ namespace "test5:test";
+ prefix test ;
+
+ revision "2016-07-04" {
+ description "Initial revision.";
+ }
+
+}
diff --git a/plugin/src/test/resources/rootNode/onlyaugment/module.yang b/plugin/src/test/resources/rootNode/onlyaugment/module.yang
new file mode 100644
index 0000000..e3e5571
--- /dev/null
+++ b/plugin/src/test/resources/rootNode/onlyaugment/module.yang
@@ -0,0 +1,21 @@
+module test5 {
+ namespace "test5:test";
+ prefix test ;
+
+ include test6;
+ revision "2016-07-04" {
+ description "Initial revision.";
+ }
+
+ augment /cont1 {
+ leaf cont1 {
+ type string;
+ }
+ }
+ augment /cont2 {
+ leaf cont2 {
+ type string;
+ }
+ }
+
+}
diff --git a/plugin/src/test/resources/rootNode/onlyaugment/submodule.yang b/plugin/src/test/resources/rootNode/onlyaugment/submodule.yang
new file mode 100644
index 0000000..9acc939
--- /dev/null
+++ b/plugin/src/test/resources/rootNode/onlyaugment/submodule.yang
@@ -0,0 +1,21 @@
+submodule test6 {
+
+ belongs-to "test5" {
+ prefix "test";
+ }
+
+ revision "2016-07-04" {
+ description "Initial revision.";
+ }
+ container cont1 {
+ leaf leaf1 {
+ type int32;
+ }
+ }
+ container cont2 {
+ leaf leaf1 {
+ type int32;
+ }
+ }
+
+}
diff --git a/plugin/src/test/resources/rootNode/onlygrouping/module.yang b/plugin/src/test/resources/rootNode/onlygrouping/module.yang
new file mode 100644
index 0000000..1c4637c
--- /dev/null
+++ b/plugin/src/test/resources/rootNode/onlygrouping/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/rootNode/onlygrouping/submodule.yang b/plugin/src/test/resources/rootNode/onlygrouping/submodule.yang
new file mode 100644
index 0000000..92d7c21
--- /dev/null
+++ b/plugin/src/test/resources/rootNode/onlygrouping/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/rootNode/onlyleaf/module.yang b/plugin/src/test/resources/rootNode/onlyleaf/module.yang
new file mode 100644
index 0000000..61864ad
--- /dev/null
+++ b/plugin/src/test/resources/rootNode/onlyleaf/module.yang
@@ -0,0 +1,15 @@
+module test5 {
+ namespace "test5:test";
+ prefix test ;
+
+ revision "2016-07-04" {
+ description "Initial revision.";
+ }
+ leaf a-leaf {
+ type int32;
+ }
+ leaf b-leaf {
+ type int32;
+ }
+
+}
diff --git a/plugin/src/test/resources/rootNode/onlyleaflist/module.yang b/plugin/src/test/resources/rootNode/onlyleaflist/module.yang
new file mode 100644
index 0000000..d8cf6b3
--- /dev/null
+++ b/plugin/src/test/resources/rootNode/onlyleaflist/module.yang
@@ -0,0 +1,15 @@
+module test5 {
+ namespace "test5:test";
+ prefix test ;
+
+ revision "2016-07-04" {
+ description "Initial revision.";
+ }
+ leaf-list a-leaf {
+ type int32;
+ }
+ leaf-list b-leaf {
+ type int32;
+ }
+
+}
diff --git a/plugin/src/test/resources/rootNode/onlytypedef/module.yang b/plugin/src/test/resources/rootNode/onlytypedef/module.yang
new file mode 100644
index 0000000..1c4637c
--- /dev/null
+++ b/plugin/src/test/resources/rootNode/onlytypedef/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/rootNode/typedefgrouping/module.yang b/plugin/src/test/resources/rootNode/typedefgrouping/module.yang
new file mode 100644
index 0000000..b54ad47
--- /dev/null
+++ b/plugin/src/test/resources/rootNode/typedefgrouping/module.yang
@@ -0,0 +1,17 @@
+module test5 {
+ namespace "test5:test";
+ prefix test ;
+
+ revision "2016-07-04" {
+ description "Initial revision.";
+ }
+ typedef typedef1 {
+ type int32;
+ }
+ grouping group1 {
+ leaf typedef-leaf {
+ type typedef1;
+ }
+ }
+
+}