[ONOS-5076] YANG data tree Builder
Change-Id: I25160b651c26e614d29d7fad85e63f77a262d77c
diff --git a/apps/yms/app/src/main/java/org/onosproject/yms/app/utils/TraversalType.java b/apps/yms/app/src/main/java/org/onosproject/yms/app/utils/TraversalType.java
new file mode 100644
index 0000000..d5b58f9
--- /dev/null
+++ b/apps/yms/app/src/main/java/org/onosproject/yms/app/utils/TraversalType.java
@@ -0,0 +1,44 @@
+/*
+ * 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.yms.app.utils;
+
+/**
+ * Represents traversal type of the YANG node tree.
+ */
+public enum TraversalType {
+
+ /*
+ * Start of traversal at the tree root.
+ */
+ ROOT,
+
+ /*
+ * Child node traversal.
+ */
+ CHILD,
+
+ /*
+ * Sibling node traversal.
+ */
+ SIBLING,
+
+ /*
+ * Parent node traversal.
+ */
+ PARENT
+}
+
diff --git a/apps/yms/app/src/main/java/org/onosproject/yms/app/utils/package-info.java b/apps/yms/app/src/main/java/org/onosproject/yms/app/utils/package-info.java
new file mode 100644
index 0000000..5957cf3
--- /dev/null
+++ b/apps/yms/app/src/main/java/org/onosproject/yms/app/utils/package-info.java
@@ -0,0 +1,21 @@
+/*
+ * 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.
+ */
+
+/**
+ * Provides implementation of build and obtain YANG data tree which is data
+ * (sub)instance representation, abstract of protocol.
+ */
+package org.onosproject.yms.app.utils;
diff --git a/apps/yms/app/src/main/java/org/onosproject/yms/app/ydt/AppData.java b/apps/yms/app/src/main/java/org/onosproject/yms/app/ydt/AppData.java
new file mode 100644
index 0000000..8fee570
--- /dev/null
+++ b/apps/yms/app/src/main/java/org/onosproject/yms/app/ydt/AppData.java
@@ -0,0 +1,85 @@
+/*
+ * 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.yms.app.ydt;
+
+import org.onosproject.yangutils.datamodel.YangSchemaNode;
+import org.onosproject.yms.ydt.YdtContext;
+
+import java.util.List;
+
+/**
+ * Maintains application data, which will be used by Application broker to
+ * interact with applications.
+ */
+public interface AppData {
+
+ /**
+ * Returns the list of nodes with operation type delete.
+ *
+ * @return list of nodes with operation type delete
+ */
+ List<YdtContext> getDeleteNodes();
+
+ /**
+ * Adds the ydt node with operation type delete in module delete node list.
+ *
+ * @param node ydt node with operation type delete/remove
+ */
+ void addDeleteNodes(YdtContext node);
+
+ /**
+ * Returns application's root ydtContext.
+ *
+ * @return YdtContext of application root node
+ */
+ YdtContext getModuleContext();
+
+ /**
+ * Sets the application's ydtContext.
+ *
+ * @param moduleNode application's ydtContext
+ */
+ void setModuleContext(YdtContext moduleNode);
+
+ /**
+ * Returns the YangSchemaNode of augmenting application.
+ *
+ * @return YangSchemaNode of augmenting application
+ */
+ YangSchemaNode getAugmentingSchemaNode();
+
+ /**
+ * Sets the YangSchemaNode of augmenting application root node.
+ *
+ * @param schemaNode YangSchemaNode of augmenting application module
+ */
+ void setAugmentingSchemaNode(YangSchemaNode schemaNode);
+
+ /**
+ * Returns the schema node current context.
+ *
+ * @return schema node
+ */
+ YangSchemaNode getSchemaNode();
+
+ /**
+ * Returns the root/module schema node current application.
+ *
+ * @return schema node
+ */
+ YangSchemaNode getRootSchemaNode();
+}
diff --git a/apps/yms/app/src/main/java/org/onosproject/yms/app/ydt/AppNodeFactory.java b/apps/yms/app/src/main/java/org/onosproject/yms/app/ydt/AppNodeFactory.java
new file mode 100644
index 0000000..621eda6
--- /dev/null
+++ b/apps/yms/app/src/main/java/org/onosproject/yms/app/ydt/AppNodeFactory.java
@@ -0,0 +1,42 @@
+/*
+ * 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.yms.app.ydt;
+
+import static org.onosproject.yms.app.ydt.DefaultYdtAppContext.getAugmentAppContext;
+import static org.onosproject.yms.app.ydt.DefaultYdtAppContext.getModuleAppContext;
+
+/**
+ * Represents an application tree node factory to create different types of
+ * application tree node.
+ */
+public final class AppNodeFactory {
+
+ // No instantiation
+ private AppNodeFactory() {
+ }
+
+ /**
+ * Returns the appropriate application context on the basis of provided
+ * isAugmented flag for given request.
+ *
+ * @param isAugmented true for augmented context; false for module context
+ * @return appContext application context
+ */
+ public static DefaultYdtAppContext getAppContext(boolean isAugmented) {
+ return isAugmented ? getAugmentAppContext() : getModuleAppContext();
+ }
+}
diff --git a/apps/yms/app/src/main/java/org/onosproject/yms/app/ydt/AppType.java b/apps/yms/app/src/main/java/org/onosproject/yms/app/ydt/AppType.java
new file mode 100644
index 0000000..4d581a3
--- /dev/null
+++ b/apps/yms/app/src/main/java/org/onosproject/yms/app/ydt/AppType.java
@@ -0,0 +1,34 @@
+/*
+ * 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.yms.app.ydt;
+
+/**
+ * Represents type of application, which is intended to maintain additional
+ * information in YDT node.
+ */
+public enum AppType {
+
+ /**
+ * YANG tree builder application.
+ */
+ YTB,
+
+ /**
+ * YANG object builder application.
+ */
+ YOB
+}
diff --git a/apps/yms/app/src/main/java/org/onosproject/yms/app/ydt/AugmentedSchemaData.java b/apps/yms/app/src/main/java/org/onosproject/yms/app/ydt/AugmentedSchemaData.java
new file mode 100644
index 0000000..6a45cad
--- /dev/null
+++ b/apps/yms/app/src/main/java/org/onosproject/yms/app/ydt/AugmentedSchemaData.java
@@ -0,0 +1,82 @@
+/*
+ * 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.yms.app.ydt;
+
+import org.onosproject.yangutils.datamodel.YangNode;
+import org.onosproject.yangutils.datamodel.YangSchemaNode;
+import org.onosproject.yms.app.ydt.exceptions.YdtException;
+import org.onosproject.yms.ydt.YdtContext;
+
+import java.util.List;
+
+/**
+ * Manages the application information required for schema nodes defined in
+ * the module (sub-module).
+ */
+public class AugmentedSchemaData implements AppData {
+
+ private static final String E_NOT_ROOTAPP =
+ "Augmented application depends on root app.";
+ private static final String E_NOT_EXIST =
+ "Augmented nodes are not part of the schema.";
+ private static final String E_NOT_MAINTAINED =
+ "Module context is not maintained.";
+
+ /*
+ * Reference for schema node of augmenting application.
+ */
+ private YangSchemaNode augModSchema;
+
+ @Override
+ public List<YdtContext> getDeleteNodes() {
+ throw new YdtException(E_NOT_ROOTAPP);
+ }
+
+ @Override
+ public void addDeleteNodes(YdtContext deletedNode) {
+ }
+
+ @Override
+ public YdtContext getModuleContext() {
+ throw new YdtException(E_NOT_EXIST);
+ }
+
+ @Override
+ public void setModuleContext(YdtContext moduleContext) {
+ throw new YdtException(E_NOT_MAINTAINED);
+ }
+
+ @Override
+ public YangSchemaNode getAugmentingSchemaNode() {
+ return augModSchema;
+ }
+
+ @Override
+ public void setAugmentingSchemaNode(YangSchemaNode schemaNode) {
+ augModSchema = schemaNode;
+ }
+
+ @Override
+ public YangSchemaNode getSchemaNode() {
+ return augModSchema;
+ }
+
+ @Override
+ public YangSchemaNode getRootSchemaNode() {
+ return ((YangNode) getSchemaNode()).getParent();
+ }
+}
diff --git a/apps/yms/app/src/main/java/org/onosproject/yms/app/ydt/DefaultYdtAppContext.java b/apps/yms/app/src/main/java/org/onosproject/yms/app/ydt/DefaultYdtAppContext.java
new file mode 100644
index 0000000..f75fc9c
--- /dev/null
+++ b/apps/yms/app/src/main/java/org/onosproject/yms/app/ydt/DefaultYdtAppContext.java
@@ -0,0 +1,302 @@
+/*
+ * 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.yms.app.ydt;
+
+import org.onosproject.yangutils.datamodel.YangAugment;
+import org.onosproject.yangutils.datamodel.YangSchemaNode;
+import org.onosproject.yangutils.datamodel.YangSchemaNodeContextInfo;
+import org.onosproject.yangutils.datamodel.YangSchemaNodeIdentifier;
+import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
+import org.onosproject.yms.app.ydt.exceptions.YdtException;
+import org.onosproject.yms.ydt.YdtContext;
+import org.onosproject.yms.ydt.YdtContextOperationType;
+
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import static org.onosproject.yms.app.ydt.YdtAppNodeOperationType.BOTH;
+import static org.onosproject.yms.app.ydt.YdtNodeFactory.getAppOpTypeFromYdtOpType;
+
+/**
+ * Represents YANG request work bench which contains all parameters for
+ * request handling and methods to build and obtain YANG application data tree
+ * which is data (sub)instance representation, abstract of protocol.
+ */
+public final class DefaultYdtAppContext<T extends AppData>
+ implements YdtAppContext {
+
+ /*
+ * Parent reference.
+ */
+ private YdtAppContext parent;
+
+ /*
+ * First child reference.
+ */
+ private YdtAppContext child;
+
+ /*
+ * Next sibling reference.
+ */
+ private YdtAppContext nextSibling;
+
+ /*
+ * Previous sibling reference.
+ */
+ private YdtAppContext previousSibling;
+
+ /*
+ * Last child reference.
+ */
+ private YdtAppContext lastChild;
+
+ /*
+ * YDT application tree extended information.
+ */
+ private T appData;
+
+ /*
+ * Reference for operation type for application root node.
+ */
+ private YdtAppNodeOperationType operationType;
+
+ /*
+ * Reference application node set.
+ */
+ private Set<YangSchemaNode> appSet;
+
+ /**
+ * Creates an instance of YANG application tree which is used by all node
+ * needs delete list.
+ */
+ private DefaultYdtAppContext() {
+ appSet = new HashSet<>();
+ }
+
+ /**
+ * Adds schema node of new requested augmented node in current context of
+ * application tree.
+ *
+ * @param schemaNode schema node of requested node
+ * @return addition result(true/false)
+ */
+ public boolean addSchemaToAppSet(YangSchemaNode schemaNode) {
+ return appSet.add(schemaNode);
+ }
+
+ @Override
+ public void updateAppOperationType(YdtContextOperationType ydtOpType) {
+ if (parent == null) {
+ return;
+ }
+ YdtAppNodeOperationType opType = getAppOpTypeFromYdtOpType(ydtOpType);
+ YdtAppContext curNode = this;
+ YdtAppNodeOperationType parentOpType = operationType;
+ if (parentOpType != null && opType != parentOpType) {
+ while (curNode.getOperationType() != BOTH &&
+ curNode.getParent() != null) {
+ curNode.setOperationType(BOTH);
+ curNode = curNode.getParent();
+ }
+ }
+ }
+
+ @Override
+ public void setAppData(YdtNode moduleNode, YangSchemaNode augmentNode) {
+ if (augmentNode != null) {
+ appData.setAugmentingSchemaNode(augmentNode);
+ } else {
+ appData.setModuleContext(moduleNode);
+ }
+ }
+
+ @Override
+ public AppData getAppData() {
+ return appData;
+ }
+
+ @Override
+ public YdtAppContext getParent() {
+ return parent;
+ }
+
+ @Override
+ public void setParent(YdtAppContext parent) {
+ this.parent = parent;
+ }
+
+ @Override
+ public YdtAppContext getFirstChild() {
+ return child;
+ }
+
+ @Override
+ public void setChild(YdtAppContext child) {
+ this.child = child;
+ }
+
+ @Override
+ public YdtAppContext getNextSibling() {
+ return nextSibling;
+ }
+
+ @Override
+ public void setNextSibling(YdtAppContext nextSibling) {
+ this.nextSibling = nextSibling;
+ }
+
+ @Override
+ public YdtAppContext getPreviousSibling() {
+ return previousSibling;
+ }
+
+ @Override
+ public void setPreviousSibling(YdtAppContext previousSibling) {
+ this.previousSibling = previousSibling;
+ }
+
+ @Override
+ public YdtAppNodeOperationType getOperationType() {
+ return operationType;
+ }
+
+ @Override
+ public void setOperationType(YdtAppNodeOperationType opType) {
+ operationType = opType;
+ }
+
+ @Override
+ public List<YdtContext> getDeleteNodes() {
+ return appData.getDeleteNodes();
+ }
+
+
+ @Override
+ public void addDeleteNode(YdtNode node) {
+ DefaultYdtAppContext<?> curNode = this;
+ while (curNode.getParent().getParent() != null) {
+ curNode = (DefaultYdtAppContext<?>) curNode.getParent();
+ }
+
+ curNode.appData.addDeleteNodes(node);
+ }
+
+ @Override
+ public YdtContext getModuleContext() {
+ return appData.getModuleContext();
+ }
+
+ @Override
+ public void setModuleContext(YdtContext moduleNode) {
+ appData.setModuleContext(moduleNode);
+ }
+
+ @Override
+ public YangSchemaNode getAugmentingSchemaNode() {
+ return appData.getAugmentingSchemaNode();
+ }
+
+ @Override
+ public void setAugmentingSchemaNode(YangSchemaNode schemaNode) {
+ appData.setAugmentingSchemaNode(schemaNode);
+ }
+
+
+ @Override
+ public YangSchemaNode getAugmentingSchemaNode(
+ YangSchemaNodeIdentifier id,
+ YangSchemaNodeContextInfo contextInfo) {
+ YangSchemaNode lastAugMod = null;
+ YangSchemaNode switchedNode =
+ contextInfo.getContextSwitchedNode();
+
+ while (switchedNode != null) {
+ if (switchedNode instanceof YangAugment) {
+ lastAugMod = switchedNode;
+ }
+ try {
+ switchedNode = switchedNode.getChildSchema(id)
+ .getContextSwitchedNode();
+ } catch (DataModelException e) {
+ throw new YdtException(e.getMessage());
+ }
+ }
+ return lastAugMod;
+ }
+
+ @Override
+ public YdtAppContext getLastChild() {
+ return lastChild;
+ }
+
+ @Override
+ public void setLastChild(YdtAppContext lastChild) {
+ this.lastChild = lastChild;
+ }
+
+ @Override
+ public void addChild(YdtAppContext newChild) {
+
+ if (newChild.getParent() == null) {
+ newChild.setParent(this);
+ }
+
+ // First child to be added.
+ if (getFirstChild() == null) {
+ setChild(newChild);
+ // Update last child.
+ setLastChild(newChild);
+ return;
+ }
+
+ // If the new node needs to be add as last child.
+ YdtAppContext curNode = getLastChild();
+ curNode.setNextSibling(newChild);
+ newChild.setPreviousSibling(curNode);
+ setLastChild(newChild);
+ }
+
+ @Override
+ public YangSchemaNode getYangSchemaNode() {
+ return appData.getSchemaNode();
+ }
+
+ /**
+ * Creates an instance of application tree context with module schema data.
+ *
+ * @return application tree context
+ */
+ public static DefaultYdtAppContext getModuleAppContext() {
+ DefaultYdtAppContext context =
+ new DefaultYdtAppContext<ModuleSchemaData>();
+ context.appData = new ModuleSchemaData();
+ return context;
+ }
+
+ /**
+ * Creates an instance of application tree context with augment schema data.
+ *
+ * @return application tree context
+ */
+ public static DefaultYdtAppContext getAugmentAppContext() {
+ DefaultYdtAppContext context =
+ new DefaultYdtAppContext<AugmentedSchemaData>();
+ context.appData = new AugmentedSchemaData();
+ return context;
+ }
+}
diff --git a/apps/yms/app/src/main/java/org/onosproject/yms/app/ydt/DefaultYdtWalker.java b/apps/yms/app/src/main/java/org/onosproject/yms/app/ydt/DefaultYdtWalker.java
new file mode 100644
index 0000000..bb692cf
--- /dev/null
+++ b/apps/yms/app/src/main/java/org/onosproject/yms/app/ydt/DefaultYdtWalker.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.yms.app.ydt;
+
+
+import org.onosproject.yms.app.utils.TraversalType;
+import org.onosproject.yms.ydt.YdtContext;
+import org.onosproject.yms.ydt.YdtListener;
+
+import static org.onosproject.yms.app.utils.TraversalType.CHILD;
+import static org.onosproject.yms.app.utils.TraversalType.PARENT;
+import static org.onosproject.yms.app.utils.TraversalType.ROOT;
+import static org.onosproject.yms.app.utils.TraversalType.SIBLING;
+
+/**
+ * Represents implementation of YDT walker, which walks the YDT.
+ */
+public class DefaultYdtWalker implements YdtExtendedWalker {
+
+ @Override
+ public void walk(YdtListener ydtListener, YdtContext rootNode) {
+ walkTree(ydtListener, rootNode, false);
+ }
+
+ /**
+ * Walks the YANG data tree till the node provided by the user.
+ * Protocols implements YDT listener and YDT Extended Listener and
+ * walks YDT tree with input as implemented object.
+ * YDT walker provides call backs to implemented methods.
+ *
+ * @param ydtListener YDT listener implemented by the protocol
+ * @param rootNode root node of YDT
+ * @param isExtended flag denotes the call type
+ */
+ private void walkTree(YdtListener ydtListener, YdtContext rootNode,
+ boolean isExtended) {
+ YdtContext curNode = rootNode;
+ TraversalType curTraversal = ROOT;
+
+ while (curNode != null) {
+ if (curTraversal != PARENT) {
+
+ // Visit (curNode) for entry callback
+ if (isExtended) {
+ ((YdtExtendedListener) ydtListener)
+ .enterYdtNode((YdtExtendedContext) curNode);
+ } else {
+ ydtListener.enterYdtNode(curNode);
+ }
+ }
+ if (curTraversal != PARENT &&
+ curNode.getFirstChild() != null) {
+ curTraversal = CHILD;
+ curNode = curNode.getFirstChild();
+ } else if (curNode.getNextSibling() != null) {
+ // Revisit (curNode) for exit callback
+ exitCallBack(ydtListener, curNode, isExtended);
+
+ /*
+ *Stop traversing the tree , tree need to be traversed
+ * till user requested node
+ */
+ if (curNode.equals(rootNode)) {
+ return;
+ }
+ curTraversal = SIBLING;
+ curNode = curNode.getNextSibling();
+ } else {
+ // Revisit (curNode) for exit callback
+ exitCallBack(ydtListener, curNode, isExtended);
+
+ /*
+ *Stop traversing the tree , tree need to be traversed
+ * till user requested node
+ */
+ if (curNode.equals(rootNode)) {
+ return;
+ }
+
+ curTraversal = PARENT;
+ curNode = curNode.getParent();
+ }
+ }
+ }
+
+ /**
+ * Provides exit call back per node on the basis of extended flag,
+ * If isExtended set then YdtExtendedListener exit node call back will
+ * be provided else YdtListener with respective type of context
+ * (YdtContext/YdtExtendedContext).
+ *
+ * @param ydtListener YDT listener implemented by the protocol
+ * @param curNode current node of YDT
+ * @param isExtended flag denotes the call type
+ */
+ private void exitCallBack(YdtListener ydtListener, YdtContext curNode,
+ boolean isExtended) {
+ if (isExtended) {
+ ((YdtExtendedListener) ydtListener)
+ .exitYdtNode((YdtExtendedContext) curNode);
+ } else {
+ ydtListener.exitYdtNode(curNode);
+ }
+ }
+
+ @Override
+ public void walk(YdtExtendedListener ydtExtendedListener,
+ YdtExtendedContext rootNode) {
+ walkTree(ydtExtendedListener, rootNode, true);
+ }
+}
diff --git a/apps/yms/app/src/main/java/org/onosproject/yms/app/ydt/ModuleSchemaData.java b/apps/yms/app/src/main/java/org/onosproject/yms/app/ydt/ModuleSchemaData.java
new file mode 100644
index 0000000..fd4f1b6
--- /dev/null
+++ b/apps/yms/app/src/main/java/org/onosproject/yms/app/ydt/ModuleSchemaData.java
@@ -0,0 +1,85 @@
+/*
+ * 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.yms.app.ydt;
+
+import org.onosproject.yangutils.datamodel.YangSchemaNode;
+import org.onosproject.yms.app.ydt.exceptions.YdtException;
+import org.onosproject.yms.ydt.YdtContext;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Manages the application information required for schema nodes defined in
+ * the module (sub-module).
+ */
+public class ModuleSchemaData implements AppData {
+
+ private static final String E_NOT_MAINTAINED =
+ "Augmented info is not maintained.";
+
+ /*
+ * Reference for application's root ydtContext.
+ */
+ private YdtContext moduleContext;
+
+ /*
+ * Reference for list of nodes with operation type delete.
+ */
+ private List<YdtContext> deleteNodes = new ArrayList<>();
+
+ @Override
+ public List<YdtContext> getDeleteNodes() {
+ // This suppose to be mutable for YAB
+ return deleteNodes;
+ }
+
+ @Override
+ public void addDeleteNodes(YdtContext deletedNode) {
+ deleteNodes.add(deletedNode);
+ }
+
+ @Override
+ public YdtContext getModuleContext() {
+ return moduleContext;
+ }
+
+ @Override
+ public void setModuleContext(YdtContext moduleContext) {
+ this.moduleContext = moduleContext;
+ }
+
+ @Override
+ public YangSchemaNode getAugmentingSchemaNode() {
+ throw new YdtException(E_NOT_MAINTAINED);
+ }
+
+ @Override
+ public void setAugmentingSchemaNode(YangSchemaNode schemaNode) {
+ throw new YdtException(E_NOT_MAINTAINED);
+ }
+
+ @Override
+ public YangSchemaNode getSchemaNode() {
+ return ((YdtExtendedContext) moduleContext).getYangSchemaNode();
+ }
+
+ @Override
+ public YangSchemaNode getRootSchemaNode() {
+ return getSchemaNode();
+ }
+}
diff --git a/apps/yms/app/src/main/java/org/onosproject/yms/app/ydt/RequestedCallType.java b/apps/yms/app/src/main/java/org/onosproject/yms/app/ydt/RequestedCallType.java
new file mode 100644
index 0000000..ace971b
--- /dev/null
+++ b/apps/yms/app/src/main/java/org/onosproject/yms/app/ydt/RequestedCallType.java
@@ -0,0 +1,39 @@
+/*
+ * 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.yms.app.ydt;
+
+/**
+ * Represents type of YANG data tree creation method caller type.
+ */
+enum RequestedCallType {
+
+ /**
+ * Requested Node is of type single/multi instance leaf.
+ */
+ LEAF,
+
+ /**
+ * Requested Node is of type single/multi instance node.
+ */
+ OTHER,
+
+ /**
+ * Requested Node is of type multi instance leaf/node.
+ */
+ MULTI_INSTANCE,
+}
+
diff --git a/apps/yms/app/src/main/java/org/onosproject/yms/app/ydt/RequestedCardinality.java b/apps/yms/app/src/main/java/org/onosproject/yms/app/ydt/RequestedCardinality.java
new file mode 100644
index 0000000..ed16951
--- /dev/null
+++ b/apps/yms/app/src/main/java/org/onosproject/yms/app/ydt/RequestedCardinality.java
@@ -0,0 +1,49 @@
+/*
+ * 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.yms.app.ydt;
+
+/**
+ * Represents type of YANG data tree node operation.
+ */
+enum RequestedCardinality {
+
+ /**
+ * Single instance of requested node.
+ */
+ SINGLE_INSTANCE,
+
+ /**
+ * Multi instance of requested node.
+ */
+ MULTI_INSTANCE,
+
+ /**
+ * Instance of requested node/leaf is unknown.
+ */
+ UNKNOWN,
+
+ /**
+ * Single instance of requested leaf.
+ */
+ SINGLE_INSTANCE_LEAF,
+
+ /**
+ * Multi instance of requested leaf.
+ */
+ MULTI_INSTANCE_LEAF
+}
+
diff --git a/apps/yms/app/src/main/java/org/onosproject/yms/app/ydt/YangRequestWorkBench.java b/apps/yms/app/src/main/java/org/onosproject/yms/app/ydt/YangRequestWorkBench.java
new file mode 100644
index 0000000..5ae1230
--- /dev/null
+++ b/apps/yms/app/src/main/java/org/onosproject/yms/app/ydt/YangRequestWorkBench.java
@@ -0,0 +1,758 @@
+/*
+ * 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.yms.app.ydt;
+
+import com.google.common.collect.ImmutableMap;
+import org.onosproject.yangutils.datamodel.YangList;
+import org.onosproject.yangutils.datamodel.YangSchemaNode;
+import org.onosproject.yangutils.datamodel.YangSchemaNodeContextInfo;
+import org.onosproject.yangutils.datamodel.YangSchemaNodeIdentifier;
+import org.onosproject.yms.app.ysr.YangSchemaRegistry;
+import org.onosproject.yms.ydt.YdtContext;
+import org.onosproject.yms.ydt.YdtContextOperationType;
+import org.onosproject.yms.ydt.YdtType;
+import org.onosproject.yms.ydt.YmsOperationType;
+
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import static org.onosproject.yangutils.datamodel.YangSchemaNodeType.YANG_MULTI_INSTANCE_LEAF_NODE;
+import static org.onosproject.yms.app.ydt.AppNodeFactory.getAppContext;
+import static org.onosproject.yms.app.ydt.RequestedCallType.LEAF;
+import static org.onosproject.yms.app.ydt.RequestedCallType.OTHER;
+import static org.onosproject.yms.app.ydt.RequestedCardinality.MULTI_INSTANCE;
+import static org.onosproject.yms.app.ydt.RequestedCardinality.MULTI_INSTANCE_LEAF;
+import static org.onosproject.yms.app.ydt.RequestedCardinality.SINGLE_INSTANCE;
+import static org.onosproject.yms.app.ydt.RequestedCardinality.UNKNOWN;
+import static org.onosproject.yms.app.ydt.YdtConstants.errorMsg;
+import static org.onosproject.yms.app.ydt.YdtNodeFactory.getAppOpTypeFromYdtOpType;
+import static org.onosproject.yms.ydt.YdtContextOperationType.CREATE;
+import static org.onosproject.yms.ydt.YdtContextOperationType.DELETE;
+import static org.onosproject.yms.ydt.YdtContextOperationType.MERGE;
+import static org.onosproject.yms.ydt.YdtContextOperationType.REMOVE;
+import static org.onosproject.yms.ydt.YdtType.MULTI_INSTANCE_LEAF_VALUE_NODE;
+import static org.onosproject.yms.ydt.YdtType.MULTI_INSTANCE_NODE;
+
+/**
+ * Represents YANG request work bench which contains all parameters for
+ * request handling and methods to build and obtain YANG data tree
+ * which is data (sub)instance representation, abstract of protocol.
+ */
+public class YangRequestWorkBench implements YdtExtendedBuilder {
+
+ // ydt formatted error string
+ private static final String FMT_NOT_EXIST =
+ "Application with name \"%s\" doesn't exist.";
+ private static final String E_USE_ADDLEAF =
+ "Requested Node should be created using addLeaf interface";
+ private static final String E_MULTI_INS =
+ "Adds an instance of type list or leaf-list node only";
+ private static final String E_CREATE =
+ "Create request is not allowed under delete operation";
+ private static final String E_DEL =
+ "Delete request is not allowed under create operation";
+ private static final String E_INVOKE_PARENT =
+ "Can't invoke get parent at logical root node";
+ private static final String FMT_TOO_FEW =
+ "Too few key parameters in %s. Expected %d; actual %d.";
+ private static final String FMT_TOO_MANY =
+ "Too many key parameters in %s. Expected %d; actual %d.";
+
+ /*
+ * Current node in YANG data tree, kept to maintain the
+ * current context in YDT.
+ */
+ private YdtNode curNode;
+
+ /*
+ * Root node in YANG data tree, kept to maintain the root context in
+ * YDT.
+ */
+ private YdtNode rootNode;
+
+ /*
+ * Current node in YANG data tree, kept to maintain the current context
+ * in ydt application tree.
+ */
+ private YdtAppContext appCurNode;
+
+ /*
+ * Root node in YANG data tree, kept to maintain the root context in ydt
+ * application tree.
+ */
+ private YdtAppContext appRootNode;
+
+ /**
+ * Root Node Tag attribute in YANG data tree, kept to maintain the root
+ * tag attributes in YDT.
+ * <p>
+ * First key param of map represent tagName name of tag attribute.
+ * Second param of map represent tagValue value of tag attribute
+ */
+ private Map<String, String> rootTagAttributeMap;
+
+ /*
+ * YANG schema registry reference.
+ */
+ private YangSchemaRegistry registry = null;
+
+ /*
+ * YMS operation type.
+ */
+ private final YmsOperationType ymsOperationType;
+
+ /*
+ * YDT default operation type.
+ */
+ private YdtContextOperationType ydtDefaultOpType;
+
+ /*
+ * Flag to identify data validation need to be done by YDT or not.
+ */
+ private final boolean validate;
+ // TODO validate need to be handle later with interaction type basis in
+ // future when it will be supported
+
+
+ /**
+ * Creates an instance of YANG request work bench which is use to initialize
+ * logical rootNode and and schema registry.
+ *
+ * @param name name of logical container of a protocol
+ * which is a holder of the complete tree
+ * @param namespace namespace of logical container
+ * @param opType type of operation done by using YANG
+ * interface
+ * @param registry Yang schema registry
+ * @param isValidate Flag to identify data validation need to be
+ * done by YDT or not
+ */
+ public YangRequestWorkBench(String name, String namespace,
+ YmsOperationType opType,
+ YangSchemaRegistry registry,
+ boolean isValidate) {
+ YdtNode newNode;
+ YangSchemaNodeIdentifier nodeIdentifier =
+ new YangSchemaNodeIdentifier();
+ nodeIdentifier.setName(name);
+ nodeIdentifier.setNameSpace(namespace);
+ newNode = new YdtSingleInstanceNode(nodeIdentifier);
+ setRootNode(newNode);
+ this.registry = registry;
+ ymsOperationType = opType;
+ validate = isValidate;
+ // Set the logical root node for yang data app tree.
+ DefaultYdtAppContext appNode = getAppContext(true);
+
+ setAppRootNode(appNode);
+ }
+
+ /**
+ * Sets the logical root context information available in YDT node.
+ *
+ * @param node logical root node
+ */
+ private void setRootNode(YdtNode node) {
+ rootNode = node;
+ curNode = node;
+ }
+
+ /**
+ * Sets the app context tree logical root node for ydt application tree.
+ *
+ * @param node application tree's logical root node
+ */
+ private void setAppRootNode(YdtAppContext node) {
+ appRootNode = node;
+ appCurNode = node;
+ }
+
+ /**
+ * Returns the YANG schema registry of Ydt.
+ * This method will be used by ytb.
+ *
+ * @return YANG schema registry
+ */
+ public YangSchemaRegistry getYangSchemaRegistry() {
+ return registry;
+ }
+
+ /**
+ * Returns the app context tree root node for ydt application tree.
+ * This method will be used by yab.
+ *
+ * @return YdtAppContext refers to root node of ydt application tree
+ */
+ public YdtAppContext getAppRootNode() {
+ return appRootNode;
+ }
+
+ /**
+ * Returns the data tree for given node identifier.
+ *
+ * @param id Represents node identifier of YANG data tree node
+ * @param namespace namespace of the application requested by user
+ * @return YANG data tree node
+ */
+ private YdtNode moduleHandler(YangSchemaNodeIdentifier id,
+ String namespace) {
+
+ YangSchemaNode node = registry
+ .getYangSchemaNodeUsingSchemaName(id.getName());
+
+ if (node == null ||
+ namespace != null && !namespace.equals(node.getNameSpace())) {
+ curNode.errorHandler(errorMsg(
+ FMT_NOT_EXIST, id.getName()), rootNode);
+ }
+
+ YdtNode newNode = new YdtSingleInstanceNode(id);
+ newNode.setYangSchemaNode(node);
+ id.setNameSpace(node.getNameSpace());
+ return newNode;
+ }
+
+ @Override
+ public void setRootTagAttributeMap(Map<String, String> attributeTag) {
+ rootTagAttributeMap = attributeTag;
+ }
+
+ @Override
+ public Map<String, String> getRootTagAttributeMap() {
+ if (rootTagAttributeMap != null) {
+ return ImmutableMap.copyOf(rootTagAttributeMap);
+ }
+ return null;
+ }
+
+ @Override
+ public void addChild(String name, String namespace) {
+ addChild(name, namespace, UNKNOWN, null, OTHER);
+ }
+
+ @Override
+ public void addChild(String name, String namespace, YdtType ydtType) {
+ addChild(name, namespace, ydtType, null);
+ }
+
+ @Override
+ public void addChild(String name, String namespace,
+ YdtContextOperationType opType) {
+ addChild(name, namespace, UNKNOWN, opType, OTHER);
+ }
+
+ @Override
+ public void addChild(String name, String namespace, YdtType ydtType,
+ YdtContextOperationType opType) {
+ RequestedCardinality cardinality = null;
+ switch (ydtType) {
+ case MULTI_INSTANCE_NODE:
+ cardinality = MULTI_INSTANCE;
+ break;
+ case SINGLE_INSTANCE_NODE:
+ cardinality = SINGLE_INSTANCE;
+ break;
+ default:
+ curNode.errorHandler(E_USE_ADDLEAF, rootNode);
+ }
+ addChild(name, namespace, cardinality, opType, OTHER);
+ }
+
+ /**
+ * Adds a last child to YANG data tree; this method is to be used by all
+ * protocols internally which are aware or unaware of the nature
+ * (single/multiple) of node.
+ *
+ * @param name name of child to be added
+ * @param namespace namespace of child to be added
+ * @param cardinality type of YANG data tree node operation
+ * @param opType type of requested operation over a node
+ * @param callType to identify the whether its a leaf or other node
+ */
+ private void addChild(String name, String namespace,
+ RequestedCardinality cardinality,
+ YdtContextOperationType opType,
+ RequestedCallType callType) {
+
+ YdtNode childNode;
+ boolean isContextSwitch = false;
+ YangSchemaNode schemaNode = null;
+ YangSchemaNodeContextInfo contextInfo;
+ YangSchemaNode augmentingSchema = null;
+
+ YangSchemaNodeIdentifier id = new YangSchemaNodeIdentifier();
+ id.setName(name);
+
+ // Module/sub-module node handler.
+ if (curNode.equals(rootNode)) {
+ childNode = moduleHandler(id, namespace);
+ } else {
+
+ // If namespace given by user null, then take namespace from parent.
+ if (namespace == null) {
+ namespace = curNode.getYdtNodeIdentifier().getNameSpace();
+ }
+
+ id.setNameSpace(namespace);
+
+ /*
+ * Get the already exiting YDT node in YDT tree with same
+ * nodeIdentifier
+ */
+ childNode = curNode.getCollidingChild(id);
+
+ /*
+ * If colliding child doesn't exist ,
+ * then query yang data model for schema of given node.
+ */
+ if (childNode == null) {
+ /*
+ * Get Yang Schema node context info which is having
+ * YangSchemaNode and ContextSwitchedNode.
+ */
+ contextInfo = curNode.getSchemaNodeContextInfo(id);
+
+ if (contextInfo.getContextSwitchedNode() != null) {
+ augmentingSchema = appCurNode.getAugmentingSchemaNode(
+ id, contextInfo);
+ if (augmentingSchema != null) {
+ /*
+ * As two tree(YDT and YDT Application Tree) are getting
+ * prepared in parallel, So setting context switch
+ * flag it will help ydt to keep the track whether
+ * ydtApp tree also need to be traversed back to parent
+ * or not with YDT tree traverse to parent call.
+ */
+ isContextSwitch = true;
+ }
+ }
+ schemaNode = contextInfo.getSchemaNode();
+ } else {
+ /*
+ * If colliding child exist , then will be leaf-list or list
+ * If its leaf-list then return and add new requested
+ * value/valueSet in same node else take yang data model
+ * information from colliding child.
+ */
+ if (childNode.getYdtType() == MULTI_INSTANCE_LEAF_VALUE_NODE) {
+ curNode = childNode;
+ return;
+ }
+ schemaNode = childNode.getYangSchemaNode();
+ }
+ childNode = YdtNodeFactory.getNode(id, schemaNode, cardinality,
+ callType);
+ }
+
+ opType = getValidOpType(opType, callType, schemaNode);
+
+ childNode.setYdtContextOperationType(opType);
+
+ curNode.addChild(childNode, true);
+
+ // Update parent ydt node map.
+ curNode.updateYdtMap(id, childNode);
+
+ processAppTree(opType, childNode, augmentingSchema, isContextSwitch);
+
+ // Updating the curNode.
+ curNode = childNode;
+ }
+
+ /**
+ * Processes application tree on the bases of requested ydt node.
+ *
+ * @param opType user requested operation type
+ * @param childNode requested ydt node
+ * @param augmentingSchema schema of last augmenting node
+ * @param isContextSwitch true, for module node call; false for modules
+ * sub-node calls
+ */
+ private void processAppTree(
+ YdtContextOperationType opType, YdtNode childNode,
+ YangSchemaNode augmentingSchema, boolean isContextSwitch) {
+
+ if (augmentingSchema != null) {
+ if (!appCurNode.addSchemaToAppSet(augmentingSchema)) {
+ return;
+ }
+ }
+ if (opType == null) {
+ opType = curNode.getYdtContextOperationType();
+ } else {
+ // Updating operation type for parent nodes
+ appCurNode.updateAppOperationType(opType);
+ }
+
+ /*
+ * Create entry of module node in ydt app tree.
+ * Or if context switch happened then also add entry for same ydt
+ * node in the ydt application tree.
+ */
+ if (curNode.equals(rootNode) || isContextSwitch) {
+ addChildInAppTree(childNode, augmentingSchema, opType,
+ isContextSwitch);
+
+ // Setting app tree node operation.
+ appCurNode.setOperationType(getAppOpTypeFromYdtOpType(opType));
+ }
+
+ // Updating the delete operation list in app tree.
+ if (opType == DELETE || opType == REMOVE) {
+ appCurNode.addDeleteNode(childNode);
+ }
+ }
+
+ /**
+ * Returns the valid operation type for requested ydt node after performing
+ * validation.
+ *
+ * @param opType user requested operation type
+ * @param callType to identify the whether its a leaf or other node
+ * @param schemaNode schema node of user requested ydt node
+ * @return operation type
+ */
+ private YdtContextOperationType getValidOpType(
+ YdtContextOperationType opType, RequestedCallType callType,
+ YangSchemaNode schemaNode) {
+
+ // Operation type not supported for leaf node.
+ if (callType == LEAF || (callType == RequestedCallType.MULTI_INSTANCE &&
+ schemaNode.getYangSchemaNodeType() ==
+ YANG_MULTI_INSTANCE_LEAF_NODE)) {
+ return null;
+ }
+
+ // Reference for parent node operation type.
+ YdtContextOperationType parentOpType = curNode
+ .getYdtContextOperationType();
+
+ if (opType != null && parentOpType != null) {
+ validateOperationType(parentOpType, opType);
+ } else if (opType == null) {
+ opType = getOperationType(parentOpType);
+ }
+ return opType;
+ }
+
+ /**
+ * Returns the operation type for non leaf node.
+ * When "operation" attribute for current node is not specified or null,
+ * then the operation applied to the parent data node of the
+ * configuration is used. If no parent data node is available,
+ * then the default-operation'value is used.
+ * If default operation type is not set, merge will be taken as default
+ * operation type.
+ *
+ * @param parentOpType operation type of parent node
+ * @return operation type for current non leaf node
+ */
+ private YdtContextOperationType getOperationType(
+ YdtContextOperationType parentOpType) {
+
+ return parentOpType != null ? parentOpType :
+ (ydtDefaultOpType != null ? ydtDefaultOpType : MERGE);
+ }
+
+ /**
+ * Adds a last child to YANG app data tree.this method is to be used
+ * internally by other ydt interfaces.
+ *
+ * @param childNode node to be added in tree
+ * @param schemaNode last augmenting module node
+ * @param childOpType operation type of node
+ * @param isContextSwitch true, for module node call; false for modules
+ * sub-node calls
+ */
+ private void addChildInAppTree(YdtNode childNode,
+ YangSchemaNode schemaNode,
+ YdtContextOperationType childOpType,
+ boolean isContextSwitch) {
+
+ YdtAppNodeOperationType opType;
+
+ DefaultYdtAppContext appContext = getAppContext(isContextSwitch);
+
+ // Add context switched child in ydt App tree.
+ appCurNode.addChild(appContext);
+ //Updating the curNode.
+ appCurNode = appContext;
+
+ // Get the app tree operation type from ydt operation type.
+ opType = getAppOpTypeFromYdtOpType(childOpType);
+
+ appCurNode.setAppData(childNode, schemaNode);
+
+ appCurNode.setOperationType(opType);
+
+ childNode.setAppContextSwitch();
+ }
+
+ /**
+ * Validates the various combination of operation type.
+ *
+ * @param parentOpType Reference for parent node operation type
+ * @param childOpType type of YANG data tree node operation
+ */
+ private void validateOperationType(YdtContextOperationType parentOpType,
+ YdtContextOperationType childOpType) {
+
+ switch (parentOpType) {
+ case CREATE:
+ // Inside the create operation delete operation should not come.
+ if (childOpType == DELETE) {
+ curNode.errorHandler(E_CREATE, rootNode);
+ }
+ break;
+ case DELETE:
+ // Inside the delete operation create operation should not come.
+ if (childOpType == CREATE) {
+ curNode.errorHandler(E_DEL, rootNode);
+ }
+ break;
+ default:
+ //TODO check all possible scenario.
+ }
+ }
+
+ @Override
+ public void addLeaf(String name, String namespace, String value) {
+ addLeaf(name, namespace, value, null, UNKNOWN);
+ }
+
+ @Override
+ public void addLeaf(String name, String namespace, Set<String> valueSet) {
+ addLeaf(name, namespace, null, valueSet, MULTI_INSTANCE_LEAF);
+ }
+
+ /**
+ * Adds a last leaf with list of values/single value to YANG data tree.
+ * This method is used by all protocols which knows the nature
+ * (single/multiple) or not.
+ * Value of leaf can be null which indicates selection node in get
+ * operation.
+ *
+ * @param name name of child to be added
+ * @param namespace namespace of child to be added, if it's
+ * null, parent's
+ * namespace will be applied to child
+ * @param value value of the child
+ * @param valueSet list of value of the child
+ * @param cardinality type of YANG data tree node operation
+ */
+ private void addLeaf(String name, String namespace, String value,
+ Set<String> valueSet,
+ RequestedCardinality cardinality) {
+ addChild(name, namespace, cardinality, null, LEAF);
+
+ // After successful addition of child node updating the values in same.
+ if (value != null) {
+ curNode.addValue(value);
+ } else if (valueSet != null) {
+ curNode.addValueSet(valueSet);
+ }
+ }
+
+ @Override
+ public void traverseToParent() {
+ // If traverse back to parent for logical root node comes
+ if (curNode.equals(rootNode)) {
+ curNode.errorHandler(E_INVOKE_PARENT, rootNode);
+ }
+
+ // If node is of multiInstanceNode type then check key uniqueness.
+ if (curNode.getYdtType() == MULTI_INSTANCE_NODE) {
+ curNode.createKeyNodeList();
+ }
+
+ /*
+ * Check application switch for curNode if set,
+ * then traverseToParent in YDT application tree.
+ */
+ if (curNode.getParent().equals(rootNode) ||
+ curNode.getAppContextSwitch()) {
+ traverseToAppTreeParent();
+ }
+
+ /*
+ * Validate all multi Instance inside current context,
+ * This is not valid for leaf and leaf-list node.
+ */
+ if (curNode instanceof YdtMultiInstanceNode ||
+ curNode instanceof YdtSingleInstanceNode) {
+ curNode.validateMultiInstanceNode();
+ }
+
+ curNode = curNode.getParent();
+ }
+
+ /**
+ * Traverses up in YANG application tree to the parent node,
+ * This will be used when Ydt current context switch flag is set.
+ */
+ private void traverseToAppTreeParent() {
+ appCurNode = appCurNode.getParent();
+ }
+
+ @Override
+ public YdtContext getCurNode() {
+ return curNode;
+ }
+
+ @Override
+ public void setDefaultEditOperationType(
+ YdtContextOperationType opType) {
+ ydtDefaultOpType = opType;
+ }
+
+ @Override
+ public YdtExtendedContext getRootNode() {
+ return rootNode;
+ }
+
+ @Override
+ public YmsOperationType getYmsOperationType() {
+ return ymsOperationType;
+ }
+
+ @Override
+ public void addMultiInstanceChild(String name, String namespace,
+ List<String> keysValueList,
+ YdtContextOperationType opType) {
+ addChild(name, namespace, UNKNOWN, opType,
+ RequestedCallType.MULTI_INSTANCE);
+ int inputCount = keysValueList.size();
+ int expectedCount;
+ if (curNode.getYdtType() == MULTI_INSTANCE_LEAF_VALUE_NODE) {
+ // After successful addition of child node updating
+ // the values in same.
+ // inputCount = curNode.getValueSet().size() + inputCount;
+ // checkElementCount(expectedCount, inputCount);
+ // TODO check the element count
+ for (String value : keysValueList) {
+ curNode.addValue(value);
+ }
+ } else if (curNode.getYdtType() == MULTI_INSTANCE_NODE) {
+ YangList yangListHolder = (YangList) curNode.getYangSchemaNode();
+ List<String> schemaKeyList = yangListHolder.getKeyList();
+ expectedCount = schemaKeyList.size();
+ checkElementCount(name, expectedCount, inputCount);
+
+ Iterator<String> sklIter = schemaKeyList.iterator();
+ Iterator<String> kvlIter = keysValueList.iterator();
+ String keyEleName;
+ while (kvlIter.hasNext()) {
+ String value = kvlIter.next();
+ keyEleName = sklIter.next();
+ addLeaf(keyEleName, namespace, value);
+ if (kvlIter.hasNext()) {
+ traverseToParentWithoutValidation();
+ }
+ }
+ curNode = curNode.getParent();
+ } else {
+ curNode.errorHandler(E_MULTI_INS, rootNode);
+ }
+ }
+
+ /**
+ * Checks the user supplied list of argument match's the expected value
+ * or not.
+ *
+ * @param name name of the parent list/leaf-list node
+ * @param expected count suppose to be
+ * @param actual user supplied values count
+ */
+ private void checkElementCount(String name, int expected,
+ int actual) {
+ if (expected < actual) {
+ curNode.errorHandler(errorMsg(FMT_TOO_MANY, name, expected, actual),
+ rootNode);
+ } else if (expected > actual) {
+ curNode.errorHandler(errorMsg(FMT_TOO_FEW, name, expected, actual),
+ rootNode);
+ }
+ }
+
+ /**
+ * Adds a last child to YANG data tree, this method is to be used by
+ * YANG object builder sub-calls internally.
+ *
+ * @param opType type of requested operation over a node
+ * @return returns added ydt node in YDT tree
+ */
+ private YdtNode addExtendedChildNode(YdtContextOperationType opType,
+ YangSchemaNode schemaNode) {
+
+ YdtNode childNode;
+ YangSchemaNodeIdentifier id =
+ schemaNode.getYangSchemaNodeIdentifier();
+
+ childNode = YdtNodeFactory
+ .getYangSchemaNodeTypeSpecificContext(
+ id, schemaNode.getYangSchemaNodeType());
+
+ childNode.setId(id);
+
+ childNode.setYangSchemaNode(schemaNode);
+
+ childNode.setYdtContextOperationType(opType);
+
+ curNode.addChild(childNode, true);
+
+ curNode = childNode;
+
+ return childNode;
+ }
+
+ @Override
+ public YdtExtendedContext addChild(YdtContextOperationType opType,
+ YangSchemaNode schemaNode) {
+ return addExtendedChildNode(opType, schemaNode);
+ }
+
+ @Override
+ public YdtExtendedContext addLeafList(Set<String> valueSet,
+ YangSchemaNode schemaNode) {
+ YdtNode childNode = addExtendedChildNode(null, schemaNode);
+
+ // After successful addition of child node updating the values in same.
+ childNode.addValueSetWithoutValidation(valueSet);
+ return childNode;
+ }
+
+ @Override
+ public YdtExtendedContext addLeaf(String value,
+ YangSchemaNode schemaNode) {
+ YdtNode childNode = addExtendedChildNode(null, schemaNode);
+
+ // After successful addition of child node updating the values in same.
+ childNode.addValueWithoutValidation(value);
+ return childNode;
+ }
+
+ @Override
+ public void traverseToParentWithoutValidation() {
+ // If traverse back to parent for logical root node comes
+ if (curNode.equals(rootNode)) {
+ curNode.errorHandler(E_INVOKE_PARENT, rootNode);
+ }
+ curNode = curNode.getParent();
+ }
+}
diff --git a/apps/yms/app/src/main/java/org/onosproject/yms/app/ydt/YangResponseWorkBench.java b/apps/yms/app/src/main/java/org/onosproject/yms/app/ydt/YangResponseWorkBench.java
new file mode 100644
index 0000000..99342d7
--- /dev/null
+++ b/apps/yms/app/src/main/java/org/onosproject/yms/app/ydt/YangResponseWorkBench.java
@@ -0,0 +1,98 @@
+/*
+ * 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.yms.app.ydt;
+
+import org.onosproject.yms.ydt.YdtContext;
+import org.onosproject.yms.ydt.YdtResponse;
+import org.onosproject.yms.ydt.YmsOperationExecutionStatus;
+import org.onosproject.yms.ydt.YmsOperationType;
+
+public class YangResponseWorkBench implements YdtResponse {
+
+ /*
+ * YDT root node context.
+ */
+ private YdtContext rootNode;
+
+ /*
+ * YMS operation execution status.
+ */
+ private YmsOperationExecutionStatus status;
+
+ /*
+ * YMS operation type.
+ */
+ private YmsOperationType ymsOperationType;
+
+ /**
+ * Creates an instance of YangResponseWorkBench which is use to
+ * initialize rootNode and childNode.
+ *
+ * @param ydtContext root node context
+ * @param exeStatus YMS operation execution status
+ * @param opType YMS operation type
+ */
+ public YangResponseWorkBench(YdtContext ydtContext,
+ YmsOperationExecutionStatus exeStatus,
+ YmsOperationType opType) {
+ rootNode = ydtContext;
+ status = exeStatus;
+ ymsOperationType = opType;
+ }
+
+ @Override
+ public YmsOperationExecutionStatus getYmsOperationResult() {
+ return status;
+ }
+
+ @Override
+ public YdtContext getRootNode() {
+ return rootNode;
+ }
+
+ @Override
+ public YmsOperationType getYmsOperationType() {
+ return ymsOperationType;
+ }
+
+ /**
+ * Sets root node.
+ *
+ * @param rootNode root node
+ */
+ public void setRootNode(YdtContext rootNode) {
+ this.rootNode = rootNode;
+ }
+
+ /**
+ * Sets YMS operation execution status.
+ *
+ * @param status YMS operation execution status
+ */
+ public void setStatus(YmsOperationExecutionStatus status) {
+ this.status = status;
+ }
+
+ /**
+ * Sets YMS operation type.
+ *
+ * @param ymsOperationType YMS operation type
+ */
+ public void setYmsOperationType(YmsOperationType ymsOperationType) {
+ this.ymsOperationType = ymsOperationType;
+ }
+}
diff --git a/apps/yms/app/src/main/java/org/onosproject/yms/app/ydt/YdtAppContext.java b/apps/yms/app/src/main/java/org/onosproject/yms/app/ydt/YdtAppContext.java
new file mode 100644
index 0000000..c845221
--- /dev/null
+++ b/apps/yms/app/src/main/java/org/onosproject/yms/app/ydt/YdtAppContext.java
@@ -0,0 +1,223 @@
+/*
+ * 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.yms.app.ydt;
+
+import org.onosproject.yangutils.datamodel.YangSchemaNode;
+import org.onosproject.yangutils.datamodel.YangSchemaNodeContextInfo;
+import org.onosproject.yangutils.datamodel.YangSchemaNodeIdentifier;
+import org.onosproject.yms.ydt.YdtContext;
+import org.onosproject.yms.ydt.YdtContextOperationType;
+
+import java.util.List;
+
+/**
+ * Abstraction of an entity which represents YANG application data tree context
+ * information. This context information will be used by protocol to obtain
+ * the information associated with YDT application node. This is used when
+ * protocol is walking the application data tree in both visitor and listener
+ * mechanism.
+ */
+public interface YdtAppContext {
+
+ /**
+ * Returns the context of parent node.
+ *
+ * @return context of parent node
+ */
+ YdtAppContext getParent();
+
+ /**
+ * Sets the context of parent node.
+ *
+ * @param parent node
+ */
+ void setParent(YdtAppContext parent);
+
+ /**
+ * Returns the context of first child.
+ *
+ * @return context of first child
+ */
+ YdtAppContext getFirstChild();
+
+ /**
+ * Sets the context of first child.
+ *
+ * @param child node
+ */
+ void setChild(YdtAppContext child);
+
+ /**
+ * Returns the context of last child.
+ *
+ * @return context of last child
+ */
+ YdtAppContext getLastChild();
+
+ /**
+ * Sets the context of last child.
+ *
+ * @param child node
+ */
+ void setLastChild(YdtAppContext child);
+
+ /**
+ * Returns the context of next sibling.
+ *
+ * @return context of next sibling
+ */
+ YdtAppContext getNextSibling();
+
+ /**
+ * Sets the context of next sibling.
+ *
+ * @param nextSibling node
+ */
+ void setNextSibling(YdtAppContext nextSibling);
+
+ /**
+ * Returns the context of previous sibling.
+ *
+ * @return context of previous sibling
+ */
+ YdtAppContext getPreviousSibling();
+
+ /**
+ * Sets the context of previous sibling.
+ *
+ * @param preSibling node
+ */
+ void setPreviousSibling(YdtAppContext preSibling);
+
+ /**
+ * Returns the app tree operation type.
+ *
+ * @return app tree operation type
+ */
+ YdtAppNodeOperationType getOperationType();
+
+ /**
+ * Set the app tree operation type.
+ *
+ * @param opType app tree operation type
+ */
+ void setOperationType(YdtAppNodeOperationType opType);
+
+ /**
+ * Returns the list of nodes with operation type delete.
+ *
+ * @return list of nodes with operation type delete
+ */
+ List<YdtContext> getDeleteNodes();
+
+ /**
+ * Adds the ydt node with operation type delete in module delete node list.
+ *
+ * @param node ydt node with operation type delete/remove
+ */
+ void addDeleteNode(YdtNode node);
+
+ /**
+ * Returns application's root ydtContext.
+ *
+ * @return YdtContext of application root node
+ */
+ YdtContext getModuleContext();
+
+ /**
+ * Sets the application's ydtContext.
+ *
+ * @param moduleNode application's ydtContext
+ */
+ void setModuleContext(YdtContext moduleNode);
+
+ /**
+ * Returns the YangSchemaNode of augmenting application.
+ *
+ * @return YangSchemaNode of augmenting application
+ */
+ YangSchemaNode getAugmentingSchemaNode();
+
+ /**
+ * Sets the YangSchemaNode of augmenting application root node.
+ *
+ * @param schemaNode YangSchemaNode of augmenting application module
+ */
+ void setAugmentingSchemaNode(YangSchemaNode schemaNode);
+
+ /**
+ * Adds a last child to ydt application data tree.
+ *
+ * @param newChild name of child to be added
+ */
+ void addChild(YdtAppContext newChild);
+
+ /**
+ * Returns augmenting node module yang schema node.
+ *
+ * @param id schema node identifier
+ * @param contextInfo Yang Schema node context info
+ * which is having YangSchemaNode and
+ * ContextSwitchedNode
+ * @return augmenting node module yang schema node
+ */
+ YangSchemaNode getAugmentingSchemaNode(
+ YangSchemaNodeIdentifier id,
+ YangSchemaNodeContextInfo contextInfo);
+
+ /**
+ * Updates the app tree operation type.
+ * <p>
+ * If earlier operation type was OTHER_EDIT and now operation type came as
+ * DELETE_ONLY or vice-versa, then update operation type to BOTH.
+ *
+ * @param opType ydt current context operation type
+ */
+ void updateAppOperationType(YdtContextOperationType opType);
+
+ /**
+ * Sets the application data for given request. If in requested parameters
+ * schemaNode is not null then appData will be set with
+ * augmentedSchemaData else with moduleSchemaData object.
+ *
+ * @param moduleNode module node of requested app
+ * @param schemaNode augmented schema node of requested context
+ */
+ void setAppData(YdtNode moduleNode, YangSchemaNode schemaNode);
+
+ /**
+ * Returns the app data for current context.
+ *
+ * @return app data
+ */
+ AppData getAppData();
+
+ /**
+ * Returns the yang schema for requested node.
+ *
+ * @return schema node
+ */
+ YangSchemaNode getYangSchemaNode();
+
+ /**
+ * Adds the given schema node in to application set.
+ *
+ * @param schemaNode schema node to be added
+ * @return true for success; false otherwise
+ */
+ boolean addSchemaToAppSet(YangSchemaNode schemaNode);
+}
diff --git a/apps/yms/app/src/main/java/org/onosproject/yms/app/ydt/YdtAppNodeOperationType.java b/apps/yms/app/src/main/java/org/onosproject/yms/app/ydt/YdtAppNodeOperationType.java
new file mode 100644
index 0000000..4880edc
--- /dev/null
+++ b/apps/yms/app/src/main/java/org/onosproject/yms/app/ydt/YdtAppNodeOperationType.java
@@ -0,0 +1,45 @@
+/*
+ * 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.yms.app.ydt;
+
+/**
+ * Represents type of YANG data tree node operation.
+ */
+public enum YdtAppNodeOperationType {
+
+ /**
+ * Type of YANG application node operation for below action:
+ * The application containing this attribute has edit operation
+ * type as delete/remove in its complete ydtTree.
+ */
+ DELETE_ONLY,
+
+ /**
+ * Type of YANG application node operation for below action:
+ * The application containing this attribute has edit operation
+ * type other than delete/remove in its complete ydtTree.
+ */
+ OTHER_EDIT,
+
+ /**
+ * Type of YANG application node operation for below action:
+ * The application containing this attribute has edit operation
+ * type of combination of any edit operation type in its complete ydtTree.
+ */
+ BOTH
+}
+
diff --git a/apps/yms/app/src/main/java/org/onosproject/yms/app/ydt/YdtConstants.java b/apps/yms/app/src/main/java/org/onosproject/yms/app/ydt/YdtConstants.java
new file mode 100644
index 0000000..2063093
--- /dev/null
+++ b/apps/yms/app/src/main/java/org/onosproject/yms/app/ydt/YdtConstants.java
@@ -0,0 +1,44 @@
+/*
+ * 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.yms.app.ydt;
+
+/**
+ * Represents common constant utility for YANG data tree.
+ */
+final class YdtConstants {
+
+ //No instantiation.
+ private YdtConstants() {
+ }
+
+ /**
+ * Error formatting string for duplicate entries found in ydt.
+ */
+ public static final String FMT_DUP_ENTRY = "Duplicate entry with name %s.";
+
+ /**
+ * Returns the error string by filling the parameters in the given
+ * formatted error string.
+ *
+ * @param fmt error format string
+ * @param params parameters to be filled in formatted string
+ * @return error string
+ */
+ public static String errorMsg(String fmt, Object... params) {
+ return String.format(fmt, params);
+ }
+}
\ No newline at end of file
diff --git a/apps/yms/app/src/main/java/org/onosproject/yms/app/ydt/YdtExtendedBuilder.java b/apps/yms/app/src/main/java/org/onosproject/yms/app/ydt/YdtExtendedBuilder.java
new file mode 100644
index 0000000..ea9c9f3d
--- /dev/null
+++ b/apps/yms/app/src/main/java/org/onosproject/yms/app/ydt/YdtExtendedBuilder.java
@@ -0,0 +1,72 @@
+/*
+ * 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.yms.app.ydt;
+
+import org.onosproject.yangutils.datamodel.YangSchemaNode;
+import org.onosproject.yms.ydt.YdtBuilder;
+import org.onosproject.yms.ydt.YdtContextOperationType;
+
+import java.util.Set;
+
+/**
+ * Abstraction of an entity which represents extension of YDT builder
+ * required by internal sub modules.
+ */
+public interface YdtExtendedBuilder extends YdtBuilder {
+
+ /**
+ * Adds a last child to YANG data tree; this method is to be used by
+ * YANG object builder.
+ *
+ * @param yangSchemaNode schema node from YANG metadata
+ * @param opType type of requested operation over a node
+ * @return YDT context
+ */
+ YdtExtendedContext addChild(YdtContextOperationType opType,
+ YangSchemaNode yangSchemaNode);
+
+ /**
+ * Adds a last leaf list to YANG data tree; this method is to be used by
+ * YANG object builder.
+ *
+ * @param valueSet list of value of the child
+ * @param yangSchemaNode schema node from YANG metadata
+ * @return YDT context
+ */
+ YdtExtendedContext addLeafList(Set<String> valueSet,
+ YangSchemaNode yangSchemaNode);
+
+ /**
+ * Adds a last leaf to YANG data tree; this method is to be used by
+ * YANG object builder.
+ *
+ * @param value value of the child
+ * @param yangSchemaNode schema node from YANG metadata
+ * @return YDT context
+ */
+ YdtExtendedContext addLeaf(String value, YangSchemaNode yangSchemaNode);
+
+ /**
+ * Traverses up in YANG data tree to the parent node, it is to be used when
+ * protocol is using extended context type and wanted to traverse
+ * up the tree without doing any validation.
+ */
+ void traverseToParentWithoutValidation();
+
+ @Override
+ YdtExtendedContext getRootNode();
+}
diff --git a/apps/yms/app/src/main/java/org/onosproject/yms/app/ydt/YdtExtendedContext.java b/apps/yms/app/src/main/java/org/onosproject/yms/app/ydt/YdtExtendedContext.java
new file mode 100644
index 0000000..3668de8
--- /dev/null
+++ b/apps/yms/app/src/main/java/org/onosproject/yms/app/ydt/YdtExtendedContext.java
@@ -0,0 +1,72 @@
+/*
+ * 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.yms.app.ydt;
+
+import org.onosproject.yangutils.datamodel.YangSchemaNode;
+import org.onosproject.yangutils.datamodel.YangSchemaNodeContextInfo;
+import org.onosproject.yangutils.datamodel.YangSchemaNodeIdentifier;
+import org.onosproject.yms.ydt.YdtContext;
+import org.onosproject.yms.ydt.YdtContextOperationType;
+
+/**
+ * Abstraction of an entity which represents application related information
+ * maintained in YDT.
+ */
+public interface YdtExtendedContext extends YdtContext {
+
+ /**
+ * Returns the application stored information. Application type is used to
+ * identify application.
+ *
+ * @param appType application type
+ * @return application information
+ */
+ Object getAppInfo(AppType appType);
+
+ /**
+ * Sets application stored information. Application type is used to
+ * identify application.
+ *
+ * @param appType application type
+ * @param object application information object
+ */
+ void addAppInfo(AppType appType, Object object);
+
+ /**
+ * Returns child schema node context information. It is used by YMS to
+ * obtain the child schema corresponding to data node identifier.
+ *
+ * @param id represents a identifier of YANG data tree node
+ * @return YANG data node context information
+ */
+ YangSchemaNodeContextInfo getSchemaNodeContextInfo(
+ YangSchemaNodeIdentifier id);
+
+ /**
+ * Returns schema node from data model for curNode.
+ *
+ * @return yang schema node
+ */
+ YangSchemaNode getYangSchemaNode();
+
+ /**
+ * Returns YDT current extended context operation type.
+ *
+ * @return operation type
+ */
+ YdtContextOperationType getYdtContextOperationType();
+}
diff --git a/apps/yms/app/src/main/java/org/onosproject/yms/app/ydt/YdtExtendedListener.java b/apps/yms/app/src/main/java/org/onosproject/yms/app/ydt/YdtExtendedListener.java
new file mode 100644
index 0000000..333f3ef
--- /dev/null
+++ b/apps/yms/app/src/main/java/org/onosproject/yms/app/ydt/YdtExtendedListener.java
@@ -0,0 +1,53 @@
+/*
+ * 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.yms.app.ydt;
+
+
+import org.onosproject.yms.ydt.YdtListener;
+
+/**
+ * Abstraction of an entity which provide call back methods which are called
+ * by YDT extended walker while walking the YANG data tree.
+ * <p>
+ * This interface needs to be implemented by protocol implementing listener's
+ * based call backs while YDT walk, and update application specific information
+ * in data node.
+ */
+public interface YdtExtendedListener extends YdtListener {
+
+ /**
+ * YANG data tree node's entry, it will be called during a node entry.
+ * <p>
+ * All the related information about the node can be obtain from the YDT
+ * context. Also it can be used to maintain / query application specific
+ * information.
+ *
+ * @param ydtExtendedContext YANG data tree context
+ */
+ void enterYdtNode(YdtExtendedContext ydtExtendedContext);
+
+ /**
+ * YANG data tree node's exit, it will be called during a node exit.
+ * <p>
+ * All the related information about the node can be obtain from the YDT
+ * context. Also it can be used to maintain / query application specific
+ * information.
+ *
+ * @param ydtExtendedContext YANG data tree context
+ */
+ void exitYdtNode(YdtExtendedContext ydtExtendedContext);
+}
diff --git a/apps/yms/app/src/main/java/org/onosproject/yms/app/ydt/YdtExtendedWalker.java b/apps/yms/app/src/main/java/org/onosproject/yms/app/ydt/YdtExtendedWalker.java
new file mode 100644
index 0000000..f3bfea3
--- /dev/null
+++ b/apps/yms/app/src/main/java/org/onosproject/yms/app/ydt/YdtExtendedWalker.java
@@ -0,0 +1,35 @@
+/*
+ * 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.yms.app.ydt;
+
+import org.onosproject.yms.ydt.YdtWalker;
+
+/**
+ * Abstraction of an entity which provides interfaces for YDT extended walker.
+ */
+public interface YdtExtendedWalker extends YdtWalker {
+
+ /**
+ * Walks the YANG data tree. Protocols implements YDT listener service and
+ * walks YDT tree with input as implemented object.
+ * YDT walker provides call backs to implemented methods.
+ *
+ * @param ydtListener YDT listener implemented by the protocol
+ * @param rootNode root node of YDT
+ */
+ void walk(YdtExtendedListener ydtListener, YdtExtendedContext rootNode);
+}
diff --git a/apps/yms/app/src/main/java/org/onosproject/yms/app/ydt/YdtMultiInstanceLeafNode.java b/apps/yms/app/src/main/java/org/onosproject/yms/app/ydt/YdtMultiInstanceLeafNode.java
new file mode 100644
index 0000000..955852d
--- /dev/null
+++ b/apps/yms/app/src/main/java/org/onosproject/yms/app/ydt/YdtMultiInstanceLeafNode.java
@@ -0,0 +1,109 @@
+/*
+ * 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.yms.app.ydt;
+
+import com.google.common.collect.ImmutableSet;
+import org.onosproject.yangutils.datamodel.YangSchemaNodeIdentifier;
+import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import static org.onosproject.yms.app.ydt.YdtConstants.errorMsg;
+import static org.onosproject.yms.ydt.YdtType.MULTI_INSTANCE_LEAF_VALUE_NODE;
+
+/**
+ * Represents YDT multi instance leaf node which can hold multiple values, it
+ * is atomic element and doesn't have any child.
+ */
+class YdtMultiInstanceLeafNode extends YdtNode {
+
+ // ydt formatted error string
+ private static final String FMT_DUP_ENTRY =
+ "Duplicate entry found under %s leaf-list node.";
+
+ /**
+ * Set of values.
+ */
+ private final Set<String> valueSet = new HashSet<>();
+
+ /**
+ * Creates a YANG multi instance leaf node.
+ *
+ * @param id node identifier of YDT multi instance node
+ */
+ protected YdtMultiInstanceLeafNode(YangSchemaNodeIdentifier id) {
+ super(MULTI_INSTANCE_LEAF_VALUE_NODE, id);
+ }
+
+ @Override
+ public Set<String> getValueSet() {
+ return ImmutableSet.copyOf(valueSet);
+ }
+
+ @Override
+ public void addValue(String value) {
+ // check the value against corresponding data-type.
+ try {
+ getYangSchemaNode().isValueValid(value);
+ } catch (Exception e) {
+ errorHandler(e.getLocalizedMessage(), this);
+ }
+ addValueToValueSet(value);
+ }
+
+ /**
+ * Adds value in the current node valueSet, after successful validation of
+ * the value.
+ *
+ * @param value value to be added
+ */
+ private void addValueToValueSet(String value) {
+
+ if (!valueSet.add(value)) {
+ errorHandler(errorMsg(FMT_DUP_ENTRY,
+ getYdtNodeIdentifier().getName()), this);
+ }
+ }
+
+ @Override
+ public void addValueSet(Set valueSet) {
+ String value = null;
+ // Check the value against corresponding data-type.
+ for (Object aValueSet : valueSet) {
+
+ try {
+ value = String.valueOf(aValueSet);
+ getYangSchemaNode().isValueValid(value);
+ } catch (DataModelException e) {
+ errorHandler(e.getLocalizedMessage(), this);
+ }
+ addValueToValueSet(value);
+ }
+ }
+
+ @Override
+ public void addValueWithoutValidation(String value) {
+ valueSet.add(value);
+ }
+
+ @Override
+ public void addValueSetWithoutValidation(Set valueSet) {
+ this.valueSet.clear();
+ this.valueSet.addAll(valueSet);
+ }
+}
diff --git a/apps/yms/app/src/main/java/org/onosproject/yms/app/ydt/YdtMultiInstanceNode.java b/apps/yms/app/src/main/java/org/onosproject/yms/app/ydt/YdtMultiInstanceNode.java
new file mode 100644
index 0000000..a24772b
--- /dev/null
+++ b/apps/yms/app/src/main/java/org/onosproject/yms/app/ydt/YdtMultiInstanceNode.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.yms.app.ydt;
+
+import com.google.common.collect.ImmutableList;
+import org.onosproject.yangutils.datamodel.YangList;
+import org.onosproject.yangutils.datamodel.YangSchemaNodeIdentifier;
+import org.onosproject.yms.ydt.YdtContext;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import static org.onosproject.yms.app.ydt.YdtConstants.errorMsg;
+import static org.onosproject.yms.ydt.YdtType.MULTI_INSTANCE_NODE;
+
+
+/**
+ * Represents a multi instance node in YANG data tree.
+ */
+public class YdtMultiInstanceNode extends YdtNode {
+
+ // ydt formatted error string
+ private static final String FMT_MISSING_KEY =
+ "%s is missing some of the keys of %s.";
+
+ /*
+ * Reference for list of key element's ydtContext.
+ */
+ private List<YdtContext> keyNodeList = new ArrayList<>();
+
+ /*
+ * Reference for composite key string for multi Instance Node..
+ */
+ private String compositeKey;
+
+ /**
+ * Creates a YANG multi instance node object.
+ *
+ * @param id node identifier of YDT multi instance node .
+ */
+ protected YdtMultiInstanceNode(YangSchemaNodeIdentifier id) {
+ super(MULTI_INSTANCE_NODE, id);
+ }
+
+ /**
+ * Returns the composite key string for current multi instance node.
+ *
+ * @return composite key string
+ */
+ public String getCompositeKey() {
+ return compositeKey;
+ }
+
+ /**
+ * Returns the list of key element's ydtContext.
+ *
+ * @return list of key element's ydtContext
+ */
+ public List<YdtContext> getKeyNodeList() {
+ return ImmutableList.copyOf(keyNodeList);
+ }
+
+ @Override
+ public void createKeyNodeList() {
+ YangList yangListHolder = (YangList) getYangSchemaNode();
+ List<String> schemaKeyList = yangListHolder.getKeyList();
+
+ /*
+ * If key element not defined in schema or config is false then
+ * return no need to do create key list.
+ */
+ if (schemaKeyList == null || !yangListHolder.isConfig()) {
+ return;
+ }
+
+ StringBuilder ksb = new StringBuilder();
+
+ // Iterator for schema key name list.
+ Iterator<String> sklItr = schemaKeyList.iterator();
+
+ List<YdtContext> nodeList = new ArrayList<>();
+
+ YangSchemaNodeIdentifier id = new YangSchemaNodeIdentifier();
+ id.setNameSpace(getYdtNodeIdentifier().getNameSpace());
+ // This loop should run while schema key list is not finished
+ while (sklItr.hasNext()) {
+ String name = sklItr.next();
+ id.setName(name);
+ List<YdtNode<YdtMultiInstanceNode>> collidingChild =
+ (List<YdtNode<YdtMultiInstanceNode>>) ydtNodeMap.get(id);
+
+ if (collidingChild == null) {
+ errorHandler(errorMsg(FMT_MISSING_KEY,
+ yangListHolder.getParent().getName(),
+ yangListHolder.getName()), this);
+ }
+
+ YdtNode<YdtMultiInstanceNode> ydtNode = collidingChild.get(0);
+ /*
+ * Preparing composite key string by concatenating values of
+ * all the key leaf.
+ */
+ ksb.append(ydtNode.getValue());
+ nodeList.add(ydtNode);
+ }
+ //Setting te key object in List.
+ keyNodeList = nodeList;
+ compositeKey = ksb.toString();
+ }
+}
diff --git a/apps/yms/app/src/main/java/org/onosproject/yms/app/ydt/YdtNode.java b/apps/yms/app/src/main/java/org/onosproject/yms/app/ydt/YdtNode.java
new file mode 100644
index 0000000..c3d4b87
--- /dev/null
+++ b/apps/yms/app/src/main/java/org/onosproject/yms/app/ydt/YdtNode.java
@@ -0,0 +1,707 @@
+/*
+ * 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.yms.app.ydt;
+
+import org.onosproject.yangutils.datamodel.YangList;
+import org.onosproject.yangutils.datamodel.YangSchemaNode;
+import org.onosproject.yangutils.datamodel.YangSchemaNodeContextInfo;
+import org.onosproject.yangutils.datamodel.YangSchemaNodeIdentifier;
+import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
+import org.onosproject.yms.app.ydt.exceptions.YdtException;
+import org.onosproject.yms.ydt.YdtContext;
+import org.onosproject.yms.ydt.YdtContextOperationType;
+import org.onosproject.yms.ydt.YdtExtendedInfoType;
+import org.onosproject.yms.ydt.YdtType;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import static org.onosproject.yms.app.ydt.YdtConstants.errorMsg;
+
+/**
+ * Represents implementation of interfaces to build and obtain YANG data tree
+ * which is data (sub)instance representation, abstract of protocol.
+ */
+public abstract class YdtNode<T> implements YdtExtendedContext, Cloneable {
+
+ // ydt formatted error string
+ private static final String FMT_UNI_KEY =
+ "Some of the key elements are not unique in %s.";
+ private static final String FMT_KLIST_STR =
+ "List of key cannot be created for leaf and leaf-list %s node.";
+ private static final String FMT_VAL_N =
+ "Value cannot be set in non leaf %s node.";
+ private static final String FMT_VAL_NS =
+ "ValueSet cannot be set in non leaf-list %s node.";
+ private static final String FMT_VAL_IN =
+ "Value cannot be invoke from non leaf %s node.";
+ private static final String FMT_VAL_INS =
+ "ValueSet cannot be invoke from non leaf-list %s node";
+ private static final String FMT_MANY_INS =
+ "Too many instances of %s. Expected maximum instances %d.";
+ private static final String FMT_FEW_INS =
+ "Too few instances of %s. Expected minimum instances %d.";
+
+ // ydt error string
+ private static final String E_EXIST = "Node is already part of a tree";
+ private static final String E_ATOMIC =
+ "Child to be added is not atomic, it already has a child";
+ private static final String E_SIB =
+ "Child to be added is not atomic, it already has a next sibling";
+ private static final String E_PRE =
+ "Child to be added is not atomic, it already has a previous " +
+ "sibling";
+ private static final String E_SUPPORT = "Requested node type not supported";
+
+ /*
+ * Parent reference.
+ */
+ private YdtNode parent;
+
+ /*
+ * First child reference.
+ */
+ private YdtNode child;
+
+ /*
+ * Next sibling reference.
+ */
+ private YdtNode nextSibling;
+
+ /*
+ * Previous sibling reference.
+ */
+ private YdtNode previousSibling;
+
+ /*
+ * Last child reference.
+ */
+ private YdtNode lastChild;
+
+ /*
+ * Type of node.
+ */
+ private YdtType ydtType;
+
+ /*
+ * Flag to keep the track of context switch,
+ * if set then traverse back to parent in YDT app tree else no need.
+ */
+ private boolean isContextSwitch;
+
+ /*
+ * YDT extended information.
+ */
+ private T ydtExtendedInfo;
+
+ /*
+ * YDT extended information type.
+ */
+ private YdtExtendedInfoType ydtExtendedInfoType;
+
+ /*
+ * Ydt map to keep the track of node added in YDT.
+ */
+ final Map<YangSchemaNodeIdentifier, List<YdtNode<T>>> ydtNodeMap =
+ new HashMap<>();
+
+ /*
+ * Reference for data-model schema node.
+ */
+ private YangSchemaNode yangSchemaNode;
+
+ /*
+ * Reference for ydt node operation type.
+ */
+ private YdtContextOperationType ydtContextOperationType;
+
+ /*
+ * Key object for ydtNodeMap.
+ */
+ private YangSchemaNodeIdentifier id;
+
+ /*
+ * Ydt map to keep the track of application information object
+ * with respective type.
+ */
+ private final Map<AppType, Object> ydtAppInfoMap = new HashMap<>();
+
+ private YdtContext clonedNode;
+
+ /**
+ * Returns the cloned ydt node.
+ *
+ * @return clonedNode cloned ydt node
+ */
+ public YdtContext getClonedNode() {
+ return clonedNode;
+ }
+
+ /**
+ * Sets the cloned node.
+ *
+ * @param clonedNode cloned ydt node
+ */
+ public void setClonedNode(YdtContext clonedNode) {
+ this.clonedNode = clonedNode;
+ }
+
+ @Override
+ public String getName() {
+ return id.getName();
+ }
+
+ @Override
+ public String getNamespace() {
+ return id.getNameSpace();
+ }
+
+ @Override
+ public <T> T getYdtContextExtendedInfo() {
+ return (T) ydtExtendedInfo;
+ }
+
+ @Override
+ public YdtExtendedInfoType getYdtExtendedInfoType() {
+ return ydtExtendedInfoType;
+ }
+
+ @Override
+ public YdtType getYdtType() {
+ return ydtType;
+ }
+
+ @Override
+ public YdtNode getParent() {
+ return parent;
+ }
+
+ @Override
+ public YdtNode getFirstChild() {
+ return child;
+ }
+
+ @Override
+ public YdtNode getNextSibling() {
+ return nextSibling;
+ }
+
+ public YangSchemaNode getYangSchemaNode() {
+ return yangSchemaNode;
+ }
+
+ @Override
+ public YdtNode getLastChild() {
+ return lastChild;
+ }
+
+ @Override
+ public Object getAppInfo(AppType appType) {
+ return ydtAppInfoMap.get(appType);
+ }
+
+ @Override
+ public void addAppInfo(AppType appType, Object object) {
+ ydtAppInfoMap.put(appType, object);
+ }
+
+ @Override
+ public YangSchemaNodeContextInfo getSchemaNodeContextInfo(
+ YangSchemaNodeIdentifier id) {
+ try {
+ return getYangSchemaNode().getChildSchema(id);
+ } catch (DataModelException e) {
+ errorHandler(e.getLocalizedMessage(), this);
+ }
+ return null;
+ }
+
+ /**
+ * Adds the given value to the non single instance leaf node.
+ * <p>
+ * This default implementation throws an exception stating that
+ * the value cannot be added. Subclasses may override this method
+ * to provide the correct behavior for their specific implementation.
+ *
+ * @param value value in a single instance node
+ */
+ public void addValue(String value) {
+ errorHandler(
+ errorMsg(FMT_VAL_N, getYdtNodeIdentifier().getName()), this);
+ }
+
+ /**
+ * Creates the list of key element's of multi instance node.
+ * this will not be applicable on leaf and leaf-list node.
+ */
+ public void createKeyNodeList() {
+ errorHandler(errorMsg(
+ FMT_KLIST_STR, getYdtNodeIdentifier().getName()), this);
+ }
+
+ /**
+ * Adds the given value to the non single instance leaf node.
+ * <p>
+ * This default implementation throws an exception stating that
+ * the value cannot be added. Subclasses may override this method
+ * to provide the correct behavior for their specific implementation.
+ * This will be applicable in case of call from SBI so no need
+ * to validate the value.
+ *
+ * @param value value in a single instance leaf node
+ */
+ public void addValueWithoutValidation(String value) {
+ errorHandler(
+ errorMsg(FMT_VAL_N, getYdtNodeIdentifier().getName()), this);
+ }
+
+ /**
+ * Adds the given valueSet to the non multi instance leaf node.
+ * <p>
+ * This default implementation throws an exception stating that
+ * the value cannot be added. Subclasses may override this method
+ * to provide the correct behavior for their specific implementation.
+ *
+ * @param valueSet valueSet in a multi instance leaf node
+ */
+ public void addValueSet(Set<String> valueSet) {
+ errorHandler(
+ errorMsg(FMT_VAL_NS, getYdtNodeIdentifier().getName()), this);
+ }
+
+ /**
+ * Adds the given valueSet to the non multi instance leaf node.
+ * <p>
+ * This default implementation throws an exception stating that
+ * the value cannot be added. Subclasses may override this method
+ * to provide the correct behavior for their specific implementation.
+ * This will be applicable in case of call from SBI so no need
+ * to validate the value.
+ *
+ * @param valueSet valueSet in a multi instance leaf node
+ */
+ public void addValueSetWithoutValidation(Set<String> valueSet) {
+ errorHandler(
+ errorMsg(FMT_VAL_NS, getYdtNodeIdentifier().getName()), this);
+ }
+
+ /**
+ * Validates requested node allowed to have duplicate entry or not.
+ * <p>
+ * This default implementation throws an exception stating that
+ * the duplicate entry found. Subclasses may override this method
+ * to provide the correct behavior for their specific implementation.
+ */
+ public void validDuplicateEntryProcessing() {
+ }
+
+ /**
+ * Returns already existing YdtNode in Ydt tree with same nodeIdentifier.
+ *
+ * @param id represents a identifier of YANG data tree node
+ * @return YDT node
+ */
+ public YdtNode getCollidingChild(YangSchemaNodeIdentifier id) {
+
+ // Find the key in YDT map for getting the colliding node.
+ List<YdtNode<T>> collidingChild = ydtNodeMap.get(id);
+
+ /*
+ * If colliding child exist then process colliding node in respective
+ * YDT node type.
+ */
+ if (collidingChild != null) {
+ collidingChild.get(0).validDuplicateEntryProcessing();
+ return collidingChild.get(0);
+ }
+
+ return null;
+ }
+
+ /**
+ * Creates a specific type of node.
+ *
+ * @param type of YDT node
+ * @param id node identifier of the YDT node
+ */
+ YdtNode(YdtType type, YangSchemaNodeIdentifier id) {
+ ydtType = type;
+ setId(id);
+ }
+
+ /**
+ * Sets the parent of node.
+ *
+ * @param parent node
+ */
+ public void setParent(YdtNode parent) {
+ this.parent = parent;
+ }
+
+ /**
+ * Sets the first instance of a child node.
+ *
+ * @param child is only child to be set
+ */
+ public void setChild(YdtNode child) {
+ this.child = child;
+ }
+
+ /**
+ * Sets the next sibling of node.
+ *
+ * @param sibling YANG node
+ */
+ public void setNextSibling(YdtNode sibling) {
+ nextSibling = sibling;
+ }
+
+ /**
+ * Returns the previous sibling of a node.
+ *
+ * @return previous sibling of a node
+ */
+ public YdtNode getPreviousSibling() {
+ return previousSibling;
+ }
+
+ /**
+ * Sets the previous sibling.
+ *
+ * @param previousSibling points to predecessor sibling
+ */
+ public void setPreviousSibling(YdtNode previousSibling) {
+ this.previousSibling = previousSibling;
+ }
+
+ @Override
+ public String getValue() {
+ errorHandler(
+ errorMsg(FMT_VAL_IN, getYdtNodeIdentifier().getName()), this);
+ return null;
+ }
+
+ @Override
+ public Set<String> getValueSet() {
+ errorHandler(
+ errorMsg(FMT_VAL_INS, getYdtNodeIdentifier().getName()), this);
+ return null;
+ }
+
+ /**
+ * Sets the data-model node reference for of a given node.
+ *
+ * @param yangSchemaNode YANG data node
+ */
+ public void setYangSchemaNode(YangSchemaNode yangSchemaNode) {
+ this.yangSchemaNode = yangSchemaNode;
+ }
+
+ /**
+ * Sets the last instance of a child node.
+ *
+ * @param child is last child to be set
+ */
+ public void setLastChild(YdtNode child) {
+ lastChild = child;
+ }
+
+ /**
+ * Returns object node identifier.
+ *
+ * @return node identifier
+ */
+ public YangSchemaNodeIdentifier getYdtNodeIdentifier() {
+ return id;
+ }
+
+ /**
+ * Sets object node identifier.
+ *
+ * @param id node identifier
+ */
+ public void setId(YangSchemaNodeIdentifier id) {
+ this.id = id;
+ }
+
+ /**
+ * Adds a child node.
+ * The children sibling list will be sorted based on node
+ * type. This will add single child or sub-tree based on isAtomic flag.
+ *
+ * @param newChild refers to a new child to be added
+ * @param isAtomic boolean flag to maintain atomicity of the current node
+ * @throws YdtException in case of violation of any YDT rule
+ */
+ public void addChild(YdtContext newChild, boolean isAtomic)
+ throws YdtException {
+
+ if (!(newChild instanceof YdtNode)) {
+ errorHandler(errorMsg(E_SUPPORT), this);
+ }
+
+ YdtNode node = (YdtNode) newChild;
+
+ if (node.getParent() == null) {
+ node.setParent(this);
+ } else if (!node.getParent().equals(this)) {
+ errorHandler(errorMsg(E_EXIST), this);
+ }
+
+ if (node.getFirstChild() != null && isAtomic) {
+ errorHandler(errorMsg(E_ATOMIC), this);
+ }
+
+ if (node.getNextSibling() != null) {
+ errorHandler(errorMsg(E_SIB), this);
+ }
+
+ if (node.getPreviousSibling() != null) {
+ errorHandler(errorMsg(E_PRE), this);
+ }
+
+ // If new node needs to be added as first child.
+ if (getFirstChild() == null) {
+ setChild(node);
+ setLastChild(node);
+ return;
+ }
+
+ // If new node needs to be added as last child.
+ YdtNode curNode = getLastChild();
+ curNode.setNextSibling(node);
+ node.setPreviousSibling(curNode);
+ setLastChild(node);
+ }
+
+ @Override
+ public YdtContextOperationType getYdtContextOperationType() {
+ return ydtContextOperationType;
+ }
+
+ /**
+ * Sets type of yang data tree node operation.
+ *
+ * @param opType type of yang data tree node operation
+ */
+ public void setYdtContextOperationType(YdtContextOperationType opType) {
+ ydtContextOperationType = opType;
+ }
+
+ /**
+ * Updates ydt map of current context parent node.
+ *
+ * @param id object node identifier
+ * @param node ydt node for which map need to be updated
+ */
+ public void updateYdtMap(YangSchemaNodeIdentifier id, YdtNode node) {
+ List<YdtNode<T>> list = ydtNodeMap.get(id);
+ if (list == null) {
+ list = new ArrayList<>();
+ ydtNodeMap.put(id, list);
+ }
+ list.add(node);
+ }
+
+ /**
+ * Returns the flag for node if context switch.
+ *
+ * @return isContextSwitch flag of a node
+ */
+ public boolean getAppContextSwitch() {
+ return isContextSwitch;
+ }
+
+ /**
+ * Sets the flag to keep the track of context switch.
+ * If it is set then when YDT get traverToParent then
+ * traverse back to parent in YDT application tree.
+ */
+ public void setAppContextSwitch() {
+ isContextSwitch = true;
+ }
+
+ /**
+ * Validates all multi Instance inside current context.
+ */
+ public void validateMultiInstanceNode() {
+
+ // Set for checking whether input string is unique or not.
+ Set<String> keyStringSet = new HashSet<>();
+
+ // Iterating over values in map and find multi instance node list only.
+ for (List<YdtNode<T>> ydtNodeList : ydtNodeMap.values()) {
+ validateInstances(keyStringSet, ydtNodeList);
+ }
+ }
+
+ /**
+ * Checks for any duplicate list entries.
+ *
+ * @param keyStringSet set to validate the composite key of an instance
+ * @param ydtNodeList list of entries
+ */
+ private void validateInstances(Set<String> keyStringSet,
+ List<YdtNode<T>> ydtNodeList) {
+ // Clearing the set.
+ keyStringSet.clear();
+
+ if (ydtNodeList.get(0) instanceof YdtMultiInstanceNode) {
+
+ // Storing the number of multiInstance node for number
+ // if instance validation.
+ int instanceCount = ydtNodeList.size();
+
+ YangList list = (YangList) ydtNodeList.get(0).getYangSchemaNode();
+ int minElement;
+ int maxElement;
+ if (list.getMinElements() != null) {
+ minElement = list.getMinElements().getMinElement();
+ if (instanceCount < minElement) {
+ errorHandler(errorMsg(FMT_FEW_INS, list.getName(),
+ minElement), this);
+ }
+ }
+
+ if (list.getMaxElements() != null) {
+ maxElement = list.getMaxElements().getMaxElement();
+ if (instanceCount > maxElement) {
+ errorHandler(errorMsg(FMT_MANY_INS, list.getName(),
+ maxElement), this);
+ }
+ }
+
+ if (list.isConfig() && instanceCount > 1) {
+ // Iterating over values in ydtNodeList of
+ // multiInstanceNode and compare the key string.
+ for (YdtNode ydtNode : ydtNodeList) {
+ if (!keyStringSet.add(((YdtMultiInstanceNode) ydtNode)
+ .getCompositeKey())) {
+ errorHandler(errorMsg(
+ FMT_UNI_KEY, ydtNode.getYdtNodeIdentifier()
+ .getName()), this);
+ }
+ }
+ }
+ }
+ }
+
+ /**
+ * Walks in whole Ydt Tree and de-reference all the tree node.
+ * This will be called only when any exception occurs while processing
+ * the node in Ydt tree.
+ *
+ * @param node ydt node
+ */
+ public void freeRestResources(YdtNode node) {
+ // Traversing to logical rootNode.
+ YdtNode rootNode = node;
+ while (rootNode.getParent() != null) {
+ rootNode = rootNode.getParent();
+ }
+ YdtNode currentNode = rootNode;
+ while (currentNode != null) {
+
+ // Move down to first child
+ YdtNode nextNode = currentNode.getFirstChild();
+ if (nextNode != null) {
+ currentNode = nextNode;
+ continue;
+ }
+
+ // No child nodes, so walk tree
+ while (currentNode != null) {
+ // To keep the track of last sibling.
+ YdtNode lastSibling = currentNode;
+
+ // Move to sibling if possible.
+ nextNode = currentNode.getNextSibling();
+
+ // free currentNode resources
+ free(lastSibling);
+
+ lastSibling.getNamespace();
+ if (nextNode != null) {
+ currentNode = nextNode;
+ break;
+ }
+
+ // Move up
+ if (currentNode.equals(rootNode)) {
+ currentNode = null;
+ } else {
+ currentNode = currentNode.getParent();
+ lastSibling.setParent(null);
+ }
+ }
+ }
+ }
+
+ /**
+ * Free the give YDT node by de-referencing it to null.
+ *
+ * @param node node to be freed
+ */
+ private void free(YdtNode node) {
+ if (node.getParent() != null) {
+ YdtNode parent = node.getParent();
+ parent.setChild(null);
+ parent.setLastChild(null);
+ if (node.getNextSibling() != null) {
+ parent.setChild(node.getNextSibling());
+ }
+ }
+ YdtNode parentRef = node.getParent();
+ node = new YdtSingleInstanceNode(null);
+ node.ydtType = null;
+ node.setParent(parentRef);
+ }
+
+ /**
+ * Clones the current node contents and create a new node.
+ *
+ * @return cloned node
+ * @throws CloneNotSupportedException clone is not supported
+ * by the referred node
+ */
+ public YdtNode clone() throws CloneNotSupportedException {
+ YdtNode clonedNode = (YdtNode) super.clone();
+ clonedNode.setPreviousSibling(null);
+ clonedNode.setNextSibling(null);
+ clonedNode.setParent(null);
+ clonedNode.setChild(null);
+ clonedNode.setLastChild(null);
+ return clonedNode;
+ }
+
+ /**
+ * Handles an error scenario, freeing allocated resources for the given YTD
+ * node before throwing an exception with the specified error message.
+ *
+ * @param error error message
+ * @param curNode ydt node
+ * @throws YdtException with the specified error message
+ */
+ public void errorHandler(String error, YdtNode curNode) {
+ curNode.freeRestResources(curNode);
+ throw new YdtException(error);
+ }
+}
diff --git a/apps/yms/app/src/main/java/org/onosproject/yms/app/ydt/YdtNodeFactory.java b/apps/yms/app/src/main/java/org/onosproject/yms/app/ydt/YdtNodeFactory.java
new file mode 100644
index 0000000..43680da
--- /dev/null
+++ b/apps/yms/app/src/main/java/org/onosproject/yms/app/ydt/YdtNodeFactory.java
@@ -0,0 +1,256 @@
+/*
+ * 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.yms.app.ydt;
+
+import org.onosproject.yangutils.datamodel.YangSchemaNode;
+import org.onosproject.yangutils.datamodel.YangSchemaNodeIdentifier;
+import org.onosproject.yangutils.datamodel.YangSchemaNodeType;
+import org.onosproject.yms.app.ydt.exceptions.YdtException;
+import org.onosproject.yms.ydt.YdtContextOperationType;
+
+import static org.onosproject.yangutils.datamodel.YangSchemaNodeType.YANG_MULTI_INSTANCE_LEAF_NODE;
+import static org.onosproject.yangutils.datamodel.YangSchemaNodeType.YANG_MULTI_INSTANCE_NODE;
+import static org.onosproject.yangutils.datamodel.YangSchemaNodeType.YANG_SINGLE_INSTANCE_LEAF_NODE;
+import static org.onosproject.yangutils.datamodel.YangSchemaNodeType.YANG_SINGLE_INSTANCE_NODE;
+import static org.onosproject.yms.app.ydt.YdtAppNodeOperationType.DELETE_ONLY;
+import static org.onosproject.yms.app.ydt.YdtAppNodeOperationType.OTHER_EDIT;
+import static org.onosproject.yms.app.ydt.YdtConstants.errorMsg;
+
+/**
+ * Represents an YANG node factory to create different types of YANG data tree
+ * node.
+ */
+final class YdtNodeFactory {
+
+ // ydt formatted error string
+ private static final String FMT_NOT_EXIST =
+ "Schema node with name %s doesn't exist.";
+
+ // No instantiation
+ private YdtNodeFactory() {
+ }
+
+ /**
+ * Returns a YANG data tree node for a given name, set of values and
+ * instance type.
+ *
+ * @param id dataNodeIdentifier of data tree node
+ * @param schemaNode data node as per YANG schema metadata
+ * @param cardinality requested cardinality of node
+ * @param callType identify the call type
+ * @return YANG data tree node
+ */
+ protected static YdtNode getNode(YangSchemaNodeIdentifier id,
+ YangSchemaNode schemaNode,
+ RequestedCardinality cardinality,
+ RequestedCallType callType) {
+
+ YdtNode newNode = null;
+ YangSchemaNodeType nodeType = schemaNode.getYangSchemaNodeType();
+
+ switch (cardinality) {
+
+ case UNKNOWN:
+ /*
+ * if requested node type is UNKNOWN, check corresponding
+ * yang data node type and create respective type node.
+ */
+ newNode = getYangSchemaNodeTypeSpecificContext(id, nodeType,
+ callType);
+ break;
+
+ /*
+ * if requested node type is specified and it exist as node of some
+ * other type in data model then throw exception
+ */
+ case SINGLE_INSTANCE:
+ validateNodeType(id, nodeType, YANG_SINGLE_INSTANCE_NODE);
+ newNode = new YdtSingleInstanceNode(id);
+ break;
+
+ case MULTI_INSTANCE:
+
+ validateNodeType(id, nodeType, YANG_MULTI_INSTANCE_NODE);
+ newNode = new YdtMultiInstanceNode(id);
+ break;
+
+ case SINGLE_INSTANCE_LEAF:
+
+ validateNodeType(id, nodeType, YANG_SINGLE_INSTANCE_LEAF_NODE);
+ newNode = new YdtSingleInstanceLeafNode(id);
+ break;
+
+ case MULTI_INSTANCE_LEAF:
+
+ validateNodeType(id, nodeType, YANG_MULTI_INSTANCE_LEAF_NODE);
+ newNode = new YdtMultiInstanceLeafNode(id);
+ break;
+
+ default:
+ throwNotExistError(id);
+ }
+
+ // set reference of yang data node in the requested node.
+ newNode.setYangSchemaNode(schemaNode);
+
+ return newNode;
+ }
+
+ /**
+ * Validates the requested ydt node type against the schema node type,
+ * if it is not equal then it will throw warning.
+ *
+ * @param id dataNodeIdentifier of data tree node
+ * @param nodeType actual node type
+ * @param requestedType user requested node type
+ */
+ private static void validateNodeType(YangSchemaNodeIdentifier id,
+ YangSchemaNodeType nodeType,
+ YangSchemaNodeType requestedType) {
+ if (nodeType != requestedType) {
+ throwNotExistError(id);
+ }
+ }
+
+ /**
+ * Creates Yang data tree node of YangSchemaNode type specific for
+ * requestedCardinality of type UNKNOWN and returns the same.
+ *
+ * @param id node identifier of data tree node
+ * @param nodeType schema node type as per YANG schema metadata
+ * @param callType identify the call type
+ * @return YANG data tree node
+ */
+ private static YdtNode getYangSchemaNodeTypeSpecificContext(
+ YangSchemaNodeIdentifier id,
+ YangSchemaNodeType nodeType,
+ RequestedCallType callType) {
+ switch (callType) {
+ case LEAF:
+ switch (nodeType) {
+
+ case YANG_SINGLE_INSTANCE_LEAF_NODE:
+ return new YdtSingleInstanceLeafNode(id);
+
+ case YANG_MULTI_INSTANCE_LEAF_NODE:
+ return new YdtMultiInstanceLeafNode(id);
+
+ default:
+ throwNotExistError(id);
+ }
+
+ case OTHER:
+ switch (nodeType) {
+
+ case YANG_SINGLE_INSTANCE_NODE:
+ return new YdtSingleInstanceNode(id);
+
+ case YANG_MULTI_INSTANCE_NODE:
+ return new YdtMultiInstanceNode(id);
+
+ default:
+ throwNotExistError(id);
+ }
+
+ case MULTI_INSTANCE:
+ switch (nodeType) {
+
+ case YANG_MULTI_INSTANCE_LEAF_NODE:
+ return new YdtMultiInstanceLeafNode(id);
+
+ case YANG_MULTI_INSTANCE_NODE:
+ return new YdtMultiInstanceNode(id);
+
+ default:
+ throwNotExistError(id);
+ }
+
+ default:
+ throwNotExistError(id);
+ }
+
+ return null;
+ }
+
+ /**
+ * Create Yang data tree node of YangSchemaNode type specific and
+ * returns the same.
+ *
+ * @param id node identifier of data tree node
+ * @param nodeType schema node type as per YANG schema metadata
+ * @return YANG data tree node
+ */
+ protected static YdtNode getYangSchemaNodeTypeSpecificContext(
+ YangSchemaNodeIdentifier id,
+ YangSchemaNodeType nodeType) {
+
+ switch (nodeType) {
+
+ case YANG_SINGLE_INSTANCE_LEAF_NODE:
+ return new YdtSingleInstanceLeafNode(id);
+
+ case YANG_MULTI_INSTANCE_LEAF_NODE:
+ return new YdtMultiInstanceLeafNode(id);
+
+ case YANG_SINGLE_INSTANCE_NODE:
+ return new YdtSingleInstanceNode(id);
+
+ case YANG_MULTI_INSTANCE_NODE:
+ return new YdtMultiInstanceNode(id);
+
+ default:
+ throwNotExistError(id);
+ }
+
+ return null;
+ }
+
+ /**
+ * Returns the app tree operation type with the help of YdtOperation type.
+ *
+ * @param opType ydt operation type
+ * @return app tree operation type
+ */
+ protected static YdtAppNodeOperationType getAppOpTypeFromYdtOpType(
+ YdtContextOperationType opType) {
+ // Get the app tree operation type.
+ switch (opType) {
+ case CREATE:
+ case MERGE:
+ case REPLACE:
+ return OTHER_EDIT;
+
+ case DELETE:
+ case REMOVE:
+ return DELETE_ONLY;
+
+ default:
+ return null;
+ //TODO handle the default data type.
+ }
+ }
+
+ /**
+ * Throws exception for requested ydt node by preparing error message with
+ * given node identifier.
+ *
+ * @param id node identifier
+ */
+ private static void throwNotExistError(YangSchemaNodeIdentifier id) {
+ throw new YdtException(errorMsg(FMT_NOT_EXIST, id.getName()));
+ }
+}
diff --git a/apps/yms/app/src/main/java/org/onosproject/yms/app/ydt/YdtSingleInstanceLeafNode.java b/apps/yms/app/src/main/java/org/onosproject/yms/app/ydt/YdtSingleInstanceLeafNode.java
new file mode 100644
index 0000000..0bd7036
--- /dev/null
+++ b/apps/yms/app/src/main/java/org/onosproject/yms/app/ydt/YdtSingleInstanceLeafNode.java
@@ -0,0 +1,74 @@
+/*
+ * 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.yms.app.ydt;
+
+import org.onosproject.yangutils.datamodel.YangSchemaNodeIdentifier;
+
+import static org.onosproject.yms.app.ydt.YdtConstants.FMT_DUP_ENTRY;
+import static org.onosproject.yms.app.ydt.YdtConstants.errorMsg;
+import static org.onosproject.yms.ydt.YdtType.SINGLE_INSTANCE_LEAF_VALUE_NODE;
+
+/**
+ * Represents YDT single instance leaf node which is an atomic element
+ * and doesn't have any child.
+ */
+class YdtSingleInstanceLeafNode extends YdtNode {
+
+ /*
+ * Value of the leaf.
+ */
+ private String value;
+
+ /**
+ * Creates a YANG single instance leaf node.
+ *
+ * @param id node identifier of YDT single instance leaf node
+ */
+ protected YdtSingleInstanceLeafNode(YangSchemaNodeIdentifier id) {
+ super(SINGLE_INSTANCE_LEAF_VALUE_NODE, id);
+ }
+
+ @Override
+ public String getValue() {
+ return value;
+ }
+
+ @Override
+ public void addValue(String value) {
+ // Check the value against corresponding data-type.
+ try {
+ getYangSchemaNode().isValueValid(value);
+ } catch (Exception e) {
+ errorHandler(e.getLocalizedMessage(), this);
+ }
+
+ // After validation is successful then add value to node.
+ this.value = value;
+ }
+
+
+ @Override
+ public void addValueWithoutValidation(String value) {
+ this.value = value;
+ }
+
+ @Override
+ public void validDuplicateEntryProcessing() {
+ errorHandler(errorMsg(FMT_DUP_ENTRY, getYdtNodeIdentifier().getName()),
+ this);
+ }
+}
diff --git a/apps/yms/app/src/main/java/org/onosproject/yms/app/ydt/YdtSingleInstanceNode.java b/apps/yms/app/src/main/java/org/onosproject/yms/app/ydt/YdtSingleInstanceNode.java
new file mode 100644
index 0000000..b7f84b5
--- /dev/null
+++ b/apps/yms/app/src/main/java/org/onosproject/yms/app/ydt/YdtSingleInstanceNode.java
@@ -0,0 +1,44 @@
+/*
+ * 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.yms.app.ydt;
+
+import org.onosproject.yangutils.datamodel.YangSchemaNodeIdentifier;
+
+import static org.onosproject.yms.app.ydt.YdtConstants.FMT_DUP_ENTRY;
+import static org.onosproject.yms.app.ydt.YdtConstants.errorMsg;
+import static org.onosproject.yms.ydt.YdtType.SINGLE_INSTANCE_NODE;
+
+/**
+ * Represents a single instance YANG data tree node.
+ */
+class YdtSingleInstanceNode extends YdtNode {
+
+ /**
+ * Creates a YANG single instance node object.
+ *
+ * @param id node identifier of YDT single instance node
+ */
+ protected YdtSingleInstanceNode(YangSchemaNodeIdentifier id) {
+ super(SINGLE_INSTANCE_NODE, id);
+ }
+
+ @Override
+ public void validDuplicateEntryProcessing() {
+ errorHandler(errorMsg(FMT_DUP_ENTRY, getYdtNodeIdentifier().getName()),
+ this);
+ }
+}
diff --git a/apps/yms/app/src/main/java/org/onosproject/yms/app/ydt/exceptions/YdtException.java b/apps/yms/app/src/main/java/org/onosproject/yms/app/ydt/exceptions/YdtException.java
new file mode 100644
index 0000000..db21976
--- /dev/null
+++ b/apps/yms/app/src/main/java/org/onosproject/yms/app/ydt/exceptions/YdtException.java
@@ -0,0 +1,65 @@
+/*
+ * 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.yms.app.ydt.exceptions;
+
+/**
+ * Represents base class for exceptions in YDT operations.
+ */
+public class YdtException extends RuntimeException {
+
+ private static final long serialVersionUID = 20160211L;
+
+ /**
+ * Creates a new YDT exception with given message.
+ *
+ * @param message the detail of exception in string
+ */
+ public YdtException(String message) {
+ super(message);
+ }
+
+ /**
+ * Creates a new YDT exception from given message and cause.
+ *
+ * @param message the detail of exception in string
+ * @param cause underlying cause of the error
+ */
+ public YdtException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ /**
+ * Creates a new YDT exception from cause.
+ *
+ * @param cause underlying cause of the error
+ */
+ public YdtException(Throwable cause) {
+ super(cause);
+ }
+
+ /**
+ * Creates a new YDT exception from given parameters.
+ *
+ * @param keyword identify error scenario whether it is many or few
+ * @param name name of the node
+ * @param count supported count value
+ */
+ public YdtException(String keyword, String name, int count) {
+ super("Too " + keyword + " key parameter in " + name + ". Expected " +
+ "count " + count + ".");
+ }
+}
diff --git a/apps/yms/app/src/main/java/org/onosproject/yms/app/ydt/exceptions/package-info.java b/apps/yms/app/src/main/java/org/onosproject/yms/app/ydt/exceptions/package-info.java
new file mode 100644
index 0000000..20da849
--- /dev/null
+++ b/apps/yms/app/src/main/java/org/onosproject/yms/app/ydt/exceptions/package-info.java
@@ -0,0 +1,20 @@
+/*
+ * 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.
+ */
+
+/**
+ * YANG data tree exceptions.
+ */
+package org.onosproject.yms.app.ydt.exceptions;
diff --git a/apps/yms/app/src/main/java/org/onosproject/yms/app/ydt/package-info.java b/apps/yms/app/src/main/java/org/onosproject/yms/app/ydt/package-info.java
new file mode 100644
index 0000000..2ed1950
--- /dev/null
+++ b/apps/yms/app/src/main/java/org/onosproject/yms/app/ydt/package-info.java
@@ -0,0 +1,21 @@
+/*
+ * 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.
+ */
+
+/**
+ * Provides implementation of build and obtain YANG data tree which is data
+ * (sub)instance representation, abstract of protocol.
+ */
+package org.onosproject.yms.app.ydt;
diff --git a/apps/yms/app/src/main/java/org/onosproject/yms/app/ymsm/YmsManager.java b/apps/yms/app/src/main/java/org/onosproject/yms/app/ymsm/YmsManager.java
index f4030ce..b9ea3a8 100644
--- a/apps/yms/app/src/main/java/org/onosproject/yms/app/ymsm/YmsManager.java
+++ b/apps/yms/app/src/main/java/org/onosproject/yms/app/ymsm/YmsManager.java
@@ -25,6 +25,8 @@
import org.onosproject.core.ApplicationId;
import org.onosproject.core.CoreService;
import org.onosproject.core.IdGenerator;
+import org.onosproject.yms.app.ydt.DefaultYdtWalker;
+import org.onosproject.yms.app.ydt.YangRequestWorkBench;
import org.onosproject.yms.app.ynh.YangNotificationExtendedService;
import org.onosproject.yms.app.ysr.DefaultYangSchemaRegistry;
import org.onosproject.yms.app.ysr.YangSchemaRegistry;
@@ -97,7 +99,8 @@
public YdtBuilder getYdtBuilder(String logicalRootName,
String rootNamespace,
YmsOperationType operationType) {
- return null;
+ return new YangRequestWorkBench(logicalRootName, rootNamespace,
+ operationType, schemaRegistry, true);
}
@Override
@@ -105,12 +108,20 @@
String rootNamespace,
YmsOperationType operationType,
Object schemaRegistryForYdt) {
- return null;
+ if (schemaRegistryForYdt != null) {
+ return new YangRequestWorkBench(logicalRootName, rootNamespace,
+ operationType,
+ (YangSchemaRegistry)
+ schemaRegistryForYdt,
+ false);
+ }
+ return new YangRequestWorkBench(logicalRootName, rootNamespace,
+ operationType, schemaRegistry, true);
}
@Override
public YdtWalker getYdtWalker() {
- return null;
+ return new DefaultYdtWalker();
}
@Override
@@ -177,5 +188,4 @@
public YangSchemaRegistry getSchemaRegistry() {
return schemaRegistry;
}
-
}
diff --git a/apps/yms/app/src/test/java/org/onosproject/yms/app/ydt/AugmentTest.java b/apps/yms/app/src/test/java/org/onosproject/yms/app/ydt/AugmentTest.java
new file mode 100644
index 0000000..8fd5580
--- /dev/null
+++ b/apps/yms/app/src/test/java/org/onosproject/yms/app/ydt/AugmentTest.java
@@ -0,0 +1,528 @@
+/*
+ * 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.yms.app.ydt;
+
+import org.junit.Test;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import static org.junit.Assert.assertNull;
+import static org.onosproject.yms.app.ydt.YdtAppNodeOperationType.BOTH;
+import static org.onosproject.yms.app.ydt.YdtAppNodeOperationType.DELETE_ONLY;
+import static org.onosproject.yms.app.ydt.YdtAppNodeOperationType.OTHER_EDIT;
+import static org.onosproject.yms.app.ydt.YdtTestConstants.A1;
+import static org.onosproject.yms.app.ydt.YdtTestConstants.A2;
+import static org.onosproject.yms.app.ydt.YdtTestConstants.A2L;
+import static org.onosproject.yms.app.ydt.YdtTestConstants.A3;
+import static org.onosproject.yms.app.ydt.YdtTestConstants.A4;
+import static org.onosproject.yms.app.ydt.YdtTestConstants.A5;
+import static org.onosproject.yms.app.ydt.YdtTestConstants.A5L;
+import static org.onosproject.yms.app.ydt.YdtTestConstants.A6;
+import static org.onosproject.yms.app.ydt.YdtTestConstants.A6L;
+import static org.onosproject.yms.app.ydt.YdtTestConstants.AUG1;
+import static org.onosproject.yms.app.ydt.YdtTestConstants.AUG2;
+import static org.onosproject.yms.app.ydt.YdtTestConstants.AUG3;
+import static org.onosproject.yms.app.ydt.YdtTestConstants.AUG4;
+import static org.onosproject.yms.app.ydt.YdtTestConstants.AUG5;
+import static org.onosproject.yms.app.ydt.YdtTestConstants.AUG6;
+import static org.onosproject.yms.app.ydt.YdtTestConstants.AUG7;
+import static org.onosproject.yms.app.ydt.YdtTestConstants.AUG8;
+import static org.onosproject.yms.app.ydt.YdtTestConstants.AUG9;
+import static org.onosproject.yms.app.ydt.YdtTestConstants.IETF;
+import static org.onosproject.yms.app.ydt.YdtTestConstants.SLINK;
+import static org.onosproject.yms.app.ydt.YdtTestConstants.STP;
+import static org.onosproject.yms.app.ydt.YdtTestConstants.TOPONS;
+import static org.onosproject.yms.app.ydt.YdtTestUtils.augmentNetworkYdt;
+import static org.onosproject.yms.app.ydt.YdtTestUtils.validateAppLogicalNodeContents;
+import static org.onosproject.yms.app.ydt.YdtTestUtils.validateAppModuleNodeContents;
+import static org.onosproject.yms.app.ydt.YdtTestUtils.validateAppNodeContents;
+import static org.onosproject.yms.app.ydt.YdtTestUtils.validateLeafContents;
+import static org.onosproject.yms.app.ydt.YdtTestUtils.validateLeafListContents;
+import static org.onosproject.yms.app.ydt.YdtTestUtils.validateNodeContents;
+import static org.onosproject.yms.app.ydt.YdtTestUtils.walkINTree;
+import static org.onosproject.yms.ydt.YdtContextOperationType.DELETE;
+import static org.onosproject.yms.ydt.YdtContextOperationType.MERGE;
+
+public class AugmentTest {
+
+ private Set<String> valueSet = new HashSet();
+
+ private static final String[] EXPECTED = {
+ "Entry Node is yms-ietf-network.",
+ "Entry Node is yms-ietf-network.",
+ "Entry Node is networks.",
+ "Entry Node is network.",
+ "Entry Node is network-id.",
+ "Exit Node is network-id.",
+ "Entry Node is link.",
+ "Entry Node is link-id.",
+ "Exit Node is link-id.",
+ "Entry Node is source.",
+ "Entry Node is source-node.",
+ "Exit Node is source-node.",
+ "Entry Node is source-tp.",
+ "Exit Node is source-tp.",
+ "Exit Node is source.",
+
+ "Entry Node is destination.",
+ "Entry Node is dest-node.",
+ "Exit Node is dest-node.",
+ "Entry Node is dest-tp.",
+ "Exit Node is dest-tp.",
+ "Exit Node is destination.",
+
+ "Entry Node is supporting-link.",
+ "Entry Node is network-ref.",
+ "Exit Node is network-ref.",
+ "Entry Node is link-ref.",
+ "Exit Node is link-ref.",
+ "Exit Node is supporting-link.",
+
+ "Entry Node is supporting-link.",
+ "Entry Node is network-ref.",
+ "Exit Node is network-ref.",
+ "Entry Node is link-ref.",
+ "Exit Node is link-ref.",
+ "Exit Node is supporting-link.",
+
+ "Entry Node is augment1.",
+ "Entry Node is value1.",
+ "Exit Node is value1.",
+ "Exit Node is augment1.",
+
+ "Entry Node is augment2.",
+ "Entry Node is key1.",
+ "Exit Node is key1.",
+ "Entry Node is key2.",
+ "Exit Node is key2.",
+
+ "Entry Node is augment5.",
+
+ "Entry Node is augment6leafList.",
+ "Exit Node is augment6leafList.",
+
+ "Entry Node is value5.",
+ "Exit Node is value5.",
+ "Exit Node is augment5.",
+
+ "Entry Node is augment5leafList.",
+ "Exit Node is augment5leafList.",
+
+ "Entry Node is augment3.",
+
+ "Entry Node is augment4.",
+ "Entry Node is value4.",
+ "Exit Node is value4.",
+ "Exit Node is augment4.",
+
+ "Entry Node is augment5.",
+
+ "Entry Node is leaf6.",
+ "Exit Node is leaf6.",
+
+ "Entry Node is value5.",
+ "Exit Node is value5.",
+ "Exit Node is augment5.",
+
+ "Entry Node is augment6.",
+ "Entry Node is value6.",
+ "Exit Node is value6.",
+ "Exit Node is augment6.",
+
+ "Entry Node is value3.",
+ "Exit Node is value3.",
+ "Exit Node is augment3.",
+
+ "Entry Node is augment3leaf.",
+ "Exit Node is augment3leaf.",
+
+ "Exit Node is augment2.",
+
+ "Entry Node is augment2leafList.",
+ "Exit Node is augment2leafList.",
+
+ "Exit Node is link.",
+
+ "Entry Node is supporting-network.",
+ "Entry Node is network-ref.",
+ "Exit Node is network-ref.",
+ "Exit Node is supporting-network.",
+ "Entry Node is node.",
+ "Entry Node is node-id.",
+ "Exit Node is node-id.",
+ "Entry Node is t-point.",
+ "Entry Node is tp-id.",
+ "Exit Node is tp-id.",
+
+ "Entry Node is supporting-termination-point.",
+ "Entry Node is network-ref.",
+ "Exit Node is network-ref.",
+ "Entry Node is node-ref.",
+ "Exit Node is node-ref.",
+ "Entry Node is tp-ref.",
+ "Exit Node is tp-ref.",
+
+ "Entry Node is augment1.",
+ "Entry Node is value1.",
+ "Exit Node is value1.",
+ "Exit Node is augment1.",
+
+ "Entry Node is augment1-leaf.",
+ "Exit Node is augment1-leaf.",
+
+ "Entry Node is augment2.",
+
+ "Entry Node is augment3.",
+ "Entry Node is value3.",
+ "Exit Node is value3.",
+ "Exit Node is augment3.",
+
+ "Entry Node is augment4leaf.",
+ "Exit Node is augment4leaf.",
+
+ "Entry Node is value2.",
+ "Exit Node is value2.",
+ "Exit Node is augment2.",
+ "Entry Node is augment2leafList.",
+ "Exit Node is augment2leafList.",
+ "Entry Node is augment2leaf.",
+ "Exit Node is augment2leaf.",
+
+ "Exit Node is supporting-termination-point.",
+ "Exit Node is t-point.",
+ "Entry Node is supporting-node.",
+ "Entry Node is network-ref.",
+ "Exit Node is network-ref.",
+ "Entry Node is node-ref.",
+ "Exit Node is node-ref.",
+ "Exit Node is supporting-node.",
+
+ "Exit Node is node.",
+ // last augmented sibling in network
+ "Entry Node is link-id.",
+ "Exit Node is link-id.",
+
+ "Exit Node is network.",
+ "Exit Node is networks.",
+ "Entry Node is networks-state.",
+ "Entry Node is network.",
+ "Entry Node is network-ref.",
+ "Exit Node is network-ref.",
+ "Entry Node is server-provided.",
+ "Exit Node is server-provided.",
+ "Exit Node is network.",
+ "Exit Node is networks-state.",
+ "Exit Node is yms-ietf-network.",
+ "Exit Node is yms-ietf-network."
+ };
+
+ /**
+ * Creates and validates ietf network augment ydt.
+ */
+ @Test
+ public void augmentTest() {
+ YangRequestWorkBench ydtBuilder = augmentNetworkYdt();
+ validateTree(ydtBuilder);
+ validateAppTree(ydtBuilder);
+ walkINTree(ydtBuilder, EXPECTED);
+ }
+
+ /**
+ * Validates the given built ydt.
+ */
+ private void validateTree(YangRequestWorkBench ydtBuilder) {
+
+ // Assign root node to ydtNode for validating purpose.
+ YdtNode ydtNode = (YdtNode) ydtBuilder.getRootNode();
+ // Logical root node does not have operation type
+ validateNodeContents(ydtNode, "yms-ietf-network", null);
+ ydtNode = ydtNode.getFirstChild();
+ validateNodeContents(ydtNode, "yms-ietf-network", MERGE);
+ ydtNode = ydtNode.getFirstChild();
+ validateNodeContents(ydtNode, "networks", MERGE);
+ ydtNode = ydtNode.getFirstChild();
+ validateNodeContents(ydtNode, "network", MERGE);
+ ydtNode = ydtNode.getFirstChild();
+ validateLeafContents(ydtNode, "network-id", "network1");
+ ydtNode = ydtNode.getNextSibling();
+
+ // Validating augmented child
+ validateNodeContents(ydtNode, "link", MERGE);
+ ydtNode = ydtNode.getFirstChild();
+ validateLeafContents(ydtNode, "link-id", "id1");
+ ydtNode = ydtNode.getNextSibling();
+
+ // Inside source node
+ validateNodeContents(ydtNode, "source", MERGE);
+ ydtNode = ydtNode.getFirstChild();
+ validateLeafContents(ydtNode, "source-node", "source1");
+ ydtNode = ydtNode.getNextSibling();
+ validateLeafContents(ydtNode, "source-tp", "source2");
+ ydtNode = ydtNode.getParent();
+ ydtNode = ydtNode.getNextSibling();
+
+ //Inside destination node
+ validateNodeContents(ydtNode, "destination", MERGE);
+ ydtNode = ydtNode.getFirstChild();
+ validateLeafContents(ydtNode, "dest-node", "dest1");
+ ydtNode = ydtNode.getNextSibling();
+ validateLeafContents(ydtNode, "dest-tp", "dest2");
+ ydtNode = ydtNode.getParent();
+ ydtNode = ydtNode.getNextSibling();
+
+ //Inside supporting links
+ validateNodeContents(ydtNode, SLINK, MERGE);
+ ydtNode = ydtNode.getFirstChild();
+ validateLeafContents(ydtNode, "network-ref", "network1");
+ ydtNode = ydtNode.getNextSibling();
+ validateLeafContents(ydtNode, "link-ref", "id2");
+ ydtNode = ydtNode.getParent();
+ ydtNode = ydtNode.getNextSibling();
+
+ //Inside another supporting links instance
+ validateNodeContents(ydtNode, SLINK, MERGE);
+ ydtNode = ydtNode.getFirstChild();
+ validateLeafContents(ydtNode, "network-ref", "network2");
+ ydtNode = ydtNode.getNextSibling();
+ validateLeafContents(ydtNode, "link-ref", "id3");
+ ydtNode = ydtNode.getParent();
+ ydtNode = ydtNode.getNextSibling();
+
+ validateNodeContents(ydtNode, "augment1", MERGE);
+ ydtNode = ydtNode.getFirstChild();
+ validateLeafContents(ydtNode, "value1", "1");
+ ydtNode = ydtNode.getParent();
+
+ ydtNode = ydtNode.getNextSibling();
+ validateNodeContents(ydtNode, "augment2", MERGE);
+ ydtNode = ydtNode.getFirstChild();
+ validateLeafContents(ydtNode, "key1", "1");
+ ydtNode = ydtNode.getNextSibling();
+ validateLeafContents(ydtNode, "key2", "2");
+
+ ydtNode = ydtNode.getNextSibling();
+ validateNodeContents(ydtNode, "augment5", DELETE);
+ ydtNode = ydtNode.getFirstChild();
+ valueSet.add("1");
+ valueSet.add("2");
+ validateLeafListContents(ydtNode, A6L, valueSet);
+ ydtNode = ydtNode.getNextSibling();
+
+ validateLeafContents(ydtNode, "value5", "5");
+ ydtNode = ydtNode.getParent();
+
+ ydtNode = ydtNode.getNextSibling();
+ validateLeafListContents(ydtNode, A5L, valueSet);
+
+ ydtNode = ydtNode.getNextSibling();
+ validateNodeContents(ydtNode, "augment3", MERGE);
+ ydtNode = ydtNode.getFirstChild();
+
+ validateNodeContents(ydtNode, "augment4", DELETE);
+ ydtNode = ydtNode.getFirstChild();
+ validateLeafContents(ydtNode, "value4", "4");
+ ydtNode = ydtNode.getParent();
+ ydtNode = ydtNode.getNextSibling();
+
+ validateNodeContents(ydtNode, "augment5", MERGE);
+ ydtNode = ydtNode.getFirstChild();
+
+ validateLeafContents(ydtNode, "leaf6", "6");
+ ydtNode = ydtNode.getNextSibling();
+
+ validateLeafContents(ydtNode, "value5", "5");
+ ydtNode = ydtNode.getParent();
+ ydtNode = ydtNode.getNextSibling();
+
+ validateNodeContents(ydtNode, "augment6", DELETE);
+ ydtNode = ydtNode.getFirstChild();
+ validateLeafContents(ydtNode, "value6", "6");
+ ydtNode = ydtNode.getParent();
+ ydtNode = ydtNode.getNextSibling();
+
+ validateLeafContents(ydtNode, "value3", "3");
+ ydtNode = ydtNode.getParent();
+ ydtNode = ydtNode.getNextSibling();
+ validateLeafContents(ydtNode, "augment3leaf", "3");
+
+ ydtNode = ydtNode.getParent();
+
+ ydtNode = ydtNode.getNextSibling();
+ validateLeafListContents(ydtNode, A2L, valueSet);
+
+ ydtNode = ydtNode.getParent();
+
+ ydtNode = ydtNode.getNextSibling();
+ validateNodeContents(ydtNode, "supporting-network", MERGE);
+ ydtNode = ydtNode.getFirstChild();
+ validateLeafContents(ydtNode, "network-ref", "network2");
+ ydtNode = ydtNode.getParent();
+
+ ydtNode = ydtNode.getNextSibling();
+ validateNodeContents(ydtNode, "node", MERGE);
+ ydtNode = ydtNode.getFirstChild();
+ validateLeafContents(ydtNode, "node-id", "node1");
+ ydtNode = ydtNode.getNextSibling();
+
+ //Inside termination-point
+ validateNodeContents(ydtNode, "t-point", MERGE);
+ ydtNode = ydtNode.getFirstChild();
+ validateLeafContents(ydtNode, "tp-id", "tp_id1");
+ ydtNode = ydtNode.getNextSibling();
+
+ validateTerminationPointAugment(ydtNode);
+ }
+
+ /**
+ * Validates the termination point node in given built ydt.
+ */
+ private void validateTerminationPointAugment(YdtNode ydtNode) {
+
+ //Inside supporting-termination-point
+ validateNodeContents(ydtNode, STP, MERGE);
+ ydtNode = ydtNode.getFirstChild();
+ validateLeafContents(ydtNode, "network-ref", "network-ref");
+ ydtNode = ydtNode.getNextSibling();
+ validateLeafContents(ydtNode, "node-ref", "node-ref");
+ ydtNode = ydtNode.getNextSibling();
+ validateLeafContents(ydtNode, "tp-ref", "tp-ref");
+
+ ydtNode = ydtNode.getNextSibling();
+ validateNodeContents(ydtNode, "augment1", MERGE);
+ ydtNode = ydtNode.getFirstChild();
+ validateLeafContents(ydtNode, "value1", "1");
+ ydtNode = ydtNode.getParent();
+
+ ydtNode = ydtNode.getNextSibling();
+ validateLeafContents(ydtNode, "augment1-leaf", "1");
+
+ ydtNode = ydtNode.getNextSibling();
+ validateNodeContents(ydtNode, "augment2", MERGE);
+ ydtNode = ydtNode.getFirstChild();
+
+ validateNodeContents(ydtNode, "augment3", MERGE);
+ ydtNode = ydtNode.getFirstChild();
+ validateLeafContents(ydtNode, "value3", "3");
+ ydtNode = ydtNode.getParent();
+
+ ydtNode = ydtNode.getNextSibling();
+ validateLeafContents(ydtNode, "augment4leaf", "4");
+
+ ydtNode = ydtNode.getNextSibling();
+ validateLeafContents(ydtNode, "value2", "2");
+ ydtNode = ydtNode.getParent();
+ ydtNode = ydtNode.getNextSibling();
+ validateLeafListContents(ydtNode, A2L, valueSet);
+
+ ydtNode = ydtNode.getNextSibling();
+ validateLeafContents(ydtNode, "augment2leaf", "2");
+
+ ydtNode = ydtNode.getParent();
+ ydtNode = ydtNode.getParent();
+
+ ydtNode = ydtNode.getNextSibling();
+ validateNodeContents(ydtNode, "supporting-node", MERGE);
+ ydtNode = ydtNode.getFirstChild();
+ validateLeafContents(ydtNode, "network-ref", "network3");
+ ydtNode = ydtNode.getNextSibling();
+ validateLeafContents(ydtNode, "node-ref", "network4");
+
+ ydtNode = ydtNode.getParent().getParent();
+
+ ydtNode = ydtNode.getNextSibling();
+ validateLeafContents(ydtNode, "link-id", "id1");
+ ydtNode = ydtNode.getParent().getParent();
+
+ ydtNode = ydtNode.getNextSibling();
+ validateNodeContents(ydtNode, "networks-state", MERGE);
+ ydtNode = ydtNode.getFirstChild();
+ validateNodeContents(ydtNode, "network", MERGE);
+ ydtNode = ydtNode.getFirstChild();
+ validateLeafContents(ydtNode, "network-ref", "network5");
+ ydtNode = ydtNode.getNextSibling();
+ validateLeafContents(ydtNode, "server-provided", "true");
+ }
+
+ /**
+ * Validates the given built ydt application tree.
+ */
+ private void validateAppTree(YangRequestWorkBench ydtBuilder) {
+
+ // Assign root node to ydtNode for validating purpose.
+ YdtAppContext ydtAppContext = ydtBuilder.getAppRootNode();
+ // Logical root node does not have operation type
+ validateAppLogicalNodeContents(ydtAppContext);
+ ydtAppContext = ydtAppContext.getFirstChild();
+ validateAppModuleNodeContents(ydtAppContext, IETF, BOTH);
+ ydtAppContext = ydtAppContext.getFirstChild();
+
+ //Inside link node
+ validateAppNodeContents(ydtAppContext, AUG1, TOPONS, BOTH);
+ ydtAppContext = ydtAppContext.getFirstChild();
+ validateAppNodeContents(ydtAppContext, AUG3, A1, OTHER_EDIT);
+ assertNull(ydtAppContext.getFirstChild());
+ assertNull(ydtAppContext.getPreviousSibling());
+ ydtAppContext = ydtAppContext.getNextSibling();
+ validateAppNodeContents(ydtAppContext, AUG3, A2, BOTH);
+
+ ydtAppContext = ydtAppContext.getFirstChild();
+ validateAppNodeContents(ydtAppContext, AUG5, A5, DELETE_ONLY);
+
+ ydtAppContext = ydtAppContext.getFirstChild();
+ validateAppNodeContents(ydtAppContext, AUG9, A6, DELETE_ONLY);
+ ydtAppContext = ydtAppContext.getParent();
+
+ ydtAppContext = ydtAppContext.getNextSibling();
+ validateAppNodeContents(ydtAppContext, AUG5, A3, BOTH);
+
+ ydtAppContext = ydtAppContext.getFirstChild();
+ validateAppNodeContents(ydtAppContext, AUG7, A4, DELETE_ONLY);
+
+ ydtAppContext = ydtAppContext.getNextSibling();
+ validateAppNodeContents(ydtAppContext, AUG7, A5, OTHER_EDIT);
+
+ ydtAppContext = ydtAppContext.getFirstChild();
+ validateAppNodeContents(ydtAppContext, AUG8, A6, OTHER_EDIT);
+ ydtAppContext = ydtAppContext.getParent();
+
+ ydtAppContext = ydtAppContext.getNextSibling();
+ validateAppNodeContents(ydtAppContext, AUG7, A6, DELETE_ONLY);
+
+ ydtAppContext = ydtAppContext.getParent();
+ ydtAppContext = ydtAppContext.getParent();
+ ydtAppContext = ydtAppContext.getParent();
+
+ ydtAppContext = ydtAppContext.getNextSibling();
+
+ validateAppNodeContents(ydtAppContext, AUG2, TOPONS, OTHER_EDIT);
+ ydtAppContext = ydtAppContext.getFirstChild();
+ validateAppNodeContents(ydtAppContext, AUG4, A1, OTHER_EDIT);
+ assertNull(ydtAppContext.getFirstChild());
+ assertNull(ydtAppContext.getPreviousSibling());
+ ydtAppContext = ydtAppContext.getNextSibling();
+ validateAppNodeContents(ydtAppContext, AUG4, A2, OTHER_EDIT);
+ assertNull(ydtAppContext.getNextSibling());
+ ydtAppContext = ydtAppContext.getFirstChild();
+ validateAppNodeContents(ydtAppContext, AUG6, A3, OTHER_EDIT);
+
+ ydtAppContext = ydtAppContext.getNextSibling();
+ validateAppNodeContents(ydtAppContext, AUG6, A4, OTHER_EDIT);
+ assertNull(ydtAppContext.getFirstChild());
+ assertNull(ydtAppContext.getNextSibling());
+ }
+}
diff --git a/apps/yms/app/src/test/java/org/onosproject/yms/app/ydt/FoodArenaTest.java b/apps/yms/app/src/test/java/org/onosproject/yms/app/ydt/FoodArenaTest.java
new file mode 100644
index 0000000..7f058a9
--- /dev/null
+++ b/apps/yms/app/src/test/java/org/onosproject/yms/app/ydt/FoodArenaTest.java
@@ -0,0 +1,73 @@
+/*
+ * 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.yms.app.ydt;
+
+import org.junit.Test;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+import static org.onosproject.yms.app.ydt.YdtTestUtils.foodArenaYdt;
+import static org.onosproject.yms.app.ydt.YdtTestUtils.validateLeafContents;
+import static org.onosproject.yms.app.ydt.YdtTestUtils.validateNodeContents;
+import static org.onosproject.yms.app.ydt.YdtTestUtils.walkINTree;
+import static org.onosproject.yms.ydt.YdtContextOperationType.MERGE;
+
+public class FoodArenaTest {
+
+ // Logger list is used for walker testing.
+ private final List<String> logger = new ArrayList<>();
+
+ private static final String[] EXPECTED = {
+ "Entry Node is foodarena.",
+ "Entry Node is food.",
+ "Entry Node is food.",
+ "Entry Node is chocolate.",
+ "Exit Node is chocolate.",
+ "Exit Node is food.",
+ "Exit Node is food.",
+ "Exit Node is foodarena."
+ };
+
+ /**
+ * Creates and validates food arena ydt.
+ */
+ @Test
+ public void foodArenaTest() throws IOException {
+
+ YangRequestWorkBench ydtBuilder = foodArenaYdt();
+ validateTree(ydtBuilder);
+ walkINTree(ydtBuilder, EXPECTED);
+ }
+
+ /**
+ * Validates the given built ydt.
+ */
+ private void validateTree(YangRequestWorkBench ydtBuilder) {
+ // Assign root node to ydtNode for validating purpose.
+ YdtNode ydtNode = (YdtNode) ydtBuilder.getRootNode();
+ // Logical root node does not have operation type
+ validateNodeContents(ydtNode, "foodarena", null);
+ ydtNode = ydtNode.getFirstChild();
+ validateNodeContents(ydtNode, "food", MERGE);
+ ydtNode = ydtNode.getFirstChild();
+ validateNodeContents(ydtNode, "food", MERGE);
+ ydtNode = ydtNode.getFirstChild();
+ validateLeafContents(ydtNode, "chocolate", "dark");
+ }
+}
diff --git a/apps/yms/app/src/test/java/org/onosproject/yms/app/ydt/IetfNetworkTest.java b/apps/yms/app/src/test/java/org/onosproject/yms/app/ydt/IetfNetworkTest.java
new file mode 100644
index 0000000..0befc4d
--- /dev/null
+++ b/apps/yms/app/src/test/java/org/onosproject/yms/app/ydt/IetfNetworkTest.java
@@ -0,0 +1,120 @@
+/*
+ * 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.yms.app.ydt;
+
+import org.junit.Test;
+
+import static org.onosproject.yms.app.ydt.YdtTestUtils.ietfNetwork1Ydt;
+import static org.onosproject.yms.app.ydt.YdtTestUtils.validateLeafContents;
+import static org.onosproject.yms.app.ydt.YdtTestUtils.validateNodeContents;
+import static org.onosproject.yms.app.ydt.YdtTestUtils.walkINTree;
+import static org.onosproject.yms.ydt.YdtContextOperationType.MERGE;
+
+public class IetfNetworkTest {
+
+ private static final String[] EXPECTED = {
+ "Entry Node is yms-ietf-network.",
+ "Entry Node is yms-ietf-network.",
+ "Entry Node is networks.",
+ "Entry Node is network.",
+ "Entry Node is network-id.",
+ "Exit Node is network-id.",
+ "Entry Node is supporting-network.",
+ "Entry Node is network-ref.",
+ "Exit Node is network-ref.",
+ "Exit Node is supporting-network.",
+ "Entry Node is node.",
+ "Entry Node is node-id.",
+ "Exit Node is node-id.",
+ "Entry Node is supporting-node.",
+ "Entry Node is network-ref.",
+ "Exit Node is network-ref.",
+ "Entry Node is node-ref.",
+ "Exit Node is node-ref.",
+ "Exit Node is supporting-node.",
+ "Exit Node is node.",
+ "Exit Node is network.",
+ "Exit Node is networks.",
+ "Entry Node is networks-state.",
+ "Entry Node is network.",
+ "Entry Node is network-ref.",
+ "Exit Node is network-ref.",
+ "Entry Node is server-provided.",
+ "Exit Node is server-provided.",
+ "Exit Node is network.",
+ "Exit Node is networks-state.",
+ "Exit Node is yms-ietf-network.",
+ "Exit Node is yms-ietf-network."
+ };
+
+ /**
+ * Creates and validates ietf network ydt.
+ */
+ @Test
+ public void ietfNetwork1Test() {
+ YangRequestWorkBench ydtBuilder = ietfNetwork1Ydt();
+ validateTree(ydtBuilder);
+ walkINTree(ydtBuilder, EXPECTED);
+ }
+
+ /**
+ * Validates the given built ydt.
+ */
+ private void validateTree(YangRequestWorkBench ydtBuilder) {
+
+ // Assign root node to ydtNode for validating purpose.
+ YdtNode ydtNode = (YdtNode) ydtBuilder.getRootNode();
+ // Logical root node does not have operation type
+ validateNodeContents(ydtNode, "yms-ietf-network", null);
+ ydtNode = ydtNode.getFirstChild();
+ validateNodeContents(ydtNode, "yms-ietf-network", MERGE);
+ ydtNode = ydtNode.getFirstChild();
+ validateNodeContents(ydtNode, "networks", MERGE);
+ ydtNode = ydtNode.getFirstChild();
+ validateNodeContents(ydtNode, "network", MERGE);
+ ydtNode = ydtNode.getFirstChild();
+ validateLeafContents(ydtNode, "network-id", "network1");
+
+ ydtNode = ydtNode.getNextSibling();
+ validateNodeContents(ydtNode, "supporting-network", MERGE);
+ ydtNode = ydtNode.getFirstChild();
+ validateLeafContents(ydtNode, "network-ref", "network2");
+ ydtNode = ydtNode.getParent();
+
+ ydtNode = ydtNode.getNextSibling();
+ validateNodeContents(ydtNode, "node", MERGE);
+ ydtNode = ydtNode.getFirstChild();
+ validateLeafContents(ydtNode, "node-id", "node1");
+ ydtNode = ydtNode.getNextSibling();
+ validateNodeContents(ydtNode, "supporting-node", MERGE);
+ ydtNode = ydtNode.getFirstChild();
+ validateLeafContents(ydtNode, "network-ref", "network3");
+ ydtNode = ydtNode.getNextSibling();
+ validateLeafContents(ydtNode, "node-ref", "network4");
+
+ ydtNode = ydtNode.getParent().getParent().getParent().getParent();
+
+ ydtNode = ydtNode.getNextSibling();
+ validateNodeContents(ydtNode, "networks-state", MERGE);
+ ydtNode = ydtNode.getFirstChild();
+ validateNodeContents(ydtNode, "network", MERGE);
+ ydtNode = ydtNode.getFirstChild();
+ validateLeafContents(ydtNode, "network-ref", "network5");
+ ydtNode = ydtNode.getNextSibling();
+ validateLeafContents(ydtNode, "server-provided", "true");
+ }
+}
diff --git a/apps/yms/app/src/test/java/org/onosproject/yms/app/ydt/IetfTopologyTest.java b/apps/yms/app/src/test/java/org/onosproject/yms/app/ydt/IetfTopologyTest.java
new file mode 100644
index 0000000..c757b0c
--- /dev/null
+++ b/apps/yms/app/src/test/java/org/onosproject/yms/app/ydt/IetfTopologyTest.java
@@ -0,0 +1,268 @@
+/*
+ * 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.yms.app.ydt;
+
+import org.junit.Test;
+
+import static org.onosproject.yms.app.ydt.YdtAppNodeOperationType.OTHER_EDIT;
+import static org.onosproject.yms.app.ydt.YdtTestConstants.AUG1;
+import static org.onosproject.yms.app.ydt.YdtTestConstants.AUG2;
+import static org.onosproject.yms.app.ydt.YdtTestConstants.IETF;
+import static org.onosproject.yms.app.ydt.YdtTestConstants.SLINK;
+import static org.onosproject.yms.app.ydt.YdtTestConstants.STP;
+import static org.onosproject.yms.app.ydt.YdtTestConstants.TOPONS;
+import static org.onosproject.yms.app.ydt.YdtTestUtils.ietfNetworkTopologyYdt;
+import static org.onosproject.yms.app.ydt.YdtTestUtils.validateAppLogicalNodeContents;
+import static org.onosproject.yms.app.ydt.YdtTestUtils.validateAppModuleNodeContents;
+import static org.onosproject.yms.app.ydt.YdtTestUtils.validateAppNodeContents;
+import static org.onosproject.yms.app.ydt.YdtTestUtils.validateLeafContents;
+import static org.onosproject.yms.app.ydt.YdtTestUtils.validateNodeContents;
+import static org.onosproject.yms.app.ydt.YdtTestUtils.walkINTree;
+import static org.onosproject.yms.ydt.YdtContextOperationType.MERGE;
+
+public class IetfTopologyTest {
+
+ private static final String[] EXPECTED = {
+ "Entry Node is yms-ietf-network.",
+ "Entry Node is yms-ietf-network.",
+ "Entry Node is networks.",
+ "Entry Node is network.",
+ "Entry Node is network-id.",
+ "Exit Node is network-id.",
+ "Entry Node is link.",
+ "Entry Node is link-id.",
+ "Exit Node is link-id.",
+ "Entry Node is source.",
+ "Entry Node is source-node.",
+ "Exit Node is source-node.",
+ "Entry Node is source-tp.",
+ "Exit Node is source-tp.",
+ "Exit Node is source.",
+
+ "Entry Node is destination.",
+ "Entry Node is dest-node.",
+ "Exit Node is dest-node.",
+ "Entry Node is dest-tp.",
+ "Exit Node is dest-tp.",
+ "Exit Node is destination.",
+
+ "Entry Node is supporting-link.",
+ "Entry Node is network-ref.",
+ "Exit Node is network-ref.",
+ "Entry Node is link-ref.",
+ "Exit Node is link-ref.",
+ "Exit Node is supporting-link.",
+
+ "Entry Node is supporting-link.",
+ "Entry Node is network-ref.",
+ "Exit Node is network-ref.",
+ "Entry Node is link-ref.",
+ "Exit Node is link-ref.",
+ "Exit Node is supporting-link.",
+ "Exit Node is link.",
+
+ "Entry Node is supporting-network.",
+ "Entry Node is network-ref.",
+ "Exit Node is network-ref.",
+ "Exit Node is supporting-network.",
+ "Entry Node is node.",
+ "Entry Node is node-id.",
+ "Exit Node is node-id.",
+ "Entry Node is t-point.",
+ "Entry Node is tp-id.",
+ "Exit Node is tp-id.",
+
+ "Entry Node is supporting-termination-point.",
+ "Entry Node is network-ref.",
+ "Exit Node is network-ref.",
+ "Entry Node is node-ref.",
+ "Exit Node is node-ref.",
+ "Entry Node is tp-ref.",
+ "Exit Node is tp-ref.",
+
+ "Exit Node is supporting-termination-point.",
+ "Exit Node is t-point.",
+ "Entry Node is supporting-node.",
+ "Entry Node is network-ref.",
+ "Exit Node is network-ref.",
+ "Entry Node is node-ref.",
+ "Exit Node is node-ref.",
+ "Exit Node is supporting-node.",
+
+ "Exit Node is node.",
+ // last augmented sibling in network
+ "Entry Node is link-id.",
+ "Exit Node is link-id.",
+
+ "Exit Node is network.",
+ "Exit Node is networks.",
+ "Entry Node is networks-state.",
+ "Entry Node is network.",
+ "Entry Node is network-ref.",
+ "Exit Node is network-ref.",
+ "Entry Node is server-provided.",
+ "Exit Node is server-provided.",
+ "Exit Node is network.",
+ "Exit Node is networks-state.",
+ "Exit Node is yms-ietf-network.",
+ "Exit Node is yms-ietf-network."
+ };
+
+ /**
+ * Creates and validates ietf network ydt.
+ */
+ @Test
+ public void ietfNetwork1Test() {
+ YangRequestWorkBench ydtBuilder = ietfNetworkTopologyYdt();
+ validateTree(ydtBuilder);
+ validateAppTree(ydtBuilder);
+ walkINTree(ydtBuilder, EXPECTED);
+ }
+
+ /**
+ * Validates the given built ydt.
+ */
+ private void validateTree(YangRequestWorkBench ydtBuilder) {
+
+ // Assign root node to ydtNode for validating purpose.
+ YdtNode ydtNode = (YdtNode) ydtBuilder.getRootNode();
+ // Logical root node does not have operation type
+ validateNodeContents(ydtNode, "yms-ietf-network", null);
+ ydtNode = ydtNode.getFirstChild();
+ validateNodeContents(ydtNode, "yms-ietf-network", MERGE);
+ ydtNode = ydtNode.getFirstChild();
+ validateNodeContents(ydtNode, "networks", MERGE);
+ ydtNode = ydtNode.getFirstChild();
+ validateNodeContents(ydtNode, "network", MERGE);
+ ydtNode = ydtNode.getFirstChild();
+ validateLeafContents(ydtNode, "network-id", "network1");
+ ydtNode = ydtNode.getNextSibling();
+
+ // Validating augmented child
+ validateNodeContents(ydtNode, "link", MERGE);
+ ydtNode = ydtNode.getFirstChild();
+ validateLeafContents(ydtNode, "link-id", "id1");
+ ydtNode = ydtNode.getNextSibling();
+
+ // Inside source node
+ validateNodeContents(ydtNode, "source", MERGE);
+ ydtNode = ydtNode.getFirstChild();
+ validateLeafContents(ydtNode, "source-node", "source1");
+ ydtNode = ydtNode.getNextSibling();
+ validateLeafContents(ydtNode, "source-tp", "source2");
+ ydtNode = ydtNode.getParent();
+ ydtNode = ydtNode.getNextSibling();
+
+ //Inside destination node
+ validateNodeContents(ydtNode, "destination", MERGE);
+ ydtNode = ydtNode.getFirstChild();
+ validateLeafContents(ydtNode, "dest-node", "dest1");
+ ydtNode = ydtNode.getNextSibling();
+ validateLeafContents(ydtNode, "dest-tp", "dest2");
+ ydtNode = ydtNode.getParent();
+ ydtNode = ydtNode.getNextSibling();
+
+ //Inside supporting links
+ validateNodeContents(ydtNode, SLINK, MERGE);
+ ydtNode = ydtNode.getFirstChild();
+ validateLeafContents(ydtNode, "network-ref", "network1");
+ ydtNode = ydtNode.getNextSibling();
+ validateLeafContents(ydtNode, "link-ref", "id2");
+ ydtNode = ydtNode.getParent();
+ ydtNode = ydtNode.getNextSibling();
+
+ //Inside another supporting links instance
+ validateNodeContents(ydtNode, SLINK, MERGE);
+ ydtNode = ydtNode.getFirstChild();
+ validateLeafContents(ydtNode, "network-ref", "network2");
+ ydtNode = ydtNode.getNextSibling();
+ validateLeafContents(ydtNode, "link-ref", "id3");
+ ydtNode = ydtNode.getParent();
+ ydtNode = ydtNode.getParent();
+
+ ydtNode = ydtNode.getNextSibling();
+ validateNodeContents(ydtNode, "supporting-network", MERGE);
+ ydtNode = ydtNode.getFirstChild();
+ validateLeafContents(ydtNode, "network-ref", "network2");
+ ydtNode = ydtNode.getParent();
+
+ ydtNode = ydtNode.getNextSibling();
+ validateNodeContents(ydtNode, "node", MERGE);
+ ydtNode = ydtNode.getFirstChild();
+ validateLeafContents(ydtNode, "node-id", "node1");
+ ydtNode = ydtNode.getNextSibling();
+
+ //Inside termination-point
+ validateNodeContents(ydtNode, "t-point", MERGE);
+ ydtNode = ydtNode.getFirstChild();
+ validateLeafContents(ydtNode, "tp-id", "tp_id1");
+ ydtNode = ydtNode.getNextSibling();
+
+ //Inside supporting-termination-point
+ validateNodeContents(ydtNode, STP, MERGE);
+ ydtNode = ydtNode.getFirstChild();
+ validateLeafContents(ydtNode, "network-ref", "network-ref");
+ ydtNode = ydtNode.getNextSibling();
+ validateLeafContents(ydtNode, "node-ref", "node-ref");
+ ydtNode = ydtNode.getNextSibling();
+ validateLeafContents(ydtNode, "tp-ref", "tp-ref");
+ ydtNode = ydtNode.getParent();
+ ydtNode = ydtNode.getParent();
+
+ ydtNode = ydtNode.getNextSibling();
+ validateNodeContents(ydtNode, "supporting-node", MERGE);
+ ydtNode = ydtNode.getFirstChild();
+ validateLeafContents(ydtNode, "network-ref", "network3");
+ ydtNode = ydtNode.getNextSibling();
+ validateLeafContents(ydtNode, "node-ref", "network4");
+
+ ydtNode = ydtNode.getParent().getParent();
+
+ ydtNode = ydtNode.getNextSibling();
+ validateLeafContents(ydtNode, "link-id", "id1");
+ ydtNode = ydtNode.getParent().getParent();
+
+ ydtNode = ydtNode.getNextSibling();
+ validateNodeContents(ydtNode, "networks-state", MERGE);
+ ydtNode = ydtNode.getFirstChild();
+ validateNodeContents(ydtNode, "network", MERGE);
+ ydtNode = ydtNode.getFirstChild();
+ validateLeafContents(ydtNode, "network-ref", "network5");
+ ydtNode = ydtNode.getNextSibling();
+ validateLeafContents(ydtNode, "server-provided", "true");
+ }
+
+ /**
+ * Validates the given built ydt application tree.
+ */
+ private void validateAppTree(YangRequestWorkBench ydtBuilder) {
+
+ // Assign root node to ydtNode for validating purpose.
+ YdtAppContext ydtAppContext = ydtBuilder.getAppRootNode();
+ // Logical root node does not have operation type
+ validateAppLogicalNodeContents(ydtAppContext);
+ ydtAppContext = ydtAppContext.getFirstChild();
+ validateAppModuleNodeContents(ydtAppContext, IETF, OTHER_EDIT);
+ ydtAppContext = ydtAppContext.getFirstChild();
+
+ //Inside link node
+ validateAppNodeContents(ydtAppContext, AUG1, TOPONS, OTHER_EDIT);
+ ydtAppContext = ydtAppContext.getNextSibling();
+
+ validateAppNodeContents(ydtAppContext, AUG2, TOPONS, OTHER_EDIT);
+ }
+}
diff --git a/apps/yms/app/src/test/java/org/onosproject/yms/app/ydt/ListTest.java b/apps/yms/app/src/test/java/org/onosproject/yms/app/ydt/ListTest.java
new file mode 100644
index 0000000..711f882
--- /dev/null
+++ b/apps/yms/app/src/test/java/org/onosproject/yms/app/ydt/ListTest.java
@@ -0,0 +1,450 @@
+/*
+ * 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.yms.app.ydt;
+
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+import org.onosproject.yangutils.datamodel.utils.builtindatatype.DataTypeException;
+import org.onosproject.yms.app.ydt.exceptions.YdtException;
+
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import static org.junit.Assert.assertEquals;
+import static org.onosproject.yms.app.ydt.YdtTestConstants.E_LEAF;
+import static org.onosproject.yms.app.ydt.YdtTestConstants.E_LIST;
+import static org.onosproject.yms.app.ydt.YdtTestConstants.E_TOPARENT;
+import static org.onosproject.yms.app.ydt.YdtTestConstants.INV;
+import static org.onosproject.yms.app.ydt.YdtTestConstants.LISTNS;
+import static org.onosproject.yms.app.ydt.YdtTestConstants.LWC;
+import static org.onosproject.yms.app.ydt.YdtTestUtils.getTestYdtBuilder;
+import static org.onosproject.yms.app.ydt.YdtTestUtils.getYdtBuilder;
+import static org.onosproject.yms.app.ydt.YdtTestUtils.listWithContainer1Ydt;
+import static org.onosproject.yms.app.ydt.YdtTestUtils.listWithContainer2Ydt;
+import static org.onosproject.yms.app.ydt.YdtTestUtils.listWithContainerYdt;
+import static org.onosproject.yms.app.ydt.YdtTestUtils.listWithoutContainerYdt;
+import static org.onosproject.yms.app.ydt.YdtTestUtils.validateLeafContents;
+import static org.onosproject.yms.app.ydt.YdtTestUtils.validateLeafListContents;
+import static org.onosproject.yms.app.ydt.YdtTestUtils.validateNodeContents;
+import static org.onosproject.yms.app.ydt.YdtTestUtils.walkINTree;
+import static org.onosproject.yms.ydt.YdtContextOperationType.MERGE;
+
+public class ListTest {
+
+ @Rule
+ public ExpectedException thrown = ExpectedException.none();
+
+ private Set<String> valueSet = new HashSet();
+
+ private static final String[] ERROR = {
+ "rootlist is missing some of the keys of listwithcontainer.",
+ "Duplicate entry with name invalid.",
+ "Some of the key elements are not unique in listwithcontainer.",
+ "Too few key parameters in listwithcontainer." +
+ " Expected 2; actual 1.",
+ "Too many key parameters in listwithcontainer." +
+ " Expected 2; actual 3.",
+ "Application with name \"" + "invalid\" doesn't exist.",
+ "Too many instances of listwithcontainer. Expected maximum " +
+ "instances 3.",
+ "Duplicate entry found under invalidinterval leaf-list node.",
+ "YANG file error : Input value \"string\" is not a valid uint16."
+ };
+
+ private static final String[] EXPECTED = {
+ "Entry Node is list.",
+ "Entry Node is rootlist.",
+ "Entry Node is listwithoutcontainer.",
+ "Entry Node is invalidinterval.",
+ "Exit Node is invalidinterval.",
+ "Exit Node is listwithoutcontainer.",
+ "Exit Node is rootlist.",
+ "Exit Node is list."
+ };
+
+ List<String> keysValueList = new ArrayList<>();
+
+ /**
+ * Creates and validates rootlist module with listwithoutcontainer node.
+ */
+ @Test
+ public void listwithoutcontainerTest() throws YdtException {
+ YangRequestWorkBench ydtBuilder = listWithoutContainerYdt();
+ validateTree(ydtBuilder);
+ // walker test
+ walkINTree(ydtBuilder, EXPECTED);
+ }
+
+ /**
+ * Creates and validates rootlist module with listwithcontainer node
+ * using addMultiInstanceChild interface for adding multi instance node.
+ */
+ @Test
+ public void listwithcontainerTest() throws YdtException {
+ YangRequestWorkBench ydtBuilder = listWithContainerYdt();
+ validateListwithcontainerTree(ydtBuilder);
+ }
+
+ /**
+ * Creates and validates rootlist module with listwithcontainer
+ * node using addChild interface for adding multi instance node.
+ */
+ @Test
+ public void listwithcontainer1Test() throws YdtException {
+ YangRequestWorkBench ydtBuilder = listWithContainer1Ydt();
+ validateListwithcontainerTree(ydtBuilder);
+ }
+
+ /**
+ * Creates and validates rootlist module with multiple instances of
+ * listwithcontainer node using addMultiInstanceChild interface for adding
+ * multi instance node.
+ */
+ @Test
+ public void listwithcontainer2Test() throws YdtException {
+ YangRequestWorkBench ydtBuilder = listWithContainer2Ydt();
+ }
+
+ /**
+ * Validates the given built ydt.
+ */
+ private void validateTree(YangRequestWorkBench ydtBuilder) {
+
+ // assign root node to ydtNode for validating purpose.
+ YdtNode ydtNode = (YdtNode) ydtBuilder.getRootNode();
+ // Logical root node does not have operation type
+ validateNodeContents(ydtNode, "list", null);
+
+ ydtNode = ydtNode.getFirstChild();
+ validateNodeContents(ydtNode, "rootlist", MERGE);
+ ydtNode = ydtNode.getFirstChild();
+ validateNodeContents(ydtNode, "listwithoutcontainer", MERGE);
+ ydtNode = ydtNode.getFirstChild();
+ validateLeafContents(ydtNode, INV, "12");
+ }
+
+ /**
+ * Validates the given list with container built ydt.
+ */
+ private void validateListwithcontainerTree(
+ YangRequestWorkBench ydtBuilder) {
+
+ valueSet.add("1");
+ valueSet.add("2");
+ // assign root node to ydtNode for validating purpose.
+ YdtNode ydtNode = (YdtNode) ydtBuilder.getRootNode();
+ // Logical root node does not have operation type
+ validateNodeContents(ydtNode, "list", null);
+
+ ydtNode = ydtNode.getFirstChild();
+ validateNodeContents(ydtNode, "rootlist", MERGE);
+ ydtNode = ydtNode.getFirstChild();
+ validateNodeContents(ydtNode, LWC, MERGE);
+ ydtNode = ydtNode.getFirstChild();
+ validateLeafContents(ydtNode, "invalid", "12");
+ ydtNode = ydtNode.getNextSibling();
+ validateLeafContents(ydtNode, "invalid1", "12");
+ ydtNode = ydtNode.getNextSibling();
+ validateLeafListContents(ydtNode, INV, valueSet);
+ ydtNode = ydtNode.getNextSibling();
+ validateNodeContents(ydtNode, "interface", MERGE);
+ ydtNode = ydtNode.getFirstChild();
+ validateLeafContents(ydtNode, INV, "12");
+ ydtNode = ydtNode.getNextSibling();
+ validateLeafContents(ydtNode, "invalid", "121");
+ }
+
+ /**
+ * Tests the negative error scenario when application name for ydt is
+ * invalid.
+ */
+ @Test
+ public void negative1Test() {
+ thrown.expect(YdtException.class);
+ thrown.expectMessage(ERROR[5]);
+ getYdtBuilder("list", "invalid", "ydt.invalid", MERGE);
+ }
+
+ /**
+ * Tests the negative error scenario when list node is not having all
+ * key elements.
+ */
+ @Test
+ public void negative2Test() throws YdtException {
+
+ YangRequestWorkBench ydtBuilder = getTestYdtBuilder(LISTNS);
+ ydtBuilder.addChild(LWC, LISTNS);
+ ydtBuilder.addLeaf("invalid", LISTNS, "12");
+ ydtBuilder.traverseToParent();
+
+ traversToParentErrorMsgValidator(ydtBuilder, ERROR[0]);
+ }
+
+ /**
+ * Tests the negative error scenario when duplicate entry of list node
+ * is created.
+ */
+ @Test
+ public void negative3Test() throws YdtException {
+ YangRequestWorkBench ydtBuilder = getTestYdtBuilder(LISTNS);
+ ydtBuilder.addChild(LWC, LISTNS);
+ ydtBuilder.addLeaf("invalid", LISTNS, "12");
+ ydtBuilder.traverseToParent();
+ leafErrorMsgValidator(ydtBuilder, "invalid", "12", ERROR[1]);
+ }
+
+ /**
+ * Tests the negative error scenario when key elements of list node
+ * are not unique.
+ */
+ @Test
+ public void negative4Test() throws YdtException {
+ YangRequestWorkBench ydtBuilder = getTestYdtBuilder(LISTNS);
+ ydtBuilder.addChild(LWC, LISTNS);
+ ydtBuilder.addLeaf("invalid", LISTNS, "12");
+ ydtBuilder.traverseToParent();
+ ydtBuilder.addLeaf("invalid1", LISTNS, "12");
+ ydtBuilder.traverseToParent();
+ ydtBuilder.traverseToParent();
+
+ ydtBuilder.addChild(LWC, LISTNS);
+ ydtBuilder.addLeaf("invalid", LISTNS, "12");
+ ydtBuilder.traverseToParent();
+ ydtBuilder.addLeaf("invalid1", LISTNS, "12");
+ ydtBuilder.traverseToParent();
+ ydtBuilder.traverseToParent();
+
+ traversToParentErrorMsgValidator(ydtBuilder, ERROR[2]);
+ }
+
+ /**
+ * Tests the negative error scenario when all key elements of list node
+ * are not supplied.
+ */
+ @Test
+ public void negative5Test() throws YdtException {
+ keysValueList.clear();
+ keysValueList.add("1");
+ keysValueList.add("2");
+ keysValueList.add("2");
+ YangRequestWorkBench ydtBuilder = getTestYdtBuilder(LISTNS);
+ listNodeErrorMsgValidator(ydtBuilder, keysValueList, ERROR[4]);
+
+ keysValueList.clear();
+ keysValueList.add("1");
+ ydtBuilder = getTestYdtBuilder(LISTNS);
+ listNodeErrorMsgValidator(ydtBuilder, keysValueList, ERROR[3]);
+ }
+
+ /**
+ * Tests the negative error scenario when instances of a list node are
+ * created above the allowed limit.
+ */
+ @Test
+ public void negative6Test() throws YdtException {
+ keysValueList.clear();
+ keysValueList.add("1");
+ keysValueList.add("1");
+ YangRequestWorkBench ydtBuilder = getTestYdtBuilder(LISTNS);
+ ydtBuilder.addMultiInstanceChild(LWC, LISTNS, keysValueList, null);
+ ydtBuilder.traverseToParent();
+
+ ydtBuilder.addChild(LWC, LISTNS);
+ ydtBuilder.addLeaf("invalid", LISTNS, "12");
+ ydtBuilder.traverseToParent();
+ ydtBuilder.addLeaf("invalid1", LISTNS, "121");
+ ydtBuilder.traverseToParent();
+ ydtBuilder.traverseToParent();
+
+ ydtBuilder.addChild(LWC, LISTNS);
+ ydtBuilder.addLeaf("invalid", LISTNS, "12");
+ ydtBuilder.traverseToParent();
+ ydtBuilder.addLeaf("invalid1", LISTNS, "1211");
+ ydtBuilder.traverseToParent();
+ ydtBuilder.traverseToParent();
+
+ ydtBuilder.addChild(LWC, LISTNS);
+ ydtBuilder.addLeaf("invalid", LISTNS, "12");
+ ydtBuilder.traverseToParent();
+ ydtBuilder.addLeaf("invalid1", LISTNS, "21");
+ ydtBuilder.traverseToParent();
+ ydtBuilder.traverseToParent();
+ traversToParentErrorMsgValidator(ydtBuilder, ERROR[6]);
+ }
+
+ /**
+ * Tests the negative error scenario when list node is not having all
+ * key elements.
+ */
+ @Test
+ public void negative7Test() throws YdtException {
+ YangRequestWorkBench ydtBuilder = getTestYdtBuilder(LISTNS);
+ ydtBuilder.addChild(LWC, LISTNS);
+ traversToParentErrorMsgValidator(ydtBuilder, ERROR[0]);
+ }
+
+ /**
+ * Tests the negative error scenario when duplicate key entry is created
+ * inside leaf-list node.
+ */
+ @Test
+ public void negative8Test() throws YdtException {
+ YangRequestWorkBench ydtBuilder = getTestYdtBuilder(LISTNS);
+ ydtBuilder.addChild(LWC, LISTNS);
+ ydtBuilder.addLeaf("invalid", LISTNS, "12");
+ ydtBuilder.traverseToParent();
+ ydtBuilder.addLeaf("invalid1", LISTNS, "12");
+ ydtBuilder.traverseToParent();
+ ydtBuilder.addLeaf(INV, LISTNS, "12");
+ ydtBuilder.traverseToParent();
+ leafErrorMsgValidator(ydtBuilder, INV, "12", ERROR[7]);
+ }
+
+ /**
+ * Tests the negative error scenario when string is passed for uint16 type
+ * leaf node.
+ */
+ @Test
+ public void negative9Test() throws YdtException {
+ YangRequestWorkBench ydtBuilder = getTestYdtBuilder(LISTNS);
+ ydtBuilder.addChild(LWC, LISTNS);
+ ydtBuilder.addLeaf("invalid", LISTNS, "12");
+ ydtBuilder.traverseToParent();
+ ydtBuilder.addLeaf("invalid1", LISTNS, "12");
+ ydtBuilder.traverseToParent();
+ leafErrorMsgValidator(ydtBuilder, INV, "string", ERROR[8]);
+ }
+
+ /**
+ * Tests the negative error scenario when duplicate key entry created
+ * inside a leaf-list node.
+ */
+ @Test
+ public void negative10Test() throws YdtException {
+ valueSet.clear();
+ valueSet.add("1");
+ valueSet.add("2");
+ valueSet.add("12");
+ YangRequestWorkBench ydtBuilder = getTestYdtBuilder(LISTNS);
+ ydtBuilder.addChild(LWC, LISTNS);
+ ydtBuilder.addLeaf("invalid", LISTNS, "12");
+ ydtBuilder.traverseToParent();
+ ydtBuilder.addLeaf("invalid1", LISTNS, "12");
+ ydtBuilder.traverseToParent();
+ ydtBuilder.addLeaf(INV, LISTNS, "12");
+ ydtBuilder.traverseToParent();
+ thrown.expect(YdtException.class);
+ thrown.expectMessage(ERROR[7]);
+ ydtBuilder.addLeaf(INV, LISTNS, valueSet);
+ }
+
+ /**
+ * Tests the negative error scenario when string is passed for uint16 type
+ * key entry inside a leaf-list node.
+ */
+ @Test
+ public void negative11Test() throws YdtException {
+ valueSet.clear();
+ valueSet.add("string");
+ YangRequestWorkBench ydtBuilder = getTestYdtBuilder(LISTNS);
+ ydtBuilder.addChild(LWC, LISTNS);
+ ydtBuilder.addLeaf("invalid", LISTNS, "12");
+ ydtBuilder.traverseToParent();
+ ydtBuilder.addLeaf("invalid1", LISTNS, "12");
+ ydtBuilder.traverseToParent();
+ ydtBuilder.addLeaf(INV, LISTNS, "12");
+ ydtBuilder.traverseToParent();
+ thrown.expect(DataTypeException.class);
+ thrown.expectMessage(ERROR[8]);
+ ydtBuilder.addLeaf(INV, LISTNS, valueSet);
+ }
+
+ /**
+ * Validate the error message obtained by adding multi instance node in
+ * current context against the given error string.
+ *
+ * @param bldr ydt builder
+ * @param list list of key values
+ * @param error error string
+ */
+ private void listNodeErrorMsgValidator(YangRequestWorkBench bldr,
+ List<String> list, String error) {
+ /*
+ * This try catch is explicitly written to use as utility in other
+ * test cases.
+ */
+ boolean isExpOccurred = false;
+ try {
+ bldr.addMultiInstanceChild(LWC, LISTNS, list, null);
+ } catch (YdtException e) {
+ isExpOccurred = true;
+ assertEquals(e.getMessage(), error);
+ }
+ assertEquals(E_LIST + LWC, isExpOccurred, true);
+ }
+
+ /**
+ * Validate the error message obtained by traversing back to parent of
+ * current context against the given error string.
+ *
+ * @param ydtBuilder ydt builder
+ * @param error error string
+ */
+ private void traversToParentErrorMsgValidator(
+ YangRequestWorkBench ydtBuilder, String error) {
+ /*
+ * This try catch is explicitly written to use as utility in other
+ * test cases.
+ */
+ boolean isExpOccurred = false;
+ try {
+ ydtBuilder.traverseToParent();
+ } catch (YdtException e) {
+ isExpOccurred = true;
+ assertEquals(e.getMessage(), error);
+ }
+ assertEquals(E_TOPARENT, isExpOccurred, true);
+ }
+
+ /**
+ * Validate the error message obtained by adding leaf node in
+ * current context against the given error string.
+ *
+ * @param bldr ydt builder
+ * @param name name of the leaf
+ * @param val leaf value
+ * @param error error string
+ */
+ private void leafErrorMsgValidator(
+ YangRequestWorkBench bldr, String name, String val, String error) {
+ /*
+ * This try catch is explicitly written to use as utility in other
+ * test cases.
+ */
+ boolean isExpOccurred = false;
+ try {
+ bldr.addLeaf(name, LISTNS, val);
+ } catch (YdtException e) {
+ isExpOccurred = true;
+ assertEquals(e.getMessage(), error);
+ }
+ assertEquals(E_LEAF + name, isExpOccurred, true);
+ }
+}
diff --git a/apps/yms/app/src/test/java/org/onosproject/yms/app/ydt/LogisticsManagerTest.java b/apps/yms/app/src/test/java/org/onosproject/yms/app/ydt/LogisticsManagerTest.java
new file mode 100644
index 0000000..a64c4c4
--- /dev/null
+++ b/apps/yms/app/src/test/java/org/onosproject/yms/app/ydt/LogisticsManagerTest.java
@@ -0,0 +1,179 @@
+/*
+ * 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.yms.app.ydt;
+
+import org.junit.Test;
+
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import static org.onosproject.yms.app.ydt.YdtTestUtils.logisticsManagerYdt;
+import static org.onosproject.yms.app.ydt.YdtTestUtils.validateLeafContents;
+import static org.onosproject.yms.app.ydt.YdtTestUtils.validateLeafListContents;
+import static org.onosproject.yms.app.ydt.YdtTestUtils.validateNodeContents;
+import static org.onosproject.yms.app.ydt.YdtTestUtils.walkINTree;
+import static org.onosproject.yms.ydt.YdtContextOperationType.MERGE;
+
+public class LogisticsManagerTest {
+
+ // Logger list is used for walker testing.
+ private final List<String> logger = new ArrayList<>();
+
+ private Set<String> valueSet = new HashSet();
+
+ private static final String[] EXPECTED = {
+ "Entry Node is logisticsmanager.",
+ "Entry Node is customssupervisor.",
+ "Entry Node is supervisor.",
+ "Exit Node is supervisor.",
+ "Exit Node is customssupervisor.",
+ "Entry Node is merchandisersupervisor.",
+ "Entry Node is supervisor.",
+ "Exit Node is supervisor.",
+ "Exit Node is merchandisersupervisor.",
+ "Entry Node is materialsupervisor.",
+ "Entry Node is supervisor.",
+ "Entry Node is name.",
+ "Exit Node is name.",
+ "Entry Node is departmentId.",
+ "Exit Node is departmentId.",
+ "Exit Node is supervisor.",
+ "Entry Node is supervisor.",
+ "Entry Node is name.",
+ "Exit Node is name.",
+ "Entry Node is departmentId.",
+ "Exit Node is departmentId.",
+ "Exit Node is supervisor.",
+ "Exit Node is materialsupervisor.",
+ "Entry Node is purchasingsupervisor.",
+ "Entry Node is supervisor.",
+ "Entry Node is purchasing-specialist.",
+ "Exit Node is purchasing-specialist.",
+ "Entry Node is support.",
+ "Exit Node is support.",
+ "Exit Node is supervisor.",
+ "Exit Node is purchasingsupervisor.",
+ "Entry Node is warehousesupervisor.",
+ "Entry Node is supervisor.",
+ "Exit Node is supervisor.",
+ "Exit Node is warehousesupervisor.",
+ "Entry Node is tradingsupervisor.",
+ "Entry Node is supervisor.",
+ "Exit Node is supervisor.",
+ "Exit Node is tradingsupervisor.",
+ "Entry Node is employeeid.",
+ "Entry Node is employeeid.",
+ "Exit Node is employeeid.",
+ "Exit Node is employeeid.",
+ "Exit Node is logisticsmanager."
+ };
+
+ /**
+ * Creates and validates logistics manager ydt.
+ */
+ @Test
+ public void logisticsManagerTest() {
+ YangRequestWorkBench ydtBuilder = logisticsManagerYdt();
+ validateTree(ydtBuilder);
+ // walker test
+ walkINTree(ydtBuilder, EXPECTED);
+ }
+
+ /**
+ * Validates the given built ydt.
+ */
+ private void validateTree(YangRequestWorkBench ydtBuilder) {
+ valueSet.add("1");
+ valueSet.add("2");
+ valueSet.add("3");
+ valueSet.add("4");
+ valueSet.add("5");
+ // assign root node to ydtNode for validating purpose.
+ YdtNode ydtNode = (YdtNode) ydtBuilder.getRootNode();
+ // Logical root node does not have operation type
+ validateNodeContents(ydtNode, "logisticsmanager", null);
+
+ ydtNode = ydtNode.getFirstChild();
+ // Logical root node does not have operation type
+ validateNodeContents(ydtNode, "customssupervisor", MERGE);
+ ydtNode = ydtNode.getFirstChild();
+ validateLeafContents(ydtNode, "supervisor", "abc");
+
+ ydtNode = ydtNode.getParent();
+
+ ydtNode = ydtNode.getNextSibling();
+ validateNodeContents(ydtNode, "merchandisersupervisor", MERGE);
+ ydtNode = ydtNode.getFirstChild();
+ validateLeafContents(ydtNode, "supervisor", "abc");
+
+ ydtNode = ydtNode.getParent();
+
+ ydtNode = ydtNode.getNextSibling();
+ validateNodeContents(ydtNode, "materialsupervisor", MERGE);
+ ydtNode = ydtNode.getFirstChild();
+ validateNodeContents(ydtNode, "supervisor", MERGE);
+
+ ydtNode = ydtNode.getFirstChild();
+ validateLeafContents(ydtNode, "name", "abc");
+ ydtNode = ydtNode.getNextSibling();
+ validateLeafContents(ydtNode, "departmentId", "xyz");
+
+ ydtNode = ydtNode.getParent();
+
+ ydtNode = ydtNode.getNextSibling();
+ validateNodeContents(ydtNode, "supervisor", MERGE);
+
+ ydtNode = ydtNode.getFirstChild();
+ validateLeafContents(ydtNode, "name", "ab");
+ ydtNode = ydtNode.getNextSibling();
+ validateLeafContents(ydtNode, "departmentId", "xy");
+
+ ydtNode = ydtNode.getParent().getParent();
+ ydtNode = ydtNode.getNextSibling();
+ validateNodeContents(ydtNode, "purchasingsupervisor", MERGE);
+ ydtNode = ydtNode.getFirstChild();
+ validateNodeContents(ydtNode, "supervisor", MERGE);
+
+ ydtNode = ydtNode.getFirstChild();
+ validateLeafContents(ydtNode, "purchasing-specialist", "abc");
+ ydtNode = ydtNode.getNextSibling();
+ validateLeafContents(ydtNode, "support", "xyz");
+
+ ydtNode = ydtNode.getParent().getParent();
+
+ ydtNode = ydtNode.getNextSibling();
+ validateNodeContents(ydtNode, "warehousesupervisor", MERGE);
+ ydtNode = ydtNode.getFirstChild();
+ validateLeafListContents(ydtNode, "supervisor", valueSet);
+
+ ydtNode = ydtNode.getParent();
+
+ ydtNode = ydtNode.getNextSibling();
+ validateNodeContents(ydtNode, "tradingsupervisor", MERGE);
+ ydtNode = ydtNode.getFirstChild();
+ validateLeafContents(ydtNode, "supervisor", "abc");
+
+ ydtNode = ydtNode.getParent();
+
+ ydtNode = ydtNode.getNextSibling();
+ validateNodeContents(ydtNode, "employeeid", MERGE);
+ ydtNode = ydtNode.getFirstChild();
+ validateLeafListContents(ydtNode, "employeeid", valueSet);
+ }
+}
diff --git a/apps/yms/app/src/test/java/org/onosproject/yms/app/ydt/MockYangSchemaRegistry.java b/apps/yms/app/src/test/java/org/onosproject/yms/app/ydt/MockYangSchemaRegistry.java
new file mode 100644
index 0000000..8df66e9
--- /dev/null
+++ b/apps/yms/app/src/test/java/org/onosproject/yms/app/ydt/MockYangSchemaRegistry.java
@@ -0,0 +1,101 @@
+/*
+ * 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.yms.app.ydt;
+
+import org.onosproject.yangutils.datamodel.YangSchemaNode;
+import org.onosproject.yms.app.ynh.YangNotificationExtendedService;
+import org.onosproject.yms.app.ysr.DefaultYangSchemaRegistry;
+import org.onosproject.yms.app.ysr.TestYangSchemaNodeProvider;
+import org.onosproject.yms.app.ysr.YangSchemaRegistry;
+
+import static org.junit.Assert.assertEquals;
+
+
+/**
+ * Represent Yang schema registry. Yang schema registry provides
+ * interface to an application to register its YANG
+ * schema with YMS. It provides YANG schema nodes to YDT, YNB and YSB.
+ */
+public class MockYangSchemaRegistry implements YangSchemaRegistry {
+
+
+ @Override
+ public void registerApplication(
+ Object managerObject,
+ Class<?> serviceClass,
+ YangNotificationExtendedService notificationExtendedService) {
+ }
+
+ @Override
+ public void unRegisterApplication(Object managerObject,
+ Class<?> serviceClass) {
+ }
+
+ @Override
+ public Object getRegisteredApplication(YangSchemaNode yangSchemaNode) {
+ return null;
+ }
+
+ @Override
+ public YangSchemaNode getYangSchemaNodeUsingAppName(String schemaName) {
+ return null;
+ }
+
+ @Override
+ public YangSchemaNode getYangSchemaNodeUsingSchemaName(String appName) {
+
+ final String target = "target/TestYangSchemaNodeProvider";
+ TestYangSchemaNodeProvider testYangSchemaNodeProvider =
+ new TestYangSchemaNodeProvider();
+
+ String searchDir = "src/test/resources/ydtTestYangFiles/";
+
+ testYangSchemaNodeProvider.processSchemaRegistry(null);
+
+ DefaultYangSchemaRegistry registry = testYangSchemaNodeProvider
+ .getDefaultYangSchemaRegistry();
+ YangSchemaNode yangNode = registry
+ .getYangSchemaNodeUsingSchemaName(appName);
+ assertEquals(appName, yangNode.getName());
+ return yangNode;
+ }
+
+ @Override
+ public YangSchemaNode
+ getYangSchemaNodeUsingGeneratedRootNodeInterfaceFileName(
+ String rootInterfaceFileName) {
+ return null;
+ }
+
+ @Override
+ public YangSchemaNode getYangSchemaNodeUsingGeneratedRootNodeOpPramFileName(
+ String rootOpParamFileName) {
+ return null;
+ }
+
+ @Override
+ public YangSchemaNode getRootYangSchemaNodeForNotification(
+ String eventSubject) {
+ return null;
+ }
+
+ @Override
+ public Class<?> getRegisteredClass(YangSchemaNode schemaNode,
+ String appName) {
+ return null;
+ }
+}
diff --git a/apps/yms/app/src/test/java/org/onosproject/yms/app/ydt/RpcTest.java b/apps/yms/app/src/test/java/org/onosproject/yms/app/ydt/RpcTest.java
new file mode 100644
index 0000000..8ca52c1
--- /dev/null
+++ b/apps/yms/app/src/test/java/org/onosproject/yms/app/ydt/RpcTest.java
@@ -0,0 +1,93 @@
+/*
+ * 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.yms.app.ydt;
+
+import org.junit.Test;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import static org.onosproject.yms.app.ydt.YdtTestUtils.helloOnos;
+import static org.onosproject.yms.app.ydt.YdtTestUtils.validateLeafContents;
+import static org.onosproject.yms.app.ydt.YdtTestUtils.validateNodeContents;
+import static org.onosproject.yms.app.ydt.YdtTestUtils.walkINTree;
+import static org.onosproject.yms.ydt.YdtContextOperationType.MERGE;
+
+public class RpcTest {
+
+ // Logger list is used for walker testing.
+ private final List<String> logger = new ArrayList<>();
+
+ private static final String[] EXPECTED = {
+ "Entry Node is Hello-ONOS.",
+ "Entry Node is Hello_ONOS.",
+ "Entry Node is hello-world.",
+ "Entry Node is input.",
+ "Entry Node is name.",
+ "Exit Node is name.",
+ "Entry Node is surName.",
+ "Exit Node is surName.",
+ "Entry Node is stringList.",
+ "Entry Node is string1.",
+ "Exit Node is string1.",
+ "Entry Node is string2.",
+ "Exit Node is string2.",
+ "Exit Node is stringList.",
+ "Exit Node is input.",
+ "Exit Node is hello-world.",
+ "Exit Node is Hello_ONOS.",
+ "Exit Node is Hello-ONOS."
+ };
+
+ /**
+ * Creates and validates hello onos ydt.
+ */
+ @Test
+ public void rpc1Test() {
+ YangRequestWorkBench ydtBuilder = helloOnos();
+ validateTree(ydtBuilder);
+ // walker test
+ walkINTree(ydtBuilder, EXPECTED);
+ }
+
+ /**
+ * Validates the given built ydt.
+ */
+ private void validateTree(YangRequestWorkBench ydtBuilder) {
+
+ // assign root node to ydtNode for validating purpose.
+ YdtNode ydtNode = (YdtNode) ydtBuilder.getRootNode();
+ // Logical root node does not have operation type
+ validateNodeContents(ydtNode, "Hello-ONOS", null);
+ ydtNode = ydtNode.getFirstChild();
+ validateNodeContents(ydtNode, "Hello_ONOS", MERGE);
+ ydtNode = ydtNode.getFirstChild();
+ validateNodeContents(ydtNode, "hello-world", MERGE);
+ ydtNode = ydtNode.getFirstChild();
+ validateNodeContents(ydtNode, "input", MERGE);
+ ydtNode = ydtNode.getFirstChild();
+ validateLeafContents(ydtNode, "name", "onos");
+ ydtNode = ydtNode.getNextSibling();
+ validateLeafContents(ydtNode, "surName", "yang");
+ ydtNode = ydtNode.getNextSibling();
+ validateNodeContents(ydtNode, "stringList", MERGE);
+ ydtNode = ydtNode.getFirstChild();
+ validateLeafContents(ydtNode, "string1", "ON");
+ ydtNode = ydtNode.getNextSibling();
+ validateLeafContents(ydtNode, "string2", "LAB");
+ }
+}
diff --git a/apps/yms/app/src/test/java/org/onosproject/yms/app/ydt/YdtBitTest.java b/apps/yms/app/src/test/java/org/onosproject/yms/app/ydt/YdtBitTest.java
new file mode 100644
index 0000000..5446b51
--- /dev/null
+++ b/apps/yms/app/src/test/java/org/onosproject/yms/app/ydt/YdtBitTest.java
@@ -0,0 +1,94 @@
+/*
+ * 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.yms.app.ydt;
+
+import org.junit.Test;
+
+import static org.onosproject.yms.app.ydt.YdtTestConstants.BIT;
+import static org.onosproject.yms.app.ydt.YdtTestConstants.BITNS;
+import static org.onosproject.yms.app.ydt.YdtTestUtils.bitYdt;
+import static org.onosproject.yms.app.ydt.YdtTestUtils.validateErrMsg;
+import static org.onosproject.yms.app.ydt.YdtTestUtils.validateLeafContents;
+import static org.onosproject.yms.app.ydt.YdtTestUtils.validateNodeContents;
+import static org.onosproject.yms.ydt.YdtContextOperationType.MERGE;
+
+public class YdtBitTest {
+
+ /*
+ BINARY
+
+ Positive scenario
+ input with position 0
+ input with position 1
+ input with position 2
+ */
+
+ /**
+ * Creates and validates bit ydt covering different positive scenario.
+ */
+ @Test
+ public void positiveTest() {
+ YangRequestWorkBench ydtBuilder = bitYdt();
+ validateTree(ydtBuilder);
+ }
+
+ /**
+ * Validates the given built ydt.
+ */
+ private void validateTree(YangRequestWorkBench ydtBuilder) {
+
+ // assign root node to ydtNode for validating purpose.
+ YdtNode ydtNode = (YdtNode) ydtBuilder.getRootNode();
+ // Logical root node does not have operation type
+ validateNodeContents(ydtNode, "builtInType", null);
+ ydtNode = ydtNode.getFirstChild();
+ validateNodeContents(ydtNode, "bit", MERGE);
+ ydtNode = ydtNode.getFirstChild();
+ validateNodeContents(ydtNode, "bitList", MERGE);
+ ydtNode = ydtNode.getFirstChild();
+ validateLeafContents(ydtNode, "bit", "disable-nagle");
+ ydtNode = ydtNode.getParent();
+ ydtNode = ydtNode.getNextSibling();
+ validateNodeContents(ydtNode, "bitList", MERGE);
+ ydtNode = ydtNode.getFirstChild();
+ validateLeafContents(ydtNode, "bit", "auto-sense-speed");
+ ydtNode = ydtNode.getParent();
+ ydtNode = ydtNode.getNextSibling();
+ validateNodeContents(ydtNode, "bitList", MERGE);
+ ydtNode = ydtNode.getFirstChild();
+ validateLeafContents(ydtNode, "bit", "ten-Mb-only");
+ }
+
+ /*
+ Negative scenario
+
+ input with position 0
+ input with position 1
+ input with position 2
+ */
+
+ /**
+ * Tests all the negative scenario's for bit data type.
+ */
+ @Test
+ public void negativeTest() {
+ validateErrMsg("bit", BITNS, "0", BIT, "bitList");
+ validateErrMsg("bit", BITNS, "default", BIT, "bitList");
+ validateErrMsg("bit", BITNS, "1", BIT, "bitList");
+ validateErrMsg("bit", BITNS, "", BIT, "bitList");
+ }
+}
diff --git a/apps/yms/app/src/test/java/org/onosproject/yms/app/ydt/YdtBooleanTest.java b/apps/yms/app/src/test/java/org/onosproject/yms/app/ydt/YdtBooleanTest.java
new file mode 100644
index 0000000..505c640
--- /dev/null
+++ b/apps/yms/app/src/test/java/org/onosproject/yms/app/ydt/YdtBooleanTest.java
@@ -0,0 +1,88 @@
+/*
+ * 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.yms.app.ydt;
+
+import org.junit.Test;
+
+import static org.onosproject.yms.app.ydt.YdtTestConstants.BOOL;
+import static org.onosproject.yms.app.ydt.YdtTestConstants.BOOLNS;
+import static org.onosproject.yms.app.ydt.YdtTestUtils.booleanYdt;
+import static org.onosproject.yms.app.ydt.YdtTestUtils.validateErrMsg;
+import static org.onosproject.yms.app.ydt.YdtTestUtils.validateLeafContents;
+import static org.onosproject.yms.app.ydt.YdtTestUtils.validateNodeContents;
+import static org.onosproject.yms.ydt.YdtContextOperationType.MERGE;
+
+public class YdtBooleanTest {
+
+ /*
+ BOOLEAN
+ Positive scenario
+ input with in "booleanList" and false
+ */
+
+ /**
+ * Creates and validates boolean ydt covering different positive scenario.
+ */
+ @Test
+ public void positiveTest() {
+ YangRequestWorkBench ydtBuilder = booleanYdt();
+ validateTree(ydtBuilder);
+ }
+
+ /**
+ * Validates the given built ydt.
+ */
+ private void validateTree(YangRequestWorkBench ydtBuilder) {
+
+ // assign root node to ydtNode for validating purpose.
+ YdtNode ydtNode = (YdtNode) ydtBuilder.getRootNode();
+ // Logical root node does not have operation type
+ validateNodeContents(ydtNode, "builtInType", null);
+ ydtNode = ydtNode.getFirstChild();
+ validateNodeContents(ydtNode, "bool", MERGE);
+ ydtNode = ydtNode.getFirstChild();
+ validateNodeContents(ydtNode, "booleanList", MERGE);
+ ydtNode = ydtNode.getFirstChild();
+ validateLeafContents(ydtNode, "boolean", "true");
+ ydtNode = ydtNode.getParent();
+ ydtNode = ydtNode.getNextSibling();
+ validateNodeContents(ydtNode, "booleanList", MERGE);
+ ydtNode = ydtNode.getFirstChild();
+ validateLeafContents(ydtNode, "boolean", "false");
+ }
+
+ /*
+ Negative scenario
+
+ input with in non zero value in case of "booleanList"
+ input with zero value in case of false
+ input with empty value in case of false
+ */
+
+ /**
+ * Tests all the negative scenario's for boolean data type.
+ */
+ @Test
+ public void negativeTest() {
+ validateErrMsg("boolean", BOOLNS, "10", BOOL, "booleanList");
+ validateErrMsg("boolean", BOOLNS, "0", BOOL, "booleanList");
+ validateErrMsg("boolean", BOOLNS, "", BOOL, "booleanList");
+ validateErrMsg("boolean", BOOLNS, "-1", BOOL, "booleanList");
+ validateErrMsg("boolean", BOOLNS, "tru", BOOL, "booleanList");
+ validateErrMsg("boolean", BOOLNS, "boolean", BOOL, "booleanList");
+ }
+}
diff --git a/apps/yms/app/src/test/java/org/onosproject/yms/app/ydt/YdtDecimal64Test.java b/apps/yms/app/src/test/java/org/onosproject/yms/app/ydt/YdtDecimal64Test.java
new file mode 100644
index 0000000..1d15d04
--- /dev/null
+++ b/apps/yms/app/src/test/java/org/onosproject/yms/app/ydt/YdtDecimal64Test.java
@@ -0,0 +1,193 @@
+/*
+ * 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.yms.app.ydt;
+
+import org.junit.Test;
+import org.onosproject.yms.app.ydt.exceptions.YdtException;
+
+import static org.onosproject.yms.app.ydt.YdtTestConstants.A;
+import static org.onosproject.yms.app.ydt.YdtTestConstants.B;
+import static org.onosproject.yms.app.ydt.YdtTestConstants.C;
+import static org.onosproject.yms.app.ydt.YdtTestConstants.E;
+import static org.onosproject.yms.app.ydt.YdtTestConstants.F;
+import static org.onosproject.yms.app.ydt.YdtTestConstants.G;
+import static org.onosproject.yms.app.ydt.YdtTestConstants.H;
+import static org.onosproject.yms.app.ydt.YdtTestConstants.MAXIWR;
+import static org.onosproject.yms.app.ydt.YdtTestConstants.MIDIWR;
+import static org.onosproject.yms.app.ydt.YdtTestConstants.MINIWR;
+import static org.onosproject.yms.app.ydt.YdtTestConstants.MRV;
+import static org.onosproject.yms.app.ydt.YdtTestConstants.NIWMF;
+import static org.onosproject.yms.app.ydt.YdtTestConstants.NWF;
+import static org.onosproject.yms.app.ydt.YdtTestConstants.PIWMF;
+import static org.onosproject.yms.app.ydt.YdtTestConstants.PWF;
+import static org.onosproject.yms.app.ydt.YdtTestConstants.TYPE;
+import static org.onosproject.yms.app.ydt.YdtTestUtils.decimal64Ydt;
+import static org.onosproject.yms.app.ydt.YdtTestUtils.validateLeafContents;
+import static org.onosproject.yms.app.ydt.YdtTestUtils.validateNodeContents;
+import static org.onosproject.yms.ydt.YdtContextOperationType.MERGE;
+
+public class YdtDecimal64Test {
+
+ /*
+
+ Positive scenario
+
+ input at boundry for decimal64 with fraction 2
+ i. min value
+ ii. max value
+
+ input at boundry for decimal64 with minimum fraction
+ i. min value
+ ii. mid value
+ iii. max value
+
+ input at boundry for decimal64 with maximum fraction
+ i. min value
+ ii. mid value
+ iii. max value
+
+ input with in range
+ if range is 10 to 100 for integer
+ i.1. input 11
+ i.2. min value 10
+ i.3. max value 100
+
+ input with multi interval range
+ if range is 10..40 | 50..100 for decimal64
+ i.1. input 11
+ i.2. input 10
+ i.3. input 40
+ i.4. input 50
+ i.5. input 55
+ i.6. input 100
+
+ if range is "min .. 3.14 | 10 | 20..max" for decimal64
+ i.1. input min
+ i.2. input 2.505
+ i.3. input 3.14
+ i.4. input 10
+ i.5. input 20
+ i.6. input 92233720368547757
+ i.7. input 92233720368547758.07
+
+ */
+
+ /**
+ * Creates and validates decimal64 ydt covering different positive scenario.
+ */
+ @Test
+ public void positiveTest() throws YdtException {
+ YangRequestWorkBench ydtBuilder = decimal64Ydt();
+ validateTree(ydtBuilder);
+ }
+
+ /**
+ * Validates the given built ydt.
+ */
+ private void validateTree(YangRequestWorkBench ydtBuilder) {
+
+ // assign root node to ydtNode for validating purpose.
+ YdtNode ydtNode = (YdtNode) ydtBuilder.getRootNode();
+ // Logical root node does not have operation type
+ validateNodeContents(ydtNode, TYPE, null);
+
+ ydtNode = ydtNode.getFirstChild();
+ validateNodeContents(ydtNode, "decimal64", MERGE);
+ ydtNode = ydtNode.getFirstChild();
+ validateLeafContents(ydtNode, "negInt", C);
+ ydtNode = ydtNode.getNextSibling();
+ validateLeafContents(ydtNode, "posInt", A);
+ ydtNode = ydtNode.getNextSibling();
+ validateLeafContents(ydtNode, NIWMF, F);
+ ydtNode = ydtNode.getNextSibling();
+ validateLeafContents(ydtNode, PIWMF, G);
+ ydtNode = ydtNode.getNextSibling();
+ validateLeafContents(ydtNode, NWF, H);
+ ydtNode = ydtNode.getNextSibling();
+ validateLeafContents(ydtNode, PWF, E);
+ ydtNode = ydtNode.getNextSibling();
+ validateLeafContents(ydtNode, MIDIWR, "11");
+ ydtNode = ydtNode.getNextSibling();
+ validateLeafContents(ydtNode, MINIWR, "10");
+ ydtNode = ydtNode.getNextSibling();
+ validateLeafContents(ydtNode, MAXIWR, "100");
+ ydtNode = ydtNode.getNextSibling();
+ validateNodeContents(ydtNode, MRV, MERGE);
+ ydtNode = ydtNode.getFirstChild();
+ validateLeafContents(ydtNode, "decimal", "11");
+ ydtNode = ydtNode.getParent();
+ ydtNode = ydtNode.getNextSibling();
+ validateNodeContents(ydtNode, MRV, MERGE);
+ ydtNode = ydtNode.getFirstChild();
+ validateLeafContents(ydtNode, "decimal", "10");
+ ydtNode = ydtNode.getParent();
+ ydtNode = ydtNode.getNextSibling();
+ validateNodeContents(ydtNode, MRV, MERGE);
+ ydtNode = ydtNode.getFirstChild();
+ validateLeafContents(ydtNode, "decimal", "40");
+ ydtNode = ydtNode.getParent();
+ ydtNode = ydtNode.getNextSibling();
+ validateNodeContents(ydtNode, MRV, MERGE);
+ ydtNode = ydtNode.getFirstChild();
+ validateLeafContents(ydtNode, "decimal", "50");
+ ydtNode = ydtNode.getParent();
+ ydtNode = ydtNode.getNextSibling();
+ validateNodeContents(ydtNode, MRV, MERGE);
+ ydtNode = ydtNode.getFirstChild();
+ validateLeafContents(ydtNode, "decimal", "55");
+ ydtNode = ydtNode.getParent();
+ ydtNode = ydtNode.getNextSibling();
+ validateNodeContents(ydtNode, MRV, MERGE);
+ ydtNode = ydtNode.getFirstChild();
+ validateLeafContents(ydtNode, "decimal", "100");
+ ydtNode = ydtNode.getParent();
+ ydtNode = ydtNode.getNextSibling();
+ validateNodeContents(ydtNode, MRV, MERGE);
+ ydtNode = ydtNode.getFirstChild();
+ validateLeafContents(ydtNode, "revDecimal", C);
+ ydtNode = ydtNode.getParent();
+ ydtNode = ydtNode.getNextSibling();
+ validateNodeContents(ydtNode, MRV, MERGE);
+ ydtNode = ydtNode.getFirstChild();
+ validateLeafContents(ydtNode, "revDecimal", "2.505");
+ ydtNode = ydtNode.getParent();
+ ydtNode = ydtNode.getNextSibling();
+ validateNodeContents(ydtNode, MRV, MERGE);
+ ydtNode = ydtNode.getFirstChild();
+ validateLeafContents(ydtNode, "revDecimal", "3.14");
+ ydtNode = ydtNode.getParent();
+ ydtNode = ydtNode.getNextSibling();
+ validateNodeContents(ydtNode, MRV, MERGE);
+ ydtNode = ydtNode.getFirstChild();
+ validateLeafContents(ydtNode, "revDecimal", "10");
+ ydtNode = ydtNode.getParent();
+ ydtNode = ydtNode.getNextSibling();
+ validateNodeContents(ydtNode, MRV, MERGE);
+ ydtNode = ydtNode.getFirstChild();
+ validateLeafContents(ydtNode, "revDecimal", "20");
+ ydtNode = ydtNode.getParent();
+ ydtNode = ydtNode.getNextSibling();
+ validateNodeContents(ydtNode, MRV, MERGE);
+ ydtNode = ydtNode.getFirstChild();
+ validateLeafContents(ydtNode, "revDecimal", B);
+ ydtNode = ydtNode.getParent();
+ ydtNode = ydtNode.getNextSibling();
+ validateNodeContents(ydtNode, MRV, MERGE);
+ ydtNode = ydtNode.getFirstChild();
+ validateLeafContents(ydtNode, "revDecimal", A);
+ }
+}
diff --git a/apps/yms/app/src/test/java/org/onosproject/yms/app/ydt/YdtEmptyTest.java b/apps/yms/app/src/test/java/org/onosproject/yms/app/ydt/YdtEmptyTest.java
new file mode 100644
index 0000000..ea5ee34
--- /dev/null
+++ b/apps/yms/app/src/test/java/org/onosproject/yms/app/ydt/YdtEmptyTest.java
@@ -0,0 +1,83 @@
+/*
+ * 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.yms.app.ydt;
+
+import org.junit.Test;
+import org.onosproject.yms.app.ydt.exceptions.YdtException;
+
+import static org.onosproject.yms.app.ydt.YdtTestConstants.EMPTY;
+import static org.onosproject.yms.app.ydt.YdtTestConstants.EMPTYNS;
+import static org.onosproject.yms.app.ydt.YdtTestConstants.TYPE;
+import static org.onosproject.yms.app.ydt.YdtTestUtils.emptyTypeYdt;
+import static org.onosproject.yms.app.ydt.YdtTestUtils.validateErrMsg;
+import static org.onosproject.yms.app.ydt.YdtTestUtils.validateLeafContents;
+import static org.onosproject.yms.app.ydt.YdtTestUtils.validateNodeContents;
+import static org.onosproject.yms.ydt.YdtContextOperationType.MERGE;
+
+public class YdtEmptyTest {
+
+ /*
+ EMPTY
+ Positive scenario
+ input with in empty.
+ */
+
+ /**
+ * Creates and validates empty ydt covering different positive scenario.
+ */
+ @Test
+ public void positiveTest() throws YdtException {
+ YangRequestWorkBench ydtBuilder = emptyTypeYdt();
+ validateTree(ydtBuilder);
+ }
+
+ /**
+ * Validates the given built ydt.
+ */
+ private void validateTree(YangRequestWorkBench ydtBuilder) {
+
+ // assign root node to ydtNode for validating purpose.
+ YdtNode ydtNode = (YdtNode) ydtBuilder.getRootNode();
+ // Logical root node does not have operation type
+ validateNodeContents(ydtNode, TYPE, null);
+
+ ydtNode = ydtNode.getFirstChild();
+ validateNodeContents(ydtNode, "emptydata", MERGE);
+ ydtNode = ydtNode.getFirstChild();
+ validateNodeContents(ydtNode, "emptyList", MERGE);
+ ydtNode = ydtNode.getFirstChild();
+ validateLeafContents(ydtNode, "empty", "");
+ }
+
+ /*
+ Negative scenario
+
+ input with " "
+ input with "tab"
+ input with """"
+ */
+
+ /**
+ * Tests all the negative scenario's for empty data type.
+ */
+ @Test
+ public void negativeTest() throws YdtException {
+ validateErrMsg("empty", EMPTYNS, " ", EMPTY, "emptyList");
+ validateErrMsg("empty", EMPTYNS, " ", EMPTY, "emptyList");
+ validateErrMsg("empty", EMPTYNS, " ", EMPTY, "emptyList");
+ }
+}
diff --git a/apps/yms/app/src/test/java/org/onosproject/yms/app/ydt/YdtEnumTest.java b/apps/yms/app/src/test/java/org/onosproject/yms/app/ydt/YdtEnumTest.java
new file mode 100644
index 0000000..77c2f81
--- /dev/null
+++ b/apps/yms/app/src/test/java/org/onosproject/yms/app/ydt/YdtEnumTest.java
@@ -0,0 +1,97 @@
+/*
+ * 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.yms.app.ydt;
+
+import org.junit.Test;
+import org.onosproject.yms.app.ydt.exceptions.YdtException;
+
+import static org.onosproject.yms.app.ydt.YdtTestConstants.ENUM;
+import static org.onosproject.yms.app.ydt.YdtTestConstants.ENUMNS;
+import static org.onosproject.yms.app.ydt.YdtTestConstants.TYPE;
+import static org.onosproject.yms.app.ydt.YdtTestUtils.enumYdt;
+import static org.onosproject.yms.app.ydt.YdtTestUtils.validateErrMsg;
+import static org.onosproject.yms.app.ydt.YdtTestUtils.validateLeafContents;
+import static org.onosproject.yms.app.ydt.YdtTestUtils.validateNodeContents;
+import static org.onosproject.yms.ydt.YdtContextOperationType.MERGE;
+
+public class YdtEnumTest {
+
+/*
+ ENUM
+
+ Positive scenario
+
+ input with in enum
+ input with "ten"
+ input with "hundred"
+ input with "thousand"
+*/
+
+ /**
+ * Creates and validates enum ydt covering different positive scenario.
+ */
+ @Test
+ public void positiveTest() throws YdtException {
+ YangRequestWorkBench ydtBuilder = enumYdt();
+ validateTree(ydtBuilder);
+ }
+
+ /**
+ * Validates the given built ydt.
+ */
+ private void validateTree(YangRequestWorkBench ydtBuilder) {
+
+ // assign root node to ydtNode for validating purpose.
+ YdtNode ydtNode = (YdtNode) ydtBuilder.getRootNode();
+ // Logical root node does not have operation type
+ validateNodeContents(ydtNode, TYPE, null);
+
+ ydtNode = ydtNode.getFirstChild();
+ validateNodeContents(ydtNode, "enumtest", MERGE);
+ ydtNode = ydtNode.getFirstChild();
+ validateNodeContents(ydtNode, "enumList", MERGE);
+ ydtNode = ydtNode.getFirstChild();
+ validateLeafContents(ydtNode, "enumleaf", "ten");
+ ydtNode = ydtNode.getParent();
+ ydtNode = ydtNode.getNextSibling();
+ validateNodeContents(ydtNode, "enumList", MERGE);
+ ydtNode = ydtNode.getFirstChild();
+ validateLeafContents(ydtNode, "enumleaf", "hundred");
+ ydtNode = ydtNode.getParent();
+ ydtNode = ydtNode.getNextSibling();
+ validateNodeContents(ydtNode, "enumList", MERGE);
+ ydtNode = ydtNode.getFirstChild();
+ validateLeafContents(ydtNode, "enumleaf", "thousand");
+ }
+
+ /*
+ Negative scenario
+
+ input with "10"
+ input with "thousands"
+ */
+
+ /**
+ * Tests all the negative scenario's for enum data type.
+ */
+ @Test
+ public void negativeTest() throws YdtException {
+ validateErrMsg("enumleaf", ENUMNS, "10", ENUM, "enumList");
+ validateErrMsg("enumleaf", ENUMNS, "thousands", ENUM, "enumList");
+ validateErrMsg("enumleaf", ENUMNS, "enumeration", ENUM, "enumList");
+ }
+}
diff --git a/apps/yms/app/src/test/java/org/onosproject/yms/app/ydt/YdtInteger16Test.java b/apps/yms/app/src/test/java/org/onosproject/yms/app/ydt/YdtInteger16Test.java
new file mode 100644
index 0000000..172732b
--- /dev/null
+++ b/apps/yms/app/src/test/java/org/onosproject/yms/app/ydt/YdtInteger16Test.java
@@ -0,0 +1,392 @@
+/*
+ * 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.yms.app.ydt;
+
+import org.junit.Test;
+import org.onosproject.yms.app.ydt.exceptions.YdtException;
+
+import static org.onosproject.yms.app.ydt.YdtTestConstants.CAPSINT16;
+import static org.onosproject.yms.app.ydt.YdtTestConstants.CAPSUINT16;
+import static org.onosproject.yms.app.ydt.YdtTestConstants.INT16NS;
+import static org.onosproject.yms.app.ydt.YdtTestConstants.MAXIWR;
+import static org.onosproject.yms.app.ydt.YdtTestConstants.MAXUINT16;
+import static org.onosproject.yms.app.ydt.YdtTestConstants.MAXUIWR;
+import static org.onosproject.yms.app.ydt.YdtTestConstants.MIDIWR;
+import static org.onosproject.yms.app.ydt.YdtTestConstants.MIDUIWR;
+import static org.onosproject.yms.app.ydt.YdtTestConstants.MINIWR;
+import static org.onosproject.yms.app.ydt.YdtTestConstants.MINUIWR;
+import static org.onosproject.yms.app.ydt.YdtTestConstants.MINVALUE;
+import static org.onosproject.yms.app.ydt.YdtTestConstants.MRV;
+import static org.onosproject.yms.app.ydt.YdtTestConstants.RUI;
+import static org.onosproject.yms.app.ydt.YdtTestConstants.SINT16;
+import static org.onosproject.yms.app.ydt.YdtTestConstants.SUINT16;
+import static org.onosproject.yms.app.ydt.YdtTestConstants.TYPE;
+import static org.onosproject.yms.app.ydt.YdtTestUtils.integer16Ydt;
+import static org.onosproject.yms.app.ydt.YdtTestUtils.validateErrMsg;
+import static org.onosproject.yms.app.ydt.YdtTestUtils.validateLeafContents;
+import static org.onosproject.yms.app.ydt.YdtTestUtils.validateNodeContents;
+import static org.onosproject.yms.ydt.YdtContextOperationType.MERGE;
+
+public class YdtInteger16Test {
+
+ /*
+ Positive scenario
+
+ input at boundry for integer
+ i. min value
+ ii. max value
+
+ input at boundry for uinteger
+ i. min value
+ ii. max value
+
+ input with in range
+ if range is 10 to 100 for integer
+ i.1. input 11
+ i.2. min value 10
+ i.3. max value 100
+
+ if range is 10 to 100 for uinteger
+ i.1. input 11
+ i.2. min value 10
+ i.3. max value 100
+
+ input with multi interval range
+ if range is 10..40 | 50..100 for integer
+ i.1. input 11
+ i.2. input 10
+ i.3. input 40
+ i.4. input 50
+ i.5. input 55
+ i.6. input 100
+
+ if range is 10..40 | 50..100 for uinteger
+ i.1. input 11
+ i.2. input 10
+ i.3. input 40
+ i.4. input 50
+ i.5. input 55
+ i.6. input 100
+
+ if range is "min .. 2 | 10 | 20..max" for integer
+ i.1. input -32768
+ i.2. input 1
+ i.3. input 2
+ i.4. input 10
+ i.5. input 20
+ i.6. input 100
+ i.7. input 32767
+
+ if range is "min .. 2 | 10 | 20..max" for uInteger
+ i.1. input 0
+ i.2. input 1
+ i.3. input 2
+ i.4. input 10
+ i.5. input 20
+ i.6. input 100
+ i.7. input 65535
+ */
+
+ /**
+ * Creates and validates integer16 ydt covering different positive scenario.
+ */
+ @Test
+ public void positiveTest() throws YdtException {
+ YangRequestWorkBench ydtBuilder = integer16Ydt();
+ validateTree(ydtBuilder);
+ }
+
+ /**
+ * Validates the given built ydt.
+ */
+ private void validateTree(YangRequestWorkBench ydtBuilder) {
+
+ // assign root node to ydtNode for validating purpose.
+ YdtNode ydtNode = (YdtNode) ydtBuilder.getRootNode();
+ // Logical root node does not have operation type
+ validateNodeContents(ydtNode, TYPE, null);
+
+ ydtNode = ydtNode.getFirstChild();
+ validateNodeContents(ydtNode, "integer16", MERGE);
+ ydtNode = ydtNode.getFirstChild();
+ validateLeafContents(ydtNode, "negInt", "-32768");
+ ydtNode = ydtNode.getNextSibling();
+ validateLeafContents(ydtNode, "posInt", "32767");
+ ydtNode = ydtNode.getNextSibling();
+ validateLeafContents(ydtNode, "minUInt", "0");
+ ydtNode = ydtNode.getNextSibling();
+ validateLeafContents(ydtNode, "maxUInt", "65535");
+ ydtNode = ydtNode.getNextSibling();
+ validateLeafContents(ydtNode, MIDIWR, "11");
+ ydtNode = ydtNode.getNextSibling();
+ validateLeafContents(ydtNode, MINIWR, "10");
+ ydtNode = ydtNode.getNextSibling();
+ validateLeafContents(ydtNode, MAXIWR, "100");
+ ydtNode = ydtNode.getNextSibling();
+ validateLeafContents(ydtNode, MIDUIWR, "11");
+ ydtNode = ydtNode.getNextSibling();
+ validateLeafContents(ydtNode, MINUIWR, "10");
+ ydtNode = ydtNode.getNextSibling();
+ validateLeafContents(ydtNode, MAXUIWR, "100");
+ ydtNode = ydtNode.getNextSibling();
+ validateNodeContents(ydtNode, MRV, MERGE);
+ ydtNode = ydtNode.getFirstChild();
+ validateLeafContents(ydtNode, "integer", "11");
+ ydtNode = ydtNode.getParent();
+ ydtNode = ydtNode.getNextSibling();
+ validateNodeContents(ydtNode, MRV, MERGE);
+ ydtNode = ydtNode.getFirstChild();
+ validateLeafContents(ydtNode, "integer", "10");
+ ydtNode = ydtNode.getParent();
+ ydtNode = ydtNode.getNextSibling();
+ validateNodeContents(ydtNode, MRV, MERGE);
+ ydtNode = ydtNode.getFirstChild();
+ validateLeafContents(ydtNode, "integer", "40");
+ ydtNode = ydtNode.getParent();
+ ydtNode = ydtNode.getNextSibling();
+ validateNodeContents(ydtNode, MRV, MERGE);
+ ydtNode = ydtNode.getFirstChild();
+ validateLeafContents(ydtNode, "integer", "50");
+ ydtNode = ydtNode.getParent();
+ ydtNode = ydtNode.getNextSibling();
+ validateNodeContents(ydtNode, MRV, MERGE);
+ ydtNode = ydtNode.getFirstChild();
+ validateLeafContents(ydtNode, "integer", "55");
+ ydtNode = ydtNode.getParent();
+ ydtNode = ydtNode.getNextSibling();
+ validateNodeContents(ydtNode, MRV, MERGE);
+ ydtNode = ydtNode.getFirstChild();
+ validateLeafContents(ydtNode, "integer", "100");
+ ydtNode = ydtNode.getParent();
+ ydtNode = ydtNode.getNextSibling();
+ validateNodeContents(ydtNode, MRV, MERGE);
+ ydtNode = ydtNode.getFirstChild();
+ validateLeafContents(ydtNode, "UnInteger", "11");
+ ydtNode = ydtNode.getParent();
+ ydtNode = ydtNode.getNextSibling();
+ validateNodeContents(ydtNode, MRV, MERGE);
+ ydtNode = ydtNode.getFirstChild();
+ validateLeafContents(ydtNode, "UnInteger", "10");
+ ydtNode = ydtNode.getParent();
+ ydtNode = ydtNode.getNextSibling();
+ validateNodeContents(ydtNode, MRV, MERGE);
+ ydtNode = ydtNode.getFirstChild();
+ validateLeafContents(ydtNode, "UnInteger", "40");
+ ydtNode = ydtNode.getParent();
+ ydtNode = ydtNode.getNextSibling();
+ validateNodeContents(ydtNode, MRV, MERGE);
+ ydtNode = ydtNode.getFirstChild();
+ validateLeafContents(ydtNode, "UnInteger", "50");
+ ydtNode = ydtNode.getParent();
+ ydtNode = ydtNode.getNextSibling();
+ validateNodeContents(ydtNode, MRV, MERGE);
+ ydtNode = ydtNode.getFirstChild();
+ validateLeafContents(ydtNode, "UnInteger", "55");
+ ydtNode = ydtNode.getParent();
+ ydtNode = ydtNode.getNextSibling();
+ validateNodeContents(ydtNode, MRV, MERGE);
+ ydtNode = ydtNode.getFirstChild();
+ validateLeafContents(ydtNode, "UnInteger", "100");
+
+ ydtNode = ydtNode.getParent();
+ ydtNode = ydtNode.getNextSibling();
+ validateNodeContents(ydtNode, MRV, MERGE);
+ ydtNode = ydtNode.getFirstChild();
+ validateLeafContents(ydtNode, "revInteger", "-32768");
+ ydtNode = ydtNode.getParent();
+ ydtNode = ydtNode.getNextSibling();
+ validateNodeContents(ydtNode, MRV, MERGE);
+ ydtNode = ydtNode.getFirstChild();
+ validateLeafContents(ydtNode, "revInteger", "1");
+ ydtNode = ydtNode.getParent();
+ ydtNode = ydtNode.getNextSibling();
+ validateNodeContents(ydtNode, MRV, MERGE);
+
+ validate1Tree(ydtNode);
+ }
+
+ /**
+ * Validates the given built ydt.
+ */
+ private void validate1Tree(YdtNode ydtNode) {
+
+ ydtNode = ydtNode.getFirstChild();
+ validateLeafContents(ydtNode, "revInteger", "2");
+ ydtNode = ydtNode.getParent();
+ ydtNode = ydtNode.getNextSibling();
+ validateNodeContents(ydtNode, MRV, MERGE);
+ ydtNode = ydtNode.getFirstChild();
+ validateLeafContents(ydtNode, "revInteger", "10");
+ ydtNode = ydtNode.getParent();
+ ydtNode = ydtNode.getNextSibling();
+ validateNodeContents(ydtNode, MRV, MERGE);
+ ydtNode = ydtNode.getFirstChild();
+ validateLeafContents(ydtNode, "revInteger", "20");
+ ydtNode = ydtNode.getParent();
+ ydtNode = ydtNode.getNextSibling();
+ validateNodeContents(ydtNode, MRV, MERGE);
+ ydtNode = ydtNode.getFirstChild();
+ validateLeafContents(ydtNode, "revInteger", "100");
+ ydtNode = ydtNode.getParent();
+ ydtNode = ydtNode.getNextSibling();
+ validateNodeContents(ydtNode, MRV, MERGE);
+ ydtNode = ydtNode.getFirstChild();
+ validateLeafContents(ydtNode, "revInteger", "32767");
+
+ ydtNode = ydtNode.getParent();
+ ydtNode = ydtNode.getNextSibling();
+ validateNodeContents(ydtNode, MRV, MERGE);
+ ydtNode = ydtNode.getFirstChild();
+ validateLeafContents(ydtNode, RUI, "0");
+ ydtNode = ydtNode.getParent();
+ ydtNode = ydtNode.getNextSibling();
+ validateNodeContents(ydtNode, MRV, MERGE);
+ ydtNode = ydtNode.getFirstChild();
+ validateLeafContents(ydtNode, RUI, "1");
+ ydtNode = ydtNode.getParent();
+ ydtNode = ydtNode.getNextSibling();
+ validateNodeContents(ydtNode, MRV, MERGE);
+ ydtNode = ydtNode.getFirstChild();
+ validateLeafContents(ydtNode, RUI, "2");
+ ydtNode = ydtNode.getParent();
+ ydtNode = ydtNode.getNextSibling();
+ validateNodeContents(ydtNode, MRV, MERGE);
+ ydtNode = ydtNode.getFirstChild();
+ validateLeafContents(ydtNode, RUI, "10");
+ ydtNode = ydtNode.getParent();
+ ydtNode = ydtNode.getNextSibling();
+ validateNodeContents(ydtNode, MRV, MERGE);
+ ydtNode = ydtNode.getFirstChild();
+ validateLeafContents(ydtNode, RUI, "20");
+ ydtNode = ydtNode.getParent();
+ ydtNode = ydtNode.getNextSibling();
+ validateNodeContents(ydtNode, MRV, MERGE);
+ ydtNode = ydtNode.getFirstChild();
+ validateLeafContents(ydtNode, RUI, "100");
+ ydtNode = ydtNode.getParent();
+ ydtNode = ydtNode.getNextSibling();
+ validateNodeContents(ydtNode, MRV, MERGE);
+ ydtNode = ydtNode.getFirstChild();
+ validateLeafContents(ydtNode, RUI, "65535");
+ }
+
+ /*
+ Negative scenario
+
+ wrong type input
+ i. input string instead of integer
+ ii. input string instead of uinteger
+
+ input out of range
+ i. input for int 8 range -32768 to 32767
+ i.1. input -32769
+ i.2. input 32768
+
+ ii. input for uint 8 range 0 to 65535
+ ii.1. input -32769
+ ii.2. input 65536
+
+ input out of range parameter
+ if range is 10 to 100 for int
+ i.1. input 9
+ i.2. input 101
+
+ if range is 10 to 100 for uInt
+ i.1. input 9
+ i.2. input 101
+
+ input with multi interval range
+ if range is 10..40 | 50..100 for integer
+ i.1. input 9
+ i.2. input 41
+ i.3. input 49
+ i.4. input 101
+
+ if range is 10..40 | 50..100 for uinteger
+ i.1. input 9
+ i.2. input 41
+ i.3. input 49
+ i.4. input 101
+
+ input with multi interval range
+ if range is min .. | 10 | 20..max for integer
+ i.1. input -32769
+ i.2. input 4
+ i.3. input 9
+ i.4. input 11
+ i.5. input 19
+ i.6. input 32768
+
+ if range is min .. 3 | 10 | 20..max for uinteger
+ i.1. input -32769
+ i.2. input 4
+ i.3. input 9
+ i.4. input 11
+ i.5. input 19
+ i.6. input 65536
+
+ */
+
+ /**
+ * Tests all the negative scenario's for integer8 data type.
+ */
+ @Test
+ public void negative1Test() throws YdtException {
+ validateErrMsg("posInt", INT16NS, "integer", SINT16, null);
+ validateErrMsg("posInt", INT16NS, "integer", SINT16, null);
+ validateErrMsg("posInt", INT16NS, "127.0", SINT16, null);
+ validateErrMsg("maxUInt", INT16NS, "integer", SUINT16, null);
+ validateErrMsg("maxUInt", INT16NS, "127.0", SUINT16, null);
+ validateErrMsg("negInt", INT16NS, "-32769", SINT16, null);
+ validateErrMsg("posInt", INT16NS, "32768", SINT16, null);
+ validateErrMsg("minUInt", INT16NS, "-32769", MINVALUE, null);
+ validateErrMsg("maxUInt", INT16NS, "65536", MAXUINT16, null);
+ validateErrMsg(MINIWR, INT16NS, "9", CAPSINT16, null);
+ validateErrMsg(MAXIWR, INT16NS, "101", CAPSINT16, null);
+ validateErrMsg(MINUIWR, INT16NS, "9", CAPSUINT16, null);
+ validateErrMsg(MAXUIWR, INT16NS, "101", CAPSUINT16, null);
+
+ validateErrMsg("integer", INT16NS, "9", CAPSINT16, MRV);
+ validateErrMsg("integer", INT16NS, "41", CAPSINT16, MRV);
+ validateErrMsg("integer", INT16NS, "49", CAPSINT16, MRV);
+ validateErrMsg("integer", INT16NS, "101", CAPSINT16, MRV);
+ validateErrMsg("UnInteger", INT16NS, "9", CAPSUINT16, MRV);
+ validateErrMsg("UnInteger", INT16NS, "41", CAPSUINT16, MRV);
+ validateErrMsg("UnInteger", INT16NS, "49", CAPSUINT16, MRV);
+ validateErrMsg("UnInteger", INT16NS, "101", CAPSUINT16, MRV);
+ validateErrMsg("UnInteger", INT16NS, "9", CAPSUINT16, MRV);
+ validateErrMsg("UnInteger", INT16NS, "41", CAPSUINT16, MRV);
+ validateErrMsg("UnInteger", INT16NS, "49", CAPSUINT16, MRV);
+ validateErrMsg("UnInteger", INT16NS, "101", CAPSUINT16, MRV);
+ validateErrMsg("UnInteger", INT16NS, "9", CAPSUINT16, MRV);
+ validateErrMsg("UnInteger", INT16NS, "41", CAPSUINT16, MRV);
+ validateErrMsg("UnInteger", INT16NS, "49", CAPSUINT16, MRV);
+ validateErrMsg("UnInteger", INT16NS, "101", CAPSUINT16, MRV);
+ validateErrMsg("revInteger", INT16NS, "-32769", SINT16, MRV);
+ validateErrMsg("revInteger", INT16NS, "19", CAPSINT16, MRV);
+ validateErrMsg("revInteger", INT16NS, "4", CAPSINT16, MRV);
+ validateErrMsg("revInteger", INT16NS, "32768", SINT16, MRV);
+ validateErrMsg("revInteger", INT16NS, "9", CAPSINT16, MRV);
+ validateErrMsg("revInteger", INT16NS, "11", CAPSINT16, MRV);
+ validateErrMsg(RUI, INT16NS, "-32769", MINVALUE, MRV);
+ validateErrMsg(RUI, INT16NS, "4", CAPSUINT16, MRV);
+ validateErrMsg(RUI, INT16NS, "9", CAPSUINT16, MRV);
+ validateErrMsg(RUI, INT16NS, "11", CAPSUINT16, MRV);
+ validateErrMsg(RUI, INT16NS, "19", CAPSUINT16, MRV);
+ validateErrMsg(RUI, INT16NS, "65536", MAXUINT16, MRV);
+ }
+}
diff --git a/apps/yms/app/src/test/java/org/onosproject/yms/app/ydt/YdtInteger32Test.java b/apps/yms/app/src/test/java/org/onosproject/yms/app/ydt/YdtInteger32Test.java
new file mode 100644
index 0000000..dd40ef5
--- /dev/null
+++ b/apps/yms/app/src/test/java/org/onosproject/yms/app/ydt/YdtInteger32Test.java
@@ -0,0 +1,390 @@
+/*
+ * 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.yms.app.ydt;
+
+import org.junit.Test;
+import org.onosproject.yms.app.ydt.exceptions.YdtException;
+
+import static org.onosproject.yms.app.ydt.YdtTestConstants.CAPSINT32;
+import static org.onosproject.yms.app.ydt.YdtTestConstants.CAPSUINT32;
+import static org.onosproject.yms.app.ydt.YdtTestConstants.INT32NS;
+import static org.onosproject.yms.app.ydt.YdtTestConstants.MAXIWR;
+import static org.onosproject.yms.app.ydt.YdtTestConstants.MAXUINT32;
+import static org.onosproject.yms.app.ydt.YdtTestConstants.MAXUIWR;
+import static org.onosproject.yms.app.ydt.YdtTestConstants.MIDIWR;
+import static org.onosproject.yms.app.ydt.YdtTestConstants.MIDUIWR;
+import static org.onosproject.yms.app.ydt.YdtTestConstants.MINIWR;
+import static org.onosproject.yms.app.ydt.YdtTestConstants.MINUIWR;
+import static org.onosproject.yms.app.ydt.YdtTestConstants.MINVALUE;
+import static org.onosproject.yms.app.ydt.YdtTestConstants.MRV;
+import static org.onosproject.yms.app.ydt.YdtTestConstants.RUI;
+import static org.onosproject.yms.app.ydt.YdtTestConstants.SINT32;
+import static org.onosproject.yms.app.ydt.YdtTestConstants.SUINT32;
+import static org.onosproject.yms.app.ydt.YdtTestConstants.TYPE;
+import static org.onosproject.yms.app.ydt.YdtTestUtils.integer32Ydt;
+import static org.onosproject.yms.app.ydt.YdtTestUtils.validateErrMsg;
+import static org.onosproject.yms.app.ydt.YdtTestUtils.validateLeafContents;
+import static org.onosproject.yms.app.ydt.YdtTestUtils.validateNodeContents;
+import static org.onosproject.yms.ydt.YdtContextOperationType.MERGE;
+
+public class YdtInteger32Test {
+
+ /*
+ Positive scenario
+
+ input at boundry for integer
+ i. min value
+ ii. max value
+
+ input at boundry for uinteger
+ i. min value
+ ii. max value
+
+ input with in range
+ if range is 10 to 100 for integer
+ i.1. input 11
+ i.2. min value 10
+ i.3. max value 100
+
+ if range is 10 to 100 for uinteger
+ i.1. input 11
+ i.2. min value 10
+ i.3. max value 100
+
+ input with multi interval range
+ if range is 10..40 | 50..100 for integer
+ i.1. input 11
+ i.2. input 10
+ i.3. input 40
+ i.4. input 50
+ i.5. input 55
+ i.6. input 100
+
+ if range is 10..40 | 50..100 for uinteger
+ i.1. input 11
+ i.2. input 10
+ i.3. input 40
+ i.4. input 50
+ i.5. input 55
+ i.6. input 100
+
+ if range is "min .. 2 | 10 | 20..max" for integer
+ i.1. input -2147483648
+ i.2. input 1
+ i.3. input 2
+ i.4. input 10
+ i.5. input 20
+ i.6. input 100
+ i.7. input 2147483647
+
+ if range is "min .. 2 | 10 | 20..max" for uInteger
+ i.1. input 0
+ i.2. input 1
+ i.3. input 2
+ i.4. input 10
+ i.5. input 20
+ i.6. input 100
+ i.7. input 4294967295
+ */
+
+ /**
+ * Creates and validates integer32 ydt covering different positive scenario.
+ */
+ @Test
+ public void positiveTest() throws YdtException {
+ YangRequestWorkBench ydtBuilder = integer32Ydt();
+ validateTree(ydtBuilder);
+ }
+
+ /**
+ * Validates the given built ydt.
+ */
+ private void validateTree(YangRequestWorkBench ydtBuilder) {
+
+ // assign root node to ydtNode for validating purpose.
+ YdtNode ydtNode = (YdtNode) ydtBuilder.getRootNode();
+ // Logical root node does not have operation type
+ validateNodeContents(ydtNode, TYPE, null);
+
+ ydtNode = ydtNode.getFirstChild();
+ validateNodeContents(ydtNode, "integer32", MERGE);
+ ydtNode = ydtNode.getFirstChild();
+ validateLeafContents(ydtNode, "negInt", "-2147483648");
+ ydtNode = ydtNode.getNextSibling();
+ validateLeafContents(ydtNode, "posInt", "2147483647");
+ ydtNode = ydtNode.getNextSibling();
+ validateLeafContents(ydtNode, "minUInt", MINVALUE);
+ ydtNode = ydtNode.getNextSibling();
+ validateLeafContents(ydtNode, "maxUInt", MAXUINT32);
+ ydtNode = ydtNode.getNextSibling();
+ validateLeafContents(ydtNode, MIDIWR, "11");
+ ydtNode = ydtNode.getNextSibling();
+ validateLeafContents(ydtNode, MINIWR, "10");
+ ydtNode = ydtNode.getNextSibling();
+ validateLeafContents(ydtNode, MAXIWR, "100");
+ ydtNode = ydtNode.getNextSibling();
+ validateLeafContents(ydtNode, MIDUIWR, "11");
+ ydtNode = ydtNode.getNextSibling();
+ validateLeafContents(ydtNode, MINUIWR, "10");
+ ydtNode = ydtNode.getNextSibling();
+ validateLeafContents(ydtNode, MAXUIWR, "100");
+ ydtNode = ydtNode.getNextSibling();
+ validateNodeContents(ydtNode, MRV, MERGE);
+ ydtNode = ydtNode.getFirstChild();
+ validateLeafContents(ydtNode, "integer", "11");
+ ydtNode = ydtNode.getParent();
+ ydtNode = ydtNode.getNextSibling();
+ validateNodeContents(ydtNode, MRV, MERGE);
+ ydtNode = ydtNode.getFirstChild();
+ validateLeafContents(ydtNode, "integer", "10");
+ ydtNode = ydtNode.getParent();
+ ydtNode = ydtNode.getNextSibling();
+ validateNodeContents(ydtNode, MRV, MERGE);
+ ydtNode = ydtNode.getFirstChild();
+ validateLeafContents(ydtNode, "integer", "40");
+ ydtNode = ydtNode.getParent();
+ ydtNode = ydtNode.getNextSibling();
+ validateNodeContents(ydtNode, MRV, MERGE);
+ ydtNode = ydtNode.getFirstChild();
+ validateLeafContents(ydtNode, "integer", "50");
+ ydtNode = ydtNode.getParent();
+ ydtNode = ydtNode.getNextSibling();
+ validateNodeContents(ydtNode, MRV, MERGE);
+ ydtNode = ydtNode.getFirstChild();
+ validateLeafContents(ydtNode, "integer", "55");
+ ydtNode = ydtNode.getParent();
+ ydtNode = ydtNode.getNextSibling();
+ validateNodeContents(ydtNode, MRV, MERGE);
+ ydtNode = ydtNode.getFirstChild();
+ validateLeafContents(ydtNode, "integer", "100");
+ ydtNode = ydtNode.getParent();
+ ydtNode = ydtNode.getNextSibling();
+ validateNodeContents(ydtNode, MRV, MERGE);
+ ydtNode = ydtNode.getFirstChild();
+ validateLeafContents(ydtNode, "UnInteger", "11");
+ ydtNode = ydtNode.getParent();
+ ydtNode = ydtNode.getNextSibling();
+ validateNodeContents(ydtNode, MRV, MERGE);
+ ydtNode = ydtNode.getFirstChild();
+ validateLeafContents(ydtNode, "UnInteger", "10");
+ ydtNode = ydtNode.getParent();
+ ydtNode = ydtNode.getNextSibling();
+ validateNodeContents(ydtNode, MRV, MERGE);
+ ydtNode = ydtNode.getFirstChild();
+ validateLeafContents(ydtNode, "UnInteger", "40");
+ ydtNode = ydtNode.getParent();
+ ydtNode = ydtNode.getNextSibling();
+ validateNodeContents(ydtNode, MRV, MERGE);
+ ydtNode = ydtNode.getFirstChild();
+ validateLeafContents(ydtNode, "UnInteger", "50");
+ ydtNode = ydtNode.getParent();
+ ydtNode = ydtNode.getNextSibling();
+ validateNodeContents(ydtNode, MRV, MERGE);
+ ydtNode = ydtNode.getFirstChild();
+ validateLeafContents(ydtNode, "UnInteger", "55");
+ ydtNode = ydtNode.getParent();
+ ydtNode = ydtNode.getNextSibling();
+ validateNodeContents(ydtNode, MRV, MERGE);
+ ydtNode = ydtNode.getFirstChild();
+ validateLeafContents(ydtNode, "UnInteger", "100");
+
+ ydtNode = ydtNode.getParent();
+ ydtNode = ydtNode.getNextSibling();
+ validateNodeContents(ydtNode, MRV, MERGE);
+ ydtNode = ydtNode.getFirstChild();
+ validateLeafContents(ydtNode, "revInteger", "-2147483648");
+ ydtNode = ydtNode.getParent();
+ ydtNode = ydtNode.getNextSibling();
+ validateNodeContents(ydtNode, MRV, MERGE);
+ ydtNode = ydtNode.getFirstChild();
+ validateLeafContents(ydtNode, "revInteger", "1");
+ ydtNode = ydtNode.getParent();
+ ydtNode = ydtNode.getNextSibling();
+ validateNodeContents(ydtNode, MRV, MERGE);
+ ydtNode = ydtNode.getFirstChild();
+ validateLeafContents(ydtNode, "revInteger", "2");
+ ydtNode = ydtNode.getParent();
+ ydtNode = ydtNode.getNextSibling();
+ validateNodeContents(ydtNode, MRV, MERGE);
+ ydtNode = ydtNode.getFirstChild();
+ validateLeafContents(ydtNode, "revInteger", "10");
+ ydtNode = ydtNode.getParent();
+ ydtNode = ydtNode.getNextSibling();
+ validateNodeContents(ydtNode, MRV, MERGE);
+ ydtNode = ydtNode.getFirstChild();
+ validateLeafContents(ydtNode, "revInteger", "20");
+ ydtNode = ydtNode.getParent();
+ ydtNode = ydtNode.getNextSibling();
+ validateNodeContents(ydtNode, MRV, MERGE);
+
+ validate1Tree(ydtNode);
+ }
+
+ /**
+ * Validates the given built ydt.
+ */
+ private void validate1Tree(YdtNode ydtNode) {
+ ydtNode = ydtNode.getFirstChild();
+ validateLeafContents(ydtNode, "revInteger", "100");
+ ydtNode = ydtNode.getParent();
+ ydtNode = ydtNode.getNextSibling();
+ validateNodeContents(ydtNode, MRV, MERGE);
+ ydtNode = ydtNode.getFirstChild();
+ validateLeafContents(ydtNode, "revInteger", "2147483647");
+
+ ydtNode = ydtNode.getParent();
+ ydtNode = ydtNode.getNextSibling();
+ validateNodeContents(ydtNode, MRV, MERGE);
+ ydtNode = ydtNode.getFirstChild();
+ validateLeafContents(ydtNode, RUI, MINVALUE);
+ ydtNode = ydtNode.getParent();
+ ydtNode = ydtNode.getNextSibling();
+ validateNodeContents(ydtNode, MRV, MERGE);
+ ydtNode = ydtNode.getFirstChild();
+ validateLeafContents(ydtNode, RUI, "1");
+ ydtNode = ydtNode.getParent();
+ ydtNode = ydtNode.getNextSibling();
+ validateNodeContents(ydtNode, MRV, MERGE);
+ ydtNode = ydtNode.getFirstChild();
+ validateLeafContents(ydtNode, RUI, "2");
+ ydtNode = ydtNode.getParent();
+ ydtNode = ydtNode.getNextSibling();
+ validateNodeContents(ydtNode, MRV, MERGE);
+ ydtNode = ydtNode.getFirstChild();
+ validateLeafContents(ydtNode, RUI, "10");
+ ydtNode = ydtNode.getParent();
+ ydtNode = ydtNode.getNextSibling();
+ validateNodeContents(ydtNode, MRV, MERGE);
+ ydtNode = ydtNode.getFirstChild();
+ validateLeafContents(ydtNode, RUI, "20");
+ ydtNode = ydtNode.getParent();
+ ydtNode = ydtNode.getNextSibling();
+ validateNodeContents(ydtNode, MRV, MERGE);
+ ydtNode = ydtNode.getFirstChild();
+ validateLeafContents(ydtNode, RUI, "100");
+ ydtNode = ydtNode.getParent();
+ ydtNode = ydtNode.getNextSibling();
+ validateNodeContents(ydtNode, MRV, MERGE);
+ ydtNode = ydtNode.getFirstChild();
+ validateLeafContents(ydtNode, RUI, MAXUINT32);
+ }
+
+ /*
+ Negative scenario
+
+ wrong type input
+ i. input string instead of integer
+ ii. input string instead of uinteger
+
+ input out of range
+ i. input for int 8 range -2147483648 to 2147483647
+ i.1. input -2147483649
+ i.2. input 2147483648
+
+ ii. input for uint 8 range 0 to 4294967295
+ ii.1. input -2147483649
+ ii.2. input 4294967296
+
+ input out of range parameter
+ if range is 10 to 100 for int
+ i.1. input 9
+ i.2. input 101
+
+ if range is 10 to 100 for uInt
+ i.1. input 9
+ i.2. input 101
+
+ input with multi interval range
+ if range is 10..40 | 50..100 for integer
+ i.1. input 9
+ i.2. input 41
+ i.3. input 49
+ i.4. input 101
+
+ if range is 10..40 | 50..100 for uinteger
+ i.1. input 9
+ i.2. input 41
+ i.3. input 49
+ i.4. input 101
+
+ input with multi interval range
+ if range is min .. | 10 | 20..max for integer
+ i.1. input -2147483649
+ i.2. input 4
+ i.3. input 9
+ i.4. input 11
+ i.5. input 19
+ i.6. input 256
+
+ if range is min .. 3 | 10 | 20..max for uinteger
+ i.1. input -2147483649
+ i.2. input 4
+ i.3. input 9
+ i.4. input 11
+ i.5. input 19
+ i.6. input 4294967296
+
+ */
+
+ /**
+ * Tests all the negative scenario's for integer8 data type.
+ */
+ @Test
+ public void negativeTest() throws YdtException {
+ validateErrMsg("posInt", INT32NS, "integer", SINT32, null);
+ validateErrMsg("posInt", INT32NS, "127.0", SINT32, null);
+ validateErrMsg("maxUInt", INT32NS, "integer", SUINT32, null);
+ validateErrMsg("maxUInt", INT32NS, "127.0", SUINT32, null);
+ validateErrMsg("negInt", INT32NS, "-2147483649", SINT32, null);
+ validateErrMsg("posInt", INT32NS, "2147483648", SINT32, null);
+ validateErrMsg("minUInt", INT32NS, "-2147483649", MINVALUE, null);
+ validateErrMsg("maxUInt", INT32NS, "4294967296", MAXUINT32, null);
+ validateErrMsg(MINIWR, INT32NS, "9", CAPSINT32, null);
+ validateErrMsg(MAXIWR, INT32NS, "101", CAPSINT32, null);
+ validateErrMsg(MINUIWR, INT32NS, "9", CAPSUINT32, null);
+ validateErrMsg(MAXUIWR, INT32NS, "101", CAPSUINT32, null);
+
+ validateErrMsg("integer", INT32NS, "9", CAPSINT32, MRV);
+ validateErrMsg("integer", INT32NS, "41", CAPSINT32, MRV);
+ validateErrMsg("integer", INT32NS, "49", CAPSINT32, MRV);
+ validateErrMsg("integer", INT32NS, "101", CAPSINT32, MRV);
+ validateErrMsg("UnInteger", INT32NS, "9", CAPSUINT32, MRV);
+ validateErrMsg("UnInteger", INT32NS, "41", CAPSUINT32, MRV);
+ validateErrMsg("UnInteger", INT32NS, "49", CAPSUINT32, MRV);
+ validateErrMsg("UnInteger", INT32NS, "101", CAPSUINT32, MRV);
+ validateErrMsg("UnInteger", INT32NS, "9", CAPSUINT32, MRV);
+ validateErrMsg("UnInteger", INT32NS, "41", CAPSUINT32, MRV);
+ validateErrMsg("UnInteger", INT32NS, "49", CAPSUINT32, MRV);
+ validateErrMsg("UnInteger", INT32NS, "101", CAPSUINT32, MRV);
+ validateErrMsg("UnInteger", INT32NS, "9", CAPSUINT32, MRV);
+ validateErrMsg("UnInteger", INT32NS, "41", CAPSUINT32, MRV);
+ validateErrMsg("UnInteger", INT32NS, "49", CAPSUINT32, MRV);
+ validateErrMsg("UnInteger", INT32NS, "101", CAPSUINT32, MRV);
+ validateErrMsg("revInteger", INT32NS, "-2147483649", SINT32, MRV);
+ validateErrMsg("revInteger", INT32NS, "4", CAPSINT32, MRV);
+ validateErrMsg("revInteger", INT32NS, "9", CAPSINT32, MRV);
+ validateErrMsg("revInteger", INT32NS, "11", CAPSINT32, MRV);
+ validateErrMsg("revInteger", INT32NS, "19", CAPSINT32, MRV);
+ validateErrMsg("revInteger", INT32NS, "2147483648", SINT32, MRV);
+ validateErrMsg(RUI, INT32NS, "-2147483649", MINVALUE, MRV);
+ validateErrMsg(RUI, INT32NS, "4", CAPSUINT32, MRV);
+ validateErrMsg(RUI, INT32NS, "9", CAPSUINT32, MRV);
+ validateErrMsg(RUI, INT32NS, "11", CAPSUINT32, MRV);
+ validateErrMsg(RUI, INT32NS, "19", CAPSUINT32, MRV);
+ validateErrMsg(RUI, INT32NS, "4294967296", MAXUINT32, MRV);
+ }
+}
diff --git a/apps/yms/app/src/test/java/org/onosproject/yms/app/ydt/YdtInteger64Test.java b/apps/yms/app/src/test/java/org/onosproject/yms/app/ydt/YdtInteger64Test.java
new file mode 100644
index 0000000..136381d
--- /dev/null
+++ b/apps/yms/app/src/test/java/org/onosproject/yms/app/ydt/YdtInteger64Test.java
@@ -0,0 +1,397 @@
+/*
+ * 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.yms.app.ydt;
+
+import org.junit.Test;
+import org.onosproject.yms.app.ydt.exceptions.YdtException;
+
+import static org.onosproject.yms.app.ydt.YdtTestConstants.CAPSINT64;
+import static org.onosproject.yms.app.ydt.YdtTestConstants.CAPSUINT64;
+import static org.onosproject.yms.app.ydt.YdtTestConstants.I;
+import static org.onosproject.yms.app.ydt.YdtTestConstants.INT64NS;
+import static org.onosproject.yms.app.ydt.YdtTestConstants.J;
+import static org.onosproject.yms.app.ydt.YdtTestConstants.K;
+import static org.onosproject.yms.app.ydt.YdtTestConstants.L;
+import static org.onosproject.yms.app.ydt.YdtTestConstants.M;
+import static org.onosproject.yms.app.ydt.YdtTestConstants.MAXIWR;
+import static org.onosproject.yms.app.ydt.YdtTestConstants.MAXUINT64;
+import static org.onosproject.yms.app.ydt.YdtTestConstants.MAXUIWR;
+import static org.onosproject.yms.app.ydt.YdtTestConstants.MIDIWR;
+import static org.onosproject.yms.app.ydt.YdtTestConstants.MIDUIWR;
+import static org.onosproject.yms.app.ydt.YdtTestConstants.MINIWR;
+import static org.onosproject.yms.app.ydt.YdtTestConstants.MINUIWR;
+import static org.onosproject.yms.app.ydt.YdtTestConstants.MINVALUE;
+import static org.onosproject.yms.app.ydt.YdtTestConstants.MRV;
+import static org.onosproject.yms.app.ydt.YdtTestConstants.RUI;
+import static org.onosproject.yms.app.ydt.YdtTestConstants.SMALLINT64;
+import static org.onosproject.yms.app.ydt.YdtTestConstants.SMALLUINT64;
+import static org.onosproject.yms.app.ydt.YdtTestConstants.TYPE;
+import static org.onosproject.yms.app.ydt.YdtTestUtils.integer64Ydt;
+import static org.onosproject.yms.app.ydt.YdtTestUtils.validateErrMsg;
+import static org.onosproject.yms.app.ydt.YdtTestUtils.validateLeafContents;
+import static org.onosproject.yms.app.ydt.YdtTestUtils.validateNodeContents;
+import static org.onosproject.yms.ydt.YdtContextOperationType.MERGE;
+
+public class YdtInteger64Test {
+
+ /*
+
+ Positive scenario
+
+ input at boundry for integer
+ i. min value
+ ii. max value
+
+ input at boundry for uinteger
+ i. min value
+ ii. max value
+
+ input with in range
+ if range is 10 to 100 for integer
+ i.1. input 11
+ i.2. min value 10
+ i.3. max value 100
+
+ if range is 10 to 100 for uinteger
+ i.1. input 11
+ i.2. min value 10
+ i.3. max value 100
+
+ input with multi interval range
+ if range is 10..40 | 50..100 for integer
+ i.1. input 11
+ i.2. input 10
+ i.3. input 40
+ i.4. input 50
+ i.5. input 55
+ i.6. input 100
+
+ if range is 10..40 | 50..100 for uinteger
+ i.1. input 11
+ i.2. input 10
+ i.3. input 40
+ i.4. input 50
+ i.5. input 55
+ i.6. input 100
+
+ if range is "min .. 2 | 10 | 20..max" for integer
+ i.1. input -9223372036854775808
+ i.2. input 1
+ i.3. input 2
+ i.4. input 10
+ i.5. input 20
+ i.6. input 100
+ i.7. input 9223372036854775807
+
+ if range is "min .. 2 | 10 | 20..max" for uInteger
+ i.1. input 0
+ i.2. input 1
+ i.3. input 2
+ i.4. input 10
+ i.5. input 20
+ i.6. input 100
+ i.7. input 18446744073709551615
+ */
+
+ /**
+ * Creates and validates integer64 ydt covering different positive scenario.
+ */
+ @Test
+ public void positiveTest() throws YdtException {
+ YangRequestWorkBench ydtBuilder = integer64Ydt();
+ validateTree(ydtBuilder);
+ }
+
+ /**
+ * Validates the given built ydt.
+ */
+ private void validateTree(YangRequestWorkBench ydtBuilder) {
+
+ // assign root node to ydtNode for validating purpose.
+ YdtNode ydtNode = (YdtNode) ydtBuilder.getRootNode();
+ // Logical root node does not have operation type
+ validateNodeContents(ydtNode, TYPE, null);
+
+ ydtNode = ydtNode.getFirstChild();
+ validateNodeContents(ydtNode, "integer64", MERGE);
+ ydtNode = ydtNode.getFirstChild();
+ validateLeafContents(ydtNode, "negInt", K);
+ ydtNode = ydtNode.getNextSibling();
+ validateLeafContents(ydtNode, "posInt", J);
+ ydtNode = ydtNode.getNextSibling();
+ validateLeafContents(ydtNode, "minUInt", MINVALUE);
+ ydtNode = ydtNode.getNextSibling();
+ validateLeafContents(ydtNode, "maxUInt", MAXUINT64);
+ ydtNode = ydtNode.getNextSibling();
+ validateLeafContents(ydtNode, MIDIWR, "11");
+ ydtNode = ydtNode.getNextSibling();
+ validateLeafContents(ydtNode, MINIWR, "10");
+ ydtNode = ydtNode.getNextSibling();
+ validateLeafContents(ydtNode, MAXIWR, "100");
+ ydtNode = ydtNode.getNextSibling();
+ validateLeafContents(ydtNode, MIDUIWR, "11");
+ ydtNode = ydtNode.getNextSibling();
+ validateLeafContents(ydtNode, MINUIWR, "10");
+ ydtNode = ydtNode.getNextSibling();
+ validateLeafContents(ydtNode, MAXUIWR, "100");
+ ydtNode = ydtNode.getNextSibling();
+ validateNodeContents(ydtNode, MRV, MERGE);
+ ydtNode = ydtNode.getFirstChild();
+ validateLeafContents(ydtNode, "integer", "11");
+ ydtNode = ydtNode.getParent();
+ ydtNode = ydtNode.getNextSibling();
+ validateNodeContents(ydtNode, MRV, MERGE);
+ ydtNode = ydtNode.getFirstChild();
+ validateLeafContents(ydtNode, "integer", "10");
+ ydtNode = ydtNode.getParent();
+ ydtNode = ydtNode.getNextSibling();
+ validateNodeContents(ydtNode, MRV, MERGE);
+ ydtNode = ydtNode.getFirstChild();
+ validateLeafContents(ydtNode, "integer", "40");
+ ydtNode = ydtNode.getParent();
+ ydtNode = ydtNode.getNextSibling();
+ validateNodeContents(ydtNode, MRV, MERGE);
+ ydtNode = ydtNode.getFirstChild();
+ validateLeafContents(ydtNode, "integer", "50");
+ ydtNode = ydtNode.getParent();
+ ydtNode = ydtNode.getNextSibling();
+ validateNodeContents(ydtNode, MRV, MERGE);
+ ydtNode = ydtNode.getFirstChild();
+ validateLeafContents(ydtNode, "integer", "55");
+ ydtNode = ydtNode.getParent();
+ ydtNode = ydtNode.getNextSibling();
+ validateNodeContents(ydtNode, MRV, MERGE);
+ ydtNode = ydtNode.getFirstChild();
+ validateLeafContents(ydtNode, "integer", "100");
+ ydtNode = ydtNode.getParent();
+ ydtNode = ydtNode.getNextSibling();
+ validateNodeContents(ydtNode, MRV, MERGE);
+ ydtNode = ydtNode.getFirstChild();
+ validateLeafContents(ydtNode, "UnInteger", "11");
+ ydtNode = ydtNode.getParent();
+ ydtNode = ydtNode.getNextSibling();
+ validateNodeContents(ydtNode, MRV, MERGE);
+ ydtNode = ydtNode.getFirstChild();
+ validateLeafContents(ydtNode, "UnInteger", "10");
+ ydtNode = ydtNode.getParent();
+ ydtNode = ydtNode.getNextSibling();
+ validateNodeContents(ydtNode, MRV, MERGE);
+ ydtNode = ydtNode.getFirstChild();
+ validateLeafContents(ydtNode, "UnInteger", "40");
+ ydtNode = ydtNode.getParent();
+ ydtNode = ydtNode.getNextSibling();
+ validateNodeContents(ydtNode, MRV, MERGE);
+ ydtNode = ydtNode.getFirstChild();
+ validateLeafContents(ydtNode, "UnInteger", "50");
+ ydtNode = ydtNode.getParent();
+ ydtNode = ydtNode.getNextSibling();
+ validateNodeContents(ydtNode, MRV, MERGE);
+ ydtNode = ydtNode.getFirstChild();
+ validateLeafContents(ydtNode, "UnInteger", "55");
+ ydtNode = ydtNode.getParent();
+ ydtNode = ydtNode.getNextSibling();
+ validateNodeContents(ydtNode, MRV, MERGE);
+ ydtNode = ydtNode.getFirstChild();
+ validateLeafContents(ydtNode, "UnInteger", "100");
+
+ ydtNode = ydtNode.getParent();
+ ydtNode = ydtNode.getNextSibling();
+ validateNodeContents(ydtNode, MRV, MERGE);
+ ydtNode = ydtNode.getFirstChild();
+ validateLeafContents(ydtNode, "revInteger", K);
+ ydtNode = ydtNode.getParent();
+ ydtNode = ydtNode.getNextSibling();
+ validateNodeContents(ydtNode, MRV, MERGE);
+ ydtNode = ydtNode.getFirstChild();
+ validateLeafContents(ydtNode, "revInteger", "1");
+ ydtNode = ydtNode.getParent();
+ ydtNode = ydtNode.getNextSibling();
+ validateNodeContents(ydtNode, MRV, MERGE);
+ ydtNode = ydtNode.getFirstChild();
+ validateLeafContents(ydtNode, "revInteger", "2");
+ ydtNode = ydtNode.getParent();
+ ydtNode = ydtNode.getNextSibling();
+ validateNodeContents(ydtNode, MRV, MERGE);
+ ydtNode = ydtNode.getFirstChild();
+ validateLeafContents(ydtNode, "revInteger", "10");
+ ydtNode = ydtNode.getParent();
+ ydtNode = ydtNode.getNextSibling();
+ validateNodeContents(ydtNode, MRV, MERGE);
+
+ validate1Tree(ydtNode);
+ }
+
+ /**
+ * Validates the given built ydt.
+ */
+ private void validate1Tree(YdtNode ydtNode) {
+ ydtNode = ydtNode.getFirstChild();
+ validateLeafContents(ydtNode, "revInteger", "20");
+ ydtNode = ydtNode.getParent();
+ ydtNode = ydtNode.getNextSibling();
+ validateNodeContents(ydtNode, MRV, MERGE);
+ ydtNode = ydtNode.getFirstChild();
+ validateLeafContents(ydtNode, "revInteger", "100");
+ ydtNode = ydtNode.getParent();
+ ydtNode = ydtNode.getNextSibling();
+ validateNodeContents(ydtNode, MRV, MERGE);
+ ydtNode = ydtNode.getFirstChild();
+ validateLeafContents(ydtNode, "revInteger", J);
+
+ ydtNode = ydtNode.getParent();
+ ydtNode = ydtNode.getNextSibling();
+ validateNodeContents(ydtNode, MRV, MERGE);
+ ydtNode = ydtNode.getFirstChild();
+ validateLeafContents(ydtNode, RUI, MINVALUE);
+ ydtNode = ydtNode.getParent();
+ ydtNode = ydtNode.getNextSibling();
+ validateNodeContents(ydtNode, MRV, MERGE);
+ ydtNode = ydtNode.getFirstChild();
+ validateLeafContents(ydtNode, RUI, "1");
+ ydtNode = ydtNode.getParent();
+ ydtNode = ydtNode.getNextSibling();
+ validateNodeContents(ydtNode, MRV, MERGE);
+ ydtNode = ydtNode.getFirstChild();
+ validateLeafContents(ydtNode, RUI, "2");
+ ydtNode = ydtNode.getParent();
+ ydtNode = ydtNode.getNextSibling();
+ validateNodeContents(ydtNode, MRV, MERGE);
+ ydtNode = ydtNode.getFirstChild();
+ validateLeafContents(ydtNode, RUI, "10");
+ ydtNode = ydtNode.getParent();
+ ydtNode = ydtNode.getNextSibling();
+ validateNodeContents(ydtNode, MRV, MERGE);
+ ydtNode = ydtNode.getFirstChild();
+ validateLeafContents(ydtNode, RUI, "20");
+ ydtNode = ydtNode.getParent();
+ ydtNode = ydtNode.getNextSibling();
+ validateNodeContents(ydtNode, MRV, MERGE);
+ ydtNode = ydtNode.getFirstChild();
+ validateLeafContents(ydtNode, RUI, "100");
+ ydtNode = ydtNode.getParent();
+ ydtNode = ydtNode.getNextSibling();
+ validateNodeContents(ydtNode, MRV, MERGE);
+ ydtNode = ydtNode.getFirstChild();
+ validateLeafContents(ydtNode, RUI, MAXUINT64);
+ }
+
+ /*
+ Negative scenario
+
+ wrong type input
+ i. input string instead of integer
+ ii. input string instead of uinteger
+
+ input out of range
+ i. input for int 8 range -9223372036854775808 to 9223372036854775807
+ i.1. input -9223372036854775809
+ i.2. input 9223372036854775808
+
+ ii. input for uint 8 range 0 to 18446744073709551615
+ ii.1. input -9223372036854775809
+ ii.2. input 18446744073709551616
+
+ input out of range parameter
+ if range is 10 to 100 for int
+ i.1. input 9
+ i.2. input 101
+
+ if range is 10 to 100 for uInt
+ i.1. input 9
+ i.2. input 101
+
+ input with multi interval range
+ if range is 10..40 | 50..100 for integer
+ i.1. input 9
+ i.2. input 41
+ i.3. input 49
+ i.4. input 101
+
+ if range is 10..40 | 50..100 for uinteger
+ i.1. input 9
+ i.2. input 41
+ i.3. input 49
+ i.4. input 101
+
+ input with multi interval range
+ if range is min .. | 10 | 20..max for integer
+ i.1. input -9223372036854775809
+ i.2. input 4
+ i.3. input 9
+ i.4. input 11
+ i.5. input 19
+ i.6. input 9223372036854775808
+
+ if range is min .. 3 | 10 | 20..max for uinteger
+ i.1. input -9223372036854775809
+ i.2. input 4
+ i.3. input 9
+ i.4. input 11
+ i.5. input 19
+ i.6. input 18446744073709551616
+
+ */
+
+ /**
+ * Tests all the negative scenario's for integer8 data type.
+ */
+ @Test
+ public void negativeTest() throws YdtException {
+ validateErrMsg("posInt", INT64NS, "integer", SMALLINT64, null);
+ validateErrMsg("posInt", INT64NS, "integer", SMALLINT64, null);
+ validateErrMsg("posInt", INT64NS, "127.0", SMALLINT64, null);
+ validateErrMsg("maxUInt", INT64NS, "integer", SMALLUINT64, null);
+ validateErrMsg("maxUInt", INT64NS, "127.0", SMALLUINT64, null);
+ validateErrMsg("negInt", INT64NS, L, SMALLINT64, null);
+ validateErrMsg("posInt", INT64NS, I, SMALLINT64, null);
+ validateErrMsg("minUInt", INT64NS, L, MINVALUE, null);
+ validateErrMsg("maxUInt", INT64NS, M, MAXUINT64, null);
+ validateErrMsg(MINIWR, INT64NS, "9", CAPSINT64, null);
+ validateErrMsg(MAXIWR, INT64NS, "101", CAPSINT64, null);
+ validateErrMsg(MINUIWR, INT64NS, "9", CAPSUINT64, null);
+ validateErrMsg(MAXUIWR, INT64NS, "101", CAPSUINT64, null);
+
+ validateErrMsg("integer", INT64NS, "9", CAPSINT64, MRV);
+ validateErrMsg("integer", INT64NS, "41", CAPSINT64, MRV);
+ validateErrMsg("integer", INT64NS, "49", CAPSINT64, MRV);
+ validateErrMsg("integer", INT64NS, "101", CAPSINT64, MRV);
+ validateErrMsg("UnInteger", INT64NS, "9", CAPSUINT64, MRV);
+ validateErrMsg("UnInteger", INT64NS, "41", CAPSUINT64, MRV);
+ validateErrMsg("UnInteger", INT64NS, "49", CAPSUINT64, MRV);
+ validateErrMsg("UnInteger", INT64NS, "101", CAPSUINT64, MRV);
+ validateErrMsg("UnInteger", INT64NS, "9", CAPSUINT64, MRV);
+ validateErrMsg("UnInteger", INT64NS, "41", CAPSUINT64, MRV);
+ validateErrMsg("UnInteger", INT64NS, "49", CAPSUINT64, MRV);
+ validateErrMsg("UnInteger", INT64NS, "101", CAPSUINT64, MRV);
+ validateErrMsg("UnInteger", INT64NS, "9", CAPSUINT64, MRV);
+ validateErrMsg("UnInteger", INT64NS, "41", CAPSUINT64, MRV);
+ validateErrMsg("UnInteger", INT64NS, "49", CAPSUINT64, MRV);
+ validateErrMsg("UnInteger", INT64NS, "101", CAPSUINT64, MRV);
+ validateErrMsg("revInteger", INT64NS, L, SMALLINT64, MRV);
+ validateErrMsg("revInteger", INT64NS, "11", CAPSINT64, MRV);
+ validateErrMsg("revInteger", INT64NS, "4", CAPSINT64, MRV);
+ validateErrMsg("revInteger", INT64NS, "9", CAPSINT64, MRV);
+ validateErrMsg("revInteger", INT64NS, "19", CAPSINT64, MRV);
+ validateErrMsg("revInteger", INT64NS, I, SMALLINT64, MRV);
+ validateErrMsg(RUI, INT64NS, L, MINVALUE, MRV);
+ validateErrMsg(RUI, INT64NS, "4", CAPSUINT64, MRV);
+ validateErrMsg(RUI, INT64NS, "9", CAPSUINT64, MRV);
+ validateErrMsg(RUI, INT64NS, "11", CAPSUINT64, MRV);
+ validateErrMsg(RUI, INT64NS, "19", CAPSUINT64, MRV);
+ validateErrMsg(RUI, INT64NS, M, MAXUINT64, MRV);
+ }
+}
diff --git a/apps/yms/app/src/test/java/org/onosproject/yms/app/ydt/YdtInteger8Test.java b/apps/yms/app/src/test/java/org/onosproject/yms/app/ydt/YdtInteger8Test.java
new file mode 100644
index 0000000..0658f26
--- /dev/null
+++ b/apps/yms/app/src/test/java/org/onosproject/yms/app/ydt/YdtInteger8Test.java
@@ -0,0 +1,389 @@
+/*
+ * 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.yms.app.ydt;
+
+import org.junit.Test;
+import org.onosproject.yms.app.ydt.exceptions.YdtException;
+
+import static org.onosproject.yms.app.ydt.YdtTestConstants.CAPSINT8;
+import static org.onosproject.yms.app.ydt.YdtTestConstants.CAPSUINT8;
+import static org.onosproject.yms.app.ydt.YdtTestConstants.INT8NS;
+import static org.onosproject.yms.app.ydt.YdtTestConstants.MAXIWR;
+import static org.onosproject.yms.app.ydt.YdtTestConstants.MAXUINT8;
+import static org.onosproject.yms.app.ydt.YdtTestConstants.MAXUIWR;
+import static org.onosproject.yms.app.ydt.YdtTestConstants.MIDIWR;
+import static org.onosproject.yms.app.ydt.YdtTestConstants.MIDUIWR;
+import static org.onosproject.yms.app.ydt.YdtTestConstants.MINIWR;
+import static org.onosproject.yms.app.ydt.YdtTestConstants.MINUIWR;
+import static org.onosproject.yms.app.ydt.YdtTestConstants.MINVALUE;
+import static org.onosproject.yms.app.ydt.YdtTestConstants.MRV;
+import static org.onosproject.yms.app.ydt.YdtTestConstants.RUI;
+import static org.onosproject.yms.app.ydt.YdtTestConstants.SMALLINT8;
+import static org.onosproject.yms.app.ydt.YdtTestConstants.SMALLUINT8;
+import static org.onosproject.yms.app.ydt.YdtTestConstants.TYPE;
+import static org.onosproject.yms.app.ydt.YdtTestUtils.integer8Ydt;
+import static org.onosproject.yms.app.ydt.YdtTestUtils.validateErrMsg;
+import static org.onosproject.yms.app.ydt.YdtTestUtils.validateLeafContents;
+import static org.onosproject.yms.app.ydt.YdtTestUtils.validateNodeContents;
+import static org.onosproject.yms.ydt.YdtContextOperationType.MERGE;
+
+public class YdtInteger8Test {
+
+ /*
+ Positive scenario
+
+ input at boundry for integer
+ i. min value
+ ii. max value
+
+ input at boundry for uinteger
+ i. min value
+ ii. max value
+
+ input with in range
+ if range is 10 to 100 for integer
+ i.1. input 11
+ i.2. min value 10
+ i.3. max value 100
+
+ if range is 10 to 100 for uinteger
+ i.1. input 11
+ i.2. min value 10
+ i.3. max value 100
+
+ input with multi interval range
+ if range is 10..40 | 50..100 for integer
+ i.1. input 11
+ i.2. input 10
+ i.3. input 40
+ i.4. input 50
+ i.5. input 55
+ i.6. input 100
+
+ if range is 10..40 | 50..100 for uinteger
+ i.1. input 11
+ i.2. input 10
+ i.3. input 40
+ i.4. input 50
+ i.5. input 55
+ i.6. input 100
+
+ if range is "min .. 2 | 10 | 20..max" for integer
+ i.1. input -128
+ i.2. input 1
+ i.3. input 2
+ i.4. input 10
+ i.5. input 20
+ i.6. input 100
+ i.7. input 127
+
+ if range is "min .. 2 | 10 | 20..max" for uInteger
+ i.1. input 0
+ i.2. input 1
+ i.3. input 2
+ i.4. input 10
+ i.5. input 20
+ i.6. input 100
+ i.7. input 255
+ */
+
+ /**
+ * Creates and validates integer8 ydt covering different positive scenario.
+ */
+ @Test
+ public void positiveTest() throws YdtException {
+ YangRequestWorkBench ydtBuilder = integer8Ydt();
+ validateTree(ydtBuilder);
+ }
+
+ /**
+ * Validates the given built ydt.
+ */
+ private void validateTree(YangRequestWorkBench ydtBuilder) {
+
+ // assign root node to ydtNode for validating purpose.
+ YdtNode ydtNode = (YdtNode) ydtBuilder.getRootNode();
+ // Logical root node does not have operation type
+ validateNodeContents(ydtNode, TYPE, null);
+
+ ydtNode = ydtNode.getFirstChild();
+ validateNodeContents(ydtNode, "integer8", MERGE);
+ ydtNode = ydtNode.getFirstChild();
+ validateLeafContents(ydtNode, "negInt", "-128");
+ ydtNode = ydtNode.getNextSibling();
+ validateLeafContents(ydtNode, "posInt", "127");
+ ydtNode = ydtNode.getNextSibling();
+ validateLeafContents(ydtNode, "minUInt", MINVALUE);
+ ydtNode = ydtNode.getNextSibling();
+ validateLeafContents(ydtNode, "maxUInt", MAXUINT8);
+ ydtNode = ydtNode.getNextSibling();
+ validateLeafContents(ydtNode, MIDIWR, "11");
+ ydtNode = ydtNode.getNextSibling();
+ validateLeafContents(ydtNode, MINIWR, "10");
+ ydtNode = ydtNode.getNextSibling();
+ validateLeafContents(ydtNode, MAXIWR, "100");
+ ydtNode = ydtNode.getNextSibling();
+ validateLeafContents(ydtNode, MIDUIWR, "11");
+ ydtNode = ydtNode.getNextSibling();
+ validateLeafContents(ydtNode, MINUIWR, "10");
+ ydtNode = ydtNode.getNextSibling();
+ validateLeafContents(ydtNode, MAXUIWR, "100");
+ ydtNode = ydtNode.getNextSibling();
+ validateNodeContents(ydtNode, MRV, MERGE);
+ ydtNode = ydtNode.getFirstChild();
+ validateLeafContents(ydtNode, "integer", "11");
+ ydtNode = ydtNode.getParent();
+ ydtNode = ydtNode.getNextSibling();
+ validateNodeContents(ydtNode, MRV, MERGE);
+ ydtNode = ydtNode.getFirstChild();
+ validateLeafContents(ydtNode, "integer", "10");
+ ydtNode = ydtNode.getParent();
+ ydtNode = ydtNode.getNextSibling();
+ validateNodeContents(ydtNode, MRV, MERGE);
+ ydtNode = ydtNode.getFirstChild();
+ validateLeafContents(ydtNode, "integer", "40");
+ ydtNode = ydtNode.getParent();
+ ydtNode = ydtNode.getNextSibling();
+ validateNodeContents(ydtNode, MRV, MERGE);
+ ydtNode = ydtNode.getFirstChild();
+ validateLeafContents(ydtNode, "integer", "50");
+ ydtNode = ydtNode.getParent();
+ ydtNode = ydtNode.getNextSibling();
+ validateNodeContents(ydtNode, MRV, MERGE);
+ ydtNode = ydtNode.getFirstChild();
+ validateLeafContents(ydtNode, "integer", "55");
+ ydtNode = ydtNode.getParent();
+ ydtNode = ydtNode.getNextSibling();
+ validateNodeContents(ydtNode, MRV, MERGE);
+ ydtNode = ydtNode.getFirstChild();
+ validateLeafContents(ydtNode, "integer", "100");
+ ydtNode = ydtNode.getParent();
+ ydtNode = ydtNode.getNextSibling();
+ validateNodeContents(ydtNode, MRV, MERGE);
+ ydtNode = ydtNode.getFirstChild();
+ validateLeafContents(ydtNode, "UnInteger", "11");
+ ydtNode = ydtNode.getParent();
+ ydtNode = ydtNode.getNextSibling();
+ validateNodeContents(ydtNode, MRV, MERGE);
+ ydtNode = ydtNode.getFirstChild();
+ validateLeafContents(ydtNode, "UnInteger", "10");
+ ydtNode = ydtNode.getParent();
+ ydtNode = ydtNode.getNextSibling();
+ validateNodeContents(ydtNode, MRV, MERGE);
+ ydtNode = ydtNode.getFirstChild();
+ validateLeafContents(ydtNode, "UnInteger", "40");
+ ydtNode = ydtNode.getParent();
+ ydtNode = ydtNode.getNextSibling();
+ validateNodeContents(ydtNode, MRV, MERGE);
+ ydtNode = ydtNode.getFirstChild();
+ validateLeafContents(ydtNode, "UnInteger", "50");
+ ydtNode = ydtNode.getParent();
+ ydtNode = ydtNode.getNextSibling();
+ validateNodeContents(ydtNode, MRV, MERGE);
+ ydtNode = ydtNode.getFirstChild();
+ validateLeafContents(ydtNode, "UnInteger", "55");
+ ydtNode = ydtNode.getParent();
+ ydtNode = ydtNode.getNextSibling();
+ validateNodeContents(ydtNode, MRV, MERGE);
+ ydtNode = ydtNode.getFirstChild();
+ validateLeafContents(ydtNode, "UnInteger", "100");
+
+ ydtNode = ydtNode.getParent();
+ ydtNode = ydtNode.getNextSibling();
+ validateNodeContents(ydtNode, MRV, MERGE);
+ ydtNode = ydtNode.getFirstChild();
+ validateLeafContents(ydtNode, "revInteger", "-128");
+ ydtNode = ydtNode.getParent();
+ ydtNode = ydtNode.getNextSibling();
+ validateNodeContents(ydtNode, MRV, MERGE);
+ ydtNode = ydtNode.getFirstChild();
+ validateLeafContents(ydtNode, "revInteger", "1");
+ ydtNode = ydtNode.getParent();
+ ydtNode = ydtNode.getNextSibling();
+ validateNodeContents(ydtNode, MRV, MERGE);
+ ydtNode = ydtNode.getFirstChild();
+ validateLeafContents(ydtNode, "revInteger", "2");
+ ydtNode = ydtNode.getParent();
+ ydtNode = ydtNode.getNextSibling();
+ validateNodeContents(ydtNode, MRV, MERGE);
+ ydtNode = ydtNode.getFirstChild();
+ validateLeafContents(ydtNode, "revInteger", "10");
+ ydtNode = ydtNode.getParent();
+ ydtNode = ydtNode.getNextSibling();
+ validateNodeContents(ydtNode, MRV, MERGE);
+ validate1Tree(ydtNode);
+ }
+
+ /**
+ * Validates the given built ydt.
+ */
+ private void validate1Tree(YdtNode ydtNode) {
+ ydtNode = ydtNode.getFirstChild();
+ validateLeafContents(ydtNode, "revInteger", "20");
+ ydtNode = ydtNode.getParent();
+ ydtNode = ydtNode.getNextSibling();
+ validateNodeContents(ydtNode, MRV, MERGE);
+ ydtNode = ydtNode.getFirstChild();
+ validateLeafContents(ydtNode, "revInteger", "100");
+ ydtNode = ydtNode.getParent();
+ ydtNode = ydtNode.getNextSibling();
+ validateNodeContents(ydtNode, MRV, MERGE);
+ ydtNode = ydtNode.getFirstChild();
+ validateLeafContents(ydtNode, "revInteger", "127");
+
+ ydtNode = ydtNode.getParent();
+ ydtNode = ydtNode.getNextSibling();
+ validateNodeContents(ydtNode, MRV, MERGE);
+ ydtNode = ydtNode.getFirstChild();
+ validateLeafContents(ydtNode, RUI, MINVALUE);
+ ydtNode = ydtNode.getParent();
+ ydtNode = ydtNode.getNextSibling();
+ validateNodeContents(ydtNode, MRV, MERGE);
+ ydtNode = ydtNode.getFirstChild();
+ validateLeafContents(ydtNode, RUI, "1");
+ ydtNode = ydtNode.getParent();
+ ydtNode = ydtNode.getNextSibling();
+ validateNodeContents(ydtNode, MRV, MERGE);
+ ydtNode = ydtNode.getFirstChild();
+ validateLeafContents(ydtNode, RUI, "2");
+ ydtNode = ydtNode.getParent();
+ ydtNode = ydtNode.getNextSibling();
+ validateNodeContents(ydtNode, MRV, MERGE);
+ ydtNode = ydtNode.getFirstChild();
+ validateLeafContents(ydtNode, RUI, "10");
+ ydtNode = ydtNode.getParent();
+ ydtNode = ydtNode.getNextSibling();
+ validateNodeContents(ydtNode, MRV, MERGE);
+ ydtNode = ydtNode.getFirstChild();
+ validateLeafContents(ydtNode, RUI, "20");
+ ydtNode = ydtNode.getParent();
+ ydtNode = ydtNode.getNextSibling();
+ validateNodeContents(ydtNode, MRV, MERGE);
+ ydtNode = ydtNode.getFirstChild();
+ validateLeafContents(ydtNode, RUI, "100");
+ ydtNode = ydtNode.getParent();
+ ydtNode = ydtNode.getNextSibling();
+ validateNodeContents(ydtNode, MRV, MERGE);
+ ydtNode = ydtNode.getFirstChild();
+ validateLeafContents(ydtNode, RUI, MAXUINT8);
+ }
+
+ /*
+ Negative scenario
+
+ wrong type input
+ i. input string instead of integer
+ ii. input string instead of uinteger
+
+ input out of range
+ i. input for int 8 range -128 to 127
+ i.1. input -129
+ i.2. input 128
+
+ ii. input for uint 8 range 0 to 255
+ ii.1. input -128
+ ii.2. input 256
+
+ input out of range parameter
+ if range is 10 to 100 for int
+ i.1. input 9
+ i.2. input 101
+
+ if range is 10 to 100 for uInt
+ i.1. input 9
+ i.2. input 101
+
+ input with multi interval range
+ if range is 10..40 | 50..100 for integer
+ i.1. input 9
+ i.2. input 41
+ i.3. input 49
+ i.4. input 101
+
+ if range is 10..40 | 50..100 for uinteger
+ i.1. input 9
+ i.2. input 41
+ i.3. input 49
+ i.4. input 101
+
+ input with multi interval range
+ if range is min .. | 10 | 20..max for integer
+ i.1. input -129
+ i.2. input 4
+ i.3. input 9
+ i.4. input 11
+ i.5. input 19
+ i.6. input 128
+
+ if range is min .. 3 | 10 | 20..max for uinteger
+ i.1. input -129
+ i.2. input 4
+ i.3. input 9
+ i.4. input 11
+ i.5. input 19
+ i.6. input 256
+
+ */
+
+ /**
+ * Tests all the negative scenario's for integer8 data type.
+ */
+ @Test
+ public void negativeTest() throws YdtException {
+ validateErrMsg("posInt", INT8NS, "integer", SMALLINT8, null);
+ validateErrMsg("posInt", INT8NS, "127.0", SMALLINT8, null);
+ validateErrMsg("maxUInt", INT8NS, "integer", SMALLUINT8, null);
+ validateErrMsg("maxUInt", INT8NS, "127.0", SMALLUINT8, null);
+ validateErrMsg("negInt", INT8NS, "-129", SMALLINT8, null);
+ validateErrMsg("posInt", INT8NS, "128", SMALLINT8, null);
+ validateErrMsg("minUInt", INT8NS, "-128", MINVALUE, null);
+ validateErrMsg("maxUInt", INT8NS, "256", MAXUINT8, null);
+ validateErrMsg(MINIWR, INT8NS, "9", CAPSINT8, null);
+ validateErrMsg(MAXIWR, INT8NS, "101", CAPSINT8, null);
+ validateErrMsg(MINUIWR, INT8NS, "9", CAPSUINT8, null);
+ validateErrMsg(MAXUIWR, INT8NS, "101", CAPSUINT8, null);
+
+ validateErrMsg("integer", INT8NS, "9", CAPSINT8, MRV);
+ validateErrMsg("integer", INT8NS, "41", CAPSINT8, MRV);
+ validateErrMsg("integer", INT8NS, "49", CAPSINT8, MRV);
+ validateErrMsg("integer", INT8NS, "101", CAPSINT8, MRV);
+ validateErrMsg("UnInteger", INT8NS, "9", CAPSUINT8, MRV);
+ validateErrMsg("UnInteger", INT8NS, "41", CAPSUINT8, MRV);
+ validateErrMsg("UnInteger", INT8NS, "49", CAPSUINT8, MRV);
+ validateErrMsg("UnInteger", INT8NS, "101", CAPSUINT8, MRV);
+ validateErrMsg("UnInteger", INT8NS, "9", CAPSUINT8, MRV);
+ validateErrMsg("UnInteger", INT8NS, "41", CAPSUINT8, MRV);
+ validateErrMsg("UnInteger", INT8NS, "49", CAPSUINT8, MRV);
+ validateErrMsg("UnInteger", INT8NS, "101", CAPSUINT8, MRV);
+ validateErrMsg("UnInteger", INT8NS, "9", CAPSUINT8, MRV);
+ validateErrMsg("UnInteger", INT8NS, "41", CAPSUINT8, MRV);
+ validateErrMsg("UnInteger", INT8NS, "49", CAPSUINT8, MRV);
+ validateErrMsg("UnInteger", INT8NS, "101", CAPSUINT8, MRV);
+ validateErrMsg("revInteger", INT8NS, "-129", SMALLINT8, MRV);
+ validateErrMsg("revInteger", INT8NS, "128", SMALLINT8, MRV);
+ validateErrMsg("revInteger", INT8NS, "4", CAPSINT8, MRV);
+ validateErrMsg("revInteger", INT8NS, "11", CAPSINT8, MRV);
+ validateErrMsg("revInteger", INT8NS, "9", CAPSINT8, MRV);
+ validateErrMsg("revInteger", INT8NS, "19", CAPSINT8, MRV);
+ validateErrMsg(RUI, INT8NS, "-129", MINVALUE, MRV);
+ validateErrMsg(RUI, INT8NS, "4", CAPSUINT8, MRV);
+ validateErrMsg(RUI, INT8NS, "9", CAPSUINT8, MRV);
+ validateErrMsg(RUI, INT8NS, "11", CAPSUINT8, MRV);
+ validateErrMsg(RUI, INT8NS, "19", CAPSUINT8, MRV);
+ validateErrMsg(RUI, INT8NS, "256", MAXUINT8, MRV);
+ }
+}
diff --git a/apps/yms/app/src/test/java/org/onosproject/yms/app/ydt/YdtTestConstants.java b/apps/yms/app/src/test/java/org/onosproject/yms/app/ydt/YdtTestConstants.java
new file mode 100644
index 0000000..daa5ce3
--- /dev/null
+++ b/apps/yms/app/src/test/java/org/onosproject/yms/app/ydt/YdtTestConstants.java
@@ -0,0 +1,138 @@
+/*
+ * 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.yms.app.ydt;
+
+/**
+ * Represents common constant utility for YANG data tree UT framework.
+ */
+final class YdtTestConstants {
+
+ // No instantiation.
+ private YdtTestConstants() {
+ }
+
+ public static final String BACKSLASH = "\"";
+ public static final String PERIOD = ".";
+ public static final String A = "92233720368547758.07";
+ public static final String B = "92233720368547757";
+ public static final String C = "-92233720368547758.08";
+ public static final String D = "92233720368547757";
+ public static final String E = "9.223372036854775807";
+ public static final String F = "-922337203685477580.8";
+ public static final String G = "922337203685477580.7";
+ public static final String H = "-9.223372036854775808";
+ public static final String I = "9223372036854775808";
+ public static final String J = "9223372036854775807";
+ public static final String K = "-9223372036854775808";
+ public static final String L = "-9223372036854775809";
+ public static final String M = "18446744073709551616";
+ public static final String NWF = "negIntWithMaxFraction";
+ public static final String PWF = "posIntWithMaxFraction";
+ public static final String NIWMF = "negIntWithMinFraction";
+ public static final String PIWMF = "posIntWithMinFraction";
+ public static final String CAPSUINT8 = "UINT8";
+ public static final String CAPSINT8 = "INT8";
+ public static final String SMALLUINT8 = "uint8.";
+ public static final String SMALLINT8 = "int8.";
+ public static final String MAXUINT8 = "255";
+ public static final String CAPSUINT16 = "UINT16";
+ public static final String CAPSINT16 = "INT16";
+ public static final String SUINT16 = "uint16.";
+ public static final String SINT16 = "int16.";
+ public static final String MAXUINT16 = "65535";
+ public static final String CAPSUINT32 = "UINT32";
+ public static final String CAPSINT32 = "INT32";
+ public static final String SUINT32 = "uint32.";
+ public static final String SINT32 = "int32.";
+ public static final String MAXUINT32 = "4294967295";
+ public static final String CAPSUINT64 = "UINT64";
+ public static final String CAPSINT64 = "INT64";
+ public static final String SMALLUINT64 = "uint64.";
+ public static final String SMALLINT64 = "int64.";
+ public static final String MAXUINT64 = "18446744073709551615";
+ public static final String MINVALUE = "0";
+ public static final String MINIWR = "minIntWithRange";
+ public static final String MIDIWR = "midIntWithRange";
+ public static final String MAXIWR = "maxIntWithRange";
+ public static final String MINUIWR = "minUIntWithRange";
+ public static final String MIDUIWR = "midUIntWithRange";
+ public static final String MAXUIWR = "maxUIntWithRange";
+ public static final String MRV = "multiRangeValidation";
+ public static final String RUI = "revUnInteger";
+ public static final String TYPE = "builtInType";
+ public static final String INT8NS = "ydt.integer8";
+ public static final String BIT = "BITS";
+ public static final String BOOL = "BOOLEAN";
+ public static final String EMPTY = "";
+ public static final String ENUM = "ENUMERATION";
+ public static final String LIST = "List";
+ public static final String LWC = "listwithcontainer";
+ public static final String INV = "invalidinterval";
+ public static final String INT16NS = "ydt.integer16";
+ public static final String INT32NS = "ydt.integer32";
+ public static final String INT64NS = "ydt.integer64";
+ public static final String BITNS = "ydt.bit";
+ public static final String BOOLNS = "ydt.boolean";
+ public static final String EMPTYNS = "ydt.emptydata";
+ public static final String ENUMNS = "ydt.enumtest";
+ public static final String LISTNS = "ydt.rootlist";
+ public static final String A1 = "ydt.augment-topology1";
+ public static final String A2 = "ydt.augment-topology2";
+ public static final String A3 = "ydt.augment-topology3";
+ public static final String A4 = "ydt.augment-topology4";
+ public static final String A5 = "ydt.augment-topology5";
+ public static final String A6 = "ydt.augment-topology6";
+ public static final String A2L = "augment2leafList";
+ public static final String A5L = "augment5leafList";
+ public static final String A6L = "augment6leafList";
+ public static final String MATERIALNS = "ydt.material-supervisor";
+ public static final String PURCHASNS = "ydt.purchasing-supervisor";
+ public static final String WAREHNS = "ydt.warehouse-supervisor";
+ public static final String TRADNS = "ydt.trading-supervisor";
+ public static final String EMPNS = "ydt.employee-id";
+ public static final String COUSTOMNS = "ydt.customs-supervisor";
+ public static final String MERCHNS = "ydt.Merchandiser-supervisor";
+ public static final String STP = "supporting-termination-point";
+ public static final String SLINK = "supporting-link";
+ public static final String AUG1 = "/nd:networks/nd:network";
+ public static final String AUG2 = "/nd:networks/nd:network/nd:node";
+ public static final String AUG3 = "/nd:networks/nd:network/topo:link";
+ public static final String AUG4 = "/nd:networks/nd:network/nd:node/" +
+ "topo:t-point/supporting-termination-point";
+ public static final String AUG5 = "/nd:networks/nd:network/topo:link/" +
+ "aug2:augment2";
+ public static final String AUG6 = "/nd:networks/nd:network/nd:node/" +
+ "topo:t-point/supporting-termination-point/aug2:augment2";
+ public static final String AUG7 = "/nd:networks/nd:network/topo:link/" +
+ "aug2:augment2/aug3:augment3";
+ public static final String AUG8 = "/nd:networks/nd:network/topo:link/" +
+ "aug2:augment2/aug3:augment3/aug5:augment5";
+ public static final String AUG9 = "/nd:networks/nd:network/topo:link/" +
+ "aug2:augment2/aug5:augment5";
+ public static final String NETNS = "ydt.augmentNetwork";
+ public static final String IETFNS =
+ "urn:ietf:params:xml:ns:yang:ietf-network";
+ public static final String IETF = "yms-ietf-network";
+ public static final String TOPONS =
+ "urn:ietf:params:xml:ns:yang:ietf-network-topology";
+ public static final String E_LEAF = "Exception has not occurred for " +
+ "invalid leaf value with name ";
+ public static final String E_LIST = "Exception has not occurred for " +
+ "invalid node addition with the name ";
+ public static final String E_TOPARENT = "Exception has not occurred " +
+ "in traverse back to parent for multi instance node.";
+}
diff --git a/apps/yms/app/src/test/java/org/onosproject/yms/app/ydt/YdtTestUtils.java b/apps/yms/app/src/test/java/org/onosproject/yms/app/ydt/YdtTestUtils.java
new file mode 100644
index 0000000..f375c1a
--- /dev/null
+++ b/apps/yms/app/src/test/java/org/onosproject/yms/app/ydt/YdtTestUtils.java
@@ -0,0 +1,1792 @@
+/*
+ * 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.yms.app.ydt;
+
+import org.junit.Rule;
+import org.junit.rules.ExpectedException;
+import org.onosproject.yms.app.ydt.exceptions.YdtException;
+import org.onosproject.yms.app.ysr.TestYangSchemaNodeProvider;
+import org.onosproject.yms.app.ysr.YangSchemaRegistry;
+import org.onosproject.yms.ydt.YdtContext;
+import org.onosproject.yms.ydt.YdtContextOperationType;
+import org.onosproject.yms.ydt.YdtListener;
+import org.onosproject.yms.ydt.YdtType;
+
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+import static org.onosproject.yms.app.ydt.YdtTestConstants.A1;
+import static org.onosproject.yms.app.ydt.YdtTestConstants.A2;
+import static org.onosproject.yms.app.ydt.YdtTestConstants.A2L;
+import static org.onosproject.yms.app.ydt.YdtTestConstants.A3;
+import static org.onosproject.yms.app.ydt.YdtTestConstants.A4;
+import static org.onosproject.yms.app.ydt.YdtTestConstants.A5;
+import static org.onosproject.yms.app.ydt.YdtTestConstants.A5L;
+import static org.onosproject.yms.app.ydt.YdtTestConstants.A6;
+import static org.onosproject.yms.app.ydt.YdtTestConstants.A6L;
+import static org.onosproject.yms.app.ydt.YdtTestConstants.BACKSLASH;
+import static org.onosproject.yms.app.ydt.YdtTestConstants.BIT;
+import static org.onosproject.yms.app.ydt.YdtTestConstants.BITNS;
+import static org.onosproject.yms.app.ydt.YdtTestConstants.BOOL;
+import static org.onosproject.yms.app.ydt.YdtTestConstants.BOOLNS;
+import static org.onosproject.yms.app.ydt.YdtTestConstants.CAPSINT16;
+import static org.onosproject.yms.app.ydt.YdtTestConstants.CAPSINT32;
+import static org.onosproject.yms.app.ydt.YdtTestConstants.CAPSINT64;
+import static org.onosproject.yms.app.ydt.YdtTestConstants.CAPSINT8;
+import static org.onosproject.yms.app.ydt.YdtTestConstants.CAPSUINT16;
+import static org.onosproject.yms.app.ydt.YdtTestConstants.CAPSUINT32;
+import static org.onosproject.yms.app.ydt.YdtTestConstants.CAPSUINT64;
+import static org.onosproject.yms.app.ydt.YdtTestConstants.CAPSUINT8;
+import static org.onosproject.yms.app.ydt.YdtTestConstants.COUSTOMNS;
+import static org.onosproject.yms.app.ydt.YdtTestConstants.EMPNS;
+import static org.onosproject.yms.app.ydt.YdtTestConstants.EMPTY;
+import static org.onosproject.yms.app.ydt.YdtTestConstants.EMPTYNS;
+import static org.onosproject.yms.app.ydt.YdtTestConstants.ENUM;
+import static org.onosproject.yms.app.ydt.YdtTestConstants.ENUMNS;
+import static org.onosproject.yms.app.ydt.YdtTestConstants.E_LEAF;
+import static org.onosproject.yms.app.ydt.YdtTestConstants.IETF;
+import static org.onosproject.yms.app.ydt.YdtTestConstants.IETFNS;
+import static org.onosproject.yms.app.ydt.YdtTestConstants.INT16NS;
+import static org.onosproject.yms.app.ydt.YdtTestConstants.INT32NS;
+import static org.onosproject.yms.app.ydt.YdtTestConstants.INT64NS;
+import static org.onosproject.yms.app.ydt.YdtTestConstants.INT8NS;
+import static org.onosproject.yms.app.ydt.YdtTestConstants.INV;
+import static org.onosproject.yms.app.ydt.YdtTestConstants.LIST;
+import static org.onosproject.yms.app.ydt.YdtTestConstants.LISTNS;
+import static org.onosproject.yms.app.ydt.YdtTestConstants.LWC;
+import static org.onosproject.yms.app.ydt.YdtTestConstants.MATERIALNS;
+import static org.onosproject.yms.app.ydt.YdtTestConstants.MAXUINT16;
+import static org.onosproject.yms.app.ydt.YdtTestConstants.MAXUINT32;
+import static org.onosproject.yms.app.ydt.YdtTestConstants.MAXUINT64;
+import static org.onosproject.yms.app.ydt.YdtTestConstants.MAXUINT8;
+import static org.onosproject.yms.app.ydt.YdtTestConstants.MERCHNS;
+import static org.onosproject.yms.app.ydt.YdtTestConstants.MINVALUE;
+import static org.onosproject.yms.app.ydt.YdtTestConstants.MRV;
+import static org.onosproject.yms.app.ydt.YdtTestConstants.NIWMF;
+import static org.onosproject.yms.app.ydt.YdtTestConstants.NWF;
+import static org.onosproject.yms.app.ydt.YdtTestConstants.PERIOD;
+import static org.onosproject.yms.app.ydt.YdtTestConstants.PIWMF;
+import static org.onosproject.yms.app.ydt.YdtTestConstants.PURCHASNS;
+import static org.onosproject.yms.app.ydt.YdtTestConstants.PWF;
+import static org.onosproject.yms.app.ydt.YdtTestConstants.SINT16;
+import static org.onosproject.yms.app.ydt.YdtTestConstants.SINT32;
+import static org.onosproject.yms.app.ydt.YdtTestConstants.SLINK;
+import static org.onosproject.yms.app.ydt.YdtTestConstants.SMALLINT64;
+import static org.onosproject.yms.app.ydt.YdtTestConstants.SMALLINT8;
+import static org.onosproject.yms.app.ydt.YdtTestConstants.SMALLUINT64;
+import static org.onosproject.yms.app.ydt.YdtTestConstants.SMALLUINT8;
+import static org.onosproject.yms.app.ydt.YdtTestConstants.STP;
+import static org.onosproject.yms.app.ydt.YdtTestConstants.SUINT16;
+import static org.onosproject.yms.app.ydt.YdtTestConstants.SUINT32;
+import static org.onosproject.yms.app.ydt.YdtTestConstants.TOPONS;
+import static org.onosproject.yms.app.ydt.YdtTestConstants.TRADNS;
+import static org.onosproject.yms.app.ydt.YdtTestConstants.TYPE;
+import static org.onosproject.yms.app.ydt.YdtTestConstants.WAREHNS;
+import static org.onosproject.yms.ydt.YdtContextOperationType.DELETE;
+import static org.onosproject.yms.ydt.YdtContextOperationType.MERGE;
+
+public class YdtTestUtils implements YdtListener {
+
+ private static List<String> kValList = new ArrayList<>();
+
+ @Rule
+ public ExpectedException thrown = ExpectedException.none();
+
+ private static YangSchemaRegistry schemaRegistry;
+
+ private static TestYangSchemaNodeProvider schemaProvider =
+ new TestYangSchemaNodeProvider();
+
+ // Logger list is used for walker testing.
+ private static final List<String> LOGGER = new ArrayList<>();
+
+ /**
+ * Returns the LOGGER with log for testing the YDT walker.
+ *
+ * @return list of logs
+ */
+ public static List<String> getLogger() {
+ return LOGGER;
+ }
+
+ /**
+ * Clear the LOGGER array.
+ */
+ public static void resetLogger() {
+ LOGGER.clear();
+ }
+
+ @Override
+ public void enterYdtNode(YdtContext ydtContext) {
+ LOGGER.add("Entry Node is " + ydtContext.getName() + PERIOD);
+ }
+
+ @Override
+ public void exitYdtNode(YdtContext ydtContext) {
+ LOGGER.add("Exit Node is " + ydtContext.getName() + PERIOD);
+ }
+
+ /**
+ * Returns schema registry of YDT.
+ *
+ * @return schema registry
+ */
+ public static YangSchemaRegistry getSchemaRegistry() {
+ return schemaRegistry;
+ }
+
+ /**
+ * Sets the ydt schema registry.
+ *
+ * @param registry schema registry
+ */
+ public static void setSchemaRegistry(YangSchemaRegistry registry) {
+ schemaRegistry = registry;
+ }
+
+ /**
+ * Returns the ydt builder for food module.
+ *
+ * @return ydt builder
+ */
+ public static YangRequestWorkBench foodArenaYdt() {
+
+ YangRequestWorkBench ydtBuilder;
+ ydtBuilder = getYdtBuilder("foodarena", "food", "ydt.food", MERGE);
+ ydtBuilder.addChild("food", "ydt.food");
+// ydtBuilder.addChild("snack", null, "ydt.food");
+// ydtBuilder.addChild("latenight", null, "ydt.food");
+ ydtBuilder.addLeaf("chocolate", "ydt.food", "dark");
+
+ return ydtBuilder;
+ }
+
+ /**
+ * Returns the ydt builder for yms-ietf-network module.
+ *
+ * @return ydt builder
+ */
+ public static YangRequestWorkBench ietfNetwork1Ydt() {
+
+ YangRequestWorkBench ydtBuilder;
+ ydtBuilder = getYdtBuilder(IETF, IETF, IETFNS, MERGE);
+ // Adding container
+ ydtBuilder.addChild("networks", null);
+ // Adding list inside container
+ ydtBuilder.addChild("network", null);
+ // Adding key element network Id
+ ydtBuilder.addLeaf("network-id", null, "network1");
+ ydtBuilder.traverseToParent();
+
+ // Adding list inside list
+ ydtBuilder.addChild("supporting-network", null);
+ // Adding key element network-ref
+ ydtBuilder.addLeaf("network-ref", null, "network2");
+ ydtBuilder.traverseToParent();
+ ydtBuilder.traverseToParent();
+
+ // Adding list inside list
+ ydtBuilder.addChild("node", null);
+ // Adding key element node-id
+ ydtBuilder.addLeaf("node-id", null, "node1");
+ ydtBuilder.traverseToParent();
+
+ // Adding list inside list
+ ydtBuilder.addChild("supporting-node", null);
+ // Adding key element network-ref
+ ydtBuilder.addLeaf("network-ref", null, "network3");
+ ydtBuilder.traverseToParent();
+
+ // Adding key element node-ref
+ ydtBuilder.addLeaf("node-ref", null, "network4");
+ ydtBuilder.traverseToParent();
+ ydtBuilder.traverseToParent();
+ ydtBuilder.traverseToParent();
+ ydtBuilder.traverseToParent();
+ ydtBuilder.traverseToParent();
+
+ // Adding container
+ ydtBuilder.addChild("networks-state", null);
+ // Adding list inside container
+ ydtBuilder.addChild("network", null);
+ // Adding key element network-ref
+ ydtBuilder.addLeaf("network-ref", null, "network5");
+ ydtBuilder.traverseToParent();
+ // Adding leaf server-provided
+ ydtBuilder.addLeaf("server-provided", null, "true");
+
+ return ydtBuilder;
+ }
+
+ /**
+ * Returns the ydt builder for yms-ietf-network-topology module.
+ *
+ * @return ydt builder
+ */
+ public static YangRequestWorkBench ietfNetworkTopologyYdt() {
+
+ YangRequestWorkBench ydtBuilder;
+ ydtBuilder = getYdtBuilder(IETF, IETF, IETFNS, MERGE);
+ // Adding container
+ ydtBuilder.addChild("networks", IETFNS, MERGE);
+ // Adding list inside container
+ ydtBuilder.addChild("network", IETFNS, MERGE);
+
+ // Adding key element network Id
+ ydtBuilder.addLeaf("network-id", null, "network1");
+ ydtBuilder.traverseToParent();
+
+ kValList.clear();
+ kValList.add("id1");
+ // adding the augmented node
+ ydtBuilder.addMultiInstanceChild("link", TOPONS, kValList, MERGE);
+ // container source
+ ydtBuilder.addChild("source", TOPONS, MERGE);
+ ydtBuilder.addLeaf("source-node", null, "source1");
+ ydtBuilder.traverseToParent();
+ ydtBuilder.addLeaf("source-tp", null, "source2");
+ ydtBuilder.traverseToParent();
+ ydtBuilder.traverseToParent();
+
+ // container destination
+ ydtBuilder.addChild("destination", TOPONS, MERGE);
+ ydtBuilder.addLeaf("dest-node", null, "dest1");
+ ydtBuilder.traverseToParent();
+ ydtBuilder.addLeaf("dest-tp", null, "dest2");
+ ydtBuilder.traverseToParent();
+ ydtBuilder.traverseToParent();
+
+ kValList.clear();
+ kValList.add("network1");
+ kValList.add("id2");
+ // adding the supporting-link list node
+ ydtBuilder.addMultiInstanceChild(SLINK, TOPONS, kValList, MERGE);
+ ydtBuilder.traverseToParent();
+
+ kValList.clear();
+ kValList.add("network2");
+ kValList.add("id3");
+ // adding the supporting-link list another instance
+ ydtBuilder.addMultiInstanceChild(SLINK, TOPONS, kValList, MERGE);
+ ydtBuilder.traverseToParent();
+ ydtBuilder.traverseToParent();
+
+ // Adding list inside list
+ ydtBuilder.addChild("supporting-network", null);
+ // Adding key element network-ref
+ ydtBuilder.addLeaf("network-ref", null, "network2");
+ ydtBuilder.traverseToParent();
+ ydtBuilder.traverseToParent();
+
+ // Adding list inside list
+ ydtBuilder.addChild("node", null);
+ // Adding key element node-id
+ ydtBuilder.addLeaf("node-id", null, "node1");
+ ydtBuilder.traverseToParent();
+
+ kValList.clear();
+ kValList.add("tp_id1");
+ //adding augmented termination-point list
+ ydtBuilder.addMultiInstanceChild("t-point", TOPONS,
+ kValList, MERGE);
+ kValList.clear();
+ kValList.add("network-ref");
+ kValList.add("node-ref");
+ kValList.add("tp-ref");
+ //adding supporting-termination-point
+ ydtBuilder.addMultiInstanceChild(STP, TOPONS, kValList, MERGE);
+ ydtBuilder.traverseToParent();
+ ydtBuilder.traverseToParent();
+
+ // Adding list inside list
+ ydtBuilder.addChild("supporting-node", null);
+ // Adding key element network-ref
+ ydtBuilder.addLeaf("network-ref", null, "network3");
+ ydtBuilder.traverseToParent();
+
+ // Adding key element node-ref
+ ydtBuilder.addLeaf("node-ref", null, "network4");
+ ydtBuilder.traverseToParent();
+ ydtBuilder.traverseToParent();
+ ydtBuilder.traverseToParent();
+
+ ydtBuilder.addLeaf("link-id", TOPONS, "id1");
+ ydtBuilder.traverseToParent();
+
+ ydtBuilder.traverseToParent();
+ ydtBuilder.traverseToParent();
+
+ // Adding container
+ ydtBuilder.addChild("networks-state", null);
+ // Adding list inside container
+ ydtBuilder.addChild("network", null);
+ // Adding key element network-ref
+ ydtBuilder.addLeaf("network-ref", null, "network5");
+ ydtBuilder.traverseToParent();
+ // Adding leaf server-provided
+ ydtBuilder.addLeaf("server-provided", null, "true");
+
+ return ydtBuilder;
+ }
+
+ /**
+ * Returns the ydt builder for augmented module.
+ *
+ * @return ydt builder
+ */
+ public static YangRequestWorkBench augmentNetworkYdt() {
+
+ YangRequestWorkBench ydtBuilder;
+ ydtBuilder = getYdtBuilder(IETF, IETF, IETFNS, MERGE);
+ // Adding container
+ ydtBuilder.addChild("networks", IETFNS, MERGE);
+ // Adding list inside container
+ ydtBuilder.addChild("network", IETFNS, MERGE);
+
+ // Adding key element network Id
+ ydtBuilder.addLeaf("network-id", null, "network1");
+ ydtBuilder.traverseToParent();
+
+ kValList.clear();
+ kValList.add("id1");
+ // adding the augmented node
+ ydtBuilder.addMultiInstanceChild("link", TOPONS, kValList, MERGE);
+ // container source
+ ydtBuilder.addChild("source", TOPONS, MERGE);
+ ydtBuilder.addLeaf("source-node", null, "source1");
+ ydtBuilder.traverseToParent();
+ ydtBuilder.addLeaf("source-tp", null, "source2");
+ ydtBuilder.traverseToParent();
+ ydtBuilder.traverseToParent();
+
+ // container destination
+ ydtBuilder.addChild("destination", TOPONS, MERGE);
+ ydtBuilder.addLeaf("dest-node", null, "dest1");
+ ydtBuilder.traverseToParent();
+ ydtBuilder.addLeaf("dest-tp", null, "dest2");
+ ydtBuilder.traverseToParent();
+ ydtBuilder.traverseToParent();
+
+ kValList.clear();
+ kValList.add("network1");
+ kValList.add("id2");
+ // adding the supporting-link list node
+ ydtBuilder.addMultiInstanceChild(SLINK, TOPONS, kValList, MERGE);
+ ydtBuilder.traverseToParent();
+
+ kValList.clear();
+ kValList.add("network2");
+ kValList.add("id3");
+ // adding the supporting-link list another instance
+ ydtBuilder.addMultiInstanceChild(SLINK, TOPONS, kValList, MERGE);
+ ydtBuilder.traverseToParent();
+
+ kValList.clear();
+ kValList.add("1");
+ ydtBuilder.addMultiInstanceChild("augment1", A1, kValList, MERGE);
+ ydtBuilder.traverseToParent();
+
+ kValList.clear();
+ kValList.add("1");
+ kValList.add("2");
+ ydtBuilder.addMultiInstanceChild("augment2", A2, kValList, MERGE);
+
+ ydtBuilder.addChild("augment5", A5, DELETE);
+
+ ydtBuilder.addMultiInstanceChild(A6L, A6, kValList, DELETE);
+ ydtBuilder.traverseToParent();
+
+ ydtBuilder.addLeaf("value5", null, "5");
+ ydtBuilder.traverseToParent();
+ ydtBuilder.traverseToParent();
+
+ ydtBuilder.addMultiInstanceChild(A5L, A5, kValList, DELETE);
+ ydtBuilder.traverseToParent();
+
+ ydtBuilder.addChild("augment3", A3, MERGE);
+
+ ydtBuilder.addChild("augment4", A4, DELETE);
+ ydtBuilder.addLeaf("value4", null, "4");
+ ydtBuilder.traverseToParent();
+ ydtBuilder.traverseToParent();
+
+ ydtBuilder.addChild("augment5", A5, MERGE);
+
+ ydtBuilder.addLeaf("leaf6", A6, "6");
+ ydtBuilder.traverseToParent();
+
+ ydtBuilder.addLeaf("value5", null, "5");
+ ydtBuilder.traverseToParent();
+ ydtBuilder.traverseToParent();
+
+ ydtBuilder.addChild("augment6", A6, DELETE);
+ ydtBuilder.addLeaf("value6", null, "6");
+ ydtBuilder.traverseToParent();
+ ydtBuilder.traverseToParent();
+
+ ydtBuilder.addLeaf("value3", null, "3");
+ ydtBuilder.traverseToParent();
+ ydtBuilder.traverseToParent();
+
+ ydtBuilder.addLeaf("augment3leaf", A3, "3");
+ ydtBuilder.traverseToParent();
+ ydtBuilder.traverseToParent();
+
+ ydtBuilder.addMultiInstanceChild(A2L, A2, kValList, MERGE);
+ ydtBuilder.traverseToParent();
+
+ ydtBuilder.traverseToParent();
+
+ // Adding list inside list
+ ydtBuilder.addChild("supporting-network", null);
+ // Adding key element network-ref
+ ydtBuilder.addLeaf("network-ref", null, "network2");
+ ydtBuilder.traverseToParent();
+ ydtBuilder.traverseToParent();
+
+ // Adding list inside list
+ ydtBuilder.addChild("node", null);
+ // Adding key element node-id
+ ydtBuilder.addLeaf("node-id", null, "node1");
+ ydtBuilder.traverseToParent();
+
+ kValList.clear();
+ kValList.add("tp_id1");
+ //adding augmented termination-point list
+ ydtBuilder.addMultiInstanceChild("t-point", TOPONS,
+ kValList, MERGE);
+ kValList.clear();
+ kValList.add("network-ref");
+ kValList.add("node-ref");
+ kValList.add("tp-ref");
+ //adding supporting-termination-point
+ ydtBuilder.addMultiInstanceChild(STP, TOPONS, kValList, MERGE);
+
+ // Adding augmented container1 inside supporting-termination-point
+ augmentTerminationPointYdt(ydtBuilder);
+
+ return ydtBuilder;
+ }
+
+ /**
+ * Adds augments inside supporting-termination-point in augmented module.
+ *
+ * @param ydtBuilder ydt builder which need to be updated
+ */
+ private static void augmentTerminationPointYdt(YangRequestWorkBench ydtBuilder) {
+
+ ydtBuilder.addChild("augment1", A1);
+ ydtBuilder.addLeaf("value1", null, "1");
+ ydtBuilder.traverseToParent();
+ ydtBuilder.traverseToParent();
+ ydtBuilder.addLeaf("augment1-leaf", A1, "1");
+
+ ydtBuilder.traverseToParent();
+
+ ydtBuilder.addChild("augment2", A2, MERGE);
+
+ ydtBuilder.addChild("augment3", A3, MERGE);
+ ydtBuilder.addLeaf("value3", null, "3");
+ ydtBuilder.traverseToParent();
+ ydtBuilder.traverseToParent();
+
+ ydtBuilder.addLeaf("augment4leaf", A4, "4");
+ ydtBuilder.traverseToParent();
+
+ ydtBuilder.addLeaf("value2", null, "2");
+ ydtBuilder.traverseToParent();
+ ydtBuilder.traverseToParent();
+
+ kValList.clear();
+ kValList.add("1");
+ kValList.add("2");
+ ydtBuilder.addMultiInstanceChild(A2L, A2, kValList, MERGE);
+ ydtBuilder.traverseToParent();
+
+ ydtBuilder.addLeaf("augment2leaf", A2, "2");
+ ydtBuilder.traverseToParent();
+
+ ydtBuilder.traverseToParent();
+ ydtBuilder.traverseToParent();
+
+ // Adding list inside list
+ ydtBuilder.addChild("supporting-node", null);
+ // Adding key element network-ref
+ ydtBuilder.addLeaf("network-ref", null, "network3");
+ ydtBuilder.traverseToParent();
+
+ // Adding key element node-ref
+ ydtBuilder.addLeaf("node-ref", null, "network4");
+ ydtBuilder.traverseToParent();
+ ydtBuilder.traverseToParent();
+ ydtBuilder.traverseToParent();
+
+ ydtBuilder.addLeaf("link-id", TOPONS, "id1");
+ ydtBuilder.traverseToParent();
+
+ ydtBuilder.traverseToParent();
+ ydtBuilder.traverseToParent();
+
+ // Adding container
+ ydtBuilder.addChild("networks-state", null);
+ // Adding list inside container
+ ydtBuilder.addChild("network", null);
+ // Adding key element network-ref
+ ydtBuilder.addLeaf("network-ref", null, "network5");
+ ydtBuilder.traverseToParent();
+ // Adding leaf server-provided
+ ydtBuilder.addLeaf("server-provided", null, "true");
+ ydtBuilder.traverseToParent();
+ ydtBuilder.traverseToParent();
+ ydtBuilder.traverseToParent();
+ ydtBuilder.traverseToParent();
+ }
+
+ /**
+ * Returns the ydt builder for rootlist module with listwithcontainer node
+ * using addMultiInstanceChild interface for adding multi instance node.
+ *
+ * @return ydt builder
+ */
+ public static YangRequestWorkBench listWithContainerYdt() {
+
+ YangRequestWorkBench ydtBuilder;
+ ydtBuilder = getYdtBuilder("list", "rootlist", "ydt.rootlist", MERGE);
+ kValList.clear();
+ kValList.add("12");
+ kValList.add("12");
+ ydtBuilder.addMultiInstanceChild(LWC, null, kValList, MERGE);
+ ydtBuilder.addLeaf(INV, null, "1");
+ ydtBuilder.traverseToParent();
+ ydtBuilder.addLeaf(INV, null, "2");
+ ydtBuilder.traverseToParent();
+ ydtBuilder.addChild("interface", null);
+ ydtBuilder.addLeaf(INV, null, "12");
+ ydtBuilder.traverseToParent();
+ ydtBuilder.addLeaf("invalid", null, "121");
+ ydtBuilder.traverseToParent();
+ ydtBuilder.traverseToParent();
+ return ydtBuilder;
+ }
+
+ /**
+ * Returns the ydt builder for rootlist module with listwithcontainer
+ * node using addChild interface for adding multi instance node.
+ *
+ * @return ydt builder
+ */
+ public static YangRequestWorkBench listWithContainer1Ydt() {
+
+ YangRequestWorkBench ydtBuilder;
+ ydtBuilder = getYdtBuilder("list", "rootlist", "ydt.rootlist", MERGE);
+ ydtBuilder.addChild(LWC, null);
+ ydtBuilder.addLeaf("invalid", null, "12");
+ ydtBuilder.traverseToParent();
+ ydtBuilder.addLeaf("invalid1", null, "12");
+ ydtBuilder.traverseToParent();
+ ydtBuilder.addLeaf(INV, null, "1");
+ ydtBuilder.traverseToParent();
+ ydtBuilder.addLeaf(INV, null, "2");
+ ydtBuilder.traverseToParent();
+ ydtBuilder.addChild("interface", null);
+ ydtBuilder.addLeaf(INV, null, "12");
+ ydtBuilder.traverseToParent();
+ ydtBuilder.addLeaf("invalid", null, "121");
+ ydtBuilder.traverseToParent();
+
+ return ydtBuilder;
+ }
+
+ /**
+ * Returns the ydt builder for rootlist module with multiple instances of
+ * listwithcontainer node using addMultiInstanceChild interface for adding
+ * multi instance node.
+ *
+ * @return ydt builder
+ */
+ public static YangRequestWorkBench listWithContainer2Ydt() {
+
+ YangRequestWorkBench ydtBuilder;
+ ydtBuilder = getYdtBuilder("list", "rootlist", "ydt.rootlist", MERGE);
+ kValList.clear();
+ kValList.add("1222");
+ kValList.add("1212");
+ ydtBuilder.addMultiInstanceChild(LWC, null, kValList, MERGE);
+
+ kValList.clear();
+ kValList.add("12");
+ kValList.add("1");
+ ydtBuilder.addMultiInstanceChild(INV, null, kValList, MERGE);
+ ydtBuilder.traverseToParent();
+ ydtBuilder.addLeaf(INV, null, "122");
+ ydtBuilder.traverseToParent();
+ ydtBuilder.addLeaf(INV, null, "2222");
+ ydtBuilder.traverseToParent();
+
+ kValList.clear();
+ kValList.add("1222");
+ kValList.add("1212");
+ ydtBuilder.addMultiInstanceChild(INV, null, kValList, MERGE);
+ ydtBuilder.traverseToParent();
+
+ ydtBuilder.addChild("interface", null);
+ ydtBuilder.addLeaf(INV, null, "12");
+ ydtBuilder.traverseToParent();
+ ydtBuilder.traverseToParent();
+ ydtBuilder.traverseToParent();
+
+ return ydtBuilder;
+ }
+
+ /**
+ * Returns the ydt builder for rootlist module with listwithoutcontainer
+ * node.
+ *
+ * @return ydt builder
+ */
+ public static YangRequestWorkBench listWithoutContainerYdt() {
+
+ YangRequestWorkBench ydtBuilder;
+ ydtBuilder = getYdtBuilder("list", "rootlist", "ydt.rootlist", MERGE);
+ ydtBuilder.addChild("listwithoutcontainer", null);
+ ydtBuilder.addLeaf(INV, null, "12");
+ ydtBuilder.traverseToParent();
+ ydtBuilder.traverseToParent();
+ return ydtBuilder;
+ }
+
+ /**
+ * Returns the ydt builder for logisticsmanager module.
+ *
+ * @return ydt builder
+ */
+ public static YangRequestWorkBench logisticsManagerYdt() {
+
+ Set<String> valueSet = new HashSet();
+ valueSet.add("1");
+ valueSet.add("2");
+ valueSet.add("3");
+ valueSet.add("4");
+ valueSet.add("5");
+
+ YangRequestWorkBench ydtBuilder;
+ ydtBuilder = getYdtBuilder("logisticsmanager", "customssupervisor",
+ null, MERGE);
+ ydtBuilder.addLeaf("supervisor", COUSTOMNS, "abc");
+ ydtBuilder.traverseToParent();
+ ydtBuilder.traverseToParent();
+
+ ydtBuilder.addChild("merchandisersupervisor", MERCHNS, MERGE);
+ ydtBuilder.addLeaf("supervisor", MERCHNS, "abc");
+ ydtBuilder.traverseToParent();
+ ydtBuilder.traverseToParent();
+
+ ydtBuilder.addChild("materialsupervisor", MATERIALNS, MERGE);
+ ydtBuilder.addChild("supervisor", MATERIALNS);
+ ydtBuilder.addLeaf("name", MATERIALNS, "abc");
+ ydtBuilder.traverseToParent();
+ ydtBuilder.addLeaf("departmentId", MATERIALNS, "xyz");
+ ydtBuilder.traverseToParent();
+ ydtBuilder.traverseToParent();
+
+ ydtBuilder.addChild("supervisor", MATERIALNS);
+ ydtBuilder.addLeaf("name", MATERIALNS, "ab");
+ ydtBuilder.traverseToParent();
+ ydtBuilder.addLeaf("departmentId", MATERIALNS, "xy");
+ ydtBuilder.traverseToParent();
+ ydtBuilder.traverseToParent();
+
+ ydtBuilder.traverseToParent();
+
+ ydtBuilder.addChild("purchasingsupervisor", PURCHASNS, MERGE);
+ ydtBuilder.addChild("supervisor", PURCHASNS);
+ ydtBuilder.addLeaf("purchasing-specialist", PURCHASNS, "abc");
+ ydtBuilder.traverseToParent();
+ ydtBuilder.addLeaf("support", "ydt.purchasing-supervisor", "xyz");
+ ydtBuilder.traverseToParent();
+ ydtBuilder.traverseToParent();
+
+ ydtBuilder.traverseToParent();
+
+ ydtBuilder.addChild("warehousesupervisor", WAREHNS, MERGE);
+ ydtBuilder.addLeaf("supervisor", WAREHNS, valueSet);
+ ydtBuilder.traverseToParent();
+ ydtBuilder.traverseToParent();
+
+ ydtBuilder.addChild("tradingsupervisor", TRADNS, MERGE);
+ ydtBuilder.addLeaf("supervisor", TRADNS, "abc");
+ ydtBuilder.traverseToParent();
+ ydtBuilder.traverseToParent();
+
+ ydtBuilder.addChild("employeeid", EMPNS, MERGE);
+ ydtBuilder.addLeaf("employeeid", EMPNS, valueSet);
+ ydtBuilder.traverseToParent();
+ ydtBuilder.traverseToParent();
+ return ydtBuilder;
+ }
+
+ /**
+ * Returns the ydt builder for bit module.
+ *
+ * @return ydt builder
+ */
+ public static YangRequestWorkBench bitYdt() {
+ YangRequestWorkBench ydtBuilder;
+ ydtBuilder = getYdtBuilder("builtInType", "bit", "ydt.bit", MERGE);
+ ydtBuilder.addChild("bitList", null);
+ ydtBuilder.addLeaf("bit", null, "disable-nagle");
+ ydtBuilder.traverseToParent();
+ ydtBuilder.traverseToParent();
+ ydtBuilder.addChild("bitList", null);
+ ydtBuilder.addLeaf("bit", null, "auto-sense-speed");
+ ydtBuilder.traverseToParent();
+ ydtBuilder.traverseToParent();
+ ydtBuilder.addChild("bitList", null);
+ ydtBuilder.addLeaf("bit", null, "ten-Mb-only");
+ ydtBuilder.traverseToParent();
+ ydtBuilder.traverseToParent();
+ ydtBuilder.addChild("bitList", null);
+ ydtBuilder.traverseToParent();
+ ydtBuilder.traverseToParent();
+ return ydtBuilder;
+ }
+
+ /**
+ * Returns the ydt builder for bool module.
+ *
+ * @return ydt builder
+ */
+ public static YangRequestWorkBench booleanYdt() {
+
+ YangRequestWorkBench ydtBuilder;
+ ydtBuilder = getYdtBuilder("builtInType", "bool", "ydt.boolean", MERGE);
+ ydtBuilder.addChild("booleanList", null);
+ ydtBuilder.addLeaf("boolean", null, "true");
+ ydtBuilder.traverseToParent();
+ ydtBuilder.traverseToParent();
+ ydtBuilder.addChild("booleanList", null);
+ ydtBuilder.addLeaf("boolean", null, "false");
+ ydtBuilder.traverseToParent();
+
+ return ydtBuilder;
+ }
+
+ /**
+ * Returns the ydt builder for emptydata module.
+ *
+ * @return ydt builder
+ */
+ public static YangRequestWorkBench emptyTypeYdt() {
+
+ YangRequestWorkBench ydtBuilder;
+ ydtBuilder = getYdtBuilder(
+ "builtInType", "emptydata", "ydt.emptydata", MERGE);
+ ydtBuilder.addChild("emptyList", null);
+ ydtBuilder.addLeaf("empty", null, "");
+
+ return ydtBuilder;
+ }
+
+ /**
+ * Returns the ydt builder for enumtest module.
+ *
+ * @return ydt builder
+ */
+ public static YangRequestWorkBench enumYdt() {
+
+ YangRequestWorkBench ydtBuilder;
+ ydtBuilder = getYdtBuilder(
+ "builtInType", "enumtest", "ydt.enumtest", MERGE);
+ ydtBuilder.addChild("enumList", null);
+ ydtBuilder.addLeaf("enumleaf", null, "ten");
+ ydtBuilder.traverseToParent();
+ ydtBuilder.traverseToParent();
+ ydtBuilder.addChild("enumList", null);
+ ydtBuilder.addLeaf("enumleaf", null, "hundred");
+ ydtBuilder.traverseToParent();
+ ydtBuilder.traverseToParent();
+ ydtBuilder.addChild("enumList", null);
+ ydtBuilder.addLeaf("enumleaf", null, "thousand");
+
+ return ydtBuilder;
+ }
+
+ /**
+ * Returns the ydt builder for builtin type integer8 module.
+ *
+ * @return ydt builder
+ */
+ public static YangRequestWorkBench integer8Ydt() {
+
+ YangRequestWorkBench ydtBuilder;
+ ydtBuilder = getYdtBuilder(
+ "builtInType", "integer8", "ydt.integer8", MERGE);
+ ydtBuilder.addLeaf("negInt", null, "-128");
+ ydtBuilder.traverseToParent();
+ ydtBuilder.addLeaf("posInt", null, "127");
+ ydtBuilder.traverseToParent();
+
+ ydtBuilder.addLeaf("minUInt", null, "0");
+ ydtBuilder.traverseToParent();
+ ydtBuilder.addLeaf("maxUInt", null, "255");
+ ydtBuilder.traverseToParent();
+
+ ydtBuilder.addLeaf("midIntWithRange", null, "11");
+ ydtBuilder.traverseToParent();
+ ydtBuilder.addLeaf("minIntWithRange", null, "10");
+ ydtBuilder.traverseToParent();
+ ydtBuilder.addLeaf("maxIntWithRange", null, "100");
+ ydtBuilder.traverseToParent();
+
+ ydtBuilder.addLeaf("midUIntWithRange", null, "11");
+ ydtBuilder.traverseToParent();
+ ydtBuilder.addLeaf("minUIntWithRange", null, "10");
+ ydtBuilder.traverseToParent();
+ ydtBuilder.addLeaf("maxUIntWithRange", null, "100");
+ ydtBuilder.traverseToParent();
+
+ ydtBuilder.addChild(MRV, null, YdtType.MULTI_INSTANCE_NODE);
+ ydtBuilder.addLeaf("integer", null, "11");
+ ydtBuilder.traverseToParent();
+ ydtBuilder.traverseToParent();
+
+ ydtBuilder.addChild(MRV, null, YdtType.MULTI_INSTANCE_NODE);
+ ydtBuilder.addLeaf("integer", null, "10");
+ ydtBuilder.traverseToParent();
+ ydtBuilder.traverseToParent();
+ ydtBuilder.addChild(MRV, null, YdtType.MULTI_INSTANCE_NODE);
+ ydtBuilder.addLeaf("integer", null, "40");
+ ydtBuilder.traverseToParent();
+ ydtBuilder.traverseToParent();
+ ydtBuilder.addChild(MRV, null, YdtType.MULTI_INSTANCE_NODE);
+ ydtBuilder.addLeaf("integer", null, "50");
+ ydtBuilder.traverseToParent();
+ ydtBuilder.traverseToParent();
+ ydtBuilder.addChild(MRV, null, YdtType.MULTI_INSTANCE_NODE);
+ ydtBuilder.addLeaf("integer", null, "55");
+ ydtBuilder.traverseToParent();
+ ydtBuilder.traverseToParent();
+ ydtBuilder.addChild(MRV, null, YdtType.MULTI_INSTANCE_NODE);
+ ydtBuilder.addLeaf("integer", null, "100");
+ ydtBuilder.traverseToParent();
+ ydtBuilder.traverseToParent();
+
+ ydtBuilder.addChild(MRV, null);
+ ydtBuilder.addLeaf("UnInteger", null, "11");
+ ydtBuilder.traverseToParent();
+ ydtBuilder.traverseToParent();
+ ydtBuilder.addChild(MRV, null, YdtType.MULTI_INSTANCE_NODE);
+ ydtBuilder.addLeaf("UnInteger", null, "10");
+ ydtBuilder.traverseToParent();
+ ydtBuilder.traverseToParent();
+ ydtBuilder.addChild(MRV, null, YdtType.MULTI_INSTANCE_NODE);
+ ydtBuilder.addLeaf("UnInteger", null, "40");
+ ydtBuilder.traverseToParent();
+ ydtBuilder.traverseToParent();
+ ydtBuilder.addChild(MRV, null, YdtType.MULTI_INSTANCE_NODE);
+ ydtBuilder.addLeaf("UnInteger", null, "50");
+ ydtBuilder.traverseToParent();
+ ydtBuilder.traverseToParent();
+ ydtBuilder.addChild(MRV, null, YdtType.MULTI_INSTANCE_NODE);
+ ydtBuilder.addLeaf("UnInteger", null, "55");
+ ydtBuilder.traverseToParent();
+ ydtBuilder.traverseToParent();
+ ydtBuilder.addChild(MRV, null, YdtType.MULTI_INSTANCE_NODE);
+ ydtBuilder.addLeaf("UnInteger", null, "100");
+ ydtBuilder.traverseToParent();
+ ydtBuilder.traverseToParent();
+
+ ydtBuilder.addChild(MRV, null);
+ ydtBuilder.addLeaf("revInteger", null, "-128");
+ ydtBuilder.traverseToParent();
+ ydtBuilder.traverseToParent();
+ ydtBuilder.addChild(MRV, null, YdtType.MULTI_INSTANCE_NODE);
+ ydtBuilder.addLeaf("revInteger", null, "1");
+ ydtBuilder.traverseToParent();
+ ydtBuilder.traverseToParent();
+ ydtBuilder.addChild(MRV, null, YdtType.MULTI_INSTANCE_NODE);
+ ydtBuilder.addLeaf("revInteger", null, "2");
+ ydtBuilder.traverseToParent();
+ ydtBuilder.traverseToParent();
+ ydtBuilder.addChild(MRV, null, YdtType.MULTI_INSTANCE_NODE);
+ ydtBuilder.addLeaf("revInteger", null, "10");
+ ydtBuilder.traverseToParent();
+ ydtBuilder.traverseToParent();
+ ydtBuilder.addChild(MRV, null, YdtType.MULTI_INSTANCE_NODE);
+ ydtBuilder.addLeaf("revInteger", null, "20");
+ ydtBuilder.traverseToParent();
+ ydtBuilder.traverseToParent();
+ ydtBuilder.addChild(MRV, null, YdtType.MULTI_INSTANCE_NODE);
+ ydtBuilder.addLeaf("revInteger", null, "100");
+ ydtBuilder.traverseToParent();
+ ydtBuilder.traverseToParent();
+ ydtBuilder.addChild(MRV, null, YdtType.MULTI_INSTANCE_NODE);
+ ydtBuilder.addLeaf("revInteger", null, "127");
+ ydtBuilder.traverseToParent();
+ ydtBuilder.traverseToParent();
+
+ ydtBuilder.addChild(MRV, null, YdtType.MULTI_INSTANCE_NODE);
+ ydtBuilder.addLeaf("revUnInteger", null, "0");
+ ydtBuilder.traverseToParent();
+ ydtBuilder.traverseToParent();
+ ydtBuilder.addChild(MRV, null, YdtType.MULTI_INSTANCE_NODE);
+ ydtBuilder.addLeaf("revUnInteger", null, "1");
+ ydtBuilder.traverseToParent();
+ ydtBuilder.traverseToParent();
+ ydtBuilder.addChild(MRV, null, YdtType.MULTI_INSTANCE_NODE);
+ ydtBuilder.addLeaf("revUnInteger", null, "2");
+ ydtBuilder.traverseToParent();
+ ydtBuilder.traverseToParent();
+ ydtBuilder.addChild(MRV, null, YdtType.MULTI_INSTANCE_NODE);
+ ydtBuilder.addLeaf("revUnInteger", null, "10");
+ ydtBuilder.traverseToParent();
+ ydtBuilder.traverseToParent();
+ ydtBuilder.addChild(MRV, null, YdtType.MULTI_INSTANCE_NODE);
+ ydtBuilder.addLeaf("revUnInteger", null, "20");
+ ydtBuilder.traverseToParent();
+ ydtBuilder.traverseToParent();
+ ydtBuilder.addChild(MRV, null, YdtType.MULTI_INSTANCE_NODE);
+ ydtBuilder.addLeaf("revUnInteger", null, "100");
+ ydtBuilder.traverseToParent();
+ ydtBuilder.traverseToParent();
+ ydtBuilder.addChild(MRV, null, YdtType.MULTI_INSTANCE_NODE);
+ ydtBuilder.addLeaf("revUnInteger", null, "255");
+ ydtBuilder.traverseToParent();
+ ydtBuilder.traverseToParent();
+
+ return ydtBuilder;
+ }
+
+ /**
+ * Returns the ydt builder for builtin type integer16 module.
+ *
+ * @return ydt builder
+ */
+ public static YangRequestWorkBench integer16Ydt() {
+
+ YangRequestWorkBench ydtBuilder;
+ ydtBuilder = getYdtBuilder(
+ "builtInType", "integer16", "ydt.integer16", MERGE);
+ ydtBuilder.addLeaf("negInt", null, "-32768");
+ ydtBuilder.traverseToParent();
+ ydtBuilder.addLeaf("posInt", null, "32767");
+ ydtBuilder.traverseToParent();
+
+ ydtBuilder.addLeaf("minUInt", null, "0");
+ ydtBuilder.traverseToParent();
+ ydtBuilder.addLeaf("maxUInt", null, "65535");
+ ydtBuilder.traverseToParent();
+
+ ydtBuilder.addLeaf("midIntWithRange", null, "11");
+ ydtBuilder.traverseToParent();
+ ydtBuilder.addLeaf("minIntWithRange", null, "10");
+ ydtBuilder.traverseToParent();
+ ydtBuilder.addLeaf("maxIntWithRange", null, "100");
+ ydtBuilder.traverseToParent();
+
+ ydtBuilder.addLeaf("midUIntWithRange", null, "11");
+ ydtBuilder.traverseToParent();
+ ydtBuilder.addLeaf("minUIntWithRange", null, "10");
+ ydtBuilder.traverseToParent();
+ ydtBuilder.addLeaf("maxUIntWithRange", null, "100");
+ ydtBuilder.traverseToParent();
+
+ ydtBuilder.addChild(MRV, null, YdtType.MULTI_INSTANCE_NODE);
+ ydtBuilder.addLeaf("integer", null, "11");
+ ydtBuilder.traverseToParent();
+ ydtBuilder.traverseToParent();
+
+ ydtBuilder.addChild(MRV, null, YdtType.MULTI_INSTANCE_NODE);
+ ydtBuilder.addLeaf("integer", null, "10");
+ ydtBuilder.traverseToParent();
+ ydtBuilder.traverseToParent();
+ ydtBuilder.addChild(MRV, null, YdtType.MULTI_INSTANCE_NODE);
+ ydtBuilder.addLeaf("integer", null, "40");
+ ydtBuilder.traverseToParent();
+ ydtBuilder.traverseToParent();
+ ydtBuilder.addChild(MRV, null, YdtType.MULTI_INSTANCE_NODE);
+ ydtBuilder.addLeaf("integer", null, "50");
+ ydtBuilder.traverseToParent();
+ ydtBuilder.traverseToParent();
+ ydtBuilder.addChild(MRV, null, YdtType.MULTI_INSTANCE_NODE);
+ ydtBuilder.addLeaf("integer", null, "55");
+ ydtBuilder.traverseToParent();
+ ydtBuilder.traverseToParent();
+ ydtBuilder.addChild(MRV, null, YdtType.MULTI_INSTANCE_NODE);
+ ydtBuilder.addLeaf("integer", null, "100");
+ ydtBuilder.traverseToParent();
+ ydtBuilder.traverseToParent();
+
+ ydtBuilder.addChild(MRV, null);
+ ydtBuilder.addLeaf("UnInteger", null, "11");
+ ydtBuilder.traverseToParent();
+ ydtBuilder.traverseToParent();
+ ydtBuilder.addChild(MRV, null, YdtType.MULTI_INSTANCE_NODE);
+ ydtBuilder.addLeaf("UnInteger", null, "10");
+ ydtBuilder.traverseToParent();
+ ydtBuilder.traverseToParent();
+ ydtBuilder.addChild(MRV, null, YdtType.MULTI_INSTANCE_NODE);
+ ydtBuilder.addLeaf("UnInteger", null, "40");
+ ydtBuilder.traverseToParent();
+ ydtBuilder.traverseToParent();
+ ydtBuilder.addChild(MRV, null, YdtType.MULTI_INSTANCE_NODE);
+ ydtBuilder.addLeaf("UnInteger", null, "50");
+ ydtBuilder.traverseToParent();
+ ydtBuilder.traverseToParent();
+ ydtBuilder.addChild(MRV, null, YdtType.MULTI_INSTANCE_NODE);
+ ydtBuilder.addLeaf("UnInteger", null, "55");
+ ydtBuilder.traverseToParent();
+ ydtBuilder.traverseToParent();
+ ydtBuilder.addChild(MRV, null, YdtType.MULTI_INSTANCE_NODE);
+ ydtBuilder.addLeaf("UnInteger", null, "100");
+ ydtBuilder.traverseToParent();
+ ydtBuilder.traverseToParent();
+
+ ydtBuilder.addChild(MRV, null);
+ ydtBuilder.addLeaf("revInteger", null, "-32768");
+ ydtBuilder.traverseToParent();
+ ydtBuilder.traverseToParent();
+ ydtBuilder.addChild(MRV, null, YdtType.MULTI_INSTANCE_NODE);
+ ydtBuilder.addLeaf("revInteger", null, "1");
+ ydtBuilder.traverseToParent();
+ ydtBuilder.traverseToParent();
+ ydtBuilder.addChild(MRV, null, YdtType.MULTI_INSTANCE_NODE);
+ ydtBuilder.addLeaf("revInteger", null, "2");
+ ydtBuilder.traverseToParent();
+ ydtBuilder.traverseToParent();
+ ydtBuilder.addChild(MRV, null, YdtType.MULTI_INSTANCE_NODE);
+ ydtBuilder.addLeaf("revInteger", null, "10");
+ ydtBuilder.traverseToParent();
+ ydtBuilder.traverseToParent();
+ ydtBuilder.addChild(MRV, null, YdtType.MULTI_INSTANCE_NODE);
+ ydtBuilder.addLeaf("revInteger", null, "20");
+ ydtBuilder.traverseToParent();
+ ydtBuilder.traverseToParent();
+ ydtBuilder.addChild(MRV, null, YdtType.MULTI_INSTANCE_NODE);
+ ydtBuilder.addLeaf("revInteger", null, "100");
+ ydtBuilder.traverseToParent();
+ ydtBuilder.traverseToParent();
+ ydtBuilder.addChild(MRV, null, YdtType.MULTI_INSTANCE_NODE);
+ ydtBuilder.addLeaf("revInteger", null, "32767");
+ ydtBuilder.traverseToParent();
+ ydtBuilder.traverseToParent();
+
+ ydtBuilder.addChild(MRV, null, YdtType.MULTI_INSTANCE_NODE);
+ ydtBuilder.addLeaf("revUnInteger", null, "0");
+ ydtBuilder.traverseToParent();
+ ydtBuilder.traverseToParent();
+ ydtBuilder.addChild(MRV, null, YdtType.MULTI_INSTANCE_NODE);
+ ydtBuilder.addLeaf("revUnInteger", null, "1");
+ ydtBuilder.traverseToParent();
+ ydtBuilder.traverseToParent();
+ ydtBuilder.addChild(MRV, null, YdtType.MULTI_INSTANCE_NODE);
+ ydtBuilder.addLeaf("revUnInteger", null, "2");
+ ydtBuilder.traverseToParent();
+ ydtBuilder.traverseToParent();
+ ydtBuilder.addChild(MRV, null, YdtType.MULTI_INSTANCE_NODE);
+ ydtBuilder.addLeaf("revUnInteger", null, "10");
+ ydtBuilder.traverseToParent();
+ ydtBuilder.traverseToParent();
+ ydtBuilder.addChild(MRV, null, YdtType.MULTI_INSTANCE_NODE);
+ ydtBuilder.addLeaf("revUnInteger", null, "20");
+ ydtBuilder.traverseToParent();
+ ydtBuilder.traverseToParent();
+ ydtBuilder.addChild(MRV, null, YdtType.MULTI_INSTANCE_NODE);
+ ydtBuilder.addLeaf("revUnInteger", null, "100");
+ ydtBuilder.traverseToParent();
+ ydtBuilder.traverseToParent();
+ ydtBuilder.addChild(MRV, null, YdtType.MULTI_INSTANCE_NODE);
+ ydtBuilder.addLeaf("revUnInteger", null, "65535");
+ ydtBuilder.traverseToParent();
+ ydtBuilder.traverseToParent();
+
+ return ydtBuilder;
+ }
+
+ /**
+ * Returns the ydt builder for builtin type integer32 module.
+ *
+ * @return ydt builder
+ */
+ public static YangRequestWorkBench integer32Ydt() {
+
+ YangRequestWorkBench ydtBuilder;
+ ydtBuilder = getYdtBuilder(
+ "builtInType", "integer32", "ydt.integer32", MERGE);
+ ydtBuilder.addLeaf("negInt", null, "-2147483648");
+ ydtBuilder.traverseToParent();
+ ydtBuilder.addLeaf("posInt", null, "2147483647");
+ ydtBuilder.traverseToParent();
+
+ ydtBuilder.addLeaf("minUInt", null, "0");
+ ydtBuilder.traverseToParent();
+ ydtBuilder.addLeaf("maxUInt", null, "4294967295");
+ ydtBuilder.traverseToParent();
+
+ ydtBuilder.addLeaf("midIntWithRange", null, "11");
+ ydtBuilder.traverseToParent();
+ ydtBuilder.addLeaf("minIntWithRange", null, "10");
+ ydtBuilder.traverseToParent();
+ ydtBuilder.addLeaf("maxIntWithRange", null, "100");
+ ydtBuilder.traverseToParent();
+
+ ydtBuilder.addLeaf("midUIntWithRange", null, "11");
+ ydtBuilder.traverseToParent();
+ ydtBuilder.addLeaf("minUIntWithRange", null, "10");
+ ydtBuilder.traverseToParent();
+ ydtBuilder.addLeaf("maxUIntWithRange", null, "100");
+ ydtBuilder.traverseToParent();
+
+ ydtBuilder.addChild(MRV, null, YdtType.MULTI_INSTANCE_NODE);
+ ydtBuilder.addLeaf("integer", null, "11");
+ ydtBuilder.traverseToParent();
+ ydtBuilder.traverseToParent();
+
+ ydtBuilder.addChild(MRV, null, YdtType.MULTI_INSTANCE_NODE);
+ ydtBuilder.addLeaf("integer", null, "10");
+ ydtBuilder.traverseToParent();
+ ydtBuilder.traverseToParent();
+ ydtBuilder.addChild(MRV, null, YdtType.MULTI_INSTANCE_NODE);
+ ydtBuilder.addLeaf("integer", null, "40");
+ ydtBuilder.traverseToParent();
+ ydtBuilder.traverseToParent();
+ ydtBuilder.addChild(MRV, null, YdtType.MULTI_INSTANCE_NODE);
+ ydtBuilder.addLeaf("integer", null, "50");
+ ydtBuilder.traverseToParent();
+ ydtBuilder.traverseToParent();
+ ydtBuilder.addChild(MRV, null, YdtType.MULTI_INSTANCE_NODE);
+ ydtBuilder.addLeaf("integer", null, "55");
+ ydtBuilder.traverseToParent();
+ ydtBuilder.traverseToParent();
+ ydtBuilder.addChild(MRV, null, YdtType.MULTI_INSTANCE_NODE);
+ ydtBuilder.addLeaf("integer", null, "100");
+ ydtBuilder.traverseToParent();
+ ydtBuilder.traverseToParent();
+
+ ydtBuilder.addChild(MRV, null);
+ ydtBuilder.addLeaf("UnInteger", null, "11");
+ ydtBuilder.traverseToParent();
+ ydtBuilder.traverseToParent();
+ ydtBuilder.addChild(MRV, null, YdtType.MULTI_INSTANCE_NODE);
+ ydtBuilder.addLeaf("UnInteger", null, "10");
+ ydtBuilder.traverseToParent();
+ ydtBuilder.traverseToParent();
+ ydtBuilder.addChild(MRV, null, YdtType.MULTI_INSTANCE_NODE);
+ ydtBuilder.addLeaf("UnInteger", null, "40");
+ ydtBuilder.traverseToParent();
+ ydtBuilder.traverseToParent();
+ ydtBuilder.addChild(MRV, null, YdtType.MULTI_INSTANCE_NODE);
+ ydtBuilder.addLeaf("UnInteger", null, "50");
+ ydtBuilder.traverseToParent();
+ ydtBuilder.traverseToParent();
+ ydtBuilder.addChild(MRV, null, YdtType.MULTI_INSTANCE_NODE);
+ ydtBuilder.addLeaf("UnInteger", null, "55");
+ ydtBuilder.traverseToParent();
+ ydtBuilder.traverseToParent();
+ ydtBuilder.addChild(MRV, null, YdtType.MULTI_INSTANCE_NODE);
+ ydtBuilder.addLeaf("UnInteger", null, "100");
+ ydtBuilder.traverseToParent();
+ ydtBuilder.traverseToParent();
+
+ ydtBuilder.addChild(MRV, null);
+ ydtBuilder.addLeaf("revInteger", null, "-2147483648");
+ ydtBuilder.traverseToParent();
+ ydtBuilder.traverseToParent();
+ ydtBuilder.addChild(MRV, null, YdtType.MULTI_INSTANCE_NODE);
+ ydtBuilder.addLeaf("revInteger", null, "1");
+ ydtBuilder.traverseToParent();
+ ydtBuilder.traverseToParent();
+ ydtBuilder.addChild(MRV, null, YdtType.MULTI_INSTANCE_NODE);
+ ydtBuilder.addLeaf("revInteger", null, "2");
+ ydtBuilder.traverseToParent();
+ ydtBuilder.traverseToParent();
+ ydtBuilder.addChild(MRV, null, YdtType.MULTI_INSTANCE_NODE);
+ ydtBuilder.addLeaf("revInteger", null, "10");
+ ydtBuilder.traverseToParent();
+ ydtBuilder.traverseToParent();
+ ydtBuilder.addChild(MRV, null, YdtType.MULTI_INSTANCE_NODE);
+ ydtBuilder.addLeaf("revInteger", null, "20");
+ ydtBuilder.traverseToParent();
+ ydtBuilder.traverseToParent();
+ ydtBuilder.addChild(MRV, null, YdtType.MULTI_INSTANCE_NODE);
+ ydtBuilder.addLeaf("revInteger", null, "100");
+ ydtBuilder.traverseToParent();
+ ydtBuilder.traverseToParent();
+ ydtBuilder.addChild(MRV, null, YdtType.MULTI_INSTANCE_NODE);
+ ydtBuilder.addLeaf("revInteger", null, "2147483647");
+ ydtBuilder.traverseToParent();
+ ydtBuilder.traverseToParent();
+
+ ydtBuilder.addChild(MRV, null, YdtType.MULTI_INSTANCE_NODE);
+ ydtBuilder.addLeaf("revUnInteger", null, "0");
+ ydtBuilder.traverseToParent();
+ ydtBuilder.traverseToParent();
+ ydtBuilder.addChild(MRV, null, YdtType.MULTI_INSTANCE_NODE);
+ ydtBuilder.addLeaf("revUnInteger", null, "1");
+ ydtBuilder.traverseToParent();
+ ydtBuilder.traverseToParent();
+ ydtBuilder.addChild(MRV, null, YdtType.MULTI_INSTANCE_NODE);
+ ydtBuilder.addLeaf("revUnInteger", null, "2");
+ ydtBuilder.traverseToParent();
+ ydtBuilder.traverseToParent();
+ ydtBuilder.addChild(MRV, null, YdtType.MULTI_INSTANCE_NODE);
+ ydtBuilder.addLeaf("revUnInteger", null, "10");
+ ydtBuilder.traverseToParent();
+ ydtBuilder.traverseToParent();
+ ydtBuilder.addChild(MRV, null, YdtType.MULTI_INSTANCE_NODE);
+ ydtBuilder.addLeaf("revUnInteger", null, "20");
+ ydtBuilder.traverseToParent();
+ ydtBuilder.traverseToParent();
+ ydtBuilder.addChild(MRV, null, YdtType.MULTI_INSTANCE_NODE);
+ ydtBuilder.addLeaf("revUnInteger", null, "100");
+ ydtBuilder.traverseToParent();
+ ydtBuilder.traverseToParent();
+ ydtBuilder.addChild(MRV, null, YdtType.MULTI_INSTANCE_NODE);
+ ydtBuilder.addLeaf("revUnInteger", null, "4294967295");
+ ydtBuilder.traverseToParent();
+ ydtBuilder.traverseToParent();
+
+ return ydtBuilder;
+ }
+
+ /**
+ * Returns the ydt builder for builtin type integer64 module.
+ *
+ * @return ydt builder
+ */
+ public static YangRequestWorkBench integer64Ydt() {
+
+ YangRequestWorkBench ydtBuilder;
+ ydtBuilder = getYdtBuilder(
+ "builtInType", "integer64", "ydt.integer64", MERGE);
+ ydtBuilder.addLeaf("negInt", null, "-9223372036854775808");
+ ydtBuilder.traverseToParent();
+ ydtBuilder.addLeaf("posInt", null, "9223372036854775807");
+ ydtBuilder.traverseToParent();
+
+ ydtBuilder.addLeaf("minUInt", null, "0");
+ ydtBuilder.traverseToParent();
+ ydtBuilder.addLeaf("maxUInt", null, "18446744073709551615");
+ ydtBuilder.traverseToParent();
+
+ ydtBuilder.addLeaf("midIntWithRange", null, "11");
+ ydtBuilder.traverseToParent();
+ ydtBuilder.addLeaf("minIntWithRange", null, "10");
+ ydtBuilder.traverseToParent();
+ ydtBuilder.addLeaf("maxIntWithRange", null, "100");
+ ydtBuilder.traverseToParent();
+
+ ydtBuilder.addLeaf("midUIntWithRange", null, "11");
+ ydtBuilder.traverseToParent();
+ ydtBuilder.addLeaf("minUIntWithRange", null, "10");
+ ydtBuilder.traverseToParent();
+ ydtBuilder.addLeaf("maxUIntWithRange", null, "100");
+ ydtBuilder.traverseToParent();
+
+ ydtBuilder.addChild(MRV, null, YdtType.MULTI_INSTANCE_NODE);
+ ydtBuilder.addLeaf("integer", null, "11");
+ ydtBuilder.traverseToParent();
+ ydtBuilder.traverseToParent();
+
+ ydtBuilder.addChild(MRV, null, YdtType.MULTI_INSTANCE_NODE);
+ ydtBuilder.addLeaf("integer", null, "10");
+ ydtBuilder.traverseToParent();
+ ydtBuilder.traverseToParent();
+ ydtBuilder.addChild(MRV, null, YdtType.MULTI_INSTANCE_NODE);
+ ydtBuilder.addLeaf("integer", null, "40");
+ ydtBuilder.traverseToParent();
+ ydtBuilder.traverseToParent();
+ ydtBuilder.addChild(MRV, null, YdtType.MULTI_INSTANCE_NODE);
+ ydtBuilder.addLeaf("integer", null, "50");
+ ydtBuilder.traverseToParent();
+ ydtBuilder.traverseToParent();
+ ydtBuilder.addChild(MRV, null, YdtType.MULTI_INSTANCE_NODE);
+ ydtBuilder.addLeaf("integer", null, "55");
+ ydtBuilder.traverseToParent();
+ ydtBuilder.traverseToParent();
+ ydtBuilder.addChild(MRV, null, YdtType.MULTI_INSTANCE_NODE);
+ ydtBuilder.addLeaf("integer", null, "100");
+ ydtBuilder.traverseToParent();
+ ydtBuilder.traverseToParent();
+
+ ydtBuilder.addChild(MRV, null);
+ ydtBuilder.addLeaf("UnInteger", null, "11");
+ ydtBuilder.traverseToParent();
+ ydtBuilder.traverseToParent();
+ ydtBuilder.addChild(MRV, null, YdtType.MULTI_INSTANCE_NODE);
+ ydtBuilder.addLeaf("UnInteger", null, "10");
+ ydtBuilder.traverseToParent();
+ ydtBuilder.traverseToParent();
+ ydtBuilder.addChild(MRV, null, YdtType.MULTI_INSTANCE_NODE);
+ ydtBuilder.addLeaf("UnInteger", null, "40");
+ ydtBuilder.traverseToParent();
+ ydtBuilder.traverseToParent();
+ ydtBuilder.addChild(MRV, null, YdtType.MULTI_INSTANCE_NODE);
+ ydtBuilder.addLeaf("UnInteger", null, "50");
+ ydtBuilder.traverseToParent();
+ ydtBuilder.traverseToParent();
+ ydtBuilder.addChild(MRV, null, YdtType.MULTI_INSTANCE_NODE);
+ ydtBuilder.addLeaf("UnInteger", null, "55");
+ ydtBuilder.traverseToParent();
+ ydtBuilder.traverseToParent();
+ ydtBuilder.addChild(MRV, null, YdtType.MULTI_INSTANCE_NODE);
+ ydtBuilder.addLeaf("UnInteger", null, "100");
+ ydtBuilder.traverseToParent();
+ ydtBuilder.traverseToParent();
+
+ ydtBuilder.addChild(MRV, null);
+ ydtBuilder.addLeaf("revInteger", null, "-9223372036854775808");
+ ydtBuilder.traverseToParent();
+ ydtBuilder.traverseToParent();
+ ydtBuilder.addChild(MRV, null, YdtType.MULTI_INSTANCE_NODE);
+ ydtBuilder.addLeaf("revInteger", null, "1");
+ ydtBuilder.traverseToParent();
+ ydtBuilder.traverseToParent();
+ ydtBuilder.addChild(MRV, null, YdtType.MULTI_INSTANCE_NODE);
+ ydtBuilder.addLeaf("revInteger", null, "2");
+ ydtBuilder.traverseToParent();
+ ydtBuilder.traverseToParent();
+ ydtBuilder.addChild(MRV, null, YdtType.MULTI_INSTANCE_NODE);
+ ydtBuilder.addLeaf("revInteger", null, "10");
+ ydtBuilder.traverseToParent();
+ ydtBuilder.traverseToParent();
+ ydtBuilder.addChild(MRV, null, YdtType.MULTI_INSTANCE_NODE);
+ ydtBuilder.addLeaf("revInteger", null, "20");
+ ydtBuilder.traverseToParent();
+ ydtBuilder.traverseToParent();
+ ydtBuilder.addChild(MRV, null, YdtType.MULTI_INSTANCE_NODE);
+ ydtBuilder.addLeaf("revInteger", null, "100");
+ ydtBuilder.traverseToParent();
+ ydtBuilder.traverseToParent();
+ ydtBuilder.addChild(MRV, null, YdtType.MULTI_INSTANCE_NODE);
+ ydtBuilder.addLeaf("revInteger", null, "9223372036854775807");
+ ydtBuilder.traverseToParent();
+ ydtBuilder.traverseToParent();
+
+ ydtBuilder.addChild(MRV, null, YdtType.MULTI_INSTANCE_NODE);
+ ydtBuilder.addLeaf("revUnInteger", null, "0");
+ ydtBuilder.traverseToParent();
+ ydtBuilder.traverseToParent();
+ ydtBuilder.addChild(MRV, null, YdtType.MULTI_INSTANCE_NODE);
+ ydtBuilder.addLeaf("revUnInteger", null, "1");
+ ydtBuilder.traverseToParent();
+ ydtBuilder.traverseToParent();
+ ydtBuilder.addChild(MRV, null, YdtType.MULTI_INSTANCE_NODE);
+ ydtBuilder.addLeaf("revUnInteger", null, "2");
+ ydtBuilder.traverseToParent();
+ ydtBuilder.traverseToParent();
+ ydtBuilder.addChild(MRV, null, YdtType.MULTI_INSTANCE_NODE);
+ ydtBuilder.addLeaf("revUnInteger", null, "10");
+ ydtBuilder.traverseToParent();
+ ydtBuilder.traverseToParent();
+ ydtBuilder.addChild(MRV, null, YdtType.MULTI_INSTANCE_NODE);
+ ydtBuilder.addLeaf("revUnInteger", null, "20");
+ ydtBuilder.traverseToParent();
+ ydtBuilder.traverseToParent();
+ ydtBuilder.addChild(MRV, null, YdtType.MULTI_INSTANCE_NODE);
+ ydtBuilder.addLeaf("revUnInteger", null, "100");
+ ydtBuilder.traverseToParent();
+ ydtBuilder.traverseToParent();
+ ydtBuilder.addChild(MRV, null, YdtType.MULTI_INSTANCE_NODE);
+ ydtBuilder.addLeaf("revUnInteger", null, "18446744073709551615");
+ ydtBuilder.traverseToParent();
+ ydtBuilder.traverseToParent();
+
+ return ydtBuilder;
+ }
+
+ /**
+ * Returns the ydt builder for builtin type decimal64 module.
+ *
+ * @return ydt builder
+ */
+ public static YangRequestWorkBench decimal64Ydt() {
+
+ YangRequestWorkBench ydtBuilder;
+ ydtBuilder = getYdtBuilder(
+ "builtInType", "decimal64", "ydt.decimal64", MERGE);
+ ydtBuilder.addLeaf("negInt", null, "-92233720368547758.08");
+ ydtBuilder.traverseToParent();
+ ydtBuilder.addLeaf("posInt", null, "92233720368547758.07");
+ ydtBuilder.traverseToParent();
+ ydtBuilder.addLeaf(NIWMF, null, "-922337203685477580.8");
+ ydtBuilder.traverseToParent();
+ ydtBuilder.addLeaf(PIWMF, null, "922337203685477580.7");
+ ydtBuilder.traverseToParent();
+ ydtBuilder.addLeaf(NWF, null, "-9.223372036854775808");
+ ydtBuilder.traverseToParent();
+ ydtBuilder.addLeaf(PWF, null, "9.223372036854775807");
+ ydtBuilder.traverseToParent();
+ ydtBuilder.addLeaf("midIntWithRange", null, "11");
+ ydtBuilder.traverseToParent();
+ ydtBuilder.addLeaf("minIntWithRange", null, "10");
+ ydtBuilder.traverseToParent();
+ ydtBuilder.addLeaf("maxIntWithRange", null, "100");
+ ydtBuilder.traverseToParent();
+
+ ydtBuilder.addChild(MRV, null);
+ ydtBuilder.addLeaf("decimal", null, "11");
+ ydtBuilder.traverseToParent();
+ ydtBuilder.traverseToParent();
+ ydtBuilder.addChild(MRV, null);
+ ydtBuilder.addLeaf("decimal", null, "10");
+ ydtBuilder.traverseToParent();
+ ydtBuilder.traverseToParent();
+ ydtBuilder.addChild(MRV, null);
+ ydtBuilder.addLeaf("decimal", null, "40");
+ ydtBuilder.traverseToParent();
+ ydtBuilder.traverseToParent();
+ ydtBuilder.addChild(MRV, null);
+ ydtBuilder.addLeaf("decimal", null, "50");
+ ydtBuilder.traverseToParent();
+ ydtBuilder.traverseToParent();
+ ydtBuilder.addChild(MRV, null);
+ ydtBuilder.addLeaf("decimal", null, "55");
+ ydtBuilder.traverseToParent();
+ ydtBuilder.traverseToParent();
+ ydtBuilder.addChild(MRV, null);
+ ydtBuilder.addLeaf("decimal", null, "100");
+ ydtBuilder.traverseToParent();
+ ydtBuilder.traverseToParent();
+ ydtBuilder.addChild(MRV, null);
+ ydtBuilder.addLeaf("revDecimal", null, "-92233720368547758.08");
+ ydtBuilder.traverseToParent();
+ ydtBuilder.traverseToParent();
+ ydtBuilder.addChild(MRV, null);
+ ydtBuilder.addLeaf("revDecimal", null, "2.505");
+ ydtBuilder.traverseToParent();
+ ydtBuilder.traverseToParent();
+ ydtBuilder.addChild(MRV, null);
+ ydtBuilder.addLeaf("revDecimal", null, "3.14");
+ ydtBuilder.traverseToParent();
+ ydtBuilder.traverseToParent();
+ ydtBuilder.addChild(MRV, null);
+ ydtBuilder.addLeaf("revDecimal", null, "10");
+ ydtBuilder.traverseToParent();
+ ydtBuilder.traverseToParent();
+ ydtBuilder.addChild(MRV, null);
+ ydtBuilder.addLeaf("revDecimal", null, "20");
+ ydtBuilder.traverseToParent();
+ ydtBuilder.traverseToParent();
+ ydtBuilder.addChild(MRV, null);
+ ydtBuilder.addLeaf("revDecimal", null, "92233720368547757");
+ ydtBuilder.traverseToParent();
+ ydtBuilder.traverseToParent();
+ ydtBuilder.addChild(MRV, null);
+ ydtBuilder.addLeaf("revDecimal", null, "92233720368547758.07");
+ ydtBuilder.traverseToParent();
+ ydtBuilder.traverseToParent();
+
+ return ydtBuilder;
+ }
+
+ /**
+ * Returns the ydt builder with requested logical root name and module name.
+ *
+ * @param rootName logical rootNode name
+ * @param moduleName application(module) name
+ * @param nameSpace namespace of module
+ * @param opType operation type
+ * @return ydt builder
+ */
+ public static YangRequestWorkBench getYdtBuilder(String rootName, String
+ moduleName, String nameSpace, YdtContextOperationType opType) {
+ setSchemaRegistry(schemaProvider.getDefaultYangSchemaRegistry());
+ YangRequestWorkBench ydtBuilder;
+ schemaProvider.processSchemaRegistry(null);
+ ydtBuilder = new YangRequestWorkBench(
+ rootName, null, null, schemaProvider
+ .getDefaultYangSchemaRegistry(), true);
+ ydtBuilder.addChild(moduleName, nameSpace, opType);
+ return ydtBuilder;
+ }
+
+ /**
+ * Compares the two value sets.
+ */
+ public static void compareValueSet(Set<String> valueSet,
+ Set<String> userInputValueSet) {
+ // Check the value against user input.
+ assertTrue("Expected 'valueSet' and 'userInputValueSet' to be equal.",
+ valueSet.containsAll(userInputValueSet));
+ }
+
+ /**
+ * Returns the ydt builder for Hello_ONOS module.
+ *
+ * @return ydt builder
+ */
+ public static YangRequestWorkBench helloOnos() {
+
+ YangRequestWorkBench ydtBuilder;
+ ydtBuilder = getYdtBuilder(
+ "Hello-ONOS", "Hello_ONOS", "ydt:hello_onos", MERGE);
+ ydtBuilder.addChild("hello-world", null);
+ ydtBuilder.addChild("input", null);
+ ydtBuilder.addLeaf("name", null, "onos");
+ ydtBuilder.traverseToParent();
+ ydtBuilder.addLeaf("surName", null, "yang");
+ ydtBuilder.traverseToParent();
+
+ kValList.clear();
+ kValList.add("ON");
+ kValList.add("LAB");
+ ydtBuilder.addMultiInstanceChild("stringList", null, kValList,
+ MERGE);
+ ydtBuilder.traverseToParent();
+ ydtBuilder.traverseToParent();
+ ydtBuilder.traverseToParent();
+
+ return ydtBuilder;
+ }
+
+ /**
+ * Returns the error message for requested node.
+ *
+ * @param value value in string format
+ * @param dataType requested data type
+ * @return error string
+ */
+ static String getErrorString(String value, String dataType) {
+ StringBuilder msg = new StringBuilder();
+ switch (dataType) {
+ case SINT16:
+ case SINT32:
+ case SMALLINT8:
+ case SMALLINT64:
+ case SMALLUINT8:
+ case SMALLUINT64:
+ case SUINT16:
+ case SUINT32:
+ case CAPSINT8:
+ case CAPSINT16:
+ case CAPSINT32:
+ case CAPSINT64:
+ case CAPSUINT8:
+ case CAPSUINT16:
+ case CAPSUINT32:
+ case CAPSUINT64:
+ case BIT:
+ case BOOL:
+ case ENUM:
+ msg.append("YANG file error : Input value ").append(BACKSLASH)
+ .append(value).append(BACKSLASH)
+ .append(" is not a valid ").append(dataType);
+ break;
+ case EMPTY:
+ msg.append("YANG file error : Input value ").append(BACKSLASH)
+ .append(value).append(BACKSLASH).append(
+ " is not allowed for a data type EMPTY");
+ break;
+ case MINVALUE:
+ msg.append("YANG file error : ").append(value)
+ .append(" is lesser than minimum value ")
+ .append(MINVALUE).append(PERIOD);
+ break;
+ case MAXUINT8:
+ case MAXUINT16:
+ case MAXUINT32:
+ case MAXUINT64:
+ msg.append("YANG file error : ").append(value)
+ .append(" is greater than maximum value ")
+ .append(dataType).append(PERIOD);
+ break;
+ default:
+ return null;
+ }
+ return msg.toString();
+ }
+
+ /**
+ * Validates the error message which is obtained by checking the given
+ * value against its data type restrictions.
+ *
+ * @param name leaf name
+ * @param nameSpace leaf namespace
+ * @param val leaf value
+ * @param type data type suffix string for exception message
+ * @param childName child name
+ */
+ public static void validateErrMsg(String name, String nameSpace,
+ String val, String type, String childName) {
+ YangRequestWorkBench ydtBuilder = getTestYdtBuilder(nameSpace);
+ boolean isExpOccurred = false;
+ /*
+ * If childName exist then leaf need to be added under the
+ * child node with the given childName
+ */
+ if (childName != null) {
+ ydtBuilder.addChild(childName, nameSpace);
+ }
+ /*
+ * This try catch is explicitly written to use as utility in other
+ * test cases.
+ */
+ try {
+ ydtBuilder.addLeaf(name, nameSpace, val);
+ } catch (YdtException e) {
+ isExpOccurred = true;
+ assertEquals(e.getMessage(), getErrorString(val, type));
+ }
+ assertEquals(E_LEAF + name, isExpOccurred, true);
+ }
+
+ /**
+ * Returns ydt builder for requested namespace.
+ *
+ * @param namespace namespace of the requested yang data tree
+ * @return ydt builder
+ */
+ public static YangRequestWorkBench getTestYdtBuilder(String namespace) {
+
+ switch (namespace) {
+ case INT8NS:
+ return getYdtBuilder(TYPE, "integer8", INT8NS, MERGE);
+ case INT16NS:
+ return getYdtBuilder(TYPE, "integer16", INT16NS, MERGE);
+ case INT32NS:
+ return getYdtBuilder(TYPE, "integer32", INT32NS, MERGE);
+ case INT64NS:
+ return getYdtBuilder(TYPE, "integer64", INT64NS, MERGE);
+ case BITNS:
+ return getYdtBuilder(TYPE, "bit", BITNS, MERGE);
+ case BOOLNS:
+ return getYdtBuilder(TYPE, "bool", BOOLNS, MERGE);
+ case EMPTYNS:
+ return getYdtBuilder(TYPE, "emptydata", EMPTYNS, MERGE);
+ case ENUMNS:
+ return getYdtBuilder(TYPE, "enumtest", ENUMNS, MERGE);
+ case LISTNS:
+ return getYdtBuilder(LIST, "rootlist", LISTNS, MERGE);
+ default:
+ return null;
+ }
+ }
+
+ /**
+ * Validates the contents of node like name, namespace and operation type.
+ *
+ * @param ydtNode node need to be validate
+ * @param name name of the node
+ * @param opType operation type of the node
+ */
+ public static void validateNodeContents(YdtNode ydtNode, String name,
+ YdtContextOperationType opType) {
+ assertEquals(ydtNode.getName(), name);
+ assertEquals(ydtNode.getYdtContextOperationType(), opType);
+ }
+
+ /**
+ * Validates the contents of leaf node like name, namespace and operation
+ * type.
+ *
+ * @param ydtNode node need to be validate
+ * @param name name of the node
+ * @param value value of the leaf node
+ */
+ public static void validateLeafContents(YdtNode ydtNode, String name,
+ String value) {
+ validateNodeContents(ydtNode, name, null);
+ assertEquals(ydtNode.getValue(), value);
+ }
+
+ /**
+ * Validates the contents of leaf-list node like name, namespace and
+ * operation type.
+ *
+ * @param ydtNode node need to be validate
+ * @param name name of the node
+ * @param valueSet value of the leaf node
+ */
+ public static void validateLeafListContents(YdtNode ydtNode, String name,
+ Set<String> valueSet) {
+ validateNodeContents(ydtNode, name, null);
+ compareValueSet(ydtNode.getValueSet(), valueSet);
+ }
+
+ /**
+ * Validates the contents of ydt application logical node.
+ *
+ * @param ydtAppNode node need to be validate
+ */
+ public static void validateAppLogicalNodeContents(
+ YdtAppContext ydtAppNode) {
+
+ assertNull(ydtAppNode.getOperationType());
+ assertNull(ydtAppNode.getParent());
+ assertNull(ydtAppNode.getNextSibling());
+ assertNull(ydtAppNode.getPreviousSibling());
+ assertNotNull(ydtAppNode.getFirstChild());
+ assertNotNull(ydtAppNode.getLastChild());
+ }
+
+ /**
+ * Validates the contents of ydt application module node.
+ *
+ * @param ydtAppNode node need to be validate
+ * @param name name of the node
+ * @param opType operation type of the app node
+ */
+ public static void validateAppModuleNodeContents(
+ YdtAppContext ydtAppNode, String name,
+ YdtAppNodeOperationType opType) {
+
+ assertEquals(ydtAppNode.getModuleContext().getName(), name);
+ assertEquals(ydtAppNode.getOperationType(), opType);
+ }
+
+ /**
+ * Validates the contents of ydt application node like name, namespace
+ * and operation type.
+ *
+ * @param ydtAppNode node need to be validate
+ * @param name name of the schema node
+ * @param ns namespace of the schema node
+ * @param opType operation type of the app node
+ */
+ public static void validateAppNodeContents(
+ YdtAppContext ydtAppNode, String name, String ns,
+ YdtAppNodeOperationType opType) {
+ assertEquals(ydtAppNode.getAugmentingSchemaNode().getName(), name);
+ assertEquals(ydtAppNode.getAugmentingSchemaNode().getNameSpace(), ns);
+ assertEquals(ydtAppNode.getOperationType(), opType);
+ }
+
+ /**
+ * Walks in the given built ydt and validates it.
+ */
+ public static void walkINTree(YangRequestWorkBench ydtBuilder,
+ String[] expected) {
+ DefaultYdtWalker ydtWalker = new DefaultYdtWalker();
+ resetLogger();
+
+ YdtTestUtils utils = new YdtTestUtils();
+ // Assign root node as starting node to walk the whole tree.
+ ydtWalker.walk(utils, ydtBuilder.getRootNode());
+ // Logger list is used for walker testing.
+ List<String> logger = getLogger();
+
+ for (int i = 0; i < expected.length; i++) {
+ assertEquals(expected[i], logger.get(i));
+ }
+ }
+}
diff --git a/apps/yms/app/src/test/resources/ydtTestYangFiles/Hello_ONOS.yang b/apps/yms/app/src/test/resources/ydtTestYangFiles/Hello_ONOS.yang
new file mode 100644
index 0000000..d5eafbe
--- /dev/null
+++ b/apps/yms/app/src/test/resources/ydtTestYangFiles/Hello_ONOS.yang
@@ -0,0 +1,57 @@
+module Hello_ONOS {
+ yang-version 1;
+ namespace "ydt:hello_onos";
+ prefix "hello";
+
+ revision "2016-09-03" {
+ description "Initial revision of hello model";
+ }
+
+ grouping greeting {
+ leaf name {
+ type string;
+ }
+
+ leaf surName {
+ type string;
+ }
+ }
+
+ rpc hello-world {
+ input {
+
+ // uses greeting;
+
+ leaf name {
+ type string;
+ }
+
+ leaf surName {
+ type string;
+ }
+
+ leaf inputDefault {
+ type string;
+ }
+
+ list stringList {
+ key "string1 string2";
+ unique "string3";
+ leaf string1 {
+ type string;
+ }
+ leaf string2 {
+ type string;
+ }
+ leaf string3 {
+ type string;
+ }
+ }
+ }
+ output {
+ leaf greetingOut {
+ type string;
+ }
+ }
+ }
+}
diff --git a/apps/yms/app/src/test/resources/ydtTestYangFiles/Logistics-manager.yang b/apps/yms/app/src/test/resources/ydtTestYangFiles/Logistics-manager.yang
new file mode 100644
index 0000000..3cd4321
--- /dev/null
+++ b/apps/yms/app/src/test/resources/ydtTestYangFiles/Logistics-manager.yang
@@ -0,0 +1,66 @@
+module Logistics-manager {
+
+ yang-version 1;
+
+ namespace "ydt.root";
+
+ prefix "root";
+
+ organization "ON-LAB";
+
+ description "This module defines for organisation.";
+
+ revision "2016-05-24" {
+ description "Initial revision.";
+ }
+
+ leaf Customs-supervisor {
+ type string;
+ description "name of the customs-supervisor.";
+ }
+
+ leaf Merchandiser-supervisor {
+ type string;
+ description "name of merchandiser-supervisor";
+ }
+
+ list Material-supervisor {
+ key "name";
+ leaf name {
+ type string;
+ description "name of logistics-supervisor";
+ }
+
+ leaf departmentId {
+ type string;
+ description "name of department";
+ }
+ }
+
+ container Purchasing-supervisor {
+ leaf purchasing-specialist {
+ type string;
+ description "name of the purchasing-specialist person";
+ }
+
+ leaf support {
+ type string;
+ description "name of the support person";
+ }
+ }
+
+ leaf-list Warehouse-supervisor {
+ type string;
+ description "name of the warehouse-supervisor's";
+ }
+
+ leaf trading-supervisor {
+ type string;
+ description "name of the trading-supervisor";
+ }
+
+ leaf-list employee-id {
+ type string;
+ description "list of the employee id";
+ }
+}
\ No newline at end of file
diff --git a/apps/yms/app/src/test/resources/ydtTestYangFiles/augment-topology1.yang b/apps/yms/app/src/test/resources/ydtTestYangFiles/augment-topology1.yang
new file mode 100644
index 0000000..6736063
--- /dev/null
+++ b/apps/yms/app/src/test/resources/ydtTestYangFiles/augment-topology1.yang
@@ -0,0 +1,51 @@
+module augment-topology1 {
+
+ yang-version 1;
+
+ namespace "ydt.augment-topology1";
+
+ prefix "aug1";
+
+ import yms-ietf-network {
+ prefix nd;
+ }
+
+ import yms-network-topology {
+ prefix topo;
+ }
+
+ organization "ON-LAB";
+
+ description "This module defines for augment-topology1 classifier.";
+
+ revision "2016-05-24" {
+ description "Initial revision.";
+ }
+
+ augment "/nd:networks/nd:network/topo:link" {
+ description
+ "Add augment1 to the link model.";
+ list augment1 {
+ key "value1";
+ leaf value1 {
+ type int8;
+ }
+ }
+ }
+
+ augment "/nd:networks/nd:network/nd:node/topo:t-point" +
+ "/supporting-termination-point" {
+ description
+ "Add augment1 to the termination-point model.";
+ container augment1 {
+ leaf value1 {
+ type int8;
+ }
+ }
+
+ leaf augment1-leaf {
+ type string;
+ }
+
+ }
+}
\ No newline at end of file
diff --git a/apps/yms/app/src/test/resources/ydtTestYangFiles/augment-topology2.yang b/apps/yms/app/src/test/resources/ydtTestYangFiles/augment-topology2.yang
new file mode 100644
index 0000000..82a19d7
--- /dev/null
+++ b/apps/yms/app/src/test/resources/ydtTestYangFiles/augment-topology2.yang
@@ -0,0 +1,63 @@
+module augment-topology2 {
+
+ yang-version 1;
+
+ namespace "ydt.augment-topology2";
+
+ prefix "aug2";
+
+ import yms-ietf-network {
+ prefix nd;
+ }
+
+ import yms-network-topology {
+ prefix topo;
+ }
+
+ organization "ON-LAB";
+
+ description "This module defines for augment-topology2 classifier.";
+
+ revision "2016-05-24" {
+ description "Initial revision.";
+ }
+
+ augment "/nd:networks/nd:network/topo:link" {
+ description
+ "Add augment2 to the link model.";
+ list augment2 {
+ key "key1 key2";
+ leaf key1 {
+ type int8;
+ }
+ leaf key2 {
+ type int8;
+ }
+ }
+
+ leaf-list augment2leafList {
+ type string;
+ }
+ }
+
+ augment "/nd:networks/nd:network/nd:node/topo:t-point/" +
+ "supporting-termination-point" {
+ description
+ "Add augment2 to the supporting-termination-point model.";
+ container augment2 {
+ config false;
+ leaf value2 {
+ type int8;
+ }
+ }
+
+ leaf-list augment2leafList {
+ type string;
+ }
+
+ leaf augment2leaf {
+ type string;
+ }
+
+ }
+}
\ No newline at end of file
diff --git a/apps/yms/app/src/test/resources/ydtTestYangFiles/augment-topology3.yang b/apps/yms/app/src/test/resources/ydtTestYangFiles/augment-topology3.yang
new file mode 100644
index 0000000..d2c58ce
--- /dev/null
+++ b/apps/yms/app/src/test/resources/ydtTestYangFiles/augment-topology3.yang
@@ -0,0 +1,59 @@
+module augment-topology3 {
+
+ yang-version 1;
+
+ namespace "ydt.augment-topology3";
+
+ prefix "aug3";
+
+ import yms-ietf-network {
+ prefix nd;
+ }
+
+ import augment-topology1 {
+ prefix aug1;
+ }
+
+ import augment-topology2 {
+ prefix aug2;
+ }
+
+ import yms-network-topology {
+ prefix topo;
+ }
+
+ organization "ON-LAB";
+
+ description "This module defines for augment-topology3 classifier.";
+
+ revision "2016-05-24" {
+ description "Initial revision.";
+ }
+
+ augment "/nd:networks/nd:network/topo:link/aug2:augment2" {
+ description
+ "Add augment3 to the augment2 model.";
+ container augment3 {
+ config false;
+ leaf value3 {
+ type int8;
+ }
+ }
+
+ leaf augment3leaf {
+ type string;
+ }
+ }
+
+ augment "/nd:networks/nd:network/nd:node/topo:t-point/" +
+ "supporting-termination-point/aug2:augment2" {
+ description
+ "Add augment3 to the augment2 model.";
+ container augment3 {
+ config false;
+ leaf value3 {
+ type int8;
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/apps/yms/app/src/test/resources/ydtTestYangFiles/augment-topology4.yang b/apps/yms/app/src/test/resources/ydtTestYangFiles/augment-topology4.yang
new file mode 100644
index 0000000..b8cea93
--- /dev/null
+++ b/apps/yms/app/src/test/resources/ydtTestYangFiles/augment-topology4.yang
@@ -0,0 +1,58 @@
+module augment-topology4 {
+
+ yang-version 1;
+
+ namespace "ydt.augment-topology4";
+
+ prefix "aug4";
+
+ import yms-ietf-network {
+ prefix nd;
+ }
+
+ import augment-topology1 {
+ prefix aug1;
+ }
+
+ import augment-topology2 {
+ prefix aug2;
+ }
+
+ import augment-topology3 {
+ prefix aug3;
+ }
+
+ import yms-network-topology {
+ prefix topo;
+ }
+
+ organization "ON-LAB";
+
+ description "This module defines for augment-topology4 classifier.";
+
+ revision "2016-05-24" {
+ description "Initial revision.";
+ }
+
+ augment "/nd:networks/nd:network/topo:link/aug2:augment2/aug3:augment3" {
+ description
+ "Add augment4 to the augment3 model.";
+ container augment4 {
+ config false;
+ leaf value4 {
+ type int8;
+ }
+ }
+ }
+
+ augment "/nd:networks/nd:network/nd:node/topo:t-point/" +
+ "supporting-termination-point/aug2:augment2" {
+ description
+ "Add augment4leaf to the augment2 model.";
+
+ leaf augment4leaf{
+ type string;
+ }
+
+ }
+}
\ No newline at end of file
diff --git a/apps/yms/app/src/test/resources/ydtTestYangFiles/augment-topology5.yang b/apps/yms/app/src/test/resources/ydtTestYangFiles/augment-topology5.yang
new file mode 100644
index 0000000..a13a688
--- /dev/null
+++ b/apps/yms/app/src/test/resources/ydtTestYangFiles/augment-topology5.yang
@@ -0,0 +1,66 @@
+module augment-topology5 {
+
+ yang-version 1;
+
+ namespace "ydt.augment-topology5";
+
+ prefix "aug5";
+
+ import yms-ietf-network {
+ prefix nd;
+ }
+
+ import augment-topology1 {
+ prefix aug1;
+ }
+
+ import augment-topology2 {
+ prefix aug2;
+ }
+
+ import augment-topology3 {
+ prefix aug3;
+ }
+
+ import augment-topology4 {
+ prefix aug4;
+ }
+
+ import yms-network-topology {
+ prefix topo;
+ }
+
+ organization "ON-LAB";
+
+ description "This module defines for augment-topology5 classifier.";
+
+ revision "2016-05-24" {
+ description "Initial revision.";
+ }
+
+ augment "/nd:networks/nd:network/topo:link/aug2:augment2" {
+ description
+ "Add container to the augment2 model.";
+ container augment5 {
+ config false;
+ leaf value5 {
+ type int8;
+ }
+ }
+
+ leaf-list augment5leafList {
+ type string;
+ }
+ }
+
+ augment "/nd:networks/nd:network/topo:link/aug2:augment2/aug3:augment3" {
+ description
+ "Add augment5 to the augment3 model.";
+ container augment5 {
+ config false;
+ leaf value5 {
+ type int8;
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/apps/yms/app/src/test/resources/ydtTestYangFiles/augment-topology6.yang b/apps/yms/app/src/test/resources/ydtTestYangFiles/augment-topology6.yang
new file mode 100644
index 0000000..15bd3d5
--- /dev/null
+++ b/apps/yms/app/src/test/resources/ydtTestYangFiles/augment-topology6.yang
@@ -0,0 +1,73 @@
+module augment-topology6 {
+
+ yang-version 1;
+
+ namespace "ydt.augment-topology6";
+
+ prefix "aug5";
+
+ import yms-ietf-network {
+ prefix nd;
+ }
+
+ import augment-topology1 {
+ prefix aug1;
+ }
+
+ import augment-topology2 {
+ prefix aug2;
+ }
+
+ import augment-topology3 {
+ prefix aug3;
+ }
+
+ import augment-topology4 {
+ prefix aug4;
+ }
+
+ import augment-topology5 {
+ prefix aug5;
+ }
+
+ import yms-network-topology {
+ prefix topo;
+ }
+
+ organization "ON-LAB";
+
+ description "This module defines for augment-topology6 classifier.";
+
+ revision "2016-05-24" {
+ description "Initial revision.";
+ }
+
+ augment "/nd:networks/nd:network/topo:link/aug2:augment2/aug3:augment3" {
+ description
+ "Add augment6 to the augment3 model.";
+ container augment6 {
+ config true;
+ leaf value6 {
+ type int8;
+ }
+ }
+ }
+
+ augment "/nd:networks/nd:network/topo:link/aug2:augment2/aug3:augment3/" +
+ "aug5:augment5" {
+ description
+ "Add leaf6 to the augment5 model.";
+ leaf leaf6 {
+ type string;
+ }
+
+ }
+
+ augment "/nd:networks/nd:network/topo:link/aug2:augment2/aug5:augment5" {
+ description
+ "Add list to the augment5 model.";
+ leaf-list augment6leafList {
+ type string;
+ }
+ }
+}
\ No newline at end of file
diff --git a/apps/yms/app/src/test/resources/ydtTestYangFiles/augmentNetwork.yang b/apps/yms/app/src/test/resources/ydtTestYangFiles/augmentNetwork.yang
new file mode 100644
index 0000000..315bc44
--- /dev/null
+++ b/apps/yms/app/src/test/resources/ydtTestYangFiles/augmentNetwork.yang
@@ -0,0 +1,33 @@
+module augmentNetwork {
+
+ yang-version 1;
+
+ namespace "ydt.augmentNetwork";
+
+ prefix "aug";
+
+ import yms-ietf-network {
+ prefix nd;
+ }
+
+
+ organization "ON-LAB";
+
+ description "This module defines for augmentNetwork classifier.";
+
+ revision "2016-05-24" {
+ description "Initial revision.";
+ }
+
+ augment "/nd:networks/nd:network" {
+ description
+ "Add container to the network model.";
+ container cont1s {
+ container cont1s {
+ leaf fine {
+ type string;
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/apps/yms/app/src/test/resources/ydtTestYangFiles/binarytest.yang b/apps/yms/app/src/test/resources/ydtTestYangFiles/binarytest.yang
new file mode 100644
index 0000000..71ada48
--- /dev/null
+++ b/apps/yms/app/src/test/resources/ydtTestYangFiles/binarytest.yang
@@ -0,0 +1,33 @@
+module binarytest {
+
+ yang-version 1;
+
+ namespace "ydt.binarytest";
+
+ prefix "binarytest";
+
+ organization "ON-LAB";
+
+ description "This module defines for binarytest classifier.";
+
+ revision "2016-05-24" {
+ description "Initial revision.";
+ }
+
+ list binaryList {
+ config false;
+ leaf binary {
+ type binary;
+ }
+ leaf binaryWithRange {
+ type binary {
+ length "2 .. 10";
+ }
+ }
+ leaf binaryWithMultiRange {
+ type binary {
+ length "min..10 | 20 | 30..max";
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/apps/yms/app/src/test/resources/ydtTestYangFiles/bit.yang b/apps/yms/app/src/test/resources/ydtTestYangFiles/bit.yang
new file mode 100644
index 0000000..6d97ccc
--- /dev/null
+++ b/apps/yms/app/src/test/resources/ydtTestYangFiles/bit.yang
@@ -0,0 +1,51 @@
+module bit {
+
+ yang-version 1;
+
+ namespace "ydt.bit";
+
+ prefix "bit";
+
+ organization "ON-LAB";
+
+ description "This module defines for bit classifier.";
+
+ revision "2016-05-24" {
+ description "Initial revision.";
+ }
+/*
+ leaf mybits {
+ type bits {
+ bit disable-nagle {
+ position 0;
+ }
+ bit auto-sense-speed {
+ position 1;
+ }
+ bit 10-Mb-only {
+ position 2;
+ }
+ }
+ default "auto-sense-speed";
+ }
+ */
+
+ list bitList {
+ config false;
+ leaf bit {
+ type bits {
+ bit disable-nagle {
+ position 0;
+ }
+ bit auto-sense-speed {
+ position 1;
+ }
+ bit ten-Mb-only {
+ position 2;
+ }
+ }
+ default "auto-sense-speed";
+
+ }
+ }
+}
\ No newline at end of file
diff --git a/apps/yms/app/src/test/resources/ydtTestYangFiles/bool.yang b/apps/yms/app/src/test/resources/ydtTestYangFiles/bool.yang
new file mode 100644
index 0000000..1bb6181
--- /dev/null
+++ b/apps/yms/app/src/test/resources/ydtTestYangFiles/bool.yang
@@ -0,0 +1,23 @@
+module bool {
+
+ yang-version 1;
+
+ namespace "ydt.boolean";
+
+ prefix "bool";
+
+ organization "ON-LAB";
+
+ description "This module defines for bool classifier.";
+
+ revision "2016-05-24" {
+ description "Initial revision.";
+ }
+
+ list booleanList {
+ key boolean;
+ leaf boolean {
+ type boolean;
+ }
+ }
+}
\ No newline at end of file
diff --git a/apps/yms/app/src/test/resources/ydtTestYangFiles/customssupervisor.yang b/apps/yms/app/src/test/resources/ydtTestYangFiles/customssupervisor.yang
new file mode 100644
index 0000000..73aa806
--- /dev/null
+++ b/apps/yms/app/src/test/resources/ydtTestYangFiles/customssupervisor.yang
@@ -0,0 +1,21 @@
+module customssupervisor {
+
+ yang-version 1;
+
+ namespace "ydt.customs-supervisor";
+
+ prefix "customs";
+
+ organization "ON-LAB";
+
+ description "This module defines for customs-supervisor.";
+
+ revision "2016-05-24" {
+ description "Initial revision.";
+ }
+
+ leaf supervisor {
+ type string;
+ description "name of the customs-supervisor.";
+ }
+}
\ No newline at end of file
diff --git a/apps/yms/app/src/test/resources/ydtTestYangFiles/decimal64.yang b/apps/yms/app/src/test/resources/ydtTestYangFiles/decimal64.yang
new file mode 100644
index 0000000..6470e8a
--- /dev/null
+++ b/apps/yms/app/src/test/resources/ydtTestYangFiles/decimal64.yang
@@ -0,0 +1,90 @@
+module decimal64 {
+
+ yang-version 1;
+
+ namespace "ydt.decimal64";
+
+ prefix "decimal64";
+
+ organization "ON-LAB";
+
+ description "This module defines for decimal64 classifier.";
+
+ revision "2016-05-24" {
+ description "Initial revision.";
+ }
+ leaf negInt {
+ type decimal64 {
+ fraction-digits 2;
+ }
+ }
+
+ leaf negIntWithMaxFraction {
+ type decimal64 {
+ fraction-digits 18;
+ }
+ }
+
+ leaf negIntWithMinFraction {
+ type decimal64 {
+ fraction-digits 1;
+ }
+ }
+
+ leaf posInt {
+ type decimal64 {
+ fraction-digits 2;
+ }
+ }
+
+ leaf posIntWithMaxFraction {
+ type decimal64 {
+ fraction-digits 18;
+ }
+
+ }
+
+ leaf posIntWithMinFraction {
+ type decimal64 {
+ fraction-digits 1;
+ }
+
+ }
+
+ leaf minIntWithRange {
+ type decimal64 {
+ fraction-digits 2;
+ range "10 .. 100";
+ }
+ }
+
+ leaf midIntWithRange {
+ type decimal64 {
+ fraction-digits 2;
+ range "10 .. 100";
+ }
+ }
+
+ leaf maxIntWithRange {
+ type decimal64 {
+ fraction-digits 2;
+ range "10 .. 100";
+ }
+ }
+
+ list multiRangeValidation {
+ config false;
+ leaf decimal {
+ type decimal64 {
+ fraction-digits 2;
+ range "10..40 | 50..100";
+ }
+ }
+ leaf revDecimal {
+ type decimal64 {
+ fraction-digits 2;
+ range "min .. 3.14 | 10 | 20..max";
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/apps/yms/app/src/test/resources/ydtTestYangFiles/employeeid.yang b/apps/yms/app/src/test/resources/ydtTestYangFiles/employeeid.yang
new file mode 100644
index 0000000..be27c70
--- /dev/null
+++ b/apps/yms/app/src/test/resources/ydtTestYangFiles/employeeid.yang
@@ -0,0 +1,21 @@
+module employeeid {
+
+ yang-version 1;
+
+ namespace "ydt.employee-id";
+
+ prefix "id";
+
+ organization "ON-LAB";
+
+ description "This module defines for employee-id.";
+
+ revision "2016-05-24" {
+ description "Initial revision.";
+ }
+
+ leaf-list employeeid {
+ type string;
+ description "list of the employee id";
+ }
+}
\ No newline at end of file
diff --git a/apps/yms/app/src/test/resources/ydtTestYangFiles/emptydata.yang b/apps/yms/app/src/test/resources/ydtTestYangFiles/emptydata.yang
new file mode 100644
index 0000000..33f58b3
--- /dev/null
+++ b/apps/yms/app/src/test/resources/ydtTestYangFiles/emptydata.yang
@@ -0,0 +1,23 @@
+module emptydata {
+
+ yang-version 1;
+
+ namespace "ydt.emptydata";
+
+ prefix "emptydata";
+
+ organization "ON-LAB";
+
+ description "This module defines for emptydata classifier.";
+
+ revision "2016-05-24" {
+ description "Initial revision.";
+ }
+
+ list emptyList {
+ config false;
+ leaf empty {
+ type empty;
+ }
+ }
+}
\ No newline at end of file
diff --git a/apps/yms/app/src/test/resources/ydtTestYangFiles/enumtest.yang b/apps/yms/app/src/test/resources/ydtTestYangFiles/enumtest.yang
new file mode 100644
index 0000000..a9255c5
--- /dev/null
+++ b/apps/yms/app/src/test/resources/ydtTestYangFiles/enumtest.yang
@@ -0,0 +1,27 @@
+module enumtest {
+
+ yang-version 1;
+
+ namespace "ydt.enumtest";
+
+ prefix "enumtest";
+
+ organization "ON-LAB";
+
+ description "This module defines for enumtest classifier.";
+
+ revision "2016-05-24" {
+ description "Initial revision.";
+ }
+
+ list enumList {
+ key enumleaf;
+ leaf enumleaf {
+ type enumeration {
+ enum ten { value "10";}
+ enum hundred { value "100";}
+ enum thousand { value "1000"; }
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/apps/yms/app/src/test/resources/ydtTestYangFiles/food.yang b/apps/yms/app/src/test/resources/ydtTestYangFiles/food.yang
new file mode 100644
index 0000000..202d11f
--- /dev/null
+++ b/apps/yms/app/src/test/resources/ydtTestYangFiles/food.yang
@@ -0,0 +1,39 @@
+module food {
+
+ yang-version 1;
+
+ namespace "ydt.food";
+
+ prefix "foodType";
+
+ organization "ON-LAB";
+
+ description "This module defines for food.";
+
+ revision "2016-06-24" {
+ description "Initial revision.";
+ }
+
+ container food {
+ choice snack {
+ case sportsarena {
+
+ leaf pretzel {
+ type empty;
+ }
+ leaf beer {
+ type empty;
+ }
+ }
+ case latenight {
+ leaf chocolate {
+ type enumeration {
+ enum dark;
+ enum milk;
+ enum first-available;
+ }
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/apps/yms/app/src/test/resources/ydtTestYangFiles/ietf-inet-types.yang b/apps/yms/app/src/test/resources/ydtTestYangFiles/ietf-inet-types.yang
new file mode 100644
index 0000000..6b994bb
--- /dev/null
+++ b/apps/yms/app/src/test/resources/ydtTestYangFiles/ietf-inet-types.yang
@@ -0,0 +1,454 @@
+ module yms-ietf-inet-types {
+
+ yang-version 1;
+
+ namespace
+ "urn:ietf:params:xml:ns:yang:ietf-inet-types";
+
+ prefix inet;
+
+ organization
+ "IETF NETMOD (NETCONF Data Modeling Language) Working Group";
+
+ contact
+ "WG Web: <http://tools.ietf.org/wg/netmod/>
+ WG List: <mailto:netmod@ietf.org>
+
+ WG Chair: David Kessens
+ <mailto:david.kessens@nsn.com>
+
+ WG Chair: Juergen Schoenwaelder
+ <mailto:j.schoenwaelder@jacobs-university.de>
+
+ Editor: Juergen Schoenwaelder
+ <mailto:j.schoenwaelder@jacobs-university.de>";
+
+ description
+ "This module contains a collection of generally useful derived
+ YANG data types for Internet addresses and related things.
+
+ Copyright (c) 2013 IETF Trust and the persons identified as
+ authors of the code. All rights reserved.
+
+ Redistribution and use in source and binary forms, with or
+ without modification, is permitted pursuant to, and subject
+ to the license terms contained in, the Simplified BSD License
+ set forth in Section 4.c of the IETF Trust's Legal Provisions
+ Relating to IETF Documents
+ (http://trustee.ietf.org/license-info).
+
+ This version of this YANG module is part of RFC 6991; see
+ the RFC itself for full legal notices.";
+
+ revision "2013-07-15" {
+ description
+ "This revision adds the following new data types:
+ - ip-address-no-zone
+ - ipv4-address-no-zone
+ - ipv6-address-no-zone";
+ reference
+ "RFC 6991: Common YANG Data Types";
+
+ }
+
+ revision "2010-09-24" {
+ description "Initial revision.";
+ reference
+ "RFC 6021: Common YANG Data Types";
+
+ }
+
+
+ typedef ip-version {
+ type enumeration {
+ enum "unknown" {
+ value 0;
+ description
+ "An unknown or unspecified version of the Internet
+ protocol.";
+ }
+ enum "ipv4" {
+ value 1;
+ description
+ "The IPv4 protocol as defined in RFC 791.";
+ }
+ enum "ipv6" {
+ value 2;
+ description
+ "The IPv6 protocol as defined in RFC 2460.";
+ }
+ }
+ description
+ "This value represents the version of the IP protocol.
+
+ In the value set and its semantics, this type is equivalent
+ to the InetVersion textual convention of the SMIv2.";
+ reference
+ "RFC 791: Internet Protocol
+ RFC 2460: Internet Protocol, Version 6 (IPv6) Specification
+ RFC 4001: Textual Conventions for Internet Network Addresses";
+
+ }
+
+ typedef dscp {
+ type uint8 {
+ range "0..63";
+ }
+ description
+ "The dscp type represents a Differentiated Services Code Point
+ that may be used for marking packets in a traffic stream.
+ In the value set and its semantics, this type is equivalent
+ to the Dscp textual convention of the SMIv2.";
+ reference
+ "RFC 3289: Management Information Base for the Differentiated
+ Services Architecture
+ RFC 2474: Definition of the Differentiated Services Field
+ (DS Field) in the IPv4 and IPv6 Headers
+ RFC 2780: IANA Allocation Guidelines For Values In
+ the Internet Protocol and Related Headers";
+
+ }
+
+ typedef ipv6-flow-label {
+ type uint32 {
+ range "0..1048575";
+ }
+ description
+ "The ipv6-flow-label type represents the flow identifier or Flow
+ Label in an IPv6 packet header that may be used to
+ discriminate traffic flows.
+
+ In the value set and its semantics, this type is equivalent
+ to the IPv6FlowLabel textual convention of the SMIv2.";
+ reference
+ "RFC 3595: Textual Conventions for IPv6 Flow Label
+ RFC 2460: Internet Protocol, Version 6 (IPv6) Specification";
+
+ }
+
+ typedef port-number {
+ type uint16 {
+ range "0..65535";
+ }
+ description
+ "The port-number type represents a 16-bit port number of an
+ Internet transport-layer protocol such as UDP, TCP, DCCP, or
+ SCTP. Port numbers are assigned by IANA. A current list of
+ all assignments is available from <http://www.iana.org/>.
+
+ Note that the port number value zero is reserved by IANA. In
+ situations where the value zero does not make sense, it can
+ be excluded by subtyping the port-number type.
+ In the value set and its semantics, this type is equivalent
+ to the InetPortNumber textual convention of the SMIv2.";
+ reference
+ "RFC 768: User Datagram Protocol
+ RFC 793: Transmission Control Protocol
+ RFC 4960: Stream Control Transmission Protocol
+ RFC 4340: Datagram Congestion Control Protocol (DCCP)
+ RFC 4001: Textual Conventions for Internet Network Addresses";
+
+ }
+
+ typedef as-number {
+ type uint32;
+ description
+ "The as-number type represents autonomous system numbers
+ which identify an Autonomous System (AS). An AS is a set
+ of routers under a single technical administration, using
+ an interior gateway protocol and common metrics to route
+ packets within the AS, and using an exterior gateway
+ protocol to route packets to other ASes. IANA maintains
+ the AS number space and has delegated large parts to the
+ regional registries.
+
+ Autonomous system numbers were originally limited to 16
+ bits. BGP extensions have enlarged the autonomous system
+ number space to 32 bits. This type therefore uses an uint32
+ base type without a range restriction in order to support
+ a larger autonomous system number space.
+
+ In the value set and its semantics, this type is equivalent
+ to the InetAutonomousSystemNumber textual convention of
+ the SMIv2.";
+ reference
+ "RFC 1930: Guidelines for creation, selection, and registration
+ of an Autonomous System (AS)
+ RFC 4271: A Border Gateway Protocol 4 (BGP-4)
+ RFC 4001: Textual Conventions for Internet Network Addresses
+ RFC 6793: BGP Support for Four-Octet Autonomous System (AS)
+ Number Space";
+
+ }
+
+ typedef ip-address {
+ type union {
+ type ipv4-address;
+ type ipv6-address;
+ }
+ description
+ "The ip-address type represents an IP address and is IP
+ version neutral. The format of the textual representation
+ implies the IP version. This type supports scoped addresses
+ by allowing zone identifiers in the address format.";
+ reference
+ "RFC 4007: IPv6 Scoped Address Architecture";
+
+ }
+
+ typedef ipv4-address {
+ type string {
+ pattern
+ '(([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])(%[\p{N}\p{L}]+)?';
+ }
+ description
+ "The ipv4-address type represents an IPv4 address in
+ dotted-quad notation. The IPv4 address may include a zone
+ index, separated by a % sign.
+
+ The zone index is used to disambiguate identical address
+ values. For link-local addresses, the zone index will
+ typically be the interface index number or the name of an
+ interface. If the zone index is not present, the default
+ zone of the device will be used.
+
+ The canonical format for the zone index is the numerical
+ format";
+ }
+
+ typedef ipv6-address {
+ type string {
+ pattern
+ '((:|[0-9a-fA-F]{0,4}):)([0-9a-fA-F]{0,4}:){0,5}((([0-9a-fA-F]{0,4}:)?(:|[0-9a-fA-F]{0,4}))|(((25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])))(%[\p{N}\p{L}]+)?';
+ pattern
+ '(([^:]+:){6}(([^:]+:[^:]+)|(.*\..*)))|((([^:]+:)*[^:]+)?::(([^:]+:)*[^:]+)?)(%.+)?';
+ }
+ description
+ "The ipv6-address type represents an IPv6 address in full,
+ mixed, shortened, and shortened-mixed notation. The IPv6
+ address may include a zone index, separated by a % sign.
+
+ The zone index is used to disambiguate identical address
+ values. For link-local addresses, the zone index will
+ typically be the interface index number or the name of an
+ interface. If the zone index is not present, the default
+ zone of the device will be used.
+
+
+
+ The canonical format of IPv6 addresses uses the textual
+ representation defined in Section 4 of RFC 5952. The
+ canonical format for the zone index is the numerical
+ format as described in Section 11.2 of RFC 4007.";
+ reference
+ "RFC 4291: IP Version 6 Addressing Architecture
+ RFC 4007: IPv6 Scoped Address Architecture
+ RFC 5952: A Recommendation for IPv6 Address Text
+ Representation";
+
+ }
+
+ typedef ip-address-no-zone {
+ type union {
+ type ipv4-address-no-zone;
+ type ipv6-address-no-zone;
+ }
+ description
+ "The ip-address-no-zone type represents an IP address and is
+ IP version neutral. The format of the textual representation
+ implies the IP version. This type does not support scoped
+ addresses since it does not allow zone identifiers in the
+ address format.";
+ reference
+ "RFC 4007: IPv6 Scoped Address Architecture";
+
+ }
+
+ typedef ipv4-address-no-zone {
+ type ipv4-address {
+ pattern '[0-9\.]*';
+ }
+ description
+ "An IPv4 address without a zone index. This type, derived from
+ ipv4-address, may be used in situations where the zone is
+ known from the context and hence no zone index is needed.";
+ }
+
+ typedef ipv6-address-no-zone {
+ type ipv6-address {
+ pattern '[0-9a-fA-F:\.]*';
+ }
+ description
+ "An IPv6 address without a zone index. This type, derived from
+ ipv6-address, may be used in situations where the zone is
+ known from the context and hence no zone index is needed.";
+ reference
+ "RFC 4291: IP Version 6 Addressing Architecture
+ RFC 4007: IPv6 Scoped Address Architecture
+ RFC 5952: A Recommendation for IPv6 Address Text
+ Representation";
+
+ }
+
+ typedef ip-prefix {
+ type union {
+ type ipv4-prefix;
+ type ipv6-prefix;
+ }
+ description
+ "The ip-prefix type represents an IP prefix and is IP
+ version neutral. The format of the textual representations
+ implies the IP version.";
+ }
+
+ typedef ipv4-prefix {
+ type string {
+ pattern
+ '(([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])/(([0-9])|([1-2][0-9])|(3[0-2]))';
+ }
+ description
+ "The ipv4-prefix type represents an IPv4 address prefix.
+ The prefix length is given by the number following the
+ slash character and must be less than or equal to 32.
+
+ A prefix length value of n corresponds to an IP address
+ mask that has n contiguous 1-bits from the most
+ significant bit (MSB) and all other bits set to 0.
+
+ The canonical format of an IPv4 prefix has all bits of
+ the IPv4 address set to zero that are not part of the
+ IPv4 prefix.";
+ }
+
+ typedef ipv6-prefix {
+ type string {
+ pattern
+ '((:|[0-9a-fA-F]{0,4}):)([0-9a-fA-F]{0,4}:){0,5}((([0-9a-fA-F]{0,4}:)?(:|[0-9a-fA-F]{0,4}))|(((25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])))(/(([0-9])|([0-9]{2})|(1[0-1][0-9])|(12[0-8])))';
+ pattern
+ '(([^:]+:){6}(([^:]+:[^:]+)|(.*\..*)))|((([^:]+:)*[^:]+)?::(([^:]+:)*[^:]+)?)(/.+)';
+ }
+ description
+ "The ipv6-prefix type represents an IPv6 address prefix.
+ The prefix length is given by the number following the
+ slash character and must be less than or equal to 128.
+
+ A prefix length value of n corresponds to an IP address
+ mask that has n contiguous 1-bits from the most
+ significant bit (MSB) and all other bits set to 0.
+
+ The IPv6 address should have all bits that do not belong
+ to the prefix set to zero.
+
+ The canonical format of an IPv6 prefix has all bits of
+ the IPv6 address set to zero that are not part of the
+ IPv6 prefix. Furthermore, the IPv6 address is represented
+ as defined in Section 4 of RFC 5952.";
+ reference
+ "RFC 5952: A Recommendation for IPv6 Address Text
+ Representation";
+
+ }
+
+ typedef domain-name {
+ type string {
+ length "1..253";
+ pattern
+ '((([a-zA-Z0-9_]([a-zA-Z0-9\-_]){0,61})?[a-zA-Z0-9]\.)*([a-zA-Z0-9_]([a-zA-Z0-9\-_]){0,61})?[a-zA-Z0-9]\.?)|\.';
+ }
+ description
+ "The domain-name type represents a DNS domain name. The
+ name SHOULD be fully qualified whenever possible.
+
+ Internet domain names are only loosely specified. Section
+ 3.5 of RFC 1034 recommends a syntax (modified in Section
+ 2.1 of RFC 1123). The pattern above is intended to allow
+ for current practice in domain name use, and some possible
+ future expansion. It is designed to hold various types of
+ domain names, including names used for A or AAAA records
+ (host names) and other records, such as SRV records. Note
+ that Internet host names have a stricter syntax (described
+ in RFC 952) than the DNS recommendations in RFCs 1034 and
+ 1123, and that systems that want to store host names in
+ schema nodes using the domain-name type are recommended to
+ adhere to this stricter standard to ensure interoperability.
+
+ The encoding of DNS names in the DNS protocol is limited
+ to 255 characters. Since the encoding consists of labels
+ prefixed by a length bytes and there is a trailing NULL
+ byte, only 253 characters can appear in the textual dotted
+ notation.
+
+ The description clause of schema nodes using the domain-name
+ type MUST describe when and how these names are resolved to
+ IP addresses. Note that the resolution of a domain-name value
+ may require to query multiple DNS records (e.g., A for IPv4
+ and AAAA for IPv6). The order of the resolution process and
+ which DNS record takes precedence can either be defined
+ explicitly or may depend on the configuration of the
+ resolver.
+
+ Domain-name values use the US-ASCII encoding. Their canonical
+ format uses lowercase US-ASCII characters. Internationalized
+ domain names MUST be A-labels as per RFC 5890.";
+ reference
+ "RFC 952: DoD Internet Host Table Specification
+ RFC 1034: Domain Names - Concepts and Facilities
+ RFC 1123: Requirements for Internet Hosts -- Application
+ and Support
+ RFC 2782: A DNS RR for specifying the location of services
+ (DNS SRV)
+ RFC 5890: Internationalized Domain Names in Applications
+ (IDNA): Definitions and Document Framework";
+
+ }
+
+ typedef host {
+ type union {
+ type ip-address;
+ type domain-name;
+ }
+ description
+ "The host type represents either an IP address or a DNS
+ domain name.";
+ }
+
+ typedef uri {
+ type string;
+ description
+ "The uri type represents a Uniform Resource Identifier
+ (URI) as defined by STD 66.
+
+ Objects using the uri type MUST be in US-ASCII encoding,
+ and MUST be normalized as described by RFC 3986 Sections
+ 6.2.1, 6.2.2.1, and 6.2.2.2. All unnecessary
+ percent-encoding is removed, and all case-insensitive
+ characters are set to lowercase except for hexadecimal
+ digits, which are normalized to uppercase as described in
+ Section 6.2.2.1.
+
+ The purpose of this normalization is to help provide
+ unique URIs. Note that this normalization is not
+ sufficient to provide uniqueness. Two URIs that are
+ textually distinct after this normalization may still be
+ equivalent.
+
+ Objects using the uri type may restrict the schemes that
+ they permit. For example, 'data:' and 'urn:' schemes
+ might not be appropriate.
+
+ A zero-length URI is not a valid URI. This can be used to
+ express 'URI absent' where required.
+
+ In the value set and its semantics, this type is equivalent
+ to the Uri SMIv2 textual convention defined in RFC 5017.";
+ reference
+ "RFC 3986: Uniform Resource Identifier (URI): Generic Syntax
+ RFC 3305: Report from the Joint W3C/IETF URI Planning Interest
+ Group: Uniform Resource Identifiers (URIs), URLs,
+ and Uniform Resource Names (URNs): Clarifications
+ and Recommendations
+ RFC 5017: MIB Textual Conventions for Uniform Resource
+ Identifiers (URIs)";
+
+ }
+ } // module ietf-inet-types
diff --git a/apps/yms/app/src/test/resources/ydtTestYangFiles/ietf-network.yang b/apps/yms/app/src/test/resources/ydtTestYangFiles/ietf-network.yang
new file mode 100644
index 0000000..b56f6cf
--- /dev/null
+++ b/apps/yms/app/src/test/resources/ydtTestYangFiles/ietf-network.yang
@@ -0,0 +1,216 @@
+ module yms-ietf-network {
+ yang-version 1;
+ namespace "urn:ietf:params:xml:ns:yang:ietf-network";
+ prefix nd;
+
+ import yms-ietf-inet-types {
+ prefix inet;
+ }
+
+ organization
+ "IETF I2RS (Interface to the Routing System) Working Group";
+
+ contact
+ "WG Web: <http://tools.ietf.org/wg/i2rs/>
+ WG List: <mailto:i2rs@ietf.org>
+
+ WG Chair: Susan Hares
+ <mailto:shares@ndzh.com>
+
+ WG Chair: Jeffrey Haas
+ <mailto:jhaas@pfrc.org>
+
+ Editor: Alexander Clemm
+ <mailto:alex@cisco.com>
+
+ Editor: Jan Medved
+ <mailto:jmedved@cisco.com>
+
+ Editor: Robert Varga
+ <mailto:rovarga@cisco.com>
+
+ Editor: Tony Tkacik
+ <mailto:ttkacik@cisco.com>
+
+ Editor: Nitin Bahadur
+ <mailto:nitin_bahadur@yahoo.com>
+
+ Editor: Hariharan Ananthakrishnan
+ <mailto:hari@packetdesign.com>";
+
+ description
+ "This module defines a common base model for a collection
+ of nodes in a network. Node definitions are further used
+ in network topologies and inventories.
+
+ Copyright (c) 2015 IETF Trust and the persons identified as
+ authors of the code. All rights reserved.
+
+ Redistribution and use in source and binary forms, with or
+ without modification, is permitted pursuant to, and subject
+ to the license terms contained in, the Simplified BSD License
+ set forth in Section 4.c of the IETF Trust's Legal Provisions
+ Relating to IETF Documents
+ (http://trustee.ietf.org/license-info).
+
+ This version of this YANG module is part of
+ draft-ietf-i2rs-yang-network-topo-02;
+ see the RFC itself for full legal notices.
+
+ NOTE TO RFC EDITOR: Please replace above reference to
+ draft-ietf-i2rs-yang-network-topo-02 with RFC
+ number when published (i.e. RFC xxxx).";
+
+ revision 2015-12-08 {
+ description
+ "Initial revision.
+ NOTE TO RFC EDITOR: Please replace the following reference
+ to draft-ietf-i2rs-yang-network-topo-02 with
+ RFC number when published (i.e. RFC xxxx).";
+ reference
+ "draft-ietf-i2rs-yang-network-topo-02";
+ }
+
+ typedef node-id {
+ type inet:uri;
+ description
+ "Identifier for a node.";
+ }
+
+ typedef network-id {
+ type inet:uri;
+ description
+ "Identifier for a network.";
+ }
+ grouping network-ref {
+ description
+ "Contains the information necessary to reference a network,
+ for example an underlay network.";
+ leaf network-ref {
+ type leafref {
+ path "/nd:networks/nd:network/nd:network-id";
+ require-instance false;
+ }
+ description
+ "Used to reference a network, for example an underlay
+ network.";
+ }
+ }
+
+ grouping node-ref {
+ description
+ "Contains the information necessary to reference a node.";
+ leaf node-ref {
+ type leafref {
+ path "/nd:networks/nd:network[nd:network-id=current()/../"+
+ "network-ref]/nd:node/nd:node-id";
+ require-instance false;
+ }
+ description
+ "Used to reference a node.
+ Nodes are identified relative to the network they are
+ contained in.";
+ }
+ uses network-ref;
+ }
+
+ container networks {
+ description
+ "Serves as top-level container for a list of networks.";
+ list network {
+ key "network-id";
+ description
+ "Describes a network.
+ A network typically contains an inventory of nodes,
+ topological information (augmented through
+ network-topology model), as well as layering
+ information.";
+ container network-types {
+ description
+ "Serves as an augmentation target.
+ The network type is indicated through corresponding
+ presence containers augmented into this container.";
+ }
+ leaf network-id {
+ type inet:uri;
+ description
+ "Identifies a network.";
+ }
+ list supporting-network {
+ key "network-ref";
+ description
+ "An underlay network, used to represent layered network
+ topologies.";
+ leaf network-ref {
+ type leafref {
+ path "/networks/network/network-id";
+ require-instance false;
+ }
+ description
+ "References the underlay network.";
+ }
+ }
+ list node {
+ key "node-id";
+ description
+ "The inventory of nodes of this network.";
+ leaf node-id {
+ type node-id;
+ description
+ "Identifies a node uniquely within the containing
+ network.";
+ }
+ list supporting-node {
+ key "network-ref node-ref";
+ description
+ "Represents another node, in an underlay network, that
+ this node is supported by. Used to represent layering
+ structure.";
+ leaf network-ref {
+ type leafref {
+ path "../../../supporting-network/network-ref";
+ require-instance false;
+ }
+ description
+ "References the underlay network that the
+ underlay node is part of.";
+ }
+ leaf node-ref {
+ type leafref {
+ path "/networks/network/node/node-id";
+ require-instance false;
+ }
+ description
+ "References the underlay node itself.";
+ }
+ }
+ }
+ }
+ }
+ container networks-state {
+ config false;
+ description
+ "Serves as top-level container for a list of state information
+ for networks";
+ list network {
+ key "network-ref";
+ description
+ "Data nodes representing operational data and state of
+ networks.
+ An instance is automatically created for every network
+ in the corresponding list under the networks container.";
+ uses network-ref;
+ leaf server-provided {
+ type boolean;
+ description
+ "Indicates whether the information concerning this
+ particular network is populated by the server
+ (server-provided true, the general case for network
+ information discovered from the server),
+ or whether it is configured by a client
+ (server-provided true, possible e.g. for
+ service overlays managed through a controller).";
+ }
+ }
+ }
+ }
diff --git a/apps/yms/app/src/test/resources/ydtTestYangFiles/integer16.yang b/apps/yms/app/src/test/resources/ydtTestYangFiles/integer16.yang
new file mode 100644
index 0000000..8db77be
--- /dev/null
+++ b/apps/yms/app/src/test/resources/ydtTestYangFiles/integer16.yang
@@ -0,0 +1,98 @@
+module integer16 {
+
+ yang-version 1;
+
+ namespace "ydt.integer16";
+
+ prefix "integer16";
+
+ organization "ON-LAB";
+
+ description "This module defines for integer16 classifier.";
+
+ revision "2016-05-24" {
+ description "Initial revision.";
+ }
+
+ list multiRangeValidation {
+ config false;
+ leaf integer {
+ type int16 {
+ range "10..40 | 50..100";
+ }
+ }
+ leaf UnInteger {
+ type uint16 {
+ range "10..40 | 50..100";
+ }
+ }
+
+ leaf revInteger {
+ type int16 {
+ range "min .. 2 | 10 | 20..max";
+ }
+ }
+
+ leaf revUnInteger {
+ type uint16 {
+ range "min .. 2 | 10 | 20..max";
+ }
+ }
+ }
+
+ leaf negInt {
+ type int16 {
+ }
+ }
+
+ leaf posInt {
+ type int16 {
+ }
+ }
+
+ leaf minIntWithRange {
+ type int16 {
+ range "10 .. 100";
+ }
+ }
+
+ leaf midIntWithRange {
+ type int16 {
+ range "10 .. 100";
+ }
+ }
+
+ leaf maxIntWithRange {
+ type int16 {
+ range "10 .. 100";
+ }
+ }
+
+ leaf minUInt {
+ type uint16 {
+ }
+ }
+
+ leaf maxUInt {
+ type uint16 {
+ }
+ }
+
+ leaf minUIntWithRange {
+ type uint16 {
+ range "10 .. 100";
+ }
+ }
+
+ leaf midUIntWithRange {
+ type uint16 {
+ range "10 .. 100";
+ }
+ }
+
+ leaf maxUIntWithRange {
+ type uint16 {
+ range "10 .. 100";
+ }
+ }
+}
diff --git a/apps/yms/app/src/test/resources/ydtTestYangFiles/integer32.yang b/apps/yms/app/src/test/resources/ydtTestYangFiles/integer32.yang
new file mode 100644
index 0000000..fb596cf
--- /dev/null
+++ b/apps/yms/app/src/test/resources/ydtTestYangFiles/integer32.yang
@@ -0,0 +1,98 @@
+module integer32 {
+
+ yang-version 1;
+
+ namespace "ydt.integer32";
+
+ prefix "integer32";
+
+ organization "ON-LAB";
+
+ description "This module defines for integer32 classifier.";
+
+ revision "2016-05-24" {
+ description "Initial revision.";
+ }
+
+ list multiRangeValidation {
+ config false;
+ leaf integer {
+ type int32 {
+ range "10..40 | 50..100";
+ }
+ }
+ leaf UnInteger {
+ type uint32 {
+ range "10..40 | 50..100";
+ }
+ }
+
+ leaf revInteger {
+ type int32 {
+ range "min .. 2 | 10 | 20..max";
+ }
+ }
+
+ leaf revUnInteger {
+ type uint32 {
+ range "min .. 2 | 10 | 20..max";
+ }
+ }
+ }
+
+ leaf negInt {
+ type int32 {
+ }
+ }
+
+ leaf posInt {
+ type int32 {
+ }
+ }
+
+ leaf minIntWithRange {
+ type int32 {
+ range "10 .. 100";
+ }
+ }
+
+ leaf midIntWithRange {
+ type int32 {
+ range "10 .. 100";
+ }
+ }
+
+ leaf maxIntWithRange {
+ type int32 {
+ range "10 .. 100";
+ }
+ }
+
+ leaf minUInt {
+ type uint32 {
+ }
+ }
+
+ leaf maxUInt {
+ type uint32 {
+ }
+ }
+
+ leaf minUIntWithRange {
+ type uint32 {
+ range "10 .. 100";
+ }
+ }
+
+ leaf midUIntWithRange {
+ type uint32 {
+ range "10 .. 100";
+ }
+ }
+
+ leaf maxUIntWithRange {
+ type uint32 {
+ range "10 .. 100";
+ }
+ }
+}
diff --git a/apps/yms/app/src/test/resources/ydtTestYangFiles/integer64.yang b/apps/yms/app/src/test/resources/ydtTestYangFiles/integer64.yang
new file mode 100644
index 0000000..39479c6
--- /dev/null
+++ b/apps/yms/app/src/test/resources/ydtTestYangFiles/integer64.yang
@@ -0,0 +1,98 @@
+module integer64 {
+
+ yang-version 1;
+
+ namespace "ydt.integer64";
+
+ prefix "integer64";
+
+ organization "ON-LAB";
+
+ description "This module defines for integer64 classifier.";
+
+ revision "2016-05-24" {
+ description "Initial revision.";
+ }
+
+ list multiRangeValidation {
+ config false;
+ leaf integer {
+ type int64 {
+ range "10..40 | 50..100";
+ }
+ }
+ leaf UnInteger {
+ type uint64 {
+ range "10..40 | 50..100";
+ }
+ }
+
+ leaf revInteger {
+ type int64 {
+ range "min .. 2 | 10 | 20..max";
+ }
+ }
+
+ leaf revUnInteger {
+ type uint64 {
+ range "min .. 2 | 10 | 20..max";
+ }
+ }
+ }
+
+ leaf negInt {
+ type int64 {
+ }
+ }
+
+ leaf posInt {
+ type int64 {
+ }
+ }
+
+ leaf minIntWithRange {
+ type int64 {
+ range "10 .. 100";
+ }
+ }
+
+ leaf midIntWithRange {
+ type int64 {
+ range "10 .. 100";
+ }
+ }
+
+ leaf maxIntWithRange {
+ type int64 {
+ range "10 .. 100";
+ }
+ }
+
+ leaf minUInt {
+ type uint64 {
+ }
+ }
+
+ leaf maxUInt {
+ type uint64 {
+ }
+ }
+
+ leaf minUIntWithRange {
+ type uint64 {
+ range "10 .. 100";
+ }
+ }
+
+ leaf midUIntWithRange {
+ type uint64 {
+ range "10 .. 100";
+ }
+ }
+
+ leaf maxUIntWithRange {
+ type uint64 {
+ range "10 .. 100";
+ }
+ }
+}
diff --git a/apps/yms/app/src/test/resources/ydtTestYangFiles/integer8.yang b/apps/yms/app/src/test/resources/ydtTestYangFiles/integer8.yang
new file mode 100644
index 0000000..e05c235
--- /dev/null
+++ b/apps/yms/app/src/test/resources/ydtTestYangFiles/integer8.yang
@@ -0,0 +1,99 @@
+module integer8 {
+
+ yang-version 1;
+
+ namespace "ydt.integer8";
+
+ prefix "integer8";
+
+ organization "ON-LAB";
+
+ description "This module defines for integer8 classifier.";
+
+ revision "2016-05-24" {
+ description "Initial revision.";
+ }
+
+ list multiRangeValidation {
+ config false;
+ leaf integer {
+ type int8 {
+ range "10..40 | 50..100";
+ }
+ }
+ leaf UnInteger {
+ type uint8 {
+ range "10..40 | 50..100";
+ }
+ }
+
+ leaf revInteger {
+ type int8 {
+ range "min .. 2 | 10 | 20..max";
+ }
+ }
+
+ leaf revUnInteger {
+ type uint8 {
+ range "min .. 2 | 10 | 20..max";
+ }
+ }
+ }
+
+
+ leaf negInt {
+ type int8 {
+ }
+ }
+
+ leaf posInt {
+ type int8 {
+ }
+ }
+
+ leaf minIntWithRange {
+ type int8 {
+ range "10 .. 100";
+ }
+ }
+
+ leaf midIntWithRange {
+ type int8 {
+ range "10 .. 100";
+ }
+ }
+
+ leaf maxIntWithRange {
+ type int8 {
+ range "10 .. 100";
+ }
+ }
+
+ leaf minUInt {
+ type uint8 {
+ }
+ }
+
+ leaf maxUInt {
+ type uint8 {
+ }
+ }
+
+ leaf minUIntWithRange {
+ type uint8 {
+ range "10 .. 100";
+ }
+ }
+
+ leaf midUIntWithRange {
+ type uint8 {
+ range "10 .. 100";
+ }
+ }
+
+ leaf maxUIntWithRange {
+ type uint8 {
+ range "10 .. 100";
+ }
+ }
+}
\ No newline at end of file
diff --git a/apps/yms/app/src/test/resources/ydtTestYangFiles/logisticsmanager.yang b/apps/yms/app/src/test/resources/ydtTestYangFiles/logisticsmanager.yang
new file mode 100644
index 0000000..7198611
--- /dev/null
+++ b/apps/yms/app/src/test/resources/ydtTestYangFiles/logisticsmanager.yang
@@ -0,0 +1,16 @@
+module logisticsmanager {
+
+ yang-version 1;
+
+ namespace "ydt.logistics-manager";
+
+ prefix "root";
+
+ organization "ON-LAB";
+
+ description "This module defines for logistics-manager.";
+
+ revision "2016-05-24" {
+ description "Initial revision.";
+ }
+}
\ No newline at end of file
diff --git a/apps/yms/app/src/test/resources/ydtTestYangFiles/materialsupervisor.yang b/apps/yms/app/src/test/resources/ydtTestYangFiles/materialsupervisor.yang
new file mode 100644
index 0000000..6ab16ea
--- /dev/null
+++ b/apps/yms/app/src/test/resources/ydtTestYangFiles/materialsupervisor.yang
@@ -0,0 +1,29 @@
+module materialsupervisor {
+
+ yang-version 1;
+
+ namespace "ydt.material-supervisor";
+
+ prefix "material";
+
+ organization "ON-LAB";
+
+ description "This module defines for material-supervisor.";
+
+ revision "2016-05-24" {
+ description "Initial revision.";
+ }
+
+ list supervisor {
+ key "name";
+ leaf name {
+ type string;
+ description "name of material-supervisor";
+ }
+
+ leaf departmentId {
+ type string;
+ description "name of department";
+ }
+ }
+}
\ No newline at end of file
diff --git a/apps/yms/app/src/test/resources/ydtTestYangFiles/merchandisersupervisor.yang b/apps/yms/app/src/test/resources/ydtTestYangFiles/merchandisersupervisor.yang
new file mode 100644
index 0000000..db40c7e
--- /dev/null
+++ b/apps/yms/app/src/test/resources/ydtTestYangFiles/merchandisersupervisor.yang
@@ -0,0 +1,21 @@
+module merchandisersupervisor {
+
+ yang-version 1;
+
+ namespace "ydt.Merchandiser-supervisor";
+
+ prefix "merchandiser";
+
+ organization "ON-LAB";
+
+ description "This module defines for Merchandiser-supervisor.";
+
+ revision "2016-05-24" {
+ description "Initial revision.";
+ }
+
+ leaf supervisor {
+ type string;
+ description "name of the Merchandiser-supervisor.";
+ }
+}
\ No newline at end of file
diff --git a/apps/yms/app/src/test/resources/ydtTestYangFiles/purchasingsupervisor.yang b/apps/yms/app/src/test/resources/ydtTestYangFiles/purchasingsupervisor.yang
new file mode 100644
index 0000000..a52b4c5
--- /dev/null
+++ b/apps/yms/app/src/test/resources/ydtTestYangFiles/purchasingsupervisor.yang
@@ -0,0 +1,27 @@
+module purchasingsupervisor {
+
+ yang-version 1;
+
+ namespace "ydt.purchasing-supervisor";
+
+ prefix "purchasing";
+
+ organization "ON-LAB";
+
+ description "This module defines for purchasing-supervisor.";
+
+ revision "2016-05-24" {
+ description "Initial revision.";
+ }
+
+ container supervisor {
+ leaf purchasing-specialist {
+ type string;
+ description "name of the purchasing-specialist person";
+ }
+ leaf support {
+ type string;
+ description "name of the support person";
+ }
+ }
+}
\ No newline at end of file
diff --git a/apps/yms/app/src/test/resources/ydtTestYangFiles/rootlist.yang b/apps/yms/app/src/test/resources/ydtTestYangFiles/rootlist.yang
new file mode 100644
index 0000000..ef5a0a0
--- /dev/null
+++ b/apps/yms/app/src/test/resources/ydtTestYangFiles/rootlist.yang
@@ -0,0 +1,111 @@
+module rootlist {
+
+ yang-version 1;
+
+ namespace "ydt.rootlist";
+
+ prefix "rootlist";
+
+ organization "ON-LAB";
+
+ description "This submodule defines for root.";
+
+ revision "2016-06-24" {
+ description "Initial revision.";
+ }
+/*
+ +--------------+---------+-------------+
+ | substatement | section | cardinality |
+ +--------------+---------+-------------+
+ | anyxml | 7.10 | 0..n |
+ | choice | 7.9 | 0..n |
+ | config | 7.19.1 | 0..1 |
+ | container | 7.5 | 0..n |
+ | description | 7.19.3 | 0..1 |
+ | grouping | 7.11 | 0..n |
+ | if-feature | 7.18.2 | 0..n |
+ | key | 7.8.2 | 0..1 |
+ | leaf | 7.6 | 0..n |
+ | leaf-list | 7.7 | 0..n |
+ | list | 7.8 | 0..n |
+ | max-elements | 7.7.4 | 0..1 |
+ | min-elements | 7.7.3 | 0..1 |
+ | must | 7.5.3 | 0..n |
+ | ordered-by | 7.7.5 | 0..1 |
+ | reference | 7.19.4 | 0..1 |
+ | status | 7.19.2 | 0..1 |
+ | typedef | 7.3 | 0..n |
+ | unique | 7.8.3 | 0..n |
+ | uses | 7.12 | 0..n |
+ | when | 7.19.5 | 0..1 |
+ +--------------+---------+-------------+
+*/
+
+ list listwithoutcontainer {
+ key "invalidinterval";
+ min-elements 1; //-- comment
+ leaf invalidinterval {
+ type "uint16";
+ units "seconds";
+ description "Interval before a route is declared invalid";
+ config true;
+ mandatory true;
+ status current;
+ reference "RFC 6020";
+ }
+ }
+
+ list listwithcontainer {
+ key "invalid invalid1";
+ max-elements 3;
+ min-elements 1;
+ reference "list reference";
+ unique "invalid";
+ leaf-list invalidinterval {
+ type "uint16";
+ units "seconds";
+ description "Interval before a route is declared invalid";
+ config false;
+ status current;
+ reference "RFC 6020";
+ }
+
+ container interface {
+ leaf invalidinterval {
+ type "uint16";
+ units "seconds";
+ status current;
+ mandatory true;
+ reference "RFC 6020";
+ }
+
+ leaf invalid {
+ type "uint16";
+ units "seconds";
+ description "Interval before a route is declared invalid";
+ default "16";
+ status current;
+ reference "RFC 6020";
+ }
+
+ }
+
+ leaf invalid {
+ type "uint16";
+ units "seconds";
+ description "Interval before a route is declared invalid";
+ mandatory true;
+ status current;
+ reference "RFC 6020";
+ }
+
+ leaf invalid1 {
+ type "uint16";
+ units "seconds";
+ description "Interval before a route is declared invalid";
+ mandatory true;
+ status current;
+ reference "RFC 6020";
+ }
+ }
+}
diff --git a/apps/yms/app/src/test/resources/ydtTestYangFiles/tradingsupervisor.yang b/apps/yms/app/src/test/resources/ydtTestYangFiles/tradingsupervisor.yang
new file mode 100644
index 0000000..a6c8681
--- /dev/null
+++ b/apps/yms/app/src/test/resources/ydtTestYangFiles/tradingsupervisor.yang
@@ -0,0 +1,21 @@
+module tradingsupervisor {
+
+ yang-version 1;
+
+ namespace "ydt.trading-supervisor";
+
+ prefix "trading";
+
+ organization "ON-LAB";
+
+ description "This module defines for trading-supervisor.";
+
+ revision "2016-05-24" {
+ description "Initial revision.";
+ }
+
+ leaf supervisor {
+ type string;
+ description "name of the trading-supervisor";
+ }
+}
\ No newline at end of file
diff --git a/apps/yms/app/src/test/resources/ydtTestYangFiles/warehousesupervisor.yang b/apps/yms/app/src/test/resources/ydtTestYangFiles/warehousesupervisor.yang
new file mode 100644
index 0000000..5145824
--- /dev/null
+++ b/apps/yms/app/src/test/resources/ydtTestYangFiles/warehousesupervisor.yang
@@ -0,0 +1,21 @@
+module warehousesupervisor {
+
+ yang-version 1;
+
+ namespace "ydt.warehouse-supervisor";
+
+ prefix "warehouse";
+
+ organization "ON-LAB";
+
+ description "This module defines for warehouse-supervisor.";
+
+ revision "2016-05-24" {
+ description "Initial revision.";
+ }
+
+ leaf-list supervisor {
+ type string;
+ description "name of the warehouse-supervisor's";
+ }
+}
\ No newline at end of file
diff --git a/apps/yms/app/src/test/resources/ydtTestYangFiles/yms-network-topology.yang b/apps/yms/app/src/test/resources/ydtTestYangFiles/yms-network-topology.yang
new file mode 100644
index 0000000..6b9452c
--- /dev/null
+++ b/apps/yms/app/src/test/resources/ydtTestYangFiles/yms-network-topology.yang
@@ -0,0 +1,304 @@
+ module yms-network-topology {
+ yang-version 1;
+ namespace "urn:ietf:params:xml:ns:yang:ietf-network-topology";
+ prefix lnk;
+
+ import yms-ietf-inet-types {
+ prefix inet;
+ }
+ import yms-ietf-network {
+ prefix nd;
+ }
+
+ organization
+ "IETF I2RS (Interface to the Routing System) Working Group";
+
+ contact
+ "WG Web: <http://tools.ietf.org/wg/i2rs/>
+ WG List: <mailto:i2rs@ietf.org>
+
+ WG Chair: Susan Hares
+ <mailto:shares@ndzh.com>
+
+ WG Chair: Jeffrey Haas
+ <mailto:jhaas@pfrc.org>
+
+ Editor: Alexander Clemm
+ <mailto:alex@cisco.com>
+
+ Editor: Jan Medved
+ <mailto:jmedved@cisco.com>
+
+ Editor: Robert Varga
+ <mailto:rovarga@cisco.com>
+
+ Editor: Tony Tkacik
+ <mailto:ttkacik@cisco.com>
+
+ Editor: Nitin Bahadur
+ <mailto:nitin_bahadur@yahoo.com>
+
+ Editor: Hariharan Ananthakrishnan
+ <mailto:hari@packetdesign.com>";
+
+ description
+ "This module defines a common base model for network topology,
+ augmenting the base network model with links to connect nodes,
+ as well as termination points to terminate links on nodes.
+
+ Copyright (c) 2015 IETF Trust and the persons identified as
+ authors of the code. All rights reserved.
+
+ Redistribution and use in source and binary forms, with or
+ without modification, is permitted pursuant to, and subject
+ to the license terms contained in, the Simplified BSD License
+ set forth in Section 4.c of the IETF Trust's Legal Provisions
+ Relating to IETF Documents
+ (http://trustee.ietf.org/license-info).
+
+ This version of this YANG module is part of
+ draft-ietf-i2rs-yang-network-topo-02;
+ see the RFC itself for full legal notices.
+
+ NOTE TO RFC EDITOR: Please replace above reference to
+ draft-ietf-i2rs-yang-network-topo-02 with RFC
+ number when published (i.e. RFC xxxx).";
+
+ revision 2015-12-08 {
+ description
+ "Initial revision.
+ NOTE TO RFC EDITOR: Please replace the following reference
+ to draft-ietf-i2rs-yang-network-topo-02 with
+ RFC number when published (i.e. RFC xxxx).";
+ reference
+ "draft-ietf-i2rs-yang-network-topo-02.";
+ }
+
+ typedef link-id {
+ type inet:uri;
+ description
+ "An identifier for a link in a topology.
+ The identifier SHOULD be chosen such that the same link in a
+ real network topology will always be identified through the
+ same identifier, even if the model is instantiated in
+ separate datastores. An implementation MAY choose to capture
+ semantics in the identifier, for example to indicate the type
+ of link and/or the type of topology that the link is a part
+ of.";
+ }
+
+ typedef tp-id {
+ type inet:uri;
+ description
+ "An identifier for termination points on a node.
+ The identifier SHOULD be chosen such that the same TP in a
+ real network topology will always be identified through the
+ same identifier, even if the model is instantiated in
+ separate datastores. An implementation MAY choose to capture
+ semantics in the identifier, for example to indicate the type
+ of TP and/or the type of node and topology that the TP is a
+ part of.";
+ }
+ grouping link-ref {
+ description
+ "References a link in a specific network.";
+ leaf link-ref {
+ type leafref {
+ path "/nd:networks/nd:network[nd:network-id=current()/../"+
+ "network-ref]/lnk:link/lnk:link-id";
+ require-instance false;
+ }
+ description
+ "A type for an absolute reference a link instance.
+ (This type should not be used for relative references.
+ In such a case, a relative path should be used instead.)";
+ }
+ uses nd:network-ref;
+ }
+
+ grouping tp-ref {
+ description
+ "References a termination point in a specific node.";
+ leaf tp-ref {
+ type leafref {
+ path "/nd:networks/nd:network[nd:network-id=current()/../"+
+ "network-ref]/nd:node[nd:node-id=current()/../"+
+ "node-ref]/lnk:termination-point/lnk:tp-id";
+ require-instance false;
+ }
+ description
+ "A type for an absolute reference to a termination point.
+ (This type should not be used for relative references.
+ In such a case, a relative path should be used instead.)";
+ }
+ uses nd:node-ref;
+ }
+
+ augment "/nd:networks/nd:network" {
+ description
+ "Add links to the network model.";
+ list link {
+ key "link-id";
+ description
+ "A Network Link connects a by Local (Source) node and
+ a Remote (Destination) Network Nodes via a set of the
+ nodes' termination points.
+ As it is possible to have several links between the same
+ source and destination nodes, and as a link could
+ potentially be re-homed between termination points, to
+ ensure that we would always know to distinguish between
+ links, every link is identified by a dedicated link
+ identifier.
+ Note that a link models a point-to-point link, not a
+ multipoint link.
+ Layering dependencies on links in underlay topologies are
+ not represented as the layering information of nodes and of
+ termination points is sufficient.";
+ container source {
+ description
+ "This container holds the logical source of a particular
+ link.";
+ leaf source-node {
+ type leafref {
+ path "../../../nd:node/nd:node-id";
+ }
+ mandatory true;
+ description
+ "Source node identifier, must be in same topology.";
+ }
+ leaf source-tp {
+ type leafref {
+ path "../../../nd:node[nd:node-id=current()/../"+
+ "source-node]/t-point/tp-id";
+ }
+ description
+ "Termination point within source node that terminates
+ the link.";
+ }
+ }
+ container destination {
+ description
+ "This container holds the logical destination of a
+ particular link.";
+ leaf dest-node {
+ type leafref {
+ path "../../../nd:node/nd:node-id";
+ }
+ mandatory true;
+ description
+ "Destination node identifier, must be in the same
+ network.";
+ }
+ leaf dest-tp {
+ type leafref {
+ path "../../../nd:node[nd:node-id=current()/../"+
+ "dest-node]/t-point/tp-id";
+ }
+ description
+ "Termination point within destination node that
+ terminates the link.";
+ }
+ }
+ leaf link-id {
+ type link-id;
+ description
+ "The identifier of a link in the topology.
+ A link is specific to a topology to which it belongs.";
+ }
+ list supporting-link {
+ key "network-ref link-ref";
+ description
+ "Identifies the link, or links, that this link
+ is dependent on.";
+ leaf network-ref {
+ type leafref {
+ path "../../../nd:supporting-network/nd:network-ref";
+ require-instance false;
+ }
+ description
+ "This leaf identifies in which underlay topology
+ supporting link is present.";
+ }
+ leaf link-ref {
+ type leafref {
+ path "/nd:networks/nd:network[nd:network-id=current()/"+
+ "../network-ref]/link/link-id";
+ require-instance false;
+ }
+ description
+ "This leaf identifies a link which is a part
+ of this link's underlay. Reference loops, in which
+ a link identifies itself as its underlay, either
+ directly or transitively, are not allowed.";
+ }
+ }
+ }
+
+ leaf link-id {
+ type link-id;
+ description
+ "The identifier of a link in the topology.
+ A link is specific to a topology to which it belongs.";
+ }
+ }
+ augment "/nd:networks/nd:network/nd:node" {
+ description
+ "Augment termination points which terminate links.
+ Termination points can ultimately be mapped to interfaces.";
+ list t-point {
+ key "tp-id";
+ description
+ "A termination point can terminate a link.
+ Depending on the type of topology, a termination point
+ could, for example, refer to a port or an interface.";
+ leaf tp-id {
+ type tp-id;
+ description
+ "Termination point identifier.";
+ }
+ list supporting-termination-point {
+ key "network-ref node-ref tp-ref";
+ description
+ "The leaf list identifies any termination points that
+ the termination point is dependent on, or maps onto.
+ Those termination points will themselves be contained
+ in a supporting node.
+ This dependency information can be inferred from
+ the dependencies between links. For this reason,
+ this item is not separately configurable. Hence no
+ corresponding constraint needs to be articulated.
+ The corresponding information is simply provided by the
+ implementing system.";
+ leaf network-ref {
+ type leafref {
+ path "../../../nd:supporting-node/nd:network-ref";
+ require-instance false;
+ }
+ description
+ "This leaf identifies in which topology the
+ supporting termination point is present.";
+ }
+ leaf node-ref {
+ type leafref {
+ path "../../../nd:supporting-node/nd:node-ref";
+ require-instance false;
+ }
+ description
+ "This leaf identifies in which node the supporting
+ termination point is present.";
+ }
+ leaf tp-ref {
+ type leafref {
+ path "/nd:networks/nd:network[nd:network-id=current()/"+
+ "../network-ref]/nd:node[nd:node-id=current()/../"+
+ "node-ref]/t-point/tp-id";
+ require-instance false;
+ }
+ description
+ "Reference to the underlay node, must be in a
+ different topology";
+ }
+ }
+ }
+ }
+ }