[ONOS-5527,ONOS-5529] process sub tree filtering in generted code changes.
Change-Id: I2b5562ee57d887c25f4a6b55cd25006e288563c0
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 5cc774a..c4a2341 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
@@ -57,7 +57,7 @@
yangPluginConfig.setCodeGenDir(DIR);
utilManager.translateToJava(yangPluginConfig);
compileCode(COMP);
- deleteDirectory(DIR);
+ //deleteDirectory(DIR);
}
/**
@@ -85,8 +85,6 @@
/**
* Checks augment translation should not result in any exception.
- * compiler not added because it contains a notification which depends on
- * onos api.
*
* @throws MojoExecutionException
*/
@@ -107,4 +105,29 @@
deleteDirectory(DIR);
}
+ /**
+ * Checks augment translation should not result in any exception.
+ *
+ * @throws MojoExecutionException
+ */
+ @Test
+ public void processChoiceAugmentInterTranslator() throws IOException,
+ ParserException, MojoExecutionException {
+ //FIXME: for augment having node with child nodes.
+ /*
+ deleteDirectory(DIR);
+ String searchDir = "src/test/resources/choiceAugment";
+ utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(searchDir));
+ utilManager.parseYangFileInfoSet();
+ utilManager.createYangNodeSet();
+ utilManager.resolveDependenciesUsingLinker();
+
+ YangPluginConfig yangPluginConfig = new YangPluginConfig();
+ yangPluginConfig.setCodeGenDir(DIR);
+ utilManager.translateToJava(yangPluginConfig);
+ compileCode(COMP);
+ deleteDirectory(DIR);
+ */
+ }
+
}
diff --git a/plugin/maven/src/test/java/org/onosproject/yangutils/plugin/manager/IdentityTranslatorTest.java b/plugin/maven/src/test/java/org/onosproject/yangutils/plugin/manager/IdentityTranslatorTest.java
new file mode 100644
index 0000000..4e9cdcb
--- /dev/null
+++ b/plugin/maven/src/test/java/org/onosproject/yangutils/plugin/manager/IdentityTranslatorTest.java
@@ -0,0 +1,62 @@
+/*
+ * 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.onosproject.yangutils.utils.io.YangPluginConfig.compileCode;
+import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.deleteDirectory;
+
+/**
+ * Translator test case for identity.
+ */
+public class IdentityTranslatorTest {
+
+ private final YangUtilManager utilManager = new YangUtilManager();
+ private static final String DIR = "target/identity/";
+ private static final String COMP = System.getProperty("user.dir") + File
+ .separator + DIR;
+
+ /**
+ * Checks augment translation should not result in any exception.
+ *
+ * @throws MojoExecutionException
+ */
+ @Test
+ public void processChoiceAugmentInterTranslator() throws IOException,
+ ParserException, MojoExecutionException {
+ deleteDirectory(DIR);
+ String searchDir = "src/test/resources/identityTranslator";
+ utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(searchDir));
+ utilManager.parseYangFileInfoSet();
+ utilManager.createYangNodeSet();
+ utilManager.resolveDependenciesUsingLinker();
+
+ YangPluginConfig yangPluginConfig = new YangPluginConfig();
+ yangPluginConfig.setCodeGenDir(DIR);
+ utilManager.translateToJava(yangPluginConfig);
+ compileCode(COMP);
+ //deleteDirectory(DIR);
+ }
+}
diff --git a/plugin/maven/src/test/resources/augmentTranslator/test.yang b/plugin/maven/src/test/resources/augmentTranslator/test.yang
index c112cef..20393a7 100644
--- a/plugin/maven/src/test/resources/augmentTranslator/test.yang
+++ b/plugin/maven/src/test/resources/augmentTranslator/test.yang
@@ -43,7 +43,21 @@
}
}
}
-
+
+ leaf leaf-a {
+ type int32;
+ }
+
+ leaf-list leaf-list-a {
+ type int32;
+ }
+
+ list list-a {
+ key "name";
+ leaf name {
+ type string;
+ }
+ }
augment /cont3 {
leaf leaf1 {
diff --git a/plugin/maven/src/test/resources/choiceAugment/all.yang b/plugin/maven/src/test/resources/choiceAugment/all.yang
new file mode 100644
index 0000000..4c08537
--- /dev/null
+++ b/plugin/maven/src/test/resources/choiceAugment/all.yang
@@ -0,0 +1,128 @@
+module ietf-inet {
+
+ namespace "yang:all";
+ prefix "inet";
+ yang-version 1;
+
+ choice name {
+ case a {
+ leaf udp {
+ type empty;
+ }
+ }
+ case b {
+ leaf tcp {
+ type empty;
+ }
+ }
+ }
+
+
+ container c {
+ choice name {
+ case a {
+ leaf udp {
+ type empty;
+ }
+ }
+ case b {
+ leaf tcp {
+ type empty;
+ }
+ }
+ }
+ }
+
+ list l {
+ config false;
+choice name {
+ case a {
+ leaf udp {
+ type empty;
+ }
+ }
+ case b {
+ leaf tcp {
+ type empty;
+ }
+ }
+ }
+ }
+
+
+ grouping g {
+ choice name {
+ case a {
+ leaf udp {
+ type empty;
+ }
+ }
+ case b {
+ leaf tcp {
+ type empty;
+ }
+ }
+ }
+ }
+
+ notification n {
+ choice name {
+ case a {
+ leaf udp {
+ type empty;
+ }
+ }
+ case b {
+ leaf tcp {
+ type empty;
+ }
+ }
+ }
+ }
+ rpc r {
+ input {
+ choice name {
+ case a {
+ leaf udp {
+ type empty;
+ }
+ }
+ case b {
+ leaf tcp {
+ type empty;
+ }
+ }
+ }
+ }
+ output {
+ choice name {
+ case a {
+ leaf udp {
+ type empty;
+ }
+ }
+ case b {
+ leaf tcp {
+ type empty;
+ }
+ }
+ }
+ }
+ }
+
+ augment /name {
+ choice name {
+ case a {
+ leaf udp {
+ type empty;
+ }
+ }
+ case b {
+ leaf tcp {
+ type empty;
+ }
+ }
+ }
+ }
+
+}
\ No newline at end of file
diff --git a/plugin/maven/src/test/resources/choiceAugment/test.yang b/plugin/maven/src/test/resources/choiceAugment/test.yang
new file mode 100644
index 0000000..ceee3d7
--- /dev/null
+++ b/plugin/maven/src/test/resources/choiceAugment/test.yang
@@ -0,0 +1,78 @@
+module test {
+ namespace "test:test";
+ prefix test ;
+
+ import test1{
+ prefix test1;
+ }
+ organization "";
+ contact "";
+
+ description
+ "Defines basic service types for L3VPN service.";
+
+ revision "2015-12-16" {
+ reference "";
+ }
+
+ augment /test1:rpc-input-output/test1:output/ {
+ choice choice1 {
+ container case1 {
+ leaf int-leaf {
+ type int32;
+ }
+ }
+ }
+ }
+
+ list node {
+ key "node-id";
+ leaf node-id{
+ type string;
+ }
+ leaf-list node-prop{
+ type string;
+ }
+ container termination-points{
+ leaf number-of-tp {
+ type int16;
+ }
+ list termination-point {
+ key "tp-id";
+ leaf tp-id {
+ type string;
+ }
+ }
+ }
+ choice choice1{
+ case case1a{
+ leaf leaf1a1{
+ type string;
+ }
+ leaf leaf1a2{
+ type string;
+ }
+ }
+ case case1b{
+ choice choice1b{
+ case case1bi{
+ leaf leaf1bia{
+ type string;
+ }
+ leaf leaf1bib{
+ type string;
+ }
+ }
+ case case1bii{
+ leaf leaf1biia{
+ type string;
+ }
+ leaf leaf1biib{
+ type string;
+ }
+ }
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/plugin/maven/src/test/resources/choiceAugment/test2.yang b/plugin/maven/src/test/resources/choiceAugment/test2.yang
new file mode 100644
index 0000000..4caa38b
--- /dev/null
+++ b/plugin/maven/src/test/resources/choiceAugment/test2.yang
@@ -0,0 +1,26 @@
+module test1 {
+ namespace "test1:test1";
+ prefix test1 ;
+
+ organization "";
+ contact "";
+
+ description
+ "Defines basic service types for L3VPN service.";
+ revision "2015-12-16" {
+ reference "";
+ }
+
+ rpc rpc-input-output {
+ input {
+ leaf leaf1 {
+ type int32;
+ }
+ }
+ output {
+ leaf leaf1 {
+ type int32;
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/plugin/maven/src/test/resources/identityTranslator/test.yang b/plugin/maven/src/test/resources/identityTranslator/test.yang
new file mode 100644
index 0000000..b8a3193
--- /dev/null
+++ b/plugin/maven/src/test/resources/identityTranslator/test.yang
@@ -0,0 +1,14 @@
+module IdentityInModule{
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix IdentityInModule;
+
+ identity ref-address-family {
+ reference "http://www.iana.org/assignments/address-family-numbers/address-family-numbers.xhtml#address-family-numbers-2";
+ }
+ leaf tunnel {
+ type identityref {
+ base ref-address-family;
+ }
+ }
+}
\ No newline at end of file