YMS migration to onos-yangtool 1.10
Change-Id: I22ddf23f813840e0afec1e7713a86891f2a52f28
diff --git a/apps/yms/app/src/main/java/org/onosproject/yms/app/ych/DefaultYangCodecHandler.java b/apps/yms/app/src/main/java/org/onosproject/yms/app/ych/DefaultYangCodecHandler.java
index 45eb37f..8847c41 100644
--- a/apps/yms/app/src/main/java/org/onosproject/yms/app/ych/DefaultYangCodecHandler.java
+++ b/apps/yms/app/src/main/java/org/onosproject/yms/app/ych/DefaultYangCodecHandler.java
@@ -30,14 +30,13 @@
import org.onosproject.yms.ydt.YdtBuilder;
import org.onosproject.yms.ydt.YdtContext;
import org.onosproject.yms.ydt.YmsOperationType;
+import org.onosproject.yms.ysr.YangModuleLibrary;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import static org.onosproject.yms.app.ych.defaultcodecs.utils.DefaultCodecUtils.isNonEmpty;
-
/**
* Represents implementation of YANG SBI broker interfaces.
@@ -54,6 +53,7 @@
* Schema registry for driver.
*/
private final YangSchemaRegistry schemaRegistry;
+ private YangModuleLibrary library;
/**
* Default codecs.
@@ -90,8 +90,9 @@
YangProtocolEncodingFormat dataFormat) {
YangDataTreeCodec codec = defaultCodecs.get(dataFormat);
+ int size = overrideCodecs.size();
// Check over ridden codec handler is exist or not.
- if (overrideCodecs != null) {
+ if (size != 0) {
YangDataTreeCodec overrideCodec = overrideCodecs.get(dataFormat);
if (overrideCodec != null) {
codec = overrideCodec;
@@ -103,6 +104,7 @@
@Override
public void addDeviceSchema(Class<?> yangModule) {
schemaRegistry.registerApplication(null, yangModule);
+ schemaRegistry.processModuleLibrary(yangModule.getName(), library);
}
@Override
@@ -166,7 +168,6 @@
opType,
schemaRegistry);
-
// Get the composite response from codec handler.
return codec.encodeYdtToCompositeProtocolFormat(extBuilder);
}
@@ -176,15 +177,20 @@
YangProtocolEncodingFormat dataFormat,
YmsOperationType opType) {
+ YdtBuilder ydtBuilder;
YangDataTreeCodec codec = getAppropriateCodec(dataFormat);
if (codec == null) {
throw new YchException(E_DATA_TREE_CODEC);
}
- // Get the YANG data tree
- YdtBuilder ydtBuilder = codec.decodeProtocolDataToYdt(inputString,
- schemaRegistry,
- opType);
+ try {
+ // Get the YANG data tree
+ ydtBuilder = codec.decodeProtocolDataToYdt(inputString,
+ schemaRegistry,
+ opType);
+ } catch (Exception e) {
+ throw new YchException(e.getLocalizedMessage());
+ }
if (ydtBuilder != null) {
return getObjectList(ydtBuilder.getRootNode());
@@ -210,10 +216,7 @@
// Get the module object by using YANG data tree
if (ydtBuilder != null) {
- List<Object> objectList = getObjectList(ydtBuilder.getRootNode());
- if (isNonEmpty(objectList)) {
- return objectList.get(0);
- }
+ return getObjectList(ydtBuilder.getRootNode());
}
return null;
@@ -260,4 +263,22 @@
return objectList;
}
+
+ /**
+ * Returns module library for YSR.
+ *
+ * @return module library for YSR
+ */
+ public YangModuleLibrary getLibrary() {
+ return library;
+ }
+
+ /**
+ * Sets module library for YSR.
+ *
+ * @param library module library for YSR
+ */
+ public void setLibrary(YangModuleLibrary library) {
+ this.library = library;
+ }
}
diff --git a/apps/yms/app/src/main/java/org/onosproject/yms/app/ych/defaultcodecs/netconf/NetconfCodec.java b/apps/yms/app/src/main/java/org/onosproject/yms/app/ych/defaultcodecs/netconf/NetconfCodec.java
index 8b50d33..5e5d731 100644
--- a/apps/yms/app/src/main/java/org/onosproject/yms/app/ych/defaultcodecs/netconf/NetconfCodec.java
+++ b/apps/yms/app/src/main/java/org/onosproject/yms/app/ych/defaultcodecs/netconf/NetconfCodec.java
@@ -82,7 +82,6 @@
//TODO
}
}
-
}
/**
@@ -100,7 +99,9 @@
try {
validateOpType(elementName, opType);
// If config tag name is found then set the root element node.
- if (ALLOWABLE_NAMES.contains(elementName)) {
+ if (DATA.equals(elementName)
+ || CONFIG.equals(elementName)
+ || FILTER.equals(elementName)) {
return rootElement;
}
@@ -113,7 +114,6 @@
retElement = getDataRootElement(childElement, opType);
}
}
-
} catch (Exception e) {
// TODO
}
diff --git a/apps/yms/app/src/main/java/org/onosproject/yms/app/ych/defaultcodecs/utils/DefaultCodecUtils.java b/apps/yms/app/src/main/java/org/onosproject/yms/app/ych/defaultcodecs/utils/DefaultCodecUtils.java
index 1d9e339..873d7bb 100644
--- a/apps/yms/app/src/main/java/org/onosproject/yms/app/ych/defaultcodecs/utils/DefaultCodecUtils.java
+++ b/apps/yms/app/src/main/java/org/onosproject/yms/app/ych/defaultcodecs/utils/DefaultCodecUtils.java
@@ -78,16 +78,6 @@
}
/**
- * Returns true, if the list is not null and non-empty; false otherwise.
- *
- * @param object list object
- * @return true, if the list is not null and non-empty; false otherwise
- */
- public static boolean isNonEmpty(List object) {
- return object != null && !object.isEmpty();
- }
-
- /**
* Converts a list of path segments to a YDT builder tree.
*
* @param paths the list of path segments split from URI
diff --git a/apps/yms/app/src/main/java/org/onosproject/yms/app/ych/defaultcodecs/xml/XmlCodecListener.java b/apps/yms/app/src/main/java/org/onosproject/yms/app/ych/defaultcodecs/xml/XmlCodecListener.java
index 6b6ba38..1c6536a 100644
--- a/apps/yms/app/src/main/java/org/onosproject/yms/app/ych/defaultcodecs/xml/XmlCodecListener.java
+++ b/apps/yms/app/src/main/java/org/onosproject/yms/app/ych/defaultcodecs/xml/XmlCodecListener.java
@@ -69,6 +69,10 @@
nameSpace = element.getNamespace().getURI();
}
+ if (nodeType == OBJECT_NODE && element.content() == null || element
+ .content().isEmpty()) {
+ nodeType = TEXT_NODE;
+ }
if (nodeType == OBJECT_NODE) {
if (ydtExtBuilder != null) {
ydtExtBuilder.addChild(element.getName(), nameSpace, opType);
diff --git a/apps/yms/app/src/main/java/org/onosproject/yms/app/ych/defaultcodecs/xml/XmlCodecSingleInstanceLeafHandler.java b/apps/yms/app/src/main/java/org/onosproject/yms/app/ych/defaultcodecs/xml/XmlCodecSingleInstanceLeafHandler.java
index f44f9b2..e7b786e 100644
--- a/apps/yms/app/src/main/java/org/onosproject/yms/app/ych/defaultcodecs/xml/XmlCodecSingleInstanceLeafHandler.java
+++ b/apps/yms/app/src/main/java/org/onosproject/yms/app/ych/defaultcodecs/xml/XmlCodecSingleInstanceLeafHandler.java
@@ -29,6 +29,9 @@
@Override
public void setXmlValue(YdtContext ydtContext,
Stack<Element> elementStack) {
- elementStack.peek().setText(ydtContext.getValue());
+
+ if (ydtContext.getValue() != null) {
+ elementStack.peek().setText(ydtContext.getValue());
+ }
}
}
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
index 8fee570..79d9581 100644
--- 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
@@ -17,9 +17,6 @@
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
@@ -28,48 +25,6 @@
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
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
index 621eda6..98187aa 100644
--- 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
@@ -16,9 +16,6 @@
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.
@@ -33,10 +30,11 @@
* 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
+ * @param flag true for augmented context; false for module context
* @return appContext application context
*/
- public static DefaultYdtAppContext getAppContext(boolean isAugmented) {
- return isAugmented ? getAugmentAppContext() : getModuleAppContext();
+ public static DefaultYdtAppContext getAppContext(boolean flag) {
+ return flag ? new DefaultYdtAppContext(new AugmentedSchemaData()) :
+ new DefaultYdtAppContext(new ModuleSchemaData());
}
}
diff --git a/apps/yms/app/src/main/java/org/onosproject/yms/app/ydt/AugmentAppData.java b/apps/yms/app/src/main/java/org/onosproject/yms/app/ydt/AugmentAppData.java
new file mode 100644
index 0000000..1a43cb7
--- /dev/null
+++ b/apps/yms/app/src/main/java/org/onosproject/yms/app/ydt/AugmentAppData.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;
+
+import org.onosproject.yangutils.datamodel.YangSchemaNode;
+
+/**
+ * Represents an augmented node in application tree.
+ */
+interface AugmentAppData extends AppData {
+
+ /**
+ * 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);
+}
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
index 6a45cad..dd4eabb 100644
--- 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
@@ -18,23 +18,12 @@
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.";
+public class AugmentedSchemaData implements AugmentAppData {
/*
* Reference for schema node of augmenting application.
@@ -42,25 +31,6 @@
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;
}
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
index f75fc9c..03502d4 100644
--- 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
@@ -16,26 +16,19 @@
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;
+import static org.onosproject.yms.app.ydt.YdtUtils.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.
+ * Abstraction of an entity which represents YDT application context
+ * information. This context information will be used by protocol to obtain
+ * the information associated with YDT application tree node.
*/
public final class DefaultYdtAppContext<T extends AppData>
implements YdtAppContext {
@@ -68,35 +61,19 @@
/*
* YDT application tree extended information.
*/
- private T appData;
+ private final 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);
+ DefaultYdtAppContext(T data) {
+ appData = data;
}
@Override
@@ -119,9 +96,9 @@
@Override
public void setAppData(YdtNode moduleNode, YangSchemaNode augmentNode) {
if (augmentNode != null) {
- appData.setAugmentingSchemaNode(augmentNode);
+ ((AugmentAppData) appData).setAugmentingSchemaNode(augmentNode);
} else {
- appData.setModuleContext(moduleNode);
+ ((ModuleAppData) appData).setModuleContext(moduleNode);
}
}
@@ -145,8 +122,12 @@
return child;
}
- @Override
- public void setChild(YdtAppContext child) {
+ /**
+ * Sets the context of first child.
+ *
+ * @param child node
+ */
+ private void setChild(YdtAppContext child) {
this.child = child;
}
@@ -156,8 +137,8 @@
}
@Override
- public void setNextSibling(YdtAppContext nextSibling) {
- this.nextSibling = nextSibling;
+ public void setNextSibling(YdtAppContext context) {
+ this.nextSibling = context;
}
@Override
@@ -166,8 +147,8 @@
}
@Override
- public void setPreviousSibling(YdtAppContext previousSibling) {
- this.previousSibling = previousSibling;
+ public void setPreviousSibling(YdtAppContext context) {
+ this.previousSibling = context;
}
@Override
@@ -182,61 +163,31 @@
@Override
public List<YdtContext> getDeleteNodes() {
- return appData.getDeleteNodes();
+ return ((ModuleAppData) appData).getDeleteNodes();
}
-
@Override
public void addDeleteNode(YdtNode node) {
DefaultYdtAppContext<?> curNode = this;
while (curNode.getParent().getParent() != null) {
curNode = (DefaultYdtAppContext<?>) curNode.getParent();
}
-
- curNode.appData.addDeleteNodes(node);
+ ((ModuleAppData) curNode.appData).addDeleteNodes(node);
}
@Override
public YdtContext getModuleContext() {
- return appData.getModuleContext();
- }
-
- @Override
- public void setModuleContext(YdtContext moduleNode) {
- appData.setModuleContext(moduleNode);
+ return ((ModuleAppData) appData).getModuleContext();
}
@Override
public YangSchemaNode getAugmentingSchemaNode() {
- return appData.getAugmentingSchemaNode();
+ return ((AugmentAppData) 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;
+ ((AugmentAppData) appData).setAugmentingSchemaNode(schemaNode);
}
@Override
@@ -244,9 +195,13 @@
return lastChild;
}
- @Override
- public void setLastChild(YdtAppContext lastChild) {
- this.lastChild = lastChild;
+ /**
+ * Sets the context of last child.
+ *
+ * @param child node
+ */
+ private void setLastChild(YdtAppContext child) {
+ lastChild = child;
}
@Override
@@ -275,28 +230,4 @@
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/ModuleAppData.java b/apps/yms/app/src/main/java/org/onosproject/yms/app/ydt/ModuleAppData.java
new file mode 100644
index 0000000..5bafe24
--- /dev/null
+++ b/apps/yms/app/src/main/java/org/onosproject/yms/app/ydt/ModuleAppData.java
@@ -0,0 +1,54 @@
+/*
+ * 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 java.util.List;
+
+/**
+ * Represents a module/sub-module node in application tree.
+ */
+interface ModuleAppData extends 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(YdtExtendedContext moduleNode);
+}
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
index fd4f1b6..0823190 100644
--- 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
@@ -17,7 +17,6 @@
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;
@@ -27,20 +26,17 @@
* 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.";
+public class ModuleSchemaData implements ModuleAppData {
/*
* Reference for application's root ydtContext.
*/
- private YdtContext moduleContext;
+ private YdtExtendedContext moduleContext;
/*
* Reference for list of nodes with operation type delete.
*/
- private List<YdtContext> deleteNodes = new ArrayList<>();
+ private final List<YdtContext> deleteNodes = new ArrayList<>();
@Override
public List<YdtContext> getDeleteNodes() {
@@ -59,27 +55,17 @@
}
@Override
- public void setModuleContext(YdtContext moduleContext) {
+ public void setModuleContext(YdtExtendedContext 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();
+ return moduleContext.getYangSchemaNode();
}
@Override
public YangSchemaNode getRootSchemaNode() {
- return getSchemaNode();
+ return moduleContext.getYangSchemaNode();
}
}
diff --git a/apps/yms/app/src/main/java/org/onosproject/yms/app/ydt/NameSpace.java b/apps/yms/app/src/main/java/org/onosproject/yms/app/ydt/NameSpace.java
new file mode 100644
index 0000000..b446457
--- /dev/null
+++ b/apps/yms/app/src/main/java/org/onosproject/yms/app/ydt/NameSpace.java
@@ -0,0 +1,47 @@
+/*
+ * 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.YangNamespace;
+
+class NameSpace implements YangNamespace {
+
+ /*
+ * Reference for namespace.
+ */
+ private final String nameSpace;
+
+ /**
+ * Creates an instance of namespace which is used to initialize the
+ * nameSpace for requested YDT node.
+ *
+ * @param nameSpace namespace of the requested node
+ */
+ public NameSpace(String nameSpace) {
+ this.nameSpace = nameSpace;
+ }
+
+ @Override
+ public String getModuleNamespace() {
+ return nameSpace;
+ }
+
+ @Override
+ public String getModuleName() {
+ return nameSpace;
+ }
+}
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
index ace971b..4c1a16c 100644
--- 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
@@ -27,9 +27,9 @@
LEAF,
/**
- * Requested Node is of type single/multi instance node.
+ * Requested Node is of type single/multi instance non leaf node.
*/
- OTHER,
+ NON_LEAF,
/**
* Requested Node is of type multi instance leaf/node.
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
index 625f1ed..dc36028 100644
--- 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
@@ -17,34 +17,42 @@
package org.onosproject.yms.app.ydt;
import com.google.common.collect.ImmutableMap;
+import org.onosproject.yangutils.datamodel.YangAugment;
+import org.onosproject.yangutils.datamodel.YangLeaf;
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.ydt.exceptions.YdtException;
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.HashSet;
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.RequestedCallType.NON_LEAF;
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.app.ydt.YdtNodeFactory.getNode;
+import static org.onosproject.yms.app.ydt.YdtNodeFactory.getYangSchemaNodeTypeSpecificContext;
+import static org.onosproject.yms.app.ydt.YdtUtils.checkElementCount;
+import static org.onosproject.yms.app.ydt.YdtUtils.freeRestResources;
+import static org.onosproject.yms.app.ydt.YdtUtils.getAppOpTypeFromYdtOpType;
+import static org.onosproject.yms.app.ydt.YdtUtils.getAugmentingSchemaNode;
+import static org.onosproject.yms.app.ydt.YdtUtils.getNodeIdentifier;
+import static org.onosproject.yms.app.ydt.YdtUtils.getValidOpType;
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;
@@ -56,45 +64,34 @@
*/
public class YangRequestWorkBench implements YdtExtendedBuilder {
- // ydt formatted error string
+ // 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";
+
+ // Ydt error strings.
+ private static final String E_USE_ADD_LEAF =
+ "Requested Node should be created using addLeaf interface.";
+
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.";
+ "Can't invoke get parent at logical root node.";
/*
- * Current node in YANG data tree, kept to maintain the
- * current context in YDT.
+ * Reference for the current context node in YANG data tree.
*/
private YdtNode curNode;
/*
- * Root node in YANG data tree, kept to maintain the root context in
- * YDT.
+ * Reference for the logical root node in YANG data tree.
*/
private YdtNode rootNode;
/*
- * Current node in YANG data tree, kept to maintain the current context
- * in ydt application tree.
+ * Reference for 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.
+ * Reference for the logical root node context in ydt application tree.
*/
private YdtAppContext appRootNode;
@@ -129,6 +126,13 @@
// TODO validate need to be handle later with interaction type basis in
// future when it will be supported
+ /*
+ * Reference for application tree node set.
+ * This set contains the method name's generated for an augmented
+ * target node to avoid the duplicate entries in YDT application tree for
+ * multiple augmented nodes under a single XPATH.
+ */
+ private Set<String> augGenMethodSet;
/**
* Creates an instance of YANG request work bench which is use to initialize
@@ -139,47 +143,27 @@
* @param namespace namespace of logical container
* @param opType type of operation done by using YANG
* interface
- * @param registry Yang schema registry
+ * @param reg 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,
+ YangSchemaRegistry reg,
boolean isValidate) {
- YdtNode newNode;
- YangSchemaNodeIdentifier nodeIdentifier =
- new YangSchemaNodeIdentifier();
- nodeIdentifier.setName(name);
- nodeIdentifier.setNameSpace(namespace);
- newNode = new YdtSingleInstanceNode(nodeIdentifier);
- setRootNode(newNode);
- this.registry = registry;
+
+ setRootNode(new YdtLogicalNode(name, namespace));
+ registry = reg;
ymsOperationType = opType;
validate = isValidate;
- // Set the logical root node for yang data app tree.
- DefaultYdtAppContext appNode = getAppContext(true);
- setAppRootNode(appNode);
+ setAppRootNode(getAppContext(true));
}
/**
- * Creates an instance of YANG request work bench which is used to build YDT
- * tree in YAB.
+ * Sets the logical root node for ydt.
*
- * @param curNode current YDT node
- * @param operationType YMS operation type
- */
- public YangRequestWorkBench(YdtNode curNode,
- YmsOperationType operationType) {
- this.curNode = curNode;
- ymsOperationType = operationType;
- }
-
- /**
- * Sets the logical root context information available in YDT node.
- *
- * @param node logical root node
+ * @param node ydt logical root node
*/
private void setRootNode(YdtNode node) {
rootNode = node;
@@ -187,9 +171,9 @@
}
/**
- * Sets the app context tree logical root node for ydt application tree.
+ * Sets the logical root node for ydt application tree.
*
- * @param node application tree's logical root node
+ * @param node ydt application context logical root node
*/
private void setAppRootNode(YdtAppContext node) {
appRootNode = node;
@@ -207,37 +191,57 @@
}
/**
- * Returns the app context tree root node for ydt application tree.
- * This method will be used by yab.
+ * Returns the ydt app context tree logical root node.
+ * This method will be used by yab and ytb.
*
- * @return YdtAppContext refers to root node of ydt application tree
+ * @return YdtAppContext app tree logical root node
*/
public YdtAppContext getAppRootNode() {
return appRootNode;
}
/**
- * Returns the data tree for given node identifier.
+ * Returns the ydt module node with requested node identifier.
*
- * @param id Represents node identifier of YANG data tree node
- * @param namespace namespace of the application requested by user
+ * @param id module/application node identifier
* @return YANG data tree node
+ * @throws YdtException when user requested node schema doesn't exist or
+ * requested node is already part of the tree
*/
- private YdtNode moduleHandler(YangSchemaNodeIdentifier id,
- String namespace) {
+ private YdtNode moduleHandler(YangSchemaNodeIdentifier id)
+ throws YdtException {
- YangSchemaNode node = registry
- .getYangSchemaNodeUsingSchemaName(id.getName());
+ YangSchemaNode node =
+ registry.getYangSchemaNodeUsingSchemaName(id.getName());
- if (node == null ||
- namespace != null && !namespace.equals(node.getNameSpace())) {
- curNode.errorHandler(errorMsg(
- FMT_NOT_EXIST, id.getName()), rootNode);
+ String namespace = id.getNameSpace().getModuleNamespace();
+
+ /*
+ * Checking received schema node is having same namespace as
+ * requested by user or not.
+ */
+ if (node == null || namespace != null &&
+ !namespace.equals(node.getYangSchemaNodeIdentifier()
+ .getNameSpace()
+ .getModuleNamespace())) {
+ throw new YdtException(errorMsg(FMT_NOT_EXIST, id.getName()));
}
- YdtNode newNode = new YdtSingleInstanceNode(id);
+ /*
+ * If yms operation is for query then no validation need to be
+ * performed.
+ */
+ if (ymsOperationType != YmsOperationType.QUERY_REQUEST) {
+ // Checking whether module node is already exits in YDT or not.
+ try {
+ curNode.getCollidingChild(id);
+ } catch (YdtException e) {
+ throw new YdtException(e.getLocalizedMessage());
+ }
+ }
+
+ YdtNode newNode = new YdtSingleInstanceNode(node);
newNode.setYangSchemaNode(node);
- id.setNameSpace(node.getNameSpace());
return newNode;
}
@@ -255,25 +259,29 @@
}
@Override
- public void addChild(String name, String namespace) {
- addChild(name, namespace, UNKNOWN, null, OTHER);
+ public void addChild(String name, String namespace)
+ throws IllegalArgumentException {
+ addChild(name, namespace, UNKNOWN, null, NON_LEAF);
}
@Override
- public void addChild(String name, String namespace, YdtType ydtType) {
+ public void addChild(String name, String namespace, YdtType ydtType)
+ throws IllegalArgumentException {
addChild(name, namespace, ydtType, null);
}
@Override
public void addChild(String name, String namespace,
- YdtContextOperationType opType) {
- addChild(name, namespace, UNKNOWN, opType, OTHER);
+ YdtContextOperationType opType)
+ throws IllegalArgumentException {
+ addChild(name, namespace, UNKNOWN, opType, NON_LEAF);
}
@Override
public void addChild(String name, String namespace, YdtType ydtType,
- YdtContextOperationType opType) {
- RequestedCardinality cardinality = null;
+ YdtContextOperationType opType)
+ throws IllegalArgumentException {
+ RequestedCardinality cardinality;
switch (ydtType) {
case MULTI_INSTANCE_NODE:
cardinality = MULTI_INSTANCE;
@@ -282,9 +290,9 @@
cardinality = SINGLE_INSTANCE;
break;
default:
- curNode.errorHandler(E_USE_ADDLEAF, rootNode);
+ throw new IllegalArgumentException(E_USE_ADD_LEAF);
}
- addChild(name, namespace, cardinality, opType, OTHER);
+ addChild(name, namespace, cardinality, opType, NON_LEAF);
}
/**
@@ -297,95 +305,108 @@
* @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
+ * @throws IllegalArgumentException when method has been passed an illegal
+ * or inappropriate argument.
*/
private void addChild(String name, String namespace,
RequestedCardinality cardinality,
YdtContextOperationType opType,
- RequestedCallType callType) {
+ RequestedCallType callType)
+ throws IllegalArgumentException {
- YdtNode childNode;
- boolean isContextSwitch = false;
- YangSchemaNode schemaNode = null;
- YangSchemaNodeContextInfo contextInfo;
+ YdtNode newNode;
+ boolean contextSwitch = false;
YangSchemaNode augmentingSchema = null;
+ YangSchemaNodeIdentifier id = getNodeIdentifier(name, namespace);
- 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();
+ try {
+ // Module/sub-module node handler.
+ if (curNode.equals(rootNode)) {
+ newNode = moduleHandler(id);
} 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;
+
+ YangSchemaNode schemaNode;
+ YangSchemaNodeContextInfo contextInfo;
+
+ // If namespace given by user null, then take namespace from parent.
+ if (namespace == null) {
+ id.setNameSpace(curNode.getYangSchemaNode().getNameSpace());
}
- schemaNode = childNode.getYangSchemaNode();
+
+ /*
+ * Get the already exiting YDT node in YDT tree with same
+ * nodeIdentifier
+ */
+ newNode = curNode.getCollidingChild(id);
+
+ /*
+ * If colliding child doesn't exist ,
+ * then query yang data model for schema of given node.
+ */
+ if (newNode == null) {
+ /*
+ * Get Yang Schema node context info which is having
+ * YangSchemaNode and ContextSwitchedNode.
+ */
+ contextInfo = curNode.getSchemaNodeContextInfo(id);
+
+ if (contextInfo.getContextSwitchedNode() != null) {
+ augmentingSchema = 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.
+ */
+ contextSwitch = true;
+ }
+ }
+ schemaNode = contextInfo.getSchemaNode();
+ } else {
+ /*
+ * If colliding child exist , then it 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 (newNode.getYdtType() == MULTI_INSTANCE_LEAF_VALUE_NODE) {
+ curNode = newNode;
+ return;
+ }
+ schemaNode = newNode.getYangSchemaNode();
+ }
+
+ /*
+ * For yms query request node specific validation are not
+ * required as rest-conf can call addChild api for leaf/leaf-list
+ * node addition also in ydt.
+ */
+ if (ymsOperationType == YmsOperationType.QUERY_REQUEST) {
+ newNode = getYangSchemaNodeTypeSpecificContext(schemaNode);
+ } else {
+ newNode = getNode(schemaNode, cardinality, callType);
+ }
}
- childNode = YdtNodeFactory.getNode(id, schemaNode, cardinality,
- callType);
+
+ opType = getValidOpType(opType, ydtDefaultOpType, newNode, curNode);
+
+ newNode.setYdtContextOperationType(opType);
+
+ curNode.addChild(newNode, true);
+ } catch (YdtException e) {
+ freeRestResources(rootNode);
+ throw new IllegalArgumentException(e.getLocalizedMessage());
}
- opType = getValidOpType(opType, callType, schemaNode);
-
- childNode.setYdtContextOperationType(opType);
-
- curNode.addChild(childNode, true);
-
// Update parent ydt node map.
- curNode.updateYdtMap(id, childNode);
+ curNode.updateYdtMap(newNode);
- processAppTree(opType, childNode, augmentingSchema, isContextSwitch);
+ processAppTree(opType, newNode, augmentingSchema, contextSwitch);
- // Updating the curNode.
- curNode = childNode;
+ curNode = newNode;
}
/**
@@ -394,18 +415,17 @@
* @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
+ * @param contextSwitch true, for module node call; false for modules
* sub-node calls
*/
private void processAppTree(
YdtContextOperationType opType, YdtNode childNode,
- YangSchemaNode augmentingSchema, boolean isContextSwitch) {
+ YangSchemaNode augmentingSchema, boolean contextSwitch) {
- if (augmentingSchema != null) {
- if (!appCurNode.addSchemaToAppSet(augmentingSchema)) {
- return;
- }
+ if (curNode == rootNode) {
+ augGenMethodSet = new HashSet<>();
}
+
if (opType == null) {
opType = curNode.getYdtContextOperationType();
} else {
@@ -414,13 +434,23 @@
}
/*
- * 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.
+ * This is to avoid multiple entries of single augmented target.
*/
- if (curNode.equals(rootNode) || isContextSwitch) {
+ if (augmentingSchema != null) {
+ if (!augGenMethodSet.add(((YangAugment) augmentingSchema)
+ .getSetterMethodName())) {
+ return;
+ }
+ }
+
+ /*
+ * Create entry of module node in ydt app tree.
+ * Or if context switch happened then also add entry for same
+ * augmented ydt node in the ydt application tree.
+ */
+ if (curNode.equals(rootNode) || contextSwitch) {
addChildInAppTree(childNode, augmentingSchema, opType,
- isContextSwitch);
+ contextSwitch);
// Setting app tree node operation.
appCurNode.setOperationType(getAppOpTypeFromYdtOpType(opType));
@@ -432,56 +462,6 @@
}
}
- /**
- * 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
@@ -504,10 +484,9 @@
// 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);
@@ -517,40 +496,15 @@
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) {
+ public void addLeaf(String name, String namespace, String value)
+ throws IllegalArgumentException {
addLeaf(name, namespace, value, null, UNKNOWN);
}
@Override
- public void addLeaf(String name, String namespace, Set<String> valueSet) {
+ public void addLeaf(String name, String namespace, Set<String> valueSet)
+ throws IllegalArgumentException {
addLeaf(name, namespace, null, valueSet, MULTI_INSTANCE_LEAF);
}
@@ -568,51 +522,66 @@
* @param value value of the child
* @param valueSet list of value of the child
* @param cardinality type of YANG data tree node operation
+ * @throws IllegalArgumentException when method has been passed an illegal
+ * or inappropriate argument.
*/
private void addLeaf(String name, String namespace, String value,
Set<String> valueSet,
- RequestedCardinality cardinality) {
- addChild(name, namespace, cardinality, null, LEAF);
+ RequestedCardinality cardinality)
+ throws IllegalArgumentException {
+ try {
+ 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);
+ // After successful addition of child node updating the values in same.
+ if (value != null) {
+ curNode.addValue(value);
+ } else if (valueSet != null) {
+ curNode.addValueSet(valueSet);
+ }
+ } catch (YdtException e) {
+ freeRestResources(rootNode);
+ throw new IllegalArgumentException(e.getLocalizedMessage());
}
}
@Override
- public void traverseToParent() {
+ public void traverseToParent() throws IllegalStateException {
// If traverse back to parent for logical root node comes
if (curNode.equals(rootNode)) {
- curNode.errorHandler(E_INVOKE_PARENT, rootNode);
+ freeRestResources(rootNode);
+ throw new IllegalStateException(E_INVOKE_PARENT);
}
- // If node is of multiInstanceNode type then check key uniqueness.
- if (curNode.getYdtType() == MULTI_INSTANCE_NODE) {
- curNode.createKeyNodeList();
- }
+ try {
- /*
- * Check application switch for curNode if set,
- * then traverseToParent in YDT application tree.
- */
- if (curNode.getParent().equals(rootNode) ||
- curNode.getAppContextSwitch()) {
- traverseToAppTreeParent();
- }
+ // If node is of multiInstanceNode type then check key uniqueness.
+ if (curNode.getYdtType() == MULTI_INSTANCE_NODE) {
+ curNode.createKeyNodeList();
+ }
- /*
- * 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();
- }
+ /*
+ * Check application switch for curNode if set,
+ * then traverseToParent in YDT application tree.
+ */
+ if (curNode.getParent().equals(rootNode) ||
+ curNode.getAppContextSwitch()) {
+ traverseToAppTreeParent();
+ }
- curNode = curNode.getParent();
+ /*
+ * 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();
+ } catch (YdtException e) {
+ freeRestResources(rootNode);
+ throw new IllegalStateException(e.getLocalizedMessage());
+ }
}
/**
@@ -647,59 +616,60 @@
@Override
public void addMultiInstanceChild(String name, String namespace,
List<String> keysValueList,
- YdtContextOperationType opType) {
+ YdtContextOperationType opType)
+ throws IllegalArgumentException {
+
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();
+ try {
+ if (curNode.getYdtType() == MULTI_INSTANCE_LEAF_VALUE_NODE) {
+
+ /*
+ * Calculating the current leaf-list node array size by adding
+ * existing elements count and new supplied elements by user for
+ * the same.
+ */
+ // TODO instance count for leaf list need to be handled.
+// if (curNode.getValueSet().size() + inputCount > expectedCount) {
+// curNode.errorHandler(
+// errorMsg(FMT_MANY_INS, name, expectedCount), rootNode);
+// }
+
+ /*
+ * After successful addition of child node updating
+ * the values in same.
+ */
+ for (String value : keysValueList) {
+ curNode.addValue(value);
}
- }
- curNode = curNode.getParent();
- } else {
- curNode.errorHandler(E_MULTI_INS, rootNode);
- }
- }
+ } else if (curNode.getYdtType() == MULTI_INSTANCE_NODE) {
- /**
- * 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);
+ YangList yangListHolder = (YangList) curNode.getYangSchemaNode();
+ List<String> schemaKeyList = yangListHolder.getKeyList();
+ int expectedCount = schemaKeyList.size();
+ checkElementCount(name, expectedCount, inputCount);
+
+ //After validation adding the key nodes under the list node.
+ 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();
+ }
+ } catch (YdtException e) {
+ freeRestResources(rootNode);
+ throw new IllegalArgumentException(e.getLocalizedMessage());
}
}
@@ -713,15 +683,7 @@
private YdtNode addExtendedChildNode(YdtContextOperationType opType,
YangSchemaNode schemaNode) {
- YdtNode childNode;
- YangSchemaNodeIdentifier id =
- schemaNode.getYangSchemaNodeIdentifier();
-
- childNode = YdtNodeFactory
- .getYangSchemaNodeTypeSpecificContext(
- id, schemaNode.getYangSchemaNodeType());
-
- childNode.setId(id);
+ YdtNode childNode = getYangSchemaNodeTypeSpecificContext(schemaNode);
childNode.setYangSchemaNode(schemaNode);
@@ -745,27 +707,53 @@
YangSchemaNode schemaNode) {
YdtNode childNode = addExtendedChildNode(null, schemaNode);
- // After successful addition of child node updating the values in same.
+ /*
+ * After successful addition of child node updating the values in
+ * valueSet.
+ */
childNode.addValueSetWithoutValidation(valueSet);
return childNode;
}
@Override
- public YdtExtendedContext addLeaf(String value,
- YangSchemaNode schemaNode) {
+ 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);
+ childNode.addValueWithoutValidation(value, ((YangLeaf) schemaNode)
+ .isKeyLeaf());
return childNode;
}
@Override
- public void traverseToParentWithoutValidation() {
- // If traverse back to parent for logical root node comes
+ public void traverseToParentWithoutValidation()
+ throws IllegalStateException {
+ // If traverse back to parent for logical root node comes.
if (curNode.equals(rootNode)) {
- curNode.errorHandler(E_INVOKE_PARENT, rootNode);
+ freeRestResources(rootNode);
+ throw new IllegalStateException(E_INVOKE_PARENT);
}
curNode = curNode.getParent();
}
+
+ /**
+ * Returns the method name's set for an augmented target node in an
+ * application tree.
+ *
+ * @return augGenMethodSet set of method name's
+ */
+ public Set<String> getAugGenMethodSet() {
+ return augGenMethodSet;
+ }
+
+ /**
+ * Sets the method name's set for an augmented target node in an
+ * application tree.
+ *
+ * @param augGenMethodSet set of method name's
+ */
+ public void setAugGenMethodSet(Set<String> augGenMethodSet) {
+ this.augGenMethodSet = augGenMethodSet;
+ }
}
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
index c845221..d6879d7 100644
--- 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
@@ -17,8 +17,6 @@
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;
@@ -55,13 +53,6 @@
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
@@ -69,13 +60,6 @@
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
@@ -139,13 +123,6 @@
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
@@ -167,19 +144,6 @@
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
@@ -212,12 +176,4 @@
* @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/YdtExtendedBuilder.java b/apps/yms/app/src/main/java/org/onosproject/yms/app/ydt/YdtExtendedBuilder.java
index ea9c9f3d..19aacb5 100644
--- 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
@@ -64,8 +64,11 @@
* 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.
+ *
+ * @throws IllegalStateException when user request for traverse to logical
+ * root node parent
*/
- void traverseToParentWithoutValidation();
+ void traverseToParentWithoutValidation() throws IllegalStateException;
@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
index 3668de8..79d9401 100644
--- 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
@@ -17,8 +17,6 @@
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;
@@ -47,16 +45,6 @@
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
diff --git a/apps/yms/app/src/main/java/org/onosproject/yms/app/ydt/YdtLogicalNode.java b/apps/yms/app/src/main/java/org/onosproject/yms/app/ydt/YdtLogicalNode.java
new file mode 100644
index 0000000..05de8b3
--- /dev/null
+++ b/apps/yms/app/src/main/java/org/onosproject/yms/app/ydt/YdtLogicalNode.java
@@ -0,0 +1,61 @@
+/*
+ * 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.ydt.exceptions.YdtException;
+
+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.LOGICAL_ROOT_NODE;
+
+/**
+ * Represents a logical YANG data tree node.
+ */
+class YdtLogicalNode extends YdtNode {
+
+ private final String name;
+ private final String namespace;
+
+ /**
+ * Creates a YANG logical node object.
+ */
+ public YdtLogicalNode(String name, String namespace) {
+ super(LOGICAL_ROOT_NODE);
+ this.name = name;
+ this.namespace = namespace;
+ }
+
+ @Override
+ public String getName() {
+ return name;
+ }
+
+ @Override
+ public String getNamespace() {
+ return namespace;
+ }
+
+ @Override
+ public String getModuleNameAsNameSpace() {
+ return namespace;
+ }
+
+ @Override
+ public void validDuplicateEntryProcessing() throws YdtException {
+ throw new YdtException(errorMsg(FMT_DUP_ENTRY, getName()));
+ }
+}
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
index 955852d..24316ad 100644
--- 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
@@ -17,10 +17,10 @@
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 org.onosproject.yangutils.datamodel.YangSchemaNode;
+import org.onosproject.yms.app.ydt.exceptions.YdtException;
-import java.util.HashSet;
+import java.util.LinkedHashSet;
import java.util.Set;
import static org.onosproject.yms.app.ydt.YdtConstants.errorMsg;
@@ -39,15 +39,15 @@
/**
* Set of values.
*/
- private final Set<String> valueSet = new HashSet<>();
+ private final Set<String> valueSet = new LinkedHashSet<>();
/**
* Creates a YANG multi instance leaf node.
*
- * @param id node identifier of YDT multi instance node
+ * @param node schema of YDT multi instance node
*/
- protected YdtMultiInstanceLeafNode(YangSchemaNodeIdentifier id) {
- super(MULTI_INSTANCE_LEAF_VALUE_NODE, id);
+ YdtMultiInstanceLeafNode(YangSchemaNode node) {
+ super(MULTI_INSTANCE_LEAF_VALUE_NODE, node);
}
@Override
@@ -56,13 +56,14 @@
}
@Override
- public void addValue(String value) {
+ public void addValue(String value) throws YdtException {
// check the value against corresponding data-type.
- try {
- getYangSchemaNode().isValueValid(value);
- } catch (Exception e) {
- errorHandler(e.getLocalizedMessage(), this);
- }
+ //TODO validation need to be decided
+// try {
+// getYangSchemaNode().isValueValid(value);
+// } catch (Exception e) {
+// throw new YdtException(e.getLocalizedMessage());
+// }
addValueToValueSet(value);
}
@@ -71,33 +72,33 @@
* the value.
*
* @param value value to be added
+ * @throws YdtException when the duplicate entry found in leaf-list node
*/
- private void addValueToValueSet(String value) {
-
+ private void addValueToValueSet(String value) throws YdtException {
if (!valueSet.add(value)) {
- errorHandler(errorMsg(FMT_DUP_ENTRY,
- getYdtNodeIdentifier().getName()), this);
+ throw new YdtException(errorMsg(FMT_DUP_ENTRY, getName()));
}
}
@Override
- public void addValueSet(Set valueSet) {
- String value = null;
+ public void addValueSet(Set valueSet) throws YdtException {
+ String value;
// 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);
- }
+ value = String.valueOf(aValueSet);
+ //TODO validation need to be decided
+// try {
+// value = String.valueOf(aValueSet);
+// getYangSchemaNode().isValueValid(value);
+// } catch (DataModelException e) {
+// throw new YdtException(e.getLocalizedMessage());
+// }
addValueToValueSet(value);
}
}
@Override
- public void addValueWithoutValidation(String value) {
+ public void addValueWithoutValidation(String value, boolean isKeyLeaf) {
valueSet.add(value);
}
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
index a24772b..48bc9ef 100644
--- 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
@@ -18,12 +18,15 @@
import com.google.common.collect.ImmutableList;
import org.onosproject.yangutils.datamodel.YangList;
+import org.onosproject.yangutils.datamodel.YangSchemaNode;
import org.onosproject.yangutils.datamodel.YangSchemaNodeIdentifier;
+import org.onosproject.yms.app.ydt.exceptions.YdtException;
import org.onosproject.yms.ydt.YdtContext;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
+import java.util.Set;
import static org.onosproject.yms.app.ydt.YdtConstants.errorMsg;
import static org.onosproject.yms.ydt.YdtType.MULTI_INSTANCE_NODE;
@@ -34,9 +37,15 @@
*/
public class YdtMultiInstanceNode extends YdtNode {
- // ydt formatted error string
+ // YDT formatted error string
private static final String FMT_MISSING_KEY =
"%s is missing some of the keys of %s.";
+ private static final String FMT_UNI_KEY =
+ "Some of the key elements are not unique in %s.";
+ 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.";
/*
* Reference for list of key element's ydtContext.
@@ -51,10 +60,10 @@
/**
* Creates a YANG multi instance node object.
*
- * @param id node identifier of YDT multi instance node .
+ * @param node schema of YDT multi instance node .
*/
- protected YdtMultiInstanceNode(YangSchemaNodeIdentifier id) {
- super(MULTI_INSTANCE_NODE, id);
+ YdtMultiInstanceNode(YangSchemaNode node) {
+ super(MULTI_INSTANCE_NODE, node);
}
/**
@@ -62,7 +71,7 @@
*
* @return composite key string
*/
- public String getCompositeKey() {
+ private String getCompositeKey() {
return compositeKey;
}
@@ -76,7 +85,7 @@
}
@Override
- public void createKeyNodeList() {
+ public void createKeyNodeList() throws YdtException {
YangList yangListHolder = (YangList) getYangSchemaNode();
List<String> schemaKeyList = yangListHolder.getKeyList();
@@ -96,30 +105,99 @@
List<YdtContext> nodeList = new ArrayList<>();
YangSchemaNodeIdentifier id = new YangSchemaNodeIdentifier();
- id.setNameSpace(getYdtNodeIdentifier().getNameSpace());
+ id.setNameSpace(new NameSpace(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);
+ YdtNode<YdtSingleInstanceLeafNode> collidingChild =
+ (YdtNode<YdtSingleInstanceLeafNode>) ydtNodeMap.get(id);
if (collidingChild == null) {
- errorHandler(errorMsg(FMT_MISSING_KEY,
- yangListHolder.getParent().getName(),
- yangListHolder.getName()), this);
+ throw new YdtException(
+ errorMsg(FMT_MISSING_KEY, yangListHolder.getParent()
+ .getName(), yangListHolder.getName()));
}
- 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);
+ ksb.append(collidingChild.getValue());
+ nodeList.add(collidingChild);
}
//Setting te key object in List.
keyNodeList = nodeList;
compositeKey = ksb.toString();
}
+
+ /**
+ * Validates the given list of instances by verifying the allowed
+ * instance count and key element uniqueness.
+ *
+ * @param keyStringSet set to validate the key element uniqueness
+ * @param list list of instance's of same list
+ * @throws YdtException when user requested multi instance node instance's
+ * count doesn't fit into the allowed instance's limit
+ * or doesn't have unique key's
+ */
+ public void validateInstances(Set keyStringSet, List list)
+ throws YdtException {
+
+ // Clearing the set.
+ keyStringSet.clear();
+
+ /*
+ * Storing the number of multiInstance node for number
+ * if instance validation.
+ */
+ int instanceCount = list.size();
+
+ YangList listSchema = (YangList) ((YdtMultiInstanceNode) list.get(0))
+ .getYangSchemaNode();
+ validateInstanceCount(instanceCount, listSchema);
+ if (listSchema.isConfig() && instanceCount > 1) {
+
+ /*
+ * Iterating over values in ydtNodeList of
+ * multiInstanceNode and compare the key string.
+ */
+ for (YdtNode ydtNode : (List<YdtNode<YdtMultiInstanceNode>>) list) {
+ if (!keyStringSet.add(((YdtMultiInstanceNode) ydtNode)
+ .getCompositeKey())) {
+ throw new YdtException(
+ errorMsg(FMT_UNI_KEY, ydtNode.getName()));
+ }
+ }
+ }
+ }
+
+ /**
+ * Validates the instance count for given list entry.
+ *
+ * @param instanceCount actual count
+ * @param list list entry for which instance count need
+ * to be validated
+ * @throws YdtException when user requested multi instance node instance's
+ * count doesn't fit into the allowed instance's limit
+ */
+ private void validateInstanceCount(int instanceCount, YangList list)
+ throws YdtException {
+
+ if (list.getMinElements() != null) {
+ int minElement = list.getMinElements().getMinElement();
+ if (instanceCount < minElement) {
+ throw new YdtException(errorMsg(FMT_FEW_INS, list.getName(),
+ minElement));
+ }
+ }
+
+ if (list.getMaxElements() != null) {
+ int maxElement = list.getMaxElements().getMaxElement();
+ if (instanceCount > maxElement) {
+ throw new YdtException(errorMsg(FMT_MANY_INS, list.getName(),
+ maxElement));
+ }
+ }
+ }
}
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
index c3d4b87..48cf53a 100644
--- 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
@@ -16,7 +16,6 @@
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;
@@ -42,10 +41,8 @@
*/
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 =
+ // YDT formatted error string
+ private static final String FMT_NON_LIST_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.";
@@ -55,12 +52,8 @@
"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
+ // 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";
@@ -99,7 +92,7 @@
/*
* Type of node.
*/
- private YdtType ydtType;
+ private final YdtType ydtType;
/*
* Flag to keep the track of context switch,
@@ -118,9 +111,17 @@
private YdtExtendedInfoType ydtExtendedInfoType;
/*
- * Ydt map to keep the track of node added in YDT.
+ * Ydt map to keep the track of node added under current parent node.
*/
- final Map<YangSchemaNodeIdentifier, List<YdtNode<T>>> ydtNodeMap =
+ final Map<YangSchemaNodeIdentifier, YdtNode<T>> ydtNodeMap =
+ new HashMap<>();
+
+ /*
+ * Ydt map to keep the track of multi instance node added under current
+ * parent node.
+ */
+ private final Map<YangSchemaNodeIdentifier,
+ List<YdtNode<YdtMultiInstanceNode>>> ydtMultiInsMap =
new HashMap<>();
/*
@@ -134,11 +135,6 @@
private YdtContextOperationType ydtContextOperationType;
/*
- * Key object for ydtNodeMap.
- */
- private YangSchemaNodeIdentifier id;
-
- /*
* Ydt map to keep the track of application information object
* with respective type.
*/
@@ -147,6 +143,26 @@
private YdtContext clonedNode;
/**
+ * Creates a specific type of node.
+ *
+ * @param type of YDT node
+ * @param node schema node
+ */
+ YdtNode(YdtType type, YangSchemaNode node) {
+ ydtType = type;
+ yangSchemaNode = node;
+ }
+
+ /**
+ * Creates a specific type of node.
+ *
+ * @param type of YDT node
+ */
+ YdtNode(YdtType type) {
+ ydtType = type;
+ }
+
+ /**
* Returns the cloned ydt node.
*
* @return clonedNode cloned ydt node
@@ -166,12 +182,17 @@
@Override
public String getName() {
- return id.getName();
+ return yangSchemaNode.getName();
}
@Override
public String getNamespace() {
- return id.getNameSpace();
+ return yangSchemaNode.getNameSpace().getModuleNamespace();
+ }
+
+ @Override
+ public String getModuleNameAsNameSpace() {
+ return yangSchemaNode.getNameSpace().getModuleName();
}
@Override
@@ -223,15 +244,21 @@
ydtAppInfoMap.put(appType, object);
}
- @Override
+ /**
+ * 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
+ * @throws YdtException when user requested node schema doesn't exist
+ */
public YangSchemaNodeContextInfo getSchemaNodeContextInfo(
- YangSchemaNodeIdentifier id) {
+ YangSchemaNodeIdentifier id) throws YdtException {
try {
return getYangSchemaNode().getChildSchema(id);
} catch (DataModelException e) {
- errorHandler(e.getLocalizedMessage(), this);
+ throw new YdtException(e.getLocalizedMessage());
}
- return null;
}
/**
@@ -243,18 +270,20 @@
*
* @param value value in a single instance node
*/
- public void addValue(String value) {
- errorHandler(
- errorMsg(FMT_VAL_N, getYdtNodeIdentifier().getName()), this);
+ public void addValue(String value) throws YdtException {
+ throw new YdtException(errorMsg(FMT_VAL_N, getName()));
}
/**
* Creates the list of key element's of multi instance node.
- * this will not be applicable on leaf and leaf-list node.
+ * This will not be applicable on leaf and leaf-list node.
+ *
+ * @throws YdtException when user requested multi instance node is missing
+ * any of the key element in request or requested
+ * node is of type other then multi instance node
*/
- public void createKeyNodeList() {
- errorHandler(errorMsg(
- FMT_KLIST_STR, getYdtNodeIdentifier().getName()), this);
+ public void createKeyNodeList() throws YdtException {
+ throw new YdtException(errorMsg(FMT_NON_LIST_STR, getName()));
}
/**
@@ -266,11 +295,12 @@
* 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
+ * @param value value in a single instance leaf node
+ * @param isKeyLeaf true, for key leaf; false non key leaf
*/
- public void addValueWithoutValidation(String value) {
- errorHandler(
- errorMsg(FMT_VAL_N, getYdtNodeIdentifier().getName()), this);
+ public void addValueWithoutValidation(String value, boolean isKeyLeaf)
+ throws YdtException {
+ throw new YdtException(errorMsg(FMT_VAL_N, getName()));
}
/**
@@ -282,9 +312,8 @@
*
* @param valueSet valueSet in a multi instance leaf node
*/
- public void addValueSet(Set<String> valueSet) {
- errorHandler(
- errorMsg(FMT_VAL_NS, getYdtNodeIdentifier().getName()), this);
+ public void addValueSet(Set<String> valueSet) throws YdtException {
+ throw new YdtException(errorMsg(FMT_VAL_NS, getName()));
}
/**
@@ -298,9 +327,9 @@
*
* @param valueSet valueSet in a multi instance leaf node
*/
- public void addValueSetWithoutValidation(Set<String> valueSet) {
- errorHandler(
- errorMsg(FMT_VAL_NS, getYdtNodeIdentifier().getName()), this);
+ public void addValueSetWithoutValidation(Set<String> valueSet)
+ throws YdtException {
+ throw new YdtException(errorMsg(FMT_VAL_NS, getName()));
}
/**
@@ -310,7 +339,7 @@
* the duplicate entry found. Subclasses may override this method
* to provide the correct behavior for their specific implementation.
*/
- public void validDuplicateEntryProcessing() {
+ void validDuplicateEntryProcessing() throws YdtException {
}
/**
@@ -318,36 +347,27 @@
*
* @param id represents a identifier of YANG data tree node
* @return YDT node
+ * @throws YdtException when user requested node already part of YDT tree.
*/
- public YdtNode getCollidingChild(YangSchemaNodeIdentifier id) {
+ public YdtNode getCollidingChild(YangSchemaNodeIdentifier id)
+ throws YdtException {
// Find the key in YDT map for getting the colliding node.
- List<YdtNode<T>> collidingChild = ydtNodeMap.get(id);
+ YdtNode 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);
+ collidingChild.validDuplicateEntryProcessing();
+ return collidingChild;
}
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
@@ -393,17 +413,13 @@
}
@Override
- public String getValue() {
- errorHandler(
- errorMsg(FMT_VAL_IN, getYdtNodeIdentifier().getName()), this);
- return null;
+ public String getValue() throws YdtException {
+ throw new YdtException(errorMsg(FMT_VAL_IN, getName()));
}
@Override
- public Set<String> getValueSet() {
- errorHandler(
- errorMsg(FMT_VAL_INS, getYdtNodeIdentifier().getName()), this);
- return null;
+ public Set<String> getValueSet() throws YdtException {
+ throw new YdtException(errorMsg(FMT_VAL_INS, getName()));
}
/**
@@ -424,23 +440,6 @@
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.
@@ -455,7 +454,7 @@
throws YdtException {
if (!(newChild instanceof YdtNode)) {
- errorHandler(errorMsg(E_SUPPORT), this);
+ throw new YdtException(errorMsg(E_SUPPORT));
}
YdtNode node = (YdtNode) newChild;
@@ -463,19 +462,19 @@
if (node.getParent() == null) {
node.setParent(this);
} else if (!node.getParent().equals(this)) {
- errorHandler(errorMsg(E_EXIST), this);
+ throw new YdtException(E_EXIST);
}
if (node.getFirstChild() != null && isAtomic) {
- errorHandler(errorMsg(E_ATOMIC), this);
+ throw new YdtException(E_ATOMIC);
}
if (node.getNextSibling() != null) {
- errorHandler(errorMsg(E_SIB), this);
+ throw new YdtException(E_SIB);
}
if (node.getPreviousSibling() != null) {
- errorHandler(errorMsg(E_PRE), this);
+ throw new YdtException(E_PRE);
}
// If new node needs to be added as first child.
@@ -507,16 +506,41 @@
}
/**
- * Updates ydt map of current context parent node.
+ * Updates ydt maps of current context parent node.
+ *
+ * @param node ydt node for which map need to be updated
+ */
+ void updateYdtMap(YdtNode node) {
+
+ YangSchemaNodeIdentifier id = node.getYangSchemaNode()
+ .getYangSchemaNodeIdentifier();
+ /*
+ * If node to be added is of type multi instance node(list) then multi
+ * instance node to be updated
+ */
+ if (node.getYdtType() == YdtType.MULTI_INSTANCE_NODE) {
+ updateMultiInsMap(id, node);
+ }
+
+ /*
+ * If entry for multi instance node is already there with same id then
+ * existing entry will be overwritten by the new entry.
+ */
+ ydtNodeMap.put(id, node);
+ }
+
+ /**
+ * Updates ydt multi instance 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);
+ private void updateMultiInsMap(YangSchemaNodeIdentifier id, YdtNode node) {
+
+ List<YdtNode<YdtMultiInstanceNode>> list = ydtMultiInsMap.get(id);
if (list == null) {
list = new ArrayList<>();
- ydtNodeMap.put(id, list);
+ ydtMultiInsMap.put(id, list);
}
list.add(node);
}
@@ -540,139 +564,45 @@
}
/**
- * Validates all multi Instance inside current context.
+ * Validates all multi Instance nodes inside current context.
*/
- public void validateMultiInstanceNode() {
+ public void validateMultiInstanceNode() throws YdtException {
// 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);
- }
+ if (ydtMultiInsMap.size() != 0) {
+ /*
+ * Iterating over values in map and find multi instance node list
+ * only.
+ */
+ for (List<YdtNode<YdtMultiInstanceNode>> ydtNodeList :
+ ydtMultiInsMap.values()) {
+ try {
+ ydtNodeList.get(0).validateInstances(keyStringSet,
+ ydtNodeList);
+ } catch (YdtException e) {
+ throw new YdtException(e.getLocalizedMessage());
}
}
}
}
/**
- * 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.
+ * Validates the given list of instances by verifying the allowed
+ * instance count and key element uniqueness.
+ * <p>
+ * This default implementation do nothing if requested node is of type
+ * other then multiInstanceNode. Subclasses may override this method
+ * to provide the correct behavior for their specific implementation.
*
- * @param node ydt node
+ * @param keyStringSet set to validate the key element uniqueness
+ * @param ydtNodeList list of instance's of same list
*/
- 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) {
+ void validateInstances(Set<String> keyStringSet,
+ List<YdtNode<YdtMultiInstanceNode>>
+ ydtNodeList) throws YdtException {
- // 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);
}
/**
@@ -691,17 +621,4 @@
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
index 43680da..aa84cea 100644
--- 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
@@ -17,17 +17,14 @@
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.yangutils.datamodel.exceptions.DataModelException;
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;
/**
@@ -36,9 +33,13 @@
*/
final class YdtNodeFactory {
- // ydt formatted error string
+ // YDT formatted error string
private static final String FMT_NOT_EXIST =
"Schema node with name %s doesn't exist.";
+ //TODO need to handle later
+ private static final String E_MULTI_INS =
+ "Requested interface adds an instance of type list or " +
+ "leaf-list node only.";
// No instantiation
private YdtNodeFactory() {
@@ -48,64 +49,68 @@
* 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 node data node as per YANG schema metadata
* @param cardinality requested cardinality of node
* @param callType identify the call type
* @return YANG data tree node
+ * @throws YdtException when user requested node type doesn't exist
*/
- protected static YdtNode getNode(YangSchemaNodeIdentifier id,
- YangSchemaNode schemaNode,
- RequestedCardinality cardinality,
- RequestedCallType callType) {
+ static YdtNode getNode(
+ YangSchemaNode node, RequestedCardinality cardinality,
+ RequestedCallType callType) throws YdtException {
- YdtNode newNode = null;
- YangSchemaNodeType nodeType = schemaNode.getYangSchemaNodeType();
+ YdtNode newNode;
+ YangSchemaNodeType type = node.getYangSchemaNodeType();
- switch (cardinality) {
+ try {
+ switch (cardinality) {
- case UNKNOWN:
+ case UNKNOWN:
+ /*
+ * if requested node type is UNKNOWN, check corresponding
+ * yang data node type and create respective type node.
+ */
+ newNode = getYangSchemaNodeTypeSpecificContext(node, type,
+ callType);
+ break;
+
/*
- * if requested node type is UNKNOWN, check corresponding
- * yang data node type and create respective type node.
+ * if requested node type is specified and it exist as node of
+ * some other type in data model then throw exception
*/
- newNode = getYangSchemaNodeTypeSpecificContext(id, nodeType,
- callType);
- break;
+ case SINGLE_INSTANCE:
+ validateNodeType(node, type, YANG_SINGLE_INSTANCE_NODE);
+ newNode = new YdtSingleInstanceNode(node);
+ 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:
- case MULTI_INSTANCE:
+ validateNodeType(node, type, YANG_MULTI_INSTANCE_NODE);
+ newNode = new YdtMultiInstanceNode(node);
+ break;
- validateNodeType(id, nodeType, YANG_MULTI_INSTANCE_NODE);
- newNode = new YdtMultiInstanceNode(id);
- break;
+ case SINGLE_INSTANCE_LEAF:
- case SINGLE_INSTANCE_LEAF:
+ validateNodeType(node, type, YANG_SINGLE_INSTANCE_LEAF_NODE);
+ newNode = new YdtSingleInstanceLeafNode(node);
+ break;
- validateNodeType(id, nodeType, YANG_SINGLE_INSTANCE_LEAF_NODE);
- newNode = new YdtSingleInstanceLeafNode(id);
- break;
+ case MULTI_INSTANCE_LEAF:
- case MULTI_INSTANCE_LEAF:
+ validateNodeType(node, type, YANG_MULTI_INSTANCE_LEAF_NODE);
+ newNode = new YdtMultiInstanceLeafNode(node);
+ break;
- validateNodeType(id, nodeType, YANG_MULTI_INSTANCE_LEAF_NODE);
- newNode = new YdtMultiInstanceLeafNode(id);
- break;
-
- default:
- throwNotExistError(id);
+ default:
+ newNode = null;
+ }
+ } catch (DataModelException | YdtException e) {
+ throw new YdtException(e.getLocalizedMessage());
}
- // set reference of yang data node in the requested node.
- newNode.setYangSchemaNode(schemaNode);
+ if (newNode == null) {
+ throw new YdtException(errorMsg(FMT_NOT_EXIST, node.getName()));
+ }
return newNode;
}
@@ -114,15 +119,17 @@
* 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 node schema node
* @param nodeType actual node type
* @param requestedType user requested node type
+ * @throws YdtException when user requested node type doesn't exist
*/
- private static void validateNodeType(YangSchemaNodeIdentifier id,
- YangSchemaNodeType nodeType,
- YangSchemaNodeType requestedType) {
+ private static void validateNodeType(
+ YangSchemaNode node, YangSchemaNodeType nodeType,
+ YangSchemaNodeType requestedType) throws YdtException {
+
if (nodeType != requestedType) {
- throwNotExistError(id);
+ throw new YdtException(errorMsg(FMT_NOT_EXIST, node.getName()));
}
}
@@ -130,127 +137,87 @@
* 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 node schema node
* @param nodeType schema node type as per YANG schema metadata
* @param callType identify the call type
* @return YANG data tree node
+ * @throws YdtException when user requested node type doesn't exist
*/
private static YdtNode getYangSchemaNodeTypeSpecificContext(
- YangSchemaNodeIdentifier id,
- YangSchemaNodeType nodeType,
- RequestedCallType callType) {
+ YangSchemaNode node, YangSchemaNodeType nodeType,
+ RequestedCallType callType) throws YdtException, DataModelException {
switch (callType) {
case LEAF:
switch (nodeType) {
case YANG_SINGLE_INSTANCE_LEAF_NODE:
- return new YdtSingleInstanceLeafNode(id);
+ return new YdtSingleInstanceLeafNode(node);
case YANG_MULTI_INSTANCE_LEAF_NODE:
- return new YdtMultiInstanceLeafNode(id);
+ return new YdtMultiInstanceLeafNode(node);
default:
- throwNotExistError(id);
+ return null;
}
- case OTHER:
+ case NON_LEAF:
switch (nodeType) {
case YANG_SINGLE_INSTANCE_NODE:
- return new YdtSingleInstanceNode(id);
+ return new YdtSingleInstanceNode(node);
case YANG_MULTI_INSTANCE_NODE:
- return new YdtMultiInstanceNode(id);
+ return new YdtMultiInstanceNode(node);
default:
- throwNotExistError(id);
+ return null;
}
case MULTI_INSTANCE:
switch (nodeType) {
case YANG_MULTI_INSTANCE_LEAF_NODE:
- return new YdtMultiInstanceLeafNode(id);
+ return new YdtMultiInstanceLeafNode(node);
case YANG_MULTI_INSTANCE_NODE:
- return new YdtMultiInstanceNode(id);
+ return new YdtMultiInstanceNode(node);
default:
- throwNotExistError(id);
+ throw new YdtException(E_MULTI_INS);
}
default:
- throwNotExistError(id);
+ return null;
}
-
- 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
+ * @param node schema node
* @return YANG data tree node
+ * @throws YdtException when user requested node type doesn't exist
*/
- protected static YdtNode getYangSchemaNodeTypeSpecificContext(
- YangSchemaNodeIdentifier id,
- YangSchemaNodeType nodeType) {
+ static YdtNode getYangSchemaNodeTypeSpecificContext(YangSchemaNode node)
+ throws YdtException {
- switch (nodeType) {
+ switch (node.getYangSchemaNodeType()) {
case YANG_SINGLE_INSTANCE_LEAF_NODE:
- return new YdtSingleInstanceLeafNode(id);
+ return new YdtSingleInstanceLeafNode(node);
case YANG_MULTI_INSTANCE_LEAF_NODE:
- return new YdtMultiInstanceLeafNode(id);
+ return new YdtMultiInstanceLeafNode(node);
case YANG_SINGLE_INSTANCE_NODE:
- return new YdtSingleInstanceNode(id);
+ return new YdtSingleInstanceNode(node);
case YANG_MULTI_INSTANCE_NODE:
- return new YdtMultiInstanceNode(id);
+ return new YdtMultiInstanceNode(node);
default:
- throwNotExistError(id);
+ throw new YdtException(errorMsg(FMT_NOT_EXIST, node.getName()));
}
-
- 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
index 0bd7036..44de72e 100644
--- 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
@@ -16,7 +16,8 @@
package org.onosproject.yms.app.ydt;
-import org.onosproject.yangutils.datamodel.YangSchemaNodeIdentifier;
+import org.onosproject.yangutils.datamodel.YangSchemaNode;
+import org.onosproject.yms.app.ydt.exceptions.YdtException;
import static org.onosproject.yms.app.ydt.YdtConstants.FMT_DUP_ENTRY;
import static org.onosproject.yms.app.ydt.YdtConstants.errorMsg;
@@ -33,13 +34,27 @@
*/
private String value;
+ /*
+ * Value of the leaf.
+ */
+ private Boolean isKeyLeaf = false;
+
/**
* Creates a YANG single instance leaf node.
*
- * @param id node identifier of YDT single instance leaf node
+ * @param node schema of YDT single instance leaf node
*/
- protected YdtSingleInstanceLeafNode(YangSchemaNodeIdentifier id) {
- super(SINGLE_INSTANCE_LEAF_VALUE_NODE, id);
+ YdtSingleInstanceLeafNode(YangSchemaNode node) {
+ super(SINGLE_INSTANCE_LEAF_VALUE_NODE, node);
+ }
+
+ /**
+ * Returns the flag indicating that requested leaf is key-leaf or not.
+ *
+ * @return isKeyLeaf true, for key leaf; false non key leaf
+ */
+ public Boolean isKeyLeaf() {
+ return isKeyLeaf;
}
@Override
@@ -48,13 +63,14 @@
}
@Override
- public void addValue(String value) {
+ public void addValue(String value) throws YdtException {
// Check the value against corresponding data-type.
- try {
- getYangSchemaNode().isValueValid(value);
- } catch (Exception e) {
- errorHandler(e.getLocalizedMessage(), this);
- }
+ //TODO validation need to be decided
+// try {
+// getYangSchemaNode().isValueValid(value);
+// } catch (Exception e) {
+// throw new YdtException(e.getLocalizedMessage());
+// }
// After validation is successful then add value to node.
this.value = value;
@@ -62,13 +78,13 @@
@Override
- public void addValueWithoutValidation(String value) {
+ public void addValueWithoutValidation(String value, boolean isKeyLeaf) {
this.value = value;
+ this.isKeyLeaf = isKeyLeaf;
}
@Override
- public void validDuplicateEntryProcessing() {
- errorHandler(errorMsg(FMT_DUP_ENTRY, getYdtNodeIdentifier().getName()),
- this);
+ public void validDuplicateEntryProcessing() throws YdtException {
+ throw new YdtException(errorMsg(FMT_DUP_ENTRY, getName()));
}
}
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
index b7f84b5..c8e66e6 100644
--- 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
@@ -16,7 +16,8 @@
package org.onosproject.yms.app.ydt;
-import org.onosproject.yangutils.datamodel.YangSchemaNodeIdentifier;
+import org.onosproject.yangutils.datamodel.YangSchemaNode;
+import org.onosproject.yms.app.ydt.exceptions.YdtException;
import static org.onosproject.yms.app.ydt.YdtConstants.FMT_DUP_ENTRY;
import static org.onosproject.yms.app.ydt.YdtConstants.errorMsg;
@@ -30,15 +31,14 @@
/**
* Creates a YANG single instance node object.
*
- * @param id node identifier of YDT single instance node
+ * @param node schema of YDT single instance node
*/
- protected YdtSingleInstanceNode(YangSchemaNodeIdentifier id) {
- super(SINGLE_INSTANCE_NODE, id);
+ YdtSingleInstanceNode(YangSchemaNode node) {
+ super(SINGLE_INSTANCE_NODE, node);
}
@Override
- public void validDuplicateEntryProcessing() {
- errorHandler(errorMsg(FMT_DUP_ENTRY, getYdtNodeIdentifier().getName()),
- this);
+ public void validDuplicateEntryProcessing() throws YdtException {
+ throw new YdtException(errorMsg(FMT_DUP_ENTRY, getName()));
}
}
diff --git a/apps/yms/app/src/main/java/org/onosproject/yms/app/ydt/YdtUtils.java b/apps/yms/app/src/main/java/org/onosproject/yms/app/ydt/YdtUtils.java
new file mode 100644
index 0000000..a9f15f2
--- /dev/null
+++ b/apps/yms/app/src/main/java/org/onosproject/yms/app/ydt/YdtUtils.java
@@ -0,0 +1,303 @@
+/*
+ * 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.YdtContextOperationType;
+
+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;
+import static org.onosproject.yms.ydt.YdtContextOperationType.CREATE;
+import static org.onosproject.yms.ydt.YdtContextOperationType.DELETE;
+import static org.onosproject.yms.ydt.YdtContextOperationType.MERGE;
+
+/**
+ * Utils to support yang data tree node creation.
+ */
+final class YdtUtils {
+
+ // YDT formatted error string
+ private static final String E_CREATE_OP =
+ "Create request is not allowed under delete operation.";
+ private static final String E_DELETE_OP =
+ "Delete request is not allowed under create operation.";
+ 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.";
+
+ //No instantiation.
+ private YdtUtils() {
+ }
+
+ /**
+ * Returns the app tree operation type with the help of YdtOperation type.
+ *
+ * @param opType ydt operation type
+ * @return app tree operation type
+ */
+ 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.
+ }
+ }
+
+ /**
+ * Validates the various combination of operation type.
+ *
+ * @param parentOpType Reference for parent node operation type
+ * @param childOpType type of YANG data tree node operation
+ * @throws YdtException when user requested node operation type is
+ * not valid as per parent node operation type
+ */
+ private static void validateOperationType(YdtContextOperationType parentOpType,
+ YdtContextOperationType childOpType)
+ throws YdtException {
+
+ switch (parentOpType) {
+ case CREATE:
+ // Inside the create operation delete operation should not come.
+ if (childOpType == DELETE) {
+ throw new YdtException(E_CREATE_OP);
+ }
+ break;
+ case DELETE:
+ // Inside the delete operation create operation should not come.
+ if (childOpType == CREATE) {
+ throw new YdtException(E_DELETE_OP);
+ }
+ break;
+ default:
+ //TODO check all possible scenario.
+ }
+ }
+
+ /**
+ * 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 type operation type of parent node
+ * @param defType YDT default operation type
+ * @return operation type for current non leaf node
+ */
+ private static YdtContextOperationType getOperationType(
+ YdtContextOperationType type, YdtContextOperationType defType) {
+ return type != null ? type : (defType != null ? defType : MERGE);
+ }
+
+ /**
+ * Returns the yang node identifier with requested name and namespace.
+ *
+ * @param name name of the node
+ * @param namespace namespace of the node
+ * @return yang node identifier
+ */
+ static YangSchemaNodeIdentifier getNodeIdentifier(String name,
+ String namespace) {
+ YangSchemaNodeIdentifier id = new YangSchemaNodeIdentifier();
+ id.setName(name);
+ id.setNameSpace(new NameSpace(namespace));
+ return id;
+ }
+
+ /**
+ * 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
+ * @throws YdtException when user requested multi instance node instance's
+ * count doesn't fit into the allowed instance limit
+ */
+ static void checkElementCount(String name, int expected,
+ int actual) throws YdtException {
+ if (expected < actual) {
+ throw new YdtException(
+ errorMsg(FMT_TOO_MANY, name, expected, actual));
+ } else if (expected > actual) {
+ throw new YdtException(
+ errorMsg(FMT_TOO_FEW, name, expected, actual));
+ }
+ }
+
+ /**
+ * Returns the valid operation type for requested ydt node after performing
+ * validation.
+ *
+ * @param opType user requested operation type
+ * @param newNode new requested ydt node
+ * @param parentNode parent node under which new node to be added
+ * @return operation type
+ * @throws YdtException when user requested node operation type is
+ * not valid as per parent node operation type
+ */
+ static YdtContextOperationType getValidOpType(
+ YdtContextOperationType opType, YdtContextOperationType defOpType,
+ YdtNode newNode, YdtNode parentNode)
+ throws YdtException {
+
+ switch (newNode.getYdtType()) {
+
+ case SINGLE_INSTANCE_NODE:
+ case MULTI_INSTANCE_NODE:
+
+ // Reference for parent node operation type.
+ YdtContextOperationType parentOpType =
+ parentNode.getYdtContextOperationType();
+
+ if (opType == null) {
+ opType = getOperationType(parentOpType, defOpType);
+ } else if (parentOpType != null) {
+ validateOperationType(parentOpType, opType);
+ }
+
+ return opType;
+
+ /*
+ * Nodes other then single/multi instance node does not support
+ * operation type so no need of validation for those.
+ */
+ default:
+ return null;
+ }
+ }
+
+ /**
+ * 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
+ * @throws YdtException when user requested node schema doesn't exist
+ */
+ public static YangSchemaNode getAugmentingSchemaNode(
+ YangSchemaNodeIdentifier id,
+ YangSchemaNodeContextInfo contextInfo) throws YdtException {
+ YangSchemaNode lastAugMod = null;
+ YangSchemaNode switchedNode =
+ contextInfo.getContextSwitchedNode();
+
+ // Finding the last augmenting schema for case/choice scenario.
+ 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;
+ }
+
+ /**
+ * De-reference all the tree node by walking the whole YDT from logical
+ * root node.
+ * This will be called only when any exception occurs while processing
+ * the node in Ydt tree.
+ *
+ * @param rootNode ydt logical root node
+ */
+ public static void freeRestResources(YdtNode rootNode) {
+
+ 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 static 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 YdtLogicalNode(null, null);
+ node.setParent(parentRef);
+ }
+}
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
index db21976..852ffd5 100644
--- 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
@@ -50,16 +50,4 @@
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/ymsm/YmsManager.java b/apps/yms/app/src/main/java/org/onosproject/yms/app/ymsm/YmsManager.java
index 475a67e..228dd02 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
@@ -33,6 +33,7 @@
import org.onosproject.yms.app.ydt.YangRequestWorkBench;
import org.onosproject.yms.app.ynh.YangNotificationExtendedService;
import org.onosproject.yms.app.ynh.YangNotificationManager;
+import org.onosproject.yms.app.ysr.DefaultYangModuleLibrary;
import org.onosproject.yms.app.ysr.DefaultYangSchemaRegistry;
import org.onosproject.yms.app.ysr.YangSchemaRegistry;
import org.onosproject.yms.ych.YangCodecHandler;
@@ -51,9 +52,11 @@
import java.util.List;
import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
+import static java.lang.String.valueOf;
+import static java.util.concurrent.Executors.newSingleThreadExecutor;
import static org.onlab.util.Tools.groupedThreads;
+import static org.onosproject.yms.app.ych.defaultcodecs.YangCodecRegistry.initializeDefaultCodec;
/**
* Represents implementation of YANG management system manager.
@@ -72,8 +75,9 @@
//module id generator should be used to generate a new module id for
//each YSR instance. So YCH also should generate it.
private IdGenerator moduleIdGenerator;
- private ExecutorService schemaRegistryExecutor;
+ private ExecutorService executor;
private YangNotificationExtendedService ynhExtendedService;
+ private YangModuleLibrary library;
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
protected CoreService coreService;
@@ -82,23 +86,22 @@
public void activate() {
appId = coreService.registerApplication(APP_ID);
moduleIdGenerator = coreService.getIdGenerator(MODULE_ID);
- schemaRegistry = new DefaultYangSchemaRegistry(String.valueOf(
- moduleIdGenerator.getNewId()));
- schemaRegistryExecutor =
- Executors.newSingleThreadExecutor(groupedThreads(
- "onos/apps/yang-management-system/schema-registry",
- "schema-registry-handler", log));
+ schemaRegistry = new DefaultYangSchemaRegistry();
+ library = new DefaultYangModuleLibrary(getNewModuleId());
+ executor = newSingleThreadExecutor(groupedThreads(
+ "onos/apps/yang-management-system/schema-registry",
+ "schema-registry-handler", log));
ynhExtendedService = new YangNotificationManager(schemaRegistry);
- //Initilize the default codecs
- YangCodecRegistry.initializeDefaultCodec();
+ //Initialize the default codec
+ initializeDefaultCodec();
log.info("Started");
}
@Deactivate
public void deactivate() {
- ((DefaultYangSchemaRegistry) schemaRegistry).flushYsrData();
- schemaRegistryExecutor.shutdown();
+ schemaRegistry.flushYsrData();
+ executor.shutdown();
// TODO implementation for other components.
log.info("Stopped");
@@ -107,25 +110,23 @@
@Override
public YdtBuilder getYdtBuilder(String logicalRootName,
String rootNamespace,
- YmsOperationType operationType) {
+ YmsOperationType opType) {
return new YangRequestWorkBench(logicalRootName, rootNamespace,
- operationType, schemaRegistry, true);
+ opType, schemaRegistry, true);
}
@Override
public YdtBuilder getYdtBuilder(String logicalRootName,
String rootNamespace,
- YmsOperationType operationType,
+ YmsOperationType opType,
Object schemaRegistryForYdt) {
if (schemaRegistryForYdt != null) {
- return new YangRequestWorkBench(logicalRootName, rootNamespace,
- operationType,
- (YangSchemaRegistry)
- schemaRegistryForYdt,
- false);
+ return new YangRequestWorkBench(
+ logicalRootName, rootNamespace, opType,
+ (YangSchemaRegistry) schemaRegistryForYdt, false);
}
return new YangRequestWorkBench(logicalRootName, rootNamespace,
- operationType, schemaRegistry, true);
+ opType, schemaRegistry, true);
}
@Override
@@ -163,13 +164,13 @@
@Override
public YangModuleLibrary getYangModuleLibrary() {
- return ((DefaultYangSchemaRegistry) schemaRegistry).getLibrary();
+ //TODO: get for YCH should be handled.
+ return library;
}
@Override
public String getYangFile(YangModuleIdentifier moduleIdentifier) {
- return ((DefaultYangSchemaRegistry) schemaRegistry)
- .getYangFile(moduleIdentifier);
+ return schemaRegistry.getYangFile(moduleIdentifier);
}
@Override
@@ -181,9 +182,14 @@
@Override
public void registerService(Object manager, Class<?> service,
List<String> features) {
- schemaRegistryExecutor.execute(() -> {
+ //perform registration of service
+ executor.execute(() -> {
+
schemaRegistry.registerApplication(manager, service);
- processNotificationRegistration(service, manager);
+ //process notification registration.
+ processNotificationRegistration(manager, service);
+
+ schemaRegistry.processModuleLibrary(service.getName(), library);
});
// TODO implementation based on supported features.
}
@@ -191,15 +197,15 @@
/**
* Process notification registration for manager class object.
*
- * @param service yang service
* @param manager yang manager
+ * @param service service class
*/
- private void processNotificationRegistration(Class<?> service,
- Object manager) {
- if (manager != null && manager instanceof ListenerService) {
- if (((DefaultYangSchemaRegistry) schemaRegistry)
- .verifyNotificationObject(service)) {
- ynhExtendedService.registerAsListener((ListenerService) manager);
+ private void processNotificationRegistration(Object manager, Class<?> service) {
+ synchronized (service) {
+ if (manager != null && manager instanceof ListenerService) {
+ if (schemaRegistry.verifyNotificationObject(manager, service)) {
+ ynhExtendedService.registerAsListener((ListenerService) manager);
+ }
}
}
}
@@ -211,11 +217,10 @@
@Override
public YangCodecHandler getYangCodecHandler() {
-
- YangSchemaRegistry yangSchemaRegistry =
- new DefaultYangSchemaRegistry(
- String.valueOf(moduleIdGenerator.getNewId()));
- return new DefaultYangCodecHandler(yangSchemaRegistry);
+ YangSchemaRegistry registry = new DefaultYangSchemaRegistry();
+ DefaultYangCodecHandler handler = new DefaultYangCodecHandler(registry);
+ handler.setLibrary(new DefaultYangModuleLibrary(getNewModuleId()));
+ return handler;
}
/**
@@ -226,4 +231,13 @@
public YangSchemaRegistry getSchemaRegistry() {
return schemaRegistry;
}
+
+ /**
+ * Returns new generated module id.
+ *
+ * @return new module id
+ */
+ private String getNewModuleId() {
+ return valueOf(moduleIdGenerator.getNewId());
+ }
}
diff --git a/apps/yms/app/src/main/java/org/onosproject/yms/app/ynh/YangNotificationManager.java b/apps/yms/app/src/main/java/org/onosproject/yms/app/ynh/YangNotificationManager.java
index 59da18c..a6d9f83 100644
--- a/apps/yms/app/src/main/java/org/onosproject/yms/app/ynh/YangNotificationManager.java
+++ b/apps/yms/app/src/main/java/org/onosproject/yms/app/ynh/YangNotificationManager.java
@@ -43,10 +43,22 @@
implements YangNotificationExtendedService {
private static final String YANG_NOTIFICATION = "yangnotification";
+
private final Logger log = LoggerFactory.getLogger(getClass());
- private final ExecutorService executor;
- private final YnhAbstractListener listener;
- private final YangSchemaRegistry schemaRegistry;
+
+ private ExecutorService executor;
+
+ /**
+ * YANG notification abstract listener. This listener will listens
+ * abstractly to all the notification from the application to which it
+ * has subscribed.
+ */
+ private YnhAbstractListener listener;
+
+ /**
+ * Maintains schema registry.
+ */
+ private YangSchemaRegistry schemaRegistry;
/**
* Creates an instance of YANG notification manager.
@@ -55,8 +67,8 @@
*/
public YangNotificationManager(YangSchemaRegistry registry) {
listener = new YnhAbstractListener();
- executor = Executors.newSingleThreadExecutor(
- groupedThreads("onos/yms", "event-handler-%d", log));
+ executor = Executors.newSingleThreadExecutor(groupedThreads(
+ "onos/yms", "event-handler-%d", log));
schemaRegistry = registry;
}
@@ -78,10 +90,12 @@
*/
private class YnhAbstractListener<E extends Event> implements
EventListener<E> {
+
@Override
public void event(Event event) {
executor.execute(() -> {
try {
+ log.info("Event received in ynh " + event.type());
/*
* Obtain YANG data tree corresponding to notification with
* logical root node as yangnotification, followed by
diff --git a/apps/yms/app/src/main/java/org/onosproject/yms/app/yob/YobUtils.java b/apps/yms/app/src/main/java/org/onosproject/yms/app/yob/YobUtils.java
index d72edc1..c8256c9 100644
--- a/apps/yms/app/src/main/java/org/onosproject/yms/app/yob/YobUtils.java
+++ b/apps/yms/app/src/main/java/org/onosproject/yms/app/yob/YobUtils.java
@@ -295,8 +295,8 @@
}
- Class<?> regClass = registry.getRegisteredClass(curSchemaNode,
- qualifiedClassName);
+ Class<?> regClass = registry.getRegisteredClass(curSchemaNode
+ );
return regClass.getClassLoader();
}
@@ -328,8 +328,7 @@
((YangNode) augmentSchemaNode).getParent();
Class<?> moduleClass = registry.getRegisteredClass(
- moduleNode, getCapitalCase(
- moduleNode.getJavaClassNameOrBuiltInType()));
+ moduleNode);
return moduleClass.getClassLoader();
}
diff --git a/apps/yms/app/src/main/java/org/onosproject/yms/app/ysr/DefaultYangModuleIdentifier.java b/apps/yms/app/src/main/java/org/onosproject/yms/app/ysr/DefaultYangModuleIdentifier.java
index e98e982..8f0af27 100644
--- a/apps/yms/app/src/main/java/org/onosproject/yms/app/ysr/DefaultYangModuleIdentifier.java
+++ b/apps/yms/app/src/main/java/org/onosproject/yms/app/ysr/DefaultYangModuleIdentifier.java
@@ -26,7 +26,7 @@
/**
* Representation of default YANG module identifier.
*/
-class DefaultYangModuleIdentifier implements YangModuleIdentifier,
+public class DefaultYangModuleIdentifier implements YangModuleIdentifier,
Comparator<YangModuleIdentifier> {
private final String moduleName;
diff --git a/apps/yms/app/src/main/java/org/onosproject/yms/app/ysr/DefaultYangModuleInformation.java b/apps/yms/app/src/main/java/org/onosproject/yms/app/ysr/DefaultYangModuleInformation.java
index 79778f7..3fc656f 100644
--- a/apps/yms/app/src/main/java/org/onosproject/yms/app/ysr/DefaultYangModuleInformation.java
+++ b/apps/yms/app/src/main/java/org/onosproject/yms/app/ysr/DefaultYangModuleInformation.java
@@ -17,6 +17,7 @@
package org.onosproject.yms.app.ysr;
import com.google.common.collect.ImmutableList;
+import org.onosproject.yangutils.datamodel.YangNamespace;
import org.onosproject.yms.ysr.YangModuleIdentifier;
import org.onosproject.yms.ysr.YangModuleInformation;
@@ -32,7 +33,7 @@
class DefaultYangModuleInformation implements YangModuleInformation {
private final YangModuleIdentifier moduleIdentifier;
- private final String nameSpace;
+ private final YangNamespace nameSpace;
private final List<String> features;
private final List<YangModuleIdentifier> subModuleIdentifiers;
@@ -43,7 +44,7 @@
* @param nameSpace name space of module
*/
DefaultYangModuleInformation(YangModuleIdentifier moduleIdentifier,
- String nameSpace) {
+ YangNamespace nameSpace) {
this.moduleIdentifier = moduleIdentifier;
this.nameSpace = nameSpace;
subModuleIdentifiers = new ArrayList<>();
@@ -55,8 +56,7 @@
return moduleIdentifier;
}
- @Override
- public String namespace() {
+ public YangNamespace namespace() {
return nameSpace;
}
diff --git a/apps/yms/app/src/main/java/org/onosproject/yms/app/ysr/DefaultYangModuleLibrary.java b/apps/yms/app/src/main/java/org/onosproject/yms/app/ysr/DefaultYangModuleLibrary.java
index 4187746..5cb991b 100644
--- a/apps/yms/app/src/main/java/org/onosproject/yms/app/ysr/DefaultYangModuleLibrary.java
+++ b/apps/yms/app/src/main/java/org/onosproject/yms/app/ysr/DefaultYangModuleLibrary.java
@@ -29,7 +29,7 @@
/**
* Representation of default YANG module library.
*/
-class DefaultYangModuleLibrary implements YangModuleLibrary {
+public class DefaultYangModuleLibrary implements YangModuleLibrary {
private final String moduleSetId;
private final List<YangModuleInformation> moduleInformation;
@@ -39,7 +39,7 @@
*
* @param moduleSetId module id
*/
- DefaultYangModuleLibrary(String moduleSetId) {
+ public DefaultYangModuleLibrary(String moduleSetId) {
this.moduleSetId = moduleSetId;
moduleInformation = new ArrayList<>();
}
diff --git a/apps/yms/app/src/main/java/org/onosproject/yms/app/ysr/DefaultYangSchemaRegistry.java b/apps/yms/app/src/main/java/org/onosproject/yms/app/ysr/DefaultYangSchemaRegistry.java
index ce123e1..58d772c 100644
--- a/apps/yms/app/src/main/java/org/onosproject/yms/app/ysr/DefaultYangSchemaRegistry.java
+++ b/apps/yms/app/src/main/java/org/onosproject/yms/app/ysr/DefaultYangSchemaRegistry.java
@@ -16,7 +16,6 @@
package org.onosproject.yms.app.ysr;
-import org.onosproject.yangutils.datamodel.RpcNotificationContainer;
import org.onosproject.yangutils.datamodel.YangInclude;
import org.onosproject.yangutils.datamodel.YangModule;
import org.onosproject.yangutils.datamodel.YangNode;
@@ -26,34 +25,33 @@
import org.onosproject.yms.ysr.YangModuleIdentifier;
import org.onosproject.yms.ysr.YangModuleInformation;
import org.onosproject.yms.ysr.YangModuleLibrary;
+import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import java.io.File;
-import java.io.FileInputStream;
import java.io.IOException;
-import java.io.ObjectInputStream;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Collections;
-import java.util.HashSet;
-import java.util.Iterator;
import java.util.List;
-import java.util.Set;
+import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import java.util.regex.Pattern;
+import static java.util.Collections.sort;
import static org.apache.commons.io.FileUtils.deleteDirectory;
import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.parseJarFile;
-import static org.onosproject.yangutils.utils.UtilConstants.DEFAULT;
-import static org.onosproject.yangutils.utils.UtilConstants.EMPTY_STRING;
import static org.onosproject.yangutils.utils.UtilConstants.EVENT_STRING;
+import static org.onosproject.yangutils.utils.UtilConstants.HYPHEN;
import static org.onosproject.yangutils.utils.UtilConstants.OP_PARAM;
import static org.onosproject.yangutils.utils.UtilConstants.PERIOD;
+import static org.onosproject.yangutils.utils.UtilConstants.SERVICE;
+import static org.onosproject.yangutils.utils.UtilConstants.SLASH;
import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getCapitalCase;
import static org.osgi.framework.FrameworkUtil.getBundle;
+import static org.slf4j.LoggerFactory.getLogger;
/**
@@ -61,111 +59,344 @@
* provides interface to an application to register its YANG schema
* with YMS. It provides YANG schema nodes to YDT, YNB and YSB.
*/
-public class DefaultYangSchemaRegistry
- implements YangSchemaRegistry {
+public class DefaultYangSchemaRegistry implements YangSchemaRegistry {
- private static final String SYSTEM = File.separator + "system" +
- File.separator;
+ private static final String SYSTEM = SLASH + "system" + SLASH;
private static final String MAVEN = "mvn:";
- private static final String HYPHEN = "-";
- private static final String DELIMITER = ".";
- private static final String SERVICE = "Service";
private static final String JAR = ".jar";
private static final String USER_DIRECTORY = "user.dir";
- private static final String SLASH = File.separator;
private static final String AT = "@";
private static final String DATE_FORMAT = "yyyy-mm-dd";
- private static final Logger log =
- LoggerFactory.getLogger(DefaultYangSchemaRegistry.class);
- private final ConcurrentMap<String, YsrAppContext> appObjectStore;
- private final ConcurrentMap<String, YsrAppContext> yangSchemaStore;
- private final ConcurrentMap<String, YsrAppContext>
- yangSchemaStoreForRootInterface;
- private final ConcurrentMap<String, YsrAppContext>
- yangSchemaStoreForRootOpParam;
- private final ConcurrentMap<String, YsrAppContext>
- yangRootSchemaStoreForNotification;
+ private static final String ONOS = "org.onosproject";
+ private static final Logger log = getLogger(DefaultYangSchemaRegistry.class);
+
+ /*
+ * Map for storing app objects.
+ */
+ private final ConcurrentMap<String, Object> appObjectStore;
+
+ /*
+ * Map for storing YANG schema nodes.
+ */
+ private final ConcurrentMap<String, ConcurrentMap<String, YangSchemaNode>>
+ yangSchemaStore;
+
+ /*
+ * Map for storing YANG schema nodes with respect to root's generated
+ * interface file name.
+ */
+ private final ConcurrentMap<String, YangSchemaNode> interfaceNameKeyStore;
+
+ /*
+ * Map for storing YANG schema nodes root's generated op param file name.
+ */
+ private final ConcurrentMap<String, YangSchemaNode> opParamNameKeyStore;
+
+ /*
+ * Map for storing YANG schema nodes with respect to notifications.
+ */
+ private final ConcurrentMap<String, YangSchemaNode> eventNameKeyStore;
+
+ /*
+ * Map for storing YANG schema nodes with respect to app name.
+ */
+ private final ConcurrentMap<String, YangSchemaNode> appNameKeyStore;
+
+ /*
+ * Map for storing registered classes.
+ */
private final ConcurrentMap<String, Class<?>> registerClassStore;
+
+ /*
+ * Map for storing YANG file details.
+ */
private final ConcurrentMap<YangModuleIdentifier, String> yangFileStore;
- private final YangModuleLibrary library;
- private YsrAppContext ysrAppContext;
- private YsrAppContext ysrContextForSchemaStore;
- private YsrAppContext ysrContextForAppStore;
- private ClassLoader classLoader;
+
+ private final ConcurrentMap<Object, Boolean> ynhRegistrationStore;
+ private final ConcurrentMap<String, String> jarPathStore;
/**
* Creates an instance of default YANG schema registry.
- *
- * @param moduleId module set id of YSR module library
*/
- public DefaultYangSchemaRegistry(String moduleId) {
+ public DefaultYangSchemaRegistry() {
appObjectStore = new ConcurrentHashMap<>();
yangSchemaStore = new ConcurrentHashMap<>();
- yangSchemaStoreForRootInterface = new ConcurrentHashMap<>();
- yangSchemaStoreForRootOpParam = new ConcurrentHashMap<>();
- yangRootSchemaStoreForNotification = new ConcurrentHashMap<>();
+ interfaceNameKeyStore = new ConcurrentHashMap<>();
+ opParamNameKeyStore = new ConcurrentHashMap<>();
+ eventNameKeyStore = new ConcurrentHashMap<>();
registerClassStore = new ConcurrentHashMap<>();
yangFileStore = new ConcurrentHashMap<>();
- library = new DefaultYangModuleLibrary(moduleId);
+ appNameKeyStore = new ConcurrentHashMap<>();
+ ynhRegistrationStore = new ConcurrentHashMap<>();
+ jarPathStore = new ConcurrentHashMap<>();
}
@Override
public void registerApplication(Object appObject, Class<?> serviceClass) {
+ synchronized (serviceClass) {
+ doPreProcessing(serviceClass, appObject);
+ if (!verifyIfApplicationAlreadyRegistered(serviceClass)) {
+ BundleContext context = getBundle(serviceClass).getBundleContext();
+ Bundle[] bundles = context.getBundles();
+ Bundle bundle;
+ int len = bundles.length;
+ List<YangNode> curNodes;
+ String jarPath;
+ for (int i = len - 1; i >= 0; i--) {
+ bundle = bundles[i];
+ if (bundle.getSymbolicName().contains(ONOS)) {
+ jarPath = getJarPathFromBundleLocation(
+ bundle.getLocation(), context.getProperty(USER_DIRECTORY));
+ curNodes = processJarParsingOperations(jarPath);
+ // process application registration.
+ if (curNodes != null && !curNodes.isEmpty()) {
+ jarPathStore.put(serviceClass.getName(), jarPath);
+ processRegistration(serviceClass, jarPath,
+ curNodes, appObject, false);
+ }
+ }
+ }
+ }
+ }
+ }
- BundleContext bundleContext = getBundle(serviceClass)
- .getBundleContext();
- String jarPath = getJarPathFromBundleLocation(
- bundleContext.getBundle().getLocation(),
- bundleContext.getProperty(USER_DIRECTORY));
- processRegistration(serviceClass, appObject, jarPath);
+ @Override
+ public void unRegisterApplication(Object managerObject,
+ Class<?> serviceClass) {
+ synchronized (serviceClass) {
+ YangSchemaNode curNode;
+ String serviceName = serviceClass.getName();
+
+ //Check if service should be unregistered?
+ if (managerObject != null) {
+ verifyApplicationRegistration(managerObject, serviceClass);
+ }
+ //Remove registered class from store.
+ registerClassStore.remove(serviceName);
+ //check if service is in app store.
+ curNode = appNameKeyStore.get(serviceName);
+ if (curNode == null) {
+ curNode = interfaceNameKeyStore.get(serviceName);
+ }
+
+ if (curNode != null) {
+ removeSchemaNode(curNode);
+ eventNameKeyStore.remove(getEventClassName(curNode));
+ appObjectStore.remove(serviceName);
+ interfaceNameKeyStore.remove(getInterfaceClassName(curNode));
+ opParamNameKeyStore.remove(getOpParamClassName(curNode));
+ yangFileStore.remove(getModuleIdentifier(curNode));
+ appNameKeyStore.remove(serviceName);
+ removeYsrGeneratedTemporaryResources(jarPathStore.get(serviceName),
+ serviceName);
+ log.info(" service {} is unregistered.",
+ serviceClass.getSimpleName());
+ } else {
+ throw new RuntimeException(serviceClass.getSimpleName() +
+ " service was not registered.");
+ }
+ }
+ }
+
+ @Override
+ public Object getRegisteredApplication(YangSchemaNode schemaNode) {
+ Object obj = null;
+ if (schemaNode != null) {
+ String name = getServiceName(schemaNode);
+ obj = appObjectStore.get(name);
+ if (obj == null) {
+ log.error("{} not found.", name);
+ }
+ }
+ return obj;
+ }
+
+ @Override
+ public YangSchemaNode getYangSchemaNodeUsingSchemaName(String schemaName) {
+ return getSchemaNodeUsingSchemaNameWithRev(schemaName);
+ }
+
+ @Override
+ public YangSchemaNode getYangSchemaNodeUsingAppName(String appName) {
+ YangSchemaNode node = appNameKeyStore.get(appName);
+ if (node == null) {
+ log.error("{} not found.", appName);
+ }
+ return node;
+ }
+
+ @Override
+ public YangSchemaNode
+ getYangSchemaNodeUsingGeneratedRootNodeInterfaceFileName(String name) {
+ YangSchemaNode node = interfaceNameKeyStore.get(name);
+ if (node == null) {
+ log.error("{} not found.", name);
+ }
+ return node;
+ }
+
+ @Override
+ public YangSchemaNode getYangSchemaNodeUsingGeneratedRootNodeOpPramFileName(
+ String name) {
+ YangSchemaNode node = opParamNameKeyStore.get(name);
+ if (node == null) {
+ log.error("{} not found.", name);
+ }
+ return node;
+ }
+
+ @Override
+ public YangSchemaNode getRootYangSchemaNodeForNotification(String name) {
+ YangSchemaNode node = eventNameKeyStore.get(name);
+ if (node == null) {
+ log.error("{} not found.", name);
+ }
+ return node;
+ }
+
+ @Override
+ public Class<?> getRegisteredClass(YangSchemaNode schemaNode) {
+ String interfaceName = getInterfaceClassName(schemaNode);
+ String serviceName = getServiceName(schemaNode);
+ Class<?> regClass = registerClassStore.get(serviceName);
+ if (regClass == null) {
+ regClass = registerClassStore.get(interfaceName);
+ }
+ return regClass;
+ }
+
+ @Override
+ public String getYangFile(YangModuleIdentifier moduleIdentifier) {
+ String file = yangFileStore.get(moduleIdentifier);
+ if (file == null) {
+ log.error("YANG files for corresponding module identifier {} not " +
+ "found", moduleIdentifier);
+ }
+ return file;
+ }
+
+ @Override
+ public boolean verifyNotificationObject(Object appObj, Class<?> service) {
+ synchronized (service) {
+ YangSchemaNode node = appNameKeyStore.get(service.getName());
+ if (node == null) {
+ log.error("application is not registered with YMS {}",
+ service.getName());
+ return false;
+ }
+ try {
+ if (node.isNotificationPresent()) {
+ if (appObj != null) {
+ Boolean ifPresent = ynhRegistrationStore.get(appObj);
+ if (ifPresent == null) {
+ ynhRegistrationStore.put(appObj, true);
+ return true;
+ }
+ }
+ }
+ } catch (DataModelException e) {
+ log.error("notification registration error: {} {}", e
+ .getLocalizedMessage(), e);
+ }
+ return false;
+ }
+ }
+
+ @Override
+ public void flushYsrData() {
+ appObjectStore.clear();
+ yangSchemaStore.clear();
+ eventNameKeyStore.clear();
+ opParamNameKeyStore.clear();
+ interfaceNameKeyStore.clear();
+ registerClassStore.clear();
+ yangFileStore.clear();
+ }
+
+ @Override
+ public void processModuleLibrary(String serviceName,
+ YangModuleLibrary library) {
+ synchronized (serviceName) {
+ YangSchemaNode node = appNameKeyStore.get(serviceName);
+ if (node != null) {
+ YangModuleInformation moduleInformation =
+ new DefaultYangModuleInformation(getModuleIdentifier(node),
+ node.getNameSpace());
+ addSubModuleIdentifier(node, (
+ DefaultYangModuleInformation) moduleInformation);
+ //TODO: add feature list to module information.
+ ((DefaultYangModuleLibrary) library)
+ .addModuleInformation(moduleInformation);
+ }
+ }
}
/**
- * Process application registration.
+ * Process service class.
*
* @param serviceClass service class
* @param appObject application object
- * @param jarPath jar path
*/
- void processRegistration(Class<?> serviceClass, Object appObject,
- String jarPath) {
- // set class loader for service class.
- setClassLoader(serviceClass.getClassLoader());
+ void doPreProcessing(Class<?> serviceClass, Object appObject) {
//Check if service should be registered?
if (appObject != null) {
verifyApplicationRegistration(appObject, serviceClass);
}
+ String name = serviceClass.getName();
//Add app class to registered service store.
- if (!registerClassStore.containsKey(serviceClass.getName())) {
- updateServiceClass(serviceClass);
+ if (!registerClassStore.containsKey(name)) {
+ registerClassStore.put(name, serviceClass);
}
+ }
+
+ void updateServiceClass(Class<?> service) {
+ registerClassStore.put(service.getName(), service);
+ }
+
+ /**
+ * Process application registration.
+ *
+ * @param service service class
+ * @param jarPath jar path
+ * @param nodes YANG nodes
+ * @param appObj application object
+ * @param isFromUt if registration is being called form unit test
+ */
+ void processRegistration(Class<?> service, String jarPath,
+ List<YangNode> nodes,
+ Object appObj, boolean isFromUt) {
// process storing operations.
- if (!verifyIfApplicationAlreadyRegistered(serviceClass)) {
- List<YangNode> curNodes =
- processJarParsingOperations(jarPath);
+ YangNode schemaNode = findNodeWhichShouldBeReg(service.getName(), nodes);
+ if (schemaNode != null) {
+ if (appObj != null) {
+ appObjectStore.put(service.getName(), appObj);
+ }
+ //Process application context for registrations.
+ processApplicationContext(schemaNode, service.getName(), isFromUt);
+ //Update YANG file store.
+ updateYangFileStore(schemaNode, jarPath);
+ }
+ }
- if (curNodes != null) {
- for (YangNode schemaNode : curNodes) {
- //Process application context for registrations.
- processApplicationContext(schemaNode);
- //Update YANG file store.
- updateYangFileStore(schemaNode, jarPath);
- //Process module library operation for current node list.
- processModuleLibrary(schemaNode);
- }
- //Set jar path for app context.
- ysrAppContext.jarPath(jarPath);
- ysrContextForSchemaStore.jarPath(jarPath);
- ysrContextForAppStore.jarPath(jarPath);
+ /**
+ * Returns the node for which corresponding class is generated.
+ *
+ * @param name generated class name
+ * @param nodes list of yang nodes
+ * @return node for which corresponding class is generated
+ */
+ private YangNode findNodeWhichShouldBeReg(String name, List<YangNode> nodes) {
+ for (YangNode node : nodes) {
+ if (name.equals(getServiceName(node)) ||
+ name.equals(getInterfaceClassName(node))) {
+ return node;
}
}
-
- //Verifies if object is updated for app store.
- updateApplicationObject(appObject, serviceClass);
+ return null;
}
/**
@@ -194,256 +425,9 @@
* @return true if application already registered
*/
private boolean verifyIfApplicationAlreadyRegistered(Class<?> appClass) {
- String simpleName = appClass.getSimpleName();
String appName = appClass.getName();
- if (!appObjectStore.containsKey(appName)) {
- if (simpleName.contains(OP_PARAM)) {
- return yangSchemaStoreForRootOpParam
- .containsKey(appName);
- } else {
- return yangSchemaStoreForRootInterface
- .containsKey(appName);
- }
- }
- return true;
- }
-
- /**
- * Verifies if service is being implemented by some new object.
- *
- * @param appObject application's object
- * @param appClass application's class
- */
- private void updateApplicationObject(Object appObject, Class<?> appClass) {
- YsrAppContext appContext =
- appObjectStore.get(appClass.getName());
- if (appContext != null) {
- YangSchemaNode schemaNode = appContext.curNode();
- String name = getInterfaceClassName(schemaNode);
- if (appContext.appObject() == null) {
- //update in application store.
- appContext.appObject(appObject);
- //Update app object for schema store for root interface.
- appContext = yangSchemaStoreForRootInterface.get(name);
- if (appContext != null) {
- appContext.appObject(appObject);
- }
- // Update app object for schema store for root op param
- appContext = yangSchemaStoreForRootOpParam.get(name + OP_PARAM);
- if (appContext != null) {
- appContext.appObject(appObject);
- }
- }
- }
- }
-
- @Override
- public void unRegisterApplication(Object managerObject,
- Class<?> serviceClass) {
- YangSchemaNode curNode = null;
- String serviceName = serviceClass.getName();
-
- //Check if service should be unregistered?
- if (managerObject != null) {
- verifyApplicationRegistration(managerObject, serviceClass);
- }
- //Remove registered class from store.
- registerClassStore.remove(serviceName);
-
- //check if service is in app store.
- if (appObjectStore.containsKey(serviceName)) {
- curNode = retrieveNodeForUnregister(serviceName, appObjectStore,
- managerObject);
- } else if (yangSchemaStoreForRootInterface.containsKey(serviceName)) {
- //check if service is in interface store.
- curNode = retrieveNodeForUnregister(serviceName,
- yangSchemaStoreForRootInterface,
- managerObject);
- } else if (yangSchemaStoreForRootOpParam.containsKey(serviceName)) {
- //check if service is in op param store.
- curNode = retrieveNodeForUnregister(serviceName,
- yangSchemaStoreForRootOpParam,
- managerObject);
- }
- if (curNode != null) {
- String javaName = getInterfaceClassName(curNode);
- removeFromYangSchemaStore(curNode);
- removeFromYangNotificationStore(curNode);
- removeFromAppSchemaStore(serviceName);
- removeFromYangSchemaNodeForRootInterface(javaName);
- removeFromYangSchemaNodeForRootOpParam(javaName);
- removeYangFileInfoFromStore(curNode);
- log.info(" service {} is unregistered.",
- serviceClass.getSimpleName());
- } else {
- throw new RuntimeException(serviceClass.getSimpleName() +
- " service was not registered.");
- }
- }
-
- @Override
- public Object getRegisteredApplication(YangSchemaNode schemaNode) {
- if (schemaNode != null) {
- String name = getInterfaceClassName(schemaNode);
- if (yangSchemaStoreForRootInterface.containsKey(name)) {
- return yangSchemaStoreForRootInterface.get(name)
- .appObject();
- }
- log.error("{} not found.", name);
- }
- return null;
- }
-
- @Override
- public YangSchemaNode getYangSchemaNodeUsingSchemaName(String schemaName) {
- return getSchemaNodeUsingSchemaNameWithRev(schemaName);
- }
-
- @Override
- public YangSchemaNode getYangSchemaNodeUsingAppName(String appName) {
- YsrAppContext appContext = appObjectStore.get(appName);
- if (appContext != null) {
- return appContext.curNode();
- }
- log.error("{} not found.", appName);
- return null;
- }
-
- @Override
- public YangSchemaNode
- getYangSchemaNodeUsingGeneratedRootNodeInterfaceFileName(String name) {
- YsrAppContext appContext = yangSchemaStoreForRootInterface.get(name);
- if (appContext != null) {
- return appContext.curNode();
- }
- log.error("{} not found.", name);
- return null;
- }
-
- @Override
- public YangSchemaNode getYangSchemaNodeUsingGeneratedRootNodeOpPramFileName(
- String name) {
- YsrAppContext appContext = yangSchemaStoreForRootOpParam.get(name);
- if (appContext != null) {
- return appContext.curNode();
- }
- log.error("{} not found.", name);
- return null;
- }
-
- @Override
- public YangSchemaNode getRootYangSchemaNodeForNotification(String name) {
- YsrAppContext appContext = yangRootSchemaStoreForNotification.get(name);
- if (appContext != null) {
- return appContext.curNode();
- }
- log.error("{} not found.", name);
- return null;
- }
-
- @Override
- public Class<?> getRegisteredClass(YangSchemaNode schemaNode,
- String appName) {
- String interfaceName = getInterfaceClassName(schemaNode);
- String serviceName = getServiceName(schemaNode);
- String defaultClass;
- if (schemaNode instanceof RpcNotificationContainer) {
- defaultClass = getOpParamClassName(schemaNode);
- } else {
- defaultClass = getDefaultClassName(schemaNode);
- }
- //If application class is registered.
- if (registerClassStore.containsKey(appName)) {
- return registerClassStore.get(appName);
- } else if (registerClassStore.containsKey(interfaceName)) {
- //If interface class is registered.
- return registerClassStore.get(interfaceName);
- } else if (registerClassStore.containsKey(serviceName)) {
- //If service class is registered.
- return registerClassStore.get(serviceName);
- } else if (registerClassStore.containsKey(defaultClass)) {
- //If default class is registered.
- return registerClassStore.get(defaultClass);
- }
- return null;
- }
-
- /**
- * Returns YANG file path for module identifier.
- *
- * @param moduleIdentifier module identifier
- * @return YANG file path for module identifier
- */
- public String getYangFile(YangModuleIdentifier moduleIdentifier) {
- if (yangFileStore.containsKey(moduleIdentifier)) {
- return yangFileStore.get(moduleIdentifier);
- }
- log.error("YANG files for corresponding module identifier {} not " +
- "found", moduleIdentifier);
- return null;
- }
-
- /**
- * Updates service class store.
- *
- * @param serviceClass service class
- */
- void updateServiceClass(Class<?> serviceClass) {
- registerClassStore.put(serviceClass.getName(), serviceClass);
- }
-
- /**
- * Updates application object store.
- *
- * @param appName application name
- */
- private void updateAppObjectStore(String appName) {
- if (verifyClassExistence(appName)) {
- appObjectStore.put(appName, ysrContextForAppStore);
- }
- }
-
- /**
- * Updates YANG schema object store.
- *
- * @param schemaNode application's schema node
- */
- private void updateYangSchemaStore(YangSchemaNode schemaNode) {
- addSchemaNodeUsingSchemaNameWithRev(schemaNode);
- }
-
- /**
- * Updates YANG schema notification object store.
- *
- * @param name application's notification name
- */
- private void updateYangNotificationStore(String name) {
- if (verifyClassExistence(name)) {
- yangRootSchemaStoreForNotification.put(name, ysrAppContext);
- }
- }
-
- /**
- * Updates YANG schema object store for root interface file name.
- *
- * @param name name of generated interface file for root
- * node
- */
- private void updateYangSchemaForRootInterfaceFileNameStore(String name) {
- if (verifyClassExistence(name)) {
- yangSchemaStoreForRootInterface.put(name, ysrAppContext);
- }
- }
-
- /**
- * Updates YANG schema object store for root op param file name.
- *
- * @param name name of generated op param file for root node
- */
- private void updateYangSchemaForRootOpParamFileNameStore(String name) {
- if (verifyClassExistence(name)) {
- yangSchemaStoreForRootOpParam.put(name, ysrAppContext);
- }
+ return appObjectStore.containsKey(appName) ||
+ interfaceNameKeyStore.containsKey(appName);
}
/**
@@ -453,9 +437,8 @@
* @param jarPath jar file path
*/
private void updateYangFileStore(YangNode node, String jarPath) {
- //FIXME: fix when yang tools support for file name.
- //yangFileStore.put(getModuleIdentifier(node),
- // getYangFilePath(jarPath, node.getFileName()));
+ yangFileStore.put(getModuleIdentifier(node),
+ getYangFilePath(jarPath, node.getFileName()));
}
/**
@@ -466,8 +449,8 @@
* @return yang file path
*/
private String getYangFilePath(String jarPath, String metaDataFileName) {
- String[] metaData = metaDataFileName.split(SLASH);
- return jarPath + SLASH + metaData[metaData.length - 1];
+ String[] metaData = metaDataFileName.split(SLASH);
+ return jarPath + SLASH + metaData[metaData.length - 1];
}
/**
@@ -478,8 +461,12 @@
*/
private List<YangNode> processJarParsingOperations(String path) {
//Deserialize data model and get the YANG node set.
+ String jar = path + JAR;
try {
- return parseJarFile(path + JAR, path);
+ File file = new File(jar);
+ if (file.exists()) {
+ return parseJarFile(path + JAR, path);
+ }
} catch (IOException e) {
log.error(" failed to parse the jar file in path {} : {} ", path,
e.getMessage());
@@ -490,30 +477,23 @@
/**
* Process an application an updates the maps for YANG schema registry.
*
- * @param appNode application YANG schema nodes
+ * @param appNode application YANG schema nodes
+ * @param name class name
+ * @param isFormUt if method is being called from unit tests
*/
- void processApplicationContext(YangSchemaNode appNode) {
+ private void processApplicationContext(YangSchemaNode appNode, String name,
+ boolean isFormUt) {
- String appName = getInterfaceClassName(appNode);
-
- //Create a new instance of ysr app context for each node.
- ysrAppContext = new YsrAppContext();
- ysrContextForSchemaStore = new YsrAppContext();
- ysrContextForAppStore = new YsrAppContext();
-
- //add cur node to app context.
- ysrAppContext.curNode(appNode);
- ysrContextForAppStore.curNode(appNode);
-
- //Updates maps wih schema nodes.
- updateAppObjectStore(getServiceName(appNode));
+ //Update map for which registrations is being called.
+ appNameKeyStore.put(name, appNode);
// Updates schema store.
- updateYangSchemaStore(appNode);
+ addToSchemaStore(appNode);
// update interface store.
- updateYangSchemaForRootInterfaceFileNameStore(appName);
+ interfaceNameKeyStore.put(getInterfaceClassName(appNode), appNode);
+
//update op param store.
- updateYangSchemaForRootOpParamFileNameStore(getOpParamClassName(appNode));
+ opParamNameKeyStore.put(getOpParamClassName(appNode), appNode);
//Checks if notification is present then update notification store map.
String eventSubject = null;
try {
@@ -525,10 +505,11 @@
e.getLocalizedMessage());
}
if (eventSubject != null) {
- updateYangNotificationStore(eventSubject);
+ eventNameKeyStore.put(eventSubject, appNode);
}
- log.info("successfully registered this application {}{}", appName,
- SERVICE);
+ if (!isFormUt) {
+ log.info("successfully registered this application {}", name);
+ }
}
/**
@@ -540,62 +521,18 @@
private String getJarPathFromBundleLocation(String mvnLocationPath,
String currentDirectory) {
String path = currentDirectory + SYSTEM;
- String[] strArray = mvnLocationPath.split(MAVEN);
- String[] split = strArray[1].split(File.separator);
- String[] groupId = split[0].split(Pattern.quote(DELIMITER));
-
- return path + groupId[0] + SLASH + groupId[1] + SLASH + split[1] +
- SLASH + split[2] + SLASH + split[1] + HYPHEN + split[2];
- }
-
- /**
- * Returns de-serializes YANG data-model nodes.
- *
- * @param serializedFileInfo serialized File Info
- * @return de-serializes YANG data-model nodes
- */
- Set<YangSchemaNode> deSerializeDataModel(String serializedFileInfo) {
-
- Set<YangSchemaNode> nodes = new HashSet<>();
- Object readValue;
- try {
- FileInputStream fileInputStream =
- new FileInputStream(serializedFileInfo);
- ObjectInputStream objectInputStream =
- new ObjectInputStream(fileInputStream);
- readValue = objectInputStream.readObject();
- if (readValue instanceof Set<?>) {
- for (Object obj : (Set<?>) readValue) {
- if (obj instanceof YangSchemaNode) {
- nodes.add((YangSchemaNode) obj);
- } else {
- throw new RuntimeException(
- "deserialize object is not an instance of " +
- "YANG schema node" + obj);
- }
+ if (mvnLocationPath.contains(MAVEN)) {
+ String[] strArray = mvnLocationPath.split(MAVEN);
+ if (strArray[1].contains(File.separator)) {
+ String[] split = strArray[1].split(File.separator);
+ if (split[0].contains(PERIOD)) {
+ String[] groupId = split[0].split(Pattern.quote(PERIOD));
+ return path + groupId[0] + SLASH + groupId[1] + SLASH + split[1] +
+ SLASH + split[2] + SLASH + split[1] + HYPHEN + split[2];
}
- } else {
- throw new RuntimeException(
- "deserialize object is not an instance of set of" +
- "YANG schema node" + readValue);
}
- objectInputStream.close();
- fileInputStream.close();
- } catch (IOException | ClassNotFoundException e) {
- log.error(" {} not found.: {}", serializedFileInfo,
- e.getLocalizedMessage());
}
-
- return nodes;
- }
-
- /**
- * Returns ysr app context.
- *
- * @return ysr app context
- */
- YsrAppContext ysrAppContext() {
- return ysrAppContext;
+ return null;
}
/**
@@ -605,61 +542,62 @@
* @return schema node based on the revision
*/
private YangSchemaNode getSchemaNodeUsingSchemaNameWithRev(String name) {
- YsrAppContext appContext;
+ ConcurrentMap<String, YangSchemaNode> revMap;
YangSchemaNode schemaNode;
if (name.contains(AT)) {
String[] revArray = name.split(AT);
- appContext = yangSchemaStore.get(revArray[0]);
- schemaNode = appContext.getSchemaNodeForRevisionStore(name);
- if (schemaNode != null) {
- return schemaNode;
+ revMap = yangSchemaStore.get(revArray[0]);
+ schemaNode = revMap.get(name);
+ if (schemaNode == null) {
+ log.error("{} not found.", name);
}
- return appContext.curNode();
+ return schemaNode;
}
if (yangSchemaStore.containsKey(name)) {
- appContext = yangSchemaStore.get(name);
- if (appContext != null) {
- Iterator<YangSchemaNode> iterator = appContext
- .getYangSchemaNodeForRevisionStore().values()
- .iterator();
- if (iterator.hasNext()) {
- return appContext.getYangSchemaNodeForRevisionStore()
- .values().iterator().next();
- } else {
- return null;
+ revMap = yangSchemaStore.get(name);
+ if (revMap != null && !revMap.isEmpty()) {
+ YangSchemaNode node = revMap.get(name);
+ if (node != null) {
+ return node;
}
+ String revName = getLatestVersion(revMap);
+ return revMap.get(revName);
}
}
log.error("{} not found.", name);
return null;
}
+ private String getLatestVersion(ConcurrentMap<String, YangSchemaNode> revMap) {
+ List<String> keys = new ArrayList<>();
+ for (Map.Entry<String, YangSchemaNode> entry : revMap.entrySet()) {
+ keys.add(entry.getKey());
+ }
+ sort(keys);
+ return keys.get(keys.size() - 1);
+ }
+
/**
* Adds schema node when different revision of node has received.
*
* @param schemaNode schema node
*/
- private void addSchemaNodeUsingSchemaNameWithRev(
- YangSchemaNode schemaNode) {
+ private void addToSchemaStore(YangSchemaNode schemaNode) {
String date = getDateInStringFormat(schemaNode);
String name = schemaNode.getName();
- if (!date.equals(EMPTY_STRING)) {
- name = name + AT + date;
+ String revName = name;
+ if (date != null) {
+ revName = name + AT + date;
}
//check if already present.
- if (!yangSchemaStore.containsKey(schemaNode.getName())) {
- ysrContextForSchemaStore.curNode(schemaNode);
- //if revision is not present no need to add in revision store.
- ysrContextForSchemaStore
- .addSchemaNodeWithRevisionStore(name, schemaNode);
- yangSchemaStore.put(schemaNode.getName(),
- ysrContextForSchemaStore);
+ if (!yangSchemaStore.containsKey(name)) {
+ ConcurrentMap<String, YangSchemaNode> revStore =
+ new ConcurrentHashMap<>();
+ revStore.put(revName, schemaNode);
+ yangSchemaStore.put(name, revStore);
} else {
- YsrAppContext appContext =
- yangSchemaStore.get(schemaNode.getName());
- appContext.addSchemaNodeWithRevisionStore(name, schemaNode);
- appContext.curNode(schemaNode);
+ yangSchemaStore.get(name).put(revName, schemaNode);
}
}
@@ -677,7 +615,7 @@
.getRevDate());
}
}
- return EMPTY_STRING;
+ return null;
}
/**
@@ -686,314 +624,21 @@
* @param removableNode schema node which needs to be removed
*/
private void removeSchemaNode(YangSchemaNode removableNode) {
-
String name = removableNode.getName();
+ String revName = name;
String date = getDateInStringFormat(removableNode);
-
- if (!date.isEmpty()) {
- name = removableNode.getName() + AT +
- getDateInStringFormat(removableNode);
+ if (date != null) {
+ revName = name + AT + date;
}
- YsrAppContext appContext = yangSchemaStore
- .get(removableNode.getName());
- if (appContext != null &&
- !appContext.getYangSchemaNodeForRevisionStore().isEmpty() &&
- appContext.getYangSchemaNodeForRevisionStore().size() != 1) {
- appContext.removeSchemaNodeForRevisionStore(name);
+ ConcurrentMap<String, YangSchemaNode> revMap = yangSchemaStore.get(name);
+ if (revMap != null && !revMap.isEmpty() && revMap.size() != 1) {
+ revMap.remove(revName);
} else {
yangSchemaStore.remove(removableNode.getName());
}
}
/**
- * Verifies if the manager object is already registered with notification
- * handler.
- *
- * @param serviceClass service class
- * @return true if the manager object is already registered with
- * notification handler
- */
- public boolean verifyNotificationObject(Class<?> serviceClass) {
- YangSchemaNode schemaNode = null;
- String serviceName = serviceClass.getName();
- if (appObjectStore.containsKey(serviceName)) {
- schemaNode = getYangSchemaNodeUsingAppName(serviceName);
- } else if (yangSchemaStoreForRootInterface.containsKey(serviceName)) {
- schemaNode =
- getYangSchemaNodeUsingGeneratedRootNodeInterfaceFileName(
- serviceName);
- } else if (yangSchemaStoreForRootOpParam.containsKey(serviceName)) {
- schemaNode = getYangSchemaNodeUsingGeneratedRootNodeOpPramFileName(
- serviceName);
- }
-
- if (schemaNode != null) {
- String name = getEventClassName(schemaNode);
-
- YsrAppContext appContext =
- yangRootSchemaStoreForNotification.get(name);
- if (appContext != null && !appContext.isNotificationRegistered()) {
- appContext.setNotificationRegistered(true);
- return true;
- }
- }
- return false;
- }
-
- /**
- * Returns schema node's generated interface class name.
- *
- * @param schemaNode schema node
- * @return schema node's generated interface class name
- */
- private String getInterfaceClassName(YangSchemaNode schemaNode) {
- return schemaNode.getJavaPackage() + PERIOD +
- getCapitalCase(schemaNode.getJavaClassNameOrBuiltInType());
- }
-
- /**
- * Returns schema node's generated op param class name.
- *
- * @param schemaNode schema node
- * @return schema node's generated op param class name
- */
- private String getOpParamClassName(YangSchemaNode schemaNode) {
- return getInterfaceClassName(schemaNode) + OP_PARAM;
- }
-
- /**
- * Returns schema node's generated op param class name.
- *
- * @param schemaNode schema node
- * @return schema node's generated op param class name
- */
- private String getDefaultClassName(YangSchemaNode schemaNode) {
- return schemaNode.getJavaPackage() + PERIOD + getCapitalCase(DEFAULT) +
- getCapitalCase(schemaNode.getJavaClassNameOrBuiltInType());
- }
-
- /**
- * Returns schema node's generated event class name.
- *
- * @param schemaNode schema node
- * @return schema node's generated event class name
- */
- private String getEventClassName(YangSchemaNode schemaNode) {
- return getInterfaceClassName(schemaNode).toLowerCase() + PERIOD +
- getCapitalCase(schemaNode.getJavaClassNameOrBuiltInType()) +
- EVENT_STRING;
- }
-
- /**
- * Returns schema node's generated service class name.
- *
- * @param schemaNode schema node
- * @return schema node's generated service class name
- */
- private String getServiceName(YangSchemaNode schemaNode) {
- return getInterfaceClassName(schemaNode) + SERVICE;
- }
-
- /**
- * Returns YSR application context for schema map.
- *
- * @return YSR application context for schema map
- */
- YsrAppContext ysrContextForSchemaStore() {
- return ysrContextForSchemaStore;
- }
-
- /**
- * Sets YSR application context for schema map.
- *
- * @param context YSR application context for
- * schema map
- */
- void ysrContextForSchemaStore(YsrAppContext context) {
- ysrContextForSchemaStore = context;
- }
-
- /**
- * Returns YSR app context for application store.
- *
- * @return YSR app context for application store
- */
- YsrAppContext ysrContextForAppStore() {
- return ysrContextForAppStore;
- }
-
- /**
- * Retrieves schema node from the store and deletes jar file path.
- *
- * @param appName application name
- * @param store YSR stores
- * @param appObject applications object
- * @return schema node from the store
- */
- private YangSchemaNode retrieveNodeForUnregister(
- String appName,
- ConcurrentMap<String, YsrAppContext> store, Object appObject) {
-
- YsrAppContext curContext = store.get(appName);
- boolean isValidObject;
- if (curContext != null) {
- isValidObject = verifyAppObject(appObject, curContext.appObject());
- if (isValidObject) {
- YangSchemaNode curNode = curContext.curNode();
- //Delete all the generated ysr information in application's
- // package.
- removeYsrGeneratedTemporaryResources(curContext.jarPath(),
- appName);
- return curNode;
- }
- }
- return null;
- }
-
- /**
- * Verifies the application object which needs to be unregistered.
- *
- * @param appObject current received application object
- * @param context stored application object
- * @return true if objects are equal
- */
- private boolean verifyAppObject(Object appObject, Object context) {
- if (appObject != null && context != null) {
- return appObject.equals(context);
- }
- return appObject == null && context == null;
- }
-
- /**
- * Removes YSR generated temporary resources.
- *
- * @param rscPath resource path
- * @param appName application name
- */
- private void removeYsrGeneratedTemporaryResources(String rscPath,
- String appName) {
- if (rscPath != null) {
- File jarPath = new File(rscPath);
- if (jarPath.exists()) {
- try {
- deleteDirectory(jarPath);
- } catch (IOException e) {
- log.error("failed to delete ysr resources for {} : {}",
- appName, e.getLocalizedMessage());
- }
- }
- }
- }
-
- /**
- * Removes from YANG schema store.
- *
- * @param curNode schema node
- */
- private void removeFromYangSchemaStore(YangSchemaNode curNode) {
- removeSchemaNode(curNode);
- }
-
- /**
- * Removes from YANG schema notification store.
- *
- * @param curNode schema node
- */
- private void removeFromYangNotificationStore(YangSchemaNode curNode) {
- yangRootSchemaStoreForNotification
- .remove(getEventClassName(curNode));
- }
-
- /**
- * Removes from app store.
- *
- * @param appName application name
- */
- private void removeFromAppSchemaStore(String appName) {
- appObjectStore.remove(appName);
- }
-
- /**
- * Removes from interface store.
- *
- * @param appName application name
- */
- private void removeFromYangSchemaNodeForRootInterface(String appName) {
- yangSchemaStoreForRootInterface.remove(appName);
- }
-
- /**
- * Removes from op param store.
- *
- * @param appName application name
- */
- private void removeFromYangSchemaNodeForRootOpParam(String appName) {
- yangSchemaStoreForRootOpParam.remove(appName + OP_PARAM);
- }
-
- /**
- * Removes YANG file information from file store.
- *
- * @param schemaNode schema node
- */
- private void removeYangFileInfoFromStore(YangSchemaNode schemaNode) {
- yangFileStore.remove(getModuleIdentifier(schemaNode));
- }
-
- /**
- * Verifies if class with given name exists.
- *
- * @param appName application name
- * @return true if class exists
- */
- boolean verifyClassExistence(String appName) {
- try {
- classLoader.loadClass(appName);
- return true;
- } catch (ClassNotFoundException e) {
- return false;
- }
- }
-
- /**
- * Clears database for YSR.
- */
- public void flushYsrData() {
- appObjectStore.clear();
- yangSchemaStore.clear();
- yangRootSchemaStoreForNotification.clear();
- yangSchemaStoreForRootOpParam.clear();
- yangSchemaStoreForRootInterface.clear();
- registerClassStore.clear();
- yangFileStore.clear();
- }
-
- /**
- * Sets class loader of registered class.
- *
- * @param classLoader class loader of registered class
- */
- void setClassLoader(ClassLoader classLoader) {
- this.classLoader = classLoader;
- }
-
- /**
- * Process module library for a registered service.
- *
- * @param node YANG schema nodes
- */
- private void processModuleLibrary(YangNode node) {
- YangModuleInformation moduleInformation =
- new DefaultYangModuleInformation(getModuleIdentifier(node),
- node.getNameSpace());
- addSubModuleIdentifier(node, (
- DefaultYangModuleInformation) moduleInformation);
- //TODO: add feature list to module information.
- ((DefaultYangModuleLibrary) library)
- .addModuleInformation(moduleInformation);
- }
-
- /**
* Adds sub module identifier.
*
* @param node schema node
@@ -1026,11 +671,66 @@
}
/**
- * Returns module library.
+ * Returns schema node's generated interface class name.
*
- * @return module library
+ * @param schemaNode schema node
+ * @return schema node's generated interface class name
*/
- public YangModuleLibrary getLibrary() {
- return library;
+ String getInterfaceClassName(YangSchemaNode schemaNode) {
+ return schemaNode.getJavaPackage() + PERIOD +
+ getCapitalCase(schemaNode.getJavaClassNameOrBuiltInType());
}
-}
+
+ /**
+ * Returns schema node's generated op param class name.
+ *
+ * @param schemaNode schema node
+ * @return schema node's generated op param class name
+ */
+ private String getOpParamClassName(YangSchemaNode schemaNode) {
+ return getInterfaceClassName(schemaNode) + OP_PARAM;
+ }
+
+ /**
+ * Returns schema node's generated event class name.
+ *
+ * @param schemaNode schema node
+ * @return schema node's generated event class name
+ */
+ private String getEventClassName(YangSchemaNode schemaNode) {
+ return getInterfaceClassName(schemaNode).toLowerCase() + PERIOD +
+ getCapitalCase(schemaNode.getJavaClassNameOrBuiltInType()) +
+ EVENT_STRING;
+ }
+
+ /**
+ * Returns schema node's generated service class name.
+ *
+ * @param schemaNode schema node
+ * @return schema node's generated service class name
+ */
+ String getServiceName(YangSchemaNode schemaNode) {
+ return getInterfaceClassName(schemaNode) + SERVICE;
+ }
+
+ /**
+ * Removes YSR generated temporary resources.
+ *
+ * @param rscPath resource path
+ * @param appName application name
+ */
+ private void removeYsrGeneratedTemporaryResources(String rscPath,
+ String appName) {
+ if (rscPath != null) {
+ File jarPath = new File(rscPath);
+ if (jarPath.exists()) {
+ try {
+ deleteDirectory(jarPath);
+ } catch (IOException e) {
+ log.error("failed to delete ysr resources for {} : {}",
+ appName, e.getLocalizedMessage());
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/apps/yms/app/src/main/java/org/onosproject/yms/app/ysr/YangSchemaRegistry.java b/apps/yms/app/src/main/java/org/onosproject/yms/app/ysr/YangSchemaRegistry.java
index 8098188..ed5d95a 100644
--- a/apps/yms/app/src/main/java/org/onosproject/yms/app/ysr/YangSchemaRegistry.java
+++ b/apps/yms/app/src/main/java/org/onosproject/yms/app/ysr/YangSchemaRegistry.java
@@ -17,6 +17,8 @@
package org.onosproject.yms.app.ysr;
import org.onosproject.yangutils.datamodel.YangSchemaNode;
+import org.onosproject.yms.ysr.YangModuleIdentifier;
+import org.onosproject.yms.ysr.YangModuleLibrary;
/**
* Abstraction of entity which provides interfaces to YANG schema registry.
@@ -27,7 +29,8 @@
* Registers applications to YMS.
*
* @param managerObject application's object
- * @param serviceClass service class to be registered
+ * @param serviceClass service class which needs to be
+ * registered
*/
void registerApplication(Object managerObject, Class<?> serviceClass);
@@ -96,9 +99,46 @@
* Returns registered service class.
*
* @param schemaNode YANG schema node
- * @param appName application's name
* @return registered service class
*/
- Class<?> getRegisteredClass(YangSchemaNode schemaNode, String appName);
+ Class<?> getRegisteredClass(YangSchemaNode schemaNode);
+
+ /**
+ * Verifies if the manager object is already registered with notification
+ * handler.
+ *
+ * @param appObj application object
+ * @param service service class
+ * @return true if the manager object is already registered with
+ * notification handler
+ */
+ boolean verifyNotificationObject(Object appObj, Class<?> service);
+
+ /**
+ * Clears database for YSR.
+ */
+ void flushYsrData();
+
+ /**
+ * Protocols like RESTCONF, use the definitions within the YANG modules
+ * advertised by the server are used to construct an RPC operation or
+ * data resource identifier.
+ * <p>
+ * Schema Resource:
+ * The server can optionally support retrieval of the YANG modules it
+ * supports.
+ *
+ * @param moduleIdentifier module's identifier
+ * @return YANG file contents of the requested YANG module.
+ */
+ String getYangFile(YangModuleIdentifier moduleIdentifier);
+
+ /**
+ * Process module library for a registered service.
+ *
+ * @param serviceName service class name
+ * @param library YANG module library
+ */
+ void processModuleLibrary(String serviceName, YangModuleLibrary library);
}
diff --git a/apps/yms/app/src/main/java/org/onosproject/yms/app/ysr/YsrAppContext.java b/apps/yms/app/src/main/java/org/onosproject/yms/app/ysr/YsrAppContext.java
deleted file mode 100644
index 4f076ab..0000000
--- a/apps/yms/app/src/main/java/org/onosproject/yms/app/ysr/YsrAppContext.java
+++ /dev/null
@@ -1,192 +0,0 @@
-/*
- * 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.ysr;
-
-import com.google.common.collect.ImmutableMap;
-import org.onosproject.yangutils.datamodel.YangSchemaNode;
-
-import java.util.Map;
-import java.util.Objects;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ConcurrentMap;
-
-/**
- * Represents registered application's context for YANG schema registry.
- */
-public class YsrAppContext {
-
- /**
- * Current application's YANG schema node.
- */
- private YangSchemaNode curNode;
-
- /**
- * Current application's YANG schema node with different revision store.
- */
- private final ConcurrentMap<String, YangSchemaNode>
- multiRevisionSchemaNodeStore;
-
- /**
- * Current application's object.
- */
- private Object appObject;
-
- /**
- * Jar file path.
- */
- private String jarPath;
-
- /**
- * If for current object notification is registered.
- */
- private boolean isNotificationRegistered;
-
- /**
- * Creates an instance of YANG schema registry application context.
- */
- YsrAppContext() {
- multiRevisionSchemaNodeStore = new ConcurrentHashMap<>();
- }
-
- /**
- * Returns current application's object.
- *
- * @return current application's object
- */
- Object appObject() {
- return appObject;
- }
-
- /**
- * Sets current application's object.
- *
- * @param appObject current application's object
- */
- void appObject(Object appObject) {
- this.appObject = appObject;
- }
-
- /**
- * Returns current application's YANG schema node.
- *
- * @return current application's YANG schema node
- */
- YangSchemaNode curNode() {
- return curNode;
- }
-
- /**
- * Sets current application's schema node.
- *
- * @param node current schema's node
- */
- void curNode(YangSchemaNode node) {
- curNode = node;
- }
-
- /**
- * Returns jar file path.
- *
- * @return jar file path
- */
- String jarPath() {
- return jarPath;
- }
-
- /**
- * Sets jar file path.
- *
- * @param jarPath jar file path
- */
- void jarPath(String jarPath) {
- this.jarPath = jarPath;
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(curNode, appObject);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj instanceof YsrAppContext) {
- YsrAppContext that = (YsrAppContext) obj;
- return Objects.equals(curNode, that.curNode) &&
- Objects.equals(appObject, that.appObject);
- }
- return false;
- }
-
- /**
- * Returns true if for application object notification is registered.
- *
- * @return true if for application object notification is registered
- */
- boolean isNotificationRegistered() {
- return isNotificationRegistered;
- }
-
- /**
- * Sets true if for application object notification is registered.
- *
- * @param notificationRegistered true if for application object notification is registered
- */
- void setNotificationRegistered(boolean notificationRegistered) {
- isNotificationRegistered = notificationRegistered;
- }
-
- /**
- * Returns YANG schema node store for specific revision.
- *
- * @return YANG schema node store for specific revision
- */
- Map<String, YangSchemaNode> getYangSchemaNodeForRevisionStore() {
- return ImmutableMap.copyOf(multiRevisionSchemaNodeStore);
- }
-
- /**
- * Returns a schema node for specific revision from store.
- *
- * @param nodeNameWithRevision schema node name for specific revision
- * @return schema node for specific revision.
- */
- YangSchemaNode getSchemaNodeForRevisionStore(String nodeNameWithRevision) {
- return multiRevisionSchemaNodeStore.get(nodeNameWithRevision);
- }
-
- /**
- * Removes a schema node of specific revision from store.
- *
- * @param nodeNameWithRevision schema node name for specific revision
- */
- void removeSchemaNodeForRevisionStore(String nodeNameWithRevision) {
- multiRevisionSchemaNodeStore.remove(nodeNameWithRevision);
- }
-
- /**
- * Adds schema node with revision from store.
- *
- * @param nodeNameWithRevision schema node name for specific revision
- * @param schemaNode schema node for specific revision
- */
- void addSchemaNodeWithRevisionStore(String nodeNameWithRevision, YangSchemaNode schemaNode) {
- multiRevisionSchemaNodeStore.put(nodeNameWithRevision, schemaNode);
- }
-}
diff --git a/apps/yms/app/src/main/java/org/onosproject/yms/app/ytb/YtbUtil.java b/apps/yms/app/src/main/java/org/onosproject/yms/app/ytb/YtbUtil.java
index 8329c9f..b81743b 100644
--- a/apps/yms/app/src/main/java/org/onosproject/yms/app/ytb/YtbUtil.java
+++ b/apps/yms/app/src/main/java/org/onosproject/yms/app/ytb/YtbUtil.java
@@ -229,8 +229,8 @@
YangNode moduleNode = curNode.getParent();
String moduleName = moduleNode.getJavaClassNameOrBuiltInType();
String modulePackage = moduleNode.getJavaPackage();
- return registry.getRegisteredClass(moduleNode,
- modulePackage + PERIOD + moduleName);
+ return registry.getRegisteredClass(moduleNode
+ );
}
/**
diff --git a/apps/yms/app/src/test/java/org/onosproject/yms/app/util/YdtNodeAdapter.java b/apps/yms/app/src/test/java/org/onosproject/yms/app/util/YdtNodeAdapter.java
deleted file mode 100644
index 639c60d..0000000
--- a/apps/yms/app/src/test/java/org/onosproject/yms/app/util/YdtNodeAdapter.java
+++ /dev/null
@@ -1,326 +0,0 @@
-/*
- * 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.util;
-
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-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 org.onosproject.yms.ydt.YdtExtendedInfoType;
-import org.onosproject.yms.ydt.YdtType;
-import org.onosproject.yms.app.ydt.YdtNode;
-import org.onosproject.yms.app.ydt.YdtExtendedContext;
-import org.onosproject.yms.app.ydt.AppType;
-
-/**
- * Represents implementation of interfaces to build and obtain YANG data tree.
- */
-public class YdtNodeAdapter<T> implements YdtExtendedContext {
-
- /**
- * Parent reference.
- */
- private YdtNodeAdapter parent;
-
- /**
- * First child reference.
- */
- private YdtNodeAdapter child;
-
- /**
- * Next sibling reference.
- */
- private YdtNodeAdapter nextSibling;
-
- /**
- * Previous sibling reference.
- */
- private YdtNodeAdapter previousSibling;
-
- /**
- * Last child reference.
- */
- private YdtNode lastChild;
-
- /**
- * Type of node.
- */
- private YdtType ydtType;
-
- /**
- * Flag to keep the track of context switch.
- */
- private boolean isContextSwitch;
-
- private T ydtExtendedInfo;
-
- /**
- * YDT extended information type.
- */
- YdtExtendedInfoType ydtExtendedInfoType;
-
- /**
- * Ydt map to keep the track of node added in YDT.
- */
- private 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.
- */
- protected YangSchemaNodeIdentifier nodeIdentifier;
-
- /**
- * Ydt map to keep the track of application information object with respective type.
- */
- Map<AppType, Object> ydtAppInfoMap = new HashMap<>();
-
-
- /**
- * Creation of YANG node object.
- */
- public YdtNodeAdapter() {
- }
-
- /**
- * Creates a specific type of node.
- *
- * @param type of YDT node
- * @param name name of the YDT node
- */
- public YdtNodeAdapter(YdtType type, String name) {
- setYdtType(type);
- }
-
- @Override
- public String getName() {
- return this.nodeIdentifier.getName();
- }
-
- @Override
- public String getNamespace() {
- return this.nodeIdentifier.getNameSpace();
- }
-
- @Override
- public <T> T getYdtContextExtendedInfo() {
- return (T) ydtExtendedInfo;
- }
-
- @Override
- public YdtExtendedInfoType getYdtExtendedInfoType() {
- return ydtExtendedInfoType;
- }
-
- @Override
- public YdtType getYdtType() {
- return ydtType;
- }
-
- /**
- * Sets the node type.
- *
- * @param ydtType type of YDT attribute
- */
- public void setYdtType(YdtType ydtType) {
- this.ydtType = ydtType;
- }
-
- @Override
- public YdtNodeAdapter getParent() {
- return parent;
- }
-
- /**
- * Sets the parent of node.
- *
- * @param parent node
- */
- public void setParent(YdtNodeAdapter parent) {
- this.parent = parent;
- }
-
- @Override
- public YdtNodeAdapter getFirstChild() {
- return child;
- }
-
- @Override
- public YdtNodeAdapter getNextSibling() {
- return nextSibling;
- }
-
- /**
- * Sets the next sibling of node.
- *
- * @param sibling YANG node
- */
- public void setNextSibling(YdtNodeAdapter sibling) {
- nextSibling = sibling;
- }
-
- @Override
- public YdtNodeAdapter getPreviousSibling() {
- return previousSibling;
- }
-
- /**
- * Sets the previous sibling.
- *
- * @param previousSibling points to predecessor sibling
- */
- public void setPreviousSibling(YdtNodeAdapter previousSibling) {
- this.previousSibling = previousSibling;
- }
-
- /**
- * Returns data-model node reference for of a given node.
- *
- * @return yang schema data node of a data-model.
- */
- public YangSchemaNode getYangSchemaNode() {
- return yangSchemaNode;
- }
-
- /**
- * Sets the data-model node reference for of a given node..
- *
- * @param yangSchemaNode YANG data node.
- */
- public void setYangSchemaNode(YangSchemaNode yangSchemaNode) {
- this.yangSchemaNode = yangSchemaNode;
- }
-
- @Override
- public YdtNode getLastChild() {
- return lastChild;
- }
-
- /**
- * Sets the last instance of a child node.
- *
- * @param child is last child to be set
- */
- public void setLastChild(YdtNode child) {
- this.lastChild = child;
- }
-
- public void setNodeIdentifier(YangSchemaNodeIdentifier nodeIdentifier) {
- this.nodeIdentifier = nodeIdentifier;
- }
-
- /**
- * Adds a child node.
- *
- * @param newChild refers to a child to be added
- */
- public void addChild(YdtContext newChild) {
-
- ((YdtNodeAdapter) newChild).setParent(this);
-
- if (this.child == null) {
- this.child = (YdtNodeAdapter) newChild;
- return;
- }
-
- YdtNodeAdapter currNode = this.child;
- while (currNode.getNextSibling() != null) {
- currNode = currNode.getNextSibling();
- }
- currNode.setNextSibling((YdtNodeAdapter) newChild);
- ((YdtNodeAdapter) newChild).setPreviousSibling(currNode);
- }
-
- /**
- * Adds a sibling to YANG data tree.
- *
- * @param newSibling context of sibling to be added
- */
- public void addSibling(YdtContext newSibling) {
-
- ((YdtNodeAdapter) newSibling).setParent(this.getParent());
-
- YdtNodeAdapter currNode = this;
-
- while (currNode.getNextSibling() != null) {
- currNode = currNode.getNextSibling();
- }
- currNode.setNextSibling((YdtNodeAdapter) newSibling);
- ((YdtNodeAdapter) newSibling).setPreviousSibling(currNode);
- }
-
- /**
- * Gets the flag for node if context switch.
- *
- * @return isContextSwitch flag of a node.
- */
- public boolean getContextSwitch() {
- return isContextSwitch;
- }
-
- /**
- * Sets the flag to keep the track of context switch.
- *
- * @param contextSwitch boolean flag.
- */
- public void setContextSwitch(boolean contextSwitch) {
- isContextSwitch = contextSwitch;
- }
-
- @Override
- public String getValue() {
- return null;
- }
-
- @Override
- public Set<String> getValueSet() {
- return null;
- }
-
- @Override
- public YangSchemaNodeContextInfo getSchemaNodeContextInfo(YangSchemaNodeIdentifier nodeIdentifier) {
- return null;
- }
-
- @Override
- public Object getAppInfo(AppType appType) {
- return null;
- }
-
- @Override
- public YdtContextOperationType getYdtContextOperationType() {
- return ydtContextOperationType;
- }
-
- @Override
- public void addAppInfo(AppType appType, Object o) {
- }
-}
diff --git a/apps/yms/app/src/test/java/org/onosproject/yms/app/yab/MockYmsManager.java b/apps/yms/app/src/test/java/org/onosproject/yms/app/yab/MockYmsManager.java
deleted file mode 100644
index 22f4fd9..0000000
--- a/apps/yms/app/src/test/java/org/onosproject/yms/app/yab/MockYmsManager.java
+++ /dev/null
@@ -1,124 +0,0 @@
-/*
- * 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.yab;
-
-import org.onosproject.yms.app.ydt.YangRequestWorkBench;
-import org.onosproject.yms.app.ysr.TestYangSchemaNodeProvider;
-import org.onosproject.yms.app.ysr.YangSchemaRegistry;
-import org.onosproject.yms.ych.YangCodecHandler;
-import org.onosproject.yms.ych.YangDataTreeCodec;
-import org.onosproject.yms.ych.YangProtocolEncodingFormat;
-import org.onosproject.yms.ydt.YdtBuilder;
-import org.onosproject.yms.ydt.YdtResponse;
-import org.onosproject.yms.ydt.YdtWalker;
-import org.onosproject.yms.ydt.YmsOperationType;
-import org.onosproject.yms.ymsm.YmsService;
-import org.onosproject.yms.ynh.YangNotificationService;
-import org.onosproject.yms.ysr.YangModuleIdentifier;
-import org.onosproject.yms.ysr.YangModuleLibrary;
-
-import java.util.List;
-
-/**
- * Represents implementation of YANG application management system manager.
- */
-public class MockYmsManager
- implements YmsService {
-
- YangSchemaRegistry schemaRegistry;
- TestYangSchemaNodeProvider testYangSchemaNodeProvider =
- new TestYangSchemaNodeProvider();
-
- @Override
- public YdtBuilder getYdtBuilder(String logicalRootName,
- String rootNamespace,
- YmsOperationType operationType) {
- testYangSchemaNodeProvider.processSchemaRegistry(new TestManager());
- schemaRegistry = testYangSchemaNodeProvider.getDefaultYangSchemaRegistry();
- return new YangRequestWorkBench(logicalRootName, rootNamespace,
- operationType, schemaRegistry, false);
- }
-
- @Override
- public YdtBuilder getYdtBuilder(String logicalRootName,
- String rootNamespace,
- YmsOperationType operationType,
- Object schemaRegistryForYdt) {
- return null;
- }
-
- @Override
- public YdtWalker getYdtWalker() {
- return null;
- }
-
- @Override
- public YdtResponse executeOperation(YdtBuilder operationRequest) {
- YangApplicationBroker requestBroker =
- new YangApplicationBroker(schemaRegistry);
- switch (operationRequest.getYmsOperationType()) {
- case EDIT_CONFIG_REQUEST:
- try {
- return requestBroker.processEdit(operationRequest);
- } catch (CloneNotSupportedException e) {
- }
- break;
- case QUERY_CONFIG_REQUEST:
- case QUERY_REQUEST:
- return requestBroker.processQuery(operationRequest);
- case RPC_REQUEST:
- return requestBroker.processOperation(operationRequest);
- default:
- }
- return null;
- }
-
- @Override
- public YangNotificationService getYangNotificationService() {
- return null;
- }
-
- @Override
- public void registerService(Object appManager, Class<?> yangService,
- List<String> supportedFeatureList) {
- }
-
- @Override
- public void unRegisterService(Object appManager, Class<?> yangService) {
-
- }
-
- @Override
- public YangModuleLibrary getYangModuleLibrary() {
- return null;
- }
-
- @Override
- public String getYangFile(YangModuleIdentifier moduleIdentifier) {
- return null;
- }
-
- @Override
- public void registerDefaultCodec(YangDataTreeCodec defaultCodec,
- YangProtocolEncodingFormat dataFormat) {
- }
-
- @Override
- public YangCodecHandler getYangCodecHandler() {
- return null;
- }
-}
diff --git a/apps/yms/app/src/test/java/org/onosproject/yms/app/yab/TestManager.java b/apps/yms/app/src/test/java/org/onosproject/yms/app/yab/TestManager.java
deleted file mode 100644
index c07a18f..0000000
--- a/apps/yms/app/src/test/java/org/onosproject/yms/app/yab/TestManager.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * 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.yab;
-
-import org.onosproject.yang.gen.v1.ydt.test.rev20160524.Test;
-import org.onosproject.yang.gen.v1.ydt.test.rev20160524.TestOpParam;
-import org.onosproject.yang.gen.v1.ydt.test.rev20160524.TestService;
-import org.onosproject.yang.gen.v1.ydt.test.rev20160524.test.Cont1;
-import org.onosproject.yang.gen.v1.ydt.test.rev20160524.test.DefaultCont1;
-import org.onosproject.yang.gen.v1.ydt.test.rev20160524.test.rockthehouse.DefaultRockTheHouseOutput;
-import org.onosproject.yang.gen.v1.ydt.test.rev20160524.test.rockthehouse.RockTheHouseInput;
-import org.onosproject.yang.gen.v1.ydt.test.rev20160524.test.rockthehouse.RockTheHouseOutput;
-import org.onosproject.yang.gen.v1.ydt.test.rev20160524.test.rockthehouse1.RockTheHouse1Input;
-import org.onosproject.yang.gen.v1.ydt.test.rev20160524.test.rockthehouse2.DefaultRockTheHouse2Output;
-import org.onosproject.yang.gen.v1.ydt.test.rev20160524.test.rockthehouse2.RockTheHouse2Output;
-
-/**
- * Implementation of the application management service.
- */
-public class TestManager implements TestService {
-
- Test response;
-
- @Override
- public Test getTest(TestOpParam test) {
- Cont1 cont = new DefaultCont1.Cont1Builder().leaf4("4").build();
- Test response = new TestOpParam.TestBuilder().cont1(cont).build();
- return response;
- }
-
- @Override
- public void setTest(TestOpParam test) {
- response = test;
- }
-
- @Override
- public Test getAugmentedTestCont4(TestOpParam test) {
- Cont1 cont = new DefaultCont1.Cont1Builder().leaf4("4").build();
- Test response = new TestOpParam.TestBuilder().cont1(cont).build();
- return response;
- }
-
- @Override
- public void setAugmentedTestCont4(TestOpParam augmentedTestCont4) {
- response = augmentedTestCont4;
- }
-
- @Override
- public RockTheHouseOutput rockTheHouse(RockTheHouseInput inputVar) {
- return DefaultRockTheHouseOutput.builder().hello("hello").build();
- }
-
-
- @Override
- public void rockTheHouse1(RockTheHouse1Input inputVar) {
- // TODO : to be implemented
- }
-
- @Override
- public RockTheHouse2Output rockTheHouse2() {
- return DefaultRockTheHouse2Output
- .builder().leaf14("14").build();
- }
-
- @Override
- public void rockTheHouse3() {
- }
-}
diff --git a/apps/yms/app/src/test/java/org/onosproject/yms/app/yab/YangApplicationBrokerTest.java b/apps/yms/app/src/test/java/org/onosproject/yms/app/yab/YangApplicationBrokerTest.java
deleted file mode 100644
index 0d77306..0000000
--- a/apps/yms/app/src/test/java/org/onosproject/yms/app/yab/YangApplicationBrokerTest.java
+++ /dev/null
@@ -1,1088 +0,0 @@
-/*
- * 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.yab;
-
-import org.junit.Test;
-import org.onosproject.yangutils.datamodel.YangAugment;
-import org.onosproject.yangutils.datamodel.YangNode;
-import org.onosproject.yms.app.ydt.YangRequestWorkBench;
-import org.onosproject.yms.app.ydt.YdtAppContext;
-import org.onosproject.yms.app.ydt.YdtAppNodeOperationType;
-import org.onosproject.yms.app.ydt.YdtNode;
-import org.onosproject.yms.ydt.YdtContext;
-
-import java.io.IOException;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-import static org.hamcrest.CoreMatchers.notNullValue;
-import static org.hamcrest.CoreMatchers.nullValue;
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.core.Is.is;
-import static org.onosproject.yms.ydt.YdtContextOperationType.DELETE;
-import static org.onosproject.yms.ydt.YdtContextOperationType.MERGE;
-import static org.onosproject.yms.ydt.YmsOperationType.EDIT_CONFIG_REQUEST;
-import static org.onosproject.yms.ydt.YmsOperationType.QUERY_CONFIG_REQUEST;
-import static org.onosproject.yms.ydt.YmsOperationType.RPC_REQUEST;
-
-/**
- * Unit test case for YANG application broker.
- */
-public class YangApplicationBrokerTest {
-
- MockYmsManager ymsManager = new MockYmsManager();
-
- /**
- * Returns YANG data tree to check edit operation of container.
- *
- * @return YANG data tree
- */
- private YangRequestWorkBench buildYdtForEditOperationWithoutDelete() {
- String rootName = "root";
- YangRequestWorkBench defaultYdtBuilder =
- (YangRequestWorkBench) ymsManager.getYdtBuilder(rootName, null,
- EDIT_CONFIG_REQUEST);
- defaultYdtBuilder.addChild("test", "ydt.test", MERGE);
- defaultYdtBuilder.addChild("cont1", null, MERGE);
- defaultYdtBuilder.addChild("cont2", null, MERGE);
- defaultYdtBuilder.addChild("cont3", null, MERGE);
- defaultYdtBuilder.addLeaf("leaf1", null, "1");
- defaultYdtBuilder.traverseToParent();
- defaultYdtBuilder.traverseToParent();
- defaultYdtBuilder.traverseToParent();
- defaultYdtBuilder.addLeaf("leaf4", null, "4");
- defaultYdtBuilder.traverseToParent();
- defaultYdtBuilder.traverseToParent();
- defaultYdtBuilder.addChild("cont4", null, MERGE);
- defaultYdtBuilder.addChild("cont5", null, MERGE);
- defaultYdtBuilder.addLeaf("leaf9", null, "9");
- defaultYdtBuilder.traverseToParent();
- defaultYdtBuilder.traverseToParent();
- defaultYdtBuilder.traverseToParent();
- defaultYdtBuilder.addLeaf("leaf10", null, "10");
- return defaultYdtBuilder;
- }
-
- private YangRequestWorkBench buildYdtForKeyLeavesInDeleteTree() {
- String rootName = "root";
- YangRequestWorkBench defaultYdtBuilder =
- (YangRequestWorkBench) ymsManager.getYdtBuilder(rootName, null,
- EDIT_CONFIG_REQUEST);
- defaultYdtBuilder.addChild("test", "ydt.test", MERGE);
- defaultYdtBuilder.addChild("list2", null, MERGE);
- defaultYdtBuilder.addLeaf("leaf5", null, "5");
- defaultYdtBuilder.traverseToParent();
- defaultYdtBuilder.addLeaf("leaf6", null, "6");
- defaultYdtBuilder.traverseToParent();
- defaultYdtBuilder.addLeaf("leaf7", null, "7");
- defaultYdtBuilder.traverseToParent();
- defaultYdtBuilder.addChild("cont7", null, DELETE);
- defaultYdtBuilder.traverseToParent();
- defaultYdtBuilder.traverseToParent();
- return defaultYdtBuilder;
- }
-
- /**
- * Returns YANG data tree to check delete operation of container.
- *
- * @return YANG data tree
- */
- private YangRequestWorkBench buildYdtForEditOperationWithDelete() {
- String rootName = "rootNode";
- YangRequestWorkBench defaultYdtBuilder =
- (YangRequestWorkBench) ymsManager.getYdtBuilder(rootName, null,
- EDIT_CONFIG_REQUEST);
- defaultYdtBuilder.addChild("test", "ydt.test", MERGE);
- defaultYdtBuilder.addChild("cont1", null, MERGE);
- defaultYdtBuilder.addChild("cont2", null, DELETE);
- defaultYdtBuilder.addChild("cont3", null, DELETE);
- defaultYdtBuilder.addLeaf("leaf1", null, "1");
- defaultYdtBuilder.traverseToParent();
- defaultYdtBuilder.traverseToParent();
- defaultYdtBuilder.traverseToParent();
- defaultYdtBuilder.addLeaf("leaf4", null, "4");
- defaultYdtBuilder.traverseToParent();
- defaultYdtBuilder.traverseToParent();
- defaultYdtBuilder.addChild("cont4", null, DELETE);
- defaultYdtBuilder.addChild("cont5", null, DELETE);
- defaultYdtBuilder.addLeaf("leaf9", null, "9");
- defaultYdtBuilder.traverseToParent();
- defaultYdtBuilder.traverseToParent();
- defaultYdtBuilder.traverseToParent();
- defaultYdtBuilder.addLeaf("leaf10", null, "10");
- return defaultYdtBuilder;
- }
-
- /**
- * Returns YANG data tree to check edit operation of list.
- *
- * @return YANG data tree
- */
- private YangRequestWorkBench buildYdtForListEditOperationWithoutDelete() {
- String rootName = "listWithoutDelete";
- Set<String> valueSet = new HashSet<>();
- valueSet.add("10");
- YangRequestWorkBench defaultYdtBuilder =
- (YangRequestWorkBench) ymsManager.getYdtBuilder(rootName, null,
- EDIT_CONFIG_REQUEST);
- defaultYdtBuilder.addChild("test", "ydt.test", MERGE);
- defaultYdtBuilder.addChild("cont1", null, MERGE);
- defaultYdtBuilder.addChild("list1", null, MERGE);
- defaultYdtBuilder.addLeaf("leaf2", null, "2");
- defaultYdtBuilder.traverseToParent();
- defaultYdtBuilder.addLeaf("leaf3", null, "3");
- defaultYdtBuilder.traverseToParent();
- defaultYdtBuilder.traverseToParent();
- defaultYdtBuilder.addLeaf("leaf4", null, "4");
- defaultYdtBuilder.traverseToParent();
- defaultYdtBuilder.traverseToParent();
- defaultYdtBuilder.addChild("list2", null, MERGE);
- defaultYdtBuilder.addLeaf("leaf5", null, "5");
- defaultYdtBuilder.traverseToParent();
- defaultYdtBuilder.addLeaf("leaf6", null, "6");
- defaultYdtBuilder.traverseToParent();
- defaultYdtBuilder.addLeaf("leaf7", null, "7");
- defaultYdtBuilder.traverseToParent();
- defaultYdtBuilder.addLeaf("leaflist8", null, valueSet);
- defaultYdtBuilder.traverseToParent();
- defaultYdtBuilder.traverseToParent();
- defaultYdtBuilder.addLeaf("leaf10", null, "10");
- return defaultYdtBuilder;
- }
-
- /**
- * Returns YANG data tree to check delete operation of list.
- *
- * @return YANG data tree
- */
- private YangRequestWorkBench buildYdtForListEditOperationWithDelete() {
- String rootName = "listWithDelete";
- YangRequestWorkBench defaultYdtBuilder =
- (YangRequestWorkBench) ymsManager.getYdtBuilder(rootName, null,
- EDIT_CONFIG_REQUEST);
- defaultYdtBuilder.addChild("test", "ydt.test", MERGE);
- defaultYdtBuilder.addChild("cont1", null, MERGE);
- defaultYdtBuilder.addChild("list1", null, DELETE);
- defaultYdtBuilder.addLeaf("leaf2", null, "2");
- defaultYdtBuilder.traverseToParent();
- defaultYdtBuilder.addLeaf("leaf3", null, "3");
- defaultYdtBuilder.traverseToParent();
- defaultYdtBuilder.traverseToParent();
- defaultYdtBuilder.addLeaf("leaf4", null, "4");
- defaultYdtBuilder.traverseToParent();
- defaultYdtBuilder.traverseToParent();
- defaultYdtBuilder.addChild("list2", null, DELETE);
- defaultYdtBuilder.addLeaf("leaf5", null, "5");
- defaultYdtBuilder.traverseToParent();
- defaultYdtBuilder.addLeaf("leaf6", null, "6");
- defaultYdtBuilder.traverseToParent();
- defaultYdtBuilder.traverseToParent();
- defaultYdtBuilder.addLeaf("leaf10", null, "10");
- return defaultYdtBuilder;
- }
-
- /**
- * Returns YANG data tree to check query operation of container.
- *
- * @return YANG data tree
- */
- private YangRequestWorkBench buildYdtForQueryOperation() {
- String rootName = "root";
- YangRequestWorkBench defaultYdtBuilder =
- (YangRequestWorkBench) ymsManager.getYdtBuilder(rootName, null,
- QUERY_CONFIG_REQUEST);
- defaultYdtBuilder.addChild("test", "ydt.test");
- defaultYdtBuilder.addChild("cont1", null);
- defaultYdtBuilder.addChild("cont2", null);
- defaultYdtBuilder.addChild("cont3", null);
- defaultYdtBuilder.traverseToParent();
- defaultYdtBuilder.traverseToParent();
- defaultYdtBuilder.traverseToParent();
- defaultYdtBuilder.addChild("cont4", null);
- defaultYdtBuilder.addChild("cont5", null);
- return defaultYdtBuilder;
- }
-
- /**
- * Returns YANG data tree to check query operation of list.
- *
- * @return YANG data tree
- */
- private YangRequestWorkBench buildYdtForListQueryOperation() {
- String rootName = "listQuery";
- YangRequestWorkBench defaultYdtBuilder =
- (YangRequestWorkBench) ymsManager.getYdtBuilder(rootName, null,
- QUERY_CONFIG_REQUEST);
- defaultYdtBuilder.addChild("test", "ydt.test");
- defaultYdtBuilder.addChild("cont1", null);
- defaultYdtBuilder.addChild("list1", null);
- defaultYdtBuilder.addLeaf("leaf2", null, "2");
- defaultYdtBuilder.traverseToParent();
- defaultYdtBuilder.traverseToParent();
- defaultYdtBuilder.traverseToParent();
- defaultYdtBuilder.addChild("list2", null);
- defaultYdtBuilder.addLeaf("leaf5", null, "5");
- defaultYdtBuilder.traverseToParent();
- defaultYdtBuilder.addLeaf("leaf6", null, "6");
- return defaultYdtBuilder;
- }
-
- /**
- * Returns YANG data tree to check delete operation of a node.
- *
- * @return YANG data tree
- */
- private YangRequestWorkBench buildYdtWithOneDeleteNode() {
- String rootName = "root";
- YangRequestWorkBench defaultYdtBuilder =
- (YangRequestWorkBench) ymsManager.getYdtBuilder(rootName, null,
- EDIT_CONFIG_REQUEST);
- defaultYdtBuilder.addChild("test", "ydt.test");
- defaultYdtBuilder.addChild("cont1", null, MERGE);
- defaultYdtBuilder.traverseToParent();
- defaultYdtBuilder.addChild("cont4", null, DELETE);
- defaultYdtBuilder.traverseToParent();
- defaultYdtBuilder.addLeaf("leaf10", null, "10");
- return defaultYdtBuilder;
- }
-
- /**
- * Returns YANG data tree to check delete operation of last node.
- *
- * @return YANG data tree
- */
- private YangRequestWorkBench buildYdtWithDeleteNodeAsLastChild() {
- String rootName = "root";
- YangRequestWorkBench defaultYdtBuilder =
- (YangRequestWorkBench) ymsManager.getYdtBuilder(rootName, null,
- EDIT_CONFIG_REQUEST);
- defaultYdtBuilder.addChild("test", "ydt.test", MERGE);
- defaultYdtBuilder.addChild("cont1", null, MERGE);
- defaultYdtBuilder.traverseToParent();
- defaultYdtBuilder.addChild("list2", null, MERGE);
- defaultYdtBuilder.addLeaf("leaf5", null, "10");
- defaultYdtBuilder.traverseToParent();
- defaultYdtBuilder.addLeaf("leaf6", null, "10");
- defaultYdtBuilder.traverseToParent();
- defaultYdtBuilder.traverseToParent();
- defaultYdtBuilder.addChild("cont4", null, DELETE);
- return defaultYdtBuilder;
- }
-
- /**
- * Returns YANG data tree to with delete operation of all the nodes.
- *
- * @return YANG data tree
- */
- private YangRequestWorkBench buildYdtWithAllDeleteNode() {
- String rootName = "root";
- YangRequestWorkBench defaultYdtBuilder =
- (YangRequestWorkBench) ymsManager.getYdtBuilder(rootName, null,
- EDIT_CONFIG_REQUEST);
- defaultYdtBuilder.addChild("test", "ydt.test", DELETE);
- defaultYdtBuilder.addChild("cont1", null, DELETE);
- defaultYdtBuilder.traverseToParent();
- defaultYdtBuilder.addChild("list2", null, DELETE);
- defaultYdtBuilder.addLeaf("leaf5", null, "10");
- defaultYdtBuilder.traverseToParent();
- defaultYdtBuilder.addLeaf("leaf6", null, "10");
- defaultYdtBuilder.traverseToParent();
- defaultYdtBuilder.traverseToParent();
- defaultYdtBuilder.addChild("cont4", null, DELETE);
- return defaultYdtBuilder;
- }
-
- /**
- * Returns YANG data tree to check rpc operation with only input.
- *
- * @return YANG data tree
- */
- private YangRequestWorkBench buildYdtForRpcWithOnlyInput() {
- String rootName = "root";
- YangRequestWorkBench defaultYdtBuilder =
- (YangRequestWorkBench) ymsManager.getYdtBuilder(rootName, null,
- RPC_REQUEST);
- defaultYdtBuilder.addChild("test", "ydt.test");
- defaultYdtBuilder.addChild("rock-the-house1", null);
- defaultYdtBuilder.addChild("input", null);
- defaultYdtBuilder.addLeaf("leaf13", null, "5");
- defaultYdtBuilder.traverseToParent();
- defaultYdtBuilder.traverseToParent();
- defaultYdtBuilder.traverseToParent();
- defaultYdtBuilder.traverseToParent();
- return defaultYdtBuilder;
- }
-
- /**
- * Returns YANG data tree to check rpc operation with only output.
- *
- * @return YANG data tree
- */
- private YangRequestWorkBench buildYdtForRpcWithOnlyOutput() {
- String rootName = "root";
- YangRequestWorkBench defaultYdtBuilder =
- (YangRequestWorkBench) ymsManager.getYdtBuilder(rootName, null,
- RPC_REQUEST);
- defaultYdtBuilder.addChild("test", "ydt.test");
- defaultYdtBuilder.addChild("rock-the-house2", null);
- defaultYdtBuilder.addChild("output", null);
- defaultYdtBuilder.addLeaf("leaf14", null, "14");
- defaultYdtBuilder.traverseToParent();
- defaultYdtBuilder.traverseToParent();
- defaultYdtBuilder.traverseToParent();
- defaultYdtBuilder.traverseToParent();
- return defaultYdtBuilder;
- }
-
- /**
- * Returns YANG data tree to check rpc operation with both input and output.
- *
- * @return YANG data tree
- */
- private YangRequestWorkBench buildYdtForRpcWithBothInputOutput() {
- String rootName = "root";
- YangRequestWorkBench defaultYdtBuilder =
- (YangRequestWorkBench) ymsManager.getYdtBuilder(rootName, null,
- RPC_REQUEST);
- defaultYdtBuilder.addChild("test", "ydt.test");
- defaultYdtBuilder.addChild("rock-the-house", null);
- defaultYdtBuilder.addChild("input", null);
- defaultYdtBuilder.addLeaf("zip-code", null, "5");
- defaultYdtBuilder.traverseToParent();
- defaultYdtBuilder.traverseToParent();
- defaultYdtBuilder.addChild("output", null);
- defaultYdtBuilder.addLeaf("hello", null, "5");
- defaultYdtBuilder.traverseToParent();
- defaultYdtBuilder.traverseToParent();
- defaultYdtBuilder.traverseToParent();
- defaultYdtBuilder.traverseToParent();
- return defaultYdtBuilder;
- }
-
- /**
- * Returns YANG data tree to check rpc operation.
- *
- * @return YANG data tree
- */
- private YangRequestWorkBench buildYdtForRpc() {
- String rootName = "root";
- YangRequestWorkBench defaultYdtBuilder =
- (YangRequestWorkBench) ymsManager.getYdtBuilder(rootName, null,
- RPC_REQUEST);
- defaultYdtBuilder.addChild("test", "ydt.test");
- defaultYdtBuilder.addChild("rock-the-house3", null);
- defaultYdtBuilder.traverseToParent();
- defaultYdtBuilder.traverseToParent();
- return defaultYdtBuilder;
- }
-
- /**
- * Returns YANG data tree to check query operation with multiple level of
- * augment.
- *
- * @return YANG data tree
- */
- private YangRequestWorkBench buildYdtForQueryWithMultipleAugment() {
- String rootName = "root";
- YangRequestWorkBench defaultYdtBuilder =
- (YangRequestWorkBench) ymsManager.getYdtBuilder(rootName, null,
- QUERY_CONFIG_REQUEST);
- defaultYdtBuilder.addChild("test", "ydt.test");
- defaultYdtBuilder.traverseToParent();
- return defaultYdtBuilder;
- }
-
- /**
- * Returns YANG data tree to check delete operation with multiple level of
- * augment.
- *
- * @return YANG data tree
- */
- private YangRequestWorkBench buildYdtForDeleteWithMultipleAugment() {
- String rootName = "root";
- YangRequestWorkBench defaultYdtBuilder =
- (YangRequestWorkBench) ymsManager.getYdtBuilder(rootName, null,
- EDIT_CONFIG_REQUEST);
- defaultYdtBuilder.addChild("test", "ydt.test");
- defaultYdtBuilder.addChild("cont4", null, DELETE);
- defaultYdtBuilder.traverseToParent();
- defaultYdtBuilder.traverseToParent();
- return defaultYdtBuilder;
- }
-
- /**
- * Checks whether YANG data tree and delete tree is correct.
- */
- @Test
- public void validateDeleteTreeOnlyOneNodeInDeleteList()
- throws IOException, CloneNotSupportedException {
- YangRequestWorkBench defaultYdtBuilder =
- buildYdtForEditOperationWithDelete();
- YdtAppContext appContext =
- defaultYdtBuilder.getAppRootNode().getFirstChild();
- YdtContext ydtContext = appContext.getModuleContext();
- List<YdtContext> deleteNodes = appContext.getDeleteNodes();
-
- YdtContext cont1YdtContext;
- YdtContext cont2YdtContext;
- YdtContext cont3YdtContext;
- YdtContext cont4YdtContext;
- YdtContext deleteTree;
-
- // verify whether ydt tree is correct
- assertThat(ydtContext.getName(), is("test"));
-
- cont1YdtContext = ydtContext.getFirstChild();
- assertThat(cont1YdtContext.getName(), is("cont1"));
-
- cont2YdtContext = cont1YdtContext.getFirstChild();
- assertThat(cont2YdtContext.getName(), is("cont2"));
-
- cont3YdtContext = cont2YdtContext.getFirstChild();
- assertThat(cont3YdtContext.getName(), is("cont3"));
-
- ydtContext = cont3YdtContext.getFirstChild();
- assertThat(ydtContext.getName(), is("leaf1"));
- assertThat(ydtContext.getValue(), is("1"));
-
- ydtContext = cont2YdtContext.getNextSibling();
- assertThat(ydtContext.getName(), is("leaf4"));
- assertThat(ydtContext.getValue(), is("4"));
-
- cont4YdtContext = cont1YdtContext.getNextSibling();
- assertThat(cont4YdtContext.getName(), is("cont4"));
-
- ydtContext = cont4YdtContext.getFirstChild();
- assertThat(ydtContext.getName(), is("cont5"));
-
- ydtContext = ydtContext.getFirstChild();
- assertThat(ydtContext.getName(), is("leaf9"));
- assertThat(ydtContext.getValue(), is("9"));
-
- ydtContext = cont4YdtContext.getNextSibling();
- assertThat(ydtContext.getName(), is("leaf10"));
- assertThat(ydtContext.getValue(), is("10"));
-
- // build delete tree
- YangApplicationBroker yab = new YangApplicationBroker(null);
- deleteTree = yab.buildDeleteTree(deleteNodes);
-
- // verify whether delete ydt tree is correct
- assertThat(deleteTree.getFirstChild().getName(), is("test"));
-
- cont1YdtContext = deleteTree.getFirstChild().getFirstChild();
- assertThat(cont1YdtContext.getName(), is("cont1"));
-
- cont2YdtContext = cont1YdtContext.getFirstChild();
- assertThat(cont2YdtContext.getName(), is("cont2"));
-
- cont3YdtContext = cont2YdtContext.getFirstChild();
- assertThat(cont3YdtContext.getName(), is("cont3"));
-
- ydtContext = cont3YdtContext.getFirstChild();
- assertThat(ydtContext.getName(), is("leaf1"));
- assertThat(ydtContext.getValue(), is("1"));
-
- assertThat(cont2YdtContext.getNextSibling(), nullValue());
-
- cont4YdtContext = cont1YdtContext.getNextSibling();
- assertThat(cont4YdtContext.getName(), is("cont4"));
-
- ydtContext = cont4YdtContext.getFirstChild();
- assertThat(ydtContext.getName(), is("cont5"));
-
- ydtContext = ydtContext.getFirstChild();
- assertThat(ydtContext.getName(), is("leaf9"));
- assertThat(ydtContext.getValue(), is("9"));
-
- assertThat(cont4YdtContext.getNextSibling(), nullValue());
-
- // ydtTree after removing delete nodes
- ydtContext = appContext.getModuleContext();
- assertThat(ydtContext.getName(), is("test"));
-
- cont1YdtContext = ydtContext.getFirstChild();
- assertThat(cont1YdtContext.getName(), is("cont1"));
-
- ydtContext = cont1YdtContext.getFirstChild();
- assertThat(ydtContext.getName(), is("leaf4"));
- assertThat(ydtContext.getValue(), is("4"));
-
- ydtContext = cont1YdtContext.getNextSibling();
- assertThat(ydtContext.getName(), is("leaf10"));
- assertThat(ydtContext.getValue(), is("10"));
- }
-
- /**
- * Checks whether YANG data tree and delete tree is correct.
- */
- @Test
- public void validateListDeleteTree()
- throws IOException, CloneNotSupportedException {
- YangRequestWorkBench defaultYdtBuilder =
- buildYdtForListEditOperationWithDelete();
- YdtAppContext appContext =
- defaultYdtBuilder.getAppRootNode().getFirstChild();
- YdtContext ydtContext = appContext.getModuleContext();
- List<YdtContext> deleteNodes = appContext.getDeleteNodes();
-
- YdtContext cont1YdtContext;
- YdtContext list1YdtContext;
- YdtContext list2YdtContext;
- YdtContext deleteTree;
-
- // verify whether ydt tree is correct
- assertThat(ydtContext.getName(), is("test"));
-
- cont1YdtContext = ydtContext.getFirstChild();
- assertThat(cont1YdtContext.getName(), is("cont1"));
-
- list1YdtContext = cont1YdtContext.getFirstChild();
- assertThat(list1YdtContext.getName(), is("list1"));
-
- ydtContext = list1YdtContext.getFirstChild();
- assertThat(ydtContext.getName(), is("leaf2"));
- assertThat(ydtContext.getValue(), is("2"));
-
- ydtContext = ydtContext.getNextSibling();
- assertThat(ydtContext.getName(), is("leaf3"));
- assertThat(ydtContext.getValue(), is("3"));
-
- ydtContext = list1YdtContext.getNextSibling();
- assertThat(ydtContext.getName(), is("leaf4"));
- assertThat(ydtContext.getValue(), is("4"));
-
- list2YdtContext = cont1YdtContext.getNextSibling();
- assertThat(list2YdtContext.getName(), is("list2"));
-
- ydtContext = list2YdtContext.getFirstChild();
- assertThat(ydtContext.getName(), is("leaf5"));
- assertThat(ydtContext.getValue(), is("5"));
-
- ydtContext = ydtContext.getNextSibling();
- assertThat(ydtContext.getName(), is("leaf6"));
- assertThat(ydtContext.getValue(), is("6"));
-
- ydtContext = list2YdtContext.getNextSibling();
- assertThat(ydtContext.getName(), is("leaf10"));
- assertThat(ydtContext.getValue(), is("10"));
-
- // build delete tree
- YangApplicationBroker yab = new YangApplicationBroker(null);
- deleteTree = yab.buildDeleteTree(deleteNodes);
-
- assertThat(deleteTree.getFirstChild().getName(), is("test"));
-
- cont1YdtContext = deleteTree.getFirstChild().getFirstChild();
- assertThat(cont1YdtContext.getName(), is("cont1"));
-
- list1YdtContext = cont1YdtContext.getFirstChild();
- assertThat(list1YdtContext.getName(), is("list1"));
-
- ydtContext = list1YdtContext.getFirstChild();
- assertThat(ydtContext.getName(), is("leaf2"));
- assertThat(ydtContext.getValue(), is("2"));
-
- ydtContext = ydtContext.getNextSibling();
- assertThat(ydtContext.getName(), is("leaf3"));
- assertThat(ydtContext.getValue(), is("3"));
-
- assertThat(list1YdtContext.getNextSibling(), nullValue());
-
- list2YdtContext = cont1YdtContext.getNextSibling();
- assertThat(list2YdtContext.getName(), is("list2"));
-
- ydtContext = list2YdtContext.getFirstChild();
- assertThat(ydtContext.getName(), is("leaf5"));
- assertThat(ydtContext.getValue(), is("5"));
-
- ydtContext = ydtContext.getNextSibling();
- assertThat(ydtContext.getName(), is("leaf6"));
- assertThat(ydtContext.getValue(), is("6"));
-
- assertThat(ydtContext.getNextSibling(), nullValue());
-
- // verify whether ydt tree is correct
- ydtContext = appContext.getModuleContext();
- assertThat(ydtContext.getName(), is("test"));
-
- cont1YdtContext = ydtContext.getFirstChild();
- assertThat(cont1YdtContext.getName(), is("cont1"));
-
- ydtContext = cont1YdtContext.getFirstChild();
- assertThat(ydtContext.getName(), is("leaf4"));
- assertThat(ydtContext.getValue(), is("4"));
-
- ydtContext = cont1YdtContext.getNextSibling();
- assertThat(ydtContext.getName(), is("leaf10"));
- assertThat(ydtContext.getValue(), is("10"));
- }
-
- /**
- * Checks whether there is no exception when there is valid edit
- * request.
- */
- @Test
- public void testExecuteEditOperationWithoutDelete()
- throws IOException, CloneNotSupportedException {
- YangRequestWorkBench defaultYdtBuilder =
- buildYdtForEditOperationWithoutDelete();
- ymsManager.executeOperation(defaultYdtBuilder);
- }
-
- /**
- * Checks whether there is no exception when there is valid delete
- * request.
- */
- @Test
- public void testExecuteEditOperationWithDelete()
- throws IOException, CloneNotSupportedException {
- YangRequestWorkBench defaultYdtBuilder =
- buildYdtForEditOperationWithDelete();
- ymsManager.executeOperation(defaultYdtBuilder);
- }
-
- /**
- * Checks whether there is no exception when there is valid edit
- * request for list.
- */
- @Test
- public void testExecuteListEditOperationWithoutDelete()
- throws IOException, CloneNotSupportedException {
- YangRequestWorkBench defaultYdtBuilder =
- buildYdtForListEditOperationWithoutDelete();
- ymsManager.executeOperation(defaultYdtBuilder);
- }
-
- /**
- * Checks whether there is no exception when there is valid delete
- * request for list.
- */
- @Test
- public void testExecuteListEditOperationWithDelete()
- throws IOException, CloneNotSupportedException {
- YangRequestWorkBench defaultYdtBuilder =
- buildYdtForListEditOperationWithDelete();
- ymsManager.executeOperation(defaultYdtBuilder);
- }
-
- /**
- * Checks whether there is no exception when there is valid query
- * request.
- */
- @Test
- public void testExecuteQueryOperation()
- throws IOException, CloneNotSupportedException {
- YangRequestWorkBench defaultYdtBuilder = buildYdtForQueryOperation();
- ymsManager.executeOperation(defaultYdtBuilder);
- }
-
- /**
- * Checks whether there is no exception when there is valid query
- * request for list.
- */
- @Test
- public void testExecuteListQueryOperation()
- throws IOException, CloneNotSupportedException {
- YangRequestWorkBench defaultYdtBuilder =
- buildYdtForListQueryOperation();
- ymsManager.executeOperation(defaultYdtBuilder);
- }
-
- /**
- * Checks whether delete tree is updated correctly.
- */
- @Test
- public void testSiblingsInDeleteTree()
- throws IOException, CloneNotSupportedException {
- YangRequestWorkBench defaultYdtBuilder = buildYdtWithOneDeleteNode();
- YdtAppContext appContext =
- defaultYdtBuilder.getAppRootNode().getFirstChild();
- YdtContext ydtContext = appContext.getModuleContext();
- List<YdtContext> deleteNodes = appContext.getDeleteNodes();
-
- // verify whether ydt tree is correct
- assertThat(ydtContext.getName(), is("test"));
-
- ydtContext = ydtContext.getFirstChild();
- assertThat(ydtContext.getName(), is("cont1"));
-
- ydtContext = ydtContext.getNextSibling();
- assertThat(ydtContext.getName(), is("cont4"));
-
- ydtContext = ydtContext.getNextSibling();
- assertThat(ydtContext.getName(), is("leaf10"));
- assertThat(ydtContext.getValue(), is("10"));
-
- // build delete tree
- YangApplicationBroker yab = new YangApplicationBroker(null);
- YdtContext deleteTree = yab.buildDeleteTree(deleteNodes);
-
- assertThat(deleteTree.getFirstChild().getName(), is("test"));
-
- ydtContext = deleteTree.getFirstChild().getFirstChild();
- assertThat(ydtContext.getName(), is("cont4"));
-
- assertThat(ydtContext.getNextSibling(), nullValue());
- assertThat(ydtContext.getPreviousSibling(), nullValue());
-
- ydtContext = appContext.getModuleContext();
-
- // verify whether ydt tree is correct
- assertThat(ydtContext.getName(), is("test"));
-
- ydtContext = ydtContext.getFirstChild();
- assertThat(ydtContext.getName(), is("cont1"));
-
- ydtContext = ydtContext.getNextSibling();
- assertThat(ydtContext.getName(), is("leaf10"));
- assertThat(ydtContext.getValue(), is("10"));
-
- assertThat(ydtContext.getNextSibling(), nullValue());
- }
-
- /**
- * Checks last child is updated correctly after delete tree is built.
- */
- @Test
- public void testLastChildInYdtTree()
- throws IOException, CloneNotSupportedException {
- YangRequestWorkBench defaultYdtBuilder =
- buildYdtWithDeleteNodeAsLastChild();
- YdtAppContext appContext =
- defaultYdtBuilder.getAppRootNode().getFirstChild();
- YdtContext ydtContext = appContext.getModuleContext();
- List<YdtContext> deleteNodes = appContext.getDeleteNodes();
- assertThat(YdtAppNodeOperationType.BOTH,
- is(appContext.getOperationType()));
-
- // verify whether ydt tree is correct
- assertThat(ydtContext.getName(), is("test"));
-
- ydtContext = ydtContext.getFirstChild();
- assertThat(ydtContext.getName(), is("cont1"));
-
- ydtContext = ydtContext.getNextSibling();
- assertThat(ydtContext.getName(), is("list2"));
-
- ydtContext = ydtContext.getNextSibling();
- assertThat(ydtContext.getName(), is("cont4"));
-
- assertThat(ydtContext.getNextSibling(), nullValue());
-
- // build delete tree
- YangApplicationBroker yab = new YangApplicationBroker(null);
- YdtContext deleteTree = yab.buildDeleteTree(deleteNodes);
-
- assertThat(deleteTree.getFirstChild().getName(), is("test"));
-
- ydtContext = deleteTree.getFirstChild().getFirstChild();
- assertThat(ydtContext.getName(), is("cont4"));
-
- ydtContext = deleteTree.getFirstChild().getLastChild();
- assertThat(ydtContext.getName(), is("cont4"));
-
- assertThat(ydtContext.getNextSibling(), nullValue());
- assertThat(ydtContext.getPreviousSibling(), nullValue());
-
- ydtContext = appContext.getModuleContext();
-
- assertThat(ydtContext.getLastChild().getName(), is("list2"));
-
- // verify whether ydt tree is correct
- assertThat(ydtContext.getName(), is("test"));
-
- ydtContext = ydtContext.getFirstChild();
- assertThat(ydtContext.getName(), is("cont1"));
-
- ydtContext = ydtContext.getNextSibling();
- assertThat(ydtContext.getName(), is("list2"));
-
- assertThat(ydtContext.getNextSibling(), nullValue());
- }
-
- /**
- * Checks YDT tree with all delete nodes.
- */
- @Test
- public void testYdtTreeWithAllDeleteNodes()
- throws IOException, CloneNotSupportedException {
- YangRequestWorkBench defaultYdtBuilder = buildYdtWithAllDeleteNode();
- YdtAppContext appContext =
- defaultYdtBuilder.getAppRootNode().getFirstChild();
- YdtContext ydtContext = appContext.getModuleContext();
- List<YdtContext> deleteNodes = appContext.getDeleteNodes();
-
- assertThat(YdtAppNodeOperationType.DELETE_ONLY,
- is(appContext.getOperationType()));
-
- // verify whether ydt tree is correct
- assertThat(ydtContext.getName(), is("test"));
-
- ydtContext = ydtContext.getFirstChild();
- assertThat(ydtContext.getName(), is("cont1"));
-
- ydtContext = ydtContext.getNextSibling();
- assertThat(ydtContext.getName(), is("list2"));
-
- ydtContext = ydtContext.getNextSibling();
- assertThat(ydtContext.getName(), is("cont4"));
-
- assertThat(ydtContext.getNextSibling(), nullValue());
-
- // build delete tree
- YangApplicationBroker yab = new YangApplicationBroker(null);
- YdtContext deleteTree = yab.buildDeleteTree(deleteNodes);
-
- assertThat(deleteTree.getFirstChild().getName(), is("test"));
-
- ydtContext = deleteTree.getFirstChild().getFirstChild();
- assertThat(ydtContext.getName(), is("cont1"));
-
- ydtContext = ydtContext.getNextSibling();
- assertThat(ydtContext.getName(), is("list2"));
-
- ydtContext = ydtContext.getNextSibling();
- assertThat(ydtContext.getName(), is("cont4"));
-
- assertThat(ydtContext.getNextSibling(), nullValue());
- }
-
- /**
- * Checks whether key leaves are also available when there is delete
- * request for list.
- */
- @Test
- public void testKeyLeavesInDeleteTree() throws IOException, CloneNotSupportedException {
- YangRequestWorkBench defaultYdtBuilder = buildYdtForKeyLeavesInDeleteTree();
-
- YdtAppContext appContext =
- defaultYdtBuilder.getAppRootNode().getFirstChild();
- YdtContext ydtContext = appContext.getModuleContext();
- List<YdtContext> deleteNodes = appContext.getDeleteNodes();
-
- assertThat(YdtAppNodeOperationType.BOTH, is(appContext.getOperationType()));
-
- // verify whether ydt tree is correct
- assertThat(ydtContext.getName(), is("test"));
-
- ydtContext = ydtContext.getFirstChild();
- assertThat(ydtContext.getName(), is("list2"));
-
- ydtContext = ydtContext.getFirstChild();
- assertThat(ydtContext.getName(), is("leaf5"));
- assertThat(ydtContext.getValue(), is("5"));
-
- ydtContext = ydtContext.getNextSibling();
- assertThat(ydtContext.getName(), is("leaf6"));
- assertThat(ydtContext.getValue(), is("6"));
-
- ydtContext = ydtContext.getNextSibling();
- assertThat(ydtContext.getName(), is("leaf7"));
- assertThat(ydtContext.getValue(), is("7"));
-
- ydtContext = ydtContext.getNextSibling();
- assertThat(ydtContext.getName(), is("cont7"));
-
- assertThat(ydtContext.getNextSibling(), nullValue());
-
- // build delete tree
- YangApplicationBroker yab = new YangApplicationBroker(null);
- YdtContext deleteTree = yab.buildDeleteTree(deleteNodes);
-
- assertThat(deleteTree.getFirstChild().getName(), is("test"));
-
- ydtContext = deleteTree.getFirstChild().getFirstChild();
- assertThat(ydtContext.getName(), is("list2"));
-
- ydtContext = ydtContext.getFirstChild();
- assertThat(ydtContext, notNullValue());
-
- ydtContext = ydtContext.getNextSibling();
- assertThat(ydtContext, notNullValue());
-
- ydtContext = ydtContext.getNextSibling();
- assertThat(ydtContext.getName(), is("cont7"));
-
- assertThat(ydtContext.getNextSibling(), nullValue());
-
- ydtContext = appContext.getModuleContext();
-
- // verify whether ydt tree is correct
- assertThat(ydtContext.getName(), is("test"));
-
- ydtContext = ydtContext.getFirstChild();
- assertThat(ydtContext.getName(), is("list2"));
-
- ydtContext = ydtContext.getFirstChild();
- assertThat(ydtContext.getName(), is("leaf5"));
- assertThat(ydtContext.getValue(), is("5"));
-
- ydtContext = ydtContext.getNextSibling();
- assertThat(ydtContext.getName(), is("leaf6"));
- assertThat(ydtContext.getValue(), is("6"));
-
- ydtContext = ydtContext.getNextSibling();
- assertThat(ydtContext.getName(), is("leaf7"));
- assertThat(ydtContext.getValue(), is("7"));
-
- assertThat(ydtContext.getNextSibling(), nullValue());
- }
-
- /**
- * Checks YDT tree and application tree for query request with mutiple
- * augments.
- */
- @Test
- public void testApptreeForQueryWithMultipleAugment()
- throws IOException, CloneNotSupportedException {
- YangRequestWorkBench defaultYdtBuilder = buildYdtForQueryWithMultipleAugment();
- YdtAppContext appContext = defaultYdtBuilder.getAppRootNode()
- .getFirstChild();
- YdtContext ydtNode = appContext.getModuleContext();
- YangNode yangNode = (YangNode) ((YdtNode) ydtNode).getYangSchemaNode();
-
- YangApplicationBroker yab = new YangApplicationBroker(defaultYdtBuilder.
- getYangSchemaRegistry());
- yab.processAugmentForChildNode(appContext, yangNode);
-
- assertThat(appContext.getModuleContext().getName(), is("test"));
-
- appContext = appContext.getFirstChild();
-
- String augmentName = ((YangAugment) appContext
- .getAugmentingSchemaNode()).getTargetNode().get(0)
- .getResolvedNode().getJavaClassNameOrBuiltInType();
- assertThat(augmentName, is("cont4"));
-
- appContext = appContext.getFirstChild();
- augmentName = ((YangAugment) appContext
- .getAugmentingSchemaNode()).getTargetNode().get(0)
- .getResolvedNode().getJavaClassNameOrBuiltInType();
- assertThat(augmentName, is("cont4"));
- assertThat(appContext.getFirstChild(), nullValue());
- assertThat(appContext.getLastChild(), nullValue());
- }
-
- /**
- * Checks whether there is no exception when there is valid query request
- * for data resource with multiple augments.
- */
- @Test
- public void testQueryWithMultipleAugment()
- throws IOException, CloneNotSupportedException {
- YangRequestWorkBench defaultYdtBuilder = buildYdtForQueryWithMultipleAugment();
- ymsManager.executeOperation(defaultYdtBuilder);
- }
-
- /**
- * Checks whether YDT is updated correctly for delete with multiple augment.
- */
- @Test
- public void testYdtForDeleteWithMultipleAugment()
- throws IOException, CloneNotSupportedException {
- YangRequestWorkBench defaultYdtBuilder =
- buildYdtForDeleteWithMultipleAugment();
- YdtAppContext appContext = defaultYdtBuilder.getAppRootNode()
- .getFirstChild();
-
- YangApplicationBroker yab = new YangApplicationBroker(defaultYdtBuilder.
- getYangSchemaRegistry());
- YdtContext deleteTree = yab.buildDeleteTree(appContext.getDeleteNodes());
- yab.processAugmentedNodesForDelete(deleteTree.getFirstChild(),
- appContext);
-
- assertThat(appContext.getModuleContext().getName(), is("test"));
-
- appContext = appContext.getFirstChild();
- String augmentName = ((YangAugment) appContext
- .getAugmentingSchemaNode()).getTargetNode().get(0)
- .getResolvedNode().getJavaClassNameOrBuiltInType();
- assertThat(augmentName, is("cont4"));
-
- appContext = appContext.getFirstChild();
- augmentName = ((YangAugment) appContext
- .getAugmentingSchemaNode()).getTargetNode().get(0)
- .getResolvedNode().getJavaClassNameOrBuiltInType();
- assertThat(augmentName, is("cont4"));
- assertThat(appContext.getFirstChild(), nullValue());
- assertThat(appContext.getLastChild(), nullValue());
-
- YdtContext ydtContext = deleteTree.getFirstChild();
- assertThat(ydtContext.getName(), is("test"));
-
- ydtContext = ydtContext.getFirstChild();
- assertThat(ydtContext.getName(), is("cont4"));
- }
-
- /**
- * Checks whether there is no exception when there is valid delete request
- * for data resource with multiple augments.
- */
- @Test
- public void testDeleteWithMultipleAugment() {
- YangRequestWorkBench defaultYdtBuilder =
- buildYdtForDeleteWithMultipleAugment();
- ymsManager.executeOperation(defaultYdtBuilder);
- }
-
- /**
- * Checks execute operation for rpc request with only output.
- */
- @Test
- public void testRpcWithOutput()
- throws IOException, CloneNotSupportedException {
- YangRequestWorkBench defaultYdtBuilder =
- buildYdtForRpcWithOnlyOutput();
- ymsManager.executeOperation(defaultYdtBuilder);
- }
-
- /**
- * Checks execute operation for rpc request with only input.
- */
- @Test
- public void testRpcWithInput()
- throws IOException, CloneNotSupportedException {
- YangRequestWorkBench defaultYdtBuilder =
- buildYdtForRpcWithOnlyInput();
- ymsManager.executeOperation(defaultYdtBuilder);
- }
-
- /**
- * Checks execute operation for rpc request with input and output.
- */
- @Test
- public void testRpcWithInputOutput()
- throws IOException, CloneNotSupportedException {
- YangRequestWorkBench defaultYdtBuilder =
- buildYdtForRpcWithBothInputOutput();
- ymsManager.executeOperation(defaultYdtBuilder);
- }
-
- /**
- * Checks execute operation for rpc request without input and
- * output.
- */
- @Test
- public void testRpcWithoutInputOutput()
- throws IOException, CloneNotSupportedException {
- YangRequestWorkBench defaultYdtBuilder =
- buildYdtForRpc();
- ymsManager.executeOperation(defaultYdtBuilder);
- }
-}
\ No newline at end of file
diff --git a/apps/yms/app/src/test/java/org/onosproject/yms/app/ych/DefaultYangCodecHandlerTest.java b/apps/yms/app/src/test/java/org/onosproject/yms/app/ych/DefaultYangCodecHandlerTest.java
deleted file mode 100644
index dcce22a..0000000
--- a/apps/yms/app/src/test/java/org/onosproject/yms/app/ych/DefaultYangCodecHandlerTest.java
+++ /dev/null
@@ -1,1422 +0,0 @@
-/*
- * 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.ych;
-
-import org.junit.Test;
-import org.onosproject.yang.gen.v1.ych.combined.rev20160524.CombinedOpParam;
-import org.onosproject.yang.gen.v1.ych.combined.rev20160524.combined.AsNum;
-import org.onosproject.yang.gen.v1.ych.combined.rev20160524.combined.Attributes;
-import org.onosproject.yang.gen.v1.ych.combined.rev20160524.combined.DefaultAttributes;
-import org.onosproject.yang.gen.v1.ych.combined.rev20160524.combined.Metric;
-import org.onosproject.yang.gen.v1.ych.combined.rev20160524.combined.PathId;
-import org.onosproject.yang.gen.v1.ych.combined.rev20160524.combined.attributes.Aigp;
-import org.onosproject.yang.gen.v1.ych.combined.rev20160524.combined.attributes.BgpParameters;
-import org.onosproject.yang.gen.v1.ych.combined.rev20160524.combined.attributes.DefaultAigp;
-import org.onosproject.yang.gen.v1.ych.combined.rev20160524.combined.attributes.DefaultBgpParameters;
-import org.onosproject.yang.gen.v1.ych.combined.rev20160524.combined.attributes.DefaultLocalPref;
-import org.onosproject.yang.gen.v1.ych.combined.rev20160524.combined.attributes.DefaultMultiExitDisc;
-import org.onosproject.yang.gen.v1.ych.combined.rev20160524.combined.attributes.DefaultOrigin;
-import org.onosproject.yang.gen.v1.ych.combined.rev20160524.combined.attributes.DefaultUnrecognizedAttributes;
-import org.onosproject.yang.gen.v1.ych.combined.rev20160524.combined.attributes.LocalPref;
-import org.onosproject.yang.gen.v1.ych.combined.rev20160524.combined.attributes.MultiExitDisc;
-import org.onosproject.yang.gen.v1.ych.combined.rev20160524.combined.attributes.Origin;
-import org.onosproject.yang.gen.v1.ych.combined.rev20160524.combined.attributes.UnrecognizedAttributes;
-import org.onosproject.yang.gen.v1.ych.combined.rev20160524.combined.attributes.aigp.AigpTlv;
-import org.onosproject.yang.gen.v1.ych.combined.rev20160524.combined.attributes.aigp.DefaultAigpTlv;
-import org.onosproject.yang.gen.v1.ych.combined.rev20160524.combined.attributes.bgpparameters.DefaultOptionalCapabilities;
-import org.onosproject.yang.gen.v1.ych.combined.rev20160524.combined.attributes.bgpparameters.OptionalCapabilities;
-import org.onosproject.yang.gen.v1.ych.combined.rev20160524.combined.attributes.bgpparameters.optionalcapabilities.Cparameters;
-import org.onosproject.yang.gen.v1.ych.combined.rev20160524.combined.attributes.bgpparameters.optionalcapabilities.DefaultCparameters;
-import org.onosproject.yang.gen.v1.ych.combined.rev20160524.combined.attributes.bgpparameters.optionalcapabilities.cparameters.As4BytesCapability;
-import org.onosproject.yang.gen.v1.ych.combined.rev20160524.combined.attributes.bgpparameters.optionalcapabilities.cparameters.DefaultAs4BytesCapability;
-import org.onosproject.yang.gen.v1.ych.empty.container.rev20160524.EmptyContainerOpParam;
-import org.onosproject.yang.gen.v1.ych.empty.container.rev20160524.emptycontainer.EmptyContainer;
-import org.onosproject.yang.gen.v1.ych.purchasing.supervisor.rev20160524.YchPurchasingsupervisorOpParam;
-import org.onosproject.yang.gen.v1.ych.purchasing.supervisor.rev20160524.ychpurchasingsupervisor.DefaultYchPurchasingSupervisor;
-import org.onosproject.yang.gen.v1.ych.purchasing.supervisor.rev20160524.ychpurchasingsupervisor.YchPurchasingSupervisor;
-import org.onosproject.yang.gen.v1.ydt.customs.supervisor.rev20160524.CustomssupervisorOpParam;
-import org.onosproject.yang.gen.v1.ydt.employee.id.rev20160524.EmployeeidOpParam;
-import org.onosproject.yang.gen.v1.ydt.material.supervisor.rev20160524.MaterialsupervisorOpParam;
-import org.onosproject.yang.gen.v1.ydt.material.supervisor.rev20160524.materialsupervisor.DefaultSupervisor;
-import org.onosproject.yang.gen.v1.ydt.material.supervisor.rev20160524.materialsupervisor.Supervisor;
-import org.onosproject.yang.gen.v1.ydt.merchandiser.supervisor.rev20160524.MerchandisersupervisorOpParam;
-import org.onosproject.yang.gen.v1.ydt.root.rev20160524.LogisticsManagerOpParam;
-import org.onosproject.yang.gen.v1.ydt.root.rev20160524.logisticsmanager.DefaultPurchasingSupervisor;
-import org.onosproject.yang.gen.v1.ydt.trading.supervisor.rev20160524.TradingsupervisorOpParam;
-import org.onosproject.yang.gen.v1.ydt.warehouse.supervisor.rev20160524.WarehousesupervisorOpParam;
-import org.onosproject.yms.app.ych.defaultcodecs.YangCodecRegistry;
-import org.onosproject.yms.app.ysr.DefaultYangSchemaRegistry;
-import org.onosproject.yms.app.ysr.TestYangSchemaNodeProvider;
-import org.onosproject.yms.ych.YangCompositeEncoding;
-
-import java.io.BufferedReader;
-import java.io.FileReader;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
-import static org.onosproject.yang.gen.v1.ydt.root.rev20160524.logisticsmanager.DefaultPurchasingSupervisor.OnosYangNodeOperationType.DELETE;
-import static org.onosproject.yms.ych.YangProtocolEncodingFormat.XML;
-import static org.onosproject.yms.ydt.YmsOperationType.EDIT_CONFIG_REQUEST;
-import static org.onosproject.yms.ydt.YmsOperationType.QUERY_CONFIG_REQUEST;
-import static org.onosproject.yms.ydt.YmsOperationType.QUERY_REQUEST;
-
-/**
- * Unit test case for default codec handler.
- */
-public class DefaultYangCodecHandlerTest {
- private TestYangSchemaNodeProvider testYangSchemaNodeProvider =
- new TestYangSchemaNodeProvider();
- private static final String AM_XML = "Incorrect XML generated: ";
- private static final String AM_OBJ = "Incorrect object generated: ";
- private static final String EMPTY_CONTAINER = "EmptyContainerOpParam";
- private static final String LOGISTIC_MOD = "LogisticsManagerOpParam";
- private static final String MERCHA_MOD = "MerchandisersupervisorOpParam";
-
- /**
- * Returns the xml string for customssupervisor module.
- *
- * @return the xml string for customssupervisor module
- */
- private static String customsXml() {
- return "<filter xmlns=\"ydt.filter-type\" type=\"subtree\">" +
- "<customssupervisor xmlns=\"ydt.customs-supervisor\">" +
- "<supervisor>Customssupervisor</supervisor>" +
- "</customssupervisor>" +
- "</filter>";
- }
-
- /**
- * Returns the xml string for merchandisersupervisor module.
- *
- * @return the xml string for merchandisersupervisor module
- */
- private static String merchandXml() {
- return "<config xmlns=\"ydt.root\">" +
- "<merchandisersupervisor xmlns=\"ydt.Merchandiser-" +
- "supervisor\">" +
- "<supervisor>Merchandisersupervisor</supervisor>" +
- "</merchandisersupervisor>" +
- "</config>";
- }
-
- /**
- * Returns the xml string for tradingsupervisor module.
- *
- * @return the xml string for tradingsupervisor module
- */
- private static String tradingXml() {
- return "<config xmlns=\"ydt.root\">" +
- "<tradingsupervisor xmlns=\"ydt.trading-supervisor\">" +
- "<supervisor>Tradingsupervisor</supervisor>" +
- "</tradingsupervisor>" +
- "</config>";
- }
-
- /**
- * Returns the xml string for customssupervisor module.
- *
- * @return the xml string for customssupervisor module
- */
- private static String customsCompositeXml() {
- return "<filter xmlns=\"ydt.filter-type\"><customssupervisor " +
- "xmlns=\"ydt.customs-supervisor\">" +
- "<supervisor>Customssupervisor</supervisor>" +
- "</customssupervisor></filter>";
- }
-
- /**
- * Returns the xml string for customssupervisor module with filter-type.
- *
- * @return the xml string for customssupervisor module with filter-type
- */
- private static String customsEmptyXml() {
- return "<filter xmlns=\"ydt.filter-type\" type=\"subtree\">" +
- "<customssupervisor xmlns=\"ydt.customs-supervisor\"/>" +
- "</filter>";
- }
-
- /**
- * Returns the xml string for materialsupervisor module.
- *
- * @return the xml string for materialsupervisor module
- */
- private static String materialXml() {
- return "<filter xmlns=\"ydt.filter-type\" type=\"subtree\">" +
- "<materialsupervisor xmlns=\"ydt.material-supervisor\">" +
- "<supervisor>" +
- "<name>abc1</name><departmentId>xyz1</departmentId>" +
- "</supervisor>" +
- "<supervisor><name>abc2</name><departmentId>xyz2</departmentId>" +
- "</supervisor>" +
- "<supervisor><name>abc3</name><departmentId>xyz3</departmentId>" +
- "</supervisor>" +
- "<supervisor><name>abc4</name><departmentId>xyz4</departmentId>" +
- "</supervisor>" +
- "<supervisor><name>abc5</name><departmentId>xyz5</departmentId>" +
- "</supervisor>" +
- "</materialsupervisor>" +
- "</filter>";
- }
-
- /**
- * Returns the xml string for EmptyContainer module.
- *
- * @return the xml string for EmptyContainer module
- */
- private static String containerEmptyXml() {
- return "<filter xmlns=\"ydt.filter-type\" type=\"subtree\">" +
- "<EmptyContainer xmlns=\"ych.Empty.Container\"/>" +
- "</filter>";
- }
-
- /**
- * Returns the xml string for Combined module.
- *
- * @return the xml string for Combined module
- */
- private static String listTestXml() {
- return "<filter xmlns=\"ydt.filter-type\" type=\"subtree\">" +
- "<Combined xmlns=\"ych:combined\"><attributes>" +
- "<origin><value>123</value></origin>" +
- "<multi-exit-disc><med>456</med></multi-exit-disc>" +
- "<local-pref><pref>23</pref></local-pref>" +
- "<aigp><aigp-tlv><metric>456</metric></aigp-tlv></aigp>" +
- "<unrecognized-attributes><partial>false</partial>" +
- "<transitive>false</transitive><type>1</type>" +
- "<value>QUJD</value></unrecognized-attributes>" +
- "<unrecognized-attributes><partial>true</partial>" +
- "<transitive>true</transitive><type>2</type>" +
- "<value>QUJD</value></unrecognized-attributes>" +
- "<unrecognized-attributes><partial>true</partial>" +
- "<transitive>false</transitive><type>3</type>" +
- "<value>QUJD</value></unrecognized-attributes>" +
- "<unrecognized-attributes><partial>false</partial>" +
- "<transitive>true</transitive><type>4</type>" +
- "<value>QUJD</value></unrecognized-attributes>" +
- "<bgp-parameters><optional-capabilities><c-parameters>" +
- "<as4-bytes-capability><as-number>11</as-number>" +
- "</as4-bytes-capability></c-parameters>" +
- "</optional-capabilities><optional-capabilities>" +
- "<c-parameters><as4-bytes-capability>" +
- "<as-number>22</as-number></as4-bytes-capability>" +
- "</c-parameters></optional-capabilities>" +
- "<optional-capabilities><c-parameters><as4-bytes-capability>" +
- "<as-number>33</as-number></as4-bytes-capability>" +
- "</c-parameters></optional-capabilities></bgp-parameters>" +
- "<bgp-parameters><optional-capabilities><c-parameters>" +
- "<as4-bytes-capability><as-number>11</as-number>" +
- "</as4-bytes-capability></c-parameters>" +
- "</optional-capabilities><optional-capabilities>" +
- "<c-parameters><as4-bytes-capability>" +
- "<as-number>22</as-number></as4-bytes-capability>" +
- "</c-parameters></optional-capabilities>" +
- "<optional-capabilities><c-parameters><as4-bytes-capability>" +
- "<as-number>33</as-number></as4-bytes-capability>" +
- "</c-parameters></optional-capabilities>" +
- "</bgp-parameters></attributes></Combined></filter>";
- }
-
- /**
- * Returns the xml string for ych-purchasingsupervisor module.
- *
- * @return the xml string for ych-purchasingsupervisor module
- */
- private static String purchaseXml() {
- return "<filter xmlns=\"ydt.filter-type\" type=\"subtree\">" +
- "<ych-purchasingsupervisor xmlns=\"ych.purchasing-supervisor\">" +
- "<ych-purchasing-supervisor operation=\"create\">" +
- "<ych-purchasing-specialist>purchasingSpecialist" +
- "</ych-purchasing-specialist>" +
- "<ych-purchasing-support>support</ych-purchasing-support>" +
- "</ych-purchasing-supervisor>" +
- "</ych-purchasingsupervisor>" +
- "</filter>";
- }
-
- /**
- * Returns the xml string for employeeid module.
- *
- * @return the xml string for employeeid module
- */
- private static String emplyIdXml() {
- return "<config xmlns=\"ydt.root\">" +
- "<employeeid xmlns=\"ydt.employee-id\">" +
- "<employeeid>Employ1</employeeid>" +
- "<employeeid>Employ5</employeeid>" +
- "<employeeid>Employ4</employeeid>" +
- "<employeeid>Employ3</employeeid>" +
- "<employeeid>Employ2</employeeid>" +
- "</employeeid>" +
- "</config>";
- }
-
- /**
- * Returns the xml string for warehousesupervisor module.
- *
- * @return the xml string for warehousesupervisor module
- */
- private static String wareHseXml() {
- return "<config xmlns=\"ydt.root\">" +
- "<warehousesupervisor xmlns=\"ydt.warehouse-supervisor\">" +
- "<supervisor>supervisor4</supervisor>" +
- "<supervisor>supervisor5</supervisor>" +
- "<supervisor>supervisor1</supervisor>" +
- "<supervisor>supervisor2</supervisor>" +
- "<supervisor>supervisor3</supervisor>" +
- "</warehousesupervisor>" +
- "</config>";
- }
-
- /**
- * Returns the xml string for more than one module.
- *
- * @return the xml string for more than one module
- */
- private static String multiModuleXml() {
- return "<config xmlns=\"ydt.root\">" +
- "<customssupervisor xmlns=\"ydt.customs-supervisor\">" +
- "<supervisor>Customssupervisor</supervisor>" +
- "</customssupervisor>" +
- "<merchandisersupervisor xmlns=\"ydt.Merchandiser-supervisor\">" +
- "<supervisor>Merchandisersupervisor</supervisor>" +
- "</merchandisersupervisor>" +
- "<materialsupervisor xmlns=\"ydt.material-supervisor\">" +
- "<supervisor>" +
- "<name>abc1</name>" +
- "<departmentId>xyz1</departmentId>" +
- "</supervisor>" +
- "<supervisor>" +
- "<name>abc2</name>" +
- "<departmentId>xyz2</departmentId>" +
- "</supervisor>" +
- "<supervisor>" +
- "<name>abc3</name>" +
- "<departmentId>xyz3</departmentId>" +
- "</supervisor>" +
- "<supervisor>" +
- "<name>abc4</name>" +
- "<departmentId>xyz4</departmentId>" +
- "</supervisor>" +
- "<supervisor>" +
- "<name>abc5</name>" +
- "<departmentId>xyz5</departmentId>" +
- "</supervisor>" +
- "</materialsupervisor>" +
- "<ych-purchasingsupervisor xmlns=\"ych.purchasing-supervisor\">" +
- "<ych-purchasing-supervisor>" +
- "<ych-purchasing-specialist>purchasingSpecialist" +
- "</ych-purchasing-specialist>" +
- "<ych-purchasing-support>support</ych-purchasing-support>" +
- "</ych-purchasing-supervisor>" +
- "</ych-purchasingsupervisor>" +
- "<warehousesupervisor xmlns=\"ydt.warehouse-supervisor\">" +
- "<supervisor>supervisor4</supervisor>" +
- "<supervisor>supervisor5</supervisor>" +
- "<supervisor>supervisor1</supervisor>" +
- "<supervisor>supervisor2</supervisor>" +
- "<supervisor>supervisor3</supervisor>" +
- "</warehousesupervisor>" +
- "<tradingsupervisor xmlns=\"ydt.trading-supervisor\">" +
- "<supervisor>Tradingsupervisor</supervisor>" +
- "</tradingsupervisor>" +
- "<employeeid xmlns=\"ydt.employee-id\">" +
- "<employeeid>Employ1</employeeid>" +
- "<employeeid>Employ5</employeeid>" +
- "<employeeid>Employ4</employeeid>" +
- "<employeeid>Employ3</employeeid>" +
- "<employeeid>Employ2</employeeid>" +
- "</employeeid>" +
- "</config>";
- }
-
- /**
- * Unit test case in which verifying xml string for module object with leaf
- * for composite encode.
- */
- @Test
- public void proceessCodecHandlerForCompositeEnc() {
- testYangSchemaNodeProvider.processSchemaRegistry(null);
- DefaultYangSchemaRegistry schemaRegistry = testYangSchemaNodeProvider
- .getDefaultYangSchemaRegistry();
-
- // Creating the object
- Object object = CustomssupervisorOpParam.builder()
- .supervisor("Customssupervisor").build();
-
- // Get the xml string and compare
- Map<String, String> tagAttr = new HashMap<String, String>();
- tagAttr.put("type", "subtree");
-
- YangCodecRegistry.initializeDefaultCodec();
- DefaultYangCodecHandler defaultYangCodecHandler =
- new DefaultYangCodecHandler(schemaRegistry);
- YangCompositeEncoding xml =
- defaultYangCodecHandler
- .encodeCompositeOperation("filter", "ydt.filter-type",
- object, XML, null);
-
- assertNull("customs-super: resource id not null",
- xml.getResourceIdentifier());
- assertEquals(AM_XML + "customs-super: comp res info",
- customsCompositeXml(), xml.getResourceInformation());
-
- // Creating the object
- object = MerchandisersupervisorOpParam.builder()
- .supervisor("Merchandisersupervisor").build();
-
- // Get the xml string and compare
- xml = defaultYangCodecHandler.encodeCompositeOperation("config",
- "ydt.root",
- object, XML,
- null);
- assertNull("merch-super: res id not null", xml.getResourceIdentifier());
- assertEquals(AM_XML + "merch-super: comp res info",
- merchandXml(), xml.getResourceInformation());
-
- // Creating the object
- object = TradingsupervisorOpParam.builder()
- .supervisor("Tradingsupervisor").build();
-
- // Get the xml string and compare
- xml = defaultYangCodecHandler
- .encodeCompositeOperation("config", "ydt.root", object, XML,
- null);
- assertNull("trading-super: res id not null",
- xml.getResourceIdentifier());
- assertEquals(AM_XML + "trading-super: comp res info",
- tradingXml(), xml.getResourceInformation());
- }
-
- /**
- * Unit test case in which verifying xml string for module object with leaf.
- */
- @Test
- public void proceessCodecHandlerForLeaf() {
- testYangSchemaNodeProvider.processSchemaRegistry(null);
- DefaultYangSchemaRegistry schemaRegistry = testYangSchemaNodeProvider
- .getDefaultYangSchemaRegistry();
- List<Object> yangModuleList = new ArrayList<>();
-
- // Creating the object
- Object object = CustomssupervisorOpParam.builder()
- .supervisor("Customssupervisor").build();
- yangModuleList.add(object);
-
- // Get the xml string and compare
- Map<String, String> tagAttr = new HashMap<String, String>();
- tagAttr.put("type", "subtree");
-
- YangCodecRegistry.initializeDefaultCodec();
- DefaultYangCodecHandler defaultYangCodecHandler =
- new DefaultYangCodecHandler(schemaRegistry);
- String xml =
- defaultYangCodecHandler.encodeOperation("filter",
- "ydt.filter-type",
- tagAttr, yangModuleList,
- XML, null);
-
- assertEquals(AM_XML + "customs-super: leaf info", customsXml(), xml);
-
- // Creating the object
- object = MerchandisersupervisorOpParam.builder()
- .supervisor("Merchandisersupervisor").build();
- yangModuleList.clear();
- yangModuleList.add(object);
-
- // Get the xml string and compare
- xml = defaultYangCodecHandler.encodeOperation("config", "ydt.root",
- null, yangModuleList,
- XML, null);
- assertEquals(AM_XML + "merchandiser-super: leaf info", merchandXml(),
- xml);
-
- // Creating the object
- object = TradingsupervisorOpParam.builder()
- .supervisor("Tradingsupervisor").build();
- yangModuleList.clear();
- yangModuleList.add(object);
-
- // Get the xml string and compare
- xml = defaultYangCodecHandler.encodeOperation("config", "ydt.root",
- null, yangModuleList,
- XML, null);
- assertEquals(AM_XML + "trading-super: leaf info", tradingXml(), xml);
- }
-
- /**
- * Unit test case in which verifying xml string for module object with
- * empty leaf.
- */
- @Test
- public void proceessCodecHandlerForEmptyLeaf() {
- testYangSchemaNodeProvider.processSchemaRegistry(null);
- DefaultYangSchemaRegistry schemaRegistry = testYangSchemaNodeProvider
- .getDefaultYangSchemaRegistry();
- List<Object> yangModuleList = new ArrayList<>();
-
- // Creating the object
- Object object = CustomssupervisorOpParam.builder().supervisor("")
- .build();
- yangModuleList.add(object);
-
- // Get the xml string and compare
- Map<String, String> tagAttr = new HashMap<String, String>();
- tagAttr.put("type", "subtree");
-
- YangCodecRegistry.initializeDefaultCodec();
- DefaultYangCodecHandler codecHandler =
- new DefaultYangCodecHandler(schemaRegistry);
- String xml = codecHandler.encodeOperation("filter", "ydt.filter-type",
- tagAttr, yangModuleList,
- XML, null);
-
- assertEquals(AM_XML + "customs-super: leaf is not empty",
- customsEmptyXml(), xml);
- }
-
- /**
- * Unit test case in which verifying xml string for module object with list.
- */
- @Test
- public void proceessCodecHandlerForList() {
- testYangSchemaNodeProvider.processSchemaRegistry(null);
- DefaultYangSchemaRegistry schemaRegistry =
- testYangSchemaNodeProvider.getDefaultYangSchemaRegistry();
- List<Object> yangModuleList = new ArrayList<>();
-
- // Creating the object
- Supervisor supervisor1 = new DefaultSupervisor.SupervisorBuilder()
- .name("abc1").departmentId("xyz1").build();
- Supervisor supervisor2 = new DefaultSupervisor.SupervisorBuilder()
- .name("abc2").departmentId("xyz2").build();
- Supervisor supervisor3 = new DefaultSupervisor.SupervisorBuilder()
- .name("abc3").departmentId("xyz3").build();
- Supervisor supervisor4 = new DefaultSupervisor.SupervisorBuilder()
- .name("abc4").departmentId("xyz4").build();
- Supervisor supervisor5 = new DefaultSupervisor.SupervisorBuilder()
- .name("abc5").departmentId("xyz5").build();
-
- Object object = MaterialsupervisorOpParam.builder()
- .addToSupervisor(supervisor1)
- .addToSupervisor(supervisor2)
- .addToSupervisor(supervisor3)
- .addToSupervisor(supervisor4)
- .addToSupervisor(supervisor5).build();
-
- yangModuleList.add(object);
-
- // Get the xml string and compare
- Map<String, String> tagAttr = new HashMap<String, String>();
- tagAttr.put("type", "subtree");
-
- YangCodecRegistry.initializeDefaultCodec();
- DefaultYangCodecHandler codecHandler =
- new DefaultYangCodecHandler(schemaRegistry);
- String xml = codecHandler.encodeOperation("filter", "ydt.filter-type",
- tagAttr, yangModuleList,
- XML, null);
- assertEquals(AM_XML + "material-super: list info", materialXml(), xml);
- }
-
- /**
- * Unit test case in which verifying xml string for module object with
- * empty container.
- */
- @Test
- public void proceessCodecHandlerForEmptyContainer() {
- testYangSchemaNodeProvider.processSchemaRegistry(null);
- DefaultYangSchemaRegistry schemaRegistry =
- testYangSchemaNodeProvider.getDefaultYangSchemaRegistry();
- List<Object> yangModuleList = new ArrayList<>();
-
- // Creating the object
- EmptyContainer emptyContainer = EmptyContainerOpParam.builder()
- .emptyContainer();
- Object object = EmptyContainerOpParam.builder()
- .emptyContainer(emptyContainer).build();
-
- yangModuleList.add(object);
-
- // Get the xml string and compare
- Map<String, String> tagAttr = new HashMap<String, String>();
- tagAttr.put("type", "subtree");
-
- YangCodecRegistry.initializeDefaultCodec();
- DefaultYangCodecHandler codecHandler =
- new DefaultYangCodecHandler(schemaRegistry);
- String xml = codecHandler.encodeOperation("filter", "ydt.filter-type",
- tagAttr, yangModuleList,
- XML, null);
- assertEquals(AM_XML + "empty-contain: container is not empty",
- containerEmptyXml(), xml);
- }
-
- /**
- * Unit test case in which verifying xml string for module object with list
- * inside list.
- */
- @Test
- public void proceessCodecHandlerForListInsideList() {
- testYangSchemaNodeProvider.processSchemaRegistry(null);
- DefaultYangSchemaRegistry schemaRegistry =
- testYangSchemaNodeProvider.getDefaultYangSchemaRegistry();
- List<Object> yangModuleList = new ArrayList<>();
-
- // Creating the object
- PathId pathId = new PathId(123);
- Origin origin = new DefaultOrigin.OriginBuilder().value(pathId)
- .build();
- MultiExitDisc multiExitDisc = new DefaultMultiExitDisc
- .MultiExitDiscBuilder().med(456).build();
- LocalPref localPref = new DefaultLocalPref.LocalPrefBuilder()
- .pref(23).build();
- Metric metric = new Metric(456);
- AigpTlv aigpTlv = new DefaultAigpTlv.AigpTlvBuilder().metric(metric)
- .build();
- Aigp aigp = new DefaultAigp.AigpBuilder().aigpTlv(aigpTlv).build();
-
- UnrecognizedAttributes unrecognizedAttributes1 =
- new DefaultUnrecognizedAttributes
- .UnrecognizedAttributesBuilder()
- .partial(false).transitive(false).type((short) 1)
- .value("ABC".getBytes()).build();
-
- UnrecognizedAttributes unrecognizedAttributes2 =
- new DefaultUnrecognizedAttributes
- .UnrecognizedAttributesBuilder()
- .partial(true).transitive(true).type((short) 2)
- .value("ABC".getBytes())
- .build();
-
- UnrecognizedAttributes unrecognizedAttributes3 =
- new DefaultUnrecognizedAttributes
- .UnrecognizedAttributesBuilder()
- .partial(true).transitive(false).type((short) 3)
- .value("ABC".getBytes())
- .build();
-
- UnrecognizedAttributes unrecognizedAttributes4 =
- new DefaultUnrecognizedAttributes
- .UnrecognizedAttributesBuilder()
- .partial(false).transitive(true).type((short) 4)
- .value("ABC".getBytes()).build();
-
- AsNum asNum1 = new AsNum(11);
- As4BytesCapability as4BytesCapability1 =
- new DefaultAs4BytesCapability.As4BytesCapabilityBuilder()
- .asNumber(asNum1).build();
- Cparameters cparameters1 = new DefaultCparameters.CparametersBuilder()
- .as4BytesCapability(as4BytesCapability1)
- .build();
- OptionalCapabilities optionalCapabilities1 =
- new DefaultOptionalCapabilities.OptionalCapabilitiesBuilder()
- .cParameters(cparameters1).build();
-
- AsNum asNum2 = new AsNum(22);
- As4BytesCapability as4BytesCapability2 =
- new DefaultAs4BytesCapability.As4BytesCapabilityBuilder()
- .asNumber(asNum2).build();
- Cparameters cparameters2 = new DefaultCparameters.CparametersBuilder()
- .as4BytesCapability(as4BytesCapability2)
- .build();
- OptionalCapabilities optionalCapabilities2 =
- new DefaultOptionalCapabilities.OptionalCapabilitiesBuilder()
- .cParameters(cparameters2).build();
-
- AsNum asNum3 = new AsNum(33);
- As4BytesCapability as4BytesCapability3 =
- new DefaultAs4BytesCapability.As4BytesCapabilityBuilder()
- .asNumber(asNum3).build();
- Cparameters cparameters3 = new DefaultCparameters.CparametersBuilder()
- .as4BytesCapability(as4BytesCapability3)
- .build();
- OptionalCapabilities optionalCapabilities3 =
- new DefaultOptionalCapabilities.OptionalCapabilitiesBuilder()
- .cParameters(cparameters3).build();
-
- BgpParameters bgpParameters1 =
- new DefaultBgpParameters.BgpParametersBuilder()
- .addToOptionalCapabilities(optionalCapabilities1)
- .addToOptionalCapabilities(optionalCapabilities2)
- .addToOptionalCapabilities(optionalCapabilities3)
- .build();
-
- AsNum asNum4 = new AsNum(11);
- As4BytesCapability as4BytesCapability4 = new DefaultAs4BytesCapability
- .As4BytesCapabilityBuilder()
- .asNumber(asNum4).build();
- Cparameters cparameters4 = new DefaultCparameters.CparametersBuilder()
- .as4BytesCapability(as4BytesCapability4)
- .build();
- OptionalCapabilities optionalCapabilities4 =
- new DefaultOptionalCapabilities.OptionalCapabilitiesBuilder()
- .cParameters(cparameters4).build();
-
- AsNum asNum5 = new AsNum(22);
- As4BytesCapability as4BytesCapability5 =
- new DefaultAs4BytesCapability.As4BytesCapabilityBuilder()
- .asNumber(asNum5).build();
- Cparameters cparameters5 =
- new DefaultCparameters.CparametersBuilder()
- .as4BytesCapability(as4BytesCapability5)
- .build();
- OptionalCapabilities optionalCapabilities5 =
- new DefaultOptionalCapabilities.OptionalCapabilitiesBuilder()
- .cParameters(cparameters5).build();
-
- AsNum asNum6 = new AsNum(33);
- As4BytesCapability as4BytesCapability6 =
- new DefaultAs4BytesCapability.As4BytesCapabilityBuilder()
- .asNumber(asNum6).build();
- Cparameters cparameters6 =
- new DefaultCparameters.CparametersBuilder()
- .as4BytesCapability(as4BytesCapability6)
- .build();
- OptionalCapabilities optionalCapabilities6 =
- new DefaultOptionalCapabilities.OptionalCapabilitiesBuilder()
- .cParameters(cparameters6).build();
-
- BgpParameters bgpParameters2 =
- new DefaultBgpParameters.BgpParametersBuilder()
- .addToOptionalCapabilities(optionalCapabilities4)
- .addToOptionalCapabilities(optionalCapabilities5)
- .addToOptionalCapabilities(optionalCapabilities6)
- .build();
-
- Attributes attributes = new DefaultAttributes.AttributesBuilder()
- .origin(origin)
- .multiExitDisc(multiExitDisc)
- .localPref(localPref)
- .aigp(aigp)
- .addToUnrecognizedAttributes(unrecognizedAttributes1)
- .addToUnrecognizedAttributes(unrecognizedAttributes2)
- .addToUnrecognizedAttributes(unrecognizedAttributes3)
- .addToUnrecognizedAttributes(unrecognizedAttributes4)
- .addToBgpParameters(bgpParameters1)
- .addToBgpParameters(bgpParameters2).build();
- Object object = CombinedOpParam.builder().attributes(attributes)
- .build();
-
- yangModuleList.add(object);
-
- // Get the xml string and compare
- Map<String, String> tagAttr = new HashMap<String, String>();
- tagAttr.put("type", "subtree");
-
- YangCodecRegistry.initializeDefaultCodec();
- DefaultYangCodecHandler codecHandler =
- new DefaultYangCodecHandler(schemaRegistry);
- String xml = codecHandler.encodeOperation("filter", "ydt.filter-type",
- tagAttr, yangModuleList,
- XML, null);
- assertEquals(AM_XML + "combined: list info", listTestXml(), xml);
- }
-
- /**
- * Unit test case in which verifying xml string for module object with
- * container.
- */
- @Test
- public void proceessCodecHandlerForContainer() {
- testYangSchemaNodeProvider.processSchemaRegistry(null);
- DefaultYangSchemaRegistry schemaRegistry =
- testYangSchemaNodeProvider.getDefaultYangSchemaRegistry();
- List<Object> yangModuleList = new ArrayList<>();
-
- // Creating the object
- YchPurchasingSupervisor supervisor =
- new DefaultYchPurchasingSupervisor
- .YchPurchasingSupervisorBuilder()
- .ychPurchasingSpecialist("purchasingSpecialist")
- .ychPurchasingSupport("support")
- .onosYangNodeOperationType(
- DefaultYchPurchasingSupervisor
- .OnosYangNodeOperationType
- .CREATE).build();
- Object object = YchPurchasingsupervisorOpParam.builder()
- .ychPurchasingSupervisor(supervisor).build();
- yangModuleList.add(object);
-
- // Get the xml string and compare
- Map<String, String> tagAttr = new HashMap<String, String>();
- tagAttr.put("type", "subtree");
-
- YangCodecRegistry.initializeDefaultCodec();
- DefaultYangCodecHandler codecHandler =
- new DefaultYangCodecHandler(schemaRegistry);
- String xml = codecHandler.encodeOperation("filter", "ydt.filter-type",
- tagAttr, yangModuleList,
- XML, null);
- assertEquals(AM_XML + "puchas-super: container info", purchaseXml(),
- xml);
- }
-
-
- /**
- * Unit test case in which verifying xml string for module object with
- * leaf list.
- */
- @Test
- public void proceessCodecHandlerForLeafList() {
- testYangSchemaNodeProvider.processSchemaRegistry(null);
- DefaultYangSchemaRegistry schemaRegistry =
- testYangSchemaNodeProvider.getDefaultYangSchemaRegistry();
- List<Object> yangModuleList = new ArrayList<>();
-
- // Creating the object
- EmployeeidOpParam.EmployeeidBuilder employeeidBuilder =
- EmployeeidOpParam.builder();
- employeeidBuilder.addToEmployeeid("Employ1");
- employeeidBuilder.addToEmployeeid("Employ2");
- employeeidBuilder.addToEmployeeid("Employ3");
- employeeidBuilder.addToEmployeeid("Employ4");
- employeeidBuilder.addToEmployeeid("Employ5");
-
- Object object = employeeidBuilder.build();
- yangModuleList.add(object);
-
- // Get the xml string and compare
- YangCodecRegistry.initializeDefaultCodec();
- DefaultYangCodecHandler codecHandler =
- new DefaultYangCodecHandler(schemaRegistry);
- String xml = codecHandler.encodeOperation("config", "ydt.root", null,
- yangModuleList, XML, null);
- assertEquals(AM_XML + "employ-id: leaf-list info", emplyIdXml(), xml);
- WarehousesupervisorOpParam.WarehousesupervisorBuilder warehsebldr =
- WarehousesupervisorOpParam.builder();
- warehsebldr.addToSupervisor("supervisor1");
- warehsebldr.addToSupervisor("supervisor2");
- warehsebldr.addToSupervisor("supervisor3");
- warehsebldr.addToSupervisor("supervisor4");
- warehsebldr.addToSupervisor("supervisor5");
-
- object = warehsebldr.build();
- yangModuleList.clear();
- yangModuleList.add(object);
-
-
- // Get the xml string and compare
- xml = codecHandler.encodeOperation("config", "ydt.root", null,
- yangModuleList, XML, null);
-
- assertEquals(AM_XML + "warehouse-super: leaf-list info", wareHseXml(),
- xml);
- }
-
- /**
- * Unit test case in which verifying xml string for multiple module object.
- */
- @Test
- public void proceessCodecHandlerForMultipleModule() {
- testYangSchemaNodeProvider.processSchemaRegistry(null);
- DefaultYangSchemaRegistry schemaRegistry =
- testYangSchemaNodeProvider.getDefaultYangSchemaRegistry();
-
- List<Object> yangModuleList = new ArrayList<>();
- YangCodecRegistry.initializeDefaultCodec();
- DefaultYangCodecHandler codecHandler =
- new DefaultYangCodecHandler(schemaRegistry);
-
- // Creating the object for customssupervisor module
- Object object = CustomssupervisorOpParam.builder()
- .supervisor("Customssupervisor").build();
- yangModuleList.add(object);
-
- // Creating the object for merchandisersupervisor module
- object = MerchandisersupervisorOpParam.builder()
- .supervisor("Merchandisersupervisor").build();
- yangModuleList.add(object);
-
- // Creating the object for materialsupervisor module
- Supervisor supervisor1 = new DefaultSupervisor.SupervisorBuilder()
- .name("abc1").departmentId("xyz1").build();
- Supervisor supervisor2 = new DefaultSupervisor.SupervisorBuilder()
- .name("abc2").departmentId("xyz2").build();
- Supervisor supervisor3 = new DefaultSupervisor.SupervisorBuilder()
- .name("abc3").departmentId("xyz3").build();
- Supervisor supervisor4 = new DefaultSupervisor.SupervisorBuilder()
- .name("abc4").departmentId("xyz4").build();
- Supervisor supervisor5 = new DefaultSupervisor.SupervisorBuilder()
- .name("abc5").departmentId("xyz5").build();
-
- object = MaterialsupervisorOpParam.builder()
- .addToSupervisor(supervisor1)
- .addToSupervisor(supervisor2)
- .addToSupervisor(supervisor3)
- .addToSupervisor(supervisor4)
- .addToSupervisor(supervisor5).build();
-
- yangModuleList.add(object);
-
- // Creating the object for YchPurchasingsupervisor module
- YchPurchasingSupervisor purSupervisor =
- new DefaultYchPurchasingSupervisor
- .YchPurchasingSupervisorBuilder()
- .ychPurchasingSpecialist("purchasingSpecialist")
- .ychPurchasingSupport("support").build();
- object = YchPurchasingsupervisorOpParam.builder()
- .ychPurchasingSupervisor(purSupervisor).build();
- yangModuleList.add(object);
-
- // Creating the object for warehousesupervisor module
- WarehousesupervisorOpParam.WarehousesupervisorBuilder warehsebldr =
- WarehousesupervisorOpParam.builder();
- warehsebldr.addToSupervisor("supervisor1");
- warehsebldr.addToSupervisor("supervisor2");
- warehsebldr.addToSupervisor("supervisor3");
- warehsebldr.addToSupervisor("supervisor4");
- warehsebldr.addToSupervisor("supervisor5");
-
- object = warehsebldr.build();
- yangModuleList.add(object);
-
- // Creating the object for tradingsupervisor module
- object = TradingsupervisorOpParam.builder()
- .supervisor("Tradingsupervisor").build();
- yangModuleList.add(object);
-
- List<String> employeeid = EmployeeidOpParam.builder().employeeid();
- if (employeeid == null) {
- employeeid = new ArrayList<>();
- }
- employeeid.add("Employ1");
- employeeid.add("Employ2");
- employeeid.add("Employ3");
- employeeid.add("Employ4");
- employeeid.add("Employ5");
-
- // Creating the object for employeeid module
- object = EmployeeidOpParam.builder().employeeid(employeeid).build();
- yangModuleList.add(object);
-
- // Get the xml string and compare
- String xml = codecHandler.encodeOperation("config", "ydt.root", null,
- yangModuleList, XML, null);
- assertEquals(AM_XML + "multiple: module info", multiModuleXml(), xml);
- }
-
- /**
- * Unit test case in which verifying object for xml string with config as
- * root name and empty container.
- */
- @Test
- public void proceessCodecDecodeFunctionForEmptyContainer() {
- String path = "src/test/resources/ychTestResourceFiles/getconfigemptycontainer.xml";
- StringBuilder sb = new StringBuilder();
- String sCurrentLine;
- testYangSchemaNodeProvider.processSchemaRegistry(null);
- DefaultYangSchemaRegistry schemaRegistry =
- testYangSchemaNodeProvider.getDefaultYangSchemaRegistry();
-
- YangCodecRegistry.initializeDefaultCodec();
- DefaultYangCodecHandler defaultYangCodecHandler =
- new DefaultYangCodecHandler(schemaRegistry);
-
- try (BufferedReader br = new BufferedReader(new FileReader(path))) {
-
- while ((sCurrentLine = br.readLine()) != null) {
- sb.append(sCurrentLine);
- }
-
- } catch (IOException e) {
- e.printStackTrace();
- }
-
- // Verify the received object list
- List<Object> objectList =
- defaultYangCodecHandler.decode(sb.toString(),
- XML, QUERY_CONFIG_REQUEST);
- Iterator<Object> iterator = objectList.iterator();
- while (iterator.hasNext()) {
- Object object = iterator.next();
- if (object.getClass().getSimpleName()
- .equals(EMPTY_CONTAINER)) {
- EmptyContainerOpParam emptyContainerOpParam =
- (EmptyContainerOpParam) object;
- assertNull(AM_OBJ + "empty-container: container value is not" +
- "null",
- emptyContainerOpParam.emptyContainer());
- } else {
- assertEquals(AM_OBJ, EMPTY_CONTAINER, object
- .getClass().getSimpleName());
- }
- }
- }
-
-
- /**
- * Unit test case in which verifying object for xml string with config as
- * root name and multiple module.
- */
- @Test
- public void proceessCodecDecodeFunctionForListInsideList() {
- String path = "src/test/resources/ychTestResourceFiles/combinedrootname.xml";
- StringBuilder sb = new StringBuilder();
- String sCurrentLine;
- testYangSchemaNodeProvider.processSchemaRegistry(null);
- DefaultYangSchemaRegistry schemaRegistry =
- testYangSchemaNodeProvider.getDefaultYangSchemaRegistry();
-
- YangCodecRegistry.initializeDefaultCodec();
- DefaultYangCodecHandler defaultYangCodecHandler =
- new DefaultYangCodecHandler(schemaRegistry);
-
- try (BufferedReader br = new BufferedReader(new FileReader(path))) {
-
- while ((sCurrentLine = br.readLine()) != null) {
- sb.append(sCurrentLine);
- }
-
- } catch (IOException e) {
- e.printStackTrace();
- }
-
- // TODO YOB and YTB need to do some changes for binary
- // Verify the received object list
- /*objectList = defaultYangCodecHandler.decode(sb.toString(),
- XML_ENCODING,
- EDIT_CONFIG_REQUEST);
- Iterator<Object> iterator = objectList.iterator();
- while (iterator.hasNext()) {
- Object object = iterator.next();
- if (object.getClass().getSimpleName().equals("CombinedOpParam")) {
- CombinedOpParam combinedOpParam = (CombinedOpParam) object;
-
- PathId pathId = new PathId(123);
- Origin origin = new DefaultOrigin.OriginBuilder()
- .value(pathId).build();
- assertTrue(combinedOpParam.attributes().origin()
- .equals(origin));
-
- MultiExitDisc multiExitDisc = new DefaultMultiExitDisc
- .MultiExitDiscBuilder().med(456).build();
- assertTrue(combinedOpParam.attributes().multiExitDisc()
- .equals(multiExitDisc));
-
- LocalPref localPref = new DefaultLocalPref.LocalPrefBuilder()
- .pref(23).build();
- assertTrue(combinedOpParam.attributes().localPref()
- .equals(localPref));
-
- Metric metric = new Metric(456);
- AigpTlv aigpTlv = new DefaultAigpTlv.AigpTlvBuilder()
- .metric(metric).build();
- Aigp aigp = new DefaultAigp.AigpBuilder().aigpTlv(aigpTlv)
- .build();
- assertTrue(combinedOpParam.attributes().aigp().equals(aigp));
-
- UnrecognizedAttributes unrecognizedAttributes1 =
- new DefaultUnrecognizedAttributes
- .UnrecognizedAttributesBuilder()
- .partial(false).transitive(false).type((short) 1)
- .value("ABC".getBytes()).build();
-
- UnrecognizedAttributes unrecognizedAttributes2 =
- new DefaultUnrecognizedAttributes
- .UnrecognizedAttributesBuilder()
- .partial(true).transitive(true).type((short) 2)
- .value("BCA".getBytes()).build();
-
- UnrecognizedAttributes unrecognizedAttributes3 =
- new DefaultUnrecognizedAttributes
- .UnrecognizedAttributesBuilder()
- .partial(true).transitive(false).type((short) 3)
- .value("CAB".getBytes()).build();
-
- UnrecognizedAttributes unrecognizedAttributes4 =
- new DefaultUnrecognizedAttributes
- .UnrecognizedAttributesBuilder()
- .partial(false).transitive(true).type((short) 4)
- .value("111".getBytes()).build();
-
- AsNum asNum1 = new AsNum(11);
- As4BytesCapability as4BytesCapability1 =
- new DefaultAs4BytesCapability
- .As4BytesCapabilityBuilder()
- .asNumber(asNum1).build();
- Cparameters cparameters1 = new DefaultCparameters
- .CparametersBuilder()
- .as4BytesCapability(as4BytesCapability1)
- .build();
- OptionalCapabilities optionalCapabilities1 =
- new DefaultOptionalCapabilities
- .OptionalCapabilitiesBuilder()
- .cParameters(cparameters1).build();
-
- AsNum asNum2 = new AsNum(22);
- As4BytesCapability as4BytesCapability2 =
- new DefaultAs4BytesCapability
- .As4BytesCapabilityBuilder()
- .asNumber(asNum2).build();
- Cparameters cparameters2 = new DefaultCparameters
- .CparametersBuilder()
- .as4BytesCapability(as4BytesCapability2)
- .build();
- OptionalCapabilities optionalCapabilities2 =
- new DefaultOptionalCapabilities
- .OptionalCapabilitiesBuilder()
- .cParameters(cparameters2).build();
-
- AsNum asNum3 = new AsNum(33);
- As4BytesCapability as4BytesCapability3 =
- new DefaultAs4BytesCapability
- .As4BytesCapabilityBuilder()
- .asNumber(asNum3).build();
- Cparameters cparameters3 =
- new DefaultCparameters.CparametersBuilder()
- .as4BytesCapability(as4BytesCapability3)
- .build();
- OptionalCapabilities optionalCapabilities3 =
- new DefaultOptionalCapabilities
- .OptionalCapabilitiesBuilder()
- .cParameters(cparameters3).build();
-
- BgpParameters bgpParameters1 =
- new DefaultBgpParameters.BgpParametersBuilder()
- .addToOptionalCapabilities(optionalCapabilities1)
- .addToOptionalCapabilities(optionalCapabilities2)
- .addToOptionalCapabilities(optionalCapabilities3)
- .build();
-
- AsNum asNum4 = new AsNum(11);
- As4BytesCapability as4BytesCapability4 =
- new DefaultAs4BytesCapability
- .As4BytesCapabilityBuilder()
- .asNumber(asNum4).build();
- Cparameters cparameters4 =
- new DefaultCparameters.CparametersBuilder()
- .as4BytesCapability(as4BytesCapability4)
- .build();
- OptionalCapabilities optionalCapabilities4 =
- new DefaultOptionalCapabilities
- .OptionalCapabilitiesBuilder()
- .cParameters(cparameters4).build();
-
- AsNum asNum5 = new AsNum(22);
- As4BytesCapability as4BytesCapability5 =
- new DefaultAs4BytesCapability
- .As4BytesCapabilityBuilder()
- .asNumber(asNum5).build();
- Cparameters cparameters5 =
- new DefaultCparameters.CparametersBuilder()
- .as4BytesCapability(as4BytesCapability5)
- .build();
- OptionalCapabilities optionalCapabilities5 =
- new DefaultOptionalCapabilities
- .OptionalCapabilitiesBuilder()
- .cParameters(cparameters5).build();
-
- AsNum asNum6 = new AsNum(33);
- As4BytesCapability as4BytesCapability6 =
- new DefaultAs4BytesCapability
- .As4BytesCapabilityBuilder()
- .asNumber(asNum6).build();
- Cparameters cparameters6 =
- new DefaultCparameters.CparametersBuilder()
- .as4BytesCapability(as4BytesCapability6)
- .build();
- OptionalCapabilities optionalCapabilities6 =
- new DefaultOptionalCapabilities
- .OptionalCapabilitiesBuilder()
- .cParameters(cparameters6).build();
-
- BgpParameters bgpParameters2 =
- new DefaultBgpParameters.BgpParametersBuilder()
- .addToOptionalCapabilities(optionalCapabilities4)
- .addToOptionalCapabilities(optionalCapabilities5)
- .addToOptionalCapabilities(optionalCapabilities6)
- .build();
-
- Attributes attributes =
- new DefaultAttributes.AttributesBuilder()
- .origin(origin)
- .multiExitDisc(multiExitDisc)
- .localPref(localPref)
- .aigp(aigp)
- .addToUnrecognizedAttributes(unrecognizedAttributes1)
- .addToUnrecognizedAttributes(unrecognizedAttributes2)
- .addToUnrecognizedAttributes(unrecognizedAttributes3)
- .addToUnrecognizedAttributes(unrecognizedAttributes4)
- .addToBgpParameters(bgpParameters1)
- .addToBgpParameters(bgpParameters2).build();
- } else {
- assertTrue(false);
- }
- }*/
- }
-
- /**
- * Unit test case in which verifying object for xml string with config as root name and
- * operation type.
- */
- @Test
- public void proceessCodecDecodeFunctionForOperTypeTest() {
- String path = "src/test/resources/ychTestResourceFiles/configrootnameOperationType.xml";
- testYangSchemaNodeProvider.processSchemaRegistry(null);
- DefaultYangSchemaRegistry schemaRegistry =
- testYangSchemaNodeProvider.getDefaultYangSchemaRegistry();
-
- YangCodecRegistry.initializeDefaultCodec();
- DefaultYangCodecHandler defaultYangCodecHandler =
- new DefaultYangCodecHandler(schemaRegistry);
-
- StringBuilder sb = new StringBuilder();
- String sCurrentLine;
-
- try (BufferedReader br = new BufferedReader(new FileReader(path))) {
-
- while ((sCurrentLine = br.readLine()) != null) {
- sb.append(sCurrentLine);
- }
-
- } catch (IOException e) {
- e.printStackTrace();
- }
-
- // Verify the received object list
- List<Object> objectList =
- defaultYangCodecHandler.decode(sb.toString(),
- XML, EDIT_CONFIG_REQUEST);
- Iterator<Object> iterator = objectList.iterator();
- while (iterator.hasNext()) {
- Object object = iterator.next();
- if (object.getClass().getSimpleName()
- .equals(LOGISTIC_MOD)) {
- LogisticsManagerOpParam logistics =
- (LogisticsManagerOpParam) object;
- DefaultPurchasingSupervisor purchasingSupervisor =
- (DefaultPurchasingSupervisor) logistics
- .purchasingSupervisor();
-
- assertEquals(AM_OBJ + "purchase-super: operation type", DELETE,
- purchasingSupervisor.onosYangNodeOperationType());
- assertEquals(AM_OBJ + "customs-super: leaf value", "abc",
- logistics.customsSupervisor());
- assertEquals(AM_OBJ + "purchase-spec: leaf value", "bcd",
- logistics.purchasingSupervisor()
- .purchasingSpecialist());
- assertEquals(AM_OBJ + "purchase-support: leaf value",
- "cde", logistics.purchasingSupervisor()
- .support());
-
- } else if (object.getClass().getSimpleName()
- .equals(MERCHA_MOD)) {
- MerchandisersupervisorOpParam merchandisersupervisorOpParam =
- (MerchandisersupervisorOpParam) object;
- assertEquals(AM_OBJ + "merchandiser-super: leaf value",
- "abc", merchandisersupervisorOpParam.supervisor());
- } else {
- assertEquals(AM_OBJ, LOGISTIC_MOD, object
- .getClass().getSimpleName());
- assertEquals(AM_OBJ, MERCHA_MOD, object
- .getClass().getSimpleName());
- }
- }
- }
-
- /**
- * Validate the leaf value for purchasing specialist.
- *
- * @param objectList object list
- */
- private void processPurchasingSpecObj(List<Object> objectList) {
- Iterator<Object> iterator = objectList.iterator();
- while (iterator.hasNext()) {
- Object object = iterator.next();
- if (object.getClass().getSimpleName()
- .equals("LogisticsManagerOpParam")) {
- LogisticsManagerOpParam logisticsManagerOpParam =
- (LogisticsManagerOpParam) object;
- assertEquals(AM_OBJ + "purchasing-spec: leaf value", "bcd",
- logisticsManagerOpParam.purchasingSupervisor()
- .purchasingSpecialist());
- } else {
- assertEquals(AM_OBJ, "LogisticsManagerOpParam", object
- .getClass().getSimpleName());
- }
- }
-
- }
-
- /**
- * Validate the leaf value for merchandiser supervisor.
- *
- * @param objectList object list
- */
- private void processMerchandiserObj(List<Object> objectList) {
- Iterator<Object> iterator = objectList.iterator();
- while (iterator.hasNext()) {
- Object object = iterator.next();
- if (object.getClass().getSimpleName()
- .equals(MERCHA_MOD)) {
- MerchandisersupervisorOpParam merchandisersupervisorOpParam =
- (MerchandisersupervisorOpParam) object;
- assertEquals(AM_OBJ + "merchandiser-super: leaf value", "abc",
- merchandisersupervisorOpParam.supervisor());
-
- } else {
- assertEquals(AM_OBJ, MERCHA_MOD, object
- .getClass().getSimpleName());
- }
- }
- }
-
- /**
- * Unit test case in which verifying object for xml string with get and
- * filter as root name.
- */
- @Test
- public void proceessCodecDecodeFunctionForGet() {
- String path = "src/test/resources/ychTestResourceFiles/getrootname.xml";
- testYangSchemaNodeProvider.processSchemaRegistry(null);
- DefaultYangSchemaRegistry schemaRegistry =
- testYangSchemaNodeProvider.getDefaultYangSchemaRegistry();
-
- YangCodecRegistry.initializeDefaultCodec();
- DefaultYangCodecHandler defaultYangCodecHandler =
- new DefaultYangCodecHandler(schemaRegistry);
-
- StringBuilder sb = new StringBuilder();
- String sCurrentLine;
-
- try (BufferedReader br = new BufferedReader(new FileReader(path))) {
-
- while ((sCurrentLine = br.readLine()) != null) {
- sb.append(sCurrentLine);
- }
-
- } catch (IOException e) {
- e.printStackTrace();
- }
-
- // Verify the received object list
- List<Object> objectList =
- defaultYangCodecHandler.decode(sb.toString(),
- XML, QUERY_REQUEST);
- processPurchasingSpecObj(objectList);
- }
-
- /**
- * Unit test case in which verifying object for xml string with get-config
- * and filter as root name.
- */
- @Test
- public void proceessCodecDecodeFunctionForGetConfig() {
- String path = "src/test/resources/ychTestResourceFiles/getconfigrootname.xml";
- testYangSchemaNodeProvider.processSchemaRegistry(null);
- DefaultYangSchemaRegistry schemaRegistry =
- testYangSchemaNodeProvider.getDefaultYangSchemaRegistry();
-
- YangCodecRegistry.initializeDefaultCodec();
- DefaultYangCodecHandler defaultYangCodecHandler =
- new DefaultYangCodecHandler(schemaRegistry);
-
- StringBuilder sb = new StringBuilder();
- String sCurrentLine;
-
- try (BufferedReader br = new BufferedReader(new FileReader(path))) {
-
- while ((sCurrentLine = br.readLine()) != null) {
- sb.append(sCurrentLine);
- }
-
- } catch (IOException e) {
- e.printStackTrace();
- }
-
- // Verify the received object list
- List<Object> objectList = defaultYangCodecHandler.decode(
- sb.toString(),
- XML, QUERY_CONFIG_REQUEST);
- processMerchandiserObj(objectList);
- }
-
- /**
- * Unit test case in which verifying object for xml string with data as
- * root name.
- */
- @Test
- public void proceessCodecDecodeFunctionForGetData() {
- String path = "src/test/resources/ychTestResourceFiles/getReply.xml";
- testYangSchemaNodeProvider.processSchemaRegistry(null);
- DefaultYangSchemaRegistry schemaRegistry =
- testYangSchemaNodeProvider.getDefaultYangSchemaRegistry();
-
- YangCodecRegistry.initializeDefaultCodec();
- DefaultYangCodecHandler defaultYangCodecHandler =
- new DefaultYangCodecHandler(schemaRegistry);
-
- StringBuilder sb = new StringBuilder();
- String sCurrentLine;
-
- try (BufferedReader br = new BufferedReader(new FileReader(path))) {
-
- while ((sCurrentLine = br.readLine()) != null) {
- sb.append(sCurrentLine);
- }
-
- } catch (IOException e) {
- e.printStackTrace();
- }
-
- // Verify the received object list
- List<Object> objectList = defaultYangCodecHandler.decode(
- sb.toString(),
- XML, QUERY_CONFIG_REQUEST);
- processPurchasingSpecObj(objectList);
- }
-
- /**
- * Unit test case in which verifying object for xml string with rpc-reply
- * and data as root name .
- */
- @Test
- public void proceessCodecDecodeFunctionForGetConfigData() {
- String path = "src/test/resources/ychTestResourceFiles/getconfigReply.xml";
- testYangSchemaNodeProvider.processSchemaRegistry(null);
- DefaultYangSchemaRegistry schemaRegistry =
- testYangSchemaNodeProvider.getDefaultYangSchemaRegistry();
-
- YangCodecRegistry.initializeDefaultCodec();
- DefaultYangCodecHandler defaultYangCodecHandler =
- new DefaultYangCodecHandler(schemaRegistry);
-
- StringBuilder sb = new StringBuilder();
- String sCurrentLine;
-
- try (BufferedReader br = new BufferedReader(new FileReader(path))) {
-
- while ((sCurrentLine = br.readLine()) != null) {
- sb.append(sCurrentLine);
- }
-
- } catch (IOException e) {
- e.printStackTrace();
- }
-
- // Verify the received object list
- List<Object> objectList = defaultYangCodecHandler.decode(sb.toString(),
- XML, null);
- processMerchandiserObj(objectList);
- }
-}
\ No newline at end of file
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
deleted file mode 100644
index 8fd5580..0000000
--- a/apps/yms/app/src/test/java/org/onosproject/yms/app/ydt/AugmentTest.java
+++ /dev/null
@@ -1,528 +0,0 @@
-/*
- * 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
deleted file mode 100644
index 7f058a9..0000000
--- a/apps/yms/app/src/test/java/org/onosproject/yms/app/ydt/FoodArenaTest.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * 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
deleted file mode 100644
index 0befc4d..0000000
--- a/apps/yms/app/src/test/java/org/onosproject/yms/app/ydt/IetfNetworkTest.java
+++ /dev/null
@@ -1,120 +0,0 @@
-/*
- * 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
deleted file mode 100644
index c757b0c..0000000
--- a/apps/yms/app/src/test/java/org/onosproject/yms/app/ydt/IetfTopologyTest.java
+++ /dev/null
@@ -1,268 +0,0 @@
-/*
- * 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
deleted file mode 100644
index 711f882..0000000
--- a/apps/yms/app/src/test/java/org/onosproject/yms/app/ydt/ListTest.java
+++ /dev/null
@@ -1,450 +0,0 @@
-/*
- * 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
deleted file mode 100644
index a64c4c4..0000000
--- a/apps/yms/app/src/test/java/org/onosproject/yms/app/ydt/LogisticsManagerTest.java
+++ /dev/null
@@ -1,179 +0,0 @@
-/*
- * 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
deleted file mode 100644
index 84c99fd..0000000
--- a/apps/yms/app/src/test/java/org/onosproject/yms/app/ydt/MockYangSchemaRegistry.java
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- * 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.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) {
- }
-
- @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
deleted file mode 100644
index 8ca52c1..0000000
--- a/apps/yms/app/src/test/java/org/onosproject/yms/app/ydt/RpcTest.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * 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
deleted file mode 100644
index 5446b51..0000000
--- a/apps/yms/app/src/test/java/org/onosproject/yms/app/ydt/YdtBitTest.java
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * 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
deleted file mode 100644
index 505c640..0000000
--- a/apps/yms/app/src/test/java/org/onosproject/yms/app/ydt/YdtBooleanTest.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * 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
deleted file mode 100644
index 1d15d04..0000000
--- a/apps/yms/app/src/test/java/org/onosproject/yms/app/ydt/YdtDecimal64Test.java
+++ /dev/null
@@ -1,193 +0,0 @@
-/*
- * 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
deleted file mode 100644
index ea5ee34..0000000
--- a/apps/yms/app/src/test/java/org/onosproject/yms/app/ydt/YdtEmptyTest.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * 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
deleted file mode 100644
index 77c2f81..0000000
--- a/apps/yms/app/src/test/java/org/onosproject/yms/app/ydt/YdtEnumTest.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
- * 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
deleted file mode 100644
index 172732b..0000000
--- a/apps/yms/app/src/test/java/org/onosproject/yms/app/ydt/YdtInteger16Test.java
+++ /dev/null
@@ -1,392 +0,0 @@
-/*
- * 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
deleted file mode 100644
index dd40ef5..0000000
--- a/apps/yms/app/src/test/java/org/onosproject/yms/app/ydt/YdtInteger32Test.java
+++ /dev/null
@@ -1,390 +0,0 @@
-/*
- * 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
deleted file mode 100644
index 136381d..0000000
--- a/apps/yms/app/src/test/java/org/onosproject/yms/app/ydt/YdtInteger64Test.java
+++ /dev/null
@@ -1,397 +0,0 @@
-/*
- * 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
deleted file mode 100644
index 0658f26..0000000
--- a/apps/yms/app/src/test/java/org/onosproject/yms/app/ydt/YdtInteger8Test.java
+++ /dev/null
@@ -1,389 +0,0 @@
-/*
- * 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
deleted file mode 100644
index daa5ce3..0000000
--- a/apps/yms/app/src/test/java/org/onosproject/yms/app/ydt/YdtTestConstants.java
+++ /dev/null
@@ -1,138 +0,0 @@
-/*
- * 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
deleted file mode 100644
index f375c1a..0000000
--- a/apps/yms/app/src/test/java/org/onosproject/yms/app/ydt/YdtTestUtils.java
+++ /dev/null
@@ -1,1792 +0,0 @@
-/*
- * 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/java/org/onosproject/yms/app/ymsm/MockCoreService.java b/apps/yms/app/src/test/java/org/onosproject/yms/app/ymsm/MockCoreService.java
deleted file mode 100644
index 62f00aa..0000000
--- a/apps/yms/app/src/test/java/org/onosproject/yms/app/ymsm/MockCoreService.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * 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.ymsm;
-
-import org.onosproject.core.ApplicationId;
-import org.onosproject.core.CoreService;
-import org.onosproject.core.IdGenerator;
-import org.onosproject.core.Version;
-
-import java.util.Set;
-import java.util.concurrent.atomic.AtomicLong;
-
-/**
- * Represents implementation of CoreService interfaces.
- */
-public class MockCoreService implements CoreService {
- @Override
- public Version version() {
- return null;
- }
-
- @Override
- public Set<ApplicationId> getAppIds() {
- return null;
- }
-
- @Override
- public ApplicationId getAppId(Short id) {
- return null;
- }
-
- @Override
- public ApplicationId getAppId(String name) {
- return null;
- }
-
- @Override
- public ApplicationId registerApplication(String name) {
- return null;
- }
-
- @Override
- public ApplicationId registerApplication(String name,
- Runnable preDeactivate) {
- return null;
- }
-
- @Override
- public IdGenerator getIdGenerator(String topic) {
- return new IdGenerator() {
- private AtomicLong counter = new AtomicLong(0);
-
- @Override
- public long getNewId() {
- return counter.getAndIncrement();
- }
- };
- }
-}
diff --git a/apps/yms/app/src/test/java/org/onosproject/yms/app/ymsm/MockOverriddenDataTreeCodec.java b/apps/yms/app/src/test/java/org/onosproject/yms/app/ymsm/MockOverriddenDataTreeCodec.java
deleted file mode 100644
index 73fddbf..0000000
--- a/apps/yms/app/src/test/java/org/onosproject/yms/app/ymsm/MockOverriddenDataTreeCodec.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * 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.ymsm;
-
-import org.onosproject.yms.app.ych.YchException;
-import org.onosproject.yms.ych.YangCompositeEncoding;
-import org.onosproject.yms.ych.YangDataTreeCodec;
-import org.onosproject.yms.ydt.YdtBuilder;
-import org.onosproject.yms.ydt.YmsOperationType;
-
-/**
- * Represents implementation of overridden YANG data tree codec interfaces.
- */
-public class MockOverriddenDataTreeCodec implements YangDataTreeCodec {
- private static final String PREFIX = "OverriddenDataTreeCodec ";
- private static final String ENCODE = PREFIX +
- "encodeYdtToProtocolFormat Called.";
- private static final String COMPOSITE_ENCODE = PREFIX +
- "encodeYdtToCompositeProtocolFormat Called.";
- private static final String DECODE = PREFIX +
- "decodeProtocolDataToYdt Called.";
- private static final String COMPOSITE_DECODE = PREFIX +
- "decodeCompositeProtocolDataToYdt Called.";
-
- @Override
- public String encodeYdtToProtocolFormat(YdtBuilder ydtBuilder) {
-
- throw new YchException(ENCODE);
- }
-
- @Override
- public YangCompositeEncoding encodeYdtToCompositeProtocolFormat(
- YdtBuilder ydtBuilder) {
-
- throw new YchException(COMPOSITE_ENCODE);
- }
-
- @Override
- public YdtBuilder decodeProtocolDataToYdt(String protocolData,
- Object schemaRegistryForYdt,
- YmsOperationType proOper) {
-
- throw new YchException(DECODE);
- }
-
- @Override
- public YdtBuilder decodeCompositeProtocolDataToYdt(
- YangCompositeEncoding protocolData,
- Object schemaRegistryForYdt,
- YmsOperationType proOper) {
-
- throw new YchException(COMPOSITE_DECODE);
- }
-}
diff --git a/apps/yms/app/src/test/java/org/onosproject/yms/app/ymsm/MockRegisteredDataTreeCodec.java b/apps/yms/app/src/test/java/org/onosproject/yms/app/ymsm/MockRegisteredDataTreeCodec.java
deleted file mode 100644
index 84117e7..0000000
--- a/apps/yms/app/src/test/java/org/onosproject/yms/app/ymsm/MockRegisteredDataTreeCodec.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * 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.ymsm;
-
-import org.onosproject.yms.app.ych.YchException;
-import org.onosproject.yms.ych.YangCompositeEncoding;
-import org.onosproject.yms.ych.YangDataTreeCodec;
-import org.onosproject.yms.ydt.YdtBuilder;
-import org.onosproject.yms.ydt.YmsOperationType;
-
-/**
- * Represents implementation of YANG SBI broker interfaces.
- */
-public class MockRegisteredDataTreeCodec implements YangDataTreeCodec {
- private static final String PREFIX = "RegisteredDataTreeCodec ";
- private static final String ENCODE = PREFIX +
- "encodeYdtToProtocolFormat Called.";
- private static final String COMPOSITE_ENCODE = PREFIX +
- "encodeYdtToCompositeProtocolFormat Called.";
- private static final String DECODE = PREFIX +
- "decodeProtocolDataToYdt Called.";
- private static final String COMPOSITE_DECODE = PREFIX +
- "decodeCompositeProtocolDataToYdt Called.";
-
- @Override
- public String encodeYdtToProtocolFormat(YdtBuilder ydtBuilder) {
- throw new YchException(ENCODE);
- }
-
- @Override
- public YangCompositeEncoding encodeYdtToCompositeProtocolFormat(
- YdtBuilder ydtBuilder) {
-
- throw new YchException(COMPOSITE_ENCODE);
- }
-
- @Override
- public YdtBuilder decodeProtocolDataToYdt(String protocolData,
- Object schemaRegistry,
- YmsOperationType proOper) {
-
- throw new YchException(DECODE);
- }
-
- @Override
- public YdtBuilder decodeCompositeProtocolDataToYdt(
- YangCompositeEncoding protocolData,
- Object schemaRegistry,
- YmsOperationType proOper) {
-
- throw new YchException(COMPOSITE_DECODE);
- }
-}
diff --git a/apps/yms/app/src/test/java/org/onosproject/yms/app/ymsm/MockYangCompositeEncoding.java b/apps/yms/app/src/test/java/org/onosproject/yms/app/ymsm/MockYangCompositeEncoding.java
deleted file mode 100644
index 1f52da6..0000000
--- a/apps/yms/app/src/test/java/org/onosproject/yms/app/ymsm/MockYangCompositeEncoding.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * 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.ymsm;
-
-import org.onosproject.yms.ych.YangCompositeEncoding;
-import org.onosproject.yms.ych.YangResourceIdentifierType;
-
-/**
- * Represents implementation of YangCompositeEncoding interfaces.
- */
-public class MockYangCompositeEncoding implements YangCompositeEncoding {
- /**
- * Resource identifier for composite encoding.
- */
- private String resourceIdentifier;
-
- /**
- * Resource information for composite encoding.
- */
- private String resourceInformation;
-
- /**
- * Resource identifier type.
- */
- private YangResourceIdentifierType resourceIdentifierType;
-
- /**
- * Sets resource identifier.
- *
- * @param resIdentifier resource identifier
- */
- public void setResourceIdentifier(String resIdentifier) {
- resourceIdentifier = resIdentifier;
- }
-
- /**
- * Sets the resource information.
- *
- * @param resInformation resource information
- */
- public void setResourceInformation(String resInformation) {
- resourceInformation = resInformation;
- }
-
- /**
- * Sets the resource identifier type.
- *
- * @param resIdent resource identifier
- */
- public void setResourceIdentifierType(YangResourceIdentifierType resIdent) {
- resourceIdentifierType = resIdent;
- }
-
- @Override
- public String getResourceIdentifier() {
- return resourceIdentifier;
- }
-
- @Override
- public YangResourceIdentifierType getResourceIdentifierType() {
- return resourceIdentifierType;
- }
-
- @Override
- public String getResourceInformation() {
- return resourceInformation;
- }
-}
diff --git a/apps/yms/app/src/test/java/org/onosproject/yms/app/ymsm/YchCompositeHandlerTest.java b/apps/yms/app/src/test/java/org/onosproject/yms/app/ymsm/YchCompositeHandlerTest.java
deleted file mode 100644
index 794298e..0000000
--- a/apps/yms/app/src/test/java/org/onosproject/yms/app/ymsm/YchCompositeHandlerTest.java
+++ /dev/null
@@ -1,288 +0,0 @@
-/*
- * 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.ymsm;
-
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
-import org.onosproject.yang.gen.v1.ydt.customs.supervisor.rev20160524.CustomssupervisorOpParam;
-import org.onosproject.yms.app.ych.defaultcodecs.YangCodecRegistry;
-import org.onosproject.yms.app.ysr.TestYangSchemaNodeProvider;
-import org.onosproject.yms.ych.YangCodecHandler;
-import org.onosproject.yms.ych.YangCompositeEncoding;
-import org.onosproject.yms.ych.YangDataTreeCodec;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import static junit.framework.TestCase.assertNotNull;
-import static org.onosproject.yms.ych.YangProtocolEncodingFormat.XML;
-
-/**
- * Unit test case for YCH composite codec handler.
- */
-public class YchCompositeHandlerTest {
- @Rule
- public ExpectedException thrown = ExpectedException.none();
-
- private static final String REG_PREFIX = "RegisteredDataTreeCodec ";
- private static final String REG_ENCODE = REG_PREFIX +
- "encodeYdtToProtocolFormat Called.";
- private static final String REG_DECODE = REG_PREFIX +
- "decodeProtocolDataToYdt Called.";
- private static final String REG_COMPO_ENCODE = REG_PREFIX +
- "encodeYdtToCompositeProtocolFormat Called.";
- private static final String REG_COMPO_DECODE = REG_PREFIX +
- "decodeCompositeProtocolDataToYdt Called.";
- private static final String OVERRIDE_PREFIX = "OverriddenDataTreeCodec ";
- private static final String OVERRIDE_ENCODE = OVERRIDE_PREFIX +
- "encodeYdtToProtocolFormat Called.";
- private static final String OVERRIDE_DECODE = OVERRIDE_PREFIX +
- "decodeProtocolDataToYdt Called.";
- private static final String OVERRIDE_COMPO_ENCODE = OVERRIDE_PREFIX +
- "encodeYdtToCompositeProtocolFormat Called.";
- private static final String OVERRIDE_COMPO_DECODE = OVERRIDE_PREFIX +
- "decodeCompositeProtocolDataToYdt Called.";
-
- private TestYangSchemaNodeProvider provider =
- new TestYangSchemaNodeProvider();
-
- /**
- * Unit test case in which verifying codec handler is null or not.
- */
- @Test
- public void checkForCodecHandler() {
- YmsManager ymsManager = new YmsManager();
- ymsManager.coreService = new MockCoreService();
- ymsManager.activate();
- YangCodecHandler yangCodecHandler = ymsManager.getYangCodecHandler();
- assertNotNull("Codec handler is null", yangCodecHandler);
- }
-
- /**
- * Unit test case in which verifying registered codec handler for encode is
- * null or not.
- */
- @Test
- public void checkForRegisterDefaultCodecEncode() {
- thrown.expectMessage(REG_ENCODE);
- YangDataTreeCodec yangDataTreeCodec = new MockRegisteredDataTreeCodec();
- YmsManager ymsManager = new YmsManager();
- YangCodecRegistry.initializeDefaultCodec();
- ymsManager.coreService = new MockCoreService();
- ymsManager.activate();
- ymsManager.registerDefaultCodec(yangDataTreeCodec, XML);
- YangCodecHandler yangCodecHandler = ymsManager.getYangCodecHandler();
- assertNotNull("Codec handler is null", yangCodecHandler);
-
- provider.processSchemaRegistry(null);
- List<Object> yangModuleList = new ArrayList<>();
-
- // Creating the object
- Object object = CustomssupervisorOpParam.builder()
- .supervisor("Customssupervisor").build();
- yangModuleList.add(object);
-
- // Get the xml string and compare
- Map<String, String> tagAttr = new HashMap<String, String>();
- tagAttr.put("type", "subtree");
-
- yangCodecHandler.encodeOperation("filter", "ydt.filter-type",
- tagAttr, yangModuleList,
- XML, null);
- }
-
- /**
- * Unit test case in which verifying registered codec handler for decode is
- * null or not.
- */
- @Test
- public void checkForRegisterDefaultCodecDecode() {
- thrown.expectMessage(REG_DECODE);
- YangDataTreeCodec yangDataTreeCodec = new MockRegisteredDataTreeCodec();
- YmsManager ymsManager = new YmsManager();
- YangCodecRegistry.initializeDefaultCodec();
- ymsManager.coreService = new MockCoreService();
- ymsManager.activate();
- ymsManager.registerDefaultCodec(yangDataTreeCodec, XML);
- YangCodecHandler yangCodecHandler = ymsManager.getYangCodecHandler();
- assertNotNull("Codec handler is null", yangCodecHandler);
-
- provider.processSchemaRegistry(null);
- yangCodecHandler.decode("XML String", XML, null);
- }
-
- /**
- * Unit test case in which verifying registered codec handler for
- * composite encode is null or not.
- */
- @Test
- public void checkForRegisterDefaultCodecCompEncode() {
- thrown.expectMessage(REG_COMPO_ENCODE);
- YangDataTreeCodec yangDataTreeCodec = new MockRegisteredDataTreeCodec();
- YmsManager ymsManager = new YmsManager();
- YangCodecRegistry.initializeDefaultCodec();
- ymsManager.coreService = new MockCoreService();
- ymsManager.activate();
- ymsManager.registerDefaultCodec(yangDataTreeCodec, XML);
- YangCodecHandler yangCodecHandler = ymsManager.getYangCodecHandler();
- assertNotNull("Codec handler is null", yangCodecHandler);
-
- provider.processSchemaRegistry(null);
- // Creating the object
- Object object = CustomssupervisorOpParam.builder()
- .supervisor("Customssupervisor").build();
-
- yangCodecHandler.encodeCompositeOperation("filter",
- "ydt.filter-type", object,
- XML, null);
- }
-
- /**
- * Unit test case in which verifying registered codec handler for
- * composite decode is null or not.
- */
- @Test
- public void checkForRegisterDefaultCodecCompDecode() {
- thrown.expectMessage(REG_COMPO_DECODE);
- YangDataTreeCodec yangDataTreeCodec = new MockRegisteredDataTreeCodec();
- YmsManager ymsManager = new YmsManager();
- YangCodecRegistry.initializeDefaultCodec();
- ymsManager.coreService = new MockCoreService();
- ymsManager.activate();
- ymsManager.registerDefaultCodec(yangDataTreeCodec, XML);
- YangCodecHandler yangCodecHandler = ymsManager.getYangCodecHandler();
- assertNotNull("Codec handler is null", yangCodecHandler);
-
- provider.processSchemaRegistry(null);
- // Creating the object
- YangCompositeEncoding yangCompositeEncoding =
- new MockYangCompositeEncoding();
- yangCodecHandler.decode(yangCompositeEncoding, XML, null);
- }
-
- /**
- * Unit test case in which verifying overridden codec handler for encode is
- * null or not.
- */
- @Test
- public void checkForOverriddenDataTreeCodecEncode() {
- thrown.expectMessage(OVERRIDE_ENCODE);
- YangDataTreeCodec yangDataTreeCodec = new MockRegisteredDataTreeCodec();
- YmsManager ymsManager = new YmsManager();
- ymsManager.coreService = new MockCoreService();
- ymsManager.activate();
- ymsManager.registerDefaultCodec(yangDataTreeCodec, XML);
- YangCodecHandler yangCodecHandler = ymsManager.getYangCodecHandler();
- assertNotNull("Codec handler is null", yangCodecHandler);
-
- YangDataTreeCodec overriddenCodec = new MockOverriddenDataTreeCodec();
- yangCodecHandler.registerOverriddenCodec(overriddenCodec, XML);
-
- provider.processSchemaRegistry(null);
- List<Object> yangModuleList = new ArrayList<>();
-
- // Creating the object
- Object object = CustomssupervisorOpParam.builder()
- .supervisor("Customssupervisor").build();
- yangModuleList.add(object);
-
- // Get the xml string and compare
- Map<String, String> tagAttr = new HashMap<String, String>();
- tagAttr.put("type", "subtree");
- yangCodecHandler.encodeOperation("filter", "ydt.filter-type",
- tagAttr, yangModuleList,
- XML, null);
- }
-
- /**
- * Unit test case in which verifying overridden codec handler for decode is
- * null or not.
- */
- @Test
- public void checkForOverriddenDataTreeCodecDecode() {
- thrown.expectMessage(OVERRIDE_DECODE);
- YangDataTreeCodec yangDataTreeCodec = new MockRegisteredDataTreeCodec();
- YmsManager ymsManager = new YmsManager();
- ymsManager.coreService = new MockCoreService();
- ymsManager.activate();
- ymsManager.registerDefaultCodec(yangDataTreeCodec, XML);
- YangCodecHandler yangCodecHandler = ymsManager.getYangCodecHandler();
- assertNotNull("Codec handler is null", yangCodecHandler);
-
- YangDataTreeCodec overriddenCodec = new MockOverriddenDataTreeCodec();
- yangCodecHandler.registerOverriddenCodec(overriddenCodec, XML);
-
- provider.processSchemaRegistry(null);
- yangCodecHandler.decode("XML String", XML, null);
- }
-
- /**
- * Unit test case in which verifying overridden codec handler for
- * composite encode is null or not.
- */
- @Test
- public void checkForOverriddenDataTreeCodecCompoEncode() {
- thrown.expectMessage(OVERRIDE_COMPO_ENCODE);
- YangDataTreeCodec yangDataTreeCodec = new MockRegisteredDataTreeCodec();
- YmsManager ymsManager = new YmsManager();
- ymsManager.coreService = new MockCoreService();
- ymsManager.activate();
- ymsManager.registerDefaultCodec(yangDataTreeCodec, XML);
- YangCodecHandler yangCodecHandler = ymsManager.getYangCodecHandler();
- assertNotNull("Codec handler is null", yangCodecHandler);
-
- YangDataTreeCodec overriddenCodec = new MockOverriddenDataTreeCodec();
- yangCodecHandler.registerOverriddenCodec(overriddenCodec, XML);
-
- provider.processSchemaRegistry(null);
- // Creating the object
- Object object = CustomssupervisorOpParam.builder()
- .supervisor("Customssupervisor").build();
- yangCodecHandler.encodeCompositeOperation("filter",
- "ydt.filter-type",
- object,
- XML, null);
- }
-
- /**
- * Unit test case in which verifying overridden codec handler for
- * composite decode is null or not.
- */
- @Test
- public void checkForOverriddenDataTreeCodecCompoDecode() {
- thrown.expectMessage(OVERRIDE_COMPO_DECODE);
- YangDataTreeCodec yangDataTreeCodec = new MockRegisteredDataTreeCodec();
- YmsManager ymsManager = new YmsManager();
- ymsManager.coreService = new MockCoreService();
- ymsManager.activate();
- ymsManager.registerDefaultCodec(yangDataTreeCodec, XML);
- YangCodecHandler yangCodecHandler = ymsManager.getYangCodecHandler();
- assertNotNull("Codec handler is null", yangCodecHandler);
-
- YangDataTreeCodec overriddenCodec = new MockOverriddenDataTreeCodec();
- yangCodecHandler.registerOverriddenCodec(overriddenCodec, XML);
-
- provider.processSchemaRegistry(null);
- // Verify the received object list
- YangCompositeEncoding yangCompositeEncoding =
- new MockYangCompositeEncoding();
- yangCodecHandler.decode(yangCompositeEncoding, XML, null);
- }
-}
diff --git a/apps/yms/app/src/test/java/org/onosproject/yms/app/yob/YobAugmentTest.java b/apps/yms/app/src/test/java/org/onosproject/yms/app/yob/YobAugmentTest.java
deleted file mode 100644
index a50d3a5..0000000
--- a/apps/yms/app/src/test/java/org/onosproject/yms/app/yob/YobAugmentTest.java
+++ /dev/null
@@ -1,132 +0,0 @@
-/*
- * Copyright (c) 2016. Lorem ipsum dolor sit amet, consectetur adipiscing elit.
- * Morbi non lorem porttitor neque feugiat blandit. Ut vitae ipsum eget quam lacinia accumsan.
- * Etiam sed turpis ac ipsum condimentum fringilla. Maecenas magna.
- * Proin dapibus sapien vel ante. Aliquam erat volutpat. Pellentesque sagittis ligula eget metus.
- * Vestibulum commodo. Ut rhoncus gravida arcu.
- */
-
-package org.onosproject.yms.app.yob;
-
-import org.junit.Test;
-import org.onosproject.yang.gen.v1.urn.ip.topo.rev20140101.ymsiptopology.node.AugmentedTopoNode;
-import org.onosproject.yang.gen.v1.urn.ip.topo.rev20140101.ymsiptopology.node.DefaultAugmentedTopoNode;
-import org.onosproject.yang.gen.v1.urn.topo.rev20140101.YmsTopologyOpParam;
-import org.onosproject.yang.gen.v1.urn.topo.rev20140101.ymstopology.DefaultNode;
-import org.onosproject.yms.app.ydt.YangRequestWorkBench;
-import org.onosproject.yms.app.ydt.YdtExtendedContext;
-import org.onosproject.yms.ydt.YdtContext;
-
-import java.io.IOException;
-
-import static org.hamcrest.core.Is.is;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertThat;
-import static org.onosproject.yms.app.yob.YobTestUtils.NODE;
-import static org.onosproject.yms.app.yob.YobTestUtils.ROOT_DATA_RESOURCE;
-import static org.onosproject.yms.app.yob.YobTestUtils.ROUTER_ID;
-import static org.onosproject.yms.app.yob.YobTestUtils.ROUTER_IP;
-import static org.onosproject.yms.app.yob.YobTestUtils.STR_LEAF_VALUE;
-import static org.onosproject.yms.app.yob.YobTestUtils.TOPOLOGY;
-import static org.onosproject.yms.ydt.YdtContextOperationType.NONE;
-
-/**
- * Test the YANG object building for the YANG data tree based on the non
- * schema augmented nodes.
- */
-public class YobAugmentTest {
-
- private YobTestUtils utils = YobTestUtils.instance();
-
- @Test
- public void augmentedLeaf() throws IOException {
-
- YangRequestWorkBench ydtBuilder = new YangRequestWorkBench(
- ROOT_DATA_RESOURCE, null, null, utils.schemaRegistry(),
- true);
-
- ydtBuilder.addChild(TOPOLOGY, null, NONE);
- ydtBuilder.addChild(NODE, null);
- ydtBuilder.addLeaf(ROUTER_ID, "urn:ip:topo", STR_LEAF_VALUE);
-
- YdtContext logicalRoot = ydtBuilder.getRootNode();
- YdtExtendedContext appRoot =
- (YdtExtendedContext) logicalRoot.getFirstChild();
-
- DefaultYobBuilder yobBuilder = new DefaultYobBuilder();
- Object yangObject = yobBuilder.getYangObject(appRoot,
- utils.schemaRegistry());
- assertNotNull("Fail to create augmented YANG object", yangObject);
-
- assertEquals("invalid augmented node created", YmsTopologyOpParam.class,
- yangObject.getClass());
-
- YmsTopologyOpParam topology = (YmsTopologyOpParam) yangObject;
- assertNotNull("failed to build augmented node", topology.node());
- assertEquals("Single node entry is expected", 1, topology.node().size());
- assertEquals("Node type is not DefaultNode", DefaultNode.class,
- topology.node().get(0).getClass());
-
- DefaultNode node = (DefaultNode) topology.node().get(0);
- assertNotNull("Augmented info is missing", node.yangAugmentedInfo(
- AugmentedTopoNode.class));
- assertEquals("Augmented class is incorrect",
- DefaultAugmentedTopoNode.class,
- node.yangAugmentedInfo(AugmentedTopoNode.class)
- .getClass());
-
- DefaultAugmentedTopoNode augmentedNode = (DefaultAugmentedTopoNode)
- node.yangAugmentedInfo(AugmentedTopoNode.class);
- assertThat("Augmented leaf value is incorrect",
- augmentedNode.routerId(), is(STR_LEAF_VALUE));
- }
-
- @Test
- public void augmentedLeaves() throws IOException {
-
- YangRequestWorkBench ydtBuilder = new YangRequestWorkBench(
- ROOT_DATA_RESOURCE, null, null, utils.schemaRegistry(),
- true);
-
- ydtBuilder.addChild(TOPOLOGY, null, NONE);
- ydtBuilder.addChild(NODE, null);
- ydtBuilder.addLeaf(ROUTER_ID, "urn:ip:topo", STR_LEAF_VALUE);
- ydtBuilder.traverseToParent();
- ydtBuilder.addLeaf(ROUTER_IP, "urn:ip:topo", STR_LEAF_VALUE);
-
- YdtContext logicalRoot = ydtBuilder.getRootNode();
- YdtExtendedContext appRoot =
- (YdtExtendedContext) logicalRoot.getFirstChild();
-
- DefaultYobBuilder yobBuilder = new DefaultYobBuilder();
- Object yangObject = yobBuilder.getYangObject(appRoot,
- utils.schemaRegistry());
- assertNotNull("Fail to create augmented YANG object", yangObject);
-
- assertEquals("invalid augmented node created",
- YmsTopologyOpParam.class, yangObject.getClass());
-
- YmsTopologyOpParam topology = (YmsTopologyOpParam) yangObject;
- assertNotNull("failed to build augmented node", topology.node());
- assertEquals("Single node entry is expected", 1,
- topology.node().size());
- assertEquals("Node type is not DefaultNode", DefaultNode.class,
- topology.node().get(0).getClass());
-
- DefaultNode node = (DefaultNode) topology.node().get(0);
- assertNotNull("Augmented info is missing", node.yangAugmentedInfo(
- AugmentedTopoNode.class));
- assertEquals("Augmented class is incorrect",
- DefaultAugmentedTopoNode.class,
- node.yangAugmentedInfo(AugmentedTopoNode.class)
- .getClass());
-
- DefaultAugmentedTopoNode augmentedNode = (DefaultAugmentedTopoNode)
- node.yangAugmentedInfo(AugmentedTopoNode.class);
- assertThat("Augmented router id is incorrect",
- augmentedNode.routerId(), is(STR_LEAF_VALUE));
- assertThat("Augmented router ip is incorrect",
- augmentedNode.routerIp(), is(STR_LEAF_VALUE));
- }
-}
diff --git a/apps/yms/app/src/test/java/org/onosproject/yms/app/yob/YobBinaryTest.java b/apps/yms/app/src/test/java/org/onosproject/yms/app/yob/YobBinaryTest.java
deleted file mode 100644
index a749874..0000000
--- a/apps/yms/app/src/test/java/org/onosproject/yms/app/yob/YobBinaryTest.java
+++ /dev/null
@@ -1,174 +0,0 @@
-/*
- * 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.yob;
-
-import org.junit.Test;
-import org.onosproject.yang.gen.v1.ydt.binarytest.rev20160524.BinarytestOpParam;
-import org.onosproject.yang.gen.v1.ydt.binarytest.rev20160524.binarytest.cont1.AugmentedCont1;
-import org.onosproject.yang.gen.v1.ydt.binarytest.rev20160524.binarytest.food.snack.Sportsarena;
-import org.onosproject.yms.app.ydt.YangRequestWorkBench;
-import org.onosproject.yms.app.ydt.YdtExtendedContext;
-import org.onosproject.yms.ydt.YdtContext;
-
-import java.io.IOException;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.core.IsNull.notNullValue;
-import static org.onosproject.yms.app.yob.YobTestUtils.ROOT_DATA_RESOURCE;
-
-/**
- * Test the YANG object building for the YANG data tree based on the binary.
- */
-public class YobBinaryTest {
-
- private YobTestUtils utils = YobTestUtils.instance();
-
- @Test
- public void testBinaryInLeaf() throws IOException {
- YangRequestWorkBench ydtBuilder = new YangRequestWorkBench(
- ROOT_DATA_RESOURCE, null, null, utils.schemaRegistry(), true);
- ydtBuilder.addChild("binarytest", "ydt.binarytest");
- ydtBuilder.addChild("binaryList", null);
- ydtBuilder.addLeaf("binary", null, "YmluYXJ5");
- ydtBuilder.traverseToParent();
- ydtBuilder.traverseToParent();
- ydtBuilder.traverseToParent();
- YdtContext rootCtx = ydtBuilder.getRootNode();
- YdtContext childCtx = rootCtx.getFirstChild();
- DefaultYobBuilder builder = new DefaultYobBuilder();
- Object yangObject = builder.getYangObject(
- (YdtExtendedContext) childCtx, utils.schemaRegistry());
- assertThat(yangObject, notNullValue());
- BinarytestOpParam binarytestOpParam = ((BinarytestOpParam) yangObject);
-
- byte[] binaryValue = binarytestOpParam.binaryList().get(0).binary();
- String value = new String(binaryValue);
- assertThat(value, is("binary"));
- }
-
- @Test
- public void testBinaryInTypedef() throws IOException {
- YangRequestWorkBench ydtBuilder = new YangRequestWorkBench(
- ROOT_DATA_RESOURCE, null, null, utils.schemaRegistry(), true);
- ydtBuilder.addChild("binarytest", "ydt.binarytest");
- ydtBuilder.addLeaf("name", null, "YmluYXJ5");
- ydtBuilder.traverseToParent();
- ydtBuilder.traverseToParent();
- YdtContext rootCtx = ydtBuilder.getRootNode();
- YdtContext childCtx = rootCtx.getFirstChild();
- DefaultYobBuilder builder = new DefaultYobBuilder();
- Object yangObject = builder.getYangObject(
- (YdtExtendedContext) childCtx, utils.schemaRegistry());
- assertThat(yangObject, notNullValue());
- BinarytestOpParam binarytestOpParam = ((BinarytestOpParam) yangObject);
-
- byte[] binaryValue = binarytestOpParam.name().binary();
- String value = new String(binaryValue);
- assertThat(value, is("binary"));
- }
-
- @Test
- public void testBinaryInGrouping() throws IOException {
- YangRequestWorkBench ydtBuilder = new YangRequestWorkBench(
- ROOT_DATA_RESOURCE, null, null, utils.schemaRegistry(), true);
- ydtBuilder.addChild("binarytest", "ydt.binarytest");
- ydtBuilder.addChild("cont1", "ydt.binarytest");
- ydtBuilder.addLeaf("surname", null, "YmluYXJ5");
- ydtBuilder.traverseToParent();
- ydtBuilder.traverseToParent();
- YdtContext rootCtx = ydtBuilder.getRootNode();
- YdtContext childCtx = rootCtx.getFirstChild();
- DefaultYobBuilder builder = new DefaultYobBuilder();
- Object yangObject = builder.getYangObject(
- (YdtExtendedContext) childCtx, utils.schemaRegistry());
- assertThat(yangObject, notNullValue());
- BinarytestOpParam binarytestOpParam = ((BinarytestOpParam) yangObject);
-
- byte[] binaryValue = binarytestOpParam.cont1().surname();
- String value = new String(binaryValue);
- assertThat(value, is("binary"));
- }
-
- @Test
- public void testBinaryInAugment() throws IOException {
- YangRequestWorkBench ydtBuilder = new YangRequestWorkBench(
- ROOT_DATA_RESOURCE, null, null, utils.schemaRegistry(), true);
- ydtBuilder.addChild("binarytest", "ydt.binarytest");
- ydtBuilder.addChild("cont1", "ydt.binarytest");
- ydtBuilder.addLeaf("lastname", null, "YmluYXJ5");
- ydtBuilder.traverseToParent();
- ydtBuilder.traverseToParent();
- YdtContext rootCtx = ydtBuilder.getRootNode();
- YdtContext childCtx = rootCtx.getFirstChild();
- DefaultYobBuilder builder = new DefaultYobBuilder();
- Object yangObject = builder.getYangObject(
- (YdtExtendedContext) childCtx, utils.schemaRegistry());
- assertThat(yangObject, notNullValue());
- BinarytestOpParam binarytestOpParam = ((BinarytestOpParam) yangObject);
-
- AugmentedCont1 augmentedCont1 = (AugmentedCont1) binarytestOpParam.cont1()
- .yangAugmentedInfo(AugmentedCont1.class);
- byte[] binaryValue = augmentedCont1.lastname();
- String value = new String(binaryValue);
- assertThat(value, is("binary"));
- }
-
- @Test
- public void testBinaryInCase() throws IOException {
- YangRequestWorkBench ydtBuilder = new YangRequestWorkBench(
- ROOT_DATA_RESOURCE, null, null, utils.schemaRegistry(), true);
- ydtBuilder.addChild("binarytest", "ydt.binarytest");
- ydtBuilder.addChild("food", "ydt.binarytest");
- ydtBuilder.addLeaf("pretzel", null, "YmluYXJ5");
- ydtBuilder.traverseToParent();
- ydtBuilder.traverseToParent();
- YdtContext rootCtx = ydtBuilder.getRootNode();
- YdtContext childCtx = rootCtx.getFirstChild();
- DefaultYobBuilder builder = new DefaultYobBuilder();
- Object yangObject = builder.getYangObject(
- (YdtExtendedContext) childCtx, utils.schemaRegistry());
- assertThat(yangObject, notNullValue());
- BinarytestOpParam binarytestOpParam = ((BinarytestOpParam) yangObject);
- Sportsarena sportsArena = ((Sportsarena) binarytestOpParam.food()
- .snack());
- byte[] binaryValue = sportsArena.pretzel();
- String value = new String(binaryValue);
- assertThat(value, is("binary"));
- }
-
- @Test
- public void testBinaryInUnion() throws IOException {
- YangRequestWorkBench ydtBuilder = new YangRequestWorkBench(
- ROOT_DATA_RESOURCE, null, null, utils.schemaRegistry(), true);
- ydtBuilder.addChild("binarytest", "ydt.binarytest");
- ydtBuilder.addLeaf("middlename", null, "YmluYXJ5");
- ydtBuilder.traverseToParent();
- ydtBuilder.traverseToParent();
- YdtContext rootCtx = ydtBuilder.getRootNode();
- YdtContext childCtx = rootCtx.getFirstChild();
- DefaultYobBuilder builder = new DefaultYobBuilder();
- Object yangObject = builder.getYangObject(
- (YdtExtendedContext) childCtx, utils.schemaRegistry());
- assertThat(yangObject, notNullValue());
- BinarytestOpParam binarytestOpParam = ((BinarytestOpParam) yangObject);
-
- byte[] binaryValue = binarytestOpParam.middlename().binary();
- String value = new String(binaryValue);
- assertThat(value, is("binary"));
- }
-}
diff --git a/apps/yms/app/src/test/java/org/onosproject/yms/app/yob/YobBitTest.java b/apps/yms/app/src/test/java/org/onosproject/yms/app/yob/YobBitTest.java
deleted file mode 100644
index 6b4b526..0000000
--- a/apps/yms/app/src/test/java/org/onosproject/yms/app/yob/YobBitTest.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * 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.yob;
-
-import org.junit.Test;
-
-import java.io.IOException;
-
-public class YobBitTest {
-
-/*
- BINARY
-
- Positive scenario
- input with position 0
- input with position 1
- input with position 2
-*/
-
-
- @Test
- public void positiveTest() throws IOException {
-
- //TODO for getYangObject
- }
-}
diff --git a/apps/yms/app/src/test/java/org/onosproject/yms/app/yob/YobBooleanTest.java b/apps/yms/app/src/test/java/org/onosproject/yms/app/yob/YobBooleanTest.java
deleted file mode 100644
index 83ce3f6..0000000
--- a/apps/yms/app/src/test/java/org/onosproject/yms/app/yob/YobBooleanTest.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * 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.yob;
-
-import org.junit.Test;
-import org.onosproject.yms.app.ydt.YangRequestWorkBench;
-import org.onosproject.yms.app.ydt.YdtExtendedContext;
-import org.onosproject.yms.app.ydt.YdtTestUtils;
-import org.onosproject.yms.ydt.YdtContext;
-
-import java.lang.reflect.Field;
-import java.util.List;
-
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-public class YobBooleanTest {
-
- private static final String BOOLEAN_LIST = "booleanList";
- private static final String AUTO_PREFIX_BOOLEAN = "yangAutoPrefixBoolean";
-
- /*
- BOOLEAN
- Positive scenario
- input with in true and false
- */
- @Test
- public void positiveTest() {
- YangRequestWorkBench defaultYdtBuilder = YdtTestUtils.booleanYdt();
- validateYangObject(defaultYdtBuilder);
- }
-
- private void validateYangObject(YangRequestWorkBench defaultYdtBuilder) {
-
- YdtContext rootCtx = defaultYdtBuilder.getRootNode();
-
- YdtContext childCtx = rootCtx.getFirstChild();
-
- DefaultYobBuilder builder = new DefaultYobBuilder();
-
- Object yangObject = builder.getYangObject(
- (YdtExtendedContext) childCtx, YdtTestUtils
- .getSchemaRegistry());
- assertNotNull(yangObject);
- try {
-
- Field field = yangObject.getClass().getDeclaredField(BOOLEAN_LIST);
- field.setAccessible(true);
- List booleanList = (List) field.get(yangObject);
- Field invalidInterval = booleanList.get(0).getClass()
- .getDeclaredField(AUTO_PREFIX_BOOLEAN);
- invalidInterval.setAccessible(true);
- assertTrue((boolean) invalidInterval.get(booleanList.get(0)));
- assertFalse((boolean) invalidInterval.get(booleanList.get(1)));
- } catch (NoSuchFieldException | IllegalAccessException e) {
- fail("No such field or illegal access exception: " + e);
- }
- }
-}
diff --git a/apps/yms/app/src/test/java/org/onosproject/yms/app/yob/YobChoiceTest.java b/apps/yms/app/src/test/java/org/onosproject/yms/app/yob/YobChoiceTest.java
deleted file mode 100644
index 305d7bf..0000000
--- a/apps/yms/app/src/test/java/org/onosproject/yms/app/yob/YobChoiceTest.java
+++ /dev/null
@@ -1,255 +0,0 @@
-/*
- * 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.yob;
-
-import org.junit.Test;
-import org.onosproject.yang.gen.v1.urn.topo.rev20140101.YmsTopologyOpParam;
-import org.onosproject.yang.gen.v1.urn.topo.rev20140101.ymstopology.DefaultNode;
-import org.onosproject.yang.gen.v1.urn.topo.rev20140101.ymstopology.Node;
-import org.onosproject.yang.gen.v1.urn.topo.rev20140101.ymstopology.node.choice1.Case1a;
-import org.onosproject.yang.gen.v1.urn.topo.rev20140101.ymstopology.node.choice1.Case1b;
-import org.onosproject.yang.gen.v1.urn.topo.rev20140101.ymstopology.node.choice1.DefaultCase1a;
-import org.onosproject.yang.gen.v1.urn.topo.rev20140101.ymstopology.node.choice1.DefaultCase1b;
-import org.onosproject.yang.gen.v1.urn.topo.rev20140101.ymstopology.node.choice1.case1b.choice1b.Case1Bi;
-import org.onosproject.yang.gen.v1.urn.topo.rev20140101.ymstopology.node.choice1.case1b.choice1b.DefaultCase1Bi;
-import org.onosproject.yms.app.ydt.YangRequestWorkBench;
-import org.onosproject.yms.app.ydt.YdtExtendedContext;
-import org.onosproject.yms.ydt.YdtContext;
-
-import java.io.IOException;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.onosproject.yms.app.yob.YobTestUtils.LEAF_1A1;
-import static org.onosproject.yms.app.yob.YobTestUtils.LEAF_1A2;
-import static org.onosproject.yms.app.yob.YobTestUtils.LEAF_1BIA;
-import static org.onosproject.yms.app.yob.YobTestUtils.LEAF_1BIB;
-import static org.onosproject.yms.app.yob.YobTestUtils.NODE;
-import static org.onosproject.yms.app.yob.YobTestUtils.ROOT_DATA_RESOURCE;
-import static org.onosproject.yms.app.yob.YobTestUtils.STR_LEAF_VALUE;
-import static org.onosproject.yms.app.yob.YobTestUtils.TOPOLOGY;
-import static org.onosproject.yms.ydt.YdtContextOperationType.NONE;
-
-/**
- * Test the YANG object building for the YANG data tree based on the non
- * schema choice and case nodes.
- */
-public class YobChoiceTest {
-
- private YobTestUtils utils = YobTestUtils.instance();
-
- @Test
- public void caseInChoice() throws IOException {
-
- YangRequestWorkBench ydtBuilder = new YangRequestWorkBench(
- ROOT_DATA_RESOURCE, null, null, utils.schemaRegistry(),
- true);
-
- ydtBuilder.addChild(TOPOLOGY, null, NONE);
- ydtBuilder.addChild(NODE, null);
- ydtBuilder.addLeaf(LEAF_1A1, null, STR_LEAF_VALUE);
-
- YdtContext logicalRoot = ydtBuilder.getRootNode();
- YdtExtendedContext appRoot =
- (YdtExtendedContext) logicalRoot.getFirstChild();
-
- DefaultYobBuilder yobBuilder = new DefaultYobBuilder();
- Object yangObject = yobBuilder.getYangObject(appRoot,
- utils.schemaRegistry());
- assertNotNull(yangObject);
- assertEquals("YANG object created is not topology object",
- YmsTopologyOpParam.class, yangObject.getClass());
-
- YmsTopologyOpParam topology = (YmsTopologyOpParam) yangObject;
- assertNotNull("Failed to build the object", topology.node());
- assertEquals("Single node entry is expected", 1,
- topology.node().size());
- assertEquals("Node type is not DefaultNode", DefaultNode.class,
- topology.node().get(0).getClass());
-
- Node node = topology.node().get(0);
- assertNotNull("choice1 is not set in node", node.choice1());
- assertEquals("choice 1 type is not ", DefaultCase1a.class,
- node.choice1().getClass());
-
- Case1a case1a = (Case1a) node.choice1();
- assertNotNull("leaf1a1 is not set in case", case1a.leaf1A1());
- assertEquals("leaf1a1 type is not correct", String.class,
- case1a.leaf1A1().getClass());
- assertEquals("leaf1a1 value is not correct", STR_LEAF_VALUE,
- case1a.leaf1A1());
-
- }
-
- @Test
- public void caseWithMultiAttribute() throws IOException {
-
- YangRequestWorkBench ydtBuilder = new YangRequestWorkBench(
- ROOT_DATA_RESOURCE, null, null, utils.schemaRegistry(),
- true);
-
- ydtBuilder.addChild(TOPOLOGY, null, NONE);
- ydtBuilder.addChild(NODE, null);
- ydtBuilder.addLeaf(LEAF_1A1, null, STR_LEAF_VALUE);
- ydtBuilder.traverseToParent();
- ydtBuilder.addLeaf(LEAF_1A2, null, STR_LEAF_VALUE);
-
- YdtContext logicalRoot = ydtBuilder.getRootNode();
- YdtExtendedContext appRoot =
- (YdtExtendedContext) logicalRoot.getFirstChild();
-
- DefaultYobBuilder yobBuilder = new DefaultYobBuilder();
- Object yangObject = yobBuilder.getYangObject(appRoot,
- utils.schemaRegistry());
- assertNotNull(yangObject);
- assertEquals("YANG object created is not topology object",
- YmsTopologyOpParam.class, yangObject.getClass());
-
- YmsTopologyOpParam topology = (YmsTopologyOpParam) yangObject;
- assertNotNull("Failed to build the object", topology.node());
- assertEquals("Single node entry is expected", 1,
- topology.node().size());
- assertEquals("Node type is not DefaultNode", DefaultNode.class,
- topology.node().get(0).getClass());
-
- Node node = topology.node().get(0);
- assertNotNull("choice1 is not set in node", node.choice1());
- assertEquals("choice 1 type is not ", DefaultCase1a.class,
- node.choice1().getClass());
-
- Case1a case1a = (Case1a) node.choice1();
- assertNotNull("leaf1a1 is not set in case", case1a.leaf1A1());
- assertEquals("leaf1a1 type is not correct", String.class,
- case1a.leaf1A1().getClass());
- assertEquals("leaf1a1 value is not correct", STR_LEAF_VALUE,
- case1a.leaf1A1());
-
- assertNotNull("leaf1a2 is not set in case", case1a.leaf1A2());
- assertEquals("leaf1a2 type is not correct", String.class,
- case1a.leaf1A2().getClass());
- assertEquals("leaf1a1 value is not correct", STR_LEAF_VALUE,
- case1a.leaf1A1());
-
- }
-
- @Test
- public void recursiveChoice() throws IOException {
-
- YangRequestWorkBench ydtBuilder = new YangRequestWorkBench(
- ROOT_DATA_RESOURCE, null, null, utils.schemaRegistry(),
- true);
-
- ydtBuilder.addChild(TOPOLOGY, null, NONE);
- ydtBuilder.addChild(NODE, null);
- ydtBuilder.addLeaf(LEAF_1BIA, null, STR_LEAF_VALUE);
-
- YdtContext logicalRoot = ydtBuilder.getRootNode();
- YdtExtendedContext appRoot =
- (YdtExtendedContext) logicalRoot.getFirstChild();
-
- DefaultYobBuilder yobBuilder = new DefaultYobBuilder();
- Object yangObject = yobBuilder.getYangObject(appRoot,
- utils.schemaRegistry());
- assertNotNull(yangObject);
- assertEquals("YANG object created is not topology object",
- YmsTopologyOpParam.class, yangObject.getClass());
-
- YmsTopologyOpParam topology = (YmsTopologyOpParam) yangObject;
- assertNotNull("Failed to build the object", topology.node());
- assertEquals("Single node entry is expected", 1,
- topology.node().size());
- assertEquals("Node type is not DefaultNode", DefaultNode.class,
- topology.node().get(0).getClass());
-
- Node node = topology.node().get(0);
- assertNotNull("Choice 1 is not set in Node", node.choice1());
- assertEquals("Choice 1 is not of type DefaultCase1b",
- DefaultCase1b.class, node.choice1().getClass());
-
- Case1b case1b = (Case1b) node.choice1();
- assertNotNull("Case1b does not have child choice1b ",
- case1b.choice1b());
- assertEquals("choice1b is not of type DefaultCase1Bi",
- DefaultCase1Bi.class, case1b.choice1b().getClass());
-
- Case1Bi case1Bi = (Case1Bi) case1b.choice1b();
- assertNotNull("leaf1bia is not set", case1Bi.leaf1Bia());
- assertEquals("leaf1bia type is not string", String.class,
- case1Bi.leaf1Bia().getClass());
- assertEquals("leaf1bia value is wrong", STR_LEAF_VALUE,
- case1Bi.leaf1Bia());
- }
-
- @Test
- public void recursiveChoiceWithMultipleAttribute() throws IOException {
-
- YangRequestWorkBench ydtBuilder = new YangRequestWorkBench(
- ROOT_DATA_RESOURCE, null, null, utils.schemaRegistry(),
- true);
-
- ydtBuilder.addChild(TOPOLOGY, null, NONE);
- ydtBuilder.addChild(NODE, null);
- ydtBuilder.addLeaf(LEAF_1BIA, null, STR_LEAF_VALUE);
- ydtBuilder.traverseToParent();
- ydtBuilder.addLeaf(LEAF_1BIB, null, STR_LEAF_VALUE);
-
-
- YdtContext logicalRoot = ydtBuilder.getRootNode();
- YdtExtendedContext appRoot =
- (YdtExtendedContext) logicalRoot.getFirstChild();
-
- DefaultYobBuilder yobBuilder = new DefaultYobBuilder();
- Object yangObject = yobBuilder.getYangObject(appRoot,
- utils.schemaRegistry());
- assertNotNull(yangObject);
- assertEquals("YANG object created is not topology object",
- YmsTopologyOpParam.class, yangObject.getClass());
-
- YmsTopologyOpParam topology = (YmsTopologyOpParam) yangObject;
- assertNotNull("Failed to build the object", topology.node());
- assertEquals("Single node entry is expected", 1,
- topology.node().size());
- assertEquals("Node type is not DefaultNode", DefaultNode.class,
- topology.node().get(0).getClass());
-
- Node node = topology.node().get(0);
- assertNotNull("Choice 1 is not set in Node", node.choice1());
- assertEquals("Choice 1 is not of type DefaultCase1b",
- DefaultCase1b.class,
- node.choice1().getClass());
-
- Case1b case1b = (Case1b) node.choice1();
- assertNotNull("Case1b does not have child choice1b ",
- case1b.choice1b());
- assertEquals("choice1b is not of type DefaultCase1Bi",
- DefaultCase1Bi.class,
- case1b.choice1b().getClass());
-
- Case1Bi case1Bi = (Case1Bi) case1b.choice1b();
- assertNotNull("leaf1bia is not set", case1Bi.leaf1Bia());
- assertEquals("leaf1bia type is not string", String.class,
- case1Bi.leaf1Bia().getClass());
- assertEquals("leaf1bia value is wrong", STR_LEAF_VALUE,
- case1Bi.leaf1Bia());
-
- assertNotNull("leaf1bib is not set", case1Bi.leaf1Bib());
- assertEquals("leaf1bia type is not string", String.class,
- case1Bi.leaf1Bib().getClass());
- assertEquals("leaf1bia value is wrong", STR_LEAF_VALUE,
- case1Bi.leaf1Bib());
- }
-}
diff --git a/apps/yms/app/src/test/java/org/onosproject/yms/app/yob/YobDecimal64Test.java b/apps/yms/app/src/test/java/org/onosproject/yms/app/yob/YobDecimal64Test.java
deleted file mode 100644
index b069ad2..0000000
--- a/apps/yms/app/src/test/java/org/onosproject/yms/app/yob/YobDecimal64Test.java
+++ /dev/null
@@ -1,141 +0,0 @@
-/*
- * 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.yob;
-
-import org.junit.Test;
-import org.onosproject.yms.app.ydt.YangRequestWorkBench;
-import org.onosproject.yms.app.ydt.YdtExtendedContext;
-import org.onosproject.yms.app.ydt.YdtTestUtils;
-import org.onosproject.yms.ydt.YdtContext;
-
-import java.lang.reflect.Field;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.fail;
-
-public class YobDecimal64Test {
-
- /*
-
- Positive scenario
-
- input at boundary for decimal64 with fraction 2
- i. min value
- ii. max value
-
- input at boundary for decimal64 with minimum fraction
- i. min value
- ii. mid value
- iii. max value
-
- input at boundary 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
-
- */
- @Test
- public void positiveTest() {
- YangRequestWorkBench defaultYdtBuilder = YdtTestUtils.decimal64Ydt();
- validateYangObject(defaultYdtBuilder);
- }
-
- private void validateYangObject(YangRequestWorkBench defaultYdtBuilder) {
-
- YdtContext rootCtx = defaultYdtBuilder.getRootNode();
-
- YdtContext childCtx = rootCtx.getFirstChild();
-
- DefaultYobBuilder builder = new DefaultYobBuilder();
-
- Object yangObject = builder.getYangObject(
- (YdtExtendedContext) childCtx, YdtTestUtils
- .getSchemaRegistry());
- assertNotNull(yangObject);
- try {
- Field negInt = yangObject.getClass().getDeclaredField("negInt");
- negInt.setAccessible(true);
- assertEquals("-92233720368547758.08", negInt
- .get(yangObject).toString());
- Field negIntWithMaxFraction = yangObject.getClass()
- .getDeclaredField("negIntWithMaxFraction");
- negIntWithMaxFraction.setAccessible(true);
- assertEquals("-9.223372036854775808", negIntWithMaxFraction
- .get(yangObject).toString());
- Field negIntWithMinFraction = yangObject.getClass()
- .getDeclaredField("negIntWithMinFraction");
- negIntWithMinFraction.setAccessible(true);
- assertEquals("-922337203685477580.8", negIntWithMinFraction
- .get(yangObject).toString());
- Field posInt = yangObject.getClass()
- .getDeclaredField("posInt");
- posInt.setAccessible(true);
- assertEquals("92233720368547758.07", posInt
- .get(yangObject).toString());
- Field posIntWithMaxFraction = yangObject
- .getClass().getDeclaredField("posIntWithMaxFraction");
- posIntWithMaxFraction.setAccessible(true);
- assertEquals("9.223372036854775807", posIntWithMaxFraction
- .get(yangObject).toString());
- Field posIntWithMinFraction = yangObject.getClass()
- .getDeclaredField("posIntWithMinFraction");
- posIntWithMinFraction.setAccessible(true);
- assertEquals("922337203685477580.7", posIntWithMinFraction
- .get(yangObject).toString());
- Field minIntWithRange = yangObject.getClass()
- .getDeclaredField("minIntWithRange");
- minIntWithRange.setAccessible(true);
- assertEquals("10", minIntWithRange
- .get(yangObject).toString());
- Field midIntWithRange = yangObject
- .getClass().getDeclaredField("midIntWithRange");
- midIntWithRange.setAccessible(true);
- assertEquals("11", midIntWithRange.get(yangObject).toString());
- Field maxIntWithRange = yangObject
- .getClass().getDeclaredField("maxIntWithRange");
- maxIntWithRange.setAccessible(true);
- assertEquals("100", maxIntWithRange.get(yangObject).toString());
- } catch (NoSuchFieldException | IllegalAccessException e) {
- fail("No such field or illegal access exception: " + e);
- }
- }
-}
diff --git a/apps/yms/app/src/test/java/org/onosproject/yms/app/yob/YobEmptyTest.java b/apps/yms/app/src/test/java/org/onosproject/yms/app/yob/YobEmptyTest.java
deleted file mode 100644
index 55c416e..0000000
--- a/apps/yms/app/src/test/java/org/onosproject/yms/app/yob/YobEmptyTest.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * 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.yob;
-
-import org.junit.Test;
-import org.onosproject.yms.app.ydt.YangRequestWorkBench;
-import org.onosproject.yms.app.ydt.YdtExtendedContext;
-import org.onosproject.yms.app.ydt.YdtTestUtils;
-import org.onosproject.yms.ydt.YdtContext;
-
-import java.lang.reflect.Field;
-import java.util.List;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.fail;
-
-public class YobEmptyTest {
-
- /*
- EMPTY
- Positive scenario
- input with in empty.
- */
- @Test
- public void positiveTest() {
- YangRequestWorkBench defaultYdtBuilder = YdtTestUtils.emptyTypeYdt();
- validateYangObject(defaultYdtBuilder);
- }
-
- private void validateYangObject(YangRequestWorkBench defaultYdtBuilder) {
-
- YdtContext rootCtx = defaultYdtBuilder.getRootNode();
-
- YdtContext childCtx = rootCtx.getFirstChild();
-
- DefaultYobBuilder builder = new DefaultYobBuilder();
-
- Object yangObject = builder.getYangObject(
- (YdtExtendedContext) childCtx, YdtTestUtils
- .getSchemaRegistry());
- assertNotNull(yangObject);
- try {
-
- Field field = yangObject.getClass().getDeclaredField("emptyList");
- field.setAccessible(true);
- List booleanList = (List) field.get(yangObject);
- Field invalidInterval = booleanList.get(0)
- .getClass().getDeclaredField("empty");
- invalidInterval.setAccessible(true);
- assertEquals(false, invalidInterval.get(booleanList.get(0)));
- } catch (NoSuchFieldException | IllegalAccessException e) {
- fail("No such field or illegal access exception: " + e);
- }
- }
-}
diff --git a/apps/yms/app/src/test/java/org/onosproject/yms/app/yob/YobEnumTest.java b/apps/yms/app/src/test/java/org/onosproject/yms/app/yob/YobEnumTest.java
deleted file mode 100644
index c479afa..0000000
--- a/apps/yms/app/src/test/java/org/onosproject/yms/app/yob/YobEnumTest.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * 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.yob;
-
-import org.junit.Test;
-import org.onosproject.yms.app.ydt.YangRequestWorkBench;
-import org.onosproject.yms.app.ydt.YdtExtendedContext;
-import org.onosproject.yms.app.ydt.YdtTestUtils;
-import org.onosproject.yms.ydt.YdtContext;
-
-import java.lang.reflect.Field;
-import java.util.List;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.fail;
-
-public class YobEnumTest {
-
-/*
- ENUM
-
- Positive scenario
-
- input with in enum
- input with "ten"
- input with "hundred"
- input with "thousand"
-*/
-
- @Test
- public void positiveTest() {
- YangRequestWorkBench defaultYdtBuilder = YdtTestUtils.enumYdt();
- validateYangObject(defaultYdtBuilder);
- }
-
- private void validateYangObject(YangRequestWorkBench defaultYdtBuilder) {
-
- YdtContext rootCtx = defaultYdtBuilder.getRootNode();
-
- YdtContext childCtx = rootCtx.getFirstChild();
-
- DefaultYobBuilder builder = new DefaultYobBuilder();
-
- Object yangObject = builder.getYangObject(
- (YdtExtendedContext) childCtx, YdtTestUtils
- .getSchemaRegistry());
- assertNotNull(yangObject);
- try {
- Field field = yangObject.getClass().getDeclaredField("enumList");
- field.setAccessible(true);
- List enumList = (List) field.get(yangObject);
- assertEquals(false, enumList.isEmpty());
- Field enumleaf = enumList.get(0)
- .getClass().getDeclaredField("enumleaf");
- enumleaf.setAccessible(true);
- assertEquals("ten", enumleaf
- .get(enumList.get(0)).toString().toLowerCase());
- assertEquals("hundred", enumleaf
- .get(enumList.get(1)).toString().toLowerCase());
- assertEquals("thousand", enumleaf
- .get(enumList.get(2)).toString().toLowerCase());
- } catch (NoSuchFieldException | IllegalAccessException e) {
- fail("No such field or illegal access exception: " + e);
- }
- }
-}
diff --git a/apps/yms/app/src/test/java/org/onosproject/yms/app/yob/YobIetfNetworkTest.java b/apps/yms/app/src/test/java/org/onosproject/yms/app/yob/YobIetfNetworkTest.java
deleted file mode 100644
index 462dccb..0000000
--- a/apps/yms/app/src/test/java/org/onosproject/yms/app/yob/YobIetfNetworkTest.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * 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.yob;
-
-import org.junit.Test;
-import org.onosproject.yms.app.ydt.YangRequestWorkBench;
-import org.onosproject.yms.app.ydt.YdtExtendedContext;
-import org.onosproject.yms.app.ydt.YdtTestUtils;
-import org.onosproject.yms.ydt.YdtContext;
-
-import static org.junit.Assert.assertNotNull;
-
-public class YobIetfNetworkTest {
-
- @Test
- public void ietfNetwork1Test() {
- YangRequestWorkBench defaultYdtBuilder = YdtTestUtils.ietfNetwork1Ydt();
- validateYangObject(defaultYdtBuilder);
- }
-
- private void validateYangObject(YangRequestWorkBench defaultYdtBuilder) {
-
- YdtContext rootCtx = defaultYdtBuilder.getRootNode();
-
- YdtContext childCtx = rootCtx.getFirstChild();
-
- DefaultYobBuilder builder = new DefaultYobBuilder();
-
- Object yangObject = builder.getYangObject(
- (YdtExtendedContext) childCtx, YdtTestUtils
- .getSchemaRegistry());
- assertNotNull(yangObject);
- //TODO yangObject need to verify
- }
-}
diff --git a/apps/yms/app/src/test/java/org/onosproject/yms/app/yob/YobInteger16Test.java b/apps/yms/app/src/test/java/org/onosproject/yms/app/yob/YobInteger16Test.java
deleted file mode 100644
index 39281b7..0000000
--- a/apps/yms/app/src/test/java/org/onosproject/yms/app/yob/YobInteger16Test.java
+++ /dev/null
@@ -1,116 +0,0 @@
-/*
- * 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.yob;
-
-import org.junit.Test;
-import org.onosproject.yms.app.ydt.YangRequestWorkBench;
-import org.onosproject.yms.app.ydt.YdtExtendedContext;
-import org.onosproject.yms.app.ydt.YdtTestUtils;
-import org.onosproject.yms.ydt.YdtContext;
-
-import java.lang.reflect.Field;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.fail;
-
-public class YobInteger16Test {
-
- /*
-
- Positive scenario
-
- input at boundary for integer
- i. min value
- ii. max value
-
- input at boundary for unsigned integer
- 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 unsigned integer
- i.1. input 11
- i.2. min value 10
- i.3. max value 100
-
- */
- @Test
- public void positiveTest() {
- YangRequestWorkBench defaultYdtBuilder = YdtTestUtils.integer16Ydt();
- validateYangObject(defaultYdtBuilder);
- }
-
- public void validateYangObject(YangRequestWorkBench defaultYdtBuilder) {
-
- YdtContext rootCtx = defaultYdtBuilder.getRootNode();
-
- YdtContext childCtx = rootCtx.getFirstChild();
-
- DefaultYobBuilder builder = new DefaultYobBuilder();
-
- Object yangObject = builder.getYangObject(
- (YdtExtendedContext) childCtx, YdtTestUtils
- .getSchemaRegistry());
- assertNotNull(yangObject);
- try {
- Field negInt = yangObject.getClass().getDeclaredField("negInt");
- negInt.setAccessible(true);
- assertEquals("-32768", negInt.get(yangObject).toString());
- Field posInt = yangObject.getClass().getDeclaredField("posInt");
- posInt.setAccessible(true);
- assertEquals("32767", posInt.get(yangObject).toString());
- Field minIntWithRange = yangObject
- .getClass().getDeclaredField("minIntWithRange");
- minIntWithRange.setAccessible(true);
- assertEquals("10", minIntWithRange.get(yangObject).toString());
- Field midIntWithRange = yangObject
- .getClass().getDeclaredField("midIntWithRange");
- midIntWithRange.setAccessible(true);
- assertEquals("11", midIntWithRange.get(yangObject).toString());
- Field maxIntWithRange = yangObject
- .getClass().getDeclaredField("maxIntWithRange");
- maxIntWithRange.setAccessible(true);
- assertEquals("100", maxIntWithRange.get(yangObject).toString());
- Field minUint = yangObject.getClass().getDeclaredField("minUint");
- minUint.setAccessible(true);
- assertEquals("0", minUint.get(yangObject).toString());
- Field maxUint = yangObject.getClass().getDeclaredField("maxUint");
- maxUint.setAccessible(true);
- assertEquals("65535", maxUint.get(yangObject).toString());
- Field minUintWithRange = yangObject
- .getClass().getDeclaredField("minUintWithRange");
- minUintWithRange.setAccessible(true);
- assertEquals("10", minUintWithRange.get(yangObject).toString());
- Field midUintWithRange = yangObject
- .getClass().getDeclaredField("midUintWithRange");
- midUintWithRange.setAccessible(true);
- assertEquals("11", midUintWithRange.get(yangObject).toString());
- Field maxUintWithRange = yangObject
- .getClass().getDeclaredField("maxUintWithRange");
- maxUintWithRange.setAccessible(true);
- assertEquals("100", maxUintWithRange.get(yangObject).toString());
- } catch (NoSuchFieldException | IllegalAccessException e) {
- fail("No such field or illegal access exception: " + e);
- }
- }
-}
diff --git a/apps/yms/app/src/test/java/org/onosproject/yms/app/yob/YobInteger32Test.java b/apps/yms/app/src/test/java/org/onosproject/yms/app/yob/YobInteger32Test.java
deleted file mode 100644
index d97f783..0000000
--- a/apps/yms/app/src/test/java/org/onosproject/yms/app/yob/YobInteger32Test.java
+++ /dev/null
@@ -1,116 +0,0 @@
-/*
- * 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.yob;
-
-import org.junit.Test;
-import org.onosproject.yms.app.ydt.YangRequestWorkBench;
-import org.onosproject.yms.app.ydt.YdtExtendedContext;
-import org.onosproject.yms.app.ydt.YdtTestUtils;
-import org.onosproject.yms.ydt.YdtContext;
-
-import java.lang.reflect.Field;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.fail;
-
-public class YobInteger32Test {
-
- /*
-
- Positive scenario
-
- input at boundary for integer
- i. min value
- ii. max value
-
- input at boundary for unsigned integer
- 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 unsigned integer
- i.1. input 11
- i.2. min value 10
- i.3. max value 100
-
- */
- @Test
- public void positiveTest() {
- YangRequestWorkBench defaultYdtBuilder = YdtTestUtils.integer32Ydt();
- validateYangObject(defaultYdtBuilder);
- }
-
- public void validateYangObject(YangRequestWorkBench defaultYdtBuilder) {
-
- YdtContext rootCtx = defaultYdtBuilder.getRootNode();
-
- YdtContext childCtx = rootCtx.getFirstChild();
-
- DefaultYobBuilder builder = new DefaultYobBuilder();
-
- Object yangObject = builder.getYangObject(
- (YdtExtendedContext) childCtx, YdtTestUtils
- .getSchemaRegistry());
- assertNotNull(yangObject);
- try {
- Field negInt = yangObject.getClass().getDeclaredField("negInt");
- negInt.setAccessible(true);
- assertEquals("-2147483648", negInt.get(yangObject).toString());
- Field posInt = yangObject.getClass().getDeclaredField("posInt");
- posInt.setAccessible(true);
- assertEquals("2147483647", posInt.get(yangObject).toString());
- Field minIntWithRange = yangObject
- .getClass().getDeclaredField("minIntWithRange");
- minIntWithRange.setAccessible(true);
- assertEquals("10", minIntWithRange.get(yangObject).toString());
- Field midIntWithRange = yangObject
- .getClass().getDeclaredField("midIntWithRange");
- midIntWithRange.setAccessible(true);
- assertEquals("11", midIntWithRange.get(yangObject).toString());
- Field maxIntWithRange = yangObject
- .getClass().getDeclaredField("maxIntWithRange");
- maxIntWithRange.setAccessible(true);
- assertEquals("100", maxIntWithRange.get(yangObject).toString());
- Field minUint = yangObject.getClass().getDeclaredField("minUint");
- minUint.setAccessible(true);
- assertEquals("0", minUint.get(yangObject).toString());
- Field maxUint = yangObject.getClass().getDeclaredField("maxUint");
- maxUint.setAccessible(true);
- assertEquals("4294967295", maxUint.get(yangObject).toString());
- Field minUintWithRange = yangObject
- .getClass().getDeclaredField("minUintWithRange");
- minUintWithRange.setAccessible(true);
- assertEquals("10", minUintWithRange.get(yangObject).toString());
- Field midUintWithRange = yangObject
- .getClass().getDeclaredField("midUintWithRange");
- midUintWithRange.setAccessible(true);
- assertEquals("11", midUintWithRange.get(yangObject).toString());
- Field maxUintWithRange = yangObject
- .getClass().getDeclaredField("maxUintWithRange");
- maxUintWithRange.setAccessible(true);
- assertEquals("100", maxUintWithRange.get(yangObject).toString());
- } catch (NoSuchFieldException | IllegalAccessException e) {
- fail("No such field or illegal access exception: " + e);
- }
- }
-}
diff --git a/apps/yms/app/src/test/java/org/onosproject/yms/app/yob/YobInteger64Test.java b/apps/yms/app/src/test/java/org/onosproject/yms/app/yob/YobInteger64Test.java
deleted file mode 100644
index a3ee166..0000000
--- a/apps/yms/app/src/test/java/org/onosproject/yms/app/yob/YobInteger64Test.java
+++ /dev/null
@@ -1,121 +0,0 @@
-/*
- * 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.yob;
-
-import org.junit.Test;
-import org.onosproject.yms.app.ydt.YangRequestWorkBench;
-import org.onosproject.yms.app.ydt.YdtExtendedContext;
-import org.onosproject.yms.app.ydt.YdtTestUtils;
-import org.onosproject.yms.ydt.YdtContext;
-
-import java.lang.reflect.Field;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.fail;
-
-
-public class YobInteger64Test {
-
- /*
-
- Positive scenario
-
- input at boundary for integer
- i. min value
- ii. max value
-
- input at boundary for unsigned integer
- 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 unsigned integer
- i.1. input 11
- i.2. min value 10
- i.3. max value 100
-
- */
- @Test
- public void positiveTest() {
- YangRequestWorkBench defaultYdtBuilder = YdtTestUtils.integer64Ydt();
- validateYangObject(defaultYdtBuilder);
- }
-
- private void validateYangObject(YangRequestWorkBench defaultYdtBuilder) {
-
- YdtContext rootCtx = defaultYdtBuilder.getRootNode();
-
- YdtContext childCtx = rootCtx.getFirstChild();
-
- DefaultYobBuilder builder = new DefaultYobBuilder();
-
- Object yangObject = builder.getYangObject(
- (YdtExtendedContext) childCtx, YdtTestUtils
- .getSchemaRegistry());
- assertNotNull(yangObject);
- try {
- Field negInt = yangObject.getClass().getDeclaredField("negInt");
- negInt.setAccessible(true);
- assertEquals("-9223372036854775808", negInt
- .get(yangObject).toString());
- Field posIntField = yangObject
- .getClass().getDeclaredField("posInt");
- posIntField.setAccessible(true);
- assertEquals("9223372036854775807", posIntField
- .get(yangObject).toString());
- Field minIntWithRange = yangObject
- .getClass().getDeclaredField("minIntWithRange");
- minIntWithRange.setAccessible(true);
- assertEquals("10", minIntWithRange.get(yangObject).toString());
- Field midIntWithRange = yangObject
- .getClass().getDeclaredField("midIntWithRange");
- midIntWithRange.setAccessible(true);
- assertEquals("11", midIntWithRange.get(yangObject).toString());
- Field maxIntWithRange = yangObject
- .getClass().getDeclaredField("maxIntWithRange");
- maxIntWithRange.setAccessible(true);
- assertEquals("100", maxIntWithRange.get(yangObject).toString());
- Field minUint = yangObject.getClass().getDeclaredField("minUint");
- minUint.setAccessible(true);
- assertEquals("0", minUint.get(yangObject).toString());
- Field maxUint = yangObject.getClass().getDeclaredField("maxUint");
- maxUint.setAccessible(true);
- assertEquals("18446744073709551615", maxUint
- .get(yangObject).toString());
- Field minUintWithRange = yangObject
- .getClass().getDeclaredField("minUintWithRange");
- minUintWithRange.setAccessible(true);
- assertEquals("10", minUintWithRange.get(yangObject).toString());
- Field midUintWithRange = yangObject
- .getClass().getDeclaredField("midUintWithRange");
- midUintWithRange.setAccessible(true);
- assertEquals("11", midUintWithRange.get(yangObject).toString());
- Field maxUintWithRange = yangObject
- .getClass().getDeclaredField("maxUintWithRange");
- maxUintWithRange.setAccessible(true);
- assertEquals("100", maxUintWithRange.get(yangObject).toString());
- } catch (IllegalAccessException | NoSuchFieldException e) {
- fail("No such field or illegal access exception: " + e);
- }
- }
-}
diff --git a/apps/yms/app/src/test/java/org/onosproject/yms/app/yob/YobInteger8Test.java b/apps/yms/app/src/test/java/org/onosproject/yms/app/yob/YobInteger8Test.java
deleted file mode 100644
index 11bd8e5..0000000
--- a/apps/yms/app/src/test/java/org/onosproject/yms/app/yob/YobInteger8Test.java
+++ /dev/null
@@ -1,152 +0,0 @@
-/*
- * 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.yob;
-
-import org.junit.Test;
-import org.onosproject.yms.app.ydt.YangRequestWorkBench;
-import org.onosproject.yms.app.ydt.YdtExtendedContext;
-import org.onosproject.yms.app.ydt.YdtTestUtils;
-import org.onosproject.yms.ydt.YdtContext;
-
-import java.lang.reflect.Field;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.fail;
-
-public class YobInteger8Test {
-
- /*
-
- Positive scenario
-
- input at boundary for integer
- i. min value
- ii. max value
-
- input at boundary for unsigned integer
- 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 unsigned 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 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 unsigned 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 "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 unsigned Integer
- 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
- */
- @Test
- public void positiveTest() {
- YangRequestWorkBench defaultYdtBuilder = YdtTestUtils.integer8Ydt();
- validateYangObject(defaultYdtBuilder);
- }
-
- private void validateYangObject(YangRequestWorkBench defaultYdtBuilder) {
-
- YdtContext rootCtx = defaultYdtBuilder.getRootNode();
-
- YdtContext childCtx = rootCtx.getFirstChild();
-
- DefaultYobBuilder builder = new DefaultYobBuilder();
-
- Object yangObject = builder.getYangObject(
- (YdtExtendedContext) childCtx, YdtTestUtils
- .getSchemaRegistry());
- assertNotNull(yangObject);
- try {
- Field negInt = yangObject.getClass().getDeclaredField("negInt");
- negInt.setAccessible(true);
- assertEquals("-128", negInt.get(yangObject).toString());
- Field posInt = yangObject.getClass().getDeclaredField("posInt");
- posInt.setAccessible(true);
- assertEquals("127", posInt.get(yangObject).toString());
- Field minIntWithRange = yangObject
- .getClass().getDeclaredField("minIntWithRange");
- minIntWithRange.setAccessible(true);
- assertEquals("10", minIntWithRange
- .get(yangObject).toString());
- Field midIntWithRange = yangObject
- .getClass().getDeclaredField("midIntWithRange");
- midIntWithRange.setAccessible(true);
- assertEquals("11", midIntWithRange
- .get(yangObject).toString());
- Field maxIntWithRange = yangObject
- .getClass().getDeclaredField("maxIntWithRange");
- maxIntWithRange.setAccessible(true);
- assertEquals("100", maxIntWithRange.get(yangObject).toString());
- Field minUint = yangObject.getClass().getDeclaredField("minUint");
- minUint.setAccessible(true);
- assertEquals("0", minUint.get(yangObject).toString());
- Field maxUint = yangObject.getClass().getDeclaredField("maxUint");
- maxUint.setAccessible(true);
- assertEquals("255", maxUint.get(yangObject).toString());
- Field minUintWithRange = yangObject
- .getClass().getDeclaredField("maxIntWithRange");
- minUintWithRange.setAccessible(true);
- assertEquals("100", minUintWithRange.get(yangObject).toString());
- Field midUintWithRange = yangObject
- .getClass().getDeclaredField("midUintWithRange");
- midUintWithRange.setAccessible(true);
- assertEquals("11", midUintWithRange.get(yangObject).toString());
- Field maxUintWithRange = yangObject
- .getClass().getDeclaredField("maxUintWithRange");
- maxUintWithRange.setAccessible(true);
- assertEquals("100", maxUintWithRange.get(yangObject).toString());
- } catch (NoSuchFieldException | IllegalAccessException e) {
- fail("No such field or illegal access exception: " + e);
- }
- }
-}
diff --git a/apps/yms/app/src/test/java/org/onosproject/yms/app/yob/YobListTest.java b/apps/yms/app/src/test/java/org/onosproject/yms/app/yob/YobListTest.java
deleted file mode 100644
index 47ec8ef..0000000
--- a/apps/yms/app/src/test/java/org/onosproject/yms/app/yob/YobListTest.java
+++ /dev/null
@@ -1,131 +0,0 @@
-/*
- * 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.yob;
-
-import org.junit.Test;
-import org.onosproject.yms.app.ydt.YangRequestWorkBench;
-import org.onosproject.yms.app.ydt.YdtExtendedContext;
-import org.onosproject.yms.app.ydt.YdtTestUtils;
-import org.onosproject.yms.ydt.YdtContext;
-
-import java.io.IOException;
-import java.lang.reflect.Field;
-import java.util.List;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-public class YobListTest {
-
- @Test
- public void listwithoutcontainerTest() {
- YangRequestWorkBench defaultYdtBuilder =
- YdtTestUtils.listWithoutContainerYdt();
- validateYangObjectList(defaultYdtBuilder);
- }
-
- private void validateYangObjectList(
- YangRequestWorkBench defaultYdtBuilder) {
-
- YdtContext rootCtx = defaultYdtBuilder.getRootNode();
-
- YdtContext childCtx = rootCtx.getFirstChild();
-
- DefaultYobBuilder builder = new DefaultYobBuilder();
-
- Object yangObject = builder.getYangObject(
- (YdtExtendedContext) childCtx, YdtTestUtils.
- getSchemaRegistry());
- assertNotNull(yangObject);
- assertTrue(yangObject.getClass().getSimpleName()
- .equals("RootlistOpParam"));
- try {
-
- Field field =
- yangObject.getClass().getDeclaredField("listwithcontainer");
- field.setAccessible(true);
- List listwithcontainer = (List) field.get(yangObject);
- assertEquals(true, listwithcontainer.isEmpty());
- Field field1 = yangObject.getClass()
- .getDeclaredField("listwithoutcontainer");
- field1.setAccessible(true);
- List listwithoutcontainer = (List) field1.get(yangObject);
- assertEquals(false, listwithoutcontainer.isEmpty());
- Field invalidinterval = listwithoutcontainer.get(0).getClass()
- .getDeclaredField("invalidinterval");
- invalidinterval.setAccessible(true);
- assertEquals("12", invalidinterval.get(listwithoutcontainer.get(0))
- .toString());
- } catch (NoSuchFieldException | IllegalAccessException e) {
- fail("No such field or illegal access exception: " + e);
- }
- }
-
- @Test
- public void listwithcontainerTest()
- throws IOException {
- YangRequestWorkBench defaultYdtBuilder =
- YdtTestUtils.listWithContainerYdt();
-
- validateYangObject(defaultYdtBuilder);
- }
-
- public void validateYangObject(YangRequestWorkBench defaultYdtBuilder) {
-
- YdtContext ydtContext = defaultYdtBuilder.getRootNode();
-
- YdtContext ydtContext1 = ydtContext.getFirstChild();
-
- DefaultYobBuilder defaultYobBuilder = new DefaultYobBuilder();
-
- Object yangObject = defaultYobBuilder.getYangObject(
- (YdtExtendedContext) ydtContext1, YdtTestUtils
- .getSchemaRegistry());
- assertNotNull(yangObject);
- assertTrue(yangObject.getClass().getSimpleName()
- .equals("RootlistOpParam"));
- try {
-
- Field field = yangObject.getClass()
- .getDeclaredField("listwithoutcontainer");
- field.setAccessible(true);
- List listwithoutcontainer = (List) field.get(yangObject);
- assertEquals(true, listwithoutcontainer.isEmpty());
- Field listwithcontainerField =
- yangObject.getClass().getDeclaredField("listwithcontainer");
- listwithcontainerField.setAccessible(true);
- List listwithcontainer =
- (List) listwithcontainerField.get(yangObject);
- Field invalid = listwithcontainer.get(0).getClass()
- .getDeclaredField("invalid");
- invalid.setAccessible(true);
- assertEquals("12",
- invalid.get(listwithcontainer.get(0)).toString());
- Field invalidinterval = listwithcontainer.get(0).getClass()
- .getDeclaredField("invalidinterval");
- invalidinterval.setAccessible(true);
- List invalidintervalList =
- (List) invalidinterval.get(listwithcontainer.get(0));
- assertEquals("1", invalidintervalList.get(0).toString());
- assertEquals("2", invalidintervalList.get(1).toString());
- } catch (NoSuchFieldException | IllegalAccessException e) {
- fail("No such field or illegal access exception: " + e);
- }
- }
-}
diff --git a/apps/yms/app/src/test/java/org/onosproject/yms/app/yob/YobLogisticsManagerTest.java b/apps/yms/app/src/test/java/org/onosproject/yms/app/yob/YobLogisticsManagerTest.java
deleted file mode 100644
index c66f555..0000000
--- a/apps/yms/app/src/test/java/org/onosproject/yms/app/yob/YobLogisticsManagerTest.java
+++ /dev/null
@@ -1,107 +0,0 @@
-/*
- * 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.yob;
-
-import org.junit.Test;
-import org.onosproject.yms.app.ydt.YangRequestWorkBench;
-import org.onosproject.yms.app.ydt.YdtExtendedContext;
-import org.onosproject.yms.app.ydt.YdtTestUtils;
-import org.onosproject.yms.ydt.YdtContext;
-
-import java.io.IOException;
-import java.lang.reflect.Field;
-import java.util.ArrayList;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.fail;
-
-public class YobLogisticsManagerTest {
-
- @Test
- public void logisticsManagerTest() throws IOException {
- YangRequestWorkBench defaultYdtBuilder = YdtTestUtils
- .logisticsManagerYdt();
-
- YdtContext rootCtx = defaultYdtBuilder.getRootNode();
-
- YdtContext childCtx = rootCtx.getFirstChild();
-
- DefaultYobBuilder builder = new DefaultYobBuilder();
-
- while (childCtx != null) {
-
- Object yangObject = builder.getYangObject(
- (YdtExtendedContext) childCtx, YdtTestUtils
- .getSchemaRegistry());
- Class<?> aClass = yangObject.getClass();
- if (aClass.getSimpleName().equals("CustomssupervisorOpParam")) {
- try {
- Field field = aClass.getDeclaredField("supervisor");
- Field onosYangNodeOperationType = aClass
- .getDeclaredField("onosYangNodeOperationType");
- field.setAccessible(true);
- onosYangNodeOperationType.setAccessible(true);
- try {
- assertEquals("abc", field.get(yangObject).toString());
- assertEquals("MERGE", onosYangNodeOperationType
- .get(yangObject).toString());
- } catch (IllegalAccessException e) {
- fail("Illegal access exception: " + e);
- }
- } catch (NoSuchFieldException e) {
- fail("No such field exception: " + e);
- }
- }
-
- if (aClass.getSimpleName().equals(
- "MerchandisersupervisorOpParam")) {
- try {
- Field field = aClass.getDeclaredField("supervisor");
- field.setAccessible(true);
- try {
- assertEquals("abc", field.get(yangObject).toString());
- } catch (IllegalAccessException e) {
- fail("Illegal access exception: " + e);
- }
- } catch (NoSuchFieldException e) {
- fail("No such field found exception: " + e);
- }
- }
-
- if (aClass.getSimpleName().equals("WarehousesupervisorOpParam")) {
- try {
- Field field = aClass.getDeclaredField("supervisor");
- field.setAccessible(true);
- try {
- ArrayList<String> arrayList =
- (ArrayList<String>) field.get(yangObject);
- assertEquals("1", arrayList.get(0));
- assertEquals("2", arrayList.get(1));
- assertEquals("3", arrayList.get(2));
- assertEquals("4", arrayList.get(3));
- assertEquals("5", arrayList.get(4));
- } catch (IllegalAccessException e) {
- fail("Illegal access exception: " + e);
- }
- } catch (NoSuchFieldException e) {
- fail("No such field exception: " + e);
- }
- }
- childCtx = childCtx.getNextSibling();
- }
- }
-}
diff --git a/apps/yms/app/src/test/java/org/onosproject/yms/app/yob/YobTestUtils.java b/apps/yms/app/src/test/java/org/onosproject/yms/app/yob/YobTestUtils.java
deleted file mode 100644
index 17b41dd..0000000
--- a/apps/yms/app/src/test/java/org/onosproject/yms/app/yob/YobTestUtils.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * 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.yob;
-
-import org.onosproject.yms.app.ysr.TestYangSchemaNodeProvider;
-import org.onosproject.yms.app.ysr.YangSchemaRegistry;
-
-/**
- * YOB test Utility.
- */
-final class YobTestUtils {
-
- /**
- * Schema nodes.
- */
- static final String ROOT_DATA_RESOURCE = "/restconf/data";
- static final String TOPOLOGY = "yms-topology";
- static final String NODE = "node";
- static final String LEAF_1A1 = "leaf1a1";
- static final String LEAF_1A2 = "leaf1a2";
- static final String LEAF_1BIA = "leaf1bia";
- static final String LEAF_1BIB = "leaf1bib";
- static final String ROUTER_ID = "router-id";
- static final String ROUTER_IP = "router-ip";
- static final String STR_LEAF_VALUE = "leaf value";
-
- private YobTestUtils() {
- TEST_SCHEMA_PROVIDER.processSchemaRegistry(null);
- }
-
- private static final TestYangSchemaNodeProvider
- TEST_SCHEMA_PROVIDER = new TestYangSchemaNodeProvider();
-
- YangSchemaRegistry schemaRegistry() {
- return TEST_SCHEMA_PROVIDER.getDefaultYangSchemaRegistry();
- }
-
- /**
- * Returns the YANG object builder factory instance.
- *
- * @return YANG object builder factory instance
- */
- static YobTestUtils instance() {
- return LazyHolder.INSTANCE;
- }
-
- /*
- * Bill Pugh Singleton pattern. INSTANCE won't be instantiated until the
- * LazyHolder class is loaded via a call to the instance() method below.
- */
- private static class LazyHolder {
- private static final YobTestUtils INSTANCE = new YobTestUtils();
- }
-}
diff --git a/apps/yms/app/src/test/java/org/onosproject/yms/app/ypm/DefaultYpmNodeTest.java b/apps/yms/app/src/test/java/org/onosproject/yms/app/ypm/DefaultYpmNodeTest.java
deleted file mode 100644
index bec2eef..0000000
--- a/apps/yms/app/src/test/java/org/onosproject/yms/app/ypm/DefaultYpmNodeTest.java
+++ /dev/null
@@ -1,193 +0,0 @@
-/*
- * 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.ypm;
-
-import org.junit.Test;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.is;
-import static org.hamcrest.Matchers.notNullValue;
-import static org.hamcrest.Matchers.nullValue;
-
-import org.onosproject.yms.ypm.YpmContext;
-import org.onosproject.yms.ypm.DefaultYpmNode;
-
-/**
- * Unit tests for DefaultYpmNode class.
- */
-public class DefaultYpmNodeTest {
- private final String logicalName = "logicalYpmNode";
- private final String moduleName1 = "portPairModule1";
- private final String moduleName2 = "portPairModule2";
- private final String xNodeName = "x";
- private final String yNodeName = "y";
- private final String zNodeName = "z";
- private final String x1NodeName = "x1";
- private final String x2NodeName = "x2";
- private final String y1NodeName = "y1";
- private final String y2NodeName = "y2";
- private final String z1NodeName = "z1";
- private final String z2NodeName = "z2";
-
- /**
- * Constructs ypm tree with single module.
- *
- * @return ypm tree root node
- */
- private YpmContext constructYpmTreeSingleModule() {
- // Create logical node
- DefaultYpmNode rootNode = new DefaultYpmNode(logicalName);
- // Create module node with moduleName1
- rootNode.addChild(moduleName1); // child to logical node
- YpmContext moduleNode = rootNode.getChild(moduleName1);
- moduleNode.addChild(xNodeName); // child to module node
- moduleNode.addChild(yNodeName); // sibling node to child node "x"
- YpmContext xNode = moduleNode.getChild("x");
- xNode.addSibling(zNodeName); // sibling node to child node "x"
- xNode.addChild(x1NodeName); // child to node x
- xNode.addChild(x2NodeName); // child to node x
- YpmContext yNode = moduleNode.getChild(yNodeName);
- yNode.addChild(y1NodeName); // child to node y
- yNode.addChild(y2NodeName); // child to node y
- YpmContext zNode = moduleNode.getChild(zNodeName);
- zNode.addChild(z1NodeName); // child to node z
- zNode.addChild(z2NodeName); // child to node z
- return rootNode;
- }
-
- /**
- * Constructs ypm tree with multi module.
- *
- * @return ypm tree root node
- */
- private YpmContext constructYpmTreeMultiModule(DefaultYpmNode rootNode) {
- rootNode.addChild(moduleName2); // child to logical node
- YpmContext moduleNode = rootNode.getChild(moduleName2);
- moduleNode.addChild(xNodeName); // child to module node
- moduleNode.addChild(yNodeName); // sibling node to child node "x"
- YpmContext xNode = moduleNode.getChild("x");
- xNode.addSibling(zNodeName); // sibling node to child node "x"
- xNode.addChild(x1NodeName); // child to node x
- xNode.addChild(x2NodeName); // child to node x
- YpmContext yNode = moduleNode.getChild(yNodeName);
- yNode.addChild(y1NodeName); // child to node y
- yNode.addChild(y2NodeName); // child to node y
- YpmContext zNode = moduleNode.getChild(zNodeName);
- zNode.addChild(z1NodeName); // child to node z
- zNode.addChild(z2NodeName); // child to node z
- return rootNode;
- }
-
- /**
- * Checks ypm tree single module construction.
- */
- @Test
- public void testYpmTreeSingleModuleConstruction() {
- DefaultYpmNode rootNode = (DefaultYpmNode) constructYpmTreeSingleModule();
- // Check one by one node
- String name = rootNode.getName();
- assertThat(name, is(logicalName));
- YpmContext moduleNode = rootNode.getChild(moduleName1);
- assertThat(moduleNode.getName(), is(moduleName1));
- YpmContext ypmNode = moduleNode.getChild(xNodeName);
- assertThat(ypmNode.getName(), is(xNodeName));
- // Check sibling by using getNextSibling();
- ypmNode = ypmNode.getNextSibling();
- assertThat(ypmNode, notNullValue()); // either y or z should be there as sibling
- ypmNode = ypmNode.getNextSibling();
- assertThat(ypmNode, notNullValue()); // either y or z should be there as sibling
- ypmNode = ypmNode.getNextSibling();
- assertThat(ypmNode, nullValue()); // last sibling point to next sibling as null
- // Check sibling by using getPreviousSibling()
- ypmNode = moduleNode.getChild(zNodeName);
- assertThat(ypmNode.getName(), is(zNodeName));
- ypmNode = ypmNode.getPreviousSibling();
- assertThat(ypmNode, notNullValue()); // either x or y should be there as sibling
- ypmNode = ypmNode.getPreviousSibling();
- assertThat(ypmNode, notNullValue()); // either x or y should be there as sibling
- ypmNode = ypmNode.getPreviousSibling();
- assertThat(ypmNode, nullValue()); // last sibling point to next sibling as null
- // Checks the child x1 and x2
- ypmNode = moduleNode.getChild(xNodeName);
- ypmNode = ypmNode.getChild(x1NodeName);
- assertThat(ypmNode.getName(), is(x1NodeName));
- ypmNode = ypmNode.getSibling(x2NodeName);
- assertThat(ypmNode.getName(), is(x2NodeName));
- // Checks the child y1 and y2
- ypmNode = moduleNode.getChild(yNodeName);
- ypmNode = ypmNode.getChild(y1NodeName);
- assertThat(ypmNode.getName(), is(y1NodeName));
- ypmNode = ypmNode.getSibling(y2NodeName);
- assertThat(ypmNode.getName(), is(y2NodeName));
- // Checks the child z1 and z2
- ypmNode = moduleNode.getChild(zNodeName);
- ypmNode = ypmNode.getChild(z1NodeName);
- assertThat(ypmNode.getName(), is(z1NodeName));
- ypmNode = ypmNode.getSibling(z2NodeName);
- assertThat(ypmNode.getName(), is(z2NodeName));
- }
-
- /**
- * Checks ypm tree multiple module construction.
- */
- @Test
- public void testYpmTreeMultiModuleConstruction() {
- DefaultYpmNode rootNode = (DefaultYpmNode) constructYpmTreeSingleModule();
- rootNode = (DefaultYpmNode) constructYpmTreeMultiModule(rootNode);
- // Check one by one node
- String name = rootNode.getName();
- assertThat(name, is(logicalName));
- YpmContext moduleNode = rootNode.getChild(moduleName2);
- assertThat(moduleNode.getName(), is(moduleName2));
- YpmContext ypmNode = moduleNode.getChild(xNodeName);
- assertThat(ypmNode.getName(), is(xNodeName));
- // Check sibling by using getNextSibling();
- ypmNode = ypmNode.getNextSibling();
- assertThat(ypmNode, notNullValue()); // either y or z should be there as sibling
- ypmNode = ypmNode.getNextSibling();
- assertThat(ypmNode, notNullValue()); // either y or z should be there as sibling
- ypmNode = ypmNode.getNextSibling();
- assertThat(ypmNode, nullValue()); // last sibling point to next sibling as null
- // Check sibling by using getPreviousSibling()
- ypmNode = moduleNode.getChild(zNodeName);
- assertThat(ypmNode.getName(), is(zNodeName));
- ypmNode = ypmNode.getPreviousSibling();
- assertThat(ypmNode, notNullValue()); // either x or y should be there as sibling
- ypmNode = ypmNode.getPreviousSibling();
- assertThat(ypmNode, notNullValue()); // either x or y should be there as sibling
- ypmNode = ypmNode.getPreviousSibling();
- assertThat(ypmNode, nullValue()); // last sibling point to next sibling as null
- // Checks the child x1 and x2
- ypmNode = moduleNode.getChild(xNodeName);
- ypmNode = ypmNode.getChild(x1NodeName);
- assertThat(ypmNode.getName(), is(x1NodeName));
- ypmNode = ypmNode.getSibling(x2NodeName);
- assertThat(ypmNode.getName(), is(x2NodeName));
- // Checks the child y1 and y2
- ypmNode = moduleNode.getChild(yNodeName);
- ypmNode = ypmNode.getChild(y1NodeName);
- assertThat(ypmNode.getName(), is(y1NodeName));
- ypmNode = ypmNode.getSibling(y2NodeName);
- assertThat(ypmNode.getName(), is(y2NodeName));
- // Checks the child z1 and z2
- ypmNode = moduleNode.getChild(zNodeName);
- ypmNode = ypmNode.getChild(z1NodeName);
- assertThat(ypmNode.getName(), is(z1NodeName));
- ypmNode = ypmNode.getSibling(z2NodeName);
- assertThat(ypmNode.getName(), is(z2NodeName));
- }
-}
diff --git a/apps/yms/app/src/test/java/org/onosproject/yms/app/ypm/YpmManagerTest.java b/apps/yms/app/src/test/java/org/onosproject/yms/app/ypm/YpmManagerTest.java
deleted file mode 100644
index 7ba2219..0000000
--- a/apps/yms/app/src/test/java/org/onosproject/yms/app/ypm/YpmManagerTest.java
+++ /dev/null
@@ -1,494 +0,0 @@
-/*
- * 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.ypm;
-
-import org.junit.Test;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.is;
-import static org.hamcrest.Matchers.notNullValue;
-import static org.hamcrest.Matchers.nullValue;
-
-import org.onosproject.yangutils.datamodel.YangSchemaNodeIdentifier;
-import org.onosproject.yms.ypm.YpmContext;
-import org.onosproject.yms.ypm.DefaultYpmNode;
-import org.onosproject.yms.app.util.YdtNodeAdapter;
-
-/**
- * Unit tests for YpmManager class.
- */
-public class YpmManagerTest {
- private final String logicalName = "logicalYpmNode";
- private final String moduleName1 = "portPairModule1";
- private final String moduleName2 = "portPairModule2";
- private final String xNodeName = "x";
- private final String yNodeName = "y";
- private final String zNodeName = "z";
- private final String x1NodeName = "x1";
- private final String x2NodeName = "x2";
- private final String y1NodeName = "y1";
- private final String y2NodeName = "y2";
- private final String y11NodeName = "y11";
- private final String z1NodeName = "z1";
- private final String z2NodeName = "z2";
- private final String z3NodeName = "z3";
-
- /**
- * Creates module1 ydt tree.
- */
- public YdtNodeAdapter createModule1Tree() throws CloneNotSupportedException {
- YangSchemaNodeIdentifier tmpNodeIdentifier;
- YdtNodeAdapter rootNode = new YdtNodeAdapter();
- tmpNodeIdentifier = new YangSchemaNodeIdentifier();
- tmpNodeIdentifier.setName(logicalName);
- rootNode.setNodeIdentifier(tmpNodeIdentifier);
-
- // Create module node with moduleName1
- YdtNodeAdapter moduleNode = new YdtNodeAdapter();
- tmpNodeIdentifier = new YangSchemaNodeIdentifier();
- tmpNodeIdentifier.setName(moduleName1);
- moduleNode.setNodeIdentifier(tmpNodeIdentifier);
- moduleNode.setParent(rootNode);
- rootNode.addChild(moduleNode); // child to logical node
- YdtNodeAdapter xNode = new YdtNodeAdapter();
- tmpNodeIdentifier = new YangSchemaNodeIdentifier();
- tmpNodeIdentifier.setName(xNodeName);
- xNode.setNodeIdentifier(tmpNodeIdentifier);
- YdtNodeAdapter yNode = new YdtNodeAdapter();
- tmpNodeIdentifier = new YangSchemaNodeIdentifier();
- tmpNodeIdentifier.setName(yNodeName);
- yNode.setNodeIdentifier(tmpNodeIdentifier);
- YdtNodeAdapter zNode = new YdtNodeAdapter();
- tmpNodeIdentifier = new YangSchemaNodeIdentifier();
- tmpNodeIdentifier.setName(zNodeName);
- zNode.setNodeIdentifier(tmpNodeIdentifier);
- moduleNode.addChild(xNode); // child to module node
- xNode.addSibling(yNode);
- yNode.addSibling(zNode);
- YdtNodeAdapter x1Node = new YdtNodeAdapter();
- tmpNodeIdentifier = new YangSchemaNodeIdentifier();
- tmpNodeIdentifier.setName(x1NodeName);
- x1Node.setNodeIdentifier(tmpNodeIdentifier);
- YdtNodeAdapter x2Node = new YdtNodeAdapter();
- tmpNodeIdentifier = new YangSchemaNodeIdentifier();
- tmpNodeIdentifier.setName(x2NodeName);
- x2Node.setNodeIdentifier(tmpNodeIdentifier);
- YdtNodeAdapter y1Node = new YdtNodeAdapter();
- tmpNodeIdentifier = new YangSchemaNodeIdentifier();
- tmpNodeIdentifier.setName(y1NodeName);
- y1Node.setNodeIdentifier(tmpNodeIdentifier);
- YdtNodeAdapter y2Node = new YdtNodeAdapter();
- tmpNodeIdentifier = new YangSchemaNodeIdentifier();
- tmpNodeIdentifier.setName(y2NodeName);
- y2Node.setNodeIdentifier(tmpNodeIdentifier);
- YdtNodeAdapter z1Node = new YdtNodeAdapter();
- tmpNodeIdentifier = new YangSchemaNodeIdentifier();
- tmpNodeIdentifier.setName(z1NodeName);
- z1Node.setNodeIdentifier(tmpNodeIdentifier);
- YdtNodeAdapter z2Node = new YdtNodeAdapter();
- tmpNodeIdentifier = new YangSchemaNodeIdentifier();
- tmpNodeIdentifier.setName(z2NodeName);
- z2Node.setNodeIdentifier(tmpNodeIdentifier);
- xNode.addChild(x1Node);
- x1Node.addSibling(x2Node);
- yNode.addChild(y1Node);
- y1Node.addSibling(y2Node);
- zNode.addChild(z1Node);
- z1Node.addSibling(z2Node);
-
- return rootNode;
- }
-
- /**
- * Checks the protocol data added in YpmManger when only single module exists.
- */
- @Test
- public void retrieveAndCheckProtocolDataWhenSingleModule() throws CloneNotSupportedException {
- YdtNodeAdapter rootNode = createModule1Tree();
-
- YpmManager ypmManager = new YpmManager();
- Object metaData = 10;
- ypmManager.setProtocolData(rootNode, metaData);
- YpmContext ypmContext = ypmManager.getProtocolData(rootNode);
- DefaultYpmNode rootYpmNode = (DefaultYpmNode) ypmContext;
- assertThat(rootYpmNode.getName(), is(logicalName));
- DefaultYpmNode currYpmNode = (DefaultYpmNode) rootYpmNode.getFirstChild();
- assertThat(currYpmNode.getName(), is(moduleName1));
- currYpmNode = (DefaultYpmNode) currYpmNode.getFirstChild();
- assertThat(currYpmNode.getName(), is(xNodeName)); // x node
- assertThat(currYpmNode.getMetaData(), is(metaData));
- assertThat(currYpmNode.getNextSibling(), notNullValue()); // y or z node
- currYpmNode = currYpmNode.getNextSibling();
- assertThat(currYpmNode.getMetaData(), is(metaData));
- assertThat(currYpmNode.getNextSibling(), notNullValue()); // y or z node
- currYpmNode = currYpmNode.getNextSibling();
- assertThat(currYpmNode.getMetaData(), is(metaData));
- assertThat(currYpmNode.getNextSibling(), nullValue()); // no sibling
-
- // Check x node leaf's x1 and x2
- DefaultYpmNode moduleYpmNode = currYpmNode.getParent();
- assertThat(moduleYpmNode.getName(), is(moduleName1));
- DefaultYpmNode xYpmNode = (DefaultYpmNode) moduleYpmNode.getFirstChild();
- assertThat(xYpmNode.getName(), is(xNodeName));
- assertThat(xYpmNode.getMetaData(), is(metaData));
- // Check x1 node
- currYpmNode = (DefaultYpmNode) xYpmNode.getFirstChild();
- assertThat(currYpmNode.getName(), is(x1NodeName));
- assertThat(currYpmNode.getMetaData(), is(metaData));
- // Check x2 node
- currYpmNode = currYpmNode.getNextSibling();
- assertThat(currYpmNode.getName(), is(x2NodeName));
- assertThat(currYpmNode.getMetaData(), is(metaData));
-
- // Check y node leaf's y1 and y2
- DefaultYpmNode yYpmNode = xYpmNode.getNextSibling();
- assertThat(yYpmNode.getName(), is(yNodeName));
- assertThat(yYpmNode.getMetaData(), is(metaData));
- // Check y1 node
- currYpmNode = (DefaultYpmNode) yYpmNode.getFirstChild();
- assertThat(currYpmNode.getName(), is(y1NodeName));
- assertThat(currYpmNode.getMetaData(), is(metaData));
- // Check y2 node
- currYpmNode = currYpmNode.getNextSibling();
- assertThat(currYpmNode.getName(), is(y2NodeName));
- assertThat(currYpmNode.getMetaData(), is(metaData));
-
- // Check z node leaf's z1 and z2
- DefaultYpmNode zYpmNode = yYpmNode.getNextSibling();
- assertThat(zYpmNode.getName(), is(zNodeName));
- assertThat(zYpmNode.getMetaData(), is(metaData));
- // Check z1 node
- currYpmNode = (DefaultYpmNode) zYpmNode.getFirstChild();
- assertThat(currYpmNode.getName(), is(z1NodeName));
- assertThat(currYpmNode.getMetaData(), is(metaData));
- // Check z2 node
- currYpmNode = currYpmNode.getNextSibling();
- assertThat(currYpmNode.getName(), is(z2NodeName));
- assertThat(currYpmNode.getMetaData(), is(metaData));
- }
-
- /**
- * Creates module2 ydt tree. Module1 and Module2 trees are point to same logical root.
- */
- public YdtNodeAdapter createModule2Tree() throws CloneNotSupportedException {
- YangSchemaNodeIdentifier tmpNodeIdentifier;
- YdtNodeAdapter rootNode = createModule1Tree();
- YdtNodeAdapter moduleNode = new YdtNodeAdapter();
- tmpNodeIdentifier = new YangSchemaNodeIdentifier();
- tmpNodeIdentifier.setName(moduleName2);
- moduleNode.setNodeIdentifier(tmpNodeIdentifier);
- moduleNode.setParent(rootNode);
- rootNode.addChild(moduleNode); // child to logical node
- YdtNodeAdapter xNode = new YdtNodeAdapter();
- tmpNodeIdentifier = new YangSchemaNodeIdentifier();
- tmpNodeIdentifier.setName(xNodeName);
- xNode.setNodeIdentifier(tmpNodeIdentifier);
- YdtNodeAdapter yNode = new YdtNodeAdapter();
- tmpNodeIdentifier = new YangSchemaNodeIdentifier();
- tmpNodeIdentifier.setName(yNodeName);
- yNode.setNodeIdentifier(tmpNodeIdentifier);
- YdtNodeAdapter zNode = new YdtNodeAdapter();
- tmpNodeIdentifier = new YangSchemaNodeIdentifier();
- tmpNodeIdentifier.setName(zNodeName);
- zNode.setNodeIdentifier(tmpNodeIdentifier);
- moduleNode.addChild(xNode); // child to module node
- xNode.addSibling(yNode);
- yNode.addSibling(zNode);
- YdtNodeAdapter x1Node = new YdtNodeAdapter();
- tmpNodeIdentifier = new YangSchemaNodeIdentifier();
- tmpNodeIdentifier.setName(x1NodeName);
- x1Node.setNodeIdentifier(tmpNodeIdentifier);
- YdtNodeAdapter x2Node = new YdtNodeAdapter();
- tmpNodeIdentifier = new YangSchemaNodeIdentifier();
- tmpNodeIdentifier.setName(x2NodeName);
- x2Node.setNodeIdentifier(tmpNodeIdentifier);
- YdtNodeAdapter y1Node = new YdtNodeAdapter();
- tmpNodeIdentifier = new YangSchemaNodeIdentifier();
- tmpNodeIdentifier.setName(y1NodeName);
- y1Node.setNodeIdentifier(tmpNodeIdentifier);
- YdtNodeAdapter y2Node = new YdtNodeAdapter();
- tmpNodeIdentifier = new YangSchemaNodeIdentifier();
- tmpNodeIdentifier.setName(y2NodeName);
- y2Node.setNodeIdentifier(tmpNodeIdentifier);
- YdtNodeAdapter z1Node = new YdtNodeAdapter();
- tmpNodeIdentifier = new YangSchemaNodeIdentifier();
- tmpNodeIdentifier.setName(z1NodeName);
- z1Node.setNodeIdentifier(tmpNodeIdentifier);
- YdtNodeAdapter z2Node = new YdtNodeAdapter();
- tmpNodeIdentifier = new YangSchemaNodeIdentifier();
- tmpNodeIdentifier.setName(z2NodeName);
- z2Node.setNodeIdentifier(tmpNodeIdentifier);
- xNode.addChild(x1Node);
- x1Node.addSibling(x2Node);
- yNode.addChild(y1Node);
- y1Node.addSibling(y2Node);
- zNode.addChild(z1Node);
- z1Node.addSibling(z2Node);
-
- return rootNode;
- }
-
- /**
- * Checks the protocol data added in YpmManger when multiple modules exists.
- */
- @Test
- public void retrieveAndCheckProtocolDataWhenMultipleModule() throws CloneNotSupportedException {
- YdtNodeAdapter rootNode = createModule2Tree();
-
- YpmManager ypmManager = new YpmManager();
- Object metaData = 10;
- ypmManager.setProtocolData(rootNode, metaData);
- YpmContext ypmContext = ypmManager.getProtocolData(rootNode);
- DefaultYpmNode rootYpmNode = (DefaultYpmNode) ypmContext;
- assertThat(rootYpmNode.getName(), is(logicalName));
- DefaultYpmNode currYpmNode = (DefaultYpmNode) rootYpmNode.getFirstChild();
- currYpmNode = currYpmNode.getNextSibling(); // jump to next module (module2)
- assertThat(currYpmNode.getName(), is(moduleName2));
- currYpmNode = (DefaultYpmNode) currYpmNode.getFirstChild();
- assertThat(currYpmNode.getName(), is(xNodeName)); // x node
- assertThat(currYpmNode.getMetaData(), is(metaData));
- assertThat(currYpmNode.getNextSibling(), notNullValue()); // y or z node
- currYpmNode = currYpmNode.getNextSibling();
- assertThat(currYpmNode.getMetaData(), is(metaData));
- assertThat(currYpmNode.getNextSibling(), notNullValue()); // y or z node
- currYpmNode = currYpmNode.getNextSibling();
- assertThat(currYpmNode.getMetaData(), is(metaData));
- assertThat(currYpmNode.getNextSibling(), nullValue()); // no sibling
-
- // Check x node leaf's x1 and x2
- DefaultYpmNode moduleYpmNode = currYpmNode.getParent();
- assertThat(moduleYpmNode.getName(), is(moduleName2));
- DefaultYpmNode xYpmNode = (DefaultYpmNode) moduleYpmNode.getFirstChild();
- assertThat(xYpmNode.getName(), is(xNodeName));
- assertThat(xYpmNode.getMetaData(), is(metaData));
- // Check x1 node
- currYpmNode = (DefaultYpmNode) xYpmNode.getFirstChild();
- assertThat(currYpmNode.getName(), is(x1NodeName));
- assertThat(currYpmNode.getMetaData(), is(metaData));
- // Check x2 node
- currYpmNode = currYpmNode.getNextSibling();
- assertThat(currYpmNode.getName(), is(x2NodeName));
- assertThat(currYpmNode.getMetaData(), is(metaData));
-
- // Check y node leaf's y1 and y2
- DefaultYpmNode yYpmNode = xYpmNode.getNextSibling();
- assertThat(yYpmNode.getName(), is(yNodeName));
- assertThat(yYpmNode.getMetaData(), is(metaData));
- // Check y1 node
- currYpmNode = (DefaultYpmNode) yYpmNode.getFirstChild();
- assertThat(currYpmNode.getName(), is(y1NodeName));
- assertThat(currYpmNode.getMetaData(), is(metaData));
- // Check y2 node
- currYpmNode = currYpmNode.getNextSibling();
- assertThat(currYpmNode.getName(), is(y2NodeName));
- assertThat(currYpmNode.getMetaData(), is(metaData));
-
- // Check z node leaf's z1 and z2
- DefaultYpmNode zYpmNode = yYpmNode.getNextSibling();
- assertThat(zYpmNode.getName(), is(zNodeName));
- assertThat(zYpmNode.getMetaData(), is(metaData));
- // Check z1 node
- currYpmNode = (DefaultYpmNode) zYpmNode.getFirstChild();
- assertThat(currYpmNode.getName(), is(z1NodeName));
- assertThat(currYpmNode.getMetaData(), is(metaData));
- // Check z2 node
- currYpmNode = currYpmNode.getNextSibling();
- assertThat(currYpmNode.getName(), is(z2NodeName));
- assertThat(currYpmNode.getMetaData(), is(metaData));
- }
-
- /**
- * Checks the protocol data added in YpmManger, but tests only part of module1 tree.
- */
- @Test
- public void retrieveAndCheckProtocolDataChosenFromPartOfModule1Tree() throws CloneNotSupportedException {
- YangSchemaNodeIdentifier tmpNodeIdentifier;
- YdtNodeAdapter rootNode = createModule2Tree();
-
- // Sets the tree
- YpmManager ypmManager = new YpmManager();
- Object metaData = 10;
- ypmManager.setProtocolData(rootNode, metaData);
-
- // Create new ydt tree part of module1 tree
- YdtNodeAdapter rootNewYdtNode = new YdtNodeAdapter();
- // Create module node with moduleName1
- tmpNodeIdentifier = new YangSchemaNodeIdentifier();
- tmpNodeIdentifier.setName(logicalName);
- rootNewYdtNode.setNodeIdentifier(tmpNodeIdentifier);
- YdtNodeAdapter moduleNode = new YdtNodeAdapter();
- tmpNodeIdentifier = new YangSchemaNodeIdentifier();
- tmpNodeIdentifier.setName(moduleName1);
- moduleNode.setNodeIdentifier(tmpNodeIdentifier);
- moduleNode.setParent(rootNewYdtNode);
- rootNewYdtNode.addChild(moduleNode); // child to logical node
- YdtNodeAdapter yNode = new YdtNodeAdapter();
- tmpNodeIdentifier = new YangSchemaNodeIdentifier();
- tmpNodeIdentifier.setName(yNodeName);
- yNode.setNodeIdentifier(tmpNodeIdentifier);
- YdtNodeAdapter zNode = new YdtNodeAdapter();
- tmpNodeIdentifier = new YangSchemaNodeIdentifier();
- tmpNodeIdentifier.setName(zNodeName);
- zNode.setNodeIdentifier(tmpNodeIdentifier);
- moduleNode.addChild(yNode); // child to module node
- yNode.addSibling(zNode);
- YdtNodeAdapter y1Node = new YdtNodeAdapter();
- tmpNodeIdentifier = new YangSchemaNodeIdentifier();
- tmpNodeIdentifier.setName(y1NodeName);
- y1Node.setNodeIdentifier(tmpNodeIdentifier);
- YdtNodeAdapter y2Node = new YdtNodeAdapter();
- tmpNodeIdentifier = new YangSchemaNodeIdentifier();
- tmpNodeIdentifier.setName(y2NodeName);
- y2Node.setNodeIdentifier(tmpNodeIdentifier);
- yNode.addChild(y1Node);
- y1Node.addSibling(y2Node);
-
- // Again sets the protocol data
- metaData = 20;
- ypmManager.setProtocolData(rootNewYdtNode, metaData);
-
- // Retrieve protocol data and check the contents
- YpmContext ypmContext = ypmManager.getProtocolData(rootNewYdtNode);
- DefaultYpmNode rootYpmNode = (DefaultYpmNode) ypmContext;
- assertThat(rootYpmNode.getName(), is(logicalName));
- DefaultYpmNode currYpmNode = (DefaultYpmNode) rootYpmNode.getFirstChild();
- assertThat(currYpmNode.getName(), is(moduleName1));
- // Check y and z node
- currYpmNode = (DefaultYpmNode) currYpmNode.getFirstChild();
- DefaultYpmNode yYpmNode = currYpmNode;
- assertThat(currYpmNode.getName(), is(yNodeName)); // x node
- assertThat(currYpmNode.getMetaData(), is(metaData));
- assertThat(currYpmNode.getNextSibling(), notNullValue()); // z node
- currYpmNode = currYpmNode.getNextSibling();
- assertThat(currYpmNode.getName(), is(zNodeName));
- assertThat(currYpmNode.getMetaData(), is(metaData));
- assertThat(currYpmNode.getNextSibling(), nullValue()); // no sibling
- // Check y1 and y2 node
- currYpmNode = (DefaultYpmNode) yYpmNode.getFirstChild();
- assertThat(currYpmNode.getName(), is(y1NodeName));
- assertThat(currYpmNode.getMetaData(), is(metaData));
- assertThat(currYpmNode.getNextSibling(), notNullValue()); // y2 should exists
- currYpmNode = currYpmNode.getNextSibling();
- assertThat(currYpmNode.getName(), is(y2NodeName));
- assertThat(currYpmNode.getMetaData(), is(metaData));
- assertThat(currYpmNode.getNextSibling(), nullValue());
- }
-
- /**
- * Checks the protocol data added in YpmManger, but tests part of module1 tree with little bit extended tree.
- */
- @Test
- public void retrieveAndCheckProtocolDataChosenFromPartOfModule1TreeWithExtended()
- throws CloneNotSupportedException {
- YangSchemaNodeIdentifier tmpNodeIdentifier;
- YdtNodeAdapter rootNode = createModule2Tree();
-
- // Sets the tree
- YpmManager ypmManager = new YpmManager();
- Object metaData = 10;
- ypmManager.setProtocolData(rootNode, metaData);
-
- // Create new ydt tree part of module1 tree
- YdtNodeAdapter rootNewYdtNode = new YdtNodeAdapter();
- // Create module node with moduleName1
- tmpNodeIdentifier = new YangSchemaNodeIdentifier();
- tmpNodeIdentifier.setName(logicalName);
- rootNewYdtNode.setNodeIdentifier(tmpNodeIdentifier);
- YdtNodeAdapter moduleNode = new YdtNodeAdapter();
- tmpNodeIdentifier = new YangSchemaNodeIdentifier();
- tmpNodeIdentifier.setName(moduleName1);
- moduleNode.setNodeIdentifier(tmpNodeIdentifier);
- moduleNode.setParent(rootNewYdtNode);
- rootNewYdtNode.addChild(moduleNode); // child to logical node
- YdtNodeAdapter yNode = new YdtNodeAdapter();
- tmpNodeIdentifier = new YangSchemaNodeIdentifier();
- tmpNodeIdentifier.setName(yNodeName);
- yNode.setNodeIdentifier(tmpNodeIdentifier);
- YdtNodeAdapter zNode = new YdtNodeAdapter();
- tmpNodeIdentifier = new YangSchemaNodeIdentifier();
- tmpNodeIdentifier.setName(zNodeName);
- zNode.setNodeIdentifier(tmpNodeIdentifier);
- moduleNode.addChild(yNode); // child to module node
- yNode.addSibling(zNode);
- YdtNodeAdapter y1Node = new YdtNodeAdapter();
- tmpNodeIdentifier = new YangSchemaNodeIdentifier();
- tmpNodeIdentifier.setName(y1NodeName);
- y1Node.setNodeIdentifier(tmpNodeIdentifier);
- YdtNodeAdapter y2Node = new YdtNodeAdapter();
- tmpNodeIdentifier = new YangSchemaNodeIdentifier();
- tmpNodeIdentifier.setName(y2NodeName);
- y2Node.setNodeIdentifier(tmpNodeIdentifier);
- yNode.addChild(y1Node);
- y1Node.addSibling(y2Node);
- YdtNodeAdapter y11Node = new YdtNodeAdapter();
- // Add new y11 node
- tmpNodeIdentifier = new YangSchemaNodeIdentifier();
- tmpNodeIdentifier.setName(y11NodeName);
- y11Node.setNodeIdentifier(tmpNodeIdentifier);
- y1Node.addChild(y11Node);
- // Add new y3 node
- YdtNodeAdapter z3Node = new YdtNodeAdapter();
- tmpNodeIdentifier = new YangSchemaNodeIdentifier();
- tmpNodeIdentifier.setName(z3NodeName);
- z3Node.setNodeIdentifier(tmpNodeIdentifier);
- zNode.addChild(z3Node);
-
- // Again sets the protocol data
- metaData = 20;
- ypmManager.setProtocolData(rootNewYdtNode, metaData);
-
- // Retrieve protocol data and check the contents
- YpmContext ypmContext = ypmManager.getProtocolData(rootNewYdtNode);
- DefaultYpmNode rootYpmNode = (DefaultYpmNode) ypmContext;
- assertThat(rootYpmNode.getName(), is(logicalName));
- DefaultYpmNode currYpmNode = (DefaultYpmNode) rootYpmNode.getFirstChild();
- assertThat(currYpmNode.getName(), is(moduleName1));
- // Check y and z node
- currYpmNode = (DefaultYpmNode) currYpmNode.getFirstChild();
- DefaultYpmNode yYpmNode = currYpmNode;
- assertThat(currYpmNode.getName(), is(yNodeName)); // y node
- assertThat(currYpmNode.getMetaData(), is(metaData));
- assertThat(currYpmNode.getNextSibling(), notNullValue()); // z node
- currYpmNode = currYpmNode.getNextSibling();
- DefaultYpmNode zYpmNode = currYpmNode;
- assertThat(currYpmNode.getName(), is(zNodeName));
- assertThat(currYpmNode.getMetaData(), is(metaData));
- assertThat(currYpmNode.getNextSibling(), nullValue()); // no sibling
- // Check y1 and y2 node
- currYpmNode = (DefaultYpmNode) yYpmNode.getFirstChild();
- DefaultYpmNode y1YpmNode = currYpmNode;
- assertThat(currYpmNode.getName(), is(y1NodeName));
- assertThat(currYpmNode.getMetaData(), is(metaData));
- assertThat(currYpmNode.getNextSibling(), notNullValue()); // y2 should exists
- currYpmNode = currYpmNode.getNextSibling();
- assertThat(currYpmNode.getName(), is(y2NodeName));
- assertThat(currYpmNode.getMetaData(), is(metaData));
- assertThat(currYpmNode.getNextSibling(), nullValue());
- // Check new y11 node
- currYpmNode = (DefaultYpmNode) y1YpmNode.getFirstChild();
- assertThat(currYpmNode.getName(), is(y11NodeName));
- assertThat(currYpmNode.getMetaData(), is(metaData));
- assertThat(currYpmNode.getNextSibling(), nullValue());
- assertThat(currYpmNode.getFirstChild(), nullValue());
- // Check new z3 node
- currYpmNode = (DefaultYpmNode) zYpmNode.getFirstChild();
- assertThat(currYpmNode.getName(), is(z3NodeName));
- assertThat(currYpmNode.getMetaData(), is(metaData));
- assertThat(currYpmNode.getNextSibling(), nullValue());
- assertThat(currYpmNode.getFirstChild(), nullValue());
- }
-}
diff --git a/apps/yms/app/src/test/java/org/onosproject/yms/app/ysr/DefaultYangSchemaRegistryTest.java b/apps/yms/app/src/test/java/org/onosproject/yms/app/ysr/DefaultYangSchemaRegistryTest.java
deleted file mode 100644
index a4a7f0e..0000000
--- a/apps/yms/app/src/test/java/org/onosproject/yms/app/ysr/DefaultYangSchemaRegistryTest.java
+++ /dev/null
@@ -1,675 +0,0 @@
-/*
- * 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.ysr;
-
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network1.rev20151208.IetfNetwork1;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network1.rev20151208.IetfNetwork1OpParam;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network1.rev20151208.IetfNetwork1Service;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network2.rev20151208.IetfNetwork2Service;
-import org.onosproject.yangutils.datamodel.YangNode;
-import org.onosproject.yangutils.datamodel.YangSchemaNode;
-
-import java.io.IOException;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.core.Is.is;
-
-/**
- * Unit test case for default schema registry.
- */
-public class DefaultYangSchemaRegistryTest {
-
- private static final String SERVICE_NAME_1 =
- "org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf" +
- ".network1.rev20151208.IetfNetwork1Service";
- private static final String SCHEMA_NAME_1 = "ietf-network1";
- private static final String EVENT_NAME_1 =
- "org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf" +
- ".network1.rev20151208.ietfnetwork1.IetfNetwork1Event";
- private static final String INTERFACE_NAME_1 =
- "org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf" +
- ".network1.rev20151208.IetfNetwork1";
- private static final String OP_PARAM_NAME_1 =
- "org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf" +
- ".network1.rev20151208.IetfNetwork1OpParam";
-
- private static final String SERVICE_NAME_2 =
- "org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf" +
- ".network2.rev20151208.IetfNetwork2Service";
- private static final String SCHEMA_NAME_2 = "ietf-network2";
- private static final String EVENT_NAME_2 =
- "org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf" +
- ".network2.rev20151208.ietfnetwork2.IetfNetwork2Event";
- private static final String INTERFACE_NAME_2 =
- "org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf" +
- ".network2.rev20151208.IetfNetwork2";
- private static final String OP_PARAM_NAME_2 =
- "org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf" +
- ".network2.rev20151208.IetfNetwork2OpParam";
-
- private static final String SERVICE_NAME_3 =
- "org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf" +
- ".network3.rev20151208.IetfNetwork3Service";
- private static final String SCHEMA_NAME_3 = "ietf-network3";
- private static final String EVENT_NAME_3 =
- "org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf" +
- ".network3.rev20151208.ietfnetwork3.IetfNetwork3Event";
- private static final String INTERFACE_NAME_3 =
- "org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf" +
- ".network3.rev20151208.IetfNetwork3";
- private static final String OP_PARAM_NAME_3 =
- "org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf" +
- ".network3.rev20151208.IetfNetwork3OpParam";
-
- private static final String SCHEMA_NAME_4 = "ietf-network4";
- private static final String SERVICE_NAME_REV_14 =
- "org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf" +
- ".network4.rev20141208.IetfNetwork4Service";
- private static final String EVENT_NAME_REV_14 =
- "org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf" +
- ".network4.rev20141208.ietfnetwork4.IetfNetwork4Event";
- private static final String INTERFACE_NAME_REV_14 =
- "org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf" +
- ".network4.rev20141208.IetfNetwork4";
- private static final String OP_PARAM_NAME_REV_14 =
- "org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf" +
- ".network4.rev20141208.IetfNetwork4OpParam";
-
- private static final String SERVICE_NAME_REV_15 =
- "org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf" +
- ".network4.rev20151208.IetfNetwork4Service";
- private static final String EVENT_NAME_REV_15 =
- "org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf" +
- ".network4.rev20151208.ietfnetwork4.IetfNetwork4Event";
- private static final String INTERFACE_NAME_REV_15 =
- "org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf" +
- ".network4.rev20151208.IetfNetwork4";
- private static final String OP_PARAM_NAME_REV_15 =
- "org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf" +
- ".network4.rev20151208.IetfNetwork4OpParam";
-
- private static final String SERVICE_NAME_REV_16 =
- "org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf" +
- ".network4.rev20161208.IetfNetwork4Service";
-
- private static final String EVENT_NAME_REV_16 =
- "org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf" +
- ".network4.rev20161208.ietfnetwork4.IetfNetwork4Event";
- private static final String INTERFACE_NAME_REV_16 =
- "org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf" +
- ".network4.rev20161208.IetfNetwork4";
- private static final String OP_PARAM_NAME_REV_16 =
- "org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf" +
- ".network4.rev20161208.IetfNetwork4OpParam";
-
- private static final String SERVICE_NAME_REV_17 =
- "org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf" +
- ".network4.rev20171208.IetfNetwork4Service";
- private static final String EVENT_NAME_REV_17 =
- "org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf" +
- ".network4.rev20171208.ietfnetwork4.IetfNetwork4Event";
- private static final String INTERFACE_NAME_REV_17 =
- "org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf" +
- ".network4.rev20171208.IetfNetwork4";
- private static final String OP_PARAM_NAME_REV_17 =
- "org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf" +
- ".network4.rev20171208.IetfNetwork4OpParam";
-
- private static final String SERVICE_NAME_NO_REV =
- "org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf" +
- ".network4.IetfNetwork4Service";
- private static final String EVENT_NAME_NO_REV =
- "org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf" +
- ".network4.ietfnetwork4.IetfNetwork4Event";
- private static final String INTERFACE_NAME_NO_REV =
- "org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf" +
- ".network4.IetfNetwork4";
- private static final String OP_PARAM_NAME_NO_REV =
- "org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf" +
- ".network4.IetfNetwork4OpParam";
-
- private static final String DATE = "2014-00-08";
- private static final String SCHEMA_NAME_WITH_DATE =
- "ietf-network4@2014-00-08";
-
- private static final String UN_REG_SCHEMA_NAME = "ietf-routing";
- private static final String UN_REG_INTERFACE_NAME = "IetfRouting";
- private static final String UN_REG_OP_PARAM_NAME = "IetfRoutingOpParam";
- private static final String UN_REG_SERVICE_NAME = "IetfRoutingService";
- private static final String UN_REG_EVENT_NAME = "IetfRoutingEvent";
-
- private final TestYangSchemaNodeProvider testYangSchemaNodeProvider =
- new TestYangSchemaNodeProvider();
- @Rule
- public ExpectedException thrown = ExpectedException.none();
-
- /**
- * Unit test case in which schema node should be present.
- *
- * @throws IOException when fails to do IO operation
- */
- @Test
- public void testForGetSchemaNode()
- throws IOException {
-
- testYangSchemaNodeProvider.processSchemaRegistry(null);
-
- DefaultYangSchemaRegistry registry =
- testYangSchemaNodeProvider.getDefaultYangSchemaRegistry();
-
- YangSchemaNode yangNode =
- registry.getYangSchemaNodeUsingAppName(SERVICE_NAME_1);
- assertThat(true, is(SCHEMA_NAME_1.equals(yangNode.getName())));
-
- yangNode = registry.getYangSchemaNodeUsingSchemaName(SCHEMA_NAME_1);
- assertThat(true, is(SCHEMA_NAME_1.equals(yangNode.getName())));
-
- yangNode =
- registry.getYangSchemaNodeUsingGeneratedRootNodeInterfaceFileName(
- INTERFACE_NAME_1);
- assertThat(true, is(SCHEMA_NAME_1.equals(yangNode.getName())));
-
- yangNode =
- registry.getYangSchemaNodeUsingGeneratedRootNodeOpPramFileName(
- OP_PARAM_NAME_1);
- assertThat(true, is(SCHEMA_NAME_1.equals(yangNode.getName())));
-
- yangNode = registry.getRootYangSchemaNodeForNotification(EVENT_NAME_1);
- assertThat(true, is(SCHEMA_NAME_1.equals(yangNode.getName())));
-
- //As we have not registered an application this object should be null.
- Object object = registry.getRegisteredApplication(yangNode);
- assertThat(true, is(object == null));
- testYangSchemaNodeProvider.unregisterService(SERVICE_NAME_1);
-
- yangNode = registry.getYangSchemaNodeUsingAppName(SERVICE_NAME_1);
- assertThat(true, is(yangNode == null));
-
- yangNode = registry.getYangSchemaNodeUsingSchemaName(SCHEMA_NAME_1);
- assertThat(true, is(yangNode == null));
-
- yangNode =
- registry.getYangSchemaNodeUsingGeneratedRootNodeInterfaceFileName(
- INTERFACE_NAME_1);
- assertThat(true, is(yangNode == null));
-
- yangNode =
- registry.getYangSchemaNodeUsingGeneratedRootNodeOpPramFileName(
- OP_PARAM_NAME_1);
- assertThat(true, is(yangNode == null));
-
- yangNode = registry.getRootYangSchemaNodeForNotification(EVENT_NAME_1);
- assertThat(true, is(yangNode == null));
-
- //As we have not registered an application this object should be null.
- object = registry.getRegisteredApplication(yangNode);
- assertThat(true, is(object == null));
-
- //With second service.
- yangNode = registry.getYangSchemaNodeUsingAppName(SERVICE_NAME_2);
- assertThat(true, is(SCHEMA_NAME_2.equals(yangNode.getName())));
-
- yangNode = registry.getYangSchemaNodeUsingSchemaName(SCHEMA_NAME_2);
- assertThat(true, is(SCHEMA_NAME_2.equals(yangNode.getName())));
-
- yangNode =
- registry.getYangSchemaNodeUsingGeneratedRootNodeInterfaceFileName(
- INTERFACE_NAME_2);
- assertThat(true, is(SCHEMA_NAME_2.equals(yangNode.getName())));
-
- yangNode =
- registry.getYangSchemaNodeUsingGeneratedRootNodeOpPramFileName(
- OP_PARAM_NAME_2);
- assertThat(true, is(SCHEMA_NAME_2.equals(yangNode.getName())));
-
- yangNode = registry.getRootYangSchemaNodeForNotification(EVENT_NAME_2);
- assertThat(true, is(SCHEMA_NAME_2.equals(yangNode.getName())));
-
- //As we have not registered an application this object should be null.
- object = registry.getRegisteredApplication(yangNode);
- assertThat(true, is(object == null));
-
- testYangSchemaNodeProvider.unregisterService(SERVICE_NAME_2);
-
- yangNode = registry.getYangSchemaNodeUsingAppName(SERVICE_NAME_2);
- assertThat(true, is(yangNode == null));
-
- yangNode = registry.getYangSchemaNodeUsingSchemaName(SCHEMA_NAME_2);
- assertThat(true, is(yangNode == null));
-
- yangNode =
- registry.getYangSchemaNodeUsingGeneratedRootNodeInterfaceFileName(
- INTERFACE_NAME_2);
- assertThat(true, is(yangNode == null));
-
- yangNode =
- registry.getYangSchemaNodeUsingGeneratedRootNodeOpPramFileName(
- OP_PARAM_NAME_2);
- assertThat(true, is(yangNode == null));
-
- yangNode = registry.getRootYangSchemaNodeForNotification(EVENT_NAME_2);
- assertThat(true, is(yangNode == null));
-
- //As we have not registered an application this object should be null.
- object = registry.getRegisteredApplication(yangNode);
- assertThat(true, is(object == null));
-
- //With third service.
- yangNode = registry.getYangSchemaNodeUsingAppName(SERVICE_NAME_3);
- assertThat(true, is(SCHEMA_NAME_3.equals(yangNode.getName())));
-
- yangNode = registry.getYangSchemaNodeUsingSchemaName(SCHEMA_NAME_3);
- assertThat(true, is(SCHEMA_NAME_3.equals(yangNode.getName())));
-
- yangNode =
- registry.getYangSchemaNodeUsingGeneratedRootNodeInterfaceFileName(
- INTERFACE_NAME_3);
- assertThat(true, is(SCHEMA_NAME_3.equals(yangNode.getName())));
-
- yangNode = registry.getRootYangSchemaNodeForNotification(EVENT_NAME_3);
- assertThat(true, is(yangNode == null));
-
- yangNode =
- registry.getYangSchemaNodeUsingGeneratedRootNodeOpPramFileName(
- OP_PARAM_NAME_3);
- assertThat(true, is(SCHEMA_NAME_3.equals(yangNode.getName())));
-
- //As we have not registered an application this object should be null.
- object = registry.getRegisteredApplication(yangNode);
- assertThat(true, is(object == null));
-
- testYangSchemaNodeProvider.unregisterService(SERVICE_NAME_3);
-
- yangNode = registry.getYangSchemaNodeUsingAppName(SERVICE_NAME_3);
- assertThat(true, is(yangNode == null));
-
- yangNode = registry.getYangSchemaNodeUsingSchemaName(SCHEMA_NAME_3);
- assertThat(true, is(yangNode == null));
-
- yangNode =
- registry.getYangSchemaNodeUsingGeneratedRootNodeInterfaceFileName(
- INTERFACE_NAME_3);
- assertThat(true, is(yangNode == null));
-
- yangNode =
- registry.getYangSchemaNodeUsingGeneratedRootNodeOpPramFileName(
- OP_PARAM_NAME_3);
- assertThat(true, is(yangNode == null));
-
- yangNode = registry.getRootYangSchemaNodeForNotification(EVENT_NAME_3);
- assertThat(true, is(yangNode == null));
-
- //As we have not registered an application this object should be null.
- object = registry.getRegisteredApplication(yangNode);
- assertThat(true, is(object == null));
- }
-
- /**
- * Unit test case in which schema node should not be present.
- *
- * @throws IOException when fails to do IO operation
- */
- @Test
- public void testForDoNotGetSchemaNode()
- throws IOException {
-
- DefaultYangSchemaRegistry registry =
- testYangSchemaNodeProvider.getDefaultYangSchemaRegistry();
-
- // here all nodes should be null as we have not done any registration
- // for this application.
- YangSchemaNode yangNode =
- registry.getYangSchemaNodeUsingAppName(UN_REG_SERVICE_NAME);
- assertThat(true, is(yangNode == null));
-
- yangNode = registry.getYangSchemaNodeUsingSchemaName(UN_REG_SCHEMA_NAME);
- assertThat(true, is(yangNode == null));
-
- yangNode =
- registry.getYangSchemaNodeUsingGeneratedRootNodeInterfaceFileName(
- UN_REG_INTERFACE_NAME);
- assertThat(true, is(yangNode == null));
-
- yangNode =
- registry.getYangSchemaNodeUsingGeneratedRootNodeOpPramFileName(
- UN_REG_OP_PARAM_NAME);
- assertThat(true, is(yangNode == null));
-
- yangNode = registry.getRootYangSchemaNodeForNotification(
- UN_REG_EVENT_NAME);
- assertThat(true, is(yangNode == null));
-
- //As we have not registered an application this object should be null.
- Object object = registry.getRegisteredApplication(yangNode);
- assertThat(true, is(object == null));
-
- }
-
- /**
- * Unit test case in which schema node should be present with multi
- * revisions.
- *
- * @throws IOException when fails to do IO operation
- */
- @Test
- public void testForGetSchemaNodeWhenNoRevision()
- throws IOException {
-
- testYangSchemaNodeProvider.processSchemaRegistry(null);
- DefaultYangSchemaRegistry registry =
- testYangSchemaNodeProvider.getDefaultYangSchemaRegistry();
-
- //Service with rev.
- YangSchemaNode yangNode =
- registry.getYangSchemaNodeUsingAppName(SERVICE_NAME_REV_15);
- assertThat(true, is(SCHEMA_NAME_4.equals(yangNode.getName())));
-
- yangNode = registry.getYangSchemaNodeUsingSchemaName(SCHEMA_NAME_4);
- assertThat(true, is(SCHEMA_NAME_4.equals(yangNode.getName())));
-
- yangNode =
- registry.getYangSchemaNodeUsingGeneratedRootNodeInterfaceFileName(
- INTERFACE_NAME_REV_15);
- assertThat(true, is(SCHEMA_NAME_4.equals(yangNode.getName())));
-
- yangNode =
- registry.getYangSchemaNodeUsingGeneratedRootNodeOpPramFileName(
- OP_PARAM_NAME_REV_15);
- assertThat(true, is(SCHEMA_NAME_4.equals(yangNode.getName())));
-
- yangNode = registry.getRootYangSchemaNodeForNotification(
- EVENT_NAME_REV_15);
- assertThat(true, is(SCHEMA_NAME_4.equals(yangNode.getName())));
-
- //As we have not registered an application this object should be null.
- Object object = registry.getRegisteredApplication(yangNode);
- assertThat(true, is(object == null));
- testYangSchemaNodeProvider.unregisterService(SERVICE_NAME_REV_15);
-
- yangNode = registry.getYangSchemaNodeUsingAppName(SERVICE_NAME_REV_15);
- assertThat(true, is(yangNode == null));
-
- //Here the yangNode should be the node which does not have revision.
- // asset should pass with false.
- yangNode = registry.getYangSchemaNodeUsingSchemaName(SCHEMA_NAME_4);
- assertThat(true, is(((YangNode) yangNode).getRevision() != null));
-
- //Service no revision.
- yangNode = registry.getYangSchemaNodeUsingAppName(SERVICE_NAME_NO_REV);
- assertThat(true, is(SCHEMA_NAME_4.equals(yangNode.getName())));
-
- yangNode = registry.getYangSchemaNodeUsingSchemaName(SCHEMA_NAME_4);
- assertThat(true, is(SCHEMA_NAME_4.equals(yangNode.getName())));
-
- yangNode =
- registry.getYangSchemaNodeUsingGeneratedRootNodeInterfaceFileName(
- INTERFACE_NAME_NO_REV);
- assertThat(true, is(SCHEMA_NAME_4.equals(yangNode.getName())));
-
- yangNode =
- registry.getYangSchemaNodeUsingGeneratedRootNodeOpPramFileName(
- OP_PARAM_NAME_NO_REV);
- assertThat(true, is(SCHEMA_NAME_4.equals(yangNode.getName())));
-
- yangNode = registry.getRootYangSchemaNodeForNotification(EVENT_NAME_NO_REV);
- assertThat(true, is(SCHEMA_NAME_4.equals(yangNode.getName())));
-
- //As we have not registered an application this object should be null.
- object = registry.getRegisteredApplication(yangNode);
- assertThat(true, is(object == null));
- testYangSchemaNodeProvider.unregisterService(SERVICE_NAME_NO_REV);
-
- yangNode = registry.getYangSchemaNodeUsingAppName(SERVICE_NAME_NO_REV);
- assertThat(true, is(yangNode == null));
-
- //Here the yangNode should be the node which have different revision.
- yangNode = registry.getYangSchemaNodeUsingSchemaName(SCHEMA_NAME_4);
- assertThat(true, is(((YangNode) yangNode).getRevision() != null));
- }
-
- /**
- * Unit test case in which schema node should be present with multi
- * revisions.
- *
- * @throws IOException when fails to do IO operation
- */
- @Test
- public void testForGetSchemaNodeWhenMultiRevision()
- throws IOException {
-
- testYangSchemaNodeProvider.processSchemaRegistry(null);
- DefaultYangSchemaRegistry registry =
- testYangSchemaNodeProvider.getDefaultYangSchemaRegistry();
-
- //Service with rev.
- YangSchemaNode yangNode =
- registry.getYangSchemaNodeUsingAppName(SERVICE_NAME_REV_15);
- assertThat(true, is(SCHEMA_NAME_4.equals(yangNode.getName())));
-
- yangNode = registry.getYangSchemaNodeUsingSchemaName(SCHEMA_NAME_4);
- assertThat(true, is(SCHEMA_NAME_4.equals(yangNode.getName())));
-
- yangNode =
- registry.getYangSchemaNodeUsingGeneratedRootNodeInterfaceFileName(
- INTERFACE_NAME_REV_15);
- assertThat(true, is(SCHEMA_NAME_4.equals(yangNode.getName())));
-
- yangNode =
- registry.getYangSchemaNodeUsingGeneratedRootNodeOpPramFileName(
- OP_PARAM_NAME_REV_15);
- assertThat(true, is(SCHEMA_NAME_4.equals(yangNode.getName())));
-
- yangNode = registry.getRootYangSchemaNodeForNotification(
- EVENT_NAME_REV_15);
- assertThat(true, is(SCHEMA_NAME_4.equals(yangNode.getName())));
-
- //As we have not registered an application this object should be null.
- Object object = registry.getRegisteredApplication(yangNode);
- assertThat(true, is(object == null));
- testYangSchemaNodeProvider.unregisterService(SERVICE_NAME_REV_15);
-
- yangNode = registry.getYangSchemaNodeUsingAppName(SERVICE_NAME_REV_15);
- assertThat(true, is(yangNode == null));
-
- //Here the yangNode should be the node which does not have revision.
- // asset should pass with false.
- yangNode = registry.getYangSchemaNodeUsingSchemaName(SCHEMA_NAME_4);
- assertThat(true, is(((YangNode) yangNode).getRevision() != null));
-
- //Service with different revision.
- yangNode = registry.getYangSchemaNodeUsingAppName(SERVICE_NAME_REV_16);
- assertThat(true, is(SCHEMA_NAME_4.equals(yangNode.getName())));
-
- yangNode = registry.getYangSchemaNodeUsingSchemaName(SCHEMA_NAME_4);
- assertThat(true, is(SCHEMA_NAME_4.equals(yangNode.getName())));
-
- yangNode =
- registry.getYangSchemaNodeUsingGeneratedRootNodeInterfaceFileName(
- INTERFACE_NAME_REV_16);
- assertThat(true, is(SCHEMA_NAME_4.equals(yangNode.getName())));
-
- yangNode =
- registry.getYangSchemaNodeUsingGeneratedRootNodeOpPramFileName(
- OP_PARAM_NAME_REV_16);
- assertThat(true, is(SCHEMA_NAME_4.equals(yangNode.getName())));
-
- yangNode = registry.getRootYangSchemaNodeForNotification(EVENT_NAME_REV_16);
- assertThat(true, is(SCHEMA_NAME_4.equals(yangNode.getName())));
-
- //As we have not registered an application this object should be null.
- object = registry.getRegisteredApplication(yangNode);
- assertThat(true, is(object == null));
- testYangSchemaNodeProvider.unregisterService(SERVICE_NAME_REV_16);
-
- yangNode = registry.getYangSchemaNodeUsingAppName(SERVICE_NAME_REV_16);
- assertThat(true, is(yangNode == null));
-
- //Here the yangNode should be the node which have different revision.
- yangNode = registry.getYangSchemaNodeUsingSchemaName(SCHEMA_NAME_4);
- assertThat(true, is(((YangNode) yangNode).getRevision() != null));
-
- //Service with different revision.
- yangNode = registry.getYangSchemaNodeUsingAppName(SERVICE_NAME_REV_17);
- assertThat(true, is(SCHEMA_NAME_4.equals(yangNode.getName())));
-
- yangNode = registry.getYangSchemaNodeUsingSchemaName(SCHEMA_NAME_4);
- assertThat(true, is(SCHEMA_NAME_4.equals(yangNode.getName())));
-
- yangNode =
- registry.getYangSchemaNodeUsingGeneratedRootNodeInterfaceFileName(
- INTERFACE_NAME_REV_17);
- assertThat(true, is(SCHEMA_NAME_4.equals(yangNode.getName())));
-
- yangNode =
- registry.getYangSchemaNodeUsingGeneratedRootNodeOpPramFileName(
- OP_PARAM_NAME_REV_17);
- assertThat(true, is(SCHEMA_NAME_4.equals(yangNode.getName())));
-
- yangNode = registry.getRootYangSchemaNodeForNotification(
- EVENT_NAME_REV_17);
- assertThat(true, is(yangNode == null));
-
- //As we have not registered an application this object should be null.
- object = registry.getRegisteredApplication(yangNode);
- assertThat(true, is(object == null));
- testYangSchemaNodeProvider.unregisterService(SERVICE_NAME_REV_17);
-
- yangNode = registry.getYangSchemaNodeUsingAppName(SERVICE_NAME_REV_17);
- assertThat(true, is(yangNode == null));
-
- //Here the yangNode should be the node which have different revision.
- yangNode = registry.getYangSchemaNodeUsingSchemaName(SCHEMA_NAME_4);
- assertThat(true, is(((YangNode) yangNode).getRevision() == null));
-
- //Service with different revision.
- yangNode = registry.getYangSchemaNodeUsingAppName(SERVICE_NAME_REV_14);
- assertThat(true, is(SCHEMA_NAME_4.equals(yangNode.getName())));
-
- yangNode = registry.getYangSchemaNodeUsingSchemaName(SCHEMA_NAME_4);
- assertThat(true, is(SCHEMA_NAME_4.equals(yangNode.getName())));
-
- yangNode =
- registry.getYangSchemaNodeUsingGeneratedRootNodeInterfaceFileName(
- INTERFACE_NAME_REV_14);
- assertThat(true, is(SCHEMA_NAME_4.equals(yangNode.getName())));
-
- yangNode =
- registry.getYangSchemaNodeUsingGeneratedRootNodeOpPramFileName(
- OP_PARAM_NAME_REV_14);
- assertThat(true, is(SCHEMA_NAME_4.equals(yangNode.getName())));
-
- yangNode = registry.getRootYangSchemaNodeForNotification(
- EVENT_NAME_REV_14);
- assertThat(true, is(SCHEMA_NAME_4.equals(yangNode.getName())));
-
- //As we have not registered an application this object should be null.
- object = registry.getRegisteredApplication(yangNode);
- assertThat(true, is(object == null));
- testYangSchemaNodeProvider.unregisterService(SERVICE_NAME_REV_14);
-
- yangNode = registry.getYangSchemaNodeUsingAppName(SERVICE_NAME_REV_14);
- assertThat(true, is(yangNode == null));
-
- //Here the yangNode should be the node which does not have revision.
- // asset should pass with false.
- yangNode = registry.getYangSchemaNodeUsingSchemaName(SCHEMA_NAME_4);
- assertThat(true, is(yangNode != null));
-
- }
-
- /**
- * Unit test case should generate exceptions.
- */
- @Test
- public void testRegistration() {
- thrown.expect(RuntimeException.class);
- testYangSchemaNodeProvider.processSchemaRegistry(null);
- testYangSchemaNodeProvider.processRegistrationOfApp();
- }
-
- /**
- * Unit test case should not generate any exceptions and should
- * return specific revision node.
- */
- @Test
- public void testGetWithSpecificRevision() {
- testYangSchemaNodeProvider.processSchemaRegistry(null);
- YangSchemaNode schemaNode = testYangSchemaNodeProvider
- .getDefaultYangSchemaRegistry()
- .getYangSchemaNodeUsingSchemaName(SCHEMA_NAME_WITH_DATE);
-
- assertThat(true, is(schemaNode.getName().equals(SCHEMA_NAME_4)));
- String date = testYangSchemaNodeProvider
- .getDefaultYangSchemaRegistry()
- .getDateInStringFormat(schemaNode);
- assertThat(true, is(date.equals(DATE)));
- }
-
- /**
- * Unit test case should not generate any exceptions
- * verify notification should be checked for registration.
- */
- @Test
- public void testNotification() {
- testYangSchemaNodeProvider.processSchemaRegistry(null);
- boolean isRegWithNotification =
- testYangSchemaNodeProvider.getDefaultYangSchemaRegistry()
- .verifyNotificationObject(IetfNetwork1Service.class);
- assertThat(true, is(isRegWithNotification));
- isRegWithNotification = testYangSchemaNodeProvider
- .getDefaultYangSchemaRegistry()
- .verifyNotificationObject(IetfNetwork1.class);
- assertThat(false, is(isRegWithNotification));
- isRegWithNotification = testYangSchemaNodeProvider
- .getDefaultYangSchemaRegistry()
- .verifyNotificationObject(IetfNetwork1OpParam.class);
- assertThat(false, is(isRegWithNotification));
- }
-
- /**
- * Unit test case should not generate any exceptions.
- */
- @Test
- public void testNotificationRegistrationInYnh() {
- testYangSchemaNodeProvider.processSchemaRegistry(null);
- testYangSchemaNodeProvider.getDefaultYangSchemaRegistry()
- .verifyNotificationObject(IetfNetwork1Service.class);
- testYangSchemaNodeProvider.getDefaultYangSchemaRegistry()
- .verifyNotificationObject(IetfNetwork1.class);
- testYangSchemaNodeProvider.getDefaultYangSchemaRegistry()
- .verifyNotificationObject(IetfNetwork1OpParam.class);
-
- boolean isRegWithNotification = testYangSchemaNodeProvider
- .getDefaultYangSchemaRegistry()
- .verifyNotificationObject(IetfNetwork2Service.class);
-
- //Register should work.
- assertThat(true, is(isRegWithNotification));
- isRegWithNotification = testYangSchemaNodeProvider
- .getDefaultYangSchemaRegistry()
- .verifyNotificationObject(IetfNetwork2Service.class);
-
- //Re register should not happen
- assertThat(false, is(isRegWithNotification));
- }
-
-}
-
-
diff --git a/apps/yms/app/src/test/java/org/onosproject/yms/app/ysr/MockIetfManager.java b/apps/yms/app/src/test/java/org/onosproject/yms/app/ysr/MockIetfManager.java
deleted file mode 100644
index 1126cdf..0000000
--- a/apps/yms/app/src/test/java/org/onosproject/yms/app/ysr/MockIetfManager.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * 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.ysr;
-
-import org.onosproject.event.ListenerRegistry;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network2.rev20151208.IetfNetwork2;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network2.rev20151208.IetfNetwork2OpParam;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network2.rev20151208.IetfNetwork2Service;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network2.rev20151208.ietfnetwork2.IetfNetwork2Event;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network2.rev20151208.ietfnetwork2.IetfNetwork2EventListener;
-
-/**
- * Represent mock implementation for services.
- */
-public class MockIetfManager
- extends ListenerRegistry<IetfNetwork2Event, IetfNetwork2EventListener>
- implements IetfNetwork2Service {
-
- @Override
- public IetfNetwork2 getIetfNetwork2(IetfNetwork2OpParam ietfNetwork2) {
- return null;
- }
-
- @Override
- public void setIetfNetwork2(IetfNetwork2OpParam ietfNetwork2) {
-
- }
-
-}
diff --git a/apps/yms/app/src/test/java/org/onosproject/yms/app/ysr/TestYangSchemaNodeProvider.java b/apps/yms/app/src/test/java/org/onosproject/yms/app/ysr/TestYangSchemaNodeProvider.java
deleted file mode 100644
index 778afd7..0000000
--- a/apps/yms/app/src/test/java/org/onosproject/yms/app/ysr/TestYangSchemaNodeProvider.java
+++ /dev/null
@@ -1,138 +0,0 @@
-/*
- * 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.ysr;
-
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network1.rev20151208.IetfNetwork1Service;
-import org.onosproject.yangutils.datamodel.YangSchemaNode;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.Set;
-
-import static org.onosproject.yangutils.utils.UtilConstants.PERIOD;
-import static org.onosproject.yangutils.utils.UtilConstants.TEMP;
-import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.deleteDirectory;
-import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getCapitalCase;
-
-/**
- * Represents mock bundle context. provides bundle context for YSR to do unit
- * testing.
- */
-public class TestYangSchemaNodeProvider {
-
- private static final String FS = File.separator;
- private static final String PATH = System.getProperty("user.dir") +
- FS + "target" + FS + "classes" + FS;
- private static final String SER_FILE_PATH = "yang" + FS + "resources" +
- FS + "YangMetaData.ser";
- private static final String TEMP_FOLDER_PATH = PATH + TEMP;
- private final DefaultYangSchemaRegistry defaultYangSchemaRegistry =
- new DefaultYangSchemaRegistry("module-id");
-
- /**
- * Creates an instance of mock bundle context.
- */
- public TestYangSchemaNodeProvider() {
- }
-
- /**
- * Process YANG schema node for a application.
- *
- * @param appObject application object
- */
- public void processSchemaRegistry(Object appObject) {
-
- Set<YangSchemaNode> appNode = defaultYangSchemaRegistry
- .deSerializeDataModel(PATH + SER_FILE_PATH);
- YsrAppContext appContext = new YsrAppContext();
- defaultYangSchemaRegistry.ysrContextForSchemaStore(appContext);
- defaultYangSchemaRegistry
- .setClassLoader(this.getClass().getClassLoader());
- String appName;
- for (YangSchemaNode node : appNode) {
- defaultYangSchemaRegistry.processApplicationContext(node);
- defaultYangSchemaRegistry.ysrAppContext().appObject(appObject);
- defaultYangSchemaRegistry.ysrContextForAppStore()
- .appObject(appObject);
- defaultYangSchemaRegistry.ysrContextForSchemaStore()
- .appObject(appObject);
- appName = node.getJavaPackage() + PERIOD +
- getCapitalCase(node.getJavaClassNameOrBuiltInType());
- storeClasses(appName);
- }
-
- try {
- deleteDirectory(TEMP_FOLDER_PATH);
- } catch (IOException e) {
- }
- }
-
- /**
- * Stores test generated class to YSR store.
- *
- * @param name name of class
- */
- private void storeClasses(String name) {
- ClassLoader classLoader = this.getClass().getClassLoader();
- if (getDefaultYangSchemaRegistry().verifyClassExistence(name)) {
- try {
- Class<?> nodeClass = classLoader.loadClass(name);
- getDefaultYangSchemaRegistry().updateServiceClass(nodeClass);
- } catch (ClassNotFoundException e) {
- e.printStackTrace();
- }
- }
- }
-
- /**
- * Unregisters services.
- *
- * @param appName application name
- */
- public void unregisterService(String appName) {
-
- if (getDefaultYangSchemaRegistry().verifyClassExistence(appName)) {
- try {
- Class<?> curClass = Class.forName(appName);
- getDefaultYangSchemaRegistry()
- .unRegisterApplication(null, curClass);
- } catch (ClassNotFoundException e) {
- e.printStackTrace();
- }
- }
- }
-
- /**
- * Returns schema registry.
- *
- * @return schema registry
- */
- public DefaultYangSchemaRegistry getDefaultYangSchemaRegistry() {
- return defaultYangSchemaRegistry;
- }
-
- /**
- * Process registration of a service.
- */
- public void processRegistrationOfApp() {
- getDefaultYangSchemaRegistry()
- .processRegistration(IetfNetwork1Service.class,
- new MockIetfManager(), "target");
-
- }
-
-}
diff --git a/apps/yms/app/src/test/java/org/onosproject/yms/app/ytb/DefaultYangTreeBuilderTest.java b/apps/yms/app/src/test/java/org/onosproject/yms/app/ytb/DefaultYangTreeBuilderTest.java
deleted file mode 100644
index b7bec31..0000000
--- a/apps/yms/app/src/test/java/org/onosproject/yms/app/ytb/DefaultYangTreeBuilderTest.java
+++ /dev/null
@@ -1,1127 +0,0 @@
-/*
- * 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.ytb;
-
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
-import org.onosproject.yang.gen.v1.yms.test.ytb.derived.type.with.bits.and.binary.rev20160826.YtbDerivedTypeWithBitsAndBinary;
-import org.onosproject.yang.gen.v1.yms.test.ytb.derived.type.with.bits.and.binary.rev20160826.YtbDerivedTypeWithBitsAndBinaryOpParam;
-import org.onosproject.yang.gen.v1.yms.test.ytb.derived.type.with.bits.and.binary.rev20160826.ytbderivedtypewithbitsandbinary.Derivedbinarya;
-import org.onosproject.yang.gen.v1.yms.test.ytb.derived.type.with.bits.and.binary.rev20160826.ytbderivedtypewithbitsandbinary.Derivedbinaryb;
-import org.onosproject.yang.gen.v1.yms.test.ytb.derived.type.with.bits.and.binary.rev20160826.ytbderivedtypewithbitsandbinary.Derivedbitsa;
-import org.onosproject.yang.gen.v1.yms.test.ytb.derived.type.with.bits.and.binary.rev20160826.ytbderivedtypewithbitsandbinary.Derivedbitsb;
-import org.onosproject.yang.gen.v1.yms.test.ytb.derived.type.with.bits.and.binary.rev20160826.ytbderivedtypewithbitsandbinary.ForunionUnion;
-import org.onosproject.yang.gen.v1.yms.test.ytb.module.with.container.rev20160826.YtbModuleWithContainer;
-import org.onosproject.yang.gen.v1.yms.test.ytb.module.with.container.rev20160826.YtbModuleWithContainerOpParam;
-import org.onosproject.yang.gen.v1.yms.test.ytb.module.with.container.rev20160826.ytbmodulewithcontainer.DefaultSched;
-import org.onosproject.yang.gen.v1.yms.test.ytb.module.with.container.rev20160826.ytbmodulewithcontainer.Sched;
-import org.onosproject.yang.gen.v1.yms.test.ytb.module.with.leaf.ietfschedule.rev20160826.YtbIetfSchedule;
-import org.onosproject.yang.gen.v1.yms.test.ytb.module.with.leaf.ietfschedule.rev20160826.YtbIetfScheduleOpParam;
-import org.onosproject.yang.gen.v1.yms.test.ytb.module.with.leaf.ietfschedule.rev20160826.ytbietfschedule.Enum1Enum;
-import org.onosproject.yang.gen.v1.yms.test.ytb.module.with.leaf.ietfschedule.rev20160826.ytbietfschedule.Enum2Enum;
-import org.onosproject.yang.gen.v1.yms.test.ytb.module.with.leaflist.rev20160826.YtbModuleWithLeafList;
-import org.onosproject.yang.gen.v1.yms.test.ytb.module.with.leaflist.rev20160826.YtbModuleWithLeafListOpParam;
-import org.onosproject.yang.gen.v1.yms.test.ytb.module.with.list.rev20160826.YtbModuleWithList;
-import org.onosproject.yang.gen.v1.yms.test.ytb.module.with.list.rev20160826.YtbModuleWithListOpParam;
-import org.onosproject.yang.gen.v1.yms.test.ytb.module.with.list.rev20160826.ytbmodulewithlist.DefaultYtblistlist;
-import org.onosproject.yang.gen.v1.yms.test.ytb.module.with.list.rev20160826.ytbmodulewithlist.Find;
-import org.onosproject.yang.gen.v1.yms.test.ytb.module.with.list.rev20160826.ytbmodulewithlist.Ytblistlist;
-import org.onosproject.yang.gen.v1.yms.test.ytb.multi.module.a.rev20160826.YtbMultiModulea;
-import org.onosproject.yang.gen.v1.yms.test.ytb.multi.module.a.rev20160826.YtbMultiModuleaOpParam;
-import org.onosproject.yang.gen.v1.yms.test.ytb.multi.module.a.rev20160826.ytbmultimodulea.DefaultYtbmultilist;
-import org.onosproject.yang.gen.v1.yms.test.ytb.multi.module.a.rev20160826.ytbmultimodulea.Ytbmultilist;
-import org.onosproject.yang.gen.v1.yms.test.ytb.multi.module.b.rev20160826.YtbMultiModuleb;
-import org.onosproject.yang.gen.v1.yms.test.ytb.multi.module.b.rev20160826.YtbMultiModulebOpParam;
-import org.onosproject.yang.gen.v1.yms.test.ytb.multi.module.b.rev20160826.ytbmultimoduleb.DefaultYtbmultilistb;
-import org.onosproject.yang.gen.v1.yms.test.ytb.multi.module.b.rev20160826.ytbmultimoduleb.Ytbmultilistb;
-import org.onosproject.yang.gen.v1.yms.test.ytb.multi.notification.with.container.rev20160826.ytbmultinotificationwithcontainer.DefaultFortesta;
-import org.onosproject.yang.gen.v1.yms.test.ytb.multi.notification.with.container.rev20160826.ytbmultinotificationwithcontainer.Fortesta;
-import org.onosproject.yang.gen.v1.yms.test.ytb.multi.notification.with.container.rev20160826.ytbmultinotificationwithcontainer.YtbMultiNotificationWithContainerEvent;
-import org.onosproject.yang.gen.v1.yms.test.ytb.multi.notification.with.container.rev20160826.ytbmultinotificationwithcontainer.YtbMultiNotificationWithContainerEventSubject;
-import org.onosproject.yang.gen.v1.yms.test.ytb.multi.notification.with.container.rev20160826.ytbmultinotificationwithcontainer.fortesta.DefaultYtbnot;
-import org.onosproject.yang.gen.v1.yms.test.ytb.multi.notification.with.container.rev20160826.ytbmultinotificationwithcontainer.fortesta.Ytbnot;
-import org.onosproject.yang.gen.v1.yms.test.ytb.tree.builder.yangautoprefixfor.list.having.list.rev20160826.YtbTreeBuilderForListHavingList;
-import org.onosproject.yang.gen.v1.yms.test.ytb.tree.builder.yangautoprefixfor.list.having.list.rev20160826.YtbTreeBuilderForListHavingListOpParam;
-import org.onosproject.yang.gen.v1.yms.test.ytb.tree.builder.yangautoprefixfor.list.having.list.rev20160826.ytbtreebuilderforlisthavinglist.Carrier;
-import org.onosproject.yang.gen.v1.yms.test.ytb.tree.builder.yangautoprefixfor.list.having.list.rev20160826.ytbtreebuilderforlisthavinglist.DefaultCarrier;
-import org.onosproject.yang.gen.v1.yms.test.ytb.tree.builder.yangautoprefixfor.list.having.list.rev20160826.ytbtreebuilderforlisthavinglist.carrier.DefaultMultiplexes;
-import org.onosproject.yang.gen.v1.yms.test.ytb.tree.builder.yangautoprefixfor.list.having.list.rev20160826.ytbtreebuilderforlisthavinglist.carrier.Multiplexes;
-import org.onosproject.yang.gen.v1.yms.test.ytb.tree.builder.yangautoprefixfor.list.having.list.rev20160826.ytbtreebuilderforlisthavinglist.carrier.multiplexes.ApplicationAreas;
-import org.onosproject.yang.gen.v1.yms.test.ytb.tree.builder.yangautoprefixfor.list.having.list.rev20160826.ytbtreebuilderforlisthavinglist.carrier.multiplexes.DefaultApplicationAreas;
-import org.onosproject.yang.gen.v1.yms.test.ytb.tree.builder.yangautoprefixfor.list.having.list.rev20160826.ytbtreebuilderforlisthavinglist.carrier.multiplexes.TypesEnum;
-import org.onosproject.yms.app.ydt.YdtExtendedBuilder;
-import org.onosproject.yms.app.ydt.YdtNode;
-import org.onosproject.yms.app.ysr.DefaultYangSchemaRegistry;
-import org.onosproject.yms.ydt.YdtBuilder;
-import org.onosproject.yms.ydt.YdtContext;
-import org.onosproject.yms.ydt.YdtContextOperationType;
-
-import java.math.BigDecimal;
-import java.math.BigInteger;
-import java.util.ArrayList;
-import java.util.BitSet;
-import java.util.List;
-import java.util.Set;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.core.Is.is;
-import static org.onosproject.yang.gen.v1.yms.test.ytb.module.with.leaf.ietfschedule.rev20160826.YtbIetfScheduleOpParam.OnosYangNodeOperationType;
-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.NONE;
-import static org.onosproject.yms.ydt.YmsOperationType.EDIT_CONFIG_REQUEST;
-import static org.onosproject.yms.ydt.YmsOperationType.QUERY_CONFIG_REQUEST;
-import static org.onosproject.yms.ydt.YmsOperationType.QUERY_REQUEST;
-
-/**
- * Unit test cases for YANG tree builder with different YANG object
- * configuration.
- */
-public class DefaultYangTreeBuilderTest extends YtbErrMsgAndConstants {
-
-
- private static final String ONE = "1";
- private static final String TWO = "2";
- private static final String THREE = "3";
- private static final String FOUR = "4";
- private static final String FIVE = "5";
- private static final String SIX = "6";
- private static final String NINE = "9";
- private static final String IETF_SCHEDULE = "YtbIetfSchedule";
- private static final String TIME = "time";
- private static final String MOD_LEAF_LIST = "YtbModuleWithLeafList";
- private static final String ENUM_1 = "enum1";
- private static final String ENUM_2 = "enum2";
- private static final String HUNDRED = "hundred";
- private static final String HUNDRED_100 = "hundred-100";
- private static final String TEN_10 = "ten-10";
- private static final String THOUSAND_1000 = "thousand-1000";
- private static final String MOD_CONT = "YtbModuleWithContainer";
- private static final String SCHED = "sched";
- private static final String PREDICT_VAL = "98989";
- private static final String MOD_LIST = "YtbModuleWithList";
- private static final String LIST_LIST = "ytblistlist";
- private static final String PREDICTION = "prediction";
- private static final String TRUE = "true";
- private static final String FALSE = "false";
- private static final String MUL_NOTIFY =
- "YtbMultiNotificationWithContainer";
- private static final String NOTIFICATION = "notification";
- private static final String NOTIFY = "fortesta";
- private static final String YTB_NOTIFY_CONT = "ytbnot";
- private static final String NOTIFY_LEAF = "notileaf";
- private static final String ANT = "ant";
- private static final String ANIMAL = "animal";
- private static final String BIRD = "bird";
- private static final String BALL = "ball";
- private static final String BAT = "bat";
- private static final String MUL_MOD_A = "YtbMultiModulea";
- private static final String MUL_LIST_A = "ytbmultilist";
- private static final String CHECK = "check";
- private static final String MUL_MOD_B = "YtbMultiModuleb";
- private static final String MUL_LIST_B = "ytbmultilistb";
- private static final String CHECKIN = "checkin";
- private static final String LIST_WITH_LIST =
- "YtbTreeBuilderForListHavingList";
- private static final String CONT_CARRIER = "carrier";
- private static final String LIST_MULTIPLEXES = "multiplexes";
- private static final String TYPES = "types";
- private static final String TIME_DIVISION = "time-division";
- private static final String APP_AREA_LIST = "application-areas";
- private static final String DEST_AREA = "destination-areas";
- private static final String FREQUENCY_DIV = "frequency-division";
- private static final String MOD_BIT_BIN = "YtbDerivedTypeWithBitsAndBinary";
- private static final String FOR_BINARY = "forbinary";
- private static final String BIN_VAL_1 = "BQUF";
- private static final String FOR_BITS = "forbits";
- private static final String FOR_BINARY_LIST = "forbinarylist";
- private static final String BIN_VAL_2 = "CQkA";
- private static final String BIN_VAL_3 = "DAYA";
- private static final String BIN_VAL_4 = "EB0Z";
- private static final String FOR_BITS_LIST = "forbitslist";
- private static final String FOR_UNION = "forunion";
- private static final String ZERO = "0";
-
- @Rule
- public ExpectedException thrown = ExpectedException.none();
-
- private static String emptyObjErrMsg(String objName) {
- return "The " + objName + " given for tree creation cannot be null";
- }
-
- private static BigDecimal getBigDeci(int bigDecimal) {
- return BigDecimal.valueOf(bigDecimal);
- }
-
- /**
- * Processes an empty object list to the YTB and checks that the
- * exception is thrown.
- */
- @Test
- public void processInvalidListInput() {
- thrown.expect(YtbException.class);
- thrown.expectMessage(emptyObjErrMsg("object list"));
- DefaultYangTreeBuilder treeBuilder = new DefaultYangTreeBuilder();
- treeBuilder.getYdtBuilderForYo(null, ROOT_NAME, ROOT_NAME_SPACE,
- EDIT_CONFIG_REQUEST, null);
- }
-
- /**
- * Processes an empty notification object to the YTB and checks that the
- * exception is thrown.
- */
- @Test
- public void processInvalidInputForNotification() {
- thrown.expect(YtbException.class);
- thrown.expectMessage(emptyObjErrMsg("event object"));
- DefaultYangTreeBuilder treeBuilder = new DefaultYangTreeBuilder();
- treeBuilder.getYdtForNotification(null, ROOT_NAME, null);
- }
-
- /**
- * Processes an empty rpc output object to the YTB and checks that the
- * exception is thrown.
- */
- @Test
- public void processInvalidInputForRpc() {
- thrown.expect(YtbException.class);
- thrown.expectMessage(emptyObjErrMsg("output object"));
- DefaultYangTreeBuilder treeBuilder = new DefaultYangTreeBuilder();
- treeBuilder.getYdtForRpcResponse(null, null);
- }
-
- /**
- * Processes a YAB/YSB request to YTB with a leaf value being filled in
- * the app object. Checks the constructed YDT tree for module and leaf
- * and its value.
- */
- @Test
- public void processModuleAndLeaf() {
-
- schemaProvider.processSchemaRegistry(null);
- DefaultYangSchemaRegistry registry = schemaProvider
- .getDefaultYangSchemaRegistry();
-
- // As an application, creates the object.
- YtbIetfSchedule schedule = new YtbIetfScheduleOpParam
- .YtbIetfScheduleBuilder()
- .time((byte) 9)
- .onosYangNodeOperationType(OnosYangNodeOperationType.MERGE)
- .build();
-
- // As YSB or YAB protocol sets the value for YTB.
- List<Object> objectList = new ArrayList<>();
- objectList.add(schedule);
-
- // Builds YANG tree in YTB.
- DefaultYangTreeBuilder treeBuilder = new DefaultYangTreeBuilder();
- YdtExtendedBuilder ydtBuilder = treeBuilder.getYdtBuilderForYo(
- objectList, ROOT_NAME, ROOT_NAME_SPACE,
- EDIT_CONFIG_REQUEST, registry);
-
- // Receives YDT context and checks the tree that is built.
- YdtContext context = ydtBuilder.getRootNode();
-
- // Gets the first module from logical root node.
- YdtContext module = context.getFirstChild();
- YdtContextOperationType opType = ((YdtNode) module)
- .getYdtContextOperationType();
- assertThat(getInCrtName(MODULE, IETF_SCHEDULE),
- module.getName(), is(IETF_SCHEDULE));
- assertThat(getInCrtOpType(MODULE, IETF_SCHEDULE),
- opType, is(MERGE));
-
- // Gets the first leaf from module IetfSchedule.
- YdtContext leafContext = module.getFirstChild();
- assertThat(getInCrtName(LEAF, TIME),
- leafContext.getName(), is(TIME));
- assertThat(getInCrtLeafValue(TIME, NINE),
- leafContext.getValue(), is(NINE));
- }
-
- /**
- * Processes a YAB/YSB request to YTB with a leaf-list value being filled
- * in the app object. Checks the constructed YDT tree for module and
- * leaf-list and its value.
- */
- @Test
- public void processModuleAndLeafList() {
-
- schemaProvider.processSchemaRegistry(null);
- DefaultYangSchemaRegistry registry = schemaProvider
- .getDefaultYangSchemaRegistry();
-
- // As an application, creates the object.
-
- // Creates list of type long for setting the leaf-list.
- List<Long> longList = new ArrayList<>();
- longList.add((long) 1);
- longList.add((long) 2);
- longList.add((long) 3);
-
- YtbModuleWithLeafList leafListModule = new YtbModuleWithLeafListOpParam
- .YtbModuleWithLeafListBuilder().time(longList).build();
-
- // As YSB or YAB protocol sets the value for YTB.
- List<Object> objectList = new ArrayList<>();
- objectList.add(leafListModule);
-
- // Builds YANG tree in YTB.
- DefaultYangTreeBuilder treeBuilder = new DefaultYangTreeBuilder();
- YdtBuilder ydtBuilder = treeBuilder.getYdtBuilderForYo(
- objectList, ROOT_NAME, ROOT_NAME_SPACE, QUERY_REQUEST, registry);
-
- // Receives YDT context and check the tree that is built.
- YdtContext context = ydtBuilder.getRootNode();
-
- // Gets the first module from logical root node.
- YdtContext module = context.getFirstChild();
- YdtContextOperationType opType = ((YdtNode) module)
- .getYdtContextOperationType();
- assertThat(getInCrtName(MODULE, MOD_LEAF_LIST),
- module.getName(), is(MOD_LEAF_LIST));
- assertThat(getInCrtOpType(MODULE, MOD_LEAF_LIST), opType, is(NONE));
-
- // Gets the first leaf-list from module.
- YdtContext leafList = module.getFirstChild();
- assertThat(getInCrtName(LEAF_LIST, TIME), leafList.getName(),
- is(TIME));
- Set<String> value = leafList.getValueSet();
- assertThat(getInCrtLeafListValue(TIME, ONE),
- value.contains(ONE), is(true));
- assertThat(getInCrtLeafListValue(TIME, TWO),
- value.contains(TWO), is(true));
- assertThat(getInCrtLeafListValue(TIME, THREE),
- value.contains(THREE), is(true));
- }
-
- /**
- * Processes leaf and leaf-list with type enum under module. Checks the
- * constructed YDT tree has YANG enum value.
- */
- @Test
- public void processWithTypeEnum() {
-
- schemaProvider.processSchemaRegistry(null);
- DefaultYangSchemaRegistry registry = schemaProvider
- .getDefaultYangSchemaRegistry();
-
- // As an application, creates the object.
-
- // Creates enum list for setting the leaf-list.
- List<Enum2Enum> enumList = new ArrayList<>();
- enumList.add(Enum2Enum.HUNDRED_100);
- enumList.add(Enum2Enum.TEN_10);
- enumList.add(Enum2Enum.THOUSAND_1000);
-
- YtbIetfSchedule schedule = new YtbIetfScheduleOpParam
- .YtbIetfScheduleBuilder()
- .time((byte) 9)
- .onosYangNodeOperationType(OnosYangNodeOperationType.MERGE)
- .enum1(Enum1Enum.HUNDRED)
- .enum2(enumList)
- .build();
-
-
- // As YSB or YAB protocol sets the value for YTB.
- List<Object> objectList = new ArrayList<>();
- objectList.add(schedule);
-
- // Builds YANG tree in YTB.
- DefaultYangTreeBuilder treeBuilder = new DefaultYangTreeBuilder();
- YdtExtendedBuilder ydtBuilder = treeBuilder.getYdtBuilderForYo(
- objectList, ROOT_NAME, ROOT_NAME_SPACE,
- EDIT_CONFIG_REQUEST, registry);
-
- // Receives YDT context and check the tree that is built.
- YdtContext context = ydtBuilder.getRootNode();
-
- // Gets the first module from logical root node.
- YdtContext module = context.getFirstChild();
- YdtContextOperationType opType =
- ((YdtNode) module).getYdtContextOperationType();
- assertThat(getInCrtName(MODULE, IETF_SCHEDULE),
- module.getName(), is(IETF_SCHEDULE));
- assertThat(getInCrtOpType(MODULE, IETF_SCHEDULE), opType, is(MERGE));
-
- // Checks the leaf and leaf-list values.
- YdtContext timeLeaf = module.getFirstChild();
- assertThat(getInCrtName(LEAF, TIME), timeLeaf.getName(), is(TIME));
- assertThat(getInCrtLeafValue(TIME, NINE),
- timeLeaf.getValue(), is(NINE));
-
- YdtContext enum1Leaf = timeLeaf.getNextSibling();
- assertThat(getInCrtName(LEAF, ENUM_1), enum1Leaf.getName(), is(ENUM_1));
- assertThat(getInCrtLeafValue(ENUM_1, HUNDRED),
- enum1Leaf.getValue(), is(HUNDRED));
-
- YdtContext enum2LeafList = enum1Leaf.getNextSibling();
- assertThat(getInCrtName(LEAF_LIST, ENUM_2),
- enum2LeafList.getName(), is(ENUM_2));
- Set<String> valueSet = enum2LeafList.getValueSet();
- assertThat(getInCrtLeafListValue(ENUM_2, HUNDRED_100),
- valueSet.contains(HUNDRED_100), is(true));
- assertThat(getInCrtLeafListValue(ENUM_2, TEN_10),
- valueSet.contains(TEN_10), is(true));
- assertThat(getInCrtLeafListValue(ENUM_2, THOUSAND_1000),
- valueSet.contains(THOUSAND_1000), is(true));
- }
-
- /**
- * Processes a YAB/YSB request to YTB with a container having leaf value
- * being filled in the app object. Checks the constructed YDT tree for
- * module and container and leaf.
- */
- @Test
- public void processModuleWithContainer() {
-
- schemaProvider.processSchemaRegistry(null);
- DefaultYangSchemaRegistry registry = schemaProvider
- .getDefaultYangSchemaRegistry();
-
- // As an application, creates the object.
-
- // Creates container object with leaf of decimal type.
- Sched sched = new DefaultSched.SchedBuilder()
- .predict(getBigDeci(98989))
- .onosYangNodeOperationType(
- DefaultSched.OnosYangNodeOperationType.DELETE)
- .build();
- // Creates module object with the container.
- YtbModuleWithContainer contModule = new YtbModuleWithContainerOpParam
- .YtbModuleWithContainerBuilder()
- .sched(sched)
- .onosYangNodeOperationType(
- YtbModuleWithContainerOpParam
- .OnosYangNodeOperationType.CREATE)
- .build();
-
- // As YSB or YAB protocol sets the value for YTB.
- List<Object> objectList = new ArrayList<>();
- objectList.add(contModule);
-
- // Builds YANG tree in YTB.
- DefaultYangTreeBuilder treeBuilder = new DefaultYangTreeBuilder();
- YdtBuilder ydtBuilder = treeBuilder.getYdtBuilderForYo(
- objectList, ROOT_NAME, ROOT_NAME_SPACE,
- QUERY_CONFIG_REQUEST, registry);
-
- // Receives YDT context and check the tree that is built.
- YdtContext context = ydtBuilder.getRootNode();
-
- // Gets the first module from logical root node.
- YdtContext module = context.getFirstChild();
- YdtContextOperationType opType = ((YdtNode) module)
- .getYdtContextOperationType();
-
- assertThat(getInCrtName(MODULE, MOD_CONT),
- module.getName(), is(MOD_CONT));
- assertThat(getInCrtOpType(MODULE, MOD_CONT), opType, is(CREATE));
-
- // Get the container from module.
- YdtContext container = module.getFirstChild();
- YdtContextOperationType opTypeOfCont = ((YdtNode) container)
- .getYdtContextOperationType();
-
- assertThat(getInCrtName(CONTAINER, SCHED),
- container.getName(), is("sched"));
- assertThat(getInCrtOpType(CONTAINER, SCHED), opTypeOfCont, is(DELETE));
-
- // Gets leaf from container.
- YdtContext leafContext = container.getFirstChild();
- assertThat(getInCrtName(LEAF, PREDICT),
- leafContext.getName(), is(PREDICT));
- assertThat(getInCrtLeafValue(PREDICT, PREDICT_VAL),
- leafContext.getValue(), is(PREDICT_VAL));
- }
-
- /**
- * Processes a YAB/YSB request to YTB with a list having leaf-list value
- * being filled in the app object. Checks the constructed YDT tree for
- * module and list and leaf-list.
- */
- @Test
- public void processModuleWithList() {
-
- schemaProvider.processSchemaRegistry(null);
- DefaultYangSchemaRegistry registry = schemaProvider
- .getDefaultYangSchemaRegistry();
-
- // As an application, creates the object.
-
- // Creates multi typedef values.
- Find find1 = new Find(true);
- Find find2 = new Find(false);
- Find find3 = new Find(true);
- Find find4 = new Find(false);
-
- // Creates two lists, with the typedef values added.
- List<Find> findList1 = new ArrayList<>();
- List<Find> findList2 = new ArrayList<>();
- findList1.add(find1);
- findList1.add(find2);
- findList2.add(find3);
- findList2.add(find4);
-
- // Creates two list contents.
- Ytblistlist list1 = new DefaultYtblistlist
- .YtblistlistBuilder().prediction(findList1).build();
- Ytblistlist list2 = new DefaultYtblistlist
- .YtblistlistBuilder().prediction(findList2).build();
-
- List<Ytblistlist> ytbList = new ArrayList<>();
- ytbList.add(list1);
- ytbList.add(list2);
-
- // Creates module having list.
- YtbModuleWithList listModule = new YtbModuleWithListOpParam
- .YtbModuleWithListBuilder().ytblistlist(ytbList).build();
-
- // As YSB or YAB protocol sets the value for YTB.
- List<Object> objectList = new ArrayList<>();
- objectList.add(listModule);
-
- // Builds YANG tree in YTB.
- DefaultYangTreeBuilder treeBuilder = new DefaultYangTreeBuilder();
- YdtBuilder ydtBuilder = treeBuilder.getYdtBuilderForYo(
- objectList, ROOT_NAME, ROOT_NAME_SPACE,
- EDIT_CONFIG_REQUEST, registry);
-
- // Receives YDT context and check the tree that is built.
- YdtContext context = ydtBuilder.getRootNode();
-
- // Gets the first module from logical root node.
- YdtContext module = context.getFirstChild();
- YdtContextOperationType opType = ((YdtNode) module)
- .getYdtContextOperationType();
-
- assertThat(getInCrtName(MODULE, MOD_LIST),
- module.getName(), is(MOD_LIST));
- assertThat(getInCrtOpType(MODULE, MOD_LIST), opType, is(NONE));
-
- // Gets the first list from module YtbModuleWithList.
- YdtContext firstList = module.getFirstChild();
- YdtContextOperationType listOpType = ((YdtNode) firstList)
- .getYdtContextOperationType();
- // Checks the contents in the list.
- assertThat(getInCrtName(LIST, LIST_LIST),
- firstList.getName(), is(LIST_LIST));
- assertThat(getInCrtOpType(LIST, LIST_LIST), listOpType, is(NONE));
-
- // Gets the contents of the leaf-list in the first list content.
- YdtContext leafListInList1 = firstList.getFirstChild();
-
- // Evaluates the leaf-list values.
- Set leafListValue1 = leafListInList1.getValueSet();
- assertThat(getInCrtName(LEAF_LIST, PREDICTION),
- leafListInList1.getName(), is(PREDICTION));
- assertThat(getInCrtLeafListValue(PREDICTION, TRUE),
- leafListValue1.contains(TRUE), is(true));
- assertThat(getInCrtLeafListValue(PREDICTION, FALSE),
- leafListValue1.contains(FALSE), is(true));
-
- // Gets the second list from module YtbModuleWithList.
- YdtContext secondList = firstList.getNextSibling();
-
- // Gets the contents of the leaf-list in the second list content.
- YdtContext leafListInList2 = secondList.getFirstChild();
- // Evaluates the leaf-list values.
- Set leafListValue2 = leafListInList2.getValueSet();
- assertThat(getInCrtName(LEAF_LIST, PREDICTION),
- leafListInList2.getName(), is(PREDICTION));
- assertThat(getInCrtLeafListValue(PREDICTION, TRUE),
- leafListValue2.contains(TRUE), is(true));
- assertThat(getInCrtLeafListValue(PREDICTION, FALSE),
- leafListValue2.contains(FALSE), is(true));
- }
-
- /**
- * Processes multi notification under module when request comes for one
- * notification event in module.
- */
- @Test
- public void processMultiNotificationWithContainer() {
-
- schemaProvider.processSchemaRegistry(null);
- DefaultYangSchemaRegistry registry = schemaProvider
- .getDefaultYangSchemaRegistry();
-
- // As an application, creates the object.
-
- // Sets the bit value.
- BitSet bitleaf = new BitSet();
- bitleaf.set(5);
- bitleaf.set(7);
-
- // Creates container with the leaf.
- Ytbnot ytbnot = new DefaultYtbnot.YtbnotBuilder().notileaf(bitleaf)
- .build();
- // Creates notification with container.
- Fortesta testa = new DefaultFortesta.FortestaBuilder()
- .ytbnot(ytbnot).build();
- // Invokes event subject class with notification.
- YtbMultiNotificationWithContainerEventSubject eventSubject = new
- YtbMultiNotificationWithContainerEventSubject();
- eventSubject.fortesta(testa);
- // Invokes event class with the event type and the event subject obj.
- YtbMultiNotificationWithContainerEvent event =
- new YtbMultiNotificationWithContainerEvent(
- YtbMultiNotificationWithContainerEvent.Type.FORTESTA,
- eventSubject);
-
- // Builds YANG tree in YTB.
- DefaultYangTreeBuilder treeBuilder = new DefaultYangTreeBuilder();
- YdtContext ydtContext = treeBuilder.getYdtForNotification(
- event, ROOT_NAME, registry);
-
- // Gets the first module from logical root node.
- YdtContext context = ydtContext.getFirstChild();
- YdtContextOperationType opType = ((YdtNode) context)
- .getYdtContextOperationType();
-
- assertThat(getInCrtName(MODULE, MUL_NOTIFY), context.getName(),
- is(MUL_NOTIFY));
- assertThat(getInCrtOpType(MODULE, MUL_NOTIFY), opType, is(NONE));
-
- // Gets the notification under module.
- YdtContext notify = context.getFirstChild();
- YdtContextOperationType notifyOpType = ((YdtNode) notify)
- .getYdtContextOperationType();
-
- // Checks the contents in the first notification.
- assertThat(getInCrtName(NOTIFICATION, NOTIFY), notify.getName(),
- is(NOTIFY));
- assertThat(getInCrtOpType(NOTIFICATION, NOTIFY), notifyOpType,
- is(NONE));
-
- // Gets the container in notification
- YdtContext container = notify.getFirstChild();
- assertThat(getInCrtName(CONTAINER, YTB_NOTIFY_CONT),
- container.getName(), is(YTB_NOTIFY_CONT));
-
- // Evaluates the leaf values.
- YdtContext leafInCont = container.getFirstChild();
- assertThat(getInCrtName(LEAF, NOTIFY_LEAF), leafInCont.getName(),
- is(NOTIFY_LEAF));
- // TODO: check the bits to string.
- }
-
- /**
- * Processes multi module with list in both the modules and checks the
- * YANG data tree building.
- */
- @Test
- public void processMultiModule() {
-
- schemaProvider.processSchemaRegistry(null);
- DefaultYangSchemaRegistry registry = schemaProvider
- .getDefaultYangSchemaRegistry();
-
- // As an application, creates the object.
-
- // Creates list of big integer for leaf-list under list1.
- List<BigInteger> bigIntegerList = new ArrayList<>();
- bigIntegerList.add(BigInteger.valueOf(1));
- bigIntegerList.add(BigInteger.valueOf(2));
- bigIntegerList.add(BigInteger.valueOf(3));
- // Creates list of big integer for leaf-list under list2.
- List<BigInteger> bigIntegerList1 = new ArrayList<>();
- bigIntegerList1.add(BigInteger.valueOf(4));
- bigIntegerList1.add(BigInteger.valueOf(5));
- bigIntegerList1.add(BigInteger.valueOf(6));
-
- // Creates two list contents.
- Ytbmultilist listContent1 = new DefaultYtbmultilist
- .YtbmultilistBuilder().check(bigIntegerList).build();
- Ytbmultilist listContent2 = new DefaultYtbmultilist
- .YtbmultilistBuilder().check(bigIntegerList1).build();
-
- List<Ytbmultilist> ytbmultilists = new ArrayList<>();
- ytbmultilists.add(listContent1);
- ytbmultilists.add(listContent2);
-
- // Creates module-a with two list contents created.
- YtbMultiModulea modulea = new YtbMultiModuleaOpParam
- .YtbMultiModuleaBuilder().ytbmultilist(ytbmultilists).build();
-
- // Creates list of string for leaf-list under list1.
- List<String> stringList = new ArrayList<>();
- stringList.add(ANT);
- stringList.add(ANIMAL);
- stringList.add(BIRD);
-
- // Creates list of string for leaf-list under list2.
- List<String> stringList1 = new ArrayList<>();
- stringList1.add(CATCH);
- stringList1.add(BALL);
- stringList1.add(BAT);
-
- // Creates two list contents.
- Ytbmultilistb listContent3 = new DefaultYtbmultilistb
- .YtbmultilistbBuilder().checkin(stringList).build();
- Ytbmultilistb listContent4 = new DefaultYtbmultilistb
- .YtbmultilistbBuilder().checkin(stringList1).build();
-
- List<Ytbmultilistb> ytbMultiListb = new ArrayList<>();
- ytbMultiListb.add(listContent3);
- ytbMultiListb.add(listContent4);
-
- // Creates module-b with two list contents created.
- YtbMultiModuleb moduleb = new YtbMultiModulebOpParam
- .YtbMultiModulebBuilder().ytbmultilistb(ytbMultiListb).build();
-
- // As YSB or YAB protocol sets the value for YTB.
- List<Object> listOfModules = new ArrayList<>();
- listOfModules.add(modulea);
- listOfModules.add(moduleb);
-
- // Builds YANG tree in YTB.
- DefaultYangTreeBuilder treeBuilder = new DefaultYangTreeBuilder();
- YdtBuilder ydtBuilder = treeBuilder.getYdtBuilderForYo(
- listOfModules, ROOT_NAME, ROOT_NAME_SPACE,
- EDIT_CONFIG_REQUEST, registry);
-
- // Receives YDT context and check the tree that is built.
- YdtContext context = ydtBuilder.getRootNode();
-
- // Checks module-a under root node.
- YdtContext moduleA = context.getFirstChild();
- assertThat(getInCrtName(MODULE, MUL_MOD_A), moduleA.getName(),
- is(MUL_MOD_A));
-
- // Checks list-a in module-a and its respective leaf-list.
- YdtContext list1InModuleA = moduleA.getFirstChild();
- assertThat(getInCrtName(LIST, MUL_LIST_A), list1InModuleA.getName(),
- is(MUL_LIST_A));
-
- YdtContext leafListA = list1InModuleA.getFirstChild();
- assertThat(getInCrtName(LEAF_LIST, CHECK), leafListA.getName(),
- is(CHECK));
-
- Set<String> valueA = leafListA.getValueSet();
- assertThat(getInCrtLeafListValue(CHECK, ONE), valueA.contains(ONE),
- is(true));
- assertThat(getInCrtLeafListValue(CHECK, TWO), valueA.contains(TWO),
- is(true));
- assertThat(getInCrtLeafListValue(CHECK, THREE), valueA.contains(THREE),
- is(true));
-
- // Checks list-b in module-a and its respective leaf-list.
- YdtContext list2InModuleA = list1InModuleA.getNextSibling();
- assertThat(getInCrtName(LIST, MUL_LIST_A), list2InModuleA.getName(),
- is(MUL_LIST_A));
-
- YdtContext leafListB = list2InModuleA.getFirstChild();
- assertThat(getInCrtName(LEAF_LIST, CHECK), leafListB.getName(),
- is(CHECK));
-
- Set<String> valueB = leafListB.getValueSet();
- assertThat(getInCrtLeafListValue(CHECK, FOUR), valueB.contains(FOUR),
- is(true));
- assertThat(getInCrtLeafListValue(CHECK, FIVE), valueB.contains(FIVE),
- is(true));
- assertThat(getInCrtLeafListValue(CHECK, SIX), valueB.contains(SIX),
- is(true));
-
- // Checks module-b under root node.
- YdtContext moduleB = moduleA.getNextSibling();
- assertThat(getInCrtName(MODULE, MUL_MOD_B), moduleB.getName(),
- is(MUL_MOD_B));
-
- // Checks list-a in module-b and its respective leaf-list.
- YdtContext list1InModuleB = moduleB.getFirstChild();
- assertThat(getInCrtName(LIST, MUL_LIST_B), list1InModuleB.getName(),
- is(MUL_LIST_B));
-
- YdtContext leafListC = list1InModuleB.getFirstChild();
- assertThat(getInCrtName(LEAF_LIST, CHECKIN), leafListC.getName(),
- is(CHECKIN));
-
- Set<String> valueC = leafListC.getValueSet();
- assertThat(getInCrtLeafListValue(CHECKIN, ANT), valueC.contains(ANT),
- is(true));
- assertThat(getInCrtLeafListValue(CHECKIN, ANIMAL),
- valueC.contains(ANIMAL), is(true));
- assertThat(getInCrtLeafListValue(CHECKIN, BIRD),
- valueC.contains(BIRD), is(true));
-
- // Checks list-b in module-b and its respective leaf-list.
- YdtContext list2InModuleB = list1InModuleB.getNextSibling();
- assertThat(getInCrtName(LIST, MUL_LIST_B), list2InModuleB.getName(),
- is(MUL_LIST_B));
-
- YdtContext leafListD = list2InModuleB.getFirstChild();
- assertThat(getInCrtName(LEAF_LIST, CHECKIN), leafListD.getName(),
- is(CHECKIN));
-
- Set<String> valueD = leafListD.getValueSet();
- assertThat(getInCrtLeafListValue(CHECKIN, CATCH),
- valueD.contains(CATCH), is(true));
- assertThat(getInCrtLeafListValue(CHECKIN, BALL),
- valueD.contains(BALL), is(true));
- assertThat(getInCrtLeafListValue(CHECKIN, BAT),
- valueD.contains(BAT), is(true));
- }
-
- /**
- * Processes tree building when a list node is having list inside it.
- */
- @Test
- public void processTreeBuilderForListHavingList() {
-
- schemaProvider.processSchemaRegistry(null);
- DefaultYangSchemaRegistry registry = schemaProvider
- .getDefaultYangSchemaRegistry();
-
- // As an application, creates the object.
-
- // Creates two binary leaf-lists for two list app areas.
- List<byte[]> destArea1 = new ArrayList<>();
- byte[] arr = new byte[]{1, 6, 3};
- byte[] arr1 = new byte[]{2, 7, 4};
- destArea1.add(arr);
- destArea1.add(arr1);
-
- List<byte[]> destArea2 = new ArrayList<>();
- byte[] arr2 = new byte[]{3, 8, 4};
- byte[] arr3 = new byte[]{5, 6, 1};
- destArea2.add(arr2);
- destArea2.add(arr3);
-
- // Creates two app areas list.
- ApplicationAreas appArea1 = new DefaultApplicationAreas
- .ApplicationAreasBuilder().destinationAreas(destArea1).build();
- ApplicationAreas appArea2 = new DefaultApplicationAreas
- .ApplicationAreasBuilder().destinationAreas(destArea2).build();
-
- List<ApplicationAreas> applicationAreasList = new ArrayList<>();
- applicationAreasList.add(appArea1);
- applicationAreasList.add(appArea2);
-
- // Adds two lists under the multiplex list for content 1.
- Multiplexes mpx1 = new DefaultMultiplexes.MultiplexesBuilder()
- .types(TypesEnum.TIME_DIVISION)
- .applicationAreas(applicationAreasList).build();
-
- // Creates two binary leaf-lists for two list app areas.
- List<byte[]> destArea3 = new ArrayList<>();
- byte[] arrB = new byte[]{0, 0, 1};
- byte[] arr1B = new byte[]{1, 0, 0};
- destArea3.add(arrB);
- destArea3.add(arr1B);
-
- List<byte[]> destArea4 = new ArrayList<>();
- byte[] arr2B = new byte[]{7, 7, 7};
- byte[] arr3B = new byte[]{0, 1};
- destArea4.add(arr2B);
- destArea4.add(arr3B);
-
- // Creates two app areas list.
- ApplicationAreas appArea3 = new DefaultApplicationAreas
- .ApplicationAreasBuilder().destinationAreas(destArea3).build();
- ApplicationAreas appArea4 = new DefaultApplicationAreas
- .ApplicationAreasBuilder().destinationAreas(destArea4).build();
-
- List<ApplicationAreas> applicationAreasListB = new ArrayList<>();
- applicationAreasListB.add(appArea3);
- applicationAreasListB.add(appArea4);
-
- // Adds two lists under the multiplex list for content 2.
- Multiplexes mpx2 = new DefaultMultiplexes.MultiplexesBuilder()
- .types(TypesEnum.FREQUENCY_DIVISION)
- .applicationAreas(applicationAreasListB).build();
-
- List<Multiplexes> multiplexList = new ArrayList<>();
- multiplexList.add(mpx1);
- multiplexList.add(mpx2);
-
- // Sets it in the container carrier.
- Carrier carrier = new DefaultCarrier.CarrierBuilder()
- .multiplexes(multiplexList).build();
-
- YtbTreeBuilderForListHavingList listWithList = new
- YtbTreeBuilderForListHavingListOpParam
- .YtbTreeBuilderForListHavingListBuilder()
- .carrier(carrier).build();
-
- // As YSB or YAB protocol sets the value for YTB.
- List<Object> objectList = new ArrayList<>();
- objectList.add(listWithList);
-
- DefaultYangTreeBuilder treeBuilder = new DefaultYangTreeBuilder();
- YdtBuilder ydtBuilder = treeBuilder.getYdtBuilderForYo(
- objectList, ROOT_NAME, ROOT_NAME_SPACE,
- QUERY_CONFIG_REQUEST, registry);
-
- // Receives YDT context and check the tree that is built.
- YdtContext context = ydtBuilder.getRootNode();
-
- // Gets the first module from logical root node.
- YdtContext module = context.getFirstChild();
- assertThat(getInCrtName(LIST, LIST_WITH_LIST), module.getName(),
- is(LIST_WITH_LIST));
-
- // Checks the container node under module node.
- YdtContext container = module.getFirstChild();
- assertThat(getInCrtName(CONTAINER, CONT_CARRIER), container.getName(),
- is(CONT_CARRIER));
-
- // Checks the list node with content 1 of multiplex.
- YdtContext mtx1 = container.getFirstChild();
- assertThat(getInCrtName(LIST, LIST_MULTIPLEXES), mtx1.getName(),
- is(LIST_MULTIPLEXES));
-
- // Checks enum leaf under multiplex of content1.
- YdtContext enumLeaf1 = mtx1.getFirstChild();
- assertThat(getInCrtName(LEAF, TYPES), enumLeaf1.getName(), is(TYPES));
- assertThat(getInCrtLeafValue(TYPES, TIME_DIVISION),
- enumLeaf1.getValue(), is(TIME_DIVISION));
-
- // Checks list app area content 1 under multiplex content 1.
- YdtContext appAreaList1 = enumLeaf1.getNextSibling();
- assertThat(getInCrtName(LIST, APP_AREA_LIST), appAreaList1.getName(),
- is(APP_AREA_LIST));
-
- YdtContext leafList1 = appAreaList1.getFirstChild();
- assertThat(getInCrtName(LEAF_LIST, DEST_AREA), leafList1.getName(),
- is(DEST_AREA));
- Set value1 = leafList1.getValueSet();
- // TODO: check the leaf-list value.
-
- // Checks list app area content 2 under multiplex content 1.
- YdtContext appAreaList2 = appAreaList1.getNextSibling();
- assertThat(getInCrtName(LIST, APP_AREA_LIST), appAreaList2.getName(),
- is(APP_AREA_LIST));
-
- YdtContext leafList2 = appAreaList2.getFirstChild();
- assertThat(getInCrtName(LEAF_LIST, DEST_AREA), leafList2.getName(),
- is(DEST_AREA));
- Set value2 = leafList1.getValueSet();
- // TODO: check the leaf-list value.
-
- // Checks the list node with content 2 of multiplex.
- YdtContext mtx2 = mtx1.getNextSibling();
- assertThat(getInCrtName(LIST, LIST_MULTIPLEXES), mtx2.getName(),
- is(LIST_MULTIPLEXES));
-
- // Checks enum leaf under multiplex of content2.
- YdtContext enumLeaf2 = mtx2.getFirstChild();
- assertThat(getInCrtName(LEAF, TYPES), enumLeaf2.getName(), is(TYPES));
- assertThat(getInCrtLeafValue(TYPES, FREQUENCY_DIV),
- enumLeaf2.getValue(), is(FREQUENCY_DIV));
-
- // Checks list app area content 1 under multiplex content 2.
- YdtContext appAreaList3 = enumLeaf2.getNextSibling();
- assertThat(getInCrtName(LIST, APP_AREA_LIST), appAreaList3.getName(),
- is(APP_AREA_LIST));
-
- YdtContext leafList3 = appAreaList3.getFirstChild();
- assertThat(getInCrtName(LEAF_LIST, DEST_AREA), leafList3.getName(),
- is(DEST_AREA));
- Set value3 = leafList3.getValueSet();
- // TODO: check the leaf-list value.
-
- // Checks list app area content 2 under multiplex content 2.
- YdtContext appAreaList4 = appAreaList3.getNextSibling();
- assertThat(getInCrtName(LIST, APP_AREA_LIST), appAreaList4.getName(),
- is(APP_AREA_LIST));
-
- YdtContext leafList4 = appAreaList4.getFirstChild();
- assertThat(getInCrtName(LEAF_LIST, DEST_AREA), leafList4.getName(),
- is(DEST_AREA));
- Set value4 = leafList4.getValueSet();
- // TODO: check the leaf-list value.
- }
-
- /**
- * Processes tree building from the derived type of leaf and leaf-list
- * having binary and bits .
- */
- @Test
- public void processTreeBuilderForBinaryAndBits() {
- schemaProvider.processSchemaRegistry(null);
- DefaultYangSchemaRegistry registry = schemaProvider
- .getDefaultYangSchemaRegistry();
-
- // As an application, creates the object.
-
- // Creates a byte array for binary leaf.
- byte[] binLeaf = new byte[]{5, 5, 5};
-
- // Assigns the value in the chained loop of typedef.
- Derivedbinaryb derBinb = new Derivedbinaryb(binLeaf);
- Derivedbinarya derBina = new Derivedbinarya(derBinb);
-
- // Creates bit set for bit leaf.
- BitSet bitLeaf = new BitSet();
- bitLeaf.set(1);
- bitLeaf.set(100);
-
- // Assigns the value in the chained loop of typedef.
- Derivedbitsb derBitb = new Derivedbitsb(bitLeaf);
- Derivedbitsa derBita = new Derivedbitsa(derBitb);
-
- // Creates a byte array list for binary leaf-list.
- byte[] binList1 = new byte[]{9, 9, 0};
- byte[] binList2 = new byte[]{12, 6, 0};
- byte[] binList3 = new byte[]{16, 29, 25};
-
- // Assigns the value in the chained loop of typedef.
- Derivedbinaryb derBinBList1 = new Derivedbinaryb(binList1);
- Derivedbinaryb derBinBList2 = new Derivedbinaryb(binList2);
- Derivedbinaryb derBinBList3 = new Derivedbinaryb(binList3);
-
- Derivedbinarya derBinAList1 = new Derivedbinarya(derBinBList1);
- Derivedbinarya derBinAList2 = new Derivedbinarya(derBinBList2);
- Derivedbinarya derBinAList3 = new Derivedbinarya(derBinBList3);
-
- List<Derivedbinarya> binAlist = new ArrayList<>();
- binAlist.add(derBinAList1);
- binAlist.add(derBinAList2);
- binAlist.add(derBinAList3);
-
- // Creates a bit set list for bit leaf-list.
- BitSet bitList1 = new BitSet();
- bitList1.set(1);
- BitSet bitList2 = new BitSet();
- bitList2.set(1);
- bitList2.set(10);
- BitSet bitList3 = new BitSet();
- bitList3.set(1);
- bitList3.set(10);
- bitList3.set(100);
-
- // Assigns the value in the chained loop of typedef.
- Derivedbitsb bitBlist1 = new Derivedbitsb(bitList1);
- Derivedbitsb bitBlist2 = new Derivedbitsb(bitList2);
- Derivedbitsb bitBlist3 = new Derivedbitsb(bitList3);
-
- Derivedbitsa bitAlist1 = new Derivedbitsa(bitBlist1);
- Derivedbitsa bitAlist2 = new Derivedbitsa(bitBlist2);
- Derivedbitsa bitAlist3 = new Derivedbitsa(bitBlist3);
-
- List<Derivedbitsa> bitAlist = new ArrayList<>();
- bitAlist.add(bitAlist1);
- bitAlist.add(bitAlist2);
- bitAlist.add(bitAlist3);
-
- // Creates a module by assigning all the leaf and leaf-list.
- YtbDerivedTypeWithBitsAndBinary bitsAndBinary = new
- YtbDerivedTypeWithBitsAndBinaryOpParam
- .YtbDerivedTypeWithBitsAndBinaryBuilder()
- .forbinary(derBina).forbits(derBita)
- .forbinarylist(binAlist)
- .forbitslist(bitAlist).build();
-
- // As YSB or YAB protocol, sets the value for YTB.
- List<Object> objectList = new ArrayList<>();
- objectList.add(bitsAndBinary);
-
- // Builds YANG tree in YTB.
- DefaultYangTreeBuilder treeBuilder = new DefaultYangTreeBuilder();
- YdtExtendedBuilder ydtBuilder = treeBuilder.getYdtBuilderForYo(
- objectList, ROOT_NAME, ROOT_NAME_SPACE,
- EDIT_CONFIG_REQUEST, registry);
-
- // Receives YDT context and check the tree that is built.
- YdtContext context = ydtBuilder.getRootNode();
-
- // Gets the first module from logical root node.
- YdtContext module = context.getFirstChild();
- assertThat(getInCrtName(MODULE, MOD_BIT_BIN), module.getName(),
- is(MOD_BIT_BIN));
-
- // Checks the leaf for binary.
- YdtContext binaryLeaf = module.getFirstChild();
- assertThat(getInCrtName(LEAF, FOR_BINARY), binaryLeaf.getName(),
- is(FOR_BINARY));
- assertThat(getInCrtLeafValue(FOR_BINARY, BIN_VAL_1),
- binaryLeaf.getValue(), is(BIN_VAL_1));
-
- // Checks the leaf for bits.
- YdtContext bitsLeaf = binaryLeaf.getNextSibling();
- assertThat(getInCrtName(LEAF, FOR_BITS), bitsLeaf.getName(),
- is(FOR_BITS));
- // TODO: The bits is not done.
- String value1 = bitsLeaf.getValue();
-
- // Checks the leaf-list for binary.
- YdtContext binaryLeafList = bitsLeaf.getNextSibling();
- assertThat(getInCrtName(LEAF_LIST, FOR_BINARY_LIST),
- binaryLeafList.getName(), is(FOR_BINARY_LIST));
-
- Set value2 = binaryLeafList.getValueSet();
- assertThat(getInCrtLeafListValue(FOR_BINARY_LIST, BIN_VAL_2),
- value2.contains(BIN_VAL_2), is(true));
- assertThat(getInCrtLeafListValue(FOR_BINARY_LIST, BIN_VAL_3),
- value2.contains(BIN_VAL_3), is(true));
- assertThat(getInCrtLeafListValue(FOR_BINARY_LIST, BIN_VAL_4),
- value2.contains(BIN_VAL_4), is(true));
-
- // Checks the leaf-list for bits.
- YdtContext bitsLeafList = binaryLeafList.getNextSibling();
- assertThat(getInCrtName(LEAF_LIST, FOR_BITS_LIST),
- bitsLeafList.getName(), is(FOR_BITS_LIST));
- // TODO: The value of bits should be mapped text string.
- Set value3 = bitsLeafList.getValueSet();
- }
-
- /**
- * Processes tree building for the union type.
- */
- @Test
- public void processYtbUnionType() {
- schemaProvider.processSchemaRegistry(null);
- DefaultYangSchemaRegistry registry = schemaProvider
- .getDefaultYangSchemaRegistry();
-
- // As an application, creates the object.
-
- // Creates union with binary type.
- byte[] binary = new byte[]{0, 0, 0};
- ForunionUnion union = new ForunionUnion(binary);
-
- // Creates module with union.
- YtbDerivedTypeWithBitsAndBinary unionType = new
- YtbDerivedTypeWithBitsAndBinaryOpParam
- .YtbDerivedTypeWithBitsAndBinaryBuilder()
- .forunion(union)
- .build();
-
- // As YSB or YAB protocol, sets the value for YTB.
- List<Object> objectList = new ArrayList<>();
- objectList.add(unionType);
-
- // Builds YANG tree in YTB.
- DefaultYangTreeBuilder treeBuilder = new DefaultYangTreeBuilder();
- YdtExtendedBuilder ydtBuilder = treeBuilder.getYdtBuilderForYo(
- objectList, ROOT_NAME, ROOT_NAME_SPACE,
- EDIT_CONFIG_REQUEST, registry);
-
- // Receives YDT context and check the tree that is built.
- YdtContext rootNode = ydtBuilder.getRootNode();
- YdtContext module = rootNode.getFirstChild();
- YdtContext unionChild = module.getFirstChild();
- assertThat(getInCrtName(LEAF, FOR_UNION), unionChild.getName(),
- is(FOR_UNION));
- //TODO: Correct it once union generated code is fixed.
- assertThat(getInCrtLeafValue(FOR_UNION, ZERO), unionChild.getValue(),
- is(ZERO));
- }
-}
diff --git a/apps/yms/app/src/test/java/org/onosproject/yms/app/ytb/YtbContextSwitchTest.java b/apps/yms/app/src/test/java/org/onosproject/yms/app/ytb/YtbContextSwitchTest.java
deleted file mode 100644
index ef48954..0000000
--- a/apps/yms/app/src/test/java/org/onosproject/yms/app/ytb/YtbContextSwitchTest.java
+++ /dev/null
@@ -1,1237 +0,0 @@
-/*
- * 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.ytb;
-
-import org.junit.Test;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev20130715.ymsietfinettypes.Uri;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev20151208.YmsIetfNetwork;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev20151208.YmsIetfNetworkOpParam;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev20151208.ymsietfnetwork.DefaultNetworks;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev20151208.ymsietfnetwork.Networks;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev20151208.ymsietfnetwork.NodeId;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev20151208.ymsietfnetwork.networks.DefaultNetwork;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev20151208.ymsietfnetwork.networks.Network;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev20151208.ymsietfnetwork.networks.network.DefaultNode;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev20151208.ymsietfnetwork.networks.network.Node;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev20151208.ymsietfnetwork.networks.network.node.DefaultSupportingNode;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev20151208.ymsietfnetwork.networks.network.node.SupportingNode;
-import org.onosproject.yang.gen.v1.yms.test.ytb.augment.from.another.file.rev20160826.ytbaugmentfromanotherfile.networks.network.node.AugmentedNdNode;
-import org.onosproject.yang.gen.v1.yms.test.ytb.augment.from.another.file.rev20160826.ytbaugmentfromanotherfile.networks.network.node.DefaultAugmentedNdNode;
-import org.onosproject.yang.gen.v1.yms.test.ytb.augment.from.another.file.rev20160826.ytbaugmentfromanotherfile.networks.network.node.augmentedndnode.DefaultTerminationPoint;
-import org.onosproject.yang.gen.v1.yms.test.ytb.augment.from.another.file.rev20160826.ytbaugmentfromanotherfile.networks.network.node.augmentedndnode.TerminationPoint;
-import org.onosproject.yang.gen.v1.yms.test.ytb.augment.from.another.file.rev20160826.ytbaugmentfromanotherfile.networks.network.node.augmentedndnode.terminationpoint.DefaultSupportingTerminationPoint;
-import org.onosproject.yang.gen.v1.yms.test.ytb.augment.from.another.file.rev20160826.ytbaugmentfromanotherfile.networks.network.node.augmentedndnode.terminationpoint.SupportingTerminationPoint;
-import org.onosproject.yang.gen.v1.yms.test.ytb.augment.yangautoprefixfor.rpc.input.rev20160826.ytbaugmentforrpcinput.activatesoftwareimage.output.AugmentedRpcOutput;
-import org.onosproject.yang.gen.v1.yms.test.ytb.augment.yangautoprefixfor.rpc.input.rev20160826.ytbaugmentforrpcinput.activatesoftwareimage.output.DefaultAugmentedRpcOutput;
-import org.onosproject.yang.gen.v1.yms.test.ytb.augment.yangautoprefixfor.rpc.input.rev20160826.ytbaugmentforrpcinput.activatesoftwareimage.output.augmentedrpcoutput.Selection;
-import org.onosproject.yang.gen.v1.yms.test.ytb.augment.yangautoprefixfor.rpc.input.rev20160826.ytbaugmentforrpcinput.activatesoftwareimage.output.augmentedrpcoutput.selection.DefaultValueIn;
-import org.onosproject.yang.gen.v1.yms.test.ytb.augment.yangautoprefixfor.rpc.input.rev20160826.ytbaugmentforrpcinput.activatesoftwareimage.output.augmentedrpcoutput.selection.valuein.ValueIn;
-import org.onosproject.yang.gen.v1.yms.test.ytb.augment.yangautoprefixfor.rpc.input.rev20160826.ytbaugmentforrpcinput2.activatesoftwareimage.output.AugmentedInputOutput;
-import org.onosproject.yang.gen.v1.yms.test.ytb.augment.yangautoprefixfor.rpc.input.rev20160826.ytbaugmentforrpcinput2.activatesoftwareimage.output.DefaultAugmentedInputOutput;
-import org.onosproject.yang.gen.v1.yms.test.ytb.augment.yangautoprefixfor.rpc.input.rev20160826.ytbaugmentforrpcinput2.activatesoftwareimage.output.augmentedinputoutput.DefaultFriction;
-import org.onosproject.yang.gen.v1.yms.test.ytb.augment.yangautoprefixfor.rpc.input.rev20160826.ytbaugmentforrpcinput2.activatesoftwareimage.output.augmentedinputoutput.Friction;
-import org.onosproject.yang.gen.v1.yms.test.ytb.choice.with.container.and.leaf.list.rev20160826.YtbChoiceWithContainerAndLeafList;
-import org.onosproject.yang.gen.v1.yms.test.ytb.choice.with.container.and.leaf.list.rev20160826.YtbChoiceWithContainerAndLeafListOpParam;
-import org.onosproject.yang.gen.v1.yms.test.ytb.choice.with.container.and.leaf.list.rev20160826.ytbchoicewithcontainerandleaflist.ContentTest;
-import org.onosproject.yang.gen.v1.yms.test.ytb.choice.with.container.and.leaf.list.rev20160826.ytbchoicewithcontainerandleaflist.CurrentValue;
-import org.onosproject.yang.gen.v1.yms.test.ytb.choice.with.container.and.leaf.list.rev20160826.ytbchoicewithcontainerandleaflist.contenttest.DefaultChoiceContainer;
-import org.onosproject.yang.gen.v1.yms.test.ytb.choice.with.container.and.leaf.list.rev20160826.ytbchoicewithcontainerandleaflist.contenttest.choicecontainer.ChoiceContainer;
-import org.onosproject.yang.gen.v1.yms.test.ytb.choice.with.container.and.leaf.list.rev20160826.ytbchoicewithcontainerandleaflist.contenttest.choicecontainer.choicecontainer.DefaultPredict;
-import org.onosproject.yang.gen.v1.yms.test.ytb.choice.with.container.and.leaf.list.rev20160826.ytbchoicewithcontainerandleaflist.contenttest.choicecontainer.choicecontainer.Predict;
-import org.onosproject.yang.gen.v1.yms.test.ytb.choice.with.container.and.leaf.list.rev20160826.ytbchoicewithcontainerandleaflist.contenttest.choicecontainer.choicecontainer.predict.DefaultReproduce;
-import org.onosproject.yang.gen.v1.yms.test.ytb.choice.with.container.and.leaf.list.rev20160826.ytbchoicewithcontainerandleaflist.contenttest.choicecontainer.choicecontainer.predict.Reproduce;
-import org.onosproject.yang.gen.v1.yms.test.ytb.choice.with.container.and.leaf.list.rev20160826.ytbchoicewithcontainerandleaflist.currentvalue.DefaultYtbAbsent;
-import org.onosproject.yang.gen.v1.yms.test.ytb.rpc.response.with.advanced.input.and.output.rev20160826.ytbrpcresponsewithadvancedinputandoutput.activatesoftwareimage.ActivateSoftwareImageOutput;
-import org.onosproject.yang.gen.v1.yms.test.ytb.rpc.response.with.advanced.input.and.output.rev20160826.ytbrpcresponsewithadvancedinputandoutput.activatesoftwareimage.DefaultActivateSoftwareImageOutput;
-import org.onosproject.yang.gen.v1.yms.test.ytb.rpc.response.with.advanced.input.and.output.rev20160826.ytbrpcresponsewithadvancedinputandoutput.activatesoftwareimage.activatesoftwareimageoutput.DefaultOutputList;
-import org.onosproject.yang.gen.v1.yms.test.ytb.rpc.response.with.advanced.input.and.output.rev20160826.ytbrpcresponsewithadvancedinputandoutput.activatesoftwareimage.activatesoftwareimageoutput.OutputList;
-import org.onosproject.yang.gen.v1.yms.test.ytb.rpc.response.with.advanced.input.and.output.rev20160826.ytbrpcresponsewithadvancedinputandoutput.activatesoftwareimage.activatesoftwareimageoutput.outputlist.ContentInside;
-import org.onosproject.yang.gen.v1.yms.test.ytb.rpc.response.with.advanced.input.and.output.rev20160826.ytbrpcresponsewithadvancedinputandoutput.activatesoftwareimage.activatesoftwareimageoutput.outputlist.DefaultContentInside;
-import org.onosproject.yang.gen.v1.yms.test.ytb.simple.augment.rev20160826.YtbSimpleAugment;
-import org.onosproject.yang.gen.v1.yms.test.ytb.simple.augment.rev20160826.YtbSimpleAugmentOpParam;
-import org.onosproject.yang.gen.v1.yms.test.ytb.simple.augment.rev20160826.ytbsimpleaugment.Cont1;
-import org.onosproject.yang.gen.v1.yms.test.ytb.simple.augment.rev20160826.ytbsimpleaugment.DefaultCont1;
-import org.onosproject.yang.gen.v1.yms.test.ytb.simple.augment.rev20160826.ytbsimpleaugment.cont1.DefaultCont2;
-import org.onosproject.yang.gen.v1.yms.test.ytb.simple.augment.rev20160826.ytbsimpleaugment.cont1.cont2.AugmentedCont2;
-import org.onosproject.yang.gen.v1.yms.test.ytb.simple.augment.rev20160826.ytbsimpleaugment.cont1.cont2.DefaultAugmentedCont2;
-import org.onosproject.yang.gen.v1.yms.test.ytb.simple.augment.rev20160826.ytbsimpleaugment.cont1.cont2.augmentedcont2.Cont1s;
-import org.onosproject.yang.gen.v1.yms.test.ytb.simple.augment.rev20160826.ytbsimpleaugment.cont1.cont2.augmentedcont2.DefaultCont1s;
-import org.onosproject.yang.gen.v1.yms.test.ytb.simple.choice.yangautoprefixcase.rev20160826.YtbSimpleChoiceCase;
-import org.onosproject.yang.gen.v1.yms.test.ytb.simple.choice.yangautoprefixcase.rev20160826.YtbSimpleChoiceCaseOpParam;
-import org.onosproject.yang.gen.v1.yms.test.ytb.simple.choice.yangautoprefixcase.rev20160826.ytbsimplechoicecase.DefaultYtbFood;
-import org.onosproject.yang.gen.v1.yms.test.ytb.simple.choice.yangautoprefixcase.rev20160826.ytbsimplechoicecase.YtbFood;
-import org.onosproject.yang.gen.v1.yms.test.ytb.simple.choice.yangautoprefixcase.rev20160826.ytbsimplechoicecase.ytbfood.YtbSnack;
-import org.onosproject.yang.gen.v1.yms.test.ytb.simple.choice.yangautoprefixcase.rev20160826.ytbsimplechoicecase.ytbfood.ytbsnack.DefaultYtbLateNight;
-import org.onosproject.yang.gen.v1.yms.test.ytb.simple.rpc.response.rev20160826.ytbsimplerpcresponse.rpc.DefaultRpcOutput;
-import org.onosproject.yang.gen.v1.yms.test.ytb.simple.rpc.response.rev20160826.ytbsimplerpcresponse.rpc.RpcOutput;
-import org.onosproject.yms.app.ydt.YangRequestWorkBench;
-import org.onosproject.yms.app.ydt.YdtExtendedBuilder;
-import org.onosproject.yms.app.ysr.DefaultYangSchemaRegistry;
-import org.onosproject.yms.ydt.YdtContext;
-
-import java.math.BigInteger;
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Set;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.core.Is.is;
-import static org.hamcrest.core.IsNull.notNullValue;
-import static org.onosproject.yms.ydt.YdtContextOperationType.NONE;
-import static org.onosproject.yms.ydt.YmsOperationType.EDIT_CONFIG_REPLY;
-import static org.onosproject.yms.ydt.YmsOperationType.EDIT_CONFIG_REQUEST;
-import static org.onosproject.yms.ydt.YmsOperationType.QUERY_CONFIG_REPLY;
-import static org.onosproject.yms.ydt.YmsOperationType.RPC_REQUEST;
-
-/**
- * Unit test cases for YANG tree builder for context switch for augment, RPC
- * and case.
- */
-public class YtbContextSwitchTest extends YtbErrMsgAndConstants {
-
- private static final String RPC_ADV_NAME = "RPCAdvanced";
- private static final String RPC_ADV_NAMESPACE = "RPCAdvancedSpace";
- private static final String RPC_ADV_IO =
- "YtbRpcResponseWithAdvancedInputAndOutput";
- private static final String ACT_IMG = "activate-software-image";
- private static final String INPUT = "input";
- private static final String FINAL = "final";
- private static final String AUG_NW_REF_1 = "network-ref-aug1";
- private static final String AUG_NODE_REF_1 = "node-ref-aug1";
- private static final String AUG_TP_REF_1 = "tp-ref-aug-1";
- private static final String AUG_TP_ID_1 = "tp-id-aug-1";
- private static final String AUG_NW_REF_B1 = "network-ref-augb1";
- private static final String AUG_NODE_REF_B1 = "node-ref-augb1";
- private static final String AUG_TP_REF_B1 = "tp-ref-aug-b1";
- private static final String AUG_TP_ID_B1 = "tp-id-aug-1b";
- private static final String NW_REF = "network-ref";
- private static final String NODE_REF = "node-ref";
- private static final String NW_REF_2 = "network-ref2";
- private static final String NODE_REF_3 = "node-ref3";
- private static final String NW_REF_B = "network-ref-b";
- private static final String NODE_REF_B = "node-ref-b";
- private static final String NW_REF_2B = "network-ref2-b";
- private static final String NODE_REF_2B = "node-ref2-b";
- private static final String NODE_REF_3B = "node-ref3-b";
- private static final String CHOC = "choc";
- private static final String CHOICE_CASE = "YtbSimpleChoiceCase";
- private static final String FOOD = "YtbFood";
- private static final String CHOCOLATE = "chocolate";
- private static final String VAL = "val";
- private static final String IND = "ind";
- private static final String CHOICE_ROOT_NAME = "choiceContainerRootName";
- private static final String CHOICE_ROOT_NAMESPACE =
- "choiceContainerRootNamespace";
- private static final String ROOT = "root";
- private static final String CHOICE_CONT =
- "YtbChoiceWithContainerAndLeafList";
- private static final String CONT_CHOICE = "choice-container";
- private static final String REPRODUCE = "reproduce";
- private static final String NINETY = "90";
- private static final String HUNDRED = "100";
- private static final String RPC_RT_NAME = "rpcRootName";
- private static final String RPC_RT_NAMESPACE = "rpcRootNameSpace";
- private static final String OUTPUT_LEAF = "output-leaf";
- private static final String FIVE_HUNDRED = "500";
- private static final String OUTPUT_LIST = "output-list";
- private static final String LIST_KEY = "list-key";
- private static final String BIN_VAL_1 = "AAE=";
- private static final String CONT_INSIDE = "content_inside";
- private static final String BIN_VAL_2 = "CAk=";
- private static final String AVAILABLE = "available";
- private static final String EIGHTY_NINE = "89";
- private static final String NINETY_EIGHT = "98";
- private static final String BIN_VAL_3 = "AAA=";
- private static final String SIM_AUG = "simpleAugment";
- private static final String SIM_AUG_NAMESPACE = "simpleAugmentSpace";
- private static final String SIMPLE_AUG = "YtbSimpleAugment";
- private static final String CONT1 = "cont1";
- private static final String CONT2 = "cont2";
- private static final String LEAF4 = "leaf4";
- private static final String CONT1S = "cont1s";
- private static final String INTER_AUG = "inter-file-augment";
- private static final String INTER_AUG_NAMESPACE =
- "inter-file-augment-space";
- private static final String IETF_NW = "yms-ietf-network";
- private static final String NWS = "networks";
- private static final String NW = "network";
- private static final String NODE = "node";
- private static final String NODE_ID = "node-id";
- private static final String TERM_POINT = "termination-point";
- private static final String TP_ID = "tp-id";
- private static final String SUP_TERM_POINT = "supporting-termination-point";
- private static final String TP_REF = "tp-ref";
- private static final String SUP_NODE = "supporting-node";
- private static final String KIN1 = "kin1";
- private static final String KIN2 = "kin2";
- private static final String VAL_IN = "value-in";
- private static final String KINETIC = "kinetic";
- private static final String FRICTION = "friction";
- private static final String SPEED = "speed";
- private static final String THOUSAND = "1000";
-
- /**
- * Creates object as like an application for RPC with list.
- *
- * @return object of RPC
- */
- private List<OutputList> createApplicationBuiltObjectForRpc() {
-
- // Creates a empty container inside without leaf for list1.
- ContentInside inside1 = new DefaultContentInside.ContentInsideBuilder()
- .build();
-
- // Creates a leaf list-key which is a leaf ref.
- byte[] listKey1 = new byte[]{0, 1};
-
- // Creates the list content 1.
- OutputList output1 = new DefaultOutputList.OutputListBuilder()
- .listKey(listKey1).contentInside(inside1).build();
-
- // Creates a list of leaf for available.
- List<Short> avail = new ArrayList<>();
- avail.add((short) 89);
- avail.add((short) 98);
-
- // Adds the leaf list in the inside container.
- ContentInside inside2 = new DefaultContentInside.ContentInsideBuilder()
- .available(avail).build();
-
- // Creates a leaf, list-key which is a leaf ref.
- byte[] listKey2 = new byte[]{8, 9};
-
- // Creates the list content 2.
- OutputList outputList2 = new DefaultOutputList.OutputListBuilder()
- .listKey(listKey2).contentInside(inside2).build();
-
- // Creates only leaf, list-key which is a leaf ref.
- byte[] arr3 = new byte[]{0, 0};
-
- // Creates the list content 3.
- OutputList outputList3 = new DefaultOutputList.OutputListBuilder()
- .listKey(arr3).build();
-
- // Adds all the list contents in array list and gives returns it.
- List<OutputList> outputLists = new ArrayList<>();
- outputLists.add(output1);
- outputLists.add(outputList2);
- outputLists.add(outputList3);
- return outputLists;
- }
-
- /**
- * Builds YANG request work bench for RPC with container input.
- *
- * @param registry schema registry
- * @return YANG request work bench
- */
- private YangRequestWorkBench buildYangRequestWorkBenchForRpc(
- DefaultYangSchemaRegistry registry) {
-
- // Creates a request work bench and adds the input child into it.
- YangRequestWorkBench workBench = new YangRequestWorkBench(
- RPC_ADV_NAME, RPC_ADV_NAMESPACE, RPC_REQUEST,
- registry, true);
- Set<String> valueList = new HashSet<>();
- valueList.add("800");
- valueList.add("900");
- workBench.addChild(RPC_ADV_IO, null, NONE);
- workBench.addChild(ACT_IMG, null, NONE);
- workBench.addChild(INPUT, null, NONE);
- workBench.addChild(FINAL, null, NONE);
- workBench.addLeaf("value", null, valueList);
- return workBench;
- }
-
- /**
- * Creates an application object for inter file augment.
- *
- * @return application object
- */
- private Object createObjectForInterFileAugment() {
-
- // Creates leaf value for network-ref.
- Uri nwkRef = new Uri(AUG_NW_REF_1);
- Uri nwkRef2 = new Uri("network-ref-aug2");
-
- // Creates leaf value for node-ref
- Uri nodeRef = new Uri(AUG_NODE_REF_1);
- NodeId nodeId = new NodeId(nodeRef);
-
- Uri nodeRef2 = new Uri("node-ref-aug2");
- NodeId nodeId2 = new NodeId(nodeRef2);
-
- // Creates support termination list with the above two contents.
- SupportingTerminationPoint point1 =
- new DefaultSupportingTerminationPoint
- .SupportingTerminationPointBuilder()
- .networkRef(nwkRef).nodeRef(nodeId)
- .tpRef(AUG_TP_REF_1).build();
- SupportingTerminationPoint point2 =
- new DefaultSupportingTerminationPoint
- .SupportingTerminationPointBuilder()
- .networkRef(nwkRef2).nodeRef(nodeId2)
- .tpRef("tp-ref-aug-2").build();
-
- List<SupportingTerminationPoint> pointList = new ArrayList<>();
- pointList.add(point1);
- pointList.add(point2);
-
- // Adds the list created to the termination point content1.
- TerminationPoint tPoint1 = new DefaultTerminationPoint
- .TerminationPointBuilder()
- .supportingTerminationPoint(pointList)
- .tpId(AUG_TP_ID_1).build();
-
- // Creates leaf value for network-ref.
- Uri nwkRef3 = new Uri(AUG_NW_REF_B1);
- Uri nwkRef4 = new Uri("network-ref-augb2");
-
- // Creates leaf value for node-ref
- Uri nodeRef3 = new Uri(AUG_NODE_REF_B1);
- NodeId nodeId3 = new NodeId(nodeRef3);
-
- Uri nodeRef4 = new Uri("node-ref-augb2");
- NodeId nodeId4 = new NodeId(nodeRef4);
-
- // Creates support termination list with the above two contents.
- SupportingTerminationPoint point3 =
- new DefaultSupportingTerminationPoint
- .SupportingTerminationPointBuilder()
- .networkRef(nwkRef3).nodeRef(nodeId3)
- .tpRef(AUG_TP_REF_B1).build();
- SupportingTerminationPoint point4 =
- new DefaultSupportingTerminationPoint
- .SupportingTerminationPointBuilder()
- .networkRef(nwkRef4).nodeRef(nodeId4)
- .tpRef("tp-ref-aug-b2").build();
-
- List<SupportingTerminationPoint> pointList2 = new ArrayList<>();
- pointList2.add(point3);
- pointList2.add(point4);
-
- // Adds the list created to the termination point content2.
- TerminationPoint tPoint2 = new DefaultTerminationPoint
- .TerminationPointBuilder()
- .supportingTerminationPoint(pointList2)
- .tpId(AUG_TP_ID_B1).build();
-
- List<TerminationPoint> terminationPointList = new ArrayList<>();
- terminationPointList.add(tPoint1);
- terminationPointList.add(tPoint2);
-
- // Adds all the above contents to the augment.
- AugmentedNdNode augment = new DefaultAugmentedNdNode
- .AugmentedNdNodeBuilder()
- .terminationPoint(terminationPointList)
- .build();
-
- // Creates leaf value for network-ref in augmented node(ietf-network).
- Uri nwRef5 = new Uri(NW_REF);
-
- //Creates leaf value for node-ref in augmented node(ietf-network).
- Uri nodeRef5 = new Uri(NODE_REF);
- NodeId nodeId5 = new NodeId(nodeRef5);
-
- // Creates supporting node list content 1 with above contents.
- SupportingNode supNode1 = new DefaultSupportingNode
- .SupportingNodeBuilder().nodeRef(nodeId5)
- .networkRef(nwRef5).build();
-
- // Creates leaf value for network-ref in augmented node(ietf-network).
- Uri nwRef6 = new Uri(NW_REF_2);
-
- //Creates leaf value for node-ref in augmented node(ietf-network).
- Uri nodeRef6 = new Uri("node-ref2");
- NodeId nodeId6 = new NodeId(nodeRef6);
-
- // Creates supporting node list content 2 with above contents.
- SupportingNode supNode2 = new DefaultSupportingNode
- .SupportingNodeBuilder()
- .nodeRef(nodeId6)
- .networkRef(nwRef6).build();
-
- List<SupportingNode> supNodeList = new ArrayList<>();
- supNodeList.add(supNode1);
- supNodeList.add(supNode2);
-
- // Creates leaf value for node-id in augmented node(ietf-network).
- Uri nodeId1 = new Uri(NODE_REF_3);
- NodeId nodeIdForId = new NodeId(nodeId1);
-
- // Creates node list with content 1 by adding augment also.
- DefaultNode.NodeBuilder nodeBuilder = new DefaultNode.NodeBuilder();
- nodeBuilder.addYangAugmentedInfo(
- augment, AugmentedNdNode.class);
- nodeBuilder.supportingNode(supNodeList);
- nodeBuilder.nodeId(nodeIdForId);
- Node node1 = nodeBuilder.build();
-
- // Creates an augment node without any values set to it.
- AugmentedNdNode augmentedNdNode2 = new DefaultAugmentedNdNode
- .AugmentedNdNodeBuilder().build();
-
- // Creates leaf value for network-ref in augmented node(ietf-network).
- Uri nwRef7 = new Uri(NW_REF_B);
-
- //Creates leaf value for node-ref in augmented node(ietf-network).
- Uri nodeRef7 = new Uri(NODE_REF_B);
- NodeId nodeId7 = new NodeId(nodeRef7);
-
- // Creates supporting node list content 1 with above contents.
- SupportingNode supNode3 = new DefaultSupportingNode
- .SupportingNodeBuilder().nodeRef(nodeId7)
- .networkRef(nwRef7).build();
-
- // Creates leaf value for network-ref in augmented node(ietf-network).
- Uri nwRef8 = new Uri(NW_REF_2B);
-
- //Creates leaf value for node-ref in augmented node(ietf-network).
- Uri nodeRef8 = new Uri(NODE_REF_2B);
- NodeId nodeId8 = new NodeId(nodeRef8);
-
- // Creates supporting node list content 1 with above contents.
- SupportingNode supNode4 = new DefaultSupportingNode
- .SupportingNodeBuilder()
- .nodeRef(nodeId8)
- .networkRef(nwRef8).build();
-
- List<SupportingNode> supNodeList2 = new ArrayList<>();
- supNodeList2.add(supNode3);
- supNodeList2.add(supNode4);
-
- // Creates leaf value for node-id in augmented node(ietf-network).
- Uri nodeIdLeaf = new Uri(NODE_REF_3B);
- NodeId nodeIdForId2 = new NodeId(nodeIdLeaf);
-
- // Creates node list with content 2 by adding empty augment also.
- DefaultNode.NodeBuilder nodeBuilder2 = new DefaultNode.NodeBuilder();
- nodeBuilder2.addYangAugmentedInfo(
- augmentedNdNode2, AugmentedNdNode.class);
- nodeBuilder2.supportingNode(supNodeList2);
- nodeBuilder2.nodeId(nodeIdForId2);
- Node node2 = nodeBuilder2.build();
-
- // Adds both nodes into the list.
- List<Node> nodeList = new LinkedList<>();
- nodeList.add(node1);
- nodeList.add(node2);
-
- // Adds the list into the network list.
- Network nwkList = new DefaultNetwork.NetworkBuilder()
- .node(nodeList).build();
-
- List<Network> networkList = new ArrayList<>();
- networkList.add(nwkList);
-
- // Adds the network list into networks container.
- Networks contNetworks = new DefaultNetworks.NetworksBuilder()
- .network(networkList).build();
-
- // Adds the container into the module.
- YmsIetfNetwork opParam = new YmsIetfNetworkOpParam
- .YmsIetfNetworkBuilder()
- .networks(contNetworks).build();
- return opParam;
- }
-
- /**
- * Processes a simple choice case and builds the YDT.
- */
- @Test
- public void processSimpleChoiceCase() {
-
- schemaProvider.processSchemaRegistry(null);
- DefaultYangSchemaRegistry registry = schemaProvider
- .getDefaultYangSchemaRegistry();
-
- // As an application, creates the object.
-
- // Creates a choice snack with the case late night.
- YtbSnack lateNight = new DefaultYtbLateNight.YtbLateNightBuilder()
- .chocolate(CHOC).build();
-
- // Creates container food with the created case.
- YtbFood food = new DefaultYtbFood.YtbFoodBuilder()
- .ytbSnack(lateNight).build();
-
- // Creates module with the container food.
- YtbSimpleChoiceCase choiceCase = new YtbSimpleChoiceCaseOpParam
- .YtbSimpleChoiceCaseBuilder().ytbFood(food).build();
-
- // As YSB or YAB protocol, sets the value for YTB.
- List<Object> objectList = new ArrayList<>();
- objectList.add(choiceCase);
-
- // Builds YANG tree in YTB.
- DefaultYangTreeBuilder treeBuilder = new DefaultYangTreeBuilder();
- YdtExtendedBuilder ydtBuilder = treeBuilder.getYdtBuilderForYo(
- objectList, ROOT_NAME, ROOT_NAME_SPACE,
- EDIT_CONFIG_REPLY, registry);
-
- // Receives YDT context and check the tree that is built.
- YdtContext rootNode = ydtBuilder.getRootNode();
-
- // Gets the first module from logical root node.
- YdtContext module = rootNode.getFirstChild();
- assertThat(getInCrtName(MODULE, CHOICE_CASE), module.getName(),
- is(CHOICE_CASE));
-
- // Gets the container food from module.
- YdtContext container = module.getFirstChild();
- assertThat(getInCrtName(CONTAINER, FOOD), container.getName(),
- is(FOOD));
-
- // Gets the case-leaf from container
- YdtContext caseNode = container.getFirstChild();
- assertThat(getInCrtName(LEAF, CHOCOLATE), caseNode.getName(),
- is(CHOCOLATE));
- assertThat(getInCrtLeafValue(CHOCOLATE, CHOC), caseNode.getValue(),
- is(CHOC));
- }
-
- /**
- * Processes module with two choices and a choice having node and a
- * leaf-list.
- */
- @Test
- public void processChoiceWithNodeAndLeafList() {
-
- schemaProvider.processSchemaRegistry(null);
- DefaultYangSchemaRegistry registry = schemaProvider
- .getDefaultYangSchemaRegistry();
-
- // As an application, creates the object.
-
- // Creates reproduce container for list predict-1.
- Reproduce reproduce1 = new DefaultReproduce.ReproduceBuilder()
- .yangAutoPrefixCatch((short) 90).build();
-
- // Assigns predict-1 with the container.
- Predict predict1 = new DefaultPredict.PredictBuilder()
- .reproduce(reproduce1).build();
-
- // Creates reproduce container for list predict-2.
- Reproduce reproduce2 = new DefaultReproduce.ReproduceBuilder()
- .yangAutoPrefixCatch((short) 100).build();
-
- // Assigns predict-2 with the container.
- Predict predict2 = new DefaultPredict.PredictBuilder()
- .reproduce(reproduce2).build();
-
- List<Predict> predictList = new ArrayList<>();
- predictList.add(predict1);
- predictList.add(predict2);
-
- // Case container is added to the choice content-test.
- ChoiceContainer containerCase = new org.onosproject.yang.gen.v1.yms
- .test.ytb.choice.with.container.and.leaf.list.rev20160826
- .ytbchoicewithcontainerandleaflist.contenttest.choicecontainer
- .DefaultChoiceContainer.ChoiceContainerBuilder()
- .predict(predictList).build();
-
- // Case container is added to the choice content-test.
- ContentTest contentTest = new DefaultChoiceContainer
- .ChoiceContainerBuilder().choiceContainer(containerCase).build();
-
- // Creates string list for leaf-list final.
- List<String> stringList = new ArrayList<>();
- stringList.add(VAL);
- stringList.add(IND);
-
- // For choice current value, the leaf list gets added as case.
- CurrentValue currentValue = new DefaultYtbAbsent.YtbAbsentBuilder()
- .yangAutoPrefixFinal(stringList).build();
-
- // Adds choice as child to the module.
- YtbChoiceWithContainerAndLeafList choiceWithContainerAndLeafList =
- new YtbChoiceWithContainerAndLeafListOpParam
- .YtbChoiceWithContainerAndLeafListBuilder()
- .contentTest(contentTest).currentValue(currentValue)
- .build();
-
- // As YSB or YAB protocol, sets the value for YTB.
- List<Object> objectList = new ArrayList<>();
- objectList.add(choiceWithContainerAndLeafList);
-
- // Builds YANG tree in YTB.
- DefaultYangTreeBuilder treeBuilder = new DefaultYangTreeBuilder();
- YdtExtendedBuilder ydtBuilder = treeBuilder.getYdtBuilderForYo(
- objectList, CHOICE_ROOT_NAME, CHOICE_ROOT_NAMESPACE,
- QUERY_CONFIG_REPLY, registry);
-
- // Receives YDT context and check the tree that is built.
- YdtContext context = ydtBuilder.getRootNode();
- assertThat(getInCrtName(ROOT, CHOICE_ROOT_NAME), context.getName(),
- is(CHOICE_ROOT_NAME));
- assertThat(getInCrtName(ROOT, CHOICE_ROOT_NAMESPACE), context.getNamespace(),
- is(CHOICE_ROOT_NAMESPACE));
-
- // Gets the first module from logical root node.
- YdtContext module = context.getFirstChild();
- assertThat(getInCrtName(MODULE, CHOICE_CONT), module.getName(),
- is(CHOICE_CONT));
-
- // Gets the first choice content under the module, as container.
- YdtContext choice1 = module.getFirstChild();
- assertThat(getInCrtName(CONTAINER, CONT_CHOICE), choice1.getName(),
- is(CONT_CHOICE));
-
- // Gets the first content in the list predict.
- YdtContext list1 = choice1.getFirstChild();
- assertThat(getInCrtName(LIST, PREDICT), list1.getName(), is(PREDICT));
-
- // Gets the container and its child leaf in the list predict.
- YdtContext container1 = list1.getFirstChild();
- assertThat(getInCrtName(CONTAINER, REPRODUCE), container1.getName(),
- is(REPRODUCE));
- YdtContext leaf1 = container1.getFirstChild();
- assertThat(getInCrtName(LEAF, CATCH), leaf1.getName(), is(CATCH));
- assertThat(getInCrtLeafValue(CATCH, NINETY), leaf1.getValue(),
- is(NINETY));
-
- // Gets the second content in the list predict.
- YdtContext list2 = list1.getNextSibling();
- assertThat(getInCrtName(LIST, PREDICT), list2.getName(), is(PREDICT));
-
- // Gets the container and its child leaf in the list predict.
- YdtContext container2 = list2.getFirstChild();
- assertThat(getInCrtName(CONTAINER, REPRODUCE), container2.getName(),
- is(REPRODUCE));
- YdtContext leaf2 = container2.getFirstChild();
- assertThat(getInCrtName(LEAF, CATCH), leaf2.getName(), is(CATCH));
- assertThat(getInCrtLeafValue(CATCH, HUNDRED), leaf2.getValue(),
- is(HUNDRED));
-
- // Gets the second choice content under the module, as leaf-list.
- YdtContext choice2 = choice1.getNextSibling();
- assertThat(getInCrtName(LEAF_LIST, FINAL), choice2.getName(),
- is(FINAL));
- Set value2 = choice2.getValueSet();
- assertThat(getInCrtLeafListValue(FINAL, VAL), value2.contains(VAL),
- is(true));
- assertThat(getInCrtLeafListValue(FINAL, IND), value2.contains(IND),
- is(true));
- }
-
- /**
- * Processes RPC response of a simple output with only a leaf content
- * inside.
- */
- @Test
- public void processSimpleRpcResponse() {
- schemaProvider.processSchemaRegistry(null);
- DefaultYangSchemaRegistry registry = schemaProvider
- .getDefaultYangSchemaRegistry();
-
- // As an application, creates the object.
- RpcOutput output = new DefaultRpcOutput.RpcOutputBuilder()
- .outputLeaf(500).build();
-
- // Creates request work bench of rpc.
- YangRequestWorkBench workBench = new YangRequestWorkBench(
- RPC_RT_NAME, RPC_RT_NAMESPACE, RPC_REQUEST, registry, true);
- workBench.addChild(RPC_NAME, null, NONE);
- workBench.addChild(RPC, null, NONE);
- workBench.addChild(INPUT, null, NONE);
-
- // Builds YANG tree in YTB.
- DefaultYangTreeBuilder treeBuilder = new DefaultYangTreeBuilder();
- YdtExtendedBuilder ydtBuilder = treeBuilder.getYdtForRpcResponse(
- output, workBench);
-
- // Receives YDT context and check the tree that is built.
- YdtContext context = ydtBuilder.getRootNode();
- assertThat(getInCrtName(ROOT, RPC_RT_NAME), context.getName(),
- is(RPC_RT_NAME));
- assertThat(getInCrtName(ROOT, RPC_RT_NAMESPACE), context.getNamespace(),
- is(RPC_RT_NAMESPACE));
-
- // Gets the first module from logical root node.
- YdtContext module = context.getFirstChild();
- assertThat(getInCrtName(MODULE, RPC_NAME), module.getName(),
- is(RPC_NAME));
-
- // Gets the rpc node from the module.
- YdtContext rpc = module.getFirstChild();
- assertThat(getInCrtName(RPC, RPC), rpc.getName(), is(RPC));
-
- // Gets the output node from the module.
- // TODO: Change assert after YANG utils is merged.
- YdtContext rpcOutput = rpc.getFirstChild();
- //assertThat(rpcOutputNode.getName(), is("output"));
-
- YdtContext outputLeaf = rpcOutput.getFirstChild();
- assertThat(getInCrtName(LEAF, OUTPUT_LEAF), outputLeaf.getName(),
- is(OUTPUT_LEAF));
- assertThat(getInCrtLeafValue(OUTPUT_LEAF, FIVE_HUNDRED),
- outputLeaf.getValue(), is(FIVE_HUNDRED));
- }
-
- /**
- * Processes RPC response of an output defined with list.
- */
- @Test
- public void processRpcResponseForAdvInputOutput() {
- schemaProvider.processSchemaRegistry(null);
- DefaultYangSchemaRegistry registry = schemaProvider
- .getDefaultYangSchemaRegistry();
-
- // As an application, creates the object.
- List<OutputList> list = createApplicationBuiltObjectForRpc();
- ActivateSoftwareImageOutput output =
- new DefaultActivateSoftwareImageOutput
- .ActivateSoftwareImageOutputBuilder()
- .outputList(list).build();
-
- // Creates request work bench of rpc.
- YangRequestWorkBench workBench = buildYangRequestWorkBenchForRpc(
- registry);
-
- // Builds YANG tree in YTB.
- DefaultYangTreeBuilder treeBuilder = new DefaultYangTreeBuilder();
- YdtExtendedBuilder ydtBuilder = treeBuilder.getYdtForRpcResponse(
- output, workBench);
-
- // Receives YDT context and check the tree that is built.
- YdtContext context = ydtBuilder.getRootNode();
- assertThat(getInCrtName(ROOT, RPC_ADV_NAME), context.getName(),
- is(RPC_ADV_NAME));
- assertThat(getInCrtName(ROOT, RPC_ADV_NAMESPACE), context.getNamespace(),
- is(RPC_ADV_NAMESPACE));
-
- // Gets the first module from logical root node.
- YdtContext module = context.getFirstChild();
- assertThat(getInCrtName(MODULE, RPC_ADV_IO), module.getName(),
- is(RPC_ADV_IO));
-
- // Gets the rpc node from module.
- YdtContext rpc = module.getFirstChild();
- assertThat(getInCrtName(RPC, ACT_IMG), rpc.getName(), is(ACT_IMG));
-
- // Gets the output node from the module.
- // TODO: Change assert after YANG utils is merged.
- YdtContext rpcOutput = rpc.getFirstChild();
- //assertThat(rpcOutputNode.getName(), is("output"));
-
- // Gets the list content 1 as the node from output.
- YdtContext outputList1 = rpcOutput.getFirstChild();
- assertThat(getInCrtName(LIST, OUTPUT_LIST), outputList1.getName(),
- is(OUTPUT_LIST));
-
- // Gets the leaf key-list from list content1.
- YdtContext keyList1 = outputList1.getFirstChild();
- assertThat(getInCrtName(LEAF, LIST_KEY), keyList1.getName(),
- is(LIST_KEY));
- assertThat(getInCrtLeafValue(LIST_KEY, BIN_VAL_1), keyList1.getValue(),
- is(BIN_VAL_1));
-
- // Gets the content inside container from list content 1.
- YdtContext cont1 = keyList1.getNextSibling();
- assertThat(getInCrtName(CONTAINER, CONT_INSIDE), cont1.getName(),
- is(CONT_INSIDE));
-
- // Gets the list content 2 as the node from output.
- YdtContext outputList2 = outputList1.getNextSibling();
- assertThat(getInCrtName(LIST, OUTPUT_LIST), outputList2.getName(),
- is(OUTPUT_LIST));
-
- // Gets the leaf-list key-list from list content2.
- YdtContext keyList2 = outputList2.getFirstChild();
- assertThat(getInCrtName(LEAF, LIST_KEY), keyList2.getName(),
- is(LIST_KEY));
- assertThat(getInCrtLeafValue(LIST_KEY, BIN_VAL_2), keyList2.getValue(),
- is(BIN_VAL_2));
-
- // Gets the content inside container from list content 2.
- YdtContext cont2 = keyList2.getNextSibling();
- assertThat(getInCrtName(CONTAINER, CONT_INSIDE), cont2.getName(),
- is(CONT_INSIDE));
-
- // Gets the leaf-list available inside container.
- YdtContext availLeafList = cont2.getFirstChild();
- assertThat(getInCrtName(LEAF_LIST, AVAILABLE), availLeafList.getName(),
- is(AVAILABLE));
- Set value1 = availLeafList.getValueSet();
- assertThat(getInCrtLeafListValue(AVAILABLE, EIGHTY_NINE),
- value1.contains(EIGHTY_NINE), is(true));
- assertThat(getInCrtLeafListValue(AVAILABLE, NINETY_EIGHT),
- value1.contains(NINETY_EIGHT), is(true));
-
- // Gets the list content 3.
- YdtContext outputList3 = outputList2.getNextSibling();
- assertThat(getInCrtName(LIST, OUTPUT_LIST), outputList3.getName(),
- is(OUTPUT_LIST));
-
- // Gets the leaf list-key in content 3 of list.
- YdtContext keyList3 = outputList3.getFirstChild();
- assertThat(getInCrtName(LEAF, LIST_KEY), keyList3.getName(),
- is(LIST_KEY));
- assertThat(getInCrtLeafValue(LIST_KEY, BIN_VAL_3), keyList3.getValue(),
- is(BIN_VAL_3));
- }
-
- /**
- * Processes simple self augment file with leaf and container inside
- * augment.
- */
- @Test
- public void processSimpleAugment() {
- schemaProvider.processSchemaRegistry(null);
- DefaultYangSchemaRegistry registry = schemaProvider
- .getDefaultYangSchemaRegistry();
-
- // As an application, creates the object.
-
- // Creates container cont1s with the leaf.
- org.onosproject.yang.gen.v1.yms.test.ytb.simple.augment.rev20160826
- .ytbsimpleaugment.cont1.cont2.augmentedcont2.cont1s
- .Cont1s cont1s1 = new org.onosproject.yang.gen.v1.yms.test
- .ytb.simple.augment.rev20160826.ytbsimpleaugment.cont1.cont2
- .augmentedcont2.cont1s.DefaultCont1s.Cont1sBuilder().build();
-
- // Appends the created container into another container.
- Cont1s cont1s = new DefaultCont1s.Cont1sBuilder()
- .cont1s(cont1s1).build();
-
- // Creates augment with the container and leaf.
- AugmentedCont2 augment = new DefaultAugmentedCont2
- .AugmentedCont2Builder().cont1s(cont1s).leaf4(500).build();
-
- // Creates for the node which will be getting augmented.
- // Creates cont2 where content will be augmented into.
- DefaultCont2.Cont2Builder augCont2 = new DefaultCont2
- .Cont2Builder();
- augCont2.addYangAugmentedInfo(augment, AugmentedCont2.class);
-
- // Creates cont1 where cont2 is added.
- Cont1 cont1 = new DefaultCont1.Cont1Builder()
- .cont2(augCont2.build()).build();
-
- // Creates module with the nodes inside.
- YtbSimpleAugment simpleAugment = new YtbSimpleAugmentOpParam
- .YtbSimpleAugmentBuilder().cont1(cont1).build();
-
- // As YSB or YAB protocol, sets the value for YTB.
- List<Object> objectList = new ArrayList<>();
- objectList.add(simpleAugment);
-
- // Builds YANG tree in YTB.
- DefaultYangTreeBuilder treeBuilder = new DefaultYangTreeBuilder();
- YdtExtendedBuilder ydtBuilder = treeBuilder.getYdtBuilderForYo(
- objectList, SIM_AUG, SIM_AUG_NAMESPACE,
- EDIT_CONFIG_REQUEST, registry);
-
- // Receives YDT context and check the tree that is built.
- YdtContext context = ydtBuilder.getRootNode();
- assertThat(getInCrtName(ROOT, SIM_AUG), context.getName(), is(SIM_AUG));
- assertThat(getInCrtName(ROOT, SIM_AUG_NAMESPACE),
- context.getNamespace(), is(SIM_AUG_NAMESPACE));
-
- // Gets the first module from logical root node.
- YdtContext module = context.getFirstChild();
- assertThat(getInCrtName(MODULE, SIMPLE_AUG), module.getName(),
- is(SIMPLE_AUG));
-
- // Gets the cont1 under module.
- YdtContext container1 = module.getFirstChild();
- assertThat(getInCrtName(CONTAINER, CONT1), container1.getName(),
- is(CONT1));
-
- // Gets the cont2 under cont1.
- YdtContext container2 = container1.getFirstChild();
- assertThat(getInCrtName(CONTAINER, CONT2), container2.getName(),
- is(CONT2));
-
- // Gets the leaf4 which was augmented under cont2.
- YdtContext leaf4 = container2.getFirstChild();
- assertThat(getInCrtName(LEAF, LEAF4), leaf4.getName(), is(LEAF4));
- assertThat(getInCrtLeafValue(LEAF4, FIVE_HUNDRED), leaf4.getValue(),
- is(FIVE_HUNDRED));
-
- // Gets the cont1s which was augmented under cont2.
- YdtContext container1s = leaf4.getNextSibling();
- assertThat(getInCrtName(CONTAINER, CONT1S), container1s.getName(),
- is(CONT1S));
-
- // Gets the cont2s which was augmented under cont1s.
- YdtContext container2s = container1s.getFirstChild();
- assertThat(getInCrtName(CONTAINER, CONT1S), container2s.getName(),
- is(CONT1S));
- }
-
- /**
- * Processes inter file augment with augmented node as list and the
- * augment having list.
- */
- @Test
- public void processInterFileAugment() {
- schemaProvider.processSchemaRegistry(null);
- DefaultYangSchemaRegistry registry = schemaProvider
- .getDefaultYangSchemaRegistry();
-
- // As an application, creates the object.
- Object opParam = createObjectForInterFileAugment();
-
- // As YSB or YAB protocol, sets the value for YTB.
- List<Object> objectList = new ArrayList<>();
- objectList.add(opParam);
-
- // Builds YANG tree in YTB.
- DefaultYangTreeBuilder treeBuilder = new DefaultYangTreeBuilder();
- YdtExtendedBuilder ydtBuilder = treeBuilder.getYdtBuilderForYo(
- objectList, INTER_AUG, INTER_AUG_NAMESPACE,
- EDIT_CONFIG_REQUEST, registry);
-
- // Receives YDT context and check the tree that is built.
- YdtContext context = ydtBuilder.getRootNode();
- assertThat(getInCrtName(ROOT, INTER_AUG), context.getName(),
- is(INTER_AUG));
- assertThat(getInCrtName(ROOT, INTER_AUG_NAMESPACE), context.getNamespace(),
- is(INTER_AUG_NAMESPACE));
-
- // Checks the first module from logical root node.
- YdtContext module = context.getFirstChild();
- assertThat(getInCrtName(MODULE, IETF_NW), module.getName(),
- is(IETF_NW));
-
- // Checks the container networks from module.
- YdtContext nwksCont = module.getFirstChild();
- assertThat(getInCrtName(CONTAINER, NWS), nwksCont.getName(), is(NWS));
-
- // Checks the list network from container networks.
- YdtContext nwrkList = nwksCont.getFirstChild();
- assertThat(getInCrtName(LIST, NW), nwrkList.getName(), is(NW));
-
- // Checks the node list content 1 under network list.
- YdtContext node1 = nwrkList.getFirstChild();
- assertThat(getInCrtName(LIST, NODE), node1.getName(), is(NODE));
-
- // Checks the node-id leaf for list content 1.
- YdtContext nodeId1 = node1.getFirstChild();
- assertThat(getInCrtName(LEAF, NODE_ID), nodeId1.getName(), is(NODE_ID));
- assertThat(getInCrtLeafValue(NODE_ID, NODE_REF_3), nodeId1.getValue(),
- is(NODE_REF_3));
-
- // Checks termination list 1 under node 1, from augment.
- YdtContext terList1 = nodeId1.getNextSibling();
- assertThat(getInCrtName(LIST, TERM_POINT), terList1.getName(),
- is(TERM_POINT));
-
- // Checks tp-id leaf from termination list content 1.
- YdtContext tpId1 = terList1.getFirstChild();
- assertThat(getInCrtName(LEAF, TP_ID), tpId1.getName(), is(TP_ID));
- assertThat(getInCrtLeafValue(TP_ID, AUG_TP_ID_1), tpId1.getValue(),
- is(AUG_TP_ID_1));
-
- // Checks supporting term point list content1 from term list content 1.
- YdtContext supTerm1 = tpId1.getNextSibling();
- assertThat(getInCrtName(LIST, SUP_TERM_POINT), supTerm1.getName(),
- is(SUP_TERM_POINT));
-
- YdtContext nwkRefSupTerm1 = supTerm1.getFirstChild();
- assertThat(getInCrtName(LEAF, NW_REF), nwkRefSupTerm1.getName(),
- is(NW_REF));
- assertThat(getInCrtLeafValue(NW_REF, AUG_NW_REF_1),
- nwkRefSupTerm1.getValue(), is(AUG_NW_REF_1));
-
- YdtContext nodeRefSupTerm1 = nwkRefSupTerm1.getNextSibling();
- assertThat(getInCrtName(LEAF, NODE_REF), nodeRefSupTerm1.getName(),
- is(NODE_REF));
- assertThat(getInCrtLeafValue(NODE_REF, AUG_NODE_REF_1),
- nodeRefSupTerm1.getValue(), is(AUG_NODE_REF_1));
-
- YdtContext tpRefSupTerm1 = nodeRefSupTerm1.getNextSibling();
- assertThat(getInCrtName(LEAF, TP_REF), tpRefSupTerm1.getName(),
- is(TP_REF));
- assertThat(getInCrtLeafValue(TP_REF, AUG_TP_REF_1),
- tpRefSupTerm1.getValue(), is(AUG_TP_REF_1));
-
- // Checks termination list 2 under node 1, from augment.
- YdtContext terminationList2 = terList1.getNextSibling();
- assertThat(getInCrtName(LIST, TERM_POINT), terminationList2.getName(),
- is(TERM_POINT));
-
- YdtContext terList2 = terminationList2.getFirstChild();
- assertThat(getInCrtName(LEAF, TP_ID), terList2.getName(), is(TP_ID));
- assertThat(getInCrtLeafValue(TP_ID, AUG_TP_ID_B1), terList2.getValue(),
- is(AUG_TP_ID_B1));
-
- // Checks supporting term point list content1 from term list content 2.
- YdtContext supTerm2 = terList2.getNextSibling();
- assertThat(getInCrtName(LIST, SUP_TERM_POINT), supTerm2.getName(),
- is(SUP_TERM_POINT));
-
- YdtContext nwkRefSupTerm2 = supTerm2.getFirstChild();
- assertThat(getInCrtName(LEAF, NW_REF), nwkRefSupTerm2.getName(),
- is(NW_REF));
- assertThat(getInCrtLeafValue(NW_REF, AUG_NW_REF_B1),
- nwkRefSupTerm2.getValue(), is(AUG_NW_REF_B1));
-
- YdtContext nodeRefSupTerm2 = nwkRefSupTerm2.getNextSibling();
- assertThat(getInCrtName(LEAF, NODE_REF), nodeRefSupTerm2.getName(),
- is(NODE_REF));
- assertThat(getInCrtLeafValue(NODE_REF, AUG_NODE_REF_B1),
- nodeRefSupTerm2.getValue(), is(AUG_NODE_REF_B1));
-
- YdtContext tpRefSupTerm2 = nodeRefSupTerm2.getNextSibling();
- assertThat(getInCrtName(LEAF, TP_REF), tpRefSupTerm2.getName(),
- is(TP_REF));
- assertThat(getInCrtLeafValue(TP_REF, AUG_TP_REF_B1),
- tpRefSupTerm2.getValue(), is(AUG_TP_REF_B1));
-
- // Checks the content of the supporting node list content 1 in node 1.
- YdtContext supNode1 = terminationList2.getNextSibling();
- assertThat(getInCrtName(LIST, SUP_NODE), supNode1.getName(),
- is(SUP_NODE));
-
- YdtContext nwkRefSupNode1 = supNode1.getFirstChild();
- assertThat(getInCrtName(LEAF, NW_REF), nwkRefSupNode1.getName(),
- is(NW_REF));
- assertThat(getInCrtLeafValue(NW_REF, NW_REF), nwkRefSupNode1.getValue(),
- is(NW_REF));
-
- YdtContext nodeRefSupNode1 = nwkRefSupNode1.getNextSibling();
- assertThat(getInCrtName(LEAF, NODE_REF), nodeRefSupNode1.getName(),
- is(NODE_REF));
- assertThat(getInCrtLeafValue(NODE_REF, NW_REF),
- nwkRefSupNode1.getValue(), is(NW_REF));
-
- // Checks the content of the supporting node list content 2 in node 1.
- YdtContext supNode2 = supNode1.getNextSibling();
- assertThat(getInCrtName(LIST, SUP_NODE), supNode2.getName(),
- is(SUP_NODE));
-
- YdtContext nwkRefSupNode2 = supNode2.getFirstChild();
- assertThat(getInCrtName(LEAF, NW_REF), nwkRefSupNode2.getName(),
- is(NW_REF));
- assertThat(getInCrtLeafValue(NW_REF, NW_REF_2),
- nwkRefSupNode2.getValue(), is(NW_REF_2));
-
- YdtContext nodeRefSupNode2 = nwkRefSupNode2.getNextSibling();
- assertThat(getInCrtName(LEAF, NODE_REF), nodeRefSupNode2.getName(),
- is(NODE_REF));
- assertThat(getInCrtLeafValue(NODE_REF, NW_REF_2),
- nwkRefSupNode2.getValue(), is(NW_REF_2));
-
- // Checks the node list content 2 under network list.
- YdtContext node2 = node1.getNextSibling();
- assertThat(getInCrtName(LIST, NODE), node2.getName(), is(NODE));
-
- // Checks the node-id leaf for list content 2.
- YdtContext nodeId2 = node2.getFirstChild();
- assertThat(getInCrtName(LEAF, NODE_ID), nodeId2.getName(), is(NODE_ID));
- assertThat(getInCrtLeafValue(NODE_ID, NODE_REF_3B), nodeId2.getValue(),
- is(NODE_REF_3B));
-
- // Checks supporting term point list content1 from term list content 2.
- YdtContext supNode3 = nodeId2.getNextSibling();
- assertThat(getInCrtName(LIST, SUP_NODE), supNode3.getName(),
- is(SUP_NODE));
-
- YdtContext nwkRefSupNode3 = supNode3.getFirstChild();
- assertThat(getInCrtName(LEAF, NW_REF), nwkRefSupNode3.getName(),
- is(NW_REF));
- assertThat(getInCrtLeafValue(NW_REF, NW_REF_B),
- nwkRefSupNode3.getValue(), is(NW_REF_B));
-
- YdtContext nodeRefSupNode3 = nwkRefSupNode3.getNextSibling();
- assertThat(getInCrtName(LEAF, NODE_REF), nodeRefSupNode3.getName(),
- is(NODE_REF));
- assertThat(getInCrtLeafValue(NODE_REF, NODE_REF_B),
- nodeRefSupNode3.getValue(), is(NODE_REF_B));
-
- // Checks supporting term point list content2 from term list content 2.
- YdtContext supNode4 = supNode3.getNextSibling();
- assertThat(getInCrtName(LIST, SUP_NODE), supNode4.getName(),
- is(SUP_NODE));
-
- YdtContext nwkRefSupNode4 = supNode4.getFirstChild();
- assertThat(getInCrtName(LEAF, NW_REF), nwkRefSupNode4.getName(),
- is(NW_REF));
- assertThat(getInCrtLeafValue(NW_REF, NW_REF_2B),
- nwkRefSupNode4.getValue(), is(NW_REF_2B));
-
- YdtContext nodeRefSupNode4 = nwkRefSupNode4.getNextSibling();
- assertThat(getInCrtName(LEAF, NODE_REF), nodeRefSupNode4.getName(),
- is(NODE_REF));
- assertThat(getInCrtLeafValue(NODE_REF, NODE_REF_2B),
- nodeRefSupNode4.getValue(), is(NODE_REF_2B));
- }
-
- /**
- * Processes inter file augment with rpc output as its target node.
- */
- @Test
- public void processInterFileAugmentWithRpcInputAsTarget() {
- schemaProvider.processSchemaRegistry(null);
- DefaultYangSchemaRegistry registry = schemaProvider
- .getDefaultYangSchemaRegistry();
-
- // Builds RPC request tree in YDT.
- YangRequestWorkBench workBench =
- buildYangRequestWorkBenchForRpc(registry);
-
- // Creates augment code object.
-
- // Creates the list of value in, case value in.
- ValueIn valuein1 = new org.onosproject.yang.gen.v1.yms.test.ytb.augment
- .yangautoprefixfor.rpc.input.rev20160826.ytbaugmentforrpcinput
- .activatesoftwareimage.output.augmentedrpcoutput.selection
- .valuein.DefaultValueIn.ValueInBuilder().kinetic(KIN1)
- .build();
- ValueIn valuein2 = new org.onosproject.yang.gen.v1.yms.test.ytb.augment
- .yangautoprefixfor.rpc.input.rev20160826.ytbaugmentforrpcinput
- .activatesoftwareimage.output.augmentedrpcoutput.selection
- .valuein.DefaultValueIn.ValueInBuilder().kinetic(KIN2)
- .build();
-
- List<ValueIn> valueInList = new ArrayList<>();
- valueInList.add(valuein1);
- valueInList.add(valuein2);
-
- // Adds the case value into the choice interface.
- Selection selection = new DefaultValueIn.ValueInBuilder()
- .valueIn(valueInList).build();
-
- // Augment is created for the object.
- AugmentedRpcOutput augmentRpcOutput = new DefaultAugmentedRpcOutput
- .AugmentedRpcOutputBuilder().selection(selection).build();
-
- // Create two list object of friction.
- Friction friction1 = new DefaultFriction.FrictionBuilder()
- .speed(BigInteger.valueOf(500)).build();
- Friction friction2 = new DefaultFriction.FrictionBuilder()
- .speed(BigInteger.valueOf(1000)).build();
-
- List<Friction> fricList = new ArrayList<>();
- fricList.add(friction1);
- fricList.add(friction2);
-
- // Create augment with the friction object created.
- AugmentedInputOutput augmentedIO = new DefaultAugmentedInputOutput
- .AugmentedInputOutputBuilder().friction(fricList).build();
-
- // Creates RPC object.
- List<OutputList> outputLists = createApplicationBuiltObjectForRpc();
-
- // Adds the augment and the rps output values into the output.
- DefaultActivateSoftwareImageOutput
- .ActivateSoftwareImageOutputBuilder output =
- new DefaultActivateSoftwareImageOutput
- .ActivateSoftwareImageOutputBuilder();
- output.addYangAugmentedInfo(augmentRpcOutput, AugmentedRpcOutput.class);
- output.addYangAugmentedInfo(augmentedIO, AugmentedInputOutput.class);
- output.outputList(outputLists);
-
- // Builds YANG tree in YTB.
- DefaultYangTreeBuilder treeBuilder = new DefaultYangTreeBuilder();
- YdtExtendedBuilder ydtBuilder = treeBuilder.getYdtForRpcResponse(
- output, workBench);
-
- // Receives YDT context and check the tree that is built.
- YdtContext context = ydtBuilder.getRootNode();
- assertThat(getInCrtName(ROOT, RPC_ADV_NAME), context.getName(),
- is(RPC_ADV_NAME));
- assertThat(getInCrtName(ROOT, RPC_ADV_NAMESPACE),
- context.getNamespace(), is(RPC_ADV_NAMESPACE));
-
- // Checks the first module from logical root node.
- YdtContext module = context.getFirstChild();
- assertThat(getInCrtName(MODULE, RPC_ADV_IO), module.getName(),
- is(RPC_ADV_IO));
-
- // Gets the rpc under module.
- YdtContext rpc = module.getFirstChild();
- assertThat(getInCrtName(RPC, ACT_IMG), rpc.getName(), is(ACT_IMG));
-
- // Gets the output value under rpc.
- // TODO: Change assert after YANG utils is merged.
- YdtContext rpcOutputNode = rpc.getFirstChild();
- //assertThat(rpcOutputNode.getName(), is("output"));
-
- YdtContext firstNode = rpcOutputNode.getFirstChild();
- assertThat(firstNode, notNullValue());
-
- YdtContext secondNode = firstNode.getNextSibling();
- assertThat(secondNode, notNullValue());
-
- YdtContext thirdNode = secondNode.getNextSibling();
- assertThat(thirdNode, notNullValue());
-
- YdtContext fourthNode = thirdNode.getNextSibling();
- assertThat(fourthNode, notNullValue());
-
- // Gets the list content 1 as the node from output.
- YdtContext outputList1 = fourthNode.getNextSibling();
- assertThat(getInCrtName(LIST, OUTPUT_LIST), outputList1.getName(),
- is(OUTPUT_LIST));
-
- // Gets the leaf key-list from list content1.
- YdtContext keyList1 = outputList1.getFirstChild();
- assertThat(getInCrtName(LEAF, LIST_KEY), keyList1.getName(),
- is(LIST_KEY));
- assertThat(getInCrtLeafValue(LIST_KEY, BIN_VAL_1), keyList1.getValue(),
- is(BIN_VAL_1));
-
- // Gets the content inside container from list content 1.
- YdtContext cont1 = keyList1.getNextSibling();
- assertThat(getInCrtName(CONTAINER, CONT_INSIDE), cont1.getName(),
- is(CONT_INSIDE));
-
- // Gets the list content 2 as the node from output.
- YdtContext outputList2 = outputList1.getNextSibling();
- assertThat(getInCrtName(LIST, OUTPUT_LIST), outputList2.getName(),
- is(OUTPUT_LIST));
-
- // Gets the leaf-list key-list from list content2.
- YdtContext keyList2 = outputList2.getFirstChild();
- assertThat(getInCrtName(LEAF, LIST_KEY), keyList2.getName(),
- is(LIST_KEY));
- assertThat(getInCrtLeafValue(LIST_KEY, BIN_VAL_2), keyList2.getValue(),
- is(BIN_VAL_2));
-
- // Gets the content inside container from list content 2.
- YdtContext cont2 = keyList2.getNextSibling();
- assertThat(getInCrtName(CONTAINER, CONT_INSIDE), cont2.getName(),
- is(CONT_INSIDE));
-
- // Gets the leaf-list available inside container.
- YdtContext availLeafList = cont2.getFirstChild();
- assertThat(getInCrtName(LEAF_LIST, AVAILABLE), availLeafList.getName(),
- is(AVAILABLE));
- Set value1 = availLeafList.getValueSet();
- assertThat(getInCrtLeafListValue(AVAILABLE, EIGHTY_NINE),
- value1.contains(EIGHTY_NINE), is(true));
- assertThat(getInCrtLeafListValue(AVAILABLE, NINETY_EIGHT),
- value1.contains(NINETY_EIGHT), is(true));
-
- // Gets the list content 3.
- YdtContext outputList3 = outputList2.getNextSibling();
- assertThat(getInCrtName(LIST, OUTPUT_LIST), outputList3.getName(),
- is(OUTPUT_LIST));
-
- // Gets the leaf list-key in content 3 of list.
- YdtContext keyList3 = outputList3.getFirstChild();
- assertThat(getInCrtName(LEAF, LIST_KEY), keyList3.getName(),
- is(LIST_KEY));
- assertThat(getInCrtLeafValue(LIST_KEY, BIN_VAL_3), keyList3.getValue(),
- is(BIN_VAL_3));
- }
-}
diff --git a/apps/yms/app/src/test/java/org/onosproject/yms/app/ytb/YtbErrMsgAndConstants.java b/apps/yms/app/src/test/java/org/onosproject/yms/app/ytb/YtbErrMsgAndConstants.java
deleted file mode 100644
index 572a4be..0000000
--- a/apps/yms/app/src/test/java/org/onosproject/yms/app/ytb/YtbErrMsgAndConstants.java
+++ /dev/null
@@ -1,150 +0,0 @@
-/*
- * 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.ytb;
-
-import org.onosproject.yms.app.ysr.TestYangSchemaNodeProvider;
-
-/**
- * Represents the abstract class for ytb test classes having common methods
- * and the constants.
- */
-public abstract class YtbErrMsgAndConstants {
-
- /**
- * Static attribute of root name.
- */
- public static final String ROOT_NAME = "rootName";
-
- /**
- * Static attribute of root name space.
- */
- public static final String ROOT_NAME_SPACE = "rootNameSpace";
-
- /**
- * Static attribute of module which is YANG name.
- */
- public static final String MODULE = "module";
-
- /**
- * Static attribute of list which is YANG name.
- */
- public static final String LIST = "list";
-
- /**
- * Static attribute of leaf which is YANG name.
- */
- public static final String LEAF = "leaf";
-
- /**
- * Static attribute of leaf-list which is YANG name.
- */
- public static final String LEAF_LIST = "leaf-list";
-
- /**
- * Static attribute of container which is YANG name.
- */
- public static final String CONTAINER = "container";
-
- /**
- * Static attribute of name predict.
- */
- public static final String PREDICT = "predict";
-
- /**
- * Static attribute of name catch.
- */
- public static final String CATCH = "catch";
-
- /**
- * Static attribute of YANG file name.
- */
- public static final String RPC_NAME = "YtbSimpleRpcResponse";
-
- /**
- * Static attribute of name rpc.
- */
- public static final String RPC = "rpc";
-
- /**
- * Created a schema node provider, which will register the app.
- */
- public TestYangSchemaNodeProvider schemaProvider =
- new TestYangSchemaNodeProvider();
-
- /**
- * Returns the error message for when leaf value doesn't match with the
- * expected value. It takes name of leaf and expected value as its
- * parameter, to throw the message.
- *
- * @param name leaf name
- * @param value expected value of leaf
- * @return error message of leaf value as incorrect
- */
- public static String getInCrtLeafValue(String name, String value) {
- return "The value of leaf " + name + " is not " + value;
- }
-
- /**
- * Returns the error message, when node name doesn't match with the
- * expected value. It takes YANG name of the node and the node name as
- * parameter, to throw the message.
- *
- * @param node YANG node name
- * @param nodeName node name
- * @return error message as the node name is incorrect
- */
- public static String getInCrtName(String node, String nodeName) {
- return getCapitalCase(node) + "'s name " + nodeName + " is incorrect.";
- }
-
- /**
- * Returns the error message, when operation type doesn't match with the
- * expected value. It takes YANG name of the node and the node name as
- * parameter, to throw the message.
- *
- * @param node YANG node name
- * @param nodeName node name
- * @return error message as the operation type is incorrect
- */
- public static String getInCrtOpType(String node, String nodeName) {
- return "The operation type of " + node + " " + nodeName + " is " +
- "incorrect";
- }
-
- /**
- * Returns the error message for when leaf-list value doesn't match with the
- * expected value. It takes name of leaf-list and expected value as its
- * parameter, to throw the message.
- *
- * @param name leaf-list name
- * @param value value in leaf-list
- * @return error message as the value in the leaf-list is incorrect
- */
- public static String getInCrtLeafListValue(String name, String value) {
- return "The leaf-list " + name + " does not have " + value + " in it.";
- }
-
- /**
- * Returns the capital cased first letter of the given string.
- *
- * @param name string to be capital cased
- * @return capital cased string
- */
- private static String getCapitalCase(String name) {
- return name.substring(0, 1).toUpperCase() + name.substring(1);
- }
-}
diff --git a/apps/yms/app/src/test/java/org/onosproject/yms/app/ytb/YtbInvalidNodeSkipTest.java b/apps/yms/app/src/test/java/org/onosproject/yms/app/ytb/YtbInvalidNodeSkipTest.java
deleted file mode 100644
index 019d958..0000000
--- a/apps/yms/app/src/test/java/org/onosproject/yms/app/ytb/YtbInvalidNodeSkipTest.java
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
- * 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.ytb;
-
-import org.junit.Test;
-import org.onosproject.yang.gen.v1.yms.test.ytb.simple.rpc.response.rev20160826.YtbSimpleRpcResponse;
-import org.onosproject.yang.gen.v1.yms.test.ytb.simple.rpc.response.rev20160826.YtbSimpleRpcResponseOpParam;
-import org.onosproject.yang.gen.v1.yms.test.ytb.simple.rpc.response.rev20160826.ytbsimplerpcresponse.Cumulative;
-import org.onosproject.yang.gen.v1.yms.test.ytb.simple.rpc.response.rev20160826.ytbsimplerpcresponse.DefaultCumulative;
-import org.onosproject.yms.app.ydt.YdtExtendedBuilder;
-import org.onosproject.yms.app.ysr.DefaultYangSchemaRegistry;
-import org.onosproject.yms.ydt.YdtContext;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.core.Is.is;
-import static org.onosproject.yms.ydt.YmsOperationType.EDIT_CONFIG_REQUEST;
-
-/**
- * Unit test cases for invalid node skip in YANG tree builder.
- */
-public class YtbInvalidNodeSkipTest extends YtbErrMsgAndConstants {
-
- private static final String CUMULATIVE = "cumulative";
- private static final String SUM = "sum";
- private static final String FIVE = "5";
- private static final String TEN = "10";
-
- /**
- * Processes RPC node which is the sibling to the empty current node.
- */
- @Test
- public void processRpcSiblingWhenNodeIsEmpty() {
-
- schemaProvider.processSchemaRegistry(null);
- DefaultYangSchemaRegistry registry = schemaProvider
- .getDefaultYangSchemaRegistry();
-
- // As an application, creates the object.
- Cumulative cumulative1 = new DefaultCumulative.CumulativeBuilder()
- .sum((byte) 5).build();
- Cumulative cumulative2 = new DefaultCumulative.CumulativeBuilder()
- .sum((byte) 10).build();
- List<Cumulative> list = new ArrayList<>();
- list.add(cumulative1);
- list.add(cumulative2);
- YtbSimpleRpcResponse rpc = new YtbSimpleRpcResponseOpParam
- .YtbSimpleRpcResponseBuilder().cumulative(list).build();
-
- // As YSB or YAB protocol sets the value for YTB.
- List<Object> objectList = new ArrayList<>();
- objectList.add(rpc);
-
- // Builds YANG tree in YTB.
- DefaultYangTreeBuilder treeBuilder = new DefaultYangTreeBuilder();
- YdtExtendedBuilder ydtBuilder = treeBuilder.getYdtBuilderForYo(
- objectList, ROOT_NAME, ROOT_NAME_SPACE,
- EDIT_CONFIG_REQUEST, registry);
-
- // Receives YDT context and checks the tree that is built.
- YdtContext context = ydtBuilder.getRootNode();
-
- // Gets the first module from logical root node.
- YdtContext module = context.getFirstChild();
- assertThat(getInCrtName(MODULE, RPC_NAME), module.getName(),
- is(RPC_NAME));
-
- // Gets the first list content of cumulative.
- YdtContext list1 = module.getFirstChild();
- assertThat(getInCrtName(LIST, CUMULATIVE), list1.getName(),
- is(CUMULATIVE));
-
- YdtContext sum1 = list1.getFirstChild();
- assertThat(getInCrtName(LEAF, SUM), sum1.getName(), is(SUM));
- assertThat(getInCrtLeafValue(SUM, FIVE), sum1.getValue(), is(FIVE));
-
- // Gets the second list content of cumulative.
- YdtContext list2 = list1.getNextSibling();
- assertThat(getInCrtName(LIST, CUMULATIVE), list2.getName(),
- is(CUMULATIVE));
-
- YdtContext sum2 = list2.getFirstChild();
- assertThat(getInCrtName(LEAF, SUM), sum2.getName(), is(SUM));
- assertThat(getInCrtLeafValue(SUM, TEN), sum2.getValue(), is(TEN));
- }
-
-
-}
diff --git a/apps/yms/app/src/test/resources/YobTestYangFiles/ip-topology.yang b/apps/yms/app/src/test/resources/YobTestYangFiles/ip-topology.yang
deleted file mode 100644
index ca117b7..0000000
--- a/apps/yms/app/src/test/resources/YobTestYangFiles/ip-topology.yang
+++ /dev/null
@@ -1,29 +0,0 @@
-
-module yms-ip-topology {
- yang-version 1;
- namespace urn:ip:topo;
- prefix ip-topo;
- import yms-topology {
- prefix topo;
- revision-date "2014-01-01";
- }
- revision 2014-01-01 {
- description "desc";
- reference "ref";
- }
-
- augment /topo:node{
- leaf router-id {
- type string;
- }
- leaf router-ip {
- type string;
- }
- }
-
- augment /topo:node/topo:termination-points/topo:termination-point {
- leaf ip-address {
- type string;
- }
- }
-}
diff --git a/apps/yms/app/src/test/resources/YobTestYangFiles/topology.yang b/apps/yms/app/src/test/resources/YobTestYangFiles/topology.yang
deleted file mode 100644
index 62c0279..0000000
--- a/apps/yms/app/src/test/resources/YobTestYangFiles/topology.yang
+++ /dev/null
@@ -1,74 +0,0 @@
-
-module yms-topology {
- yang-version 1;
- namespace urn:topo;
- prefix topo;
- revision 2014-01-01 {
- description "desc";
- reference "ref";
- }
- list node {
- key "node-id";
- leaf node-id{
- type string;
- }
- leaf-list node-prop{
- type string;
- }
- container termination-points{
- leaf number-of-tp {
- type int16;
- }
- list termination-point {
- key "tp-id";
- leaf tp-id {
- type string;
- }
- }
- }
- choice choice1{
- case case1a{
- leaf leaf1a1{
- type string;
- }
- leaf leaf1a2{
- type string;
- }
- }
- case case1b{
- choice choice1b{
- case case1bi{
- leaf leaf1bia{
- type string;
- }
- leaf leaf1bib{
- type string;
- }
- }
- case case1bii{
- leaf leaf1biia{
- type string;
- }
- leaf leaf1biib{
- type string;
- }
- }
- }
- }
- }
- }
-
- rpc set-node-limit {
- input {
- leaf node-limit {
- type int16;
- }
- }
- }
-
- notification node-limit-reached {
- leaf node-limit {
- type int16;
- }
- }
-}
diff --git a/apps/yms/app/src/test/resources/yabTestYangFiles/test.yang b/apps/yms/app/src/test/resources/yabTestYangFiles/test.yang
deleted file mode 100644
index e37bed6..0000000
--- a/apps/yms/app/src/test/resources/yabTestYangFiles/test.yang
+++ /dev/null
@@ -1,111 +0,0 @@
-module test {
-
- yang-version 1;
- namespace "ydt.test";
- prefix "t6";
- organization "ON-LAB";
-
- revision "2016-05-24" {
- description "Initial revision.";
- }
-
- container cont1 {
- container cont2 {
- container cont3 {
- leaf leaf1 {
- type string;
- }
- }
- }
- list list1 {
- key leaf2;
- leaf leaf2 {
- type string;
- }
- leaf leaf3 {
- type string;
- }
- }
- leaf leaf4 {
- type string;
- }
- }
- list list2 {
- key "leaf5 leaf6";
- leaf leaf5 {
- type string;
- }
- leaf leaf6 {
- type string;
- }
- leaf leaf7 {
- type string;
- }
- leaf-list leaflist8 {
- type string;
- }
- container cont7 {
- leaf leaf12 {
- type string;
- }
- }
- }
- container cont4 {
- container cont5 {
- leaf leaf9 {
- type string;
- }
- }
- }
- leaf leaf10 {
- type string;
- }
-
- rpc rock-the-house {
- input {
- leaf zip-code {
- type string;
- }
- }
- output {
- leaf hello {
- type string;
- }
- }
- }
-
- rpc rock-the-house1 {
- input {
- leaf leaf13 {
- type string;
- }
- }
- }
-
- rpc rock-the-house2 {
- output {
- leaf leaf14 {
- type string;
- }
- }
- }
-
- rpc rock-the-house3 {
- }
-
- augment "/cont4" {
- container cont6 {
- leaf leaf11 {
- type string;
- }
- }
- }
-
- augment "/cont4/cont6" {
- container cont7 {
- leaf leaf12 {
- type string;
- }
- }
- }
-}
diff --git a/apps/yms/app/src/test/resources/ychTestResourceFiles/Combined.yang b/apps/yms/app/src/test/resources/ychTestResourceFiles/Combined.yang
deleted file mode 100644
index a9c2f48..0000000
--- a/apps/yms/app/src/test/resources/ychTestResourceFiles/Combined.yang
+++ /dev/null
@@ -1,114 +0,0 @@
-module Combined {
-
- yang-version 1;
- namespace "ych:combined";
- prefix "combined";
-
- organization "Huawei India Pvt. Ltd.";
-
- description "This module defines for purchasing-supervisor.";
-
- revision "2016-05-24" {
- description "Initial revision.";
- }
-
- typedef protocol-version {
- type uint8 {
- range 1..7;
- }
- }
-
- typedef path-id {
- type uint32;
- default 0;
- description
- "Identifier of a single path. The identifier does not
- carry any semantic meaning beyond uniquely identifying
- a path.";
- }
-
- typedef as-num {
- type uint32;
- default 0;
- description
- "Identifier of a single path. The identifier does not
- carry any semantic meaning beyond uniquely identifying
- a path.";
- }
-
- typedef metric {
- type uint32;
- default 0;
- description
- "Identifier of a single path. The identifier does not
- carry any semantic meaning beyond uniquely identifying
- a path.";
- }
-
- container attributes {
- container origin {
- reference "http://tools.ietf.org/html/rfc4271#section-5.1.1";
- leaf value {
- type path-id;
- mandatory true;
- }
- }
- container multi-exit-disc {
- reference "http://tools.ietf.org/html/rfc4271#section-5.1.4";
- leaf med {
- type uint32;
- }
- }
- container local-pref {
- reference "http://tools.ietf.org/html/rfc4271#section-5.1.5";
- leaf pref {
- type uint32;
- }
- }
- container aigp {
- container aigp-tlv {
- leaf metric {
- type metric;
- }
- }
- }
-
- list unrecognized-attributes {
- key type;
- leaf partial {
- type boolean;
- mandatory true;
- }
- leaf transitive {
- type boolean;
- mandatory true;
- }
- leaf type {
- type uint8;
- mandatory true;
- }
- leaf value {
- type binary {
- length 0..65535;
- }
- mandatory true;
- }
- }
-
- list bgp-parameters {
- config false;
- list optional-capabilities {
- config false;
- reference "http://tools.ietf.org/html/rfc5492#section-4";
- container c-parameters {
- container as4-bytes-capability {
- reference "http://tools.ietf.org/html/rfc6793";
- leaf as-number {
- type as-num;
- }
- }
- }
- }
- }
- }
-}
diff --git a/apps/yms/app/src/test/resources/ychTestResourceFiles/EmptyContainer.yang b/apps/yms/app/src/test/resources/ychTestResourceFiles/EmptyContainer.yang
deleted file mode 100644
index 92106e9..0000000
--- a/apps/yms/app/src/test/resources/ychTestResourceFiles/EmptyContainer.yang
+++ /dev/null
@@ -1,19 +0,0 @@
-module EmptyContainer {
-
- yang-version 1;
-
- namespace "ych.Empty.Container";
-
- prefix "purchasing";
-
- organization "ON-LAB";
-
- description "This module defines for purchasing-supervisor.";
-
- revision "2016-05-24" {
- description "Initial revision.";
- }
-
- container EmptyContainer {
- }
-}
\ No newline at end of file
diff --git a/apps/yms/app/src/test/resources/ychTestResourceFiles/combinedrootname.xml b/apps/yms/app/src/test/resources/ychTestResourceFiles/combinedrootname.xml
deleted file mode 100644
index 1997f3d..0000000
--- a/apps/yms/app/src/test/resources/ychTestResourceFiles/combinedrootname.xml
+++ /dev/null
@@ -1,98 +0,0 @@
-<rpc message-id="101"
- xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
- <edit-config>
- <target>
- <running/>
- </target>
- <filter xmlns="ydt.filter-type" type="subtree">
- <Combined xmlns="ych:combined">
- <attributes>
- <origin>
- <value>123</value>
- </origin>
- <multi-exit-disc>
- <med>456</med>
- </multi-exit-disc>
- <local-pref>
- <pref>23</pref>
- </local-pref>
- <aigp>
- <aigp-tlv>
- <metric>456</metric>
- </aigp-tlv>
- </aigp>
- <unrecognized-attributes>
- <partial>false</partial>
- <transitive>false</transitive>
- <type>1</type>
- <value>QUJD</value>
- </unrecognized-attributes>
- <unrecognized-attributes>
- <partial>true</partial>
- <transitive>true</transitive>
- <type>2</type>
- <value>QUJD</value>
- </unrecognized-attributes>
- <unrecognized-attributes>
- <partial>true</partial>
- <transitive>false</transitive>
- <type>3</type>
- <value>QUJD</value>
- </unrecognized-attributes>
- <unrecognized-attributes>
- <partial>false</partial>
- <transitive>true</transitive>
- <type>4</type>
- <value>QUJD</value>
- </unrecognized-attributes>
- <bgp-parameters>
- <optional-capabilities>
- <c-parameters>
- <as4-bytes-capability>
- <as-number>11</as-number>
- </as4-bytes-capability>
- </c-parameters>
- </optional-capabilities>
- <optional-capabilities>
- <c-parameters>
- <as4-bytes-capability>
- <as-number>22</as-number>
- </as4-bytes-capability>
- </c-parameters>
- </optional-capabilities>
- <optional-capabilities>
- <c-parameters>
- <as4-bytes-capability>
- <as-number>33</as-number>
- </as4-bytes-capability>
- </c-parameters>
- </optional-capabilities>
- </bgp-parameters>
- <bgp-parameters>
- <optional-capabilities>
- <c-parameters>
- <as4-bytes-capability>
- <as-number>33</as-number>
- </as4-bytes-capability>
- </c-parameters>
- </optional-capabilities>
- <optional-capabilities>
- <c-parameters>
- <as4-bytes-capability>
- <as-number>33</as-number>
- </as4-bytes-capability>
- </c-parameters>
- </optional-capabilities>
- <optional-capabilities>
- <c-parameters>
- <as4-bytes-capability>
- <as-number>33</as-number>
- </as4-bytes-capability>
- </c-parameters>
- </optional-capabilities>
- </bgp-parameters>
- </attributes>
- </Combined>
- </filter>
- </edit-config>
-</rpc>
\ No newline at end of file
diff --git a/apps/yms/app/src/test/resources/ychTestResourceFiles/configrootname.xml b/apps/yms/app/src/test/resources/ychTestResourceFiles/configrootname.xml
deleted file mode 100644
index c8509f1..0000000
--- a/apps/yms/app/src/test/resources/ychTestResourceFiles/configrootname.xml
+++ /dev/null
@@ -1,20 +0,0 @@
-<rpc message-id="101"
- xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
- <edit-config>
- <target>
- <running/>
- </target>
- <config xmlns:xc="urn:ietf:params:xml:ns:netconf:base:1.0">
- <Logistics-manager xmlns="ydt.root">
- <Customs-supervisor>abc</Customs-supervisor>
- <Purchasing-supervisor xmlns="ydt.root">
- <purchasing-specialist>bcd</purchasing-specialist>
- <support>cde</support>
- </Purchasing-supervisor>
- </Logistics-manager>
- <merchandisersupervisor xmlns="ydt.Merchandiser-supervisor">
- <supervisor>abc</supervisor>
- </merchandisersupervisor>
- </config>
- </edit-config>
-</rpc>
\ No newline at end of file
diff --git a/apps/yms/app/src/test/resources/ychTestResourceFiles/configrootnameOperationType.xml b/apps/yms/app/src/test/resources/ychTestResourceFiles/configrootnameOperationType.xml
deleted file mode 100644
index 6cecea49..0000000
--- a/apps/yms/app/src/test/resources/ychTestResourceFiles/configrootnameOperationType.xml
+++ /dev/null
@@ -1,20 +0,0 @@
-<rpc message-id="101"
- xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
- <edit-config>
- <target>
- <running/>
- </target>
- <config xmlns:xc="urn:ietf:params:xml:ns:netconf:base:1.0">
- <Logistics-manager xmlns="ydt.root">
- <Customs-supervisor>abc</Customs-supervisor>
- <Purchasing-supervisor xmlns="ydt.root" operation="delete">
- <purchasing-specialist>bcd</purchasing-specialist>
- <support>cde</support>
- </Purchasing-supervisor>
- </Logistics-manager>
- <merchandisersupervisor xmlns="ydt.Merchandiser-supervisor">
- <supervisor>abc</supervisor>
- </merchandisersupervisor>
- </config>
- </edit-config>
-</rpc>
\ No newline at end of file
diff --git a/apps/yms/app/src/test/resources/ychTestResourceFiles/getReply.xml b/apps/yms/app/src/test/resources/ychTestResourceFiles/getReply.xml
deleted file mode 100644
index b6d11fe..0000000
--- a/apps/yms/app/src/test/resources/ychTestResourceFiles/getReply.xml
+++ /dev/null
@@ -1,11 +0,0 @@
-<rpc-reply message-id="101"
- xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"
- xmlns:ex="http://example.net/content/1.0">
- <data>
- <Logistics-manager xmlns="ydt.root">
- <Purchasing-supervisor xmlns="ydt.root">
- <purchasing-specialist>bcd</purchasing-specialist>
- </Purchasing-supervisor>
- </Logistics-manager>
- </data>
-</rpc-reply>
\ No newline at end of file
diff --git a/apps/yms/app/src/test/resources/ychTestResourceFiles/getconfigReply.xml b/apps/yms/app/src/test/resources/ychTestResourceFiles/getconfigReply.xml
deleted file mode 100644
index e27beab..0000000
--- a/apps/yms/app/src/test/resources/ychTestResourceFiles/getconfigReply.xml
+++ /dev/null
@@ -1,8 +0,0 @@
-<rpc message-id="101"
- xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
- <data>
- <merchandisersupervisor xmlns="ydt.Merchandiser-supervisor">
- <supervisor>abc</supervisor>
- </merchandisersupervisor>
- </data>
-</rpc>
\ No newline at end of file
diff --git a/apps/yms/app/src/test/resources/ychTestResourceFiles/getconfigemptycontainer.xml b/apps/yms/app/src/test/resources/ychTestResourceFiles/getconfigemptycontainer.xml
deleted file mode 100644
index adc7902..0000000
--- a/apps/yms/app/src/test/resources/ychTestResourceFiles/getconfigemptycontainer.xml
+++ /dev/null
@@ -1,11 +0,0 @@
-<rpc message-id="101"
- xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
- <get-config>
- <source>
- <running/>
- </source>
- <filter xmlns="ydt.filter-type" type="subtree">
- <EmptyContainer xmlns="ych.Empty.Container"/>
- </filter>
- </get-config>
-</rpc>
\ No newline at end of file
diff --git a/apps/yms/app/src/test/resources/ychTestResourceFiles/getconfigrootname.xml b/apps/yms/app/src/test/resources/ychTestResourceFiles/getconfigrootname.xml
deleted file mode 100644
index df69691..0000000
--- a/apps/yms/app/src/test/resources/ychTestResourceFiles/getconfigrootname.xml
+++ /dev/null
@@ -1,13 +0,0 @@
-<rpc message-id="101"
- xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
- <get-config>
- <source>
- <running/>
- </source>
- <filter type="subtree">
- <merchandisersupervisor xmlns="ydt.Merchandiser-supervisor">
- <supervisor>abc</supervisor>
- </merchandisersupervisor>
- </filter>
- </get-config>
-</rpc>
\ No newline at end of file
diff --git a/apps/yms/app/src/test/resources/ychTestResourceFiles/getrootname.xml b/apps/yms/app/src/test/resources/ychTestResourceFiles/getrootname.xml
deleted file mode 100644
index 9773893..0000000
--- a/apps/yms/app/src/test/resources/ychTestResourceFiles/getrootname.xml
+++ /dev/null
@@ -1,12 +0,0 @@
-<rpc message-id="101"
- xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
- <get>
- <filter type="subtree">
- <Logistics-manager xmlns="ydt.root">
- <Purchasing-supervisor xmlns="ydt.root">
- <purchasing-specialist>bcd</purchasing-specialist>
- </Purchasing-supervisor>
- </Logistics-manager>
- </filter>
- </get>
-</rpc>
\ No newline at end of file
diff --git a/apps/yms/app/src/test/resources/ychTestResourceFiles/purchasingsupervisor.yang b/apps/yms/app/src/test/resources/ychTestResourceFiles/purchasingsupervisor.yang
deleted file mode 100644
index 507c64e..0000000
--- a/apps/yms/app/src/test/resources/ychTestResourceFiles/purchasingsupervisor.yang
+++ /dev/null
@@ -1,28 +0,0 @@
-module ych-purchasingsupervisor {
-
- yang-version 1;
-
- namespace "ych.purchasing-supervisor";
-
- prefix "purchasing";
-
- organization "ON-LAB";
-
- description "This module defines for purchasing-supervisor.";
-
- revision "2016-05-24" {
- description "Initial revision.";
- }
-
- container ych-purchasing-supervisor {
- leaf ych-purchasing-specialist {
- type string;
- description "name of the purchasing-specialist person";
- }
-
- leaf ych-purchasing-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/Hello_ONOS.yang b/apps/yms/app/src/test/resources/ydtTestYangFiles/Hello_ONOS.yang
deleted file mode 100644
index d5eafbe..0000000
--- a/apps/yms/app/src/test/resources/ydtTestYangFiles/Hello_ONOS.yang
+++ /dev/null
@@ -1,57 +0,0 @@
-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
deleted file mode 100644
index 3cd4321..0000000
--- a/apps/yms/app/src/test/resources/ydtTestYangFiles/Logistics-manager.yang
+++ /dev/null
@@ -1,66 +0,0 @@
-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
deleted file mode 100644
index 6736063..0000000
--- a/apps/yms/app/src/test/resources/ydtTestYangFiles/augment-topology1.yang
+++ /dev/null
@@ -1,51 +0,0 @@
-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
deleted file mode 100644
index 82a19d7..0000000
--- a/apps/yms/app/src/test/resources/ydtTestYangFiles/augment-topology2.yang
+++ /dev/null
@@ -1,63 +0,0 @@
-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
deleted file mode 100644
index d2c58ce..0000000
--- a/apps/yms/app/src/test/resources/ydtTestYangFiles/augment-topology3.yang
+++ /dev/null
@@ -1,59 +0,0 @@
-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
deleted file mode 100644
index b8cea93..0000000
--- a/apps/yms/app/src/test/resources/ydtTestYangFiles/augment-topology4.yang
+++ /dev/null
@@ -1,58 +0,0 @@
-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
deleted file mode 100644
index a13a688..0000000
--- a/apps/yms/app/src/test/resources/ydtTestYangFiles/augment-topology5.yang
+++ /dev/null
@@ -1,66 +0,0 @@
-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
deleted file mode 100644
index 15bd3d5..0000000
--- a/apps/yms/app/src/test/resources/ydtTestYangFiles/augment-topology6.yang
+++ /dev/null
@@ -1,73 +0,0 @@
-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
deleted file mode 100644
index 315bc44..0000000
--- a/apps/yms/app/src/test/resources/ydtTestYangFiles/augmentNetwork.yang
+++ /dev/null
@@ -1,33 +0,0 @@
-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
deleted file mode 100644
index f6db459d..0000000
--- a/apps/yms/app/src/test/resources/ydtTestYangFiles/binarytest.yang
+++ /dev/null
@@ -1,74 +0,0 @@
-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";
- }
- }
- }
-
- typedef percent {
- type binary;
- }
-
- leaf name {
- type percent;
- }
-
- grouping greeting {
- leaf surname {
- type binary;
- }
- }
-
- container cont1 {
- uses greeting;
- }
-
- augment "/cont1" {
- leaf lastname {
- type binary;
- }
- }
-
- container food {
- choice snack {
- case sportsarena {
- leaf pretzel {
- type binary;
- }
- }
- }
- }
-
- leaf middlename {
- type union {
- type int8;
- type binary;
- }
- }
-}
\ 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
deleted file mode 100644
index 6d97ccc..0000000
--- a/apps/yms/app/src/test/resources/ydtTestYangFiles/bit.yang
+++ /dev/null
@@ -1,51 +0,0 @@
-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
deleted file mode 100644
index 1bb6181..0000000
--- a/apps/yms/app/src/test/resources/ydtTestYangFiles/bool.yang
+++ /dev/null
@@ -1,23 +0,0 @@
-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
deleted file mode 100644
index 73aa806..0000000
--- a/apps/yms/app/src/test/resources/ydtTestYangFiles/customssupervisor.yang
+++ /dev/null
@@ -1,21 +0,0 @@
-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
deleted file mode 100644
index 6470e8a..0000000
--- a/apps/yms/app/src/test/resources/ydtTestYangFiles/decimal64.yang
+++ /dev/null
@@ -1,90 +0,0 @@
-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
deleted file mode 100644
index be27c70..0000000
--- a/apps/yms/app/src/test/resources/ydtTestYangFiles/employeeid.yang
+++ /dev/null
@@ -1,21 +0,0 @@
-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
deleted file mode 100644
index 33f58b3..0000000
--- a/apps/yms/app/src/test/resources/ydtTestYangFiles/emptydata.yang
+++ /dev/null
@@ -1,23 +0,0 @@
-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
deleted file mode 100644
index a9255c5..0000000
--- a/apps/yms/app/src/test/resources/ydtTestYangFiles/enumtest.yang
+++ /dev/null
@@ -1,27 +0,0 @@
-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
deleted file mode 100644
index 202d11f..0000000
--- a/apps/yms/app/src/test/resources/ydtTestYangFiles/food.yang
+++ /dev/null
@@ -1,39 +0,0 @@
-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
deleted file mode 100644
index 6b994bb..0000000
--- a/apps/yms/app/src/test/resources/ydtTestYangFiles/ietf-inet-types.yang
+++ /dev/null
@@ -1,454 +0,0 @@
- 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
deleted file mode 100644
index b56f6cf..0000000
--- a/apps/yms/app/src/test/resources/ydtTestYangFiles/ietf-network.yang
+++ /dev/null
@@ -1,216 +0,0 @@
- 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
deleted file mode 100644
index 8db77be..0000000
--- a/apps/yms/app/src/test/resources/ydtTestYangFiles/integer16.yang
+++ /dev/null
@@ -1,98 +0,0 @@
-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
deleted file mode 100644
index fb596cf..0000000
--- a/apps/yms/app/src/test/resources/ydtTestYangFiles/integer32.yang
+++ /dev/null
@@ -1,98 +0,0 @@
-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
deleted file mode 100644
index 39479c6..0000000
--- a/apps/yms/app/src/test/resources/ydtTestYangFiles/integer64.yang
+++ /dev/null
@@ -1,98 +0,0 @@
-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
deleted file mode 100644
index e05c235..0000000
--- a/apps/yms/app/src/test/resources/ydtTestYangFiles/integer8.yang
+++ /dev/null
@@ -1,99 +0,0 @@
-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
deleted file mode 100644
index 7198611..0000000
--- a/apps/yms/app/src/test/resources/ydtTestYangFiles/logisticsmanager.yang
+++ /dev/null
@@ -1,16 +0,0 @@
-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
deleted file mode 100644
index 6ab16ea..0000000
--- a/apps/yms/app/src/test/resources/ydtTestYangFiles/materialsupervisor.yang
+++ /dev/null
@@ -1,29 +0,0 @@
-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
deleted file mode 100644
index db40c7e..0000000
--- a/apps/yms/app/src/test/resources/ydtTestYangFiles/merchandisersupervisor.yang
+++ /dev/null
@@ -1,21 +0,0 @@
-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
deleted file mode 100644
index a52b4c5..0000000
--- a/apps/yms/app/src/test/resources/ydtTestYangFiles/purchasingsupervisor.yang
+++ /dev/null
@@ -1,27 +0,0 @@
-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
deleted file mode 100644
index ef5a0a0..0000000
--- a/apps/yms/app/src/test/resources/ydtTestYangFiles/rootlist.yang
+++ /dev/null
@@ -1,111 +0,0 @@
-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
deleted file mode 100644
index a6c8681..0000000
--- a/apps/yms/app/src/test/resources/ydtTestYangFiles/tradingsupervisor.yang
+++ /dev/null
@@ -1,21 +0,0 @@
-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
deleted file mode 100644
index 5145824..0000000
--- a/apps/yms/app/src/test/resources/ydtTestYangFiles/warehousesupervisor.yang
+++ /dev/null
@@ -1,21 +0,0 @@
-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
deleted file mode 100644
index 6b9452c..0000000
--- a/apps/yms/app/src/test/resources/ydtTestYangFiles/yms-network-topology.yang
+++ /dev/null
@@ -1,304 +0,0 @@
- 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";
- }
- }
- }
- }
- }
diff --git a/apps/yms/app/src/test/resources/ysrTestYangFiles/multiRevisions/norev.yang b/apps/yms/app/src/test/resources/ysrTestYangFiles/multiRevisions/norev.yang
deleted file mode 100644
index 23eaaba..0000000
--- a/apps/yms/app/src/test/resources/ysrTestYangFiles/multiRevisions/norev.yang
+++ /dev/null
@@ -1,85 +0,0 @@
- module ietf-network4 {
- yang-version 1;
- namespace "urn:ietf:params:xml:ns:yang:ietf-network4";
- 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 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).";
-
- notification network-up {
- container networks {
- leaf id {
- type int32;
- }
- container network {
- leaf ip-address {
- type int32;
- }
- }
- }
- }
- notification network-down {
- container networks {
- leaf id {
- type int32;
- }
- container network {
- leaf ip-address {
- type int32;
- }
- }
- }
- }
-
-}
diff --git a/apps/yms/app/src/test/resources/ysrTestYangFiles/multiRevisions/withrev.yang b/apps/yms/app/src/test/resources/ysrTestYangFiles/multiRevisions/withrev.yang
deleted file mode 100644
index ab0cffa..0000000
--- a/apps/yms/app/src/test/resources/ysrTestYangFiles/multiRevisions/withrev.yang
+++ /dev/null
@@ -1,95 +0,0 @@
- module ietf-network4 {
- yang-version 1;
- namespace "urn:ietf:params:xml:ns:yang:ietf-network4";
- 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 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";
- }
-
- notification network-up {
- container networks {
- leaf id {
- type int32;
- }
- container network {
- leaf ip-address {
- type int32;
- }
- }
- }
- }
- notification network-down {
- container networks {
- leaf id {
- type int32;
- }
- container network {
- leaf ip-address {
- type int32;
- }
- }
- }
- }
-
-}
diff --git a/apps/yms/app/src/test/resources/ysrTestYangFiles/multiRevisions/withrev2.yang b/apps/yms/app/src/test/resources/ysrTestYangFiles/multiRevisions/withrev2.yang
deleted file mode 100644
index f7c9a16..0000000
--- a/apps/yms/app/src/test/resources/ysrTestYangFiles/multiRevisions/withrev2.yang
+++ /dev/null
@@ -1,95 +0,0 @@
- module ietf-network4 {
- yang-version 1;
- namespace "urn:ietf:params:xml:ns:yang:ietf-network4";
- 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 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 2016-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";
- }
-
- notification network-up {
- container networks {
- leaf id {
- type int32;
- }
- container network {
- leaf ip-address {
- type int32;
- }
- }
- }
- }
- notification network-down {
- container networks {
- leaf id {
- type int32;
- }
- container network {
- leaf ip-address {
- type int32;
- }
- }
- }
- }
-
-}
diff --git a/apps/yms/app/src/test/resources/ysrTestYangFiles/multiRevisions/withrev3.yang b/apps/yms/app/src/test/resources/ysrTestYangFiles/multiRevisions/withrev3.yang
deleted file mode 100644
index f4abc06..0000000
--- a/apps/yms/app/src/test/resources/ysrTestYangFiles/multiRevisions/withrev3.yang
+++ /dev/null
@@ -1,95 +0,0 @@
- module ietf-network4 {
- yang-version 1;
- namespace "urn:ietf:params:xml:ns:yang:ietf-network4";
- 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 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 2014-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";
- }
-
- notification network-up {
- container networks {
- leaf id {
- type int32;
- }
- container network {
- leaf ip-address {
- type int32;
- }
- }
- }
- }
- notification network-down {
- container networks {
- leaf id {
- type int32;
- }
- container network {
- leaf ip-address {
- type int32;
- }
- }
- }
- }
-
-}
diff --git a/apps/yms/app/src/test/resources/ysrTestYangFiles/multiRevisions/withrev4.yang b/apps/yms/app/src/test/resources/ysrTestYangFiles/multiRevisions/withrev4.yang
deleted file mode 100644
index 9352fb4..0000000
--- a/apps/yms/app/src/test/resources/ysrTestYangFiles/multiRevisions/withrev4.yang
+++ /dev/null
@@ -1,76 +0,0 @@
- module ietf-network4 {
- yang-version 1;
- namespace "urn:ietf:params:xml:ns:yang:ietf-network4";
- 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 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 2017-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";
- }
-
- container network {
- leaf ip {
- type int32;
- }
- }
-
-}
diff --git a/apps/yms/app/src/test/resources/ysrTestYangFiles/withNotification/ysr1.yang b/apps/yms/app/src/test/resources/ysrTestYangFiles/withNotification/ysr1.yang
deleted file mode 100644
index a58e99d..0000000
--- a/apps/yms/app/src/test/resources/ysrTestYangFiles/withNotification/ysr1.yang
+++ /dev/null
@@ -1,95 +0,0 @@
- module ietf-network1 {
- yang-version 1;
- namespace "urn:ietf:params:xml:ns:yang:ietf-network1";
- 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 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";
- }
-
- notification network-up {
- container networks {
- leaf id {
- type int32;
- }
- container network {
- leaf ip-address {
- type int32;
- }
- }
- }
- }
- notification network-down {
- container networks {
- leaf id {
- type int32;
- }
- container network {
- leaf ip-address {
- type int32;
- }
- }
- }
- }
-
-}
diff --git a/apps/yms/app/src/test/resources/ysrTestYangFiles/withNotification/ysr2.yang b/apps/yms/app/src/test/resources/ysrTestYangFiles/withNotification/ysr2.yang
deleted file mode 100644
index c241068..0000000
--- a/apps/yms/app/src/test/resources/ysrTestYangFiles/withNotification/ysr2.yang
+++ /dev/null
@@ -1,95 +0,0 @@
- module ietf-network2 {
- yang-version 1;
- namespace "urn:ietf:params:xml:ns:yang:ietf-network2";
- 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 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";
- }
-
- notification network-up {
- container networks {
- leaf id {
- type int32;
- }
- container network {
- leaf ip-address {
- type int32;
- }
- }
- }
- }
- notification network-down {
- container networks {
- leaf id {
- type int32;
- }
- container network {
- leaf ip-address {
- type int32;
- }
- }
- }
- }
-
-}
diff --git a/apps/yms/app/src/test/resources/ysrTestYangFiles/withoutNotification/ysr3.yang b/apps/yms/app/src/test/resources/ysrTestYangFiles/withoutNotification/ysr3.yang
deleted file mode 100644
index 0e86062..0000000
--- a/apps/yms/app/src/test/resources/ysrTestYangFiles/withoutNotification/ysr3.yang
+++ /dev/null
@@ -1,81 +0,0 @@
- module ietf-network3 {
- yang-version 1;
- namespace "urn:ietf:params:xml:ns:yang:ietf-network3";
- 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 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";
- }
-
- container networks {
- leaf id {
- type int32;
- }
- container network {
- leaf ip-address {
- type int32;
- }
- }
- }
-
-}
diff --git a/apps/yms/app/src/test/resources/ytbTestYangFiles/YtbAugmentForRpcInput.yang b/apps/yms/app/src/test/resources/ytbTestYangFiles/YtbAugmentForRpcInput.yang
deleted file mode 100644
index 2e8d1b3..0000000
--- a/apps/yms/app/src/test/resources/ytbTestYangFiles/YtbAugmentForRpcInput.yang
+++ /dev/null
@@ -1,20 +0,0 @@
-module YtbAugmentForRpcInput {
- yang-version 1;
- namespace "yms:test:ytb:augment:for:rpc:input";
- prefix "sch";
- import YtbRpcResponseWithAdvancedInputAndOutput {
- prefix rpc;
- }
- revision "2016-08-26";
-
- augment "/rpc:activate-software-image/rpc:output/" {
- choice selection {
- list value-in {
- key "kinetic";
- leaf kinetic {
- type "string";
- }
- }
- }
- }
-}
\ No newline at end of file
diff --git a/apps/yms/app/src/test/resources/ytbTestYangFiles/YtbAugmentForRpcInput2.yang b/apps/yms/app/src/test/resources/ytbTestYangFiles/YtbAugmentForRpcInput2.yang
deleted file mode 100644
index af59b47..0000000
--- a/apps/yms/app/src/test/resources/ytbTestYangFiles/YtbAugmentForRpcInput2.yang
+++ /dev/null
@@ -1,17 +0,0 @@
-module YtbAugmentForRpcInput2 {
- yang-version 1;
- namespace "yms:test:ytb:augment:for:rpc:input";
- prefix "sch";
- import YtbRpcResponseWithAdvancedInputAndOutput {
- prefix input;
- }
- revision "2016-08-26";
- augment "/input:activate-software-image/input:output/" {
- list friction {
- key "speed";
- leaf speed {
- type uint64;
- }
- }
- }
-}
\ No newline at end of file
diff --git a/apps/yms/app/src/test/resources/ytbTestYangFiles/YtbAugmentFromAnotherFile.yang b/apps/yms/app/src/test/resources/ytbTestYangFiles/YtbAugmentFromAnotherFile.yang
deleted file mode 100644
index 8c183c45..0000000
--- a/apps/yms/app/src/test/resources/ytbTestYangFiles/YtbAugmentFromAnotherFile.yang
+++ /dev/null
@@ -1,41 +0,0 @@
-module YtbAugmentFromAnotherFile {
- yang-version 1;
- namespace "yms:test:ytb:augment:from:another:file";
- prefix "sch";
- import yms-ietf-network {
- prefix nd;
- }
- revision "2016-08-26";
-
- augment "/nd:networks/nd:network/nd:node" {
- list termination-point {
- key "tp-id";
- leaf tp-id {
- type string;
- }
- list supporting-termination-point {
- key "network-ref node-ref tp-ref";
- leaf network-ref {
- type leafref {
- path "../../../nd:supporting-node/nd:network-ref";
- require-instance false;
- }
- }
- leaf node-ref {
- type leafref {
- path "../../../nd:supporting-node/nd:node-ref";
- require-instance false;
- }
- }
- leaf tp-ref {
- type leafref {
- path "/nd:networks/nd:network[nd:network-id=current()/"+
- "../network-ref]/nd:node[nd:node-id=current()/../"+
- "node-ref]/termination-point/tp-id";
- require-instance false;
- }
- }
- }
- }
- }
-}
\ No newline at end of file
diff --git a/apps/yms/app/src/test/resources/ytbTestYangFiles/YtbChoiceWithContainerAndLeafList.yang b/apps/yms/app/src/test/resources/ytbTestYangFiles/YtbChoiceWithContainerAndLeafList.yang
deleted file mode 100644
index 9ae462e..0000000
--- a/apps/yms/app/src/test/resources/ytbTestYangFiles/YtbChoiceWithContainerAndLeafList.yang
+++ /dev/null
@@ -1,76 +0,0 @@
-module YtbChoiceWithContainerAndLeafList {
- yang-version 1;
- namespace "yms:test:ytb:choice:with:container:and:leaf:list";
- prefix "sch";
- revision "2016-08-26";
- leaf refer {
- type binary;
- }
- rpc invalid1 {
- input {
- leaf value {
- type string;
- }
- }
- output {
- leaf value {
- type string;
- }
- }
- }
- choice content-test {
- leaf-list list-items {
- type leafref {
- path "/refer";
- }
- }
- container choice-container {
- list predict {
- config "false";
- container reproduce {
- leaf catch {
- type int16;
- }
- }
- }
- }
- case valid {
- list validlistincase {
- config "false";
- leaf validity {
- type int32;
- }
- }
- }
- case invalid {
- leaf create-invalid {
- type uint16;
- }
- }
- }
- notification invalid {
- leaf value {
- type string;
- }
- }
- notification invalid2 {
- list node {
- config false;
- leaf value {
- type string;
- }
- }
- }
- choice current-value {
- case ytb-present {
- leaf-list represent {
- type uint32;
- }
- }
- case ytb-absent {
- leaf-list final {
- type instance-identifier;
- }
- }
- }
-}
diff --git a/apps/yms/app/src/test/resources/ytbTestYangFiles/YtbDerivedTypeWithBitsAndBinary.yang b/apps/yms/app/src/test/resources/ytbTestYangFiles/YtbDerivedTypeWithBitsAndBinary.yang
deleted file mode 100644
index 1ca30a4..0000000
--- a/apps/yms/app/src/test/resources/ytbTestYangFiles/YtbDerivedTypeWithBitsAndBinary.yang
+++ /dev/null
@@ -1,56 +0,0 @@
-module YtbDerivedTypeWithBitsAndBinary {
- yang-version 1;
- namespace "yms:test:ytb:derived:type:with:bits:and:binary";
- prefix "sch";
- revision "2016-08-26";
-
- typedef derivedbinarya {
- type derivedbinaryb;
- }
-
- typedef derivedbinaryb {
- type binary;
- }
-
- typedef derivedbitsa {
- type derivedbitsb;
- }
-
- typedef derivedbitsb {
- type bits {
- bit index {
- position 1;
- }
- bit name {
- position 10;
- }
- bit signature {
- position 100;
- }
- }
- }
-
- leaf forbinary {
- type derivedbinarya;
- }
-
- leaf forbits {
- type derivedbitsa;
- }
-
- leaf-list forbinarylist {
- type derivedbinarya;
- }
-
- leaf-list forbitslist {
- type derivedbitsa;
- }
-
- leaf forunion {
- type union {
- type binary;
- type int8;
- }
- }
-}
-
diff --git a/apps/yms/app/src/test/resources/ytbTestYangFiles/YtbIetfSchedule.yang b/apps/yms/app/src/test/resources/ytbTestYangFiles/YtbIetfSchedule.yang
deleted file mode 100644
index 84c908b..0000000
--- a/apps/yms/app/src/test/resources/ytbTestYangFiles/YtbIetfSchedule.yang
+++ /dev/null
@@ -1,29 +0,0 @@
-module YtbIetfSchedule {
- yang-version 1;
- namespace "yms:test:ytb:module:with:leaf:ietfschedule";
- prefix "sch";
- revision "2016-08-26";
- leaf time {
- type int8;
- }
- leaf enum1 {
- type enumeration {
- enum ten { value "10";}
- enum hundred { value "100";}
- enum thousand { value "1000"; }
- }
- }
- leaf-list enum2 {
- type enumeration {
- enum ten-10 { value "10";}
- enum hundred-100 { value "100";}
- enum thousand-1000 { value "1000"; }
- }
- }
- container monitor {
- leaf check {
- type uint8;
- }
- }
-}
-
diff --git a/apps/yms/app/src/test/resources/ytbTestYangFiles/YtbModuleWithContainer.yang b/apps/yms/app/src/test/resources/ytbTestYangFiles/YtbModuleWithContainer.yang
deleted file mode 100644
index b0d19b8..0000000
--- a/apps/yms/app/src/test/resources/ytbTestYangFiles/YtbModuleWithContainer.yang
+++ /dev/null
@@ -1,13 +0,0 @@
-module YtbModuleWithContainer {
- yang-version 1;
- namespace "yms:test:ytb:module:with:container";
- prefix "sch";
- revision "2016-08-26";
- container sched {
- leaf predict {
- type decimal64 {
- fraction-digits 2;
- }
- }
- }
-}
diff --git a/apps/yms/app/src/test/resources/ytbTestYangFiles/YtbModuleWithLeafList.yang b/apps/yms/app/src/test/resources/ytbTestYangFiles/YtbModuleWithLeafList.yang
deleted file mode 100644
index 3d02384..0000000
--- a/apps/yms/app/src/test/resources/ytbTestYangFiles/YtbModuleWithLeafList.yang
+++ /dev/null
@@ -1,9 +0,0 @@
-module YtbModuleWithLeafList {
- yang-version 1;
- namespace "yms:test:ytb:module:with:leaflist";
- prefix "sch";
- revision "2016-08-26";
- leaf-list time {
- type int64;
- }
-}
diff --git a/apps/yms/app/src/test/resources/ytbTestYangFiles/YtbModuleWithList.yang b/apps/yms/app/src/test/resources/ytbTestYangFiles/YtbModuleWithList.yang
deleted file mode 100644
index 297a8f4..0000000
--- a/apps/yms/app/src/test/resources/ytbTestYangFiles/YtbModuleWithList.yang
+++ /dev/null
@@ -1,15 +0,0 @@
-module YtbModuleWithList {
- yang-version 1;
- namespace "yms:test:ytb:module:with:list";
- prefix "sch";
- revision "2016-08-26";
- list ytblistlist {
- config false;
- leaf-list prediction {
- type find;
- }
- }
- typedef find {
- type boolean;
- }
-}
diff --git a/apps/yms/app/src/test/resources/ytbTestYangFiles/YtbMultiModulea.yang b/apps/yms/app/src/test/resources/ytbTestYangFiles/YtbMultiModulea.yang
deleted file mode 100644
index 523f400..0000000
--- a/apps/yms/app/src/test/resources/ytbTestYangFiles/YtbMultiModulea.yang
+++ /dev/null
@@ -1,12 +0,0 @@
-module YtbMultiModulea {
- yang-version 1;
- namespace "yms:test:ytb:multi:module:a";
- prefix "sch";
- revision "2016-08-26";
- list ytbmultilist {
- config false;
- leaf-list check {
- type uint64;
- }
- }
-}
diff --git a/apps/yms/app/src/test/resources/ytbTestYangFiles/YtbMultiModuleb.yang b/apps/yms/app/src/test/resources/ytbTestYangFiles/YtbMultiModuleb.yang
deleted file mode 100644
index 7c2c257..0000000
--- a/apps/yms/app/src/test/resources/ytbTestYangFiles/YtbMultiModuleb.yang
+++ /dev/null
@@ -1,12 +0,0 @@
-module YtbMultiModuleb {
- yang-version 1;
- namespace "yms:test:ytb:multi:module:b";
- prefix "sch";
- revision "2016-08-26";
- list ytbmultilistb {
- config false;
- leaf-list checkin {
- type string;
- }
- }
-}
diff --git a/apps/yms/app/src/test/resources/ytbTestYangFiles/YtbMultiNotificationWithContainer.yang b/apps/yms/app/src/test/resources/ytbTestYangFiles/YtbMultiNotificationWithContainer.yang
deleted file mode 100644
index 9a66110..0000000
--- a/apps/yms/app/src/test/resources/ytbTestYangFiles/YtbMultiNotificationWithContainer.yang
+++ /dev/null
@@ -1,31 +0,0 @@
-module YtbMultiNotificationWithContainer {
- yang-version 1;
- namespace "yms:test:ytb:multi:notification:with:container";
- prefix "sch";
- revision "2016-08-26";
- notification fortesta {
- container ytbnot {
- leaf notileaf {
- type bits {
- bit leaf1 {
- position 0;
- }
- bit leaf2 {
- position 1;
- }
- }
- }
- }
- }
- list cumulative {
- key "sum";
- leaf sum {
- type int8;
- }
- }
- notification fortestb {
- leaf-list notileaflist {
- type empty;
- }
- }
-}
diff --git a/apps/yms/app/src/test/resources/ytbTestYangFiles/YtbRpcResponseWithAdvancedInputAndOutput.yang b/apps/yms/app/src/test/resources/ytbTestYangFiles/YtbRpcResponseWithAdvancedInputAndOutput.yang
deleted file mode 100644
index c9f708e..0000000
--- a/apps/yms/app/src/test/resources/ytbTestYangFiles/YtbRpcResponseWithAdvancedInputAndOutput.yang
+++ /dev/null
@@ -1,39 +0,0 @@
-module YtbRpcResponseWithAdvancedInputAndOutput {
- yang-version 1;
- namespace "yms:test:ytb:rpc:response:with:advanced:input:and:output";
- prefix "sch";
- revision "2016-08-26";
- leaf refer {
- type binary;
- }
- rpc activate-software-image {
- input {
- container final {
- leaf-list value {
- type uint16;
- }
- }
- }
- output {
- list output-list {
- key "list-key";
- leaf list-key {
- type leafref {
- path "/refer";
- }
- }
- container content_inside {
- leaf-list available {
- type int16;
- }
- }
- }
- }
- }
- list cumulative {
- key "sum";
- leaf sum {
- type int8;
- }
- }
-}
\ No newline at end of file
diff --git a/apps/yms/app/src/test/resources/ytbTestYangFiles/YtbSimpleAugment.yang b/apps/yms/app/src/test/resources/ytbTestYangFiles/YtbSimpleAugment.yang
deleted file mode 100644
index 919d5ed..0000000
--- a/apps/yms/app/src/test/resources/ytbTestYangFiles/YtbSimpleAugment.yang
+++ /dev/null
@@ -1,26 +0,0 @@
-module YtbSimpleAugment {
- yang-version 1;
- namespace "yms:test:ytb:simple:augment";
- prefix "sch";
- revision "2016-08-26";
- container cont1 {
- container cont2 {
- leaf fine {
- type string;
- }
- }
- }
-
- augment /cont1/cont2 {
- leaf leaf4 {
- type int32;
- }
- container cont1s {
- container cont1s {
- leaf fine {
- type string;
- }
- }
- }
- }
-}
diff --git a/apps/yms/app/src/test/resources/ytbTestYangFiles/YtbSimpleChoiceCase.yang b/apps/yms/app/src/test/resources/ytbTestYangFiles/YtbSimpleChoiceCase.yang
deleted file mode 100644
index 818d04e..0000000
--- a/apps/yms/app/src/test/resources/ytbTestYangFiles/YtbSimpleChoiceCase.yang
+++ /dev/null
@@ -1,23 +0,0 @@
-module YtbSimpleChoiceCase {
- yang-version 1;
- namespace "yms:test:ytb:simple:choice:case";
- prefix "sch";
- revision "2016-08-26";
- container YtbFood {
- choice YtbSnack {
- case ytb-sports-arena {
- leaf pretzel {
- type string;
- }
- leaf beer {
- type string;
- }
- }
- case ytb-late-night {
- leaf chocolate {
- type string;
- }
- }
- }
- }
-}
diff --git a/apps/yms/app/src/test/resources/ytbTestYangFiles/YtbSimpleRpcResponse.yang b/apps/yms/app/src/test/resources/ytbTestYangFiles/YtbSimpleRpcResponse.yang
deleted file mode 100644
index 7aaa50f..0000000
--- a/apps/yms/app/src/test/resources/ytbTestYangFiles/YtbSimpleRpcResponse.yang
+++ /dev/null
@@ -1,26 +0,0 @@
-module YtbSimpleRpcResponse {
- yang-version 1;
- namespace "yms:test:ytb:simple:rpc:response";
- prefix "sch";
- revision "2016-08-26";
- container ytb-rpc-cont {
- leaf vary {
- type uint8;
- }
- }
- rpc rpc {
- input {
- }
- output {
- leaf output-leaf {
- type uint32;
- }
- }
- }
- list cumulative {
- key "sum";
- leaf sum {
- type int8;
- }
- }
-}
diff --git a/apps/yms/app/src/test/resources/ytbTestYangFiles/YtbTreeBuilderForListHavingList.yang b/apps/yms/app/src/test/resources/ytbTestYangFiles/YtbTreeBuilderForListHavingList.yang
deleted file mode 100644
index bd58e30..0000000
--- a/apps/yms/app/src/test/resources/ytbTestYangFiles/YtbTreeBuilderForListHavingList.yang
+++ /dev/null
@@ -1,26 +0,0 @@
-module YtbTreeBuilderForListHavingList {
- yang-version 1;
- namespace "yms:test:ytb:tree:builder:for:list:having:list";
- prefix "sch";
- revision "2016-08-26";
- container carrier {
- list multiplexes {
- key "types";
- list application-areas {
- config false;
- leaf-list destination-areas {
- type binary;
- }
- }
- leaf types {
- type enumeration {
- enum space-division;
- enum frequency-division;
- enum time-division {
- value 3;
- }
- }
- }
- }
- }
-}