[ONOS-5088] YANG SBI Broker Implementation.
Change-Id: Ibe87e095a4c209c54e3e90aceca0ec9097c5ede0
diff --git a/apps/yms/app/features.xml b/apps/yms/app/features.xml
index a614bfe..80dc01d 100644
--- a/apps/yms/app/features.xml
+++ b/apps/yms/app/features.xml
@@ -20,5 +20,6 @@
<feature>onos-api</feature>
<bundle>mvn:${project.groupId}/onos-app-yms-api/${project.version}</bundle>
<bundle>mvn:${project.groupId}/${project.artifactId}/${project.version}</bundle>
+ <bundle dependency="true">mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.dom4j/1.6.1_5</bundle>
</feature>
</features>
diff --git a/apps/yms/app/pom.xml b/apps/yms/app/pom.xml
index dc88d6b..a34feb1 100644
--- a/apps/yms/app/pom.xml
+++ b/apps/yms/app/pom.xml
@@ -38,6 +38,12 @@
<artifactId>org.apache.felix.framework</artifactId>
<version>4.2.1</version>
</dependency>
+ <!--https://mvnrepository.com/artifact/org.apache.servicemix.bundles/org.apache.servicemix.bundles.dom4j -->
+ <dependency>
+ <groupId>org.apache.servicemix.bundles</groupId>
+ <artifactId>org.apache.servicemix.bundles.dom4j</artifactId>
+ <version>1.6.1_5</version>
+ </dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
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
new file mode 100644
index 0000000..8ba016d
--- /dev/null
+++ b/apps/yms/app/src/main/java/org/onosproject/yms/app/ych/DefaultYangCodecHandler.java
@@ -0,0 +1,263 @@
+/*
+ * 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.onosproject.yms.app.ych.defaultcodecs.YangCodecRegistry;
+import org.onosproject.yms.app.ydt.YdtExtendedBuilder;
+import org.onosproject.yms.app.ydt.YdtExtendedContext;
+import org.onosproject.yms.app.yob.DefaultYobBuilder;
+import org.onosproject.yms.app.ysr.YangSchemaRegistry;
+import org.onosproject.yms.app.ytb.DefaultYangTreeBuilder;
+import org.onosproject.yms.app.ytb.YtbException;
+import org.onosproject.yms.ych.YangCodecHandler;
+import org.onosproject.yms.ych.YangCompositeEncoding;
+import org.onosproject.yms.ych.YangDataTreeCodec;
+import org.onosproject.yms.ych.YangProtocolEncodingFormat;
+import org.onosproject.yms.ydt.YdtBuilder;
+import org.onosproject.yms.ydt.YdtContext;
+import org.onosproject.yms.ydt.YmsOperationType;
+
+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.
+ * YCH acts as a broker between YMS and driver/provider.
+ */
+public class DefaultYangCodecHandler implements YangCodecHandler {
+
+ private static final String E_MODULE_LIST = "The input module or " +
+ "sub-module object list cannot be null.";
+ private static final String E_DATA_TREE_CODEC = "data tree codec handler" +
+ " is null.";
+
+ /**
+ * Schema registry for driver.
+ */
+ private final YangSchemaRegistry schemaRegistry;
+
+ /**
+ * Default codecs.
+ */
+ private final Map<YangProtocolEncodingFormat, YangDataTreeCodec>
+ defaultCodecs = new HashMap<>();
+
+ /**
+ * Override codec handler.
+ */
+ private final Map<YangProtocolEncodingFormat, YangDataTreeCodec>
+ overrideCodecs = new HashMap<>();
+
+ /**
+ * Creates a new YANG codec handler.
+ *
+ * @param registry YANG schema registry
+ */
+ public DefaultYangCodecHandler(YangSchemaRegistry registry) {
+ schemaRegistry = registry;
+
+ // update the default codecs from codec registry
+ Map<YangProtocolEncodingFormat, YangDataTreeCodec> recvCodec =
+ YangCodecRegistry.getDefaultCodecs();
+ if (!recvCodec.isEmpty()) {
+ for (Map.Entry<YangProtocolEncodingFormat, YangDataTreeCodec>
+ codecEntry : recvCodec.entrySet()) {
+ defaultCodecs.put(codecEntry.getKey(), codecEntry.getValue());
+ }
+ }
+ }
+
+ private YangDataTreeCodec getAppropriateCodec(
+ YangProtocolEncodingFormat dataFormat) {
+ YangDataTreeCodec codec = defaultCodecs.get(dataFormat);
+
+ // Check over ridden codec handler is exist or not.
+ if (overrideCodecs != null) {
+ YangDataTreeCodec overrideCodec = overrideCodecs.get(dataFormat);
+ if (overrideCodec != null) {
+ codec = overrideCodec;
+ }
+ }
+ return codec;
+ }
+
+ @Override
+ public void addDeviceSchema(Class<?> yangModule) {
+ schemaRegistry.registerApplication(null, yangModule, null);
+ }
+
+ @Override
+ public String encodeOperation(String rootName,
+ String rootNamespace,
+ Map<String, String> tagAttrMap,
+ List<Object> moduleList,
+ YangProtocolEncodingFormat dataFormat,
+ YmsOperationType opType) {
+
+ if (moduleList == null || moduleList.isEmpty()) {
+ throw new YchException(E_MODULE_LIST);
+ }
+
+ // Get the default codec handler.
+ YangDataTreeCodec codec = getAppropriateCodec(dataFormat);
+ if (codec == null) {
+ throw new YchException(E_DATA_TREE_CODEC);
+ }
+
+ // Get yang data tree from YTB for the received objects.
+ DefaultYangTreeBuilder builder = new DefaultYangTreeBuilder();
+ YdtExtendedBuilder encodedYdt =
+ builder.getYdtBuilderForYo(moduleList, rootName,
+ rootNamespace, opType,
+ schemaRegistry);
+
+ encodedYdt.setRootTagAttributeMap(tagAttrMap);
+
+ // Get the xml string form codec handler.
+ return codec.encodeYdtToProtocolFormat(encodedYdt);
+ }
+
+ @Override
+ public YangCompositeEncoding encodeCompositeOperation(
+ String rootName,
+ String rootNamespace,
+ Object moduleObject,
+ YangProtocolEncodingFormat dataFormat,
+ YmsOperationType opType) {
+
+ if (moduleObject == null) {
+ throw new YtbException(E_MODULE_LIST);
+ }
+
+ // Get the default codec handler.
+ YangDataTreeCodec codec = getAppropriateCodec(dataFormat);
+ if (codec == null) {
+ throw new YchException(E_DATA_TREE_CODEC);
+ }
+
+ List<Object> yangModuleList = new ArrayList<>();
+ yangModuleList.add(moduleObject);
+
+ // Get yang data tree from YTB for the received objects.
+ DefaultYangTreeBuilder builder = new DefaultYangTreeBuilder();
+ YdtExtendedBuilder extBuilder =
+ builder.getYdtBuilderForYo(yangModuleList,
+ rootName,
+ rootNamespace,
+ opType,
+ schemaRegistry);
+
+
+ // Get the composite response from codec handler.
+ return codec.encodeYdtToCompositeProtocolFormat(extBuilder);
+ }
+
+ @Override
+ public List<Object> decode(String inputString,
+ YangProtocolEncodingFormat dataFormat,
+ YmsOperationType opType) {
+
+ 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);
+
+ if (ydtBuilder != null) {
+ return getObjectList(ydtBuilder.getRootNode());
+ }
+
+ return null;
+ }
+
+ @Override
+ public Object decode(YangCompositeEncoding protoData,
+ YangProtocolEncodingFormat dataFormat,
+ YmsOperationType opType) {
+
+ YangDataTreeCodec codec = getAppropriateCodec(dataFormat);
+ if (codec == null) {
+ throw new YchException(E_DATA_TREE_CODEC);
+ }
+
+ YdtBuilder ydtBuilder =
+ codec.decodeCompositeProtocolDataToYdt(protoData,
+ schemaRegistry,
+ opType);
+
+ // 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 null;
+ }
+
+ @Override
+ public void registerOverriddenCodec(YangDataTreeCodec overrideCodec,
+ YangProtocolEncodingFormat dataFormat) {
+ overrideCodecs.put(dataFormat, overrideCodec);
+ }
+
+ /**
+ * Returns the list of objects from YDT data tree.
+ *
+ * @param rootNode YDT root node
+ * @return returns list of objects
+ */
+ private List<Object> getObjectList(YdtContext rootNode) {
+
+ if (rootNode == null) {
+ // TODO
+ return null;
+ }
+
+ if (rootNode.getFirstChild() == null) {
+ // TODO
+ return null;
+ }
+
+ YdtContext curNode = rootNode.getFirstChild();
+ DefaultYobBuilder builder = new DefaultYobBuilder();
+ Object object = builder.getYangObject((YdtExtendedContext) curNode,
+ schemaRegistry);
+ List<Object> objectList = new ArrayList<>();
+ objectList.add(object);
+
+ // Check next module is exit or not. If exist get the object for that.
+ while (curNode.getNextSibling() != null) {
+ curNode = curNode.getNextSibling();
+ object = builder.getYangObject((YdtExtendedContext) curNode,
+ schemaRegistry);
+ objectList.add(object);
+ }
+
+ return objectList;
+ }
+}
diff --git a/apps/yms/app/src/main/java/org/onosproject/yms/app/ych/YchException.java b/apps/yms/app/src/main/java/org/onosproject/yms/app/ych/YchException.java
new file mode 100644
index 0000000..bc6cbaa
--- /dev/null
+++ b/apps/yms/app/src/main/java/org/onosproject/yms/app/ych/YchException.java
@@ -0,0 +1,58 @@
+/*
+ * 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;
+
+/**
+ * Represents base class for exceptions in YCH operations.
+ */
+public class YchException extends RuntimeException {
+ private static final long serialVersionUID = 20160211L;
+
+ /**
+ * Creates a new YCH exception.
+ */
+ public YchException() {
+ }
+
+ /**
+ * Creates a new YCH exception with given message.
+ *
+ * @param message the detail of exception in string
+ */
+ public YchException(String message) {
+ super(message);
+ }
+
+ /**
+ * Creates a new YCH exception from given message and cause.
+ *
+ * @param message the detail of exception in string
+ * @param cause underlying cause of the error
+ */
+ public YchException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ /**
+ * Creates a new YCH exception from cause.
+ *
+ * @param cause underlying cause of the error
+ */
+ public YchException(Throwable cause) {
+ super(cause);
+ }
+}
diff --git a/apps/yms/app/src/main/java/org/onosproject/yms/app/ych/defaultcodecs/CodecHandlerFactory.java b/apps/yms/app/src/main/java/org/onosproject/yms/app/ych/defaultcodecs/CodecHandlerFactory.java
new file mode 100644
index 0000000..b734239
--- /dev/null
+++ b/apps/yms/app/src/main/java/org/onosproject/yms/app/ych/defaultcodecs/CodecHandlerFactory.java
@@ -0,0 +1,109 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.yms.app.ych.defaultcodecs;
+
+
+import org.onosproject.yms.app.ych.YchException;
+import org.onosproject.yms.app.ych.defaultcodecs.xml.XmlCodecHandler;
+import org.onosproject.yms.app.ych.defaultcodecs.xml.XmlCodecMultiInstanceHandler;
+import org.onosproject.yms.app.ych.defaultcodecs.xml.XmlCodecMultiInstanceLeafHandler;
+import org.onosproject.yms.app.ych.defaultcodecs.xml.XmlCodecSingleInstanceHandler;
+import org.onosproject.yms.app.ych.defaultcodecs.xml.XmlCodecSingleInstanceLeafHandler;
+import org.onosproject.yms.ych.YangProtocolEncodingFormat;
+import org.onosproject.yms.ydt.YdtContext;
+import org.onosproject.yms.ydt.YdtType;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import static org.onosproject.yms.ych.YangProtocolEncodingFormat.XML;
+import static org.onosproject.yms.ydt.YdtType.MULTI_INSTANCE_LEAF_VALUE_NODE;
+import static org.onosproject.yms.ydt.YdtType.MULTI_INSTANCE_NODE;
+import static org.onosproject.yms.ydt.YdtType.SINGLE_INSTANCE_LEAF_VALUE_NODE;
+import static org.onosproject.yms.ydt.YdtType.SINGLE_INSTANCE_NODE;
+
+/**
+ * Represents an YCH handle factory to create different types of YANG data tree
+ * node.
+ */
+public final class CodecHandlerFactory {
+
+ private static final Logger log =
+ LoggerFactory.getLogger(CodecHandlerFactory.class);
+ private static final String YDT_TYPE_ERROR = "YDT type is not supported.";
+
+ /**
+ * Map of xml codec handler.
+ */
+ private final Map<YdtType, XmlCodecHandler> handlerMap;
+
+ /**
+ * Creates a new codec handler factory.
+ */
+ private CodecHandlerFactory() {
+ handlerMap = new HashMap<>();
+ handlerMap.put(SINGLE_INSTANCE_NODE,
+ new XmlCodecSingleInstanceHandler());
+ handlerMap.put(MULTI_INSTANCE_NODE,
+ new XmlCodecMultiInstanceHandler());
+ handlerMap.put(SINGLE_INSTANCE_LEAF_VALUE_NODE,
+ new XmlCodecSingleInstanceLeafHandler());
+ handlerMap.put(MULTI_INSTANCE_LEAF_VALUE_NODE,
+ new XmlCodecMultiInstanceLeafHandler());
+ }
+
+ /**
+ * Returns YCH instance handler node instance.
+ *
+ * @param node YDT context node
+ * @param format data format type expected from driver
+ * @return returns YCH handler node instance
+ */
+ public XmlCodecHandler getCodecHandlerForContext(
+ YdtContext node,
+ YangProtocolEncodingFormat format) {
+ if (format == XML) {
+ XmlCodecHandler handler = handlerMap.get(node.getYdtType());
+ if (handler == null) {
+ throw new YchException(YDT_TYPE_ERROR + node.getYdtType());
+ }
+ return handler;
+ }
+ log.error("{} data format is not supported.", format);
+ return null;
+ }
+
+ /*
+ * 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 CodecHandlerFactory INSTANCE =
+ new CodecHandlerFactory();
+ }
+
+ /**
+ * Returns a reference to the Singleton Codec Handler factory.
+ *
+ * @return the singleton codec handler factory
+ */
+ public static CodecHandlerFactory instance() {
+ return LazyHolder.INSTANCE;
+ }
+}
diff --git a/apps/yms/app/src/main/java/org/onosproject/yms/app/ych/defaultcodecs/YangCodecRegistry.java b/apps/yms/app/src/main/java/org/onosproject/yms/app/ych/defaultcodecs/YangCodecRegistry.java
new file mode 100644
index 0000000..2050b56
--- /dev/null
+++ b/apps/yms/app/src/main/java/org/onosproject/yms/app/ych/defaultcodecs/YangCodecRegistry.java
@@ -0,0 +1,71 @@
+/*
+ * 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.defaultcodecs;
+
+import org.onosproject.yms.app.ych.defaultcodecs.xml.DefaultXmlCodec;
+import org.onosproject.yms.ych.YangDataTreeCodec;
+import org.onosproject.yms.ych.YangProtocolEncodingFormat;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+
+import static org.onosproject.yms.ych.YangProtocolEncodingFormat.XML;
+
+/**
+ * Default implementation of YANG codec registry.
+ */
+public final class YangCodecRegistry {
+
+ // no instantiation
+ private YangCodecRegistry() {
+ }
+
+ /**
+ * Default codec map.
+ */
+ private static final Map<YangProtocolEncodingFormat, YangDataTreeCodec>
+ DEFAULT_CODECS = new HashMap<>();
+
+ /**
+ * Initialise the default codec map.
+ */
+ public static void initializeDefaultCodec() {
+ DEFAULT_CODECS.put(XML, new DefaultXmlCodec());
+ }
+
+ /**
+ * Returns the default codec map.
+ *
+ * @return the default codec map
+ */
+ public static Map<YangProtocolEncodingFormat, YangDataTreeCodec> getDefaultCodecs() {
+ return Collections.unmodifiableMap(DEFAULT_CODECS);
+ }
+
+ /**
+ * Registers a default codec for the specified data format.
+ *
+ * @param defaultCodec registered data tree codec
+ * @param dataFormat protocol encoding data format
+ */
+ public static void registerDefaultCodec(
+ YangDataTreeCodec defaultCodec,
+ YangProtocolEncodingFormat dataFormat) {
+ DEFAULT_CODECS.put(dataFormat, defaultCodec);
+ }
+}
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
new file mode 100644
index 0000000..8b50d33
--- /dev/null
+++ b/apps/yms/app/src/main/java/org/onosproject/yms/app/ych/defaultcodecs/netconf/NetconfCodec.java
@@ -0,0 +1,123 @@
+/*
+ * 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.defaultcodecs.netconf;
+
+import com.google.common.collect.ImmutableSet;
+import org.dom4j.Element;
+import org.onosproject.yms.app.ych.YchException;
+import org.onosproject.yms.ydt.YmsOperationType;
+
+import java.util.Iterator;
+import java.util.Set;
+
+import static org.onosproject.yms.app.ych.defaultcodecs.netconf.NetconfCodecConstants.CONFIG;
+import static org.onosproject.yms.app.ych.defaultcodecs.netconf.NetconfCodecConstants.DATA;
+import static org.onosproject.yms.app.ych.defaultcodecs.netconf.NetconfCodecConstants.EDIT_CONFIG;
+import static org.onosproject.yms.app.ych.defaultcodecs.netconf.NetconfCodecConstants.FILTER;
+import static org.onosproject.yms.app.ych.defaultcodecs.netconf.NetconfCodecConstants.GET;
+import static org.onosproject.yms.app.ych.defaultcodecs.netconf.NetconfCodecConstants.GET_CONFIG;
+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;
+
+/**
+ * Represents an YCH netconf codec to find the root element in the xml string.
+ */
+public class NetconfCodec {
+
+ private static final String PROTO_OPER_ERROR = "Received protocol " +
+ "operation is not same as in the XML string: ";
+ private static final Set<String> ALLOWABLE_NAMES =
+ ImmutableSet.of(CONFIG, DATA, FILTER);
+
+ /**
+ * Validate the operation type.
+ *
+ * @param elementName tag name in the xml string
+ * @param opType operation type
+ */
+ private void validateOpType(String elementName, YmsOperationType opType) {
+ switch (elementName) {
+ // edit-config tag name is found in xml then check the
+ // interaction type.
+ case EDIT_CONFIG: {
+ if (opType != EDIT_CONFIG_REQUEST) {
+ throw new YchException(PROTO_OPER_ERROR + opType);
+ }
+ break;
+ }
+
+ // get-config tag name is found in xml then check the
+ // interaction type.
+ case GET_CONFIG: {
+ if (opType != QUERY_CONFIG_REQUEST) {
+ throw new YchException(PROTO_OPER_ERROR + opType);
+ }
+ break;
+ }
+
+ // get tag name is found in xml then check the interaction type.
+ case GET: {
+ if (opType != QUERY_REQUEST) {
+ throw new YchException(PROTO_OPER_ERROR + opType);
+ }
+ break;
+ }
+
+ default: {
+ //TODO
+ }
+ }
+
+ }
+
+ /**
+ * Returns the data root element based on the NETCONF operation parameter.
+ *
+ * @param rootElement root element of document tree to find the root node
+ * @param opType protocol operation being performed
+ * @return the data root node element
+ */
+ public Element getDataRootElement(Element rootElement,
+ YmsOperationType opType) {
+
+ Element retElement = null;
+ String elementName = rootElement.getName();
+ try {
+ validateOpType(elementName, opType);
+ // If config tag name is found then set the root element node.
+ if (ALLOWABLE_NAMES.contains(elementName)) {
+ return rootElement;
+ }
+
+ // If element has child node then traverse through the child node
+ // by recursively calling getDataRootElement method.
+ if (rootElement.hasContent() && !rootElement.isTextOnly()) {
+ for (Iterator i = rootElement.elementIterator();
+ i.hasNext();) {
+ Element childElement = (Element) i.next();
+ retElement = getDataRootElement(childElement, opType);
+ }
+ }
+
+ } catch (Exception e) {
+ // TODO
+ }
+
+ return retElement;
+ }
+}
diff --git a/apps/yms/app/src/main/java/org/onosproject/yms/app/ych/defaultcodecs/netconf/NetconfCodecConstants.java b/apps/yms/app/src/main/java/org/onosproject/yms/app/ych/defaultcodecs/netconf/NetconfCodecConstants.java
new file mode 100644
index 0000000..bf0ee49
--- /dev/null
+++ b/apps/yms/app/src/main/java/org/onosproject/yms/app/ych/defaultcodecs/netconf/NetconfCodecConstants.java
@@ -0,0 +1,63 @@
+/*
+ * 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.defaultcodecs.netconf;
+
+/**
+ * Represents utilities constants which are used while codec encoding
+ * and decoding.
+ */
+public final class NetconfCodecConstants {
+
+ // no instantiation
+ private NetconfCodecConstants() {
+ }
+
+ /**
+ * Static attribute for edit config string.
+ */
+ static final String EDIT_CONFIG = "edit-config";
+
+ /**
+ * Static attribute for edit config string.
+ */
+ static final String GET_CONFIG = "get-config";
+
+ /**
+ * Static attribute for edit config string.
+ */
+ static final String GET = "get";
+
+ /**
+ * Static attribute for edit config string.
+ */
+ static final String CONFIG = "config";
+
+ /**
+ * Static attribute for edit config string.
+ */
+ static final String DATA = "data";
+
+ /**
+ * Static attribute for edit config string.
+ */
+ static final String FILTER = "filter";
+
+ /**
+ * Static attribute for edit config string.
+ */
+ public static final String OPERATION = "operation";
+}
diff --git a/apps/yms/app/src/main/java/org/onosproject/yms/app/ych/defaultcodecs/netconf/package-info.java b/apps/yms/app/src/main/java/org/onosproject/yms/app/ych/defaultcodecs/netconf/package-info.java
new file mode 100644
index 0000000..e37cb16
--- /dev/null
+++ b/apps/yms/app/src/main/java/org/onosproject/yms/app/ych/defaultcodecs/netconf/package-info.java
@@ -0,0 +1,21 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * Provides implementation of default codec handler for netconf related
+ * operation.
+ */
+package org.onosproject.yms.app.ych.defaultcodecs.netconf;
diff --git a/apps/yms/app/src/main/java/org/onosproject/yms/app/ych/defaultcodecs/package-info.java b/apps/yms/app/src/main/java/org/onosproject/yms/app/ych/defaultcodecs/package-info.java
new file mode 100644
index 0000000..2b3da2b
--- /dev/null
+++ b/apps/yms/app/src/main/java/org/onosproject/yms/app/ych/defaultcodecs/package-info.java
@@ -0,0 +1,20 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * Default codec to support protocol data format encoding and decoding of the YANG objects.
+ */
+package org.onosproject.yms.app.ych.defaultcodecs;
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
new file mode 100644
index 0000000..1d9e339
--- /dev/null
+++ b/apps/yms/app/src/main/java/org/onosproject/yms/app/ych/defaultcodecs/utils/DefaultCodecUtils.java
@@ -0,0 +1,261 @@
+/*
+ * 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.defaultcodecs.utils;
+
+import com.google.common.base.Splitter;
+import com.google.common.collect.Lists;
+import org.onosproject.yms.app.ych.YchException;
+import org.onosproject.yms.ydt.YdtBuilder;
+import org.onosproject.yms.ydt.YdtContextOperationType;
+
+import java.io.UnsupportedEncodingException;
+import java.net.URLDecoder;
+import java.util.ArrayList;
+import java.util.List;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+import static org.onosproject.yms.ydt.YdtContextOperationType.NONE;
+import static org.onosproject.yms.ydt.YdtType.SINGLE_INSTANCE_NODE;
+
+/**
+ * Utils to complete the conversion between JSON and YDT(YANG DATA MODEL).
+ */
+public final class DefaultCodecUtils {
+
+ private static final Splitter SLASH_SPLITTER = Splitter.on('/');
+ private static final Splitter COMMA_SPLITTER = Splitter.on(',');
+ private static final String EQUAL = "=";
+ private static final String COMMA = ",";
+ private static final String COLON = ":";
+ private static final String URI_ENCODING_CHAR_SET = "ISO-8859-1";
+ private static final String URI_NULL_CHECK_ERROR = "uri identifier " +
+ "should not be null";
+ private static final String URI_MODULE_FORMAT = "Illegal URI, First " +
+ "node should be in format \"moduleName:nodeName\"";
+
+ private static final String URI_LEAF_FORMAT = "Illegal URI, List or " +
+ "Leaf-list node should be in format \"nodeName=key\"or " +
+ "\"nodeName=instance-value\"";
+
+ // no instantiation
+ private DefaultCodecUtils() {
+ }
+
+ /**
+ * Converts URI identifier to YDT builder.
+ *
+ * @param identifier the uri identifier from web request
+ * @param builder the base YDT builder
+ * @param ydtOpType the YDT context operation type
+ * @return the YDT builder with the tree info of identifier
+ */
+ public static YdtBuilder convertUriToYdt(
+ String identifier,
+ YdtBuilder builder,
+ YdtContextOperationType ydtOpType) {
+ checkNotNull(identifier, URI_NULL_CHECK_ERROR);
+ List<String> segmentPaths =
+ urlPathArgsDecode(SLASH_SPLITTER.split(identifier));
+ if (segmentPaths.isEmpty()) {
+ return null;
+ }
+ processPathSegments(segmentPaths, builder, ydtOpType);
+ return builder;
+ }
+
+ /**
+ * 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
+ * @param builder the base YDT builder
+ * @param ydtOpType the YDT context operation type
+ * @return the YDT builder with the tree info of paths
+ */
+ private static YdtBuilder processPathSegments(
+ List<String> paths,
+ YdtBuilder builder,
+ YdtContextOperationType ydtOpType) {
+ if (paths.isEmpty()) {
+ return builder;
+ }
+ boolean isLastNode = paths.size() == 1;
+ YdtContextOperationType thisOpType = isLastNode ? ydtOpType : NONE;
+
+ final String path = paths.iterator().next();
+ if (path.contains(COLON)) {
+ addModule(builder, path);
+ addNode(path, builder, thisOpType);
+ } else if (path.contains(EQUAL)) {
+ addListOrLeafList(path, builder, thisOpType);
+ } else {
+ addLeaf(path, builder, thisOpType);
+ }
+
+ if (isLastNode) {
+ return builder;
+ }
+ List<String> remainPaths = paths.subList(1, paths.size());
+ processPathSegments(remainPaths, builder, ydtOpType);
+
+ return builder;
+ }
+
+ /**
+ * Returns YDT builder after adding module node.
+ *
+ * @param builder YDT builder
+ * @param path path segment
+ * @return the YDT builder
+ */
+ private static YdtBuilder addModule(YdtBuilder builder, String path) {
+ String moduleName = getPreSegment(path, COLON);
+ if (moduleName == null) {
+ throw new YchException(URI_MODULE_FORMAT);
+ }
+ builder.addChild(moduleName, null, SINGLE_INSTANCE_NODE);
+ return builder;
+ }
+
+ /**
+ * Returns YDT builder after adding single instance node.
+ *
+ * @param path path segments
+ * @param builder YDT builder
+ * @param ydtOpType YDT context operation type
+ * @return the YDT builder
+ */
+ private static YdtBuilder addNode(String path, YdtBuilder builder,
+ YdtContextOperationType ydtOpType) {
+ String nodeName = getPostSegment(path, COLON);
+ builder.addChild(nodeName, null, SINGLE_INSTANCE_NODE, ydtOpType);
+ return builder;
+ }
+
+ /**
+ * Returns YDT builder after adding multi instance node.
+ *
+ * @param path path segments
+ * @param builder YDT builder
+ * @param opType the YDT context operation type
+ * @return the YDT builder
+ */
+ private static YdtBuilder addListOrLeafList(
+ String path,
+ YdtBuilder builder,
+ YdtContextOperationType opType) {
+ String nodeName = getPreSegment(path, EQUAL);
+ String keyStr = getPostSegment(path, EQUAL);
+ if (keyStr == null) {
+ throw new YchException(URI_LEAF_FORMAT);
+ }
+ builder.setDefaultEditOperationType(opType);
+ if (keyStr.contains(COMMA)) {
+ List<String> keys = Lists.newArrayList(
+ COMMA_SPLITTER.split(keyStr));
+ builder.addMultiInstanceChild(nodeName, null, keys, null);
+ } else {
+ builder.addMultiInstanceChild(nodeName, null,
+ Lists.newArrayList(keyStr), null);
+ }
+ return builder;
+ }
+
+ /**
+ * Returns YDT builder after adding leaf.
+ *
+ * @param path path segments
+ * @param builder YDT builder
+ * @param ydtOpType YDT context operation type
+ * @return the YDT builder
+ */
+ private static YdtBuilder addLeaf(String path, YdtBuilder builder,
+ YdtContextOperationType ydtOpType) {
+ checkNotNull(path);
+ builder.addChild(path, null, ydtOpType);
+ return builder;
+ }
+
+ /**
+ * Returns the node name before the specified character in the string.
+ *
+ * @param path path segment
+ * @param splitChar character in the string
+ * @return the node name string
+ */
+ private static String getPreSegment(String path, String splitChar) {
+ int idx = path.indexOf(splitChar);
+ if (idx == -1) {
+ return null;
+ }
+
+ if (path.indexOf(':', idx + 1) != -1) {
+ return null;
+ }
+
+ return path.substring(0, idx);
+ }
+
+ /**
+ * Returns the string after the specified character in the string.
+ *
+ * @param path path segment
+ * @param splitChar character in the string
+ * @return the substring after specified character
+ */
+ private static String getPostSegment(String path, String splitChar) {
+ int idx = path.indexOf(splitChar);
+ if (idx == -1) {
+ return path;
+ }
+
+ if (path.indexOf(splitChar, idx + 1) != -1) {
+ return null;
+ }
+
+ return path.substring(idx + 1);
+ }
+
+ /**
+ * Converts a list of path from the original format to ISO-8859-1 code.
+ *
+ * @param paths the original paths
+ * @return list of decoded paths
+ */
+ private static List<String> urlPathArgsDecode(Iterable<String> paths) {
+ try {
+ List<String> decodedPathArgs = new ArrayList<>();
+ for (String pathArg : paths) {
+ String decode = URLDecoder.decode(pathArg,
+ URI_ENCODING_CHAR_SET);
+ decodedPathArgs.add(decode);
+ }
+ return decodedPathArgs;
+ } catch (UnsupportedEncodingException e) {
+ throw new YchException("Invalid URL path arg '" + paths + "': ", e);
+ }
+ }
+}
diff --git a/apps/yms/app/src/main/java/org/onosproject/yms/app/ych/defaultcodecs/utils/package-info.java b/apps/yms/app/src/main/java/org/onosproject/yms/app/ych/defaultcodecs/utils/package-info.java
new file mode 100644
index 0000000..f0d8599
--- /dev/null
+++ b/apps/yms/app/src/main/java/org/onosproject/yms/app/ych/defaultcodecs/utils/package-info.java
@@ -0,0 +1,20 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * Provides implementation of default codec utilities.
+ */
+package org.onosproject.yms.app.ych.defaultcodecs.utils;
diff --git a/apps/yms/app/src/main/java/org/onosproject/yms/app/ych/defaultcodecs/xml/DefaultXmlCodec.java b/apps/yms/app/src/main/java/org/onosproject/yms/app/ych/defaultcodecs/xml/DefaultXmlCodec.java
new file mode 100644
index 0000000..915863e
--- /dev/null
+++ b/apps/yms/app/src/main/java/org/onosproject/yms/app/ych/defaultcodecs/xml/DefaultXmlCodec.java
@@ -0,0 +1,190 @@
+/*
+ * 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.defaultcodecs.xml;
+
+import org.dom4j.Document;
+import org.dom4j.DocumentException;
+import org.dom4j.DocumentHelper;
+import org.dom4j.Element;
+import org.dom4j.Namespace;
+import org.onosproject.yms.app.ych.YchException;
+import org.onosproject.yms.app.ych.defaultcodecs.netconf.NetconfCodec;
+import org.onosproject.yms.app.ych.defaultcodecs.utils.DefaultCodecUtils;
+import org.onosproject.yms.app.ydt.DefaultYdtWalker;
+import org.onosproject.yms.app.ydt.YangRequestWorkBench;
+import org.onosproject.yms.app.ydt.YdtExtendedBuilder;
+import org.onosproject.yms.app.ydt.YdtExtendedContext;
+import org.onosproject.yms.app.ydt.YdtExtendedWalker;
+import org.onosproject.yms.app.ysr.YangSchemaRegistry;
+import org.onosproject.yms.ych.YangCompositeEncoding;
+import org.onosproject.yms.ych.YangDataTreeCodec;
+import org.onosproject.yms.ydt.YdtBuilder;
+import org.onosproject.yms.ydt.YmsOperationType;
+
+import java.util.Map;
+
+import static org.onosproject.yms.ych.YangProtocolEncodingFormat.XML;
+import static org.onosproject.yms.ydt.YdtContextOperationType.CREATE;
+
+/**
+ * Represents an implementation of YCH data tree codec interface.
+ */
+public class DefaultXmlCodec implements YangDataTreeCodec {
+
+ private static final String E_RESTCONF_ROOT = "/onos/restconf";
+ private static final String E_YDT_ROOT_NODE = "YDT extended root node " +
+ "is null.";
+ private static final String E_ROOT_ELEMENT = "Root element in XML " +
+ "input string is not well-formed.";
+ private static final String E_ROOT_KEY_ELEMENT = "Root element " +
+ "(filter, config, data) in XML input string is not found.";
+
+
+ /**
+ * Creates a new YANG xml codec.
+ */
+ public DefaultXmlCodec() {
+ }
+
+ /**
+ * Returns the xml string from YDT.
+ *
+ * @param ydtBuilder YDT builder
+ * @return the xml string from YDT
+ */
+ private String buildXmlForYdt(YdtBuilder ydtBuilder) {
+
+ YdtExtendedBuilder extBuilder = (YdtExtendedBuilder) ydtBuilder;
+ YdtExtendedContext rootNode = extBuilder.getRootNode();
+
+ if (rootNode == null) {
+ throw new YchException(E_YDT_ROOT_NODE);
+ }
+
+ // Creating the root element for xml.
+ Element rootElement =
+ DocumentHelper.createDocument().addElement(rootNode.getName());
+
+ // Adding the name space if exist for root name.
+ if (rootNode.getNamespace() != null) {
+ rootElement.add(Namespace.get(rootNode.getNamespace()));
+ }
+
+ // Adding the attribute if exist
+ Map<String, String> tagAttrMap = extBuilder.getRootTagAttributeMap();
+ if (tagAttrMap != null && !tagAttrMap.isEmpty()) {
+ for (Map.Entry<String, String> attr : tagAttrMap.entrySet()) {
+ rootElement.addAttribute(attr.getKey(), attr.getValue());
+ }
+ }
+
+ XmlCodecYdtListener listener = new XmlCodecYdtListener(XML, rootNode);
+ listener.getElementStack().push(rootElement);
+
+ // Walk through YDT and build the xml.
+ YdtExtendedWalker extWalker = new DefaultYdtWalker();
+ extWalker.walk(listener, rootNode);
+
+ return rootElement.asXML();
+ }
+
+ @Override
+ public String encodeYdtToProtocolFormat(YdtBuilder ydtBuilder) {
+ return buildXmlForYdt(ydtBuilder);
+ }
+
+ @Override
+ public YangCompositeEncoding encodeYdtToCompositeProtocolFormat(
+ YdtBuilder ydtBuilder) {
+
+ YangCompositeEncodingImpl encoding = new YangCompositeEncodingImpl();
+ encoding.setResourceIdentifier(null);
+ encoding.setResourceInformation(buildXmlForYdt(ydtBuilder));
+ return encoding;
+ }
+
+ @Override
+ public YdtBuilder decodeCompositeProtocolDataToYdt(
+ YangCompositeEncoding protoData,
+ Object schemaReg,
+ YmsOperationType opType) {
+
+ YdtExtendedBuilder extBuilder =
+ new YangRequestWorkBench(E_RESTCONF_ROOT, null,
+ opType,
+ (YangSchemaRegistry) schemaReg,
+ false);
+
+ DefaultCodecUtils.convertUriToYdt(protoData.getResourceIdentifier(),
+ extBuilder,
+ CREATE);
+ Document document;
+
+ try {
+ document = DocumentHelper
+ .parseText(protoData.getResourceInformation());
+ } catch (DocumentException e) {
+ throw new YchException(E_ROOT_ELEMENT);
+ }
+
+ XmlCodecListener listener = new XmlCodecListener();
+ listener.setYdtExtBuilder(extBuilder);
+
+ // Walk through xml and build the yang data tree.
+ XmlWalker walker = new DefaultXmlCodecWalker();
+ walker.walk(listener, document.getRootElement(),
+ document.getRootElement());
+ return extBuilder;
+ }
+
+ @Override
+ public YdtBuilder decodeProtocolDataToYdt(String protoData,
+ Object schemaReg,
+ YmsOperationType opType) {
+ Document document;
+
+ try {
+ document = DocumentHelper.parseText(protoData);
+ } catch (DocumentException e) {
+ throw new YchException(E_ROOT_ELEMENT);
+ }
+
+ NetconfCodec codec = new NetconfCodec();
+ // Find the root element in xml string
+ Element rootElement =
+ codec.getDataRootElement(document.getRootElement(), opType);
+
+ if (rootElement == null) {
+ throw new YchException(E_ROOT_KEY_ELEMENT);
+ }
+
+ // Get the YDT builder for the logical root name.
+ YdtExtendedBuilder extBuilder =
+ new YangRequestWorkBench(rootElement.getName(),
+ rootElement.getNamespaceURI(),
+ opType,
+ (YangSchemaRegistry) schemaReg,
+ false);
+
+ XmlCodecListener listener = new XmlCodecListener();
+ listener.setYdtExtBuilder(extBuilder);
+ // Walk through xml and build the yang data tree.
+ XmlWalker walker = new DefaultXmlCodecWalker();
+ walker.walk(listener, rootElement, rootElement);
+ return extBuilder;
+ }
+}
diff --git a/apps/yms/app/src/main/java/org/onosproject/yms/app/ych/defaultcodecs/xml/DefaultXmlCodecWalker.java b/apps/yms/app/src/main/java/org/onosproject/yms/app/ych/defaultcodecs/xml/DefaultXmlCodecWalker.java
new file mode 100644
index 0000000..b5a9ea2
--- /dev/null
+++ b/apps/yms/app/src/main/java/org/onosproject/yms/app/ych/defaultcodecs/xml/DefaultXmlCodecWalker.java
@@ -0,0 +1,65 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.yms.app.ych.defaultcodecs.xml;
+
+import org.dom4j.Element;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.Iterator;
+
+import static org.onosproject.yms.app.ych.defaultcodecs.xml.XmlNodeType.OBJECT_NODE;
+import static org.onosproject.yms.app.ych.defaultcodecs.xml.XmlNodeType.TEXT_NODE;
+
+/**
+ * Represents implementation of codec xml walker.
+ */
+class DefaultXmlCodecWalker implements XmlWalker {
+ private final Logger log = LoggerFactory.getLogger(getClass());
+
+ @Override
+ public void walk(XmlListener listener, Element element,
+ Element rootElement) {
+ try {
+ listener.enterXmlElement(element, getElementType(element),
+ rootElement);
+
+ if (element.hasContent() && !element.isTextOnly()) {
+ for (Iterator i = element.elementIterator(); i.hasNext();) {
+ Element childElement = (Element) i.next();
+ walk(listener, childElement, rootElement);
+ }
+ }
+
+ listener.exitXmlElement(element, getElementType(element),
+ rootElement);
+ } catch (Exception e) {
+ log.error("Exception occurred when walk xml element: {}", element);
+ }
+ }
+
+ /**
+ * Determine the type of an element.
+ *
+ * @param element to be analysed
+ * @return type of the element
+ */
+ private XmlNodeType getElementType(Element element) {
+ return element.hasContent() && element.isTextOnly() ?
+ TEXT_NODE : OBJECT_NODE;
+ }
+}
diff --git a/apps/yms/app/src/main/java/org/onosproject/yms/app/ych/defaultcodecs/xml/XmlCodecHandler.java b/apps/yms/app/src/main/java/org/onosproject/yms/app/ych/defaultcodecs/xml/XmlCodecHandler.java
new file mode 100644
index 0000000..b7685a8
--- /dev/null
+++ b/apps/yms/app/src/main/java/org/onosproject/yms/app/ych/defaultcodecs/xml/XmlCodecHandler.java
@@ -0,0 +1,101 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.yms.app.ych.defaultcodecs.xml;
+
+import org.dom4j.Element;
+import org.onosproject.yms.app.ydt.YdtExtendedContext;
+import org.onosproject.yms.ydt.YdtContext;
+import org.onosproject.yms.ydt.YdtContextOperationType;
+
+import java.util.Stack;
+
+import static org.onosproject.yms.app.ych.defaultcodecs.netconf.NetconfCodecConstants.OPERATION;
+import static org.onosproject.yms.ydt.YdtContextOperationType.NONE;
+
+/**
+ * Represents an codec handler to process the xml content and add
+ * element to the stack.
+ */
+public abstract class XmlCodecHandler {
+
+ /**
+ * Sets the namespace and tag name in element tree maintained in stack.
+ *
+ * @param ydtContext YDT context
+ * @param elementStack element tree stack
+ */
+ void processXmlContext(YdtContext ydtContext,
+ Stack<Element> elementStack) {
+
+ Element newElement = updateNameAndNamespace(ydtContext,
+ elementStack.peek());
+ elementStack.push(newElement);
+ }
+
+ /**
+ * Returns the new element name by updating tag name and namespace.
+ *
+ * @param ydtContext YDT context node
+ * @param xmlElement element in the stack used for adding new element
+ * @return new element name by updating tag name and namespace
+ */
+ Element updateNameAndNamespace(YdtContext ydtContext,
+ Element xmlElement) {
+ String nameSpace = null;
+ if (ydtContext.getNamespace() != null) {
+ nameSpace = ydtContext.getNamespace();
+ }
+
+ String parentNameSpace = null;
+ if (ydtContext.getParent() != null) {
+ parentNameSpace = ydtContext.getParent().getNamespace();
+ }
+
+ Element newElement;
+ if (nameSpace != null) {
+ newElement = xmlElement.addElement(ydtContext.getName(),
+ nameSpace);
+ } else {
+ if (parentNameSpace != null) {
+ newElement = xmlElement.addElement(ydtContext.getName(),
+ parentNameSpace);
+ } else {
+ newElement = xmlElement.addElement(ydtContext.getName());
+ }
+ }
+
+ YdtContextOperationType opType = ((YdtExtendedContext) ydtContext)
+ .getYdtContextOperationType();
+ if (opType != null && opType != NONE) {
+ newElement.addAttribute(OPERATION,
+ opType.toString().toLowerCase());
+ }
+
+ return newElement;
+ }
+
+ /**
+ * Sets the leaf value in the current element maintained in stack.
+ * Default behaviour is to do nothing.
+ *
+ * @param ydtContext YDT context node
+ * @param domElementStack current element node in the stack
+ */
+ public void setXmlValue(YdtContext ydtContext,
+ Stack<Element> domElementStack) {
+ }
+}
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
new file mode 100644
index 0000000..6b6ba38
--- /dev/null
+++ b/apps/yms/app/src/main/java/org/onosproject/yms/app/ych/defaultcodecs/xml/XmlCodecListener.java
@@ -0,0 +1,96 @@
+/*
+ * 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.defaultcodecs.xml;
+
+import org.dom4j.Attribute;
+import org.dom4j.Element;
+import org.onosproject.yms.app.ydt.YdtExtendedBuilder;
+import org.onosproject.yms.ydt.YdtContextOperationType;
+
+import java.util.Iterator;
+
+import static org.onosproject.yms.app.ych.defaultcodecs.netconf.NetconfCodecConstants.OPERATION;
+import static org.onosproject.yms.app.ych.defaultcodecs.xml.XmlNodeType.OBJECT_NODE;
+import static org.onosproject.yms.app.ych.defaultcodecs.xml.XmlNodeType.TEXT_NODE;
+
+/**
+ * Default implementation of codec xml listener.
+ */
+class XmlCodecListener implements XmlListener {
+
+ /**
+ * YANG data tree builder object.
+ */
+ private YdtExtendedBuilder ydtExtBuilder;
+
+ /**
+ * Sets the YANG data tree builder object.
+ *
+ * @param ydtBuilder YANG data tree builder object
+ */
+ void setYdtExtBuilder(YdtExtendedBuilder ydtBuilder) {
+ ydtExtBuilder = ydtBuilder;
+ }
+
+ @Override
+ public void enterXmlElement(Element element, XmlNodeType nodeType,
+ Element rootElement) {
+ if (element.equals(rootElement)) {
+ return;
+ }
+
+ YdtContextOperationType opType = null;
+
+ for (Iterator iter = element.attributeIterator(); iter.hasNext();) {
+ Attribute attr = (Attribute) iter.next();
+ if (attr.getName().equals(OPERATION)) {
+ opType =
+ YdtContextOperationType.valueOf(attr.getValue()
+ .toUpperCase());
+ }
+ }
+
+ String nameSpace = null;
+ if (element.getNamespace() != null) {
+ nameSpace = element.getNamespace().getURI();
+ }
+
+ if (nodeType == OBJECT_NODE) {
+ if (ydtExtBuilder != null) {
+ ydtExtBuilder.addChild(element.getName(), nameSpace, opType);
+ }
+ } else if (nodeType == TEXT_NODE) {
+
+ if (ydtExtBuilder != null) {
+ ydtExtBuilder.addLeaf(element.getName(), nameSpace,
+ element.getText());
+ }
+ }
+ }
+
+ @Override
+ public void exitXmlElement(Element element, XmlNodeType nodeType,
+ Element rootElement) {
+ if (element.equals(rootElement)) {
+ return;
+ }
+
+ if (ydtExtBuilder != null) {
+ ydtExtBuilder.traverseToParent();
+ }
+ }
+}
diff --git a/apps/yms/app/src/main/java/org/onosproject/yms/app/ych/defaultcodecs/xml/XmlCodecMultiInstanceHandler.java b/apps/yms/app/src/main/java/org/onosproject/yms/app/ych/defaultcodecs/xml/XmlCodecMultiInstanceHandler.java
new file mode 100644
index 0000000..fa63ce5
--- /dev/null
+++ b/apps/yms/app/src/main/java/org/onosproject/yms/app/ych/defaultcodecs/xml/XmlCodecMultiInstanceHandler.java
@@ -0,0 +1,23 @@
+/*
+ * 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.defaultcodecs.xml;
+
+/**
+ * Represents a multi instance node handler in YCH.
+ */
+public class XmlCodecMultiInstanceHandler extends XmlCodecHandler {
+}
diff --git a/apps/yms/app/src/main/java/org/onosproject/yms/app/ych/defaultcodecs/xml/XmlCodecMultiInstanceLeafHandler.java b/apps/yms/app/src/main/java/org/onosproject/yms/app/ych/defaultcodecs/xml/XmlCodecMultiInstanceLeafHandler.java
new file mode 100644
index 0000000..234d9d9
--- /dev/null
+++ b/apps/yms/app/src/main/java/org/onosproject/yms/app/ych/defaultcodecs/xml/XmlCodecMultiInstanceLeafHandler.java
@@ -0,0 +1,49 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.yms.app.ych.defaultcodecs.xml;
+
+import org.dom4j.Element;
+import org.onosproject.yms.ydt.YdtContext;
+
+import java.util.Iterator;
+import java.util.Stack;
+
+/**
+ * Represents a multi instance leaf node handler in YCH.
+ */
+public class XmlCodecMultiInstanceLeafHandler extends XmlCodecHandler {
+
+ @Override
+ public void setXmlValue(YdtContext ydtContext,
+ Stack<Element> elementStack) {
+
+ if (ydtContext.getValueSet().isEmpty()) {
+ return;
+ }
+
+ Iterator<String> iterator = ydtContext.getValueSet().iterator();
+ elementStack.peek().setText(iterator.next());
+ Element topOfStack = elementStack.pop();
+ Element parent = elementStack.peek();
+
+ while (iterator.hasNext()) {
+ Element newElement = updateNameAndNamespace(ydtContext, parent);
+ newElement.setText(iterator.next());
+ }
+ elementStack.push(topOfStack);
+ }
+}
diff --git a/apps/yms/app/src/main/java/org/onosproject/yms/app/ych/defaultcodecs/xml/XmlCodecSingleInstanceHandler.java b/apps/yms/app/src/main/java/org/onosproject/yms/app/ych/defaultcodecs/xml/XmlCodecSingleInstanceHandler.java
new file mode 100644
index 0000000..66f3483
--- /dev/null
+++ b/apps/yms/app/src/main/java/org/onosproject/yms/app/ych/defaultcodecs/xml/XmlCodecSingleInstanceHandler.java
@@ -0,0 +1,23 @@
+/*
+ * 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.defaultcodecs.xml;
+
+/**
+ * Represents a single instance node handler in YCH.
+ */
+public class XmlCodecSingleInstanceHandler extends XmlCodecHandler {
+}
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
new file mode 100644
index 0000000..f44f9b2
--- /dev/null
+++ b/apps/yms/app/src/main/java/org/onosproject/yms/app/ych/defaultcodecs/xml/XmlCodecSingleInstanceLeafHandler.java
@@ -0,0 +1,34 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.yms.app.ych.defaultcodecs.xml;
+
+import org.dom4j.Element;
+import org.onosproject.yms.ydt.YdtContext;
+
+import java.util.Stack;
+
+/**
+ * Represents a single instance leaf node handler in YCH.
+ */
+public class XmlCodecSingleInstanceLeafHandler extends XmlCodecHandler {
+
+ @Override
+ public void setXmlValue(YdtContext ydtContext,
+ Stack<Element> elementStack) {
+ elementStack.peek().setText(ydtContext.getValue());
+ }
+}
diff --git a/apps/yms/app/src/main/java/org/onosproject/yms/app/ych/defaultcodecs/xml/XmlCodecYdtListener.java b/apps/yms/app/src/main/java/org/onosproject/yms/app/ych/defaultcodecs/xml/XmlCodecYdtListener.java
new file mode 100644
index 0000000..98a8ccb
--- /dev/null
+++ b/apps/yms/app/src/main/java/org/onosproject/yms/app/ych/defaultcodecs/xml/XmlCodecYdtListener.java
@@ -0,0 +1,110 @@
+/*
+ * 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.defaultcodecs.xml;
+
+import org.dom4j.Element;
+import org.onosproject.yms.app.ych.defaultcodecs.CodecHandlerFactory;
+import org.onosproject.yms.app.ydt.YdtExtendedContext;
+import org.onosproject.yms.app.ydt.YdtExtendedListener;
+import org.onosproject.yms.ych.YangProtocolEncodingFormat;
+import org.onosproject.yms.ydt.YdtContext;
+
+import java.util.Objects;
+import java.util.Stack;
+
+import static org.onosproject.yms.ych.YangProtocolEncodingFormat.XML;
+
+/**
+ * Represents implementation of codec YANG data object listener.
+ */
+class XmlCodecYdtListener implements YdtExtendedListener {
+
+ /**
+ * Data format type requested from driver.
+ */
+ private YangProtocolEncodingFormat dataFormat;
+
+ /**
+ * Stack for element is maintained for hierarchical references, this is
+ * used during YDT walker and preparation of xml/json.
+ */
+ private final Stack<Element> elementStack = new Stack<>();
+
+ /**
+ * Root name received from driver.
+ */
+ private YdtExtendedContext rootYdtNode;
+
+ /**
+ * Creates a new codec listener.
+ *
+ * @param format protocol data format
+ * @param rootNode extended YDT root node
+ */
+ XmlCodecYdtListener(YangProtocolEncodingFormat format,
+ YdtExtendedContext rootNode) {
+ dataFormat = format;
+ rootYdtNode = rootNode;
+ }
+
+ /**
+ * Returns the stack for the element.
+ *
+ * @return the stack for the element
+ */
+ Stack<Element> getElementStack() {
+ return elementStack;
+ }
+
+ @Override
+ public void enterYdtNode(YdtExtendedContext ydtContext) {
+
+ if (!Objects.equals(rootYdtNode, ydtContext)) {
+
+ CodecHandlerFactory factory = CodecHandlerFactory.instance();
+ XmlCodecHandler handler =
+ factory.getCodecHandlerForContext(ydtContext, dataFormat);
+ try {
+ if (dataFormat == XML && handler != null) {
+ handler.processXmlContext(ydtContext, elementStack);
+ }
+ } catch (Exception e) {
+ // TODO
+ }
+
+ if (dataFormat == XML && handler != null) {
+ handler.setXmlValue(ydtContext, elementStack);
+ }
+ }
+ }
+
+ @Override
+ public void exitYdtNode(YdtExtendedContext ydtExtendedContext) {
+ if (!Objects.equals(rootYdtNode, ydtExtendedContext)) {
+ elementStack.pop();
+ }
+ }
+
+ @Override
+ public void enterYdtNode(YdtContext ydtContext) {
+ }
+
+ @Override
+ public void exitYdtNode(YdtContext ydtContext) {
+ }
+
+}
diff --git a/apps/yms/app/src/main/java/org/onosproject/yms/app/ych/defaultcodecs/xml/XmlListener.java b/apps/yms/app/src/main/java/org/onosproject/yms/app/ych/defaultcodecs/xml/XmlListener.java
new file mode 100644
index 0000000..8c1bc7f
--- /dev/null
+++ b/apps/yms/app/src/main/java/org/onosproject/yms/app/ych/defaultcodecs/xml/XmlListener.java
@@ -0,0 +1,50 @@
+/*
+ * 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.defaultcodecs.xml;
+
+import org.dom4j.Element;
+
+/**
+ * Abstraction of an entity which provide call back methods which are called
+ * by xml walker while walking the xml data tree. This interface needs to be
+ * implemented by protocol implementing listener's based call backs while
+ * xml walk.
+ */
+interface XmlListener {
+
+ /**
+ * Callback invoked during a node entry. All the related information
+ * about the node can be obtained from the element.
+ *
+ * @param element current xml node(element)
+ * @param nodeType xml node type
+ * @param rootElement root element
+ */
+ void enterXmlElement(Element element, XmlNodeType nodeType,
+ Element rootElement);
+
+ /**
+ * Callback invoked during a node exit. All the related information
+ * about the node can be obtained from the element.
+ *
+ * @param element current xml node(element)
+ * @param nodeType xml node type
+ * @param rootElement root element
+ */
+ void exitXmlElement(Element element, XmlNodeType nodeType,
+ Element rootElement);
+}
diff --git a/apps/yms/app/src/main/java/org/onosproject/yms/app/ych/defaultcodecs/xml/XmlNodeType.java b/apps/yms/app/src/main/java/org/onosproject/yms/app/ych/defaultcodecs/xml/XmlNodeType.java
new file mode 100644
index 0000000..786f1b5
--- /dev/null
+++ b/apps/yms/app/src/main/java/org/onosproject/yms/app/ych/defaultcodecs/xml/XmlNodeType.java
@@ -0,0 +1,32 @@
+/*
+ * 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.defaultcodecs.xml;
+
+/**
+ * Represents type of node in xml data tree.
+ */
+enum XmlNodeType {
+ /**
+ * An object node has at least one child node.
+ */
+ OBJECT_NODE,
+
+ /**
+ * A text node has no child node, and has a text value.
+ */
+ TEXT_NODE
+}
diff --git a/apps/yms/app/src/main/java/org/onosproject/yms/app/ych/defaultcodecs/xml/XmlWalker.java b/apps/yms/app/src/main/java/org/onosproject/yms/app/ych/defaultcodecs/xml/XmlWalker.java
new file mode 100644
index 0000000..9e48add
--- /dev/null
+++ b/apps/yms/app/src/main/java/org/onosproject/yms/app/ych/defaultcodecs/xml/XmlWalker.java
@@ -0,0 +1,37 @@
+/*
+ * 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.defaultcodecs.xml;
+
+import org.dom4j.Element;
+
+/**
+ * Abstraction of an entity which provides interfaces for xml walk.
+ * This interface serve as common tools for anyone who needs to parse the xml
+ * node with depth-first algorithm.
+ */
+interface XmlWalker {
+ /**
+ * Walks the xml data tree. Protocols implements xml listener service
+ * and walks xml tree with input as implemented object. xml walker provides
+ * call backs to implemented methods.
+ *
+ * @param listener xml listener implemented by the protocol
+ * @param walkElement root node(element) of the xml data tree
+ * @param rootElement logical root node(element) of the xml data tree
+ */
+ void walk(XmlListener listener, Element walkElement, Element rootElement);
+}
diff --git a/apps/yms/app/src/main/java/org/onosproject/yms/app/ych/defaultcodecs/xml/YangCompositeEncodingImpl.java b/apps/yms/app/src/main/java/org/onosproject/yms/app/ych/defaultcodecs/xml/YangCompositeEncodingImpl.java
new file mode 100644
index 0000000..0e8d669
--- /dev/null
+++ b/apps/yms/app/src/main/java/org/onosproject/yms/app/ych/defaultcodecs/xml/YangCompositeEncodingImpl.java
@@ -0,0 +1,72 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.yms.app.ych.defaultcodecs.xml;
+
+import org.onosproject.yms.ych.YangCompositeEncoding;
+import org.onosproject.yms.ych.YangResourceIdentifierType;
+
+/**
+ * Represents implementation of YangCompositeEncoding interfaces.
+ */
+class YangCompositeEncodingImpl implements YangCompositeEncoding {
+
+ /**
+ * Resource identifier for composite encoding.
+ */
+ private String resourceIdentifier;
+
+ /**
+ * Resource information for composite encoding.
+ */
+ private String resourceInformation;
+
+ /**
+ * Resource identifier type.
+ */
+ private YangResourceIdentifierType resourceIdentifierType;
+
+ @Override
+ public void setResourceIdentifier(String resourceId) {
+ resourceIdentifier = resourceId;
+ }
+
+ @Override
+ public void setResourceInformation(String resourceInfo) {
+ resourceInformation = resourceInfo;
+ }
+
+ @Override
+ public void setResourceIdentifierType(YangResourceIdentifierType idType) {
+ resourceIdentifierType = idType;
+ }
+
+ @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/main/java/org/onosproject/yms/app/ych/defaultcodecs/xml/package-info.java b/apps/yms/app/src/main/java/org/onosproject/yms/app/ych/defaultcodecs/xml/package-info.java
new file mode 100644
index 0000000..68e96e6
--- /dev/null
+++ b/apps/yms/app/src/main/java/org/onosproject/yms/app/ych/defaultcodecs/xml/package-info.java
@@ -0,0 +1,21 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * Provides implementation of default codec handler for xml related
+ * operation.
+ */
+package org.onosproject.yms.app.ych.defaultcodecs.xml;
diff --git a/apps/yms/app/src/main/java/org/onosproject/yms/app/ych/package-info.java b/apps/yms/app/src/main/java/org/onosproject/yms/app/ych/package-info.java
new file mode 100644
index 0000000..0cf839b
--- /dev/null
+++ b/apps/yms/app/src/main/java/org/onosproject/yms/app/ych/package-info.java
@@ -0,0 +1,22 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * Provides interfaces to YANG codec utility.
+ * YANG codec utility provides interfaces which can be used by the driver / provider to
+ * translate protocol specific data representation to YANG modeled objects.
+ */
+package org.onosproject.yms.app.ych;
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 ba0554b..4ccce37 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
@@ -26,6 +26,8 @@
import org.onosproject.core.CoreService;
import org.onosproject.core.IdGenerator;
import org.onosproject.yms.app.yab.YangApplicationBroker;
+import org.onosproject.yms.app.ych.DefaultYangCodecHandler;
+import org.onosproject.yms.app.ych.defaultcodecs.YangCodecRegistry;
import org.onosproject.yms.app.ydt.DefaultYdtWalker;
import org.onosproject.yms.app.ydt.YangRequestWorkBench;
import org.onosproject.yms.app.ynh.YangNotificationExtendedService;
@@ -84,6 +86,10 @@
Executors.newSingleThreadExecutor(groupedThreads(
"onos/apps/yang-management-system/schema-registry",
"schema-registry-handler", log));
+
+ //Initilize the default codecs
+ YangCodecRegistry.initializeDefaultCodec();
+
log.info("Started");
}
@@ -174,9 +180,8 @@
}
@Override
- public void registerDefaultCodec(YangDataTreeCodec defaultCodec,
- YangProtocolEncodingFormat dataFormat) {
-
+ public void registerDefaultCodec(YangDataTreeCodec defaultCodec, YangProtocolEncodingFormat dataFormat) {
+ YangCodecRegistry.registerDefaultCodec(defaultCodec, dataFormat);
}
@Override
@@ -196,7 +201,11 @@
@Override
public YangCodecHandler getYangCodecHandler() {
- return null;
+
+ YangSchemaRegistry yangSchemaRegistry =
+ new DefaultYangSchemaRegistry(
+ String.valueOf(moduleIdGenerator.getNewId()));
+ return new DefaultYangCodecHandler(yangSchemaRegistry);
}
/**
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
new file mode 100644
index 0000000..dcce22a
--- /dev/null
+++ b/apps/yms/app/src/test/java/org/onosproject/yms/app/ych/DefaultYangCodecHandlerTest.java
@@ -0,0 +1,1422 @@
+/*
+ * 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/ymsm/MockCoreService.java b/apps/yms/app/src/test/java/org/onosproject/yms/app/ymsm/MockCoreService.java
new file mode 100644
index 0000000..62f00aa
--- /dev/null
+++ b/apps/yms/app/src/test/java/org/onosproject/yms/app/ymsm/MockCoreService.java
@@ -0,0 +1,73 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.yms.app.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
new file mode 100644
index 0000000..73fddbf
--- /dev/null
+++ b/apps/yms/app/src/test/java/org/onosproject/yms/app/ymsm/MockOverriddenDataTreeCodec.java
@@ -0,0 +1,68 @@
+/*
+ * 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
new file mode 100644
index 0000000..84117e7
--- /dev/null
+++ b/apps/yms/app/src/test/java/org/onosproject/yms/app/ymsm/MockRegisteredDataTreeCodec.java
@@ -0,0 +1,67 @@
+/*
+ * 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
new file mode 100644
index 0000000..1f52da6
--- /dev/null
+++ b/apps/yms/app/src/test/java/org/onosproject/yms/app/ymsm/MockYangCompositeEncoding.java
@@ -0,0 +1,82 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.yms.app.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
new file mode 100644
index 0000000..794298e
--- /dev/null
+++ b/apps/yms/app/src/test/java/org/onosproject/yms/app/ymsm/YchCompositeHandlerTest.java
@@ -0,0 +1,288 @@
+/*
+ * 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/resources/ychTestResourceFiles/Combined.yang b/apps/yms/app/src/test/resources/ychTestResourceFiles/Combined.yang
new file mode 100644
index 0000000..a9c2f48
--- /dev/null
+++ b/apps/yms/app/src/test/resources/ychTestResourceFiles/Combined.yang
@@ -0,0 +1,114 @@
+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
new file mode 100644
index 0000000..92106e9
--- /dev/null
+++ b/apps/yms/app/src/test/resources/ychTestResourceFiles/EmptyContainer.yang
@@ -0,0 +1,19 @@
+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
new file mode 100644
index 0000000..1997f3d
--- /dev/null
+++ b/apps/yms/app/src/test/resources/ychTestResourceFiles/combinedrootname.xml
@@ -0,0 +1,98 @@
+<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
new file mode 100644
index 0000000..c8509f1
--- /dev/null
+++ b/apps/yms/app/src/test/resources/ychTestResourceFiles/configrootname.xml
@@ -0,0 +1,20 @@
+<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
new file mode 100644
index 0000000..6cecea49
--- /dev/null
+++ b/apps/yms/app/src/test/resources/ychTestResourceFiles/configrootnameOperationType.xml
@@ -0,0 +1,20 @@
+<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
new file mode 100644
index 0000000..b6d11fe
--- /dev/null
+++ b/apps/yms/app/src/test/resources/ychTestResourceFiles/getReply.xml
@@ -0,0 +1,11 @@
+<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
new file mode 100644
index 0000000..e27beab
--- /dev/null
+++ b/apps/yms/app/src/test/resources/ychTestResourceFiles/getconfigReply.xml
@@ -0,0 +1,8 @@
+<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
new file mode 100644
index 0000000..adc7902
--- /dev/null
+++ b/apps/yms/app/src/test/resources/ychTestResourceFiles/getconfigemptycontainer.xml
@@ -0,0 +1,11 @@
+<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
new file mode 100644
index 0000000..df69691
--- /dev/null
+++ b/apps/yms/app/src/test/resources/ychTestResourceFiles/getconfigrootname.xml
@@ -0,0 +1,13 @@
+<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
new file mode 100644
index 0000000..9773893
--- /dev/null
+++ b/apps/yms/app/src/test/resources/ychTestResourceFiles/getrootname.xml
@@ -0,0 +1,12 @@
+<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
new file mode 100644
index 0000000..507c64e
--- /dev/null
+++ b/apps/yms/app/src/test/resources/ychTestResourceFiles/purchasingsupervisor.yang
@@ -0,0 +1,28 @@
+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