aboutsummaryrefslogtreecommitdiffstats
path: root/restconf-client
diff options
context:
space:
mode:
authorjanani b <janani.b@huawei.com>2019-04-05 18:23:44 +0530
committerjanani b <janani.b@huawei.com>2019-04-05 18:23:44 +0530
commit614bd0b6897b1ece3ee7deb581089c301bb3f2e8 (patch)
tree5c9c469e44c9e339634665eddf507ffeb6741020 /restconf-client
parentf360b7b2bc9ed8d321dade9cadafe2ebda4f46ab (diff)
Replacing ":" by "_" for parameters
Supporting "_" to be present for module name seperator while giving parameters in DG node. Issue-ID: CCSDK-1045 Change-Id: I008fa8503f1314e593f96393121a02f429bac636 Signed-off-by: janani b <janani.b@huawei.com>
Diffstat (limited to 'restconf-client')
-rw-r--r--restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/restconfapicall/RestconfApiCallNode.java25
-rw-r--r--restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/restconfapicall/RestconfApiUtils.java22
-rw-r--r--restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/DefaultPropertiesNodeListener.java11
-rw-r--r--restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/MdsalPropertiesNodeSerializer.java41
-rw-r--r--restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/MdsalPropertiesNodeUtils.java243
-rw-r--r--restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/SchemaPathHolder.java77
-rw-r--r--restconf-client/provider/src/test/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/DataFormatSerializerTest.java98
-rw-r--r--restconf-client/provider/src/test/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/DataFormatUtilsTest.java22
-rw-r--r--restconf-client/provider/src/test/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/IdentifierValidationTest.java762
-rw-r--r--restconf-client/provider/src/test/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/IdentifierValidationUtilsTest.java469
-rw-r--r--restconf-client/provider/src/test/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/PropertiesSerializerTest.java224
-rw-r--r--restconf-client/provider/src/test/resources/yang/test_augment_1_for_module.yang108
-rw-r--r--restconf-client/provider/src/test/resources/yang/test_name_of_the_module.yang231
13 files changed, 2107 insertions, 226 deletions
diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/restconfapicall/RestconfApiCallNode.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/restconfapicall/RestconfApiCallNode.java
index a76b27d0..3007b5a1 100644
--- a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/restconfapicall/RestconfApiCallNode.java
+++ b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/restconfapicall/RestconfApiCallNode.java
@@ -25,6 +25,18 @@ import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import com.google.gson.stream.JsonWriter;
+
+import javax.ws.rs.core.UriBuilder;
+import java.io.StringWriter;
+import java.io.Writer;
+import java.net.SocketException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
import org.dom4j.Document;
import org.dom4j.DocumentException;
import org.dom4j.DocumentHelper;
@@ -54,17 +66,6 @@ import org.osgi.framework.ServiceReference;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import javax.ws.rs.core.UriBuilder;
-import java.io.StringWriter;
-import java.io.Writer;
-import java.net.SocketException;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
import static com.google.common.base.Strings.repeat;
import static java.lang.String.format;
import static java.lang.String.valueOf;
@@ -91,8 +92,8 @@ import static org.onap.ccsdk.sli.plugins.restconfapicall.RestconfApiUtils.RES_PR
import static org.onap.ccsdk.sli.plugins.restconfapicall.RestconfApiUtils.RETRY_COUNT;
import static org.onap.ccsdk.sli.plugins.restconfapicall.RestconfApiUtils.RETRY_FAIL;
import static org.onap.ccsdk.sli.plugins.restconfapicall.RestconfApiUtils.UPDATED_URL;
-import static org.onap.ccsdk.sli.plugins.restconfapicall.RestconfApiUtils.getUpdatedXmlReq;
import static org.onap.ccsdk.sli.plugins.restconfapicall.RestconfApiUtils.getSchemaCtxFromDir;
+import static org.onap.ccsdk.sli.plugins.restconfapicall.RestconfApiUtils.getUpdatedXmlReq;
import static org.onap.ccsdk.sli.plugins.restconfapicall.RestconfApiUtils.getYangParameters;
import static org.onap.ccsdk.sli.plugins.restconfapicall.RestconfApiUtils.parseUrl;
import static org.onap.ccsdk.sli.plugins.yangserializers.dfserializer.DfListenerFactory.instance;
diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/restconfapicall/RestconfApiUtils.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/restconfapicall/RestconfApiUtils.java
index c5c7a919..505089c4 100644
--- a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/restconfapicall/RestconfApiUtils.java
+++ b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/restconfapicall/RestconfApiUtils.java
@@ -22,15 +22,6 @@
package org.onap.ccsdk.sli.plugins.restconfapicall;
-import org.onap.ccsdk.sli.core.sli.SvcLogicException;
-import org.onap.ccsdk.sli.plugins.restapicall.HttpMethod;
-import org.onap.ccsdk.sli.plugins.yangserializers.dfserializer.YangParameters;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-import org.opendaylight.yangtools.yang.model.parser.api.YangSyntaxErrorException;
-import org.opendaylight.yangtools.yang.parser.rfc7950.repo.YangStatementStreamSource;
-import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
-import org.opendaylight.yangtools.yang.parser.stmt.reactor.CrossSourceStatementReactor;
-
import java.io.File;
import java.io.IOException;
import java.net.URI;
@@ -43,6 +34,15 @@ import java.util.LinkedList;
import java.util.List;
import java.util.Map;
+import org.onap.ccsdk.sli.core.sli.SvcLogicException;
+import org.onap.ccsdk.sli.plugins.restapicall.HttpMethod;
+import org.onap.ccsdk.sli.plugins.yangserializers.dfserializer.YangParameters;
+import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+import org.opendaylight.yangtools.yang.model.parser.api.YangSyntaxErrorException;
+import org.opendaylight.yangtools.yang.parser.rfc7950.repo.YangStatementStreamSource;
+import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
+import org.opendaylight.yangtools.yang.parser.stmt.reactor.CrossSourceStatementReactor;
+
import static org.onap.ccsdk.sli.plugins.restapicall.RestapiCallNode.getParameters;
import static org.onap.ccsdk.sli.plugins.restapicall.RestapiCallNode.parseParam;
import static org.opendaylight.yangtools.yang.model.repo.api.StatementParserMode.DEFAULT_MODE;
@@ -156,6 +156,7 @@ public final class RestconfApiUtils {
*/
private static String getParsedPath(String path) {
String firstHalf;
+ String secondHalf;
if (path.contains(COLON)) {
String[] p = path.split(COLON);
if (p[0].contains(SLASH)) {
@@ -164,7 +165,8 @@ public final class RestconfApiUtils {
} else {
firstHalf = p[0];
}
- return firstHalf + COLON + p[1];
+ secondHalf = path.substring(p[0].length() + 1);
+ return firstHalf + COLON + secondHalf;
}
return path;
}
diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/DefaultPropertiesNodeListener.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/DefaultPropertiesNodeListener.java
index 491dcb09..2fa00bfb 100644
--- a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/DefaultPropertiesNodeListener.java
+++ b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/DefaultPropertiesNodeListener.java
@@ -20,12 +20,14 @@
package org.onap.ccsdk.sli.plugins.yangserializers.pnserializer;
-import org.onap.ccsdk.sli.core.sli.SvcLogicException;
-
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
+import org.onap.ccsdk.sli.core.sli.SvcLogicException;
+
+import static org.onap.ccsdk.sli.plugins.yangserializers.pnserializer.MdsalPropertiesNodeUtils.COLON;
+import static org.onap.ccsdk.sli.plugins.yangserializers.pnserializer.MdsalPropertiesNodeUtils.UNDERSCORE;
import static org.onap.ccsdk.sli.plugins.yangserializers.pnserializer.NodeType.MULTI_INSTANCE_LEAF_NODE;
import static org.onap.ccsdk.sli.plugins.yangserializers.pnserializer.NodeType.SINGLE_INSTANCE_LEAF_NODE;
@@ -56,9 +58,10 @@ public class DefaultPropertiesNodeListener implements PropertiesNodeListener {
|| node.nodeType() == MULTI_INSTANCE_LEAF_NODE) {
String val = ((LeafNode) node).value();
if (((LeafNode) node).valueNs() != null) {
- val = ((LeafNode) node).valueNs().moduleName() + ":" + val;
+ val = ((LeafNode) node).valueNs().moduleName() + COLON + val;
}
- params.put(node.uri(), val);
+ String uri = node.uri().replaceAll(COLON, UNDERSCORE);
+ params.put(uri, val);
}
}
diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/MdsalPropertiesNodeSerializer.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/MdsalPropertiesNodeSerializer.java
index 13a5c5a0..759fe802 100644
--- a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/MdsalPropertiesNodeSerializer.java
+++ b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/MdsalPropertiesNodeSerializer.java
@@ -20,20 +20,25 @@
package org.onap.ccsdk.sli.plugins.yangserializers.pnserializer;
+import java.util.HashMap;
+import java.util.Map;
+
import org.onap.ccsdk.sli.core.sli.SvcLogicException;
+import org.opendaylight.restconf.common.errors.RestconfDocumentedException;
import org.opendaylight.yangtools.yang.model.api.Module;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
import org.opendaylight.yangtools.yang.model.api.SchemaNode;
import org.opendaylight.yangtools.yang.model.util.SchemaContextUtil;
-import java.util.Map;
-
+import static org.onap.ccsdk.sli.plugins.yangserializers.pnserializer.MdsalPropertiesNodeUtils.DOT_REGEX;
+import static org.onap.ccsdk.sli.plugins.yangserializers.pnserializer.MdsalPropertiesNodeUtils.SLASH;
import static org.onap.ccsdk.sli.plugins.yangserializers.pnserializer.MdsalPropertiesNodeUtils.getChildSchemaNode;
import static org.onap.ccsdk.sli.plugins.yangserializers.pnserializer.MdsalPropertiesNodeUtils.getIndex;
import static org.onap.ccsdk.sli.plugins.yangserializers.pnserializer.MdsalPropertiesNodeUtils.getListName;
import static org.onap.ccsdk.sli.plugins.yangserializers.pnserializer.MdsalPropertiesNodeUtils.getNamespace;
import static org.onap.ccsdk.sli.plugins.yangserializers.pnserializer.MdsalPropertiesNodeUtils.getNodeType;
import static org.onap.ccsdk.sli.plugins.yangserializers.pnserializer.MdsalPropertiesNodeUtils.getParsedValue;
+import static org.onap.ccsdk.sli.plugins.yangserializers.pnserializer.MdsalPropertiesNodeUtils.getProcessedPath;
import static org.onap.ccsdk.sli.plugins.yangserializers.pnserializer.MdsalPropertiesNodeUtils.getRevision;
import static org.onap.ccsdk.sli.plugins.yangserializers.pnserializer.MdsalPropertiesNodeUtils.getValueNamespace;
import static org.onap.ccsdk.sli.plugins.yangserializers.pnserializer.MdsalPropertiesNodeUtils.resolveName;
@@ -70,6 +75,8 @@ public class MdsalPropertiesNodeSerializer extends PropertiesNodeSerializer<Sche
String rootUri = uri().replaceAll("\\/", "\\.");
node = createRootNode(lastNodeName, rootUri);
+ paramMap = convertToValidParam(paramMap);
+
for (Map.Entry<String, String> entry : paramMap.entrySet()) {
String[] names = entry.getKey().split("\\.");
for (int i = 0; i < names.length; i++) {
@@ -86,6 +93,30 @@ public class MdsalPropertiesNodeSerializer extends PropertiesNodeSerializer<Sche
return node;
}
+ /**
+ * Converts all the params in the svc logic context into a valid param by
+ * replacing the underscore in module name to colon at necessary places.
+ *
+ * @param paramMap list of invalid parameters
+ * @return list of partially valid parameters
+ */
+ private Map<String, String> convertToValidParam(Map<String, String> paramMap) {
+ Map<String, String> fixedParams = new HashMap<>();
+ for(Map.Entry<String, String> entry : paramMap.entrySet()) {
+ String key = entry.getKey().replaceAll(DOT_REGEX, SLASH);
+ try {
+ SchemaPathHolder fixedUrl = getProcessedPath(key, schemaCtx());
+ String fixedUri = fixedUrl.getUri().replaceAll(
+ SLASH, DOT_REGEX);
+ fixedParams.put(fixedUri, entry.getValue());
+ } catch (IllegalArgumentException | RestconfDocumentedException
+ | NullPointerException e) {
+ fixedParams.put(entry.getKey(), entry.getValue());
+ }
+ }
+ return fixedParams;
+ }
+
@Override
public Map<String, String> decode(PropertiesNode propertiesNode)
throws SvcLogicException {
@@ -104,8 +135,10 @@ public class MdsalPropertiesNodeSerializer extends PropertiesNodeSerializer<Sche
private void createPropertyNode(int index, int length, String name,
String value) throws SvcLogicException {
- String localName = resolveName(name);
- Namespace ns = getNamespace(getListName(name), schemaCtx(), node);
+
+ Namespace ns = getNamespace(getListName(name), schemaCtx(),
+ node, curSchema);
+ String localName = resolveName(ns, name);
SchemaNode schema = getChildSchemaNode(curSchema, localName, ns);
if (schema == null) {
return;
diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/MdsalPropertiesNodeUtils.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/MdsalPropertiesNodeUtils.java
index ccc4f2bd..d0b34f9b 100644
--- a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/MdsalPropertiesNodeUtils.java
+++ b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/MdsalPropertiesNodeUtils.java
@@ -20,7 +20,14 @@
package org.onap.ccsdk.sli.plugins.yangserializers.pnserializer;
+import java.util.Collection;
+import java.util.Deque;
+import java.util.Iterator;
+import java.util.Optional;
+
import org.onap.ccsdk.sli.core.sli.SvcLogicException;
+import org.opendaylight.restconf.common.context.InstanceIdentifierContext;
+import org.opendaylight.restconf.common.errors.RestconfDocumentedException;
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.common.Revision;
import org.opendaylight.yangtools.yang.data.impl.schema.SchemaUtils;
@@ -33,19 +40,38 @@ import org.opendaylight.yangtools.yang.model.api.IdentitySchemaNode;
import org.opendaylight.yangtools.yang.model.api.Module;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
import org.opendaylight.yangtools.yang.model.api.SchemaNode;
-
-import java.util.Collection;
-import java.util.Deque;
-import java.util.Iterator;
-import java.util.Optional;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import static com.google.common.base.Preconditions.checkArgument;
+import static java.lang.String.format;
+import static java.util.regex.Pattern.quote;
+import static org.opendaylight.restconf.nb.rfc8040.utils.parser.ParserIdentifier.toInstanceIdentifier;
/**
* Represents utilities for properties node tree.
*/
public final class MdsalPropertiesNodeUtils {
+ static final String COLON = ":";
+
+ static final String UNDERSCORE = "_";
+
+ static final String SLASH = "/";
+
+ static final String DOT_REGEX = "\\.";
+
+ private static final String INFO_MSG = "The %s formed is currently not" +
+ " valid";
+
+ private static final String EXC_MSG = "Unable to form a formatted path";
+
+ /**
+ * Logger for the Mdsal properties util class.
+ */
+ private static final Logger log = LoggerFactory.getLogger(
+ MdsalPropertiesNodeUtils.class);
+
private MdsalPropertiesNodeUtils() {
}
@@ -89,7 +115,7 @@ public final class MdsalPropertiesNodeUtils {
* @param name name of the property
* @return name of the property
*/
- public static String resolveName(String name) {
+ static String resolveName(String name) {
String localName = getListName(name);
final int lastIndexOfColon = localName.lastIndexOf(":");
if (lastIndexOfColon != -1) {
@@ -99,6 +125,24 @@ public final class MdsalPropertiesNodeUtils {
}
/**
+ * Returns name of the property after pruning namespace and index if the
+ * property is multi instance by knowing the module name from namespace.
+ *
+ * @param ns namespace
+ * @param name name of the node
+ * @return resolved name
+ */
+ static String resolveName(Namespace ns, String name) {
+ String localName = getListName(name);
+ String modName = ns.moduleName();
+ if ((localName.contains(COLON) || localName.contains(UNDERSCORE))
+ && localName.startsWith(modName)) {
+ localName = localName.substring(modName.length()+1);
+ }
+ return localName;
+ }
+
+ /**
* Adds current node to parent's augmentation map.
*
* @param augSchema augment schema
@@ -203,31 +247,182 @@ public final class MdsalPropertiesNodeUtils {
}
/**
- * Returns namespace.
+ * Returns the schema path holder with a formatted url and the instance
+ * identifier context from a given uri or the parameters from svc logic
+ * context.
*
- * @param childName name of the property
- * @param ctx schema context
- * @param parent parent property node
- * @return namespace
+ * @param uri unformatted uri or parameter
+ * @param context schema context
+ * @return schema path holder
+ */
+ public static SchemaPathHolder getProcessedPath(String uri,
+ SchemaContext context) {
+
+ String uri1 = uri.replaceAll(UNDERSCORE, COLON);
+ try {
+ InstanceIdentifierContext<?> id = toInstanceIdentifier(
+ uri1, context, null);
+ return new SchemaPathHolder(id, uri1);
+ } catch (IllegalArgumentException | RestconfDocumentedException
+ | NullPointerException e) {
+ return processNodesAndAppendPath(uri, context);
+ }
+ }
+
+ /**
+ * Processes the nodes in the given uri and finds instance identifier
+ * context till it reaches the last node in uri. If its not able to find
+ * schema for the path, it appends the suffix part and puts it back in
+ * the param list.
+ *
+ * @param uri uri with underscore
+ * @param context schema context
+ * @return schema and path holder
+ */
+ private static SchemaPathHolder processNodesAndAppendPath(String uri,
+ SchemaContext context) {
+
+ String actPath = "";
+ SchemaPathHolder id = new SchemaPathHolder(null, "");
+ String[] uriParts = uri.split(SLASH);
+ String sec = "";
+ if (uri.contains(UNDERSCORE)) {
+ sec = uri.substring(uriParts[0].length()+1);
+ }
+ for (int i = 0; i<uriParts.length; i++) {
+
+ try {
+ id = processIdentifier(uriParts[i], context, actPath);
+ } catch (IllegalArgumentException e) {
+ id.setUri(actPath+ uriParts[i] + sec);
+ return id;
+ }
+
+ actPath = actPath + id.getUri() + SLASH;
+ if (sec.startsWith(SLASH)) {
+ sec = sec.replaceFirst(SLASH, "");
+ }
+ if (i+1 < uriParts.length) {
+ sec = sec.replaceFirst(quote(uriParts[i + 1]), "");
+ }
+ }
+ id.setUri(actPath.substring(0,actPath.length() - 1));
+ return id;
+ }
+
+ /**
+ * Processes the schema and path holder for a given node in the path. It
+ * figures if the path is valid by replacing underscore in the node
+ * consecutively, till it finds the proper schema for the node.
+ *
+ * @param node node in the path
+ * @param context schema context
+ * @param prefix prefix for the node in the path
+ * @return schema and path holder
*/
- public static Namespace getNamespace(String childName,
- SchemaContext ctx,
- PropertiesNode parent) {
- int lastIndexOfColon = childName.lastIndexOf(":");
+ private static SchemaPathHolder processIdentifier(String node,
+ SchemaContext context,
+ String prefix) {
+
+ String[] values = node.split(UNDERSCORE);
+ String val = values[0];
+ StringBuilder firstHalf = new StringBuilder();
+ String secondHalf = "";
+ if (node.contains(UNDERSCORE)) {
+ secondHalf = node.substring(values[0].length()+1);
+ }
+ InstanceIdentifierContext<?> id;
+ for (int i = 0; i< values.length-1; i++) {
+ val = values[i];
+ val = firstHalf + val + COLON + secondHalf;
+ try {
+ id = toInstanceIdentifier(prefix + val, context, null);
+ return new SchemaPathHolder(id, val);
+ } catch (IllegalArgumentException | RestconfDocumentedException |
+ NullPointerException e) {
+ log.info(format(INFO_MSG, val));
+ }
+ firstHalf.append(values[i]).append(UNDERSCORE);
+ secondHalf = secondHalf.replaceFirst(
+ values[i + 1] + UNDERSCORE,"");
+ }
+ val = val.replace(COLON,UNDERSCORE);
+ try {
+ id = toInstanceIdentifier(prefix + val, context, null);
+ return new SchemaPathHolder(id, val);
+ } catch (IllegalArgumentException | RestconfDocumentedException |
+ NullPointerException e1) {
+ throw new IllegalArgumentException(EXC_MSG, e1);
+ }
+ }
+
+ /**
+ * Returns the namespace of the given node name. If the node name is
+ * separated by colon, the it splits with colon and forms the namespace.
+ * If the node name is formed with underscore, then it splits the node
+ * name consecutively to figure out the proper module name.
+ *
+ * @param childName node name
+ * @param ctx schema context
+ * @param parent parent properties node
+ * @param curSchema current schema
+ * @return namespace of the given node
+ */
+ static Namespace getNamespace(String childName, SchemaContext ctx,
+ PropertiesNode parent, SchemaNode curSchema) {
+
+ Namespace parentNs = parent.namespace();
+ Namespace ns = new Namespace(parentNs.moduleName(),
+ parentNs.moduleNs(), parentNs.revision());
+ int lastIndexOfColon = childName.lastIndexOf(COLON);
if (lastIndexOfColon != -1) {
String moduleName = childName.substring(0, lastIndexOfColon);
- Iterator<Module> it = ctx.findModules(moduleName).iterator();
- if (!it.hasNext()) {
- // module is not present in context
- return null;
+ childName = childName.substring(lastIndexOfColon+1);
+ Namespace ns1 = getNs(moduleName, ctx);
+ if (ns1 != null) {
+ ns = ns1;
}
+ }
+
+ SchemaNode child = getChildSchemaNode(curSchema, childName, ns);
+
+ if (child == null && childName.contains(UNDERSCORE)) {
+ String[] children = childName.split(UNDERSCORE);
+ String second = childName.substring(children[0].length() + 1);
+ StringBuilder first = new StringBuilder();
+
+ for (int i =0; i< children.length; i++) {
+ String moduleName = first + children[i];
+ Namespace newNs = getNs(moduleName, ctx);
+ if (newNs != null) {
+ return newNs;
+ }
+ first.append(children[i]).append(UNDERSCORE);
+ if (i + 1 < children.length) {
+ second = second.replaceFirst(
+ children[i + 1] + UNDERSCORE, "");
+ }
+ }
+ return ns;
+ }
+ return ns;
+ }
+
+ /**
+ * Returns the namespace by finding the given module in the schema context.
+ *
+ * @param modName module name
+ * @param ctx schema context
+ * @return namespace of the given node name
+ */
+ private static Namespace getNs(String modName, SchemaContext ctx) {
+ Iterator<Module> it = ctx.findModules(modName).iterator();
+ if (it.hasNext()) {
Module m = it.next();
- return new Namespace(moduleName, m.getQNameModule().getNamespace(),
+ return new Namespace(modName, m.getQNameModule().getNamespace(),
getRevision(m.getRevision()));
}
- Namespace parentNs = parent.namespace();
- return new Namespace(parentNs.moduleName(), parentNs.moduleNs(),
- parentNs.revision());
+ return null;
}
/**
@@ -239,7 +434,7 @@ public final class MdsalPropertiesNodeUtils {
* @return child schema node
*/
public static SchemaNode getChildSchemaNode(SchemaNode curSchema,
- String name,
+ String name,
Namespace namespace) {
if (namespace == null) {
return null;
diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/SchemaPathHolder.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/SchemaPathHolder.java
new file mode 100644
index 00000000..4ef1bc66
--- /dev/null
+++ b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/SchemaPathHolder.java
@@ -0,0 +1,77 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - CCSDK
+ * ================================================================================
+ * Copyright (C) 2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * ================================================================================
+ * 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.ccsdk.sli.plugins.yangserializers.pnserializer;
+
+import org.opendaylight.restconf.common.context.InstanceIdentifierContext;
+
+/**
+ * Representation of a holder for a proper path and its corresponding schema.
+ */
+public class SchemaPathHolder {
+
+ /**
+ * Schema context for the path.
+ */
+ private InstanceIdentifierContext insId;
+
+ /**
+ * Formatted path.
+ */
+ private String uri;
+
+ /**
+ * Constructs schema path holder with path and its schema.
+ *
+ * @param insId instance identifier context
+ * @param uri path
+ */
+ public SchemaPathHolder(InstanceIdentifierContext insId, String uri) {
+ this.insId = insId;
+ this.uri = uri;
+ }
+
+ /**
+ * Returns the instance identifier context of the path.
+ *
+ * @return schema of the path
+ */
+ public InstanceIdentifierContext getInsId() {
+ return insId;
+ }
+
+ /**
+ * Returns the formatted path.
+ *
+ * @return formatted path
+ */
+ public String getUri() {
+ return uri;
+ }
+
+ /**
+ * Sets the formatted path.
+ *
+ * @param uri formatted path
+ */
+ public void setUri(String uri) {
+ this.uri = uri;
+ }
+}
diff --git a/restconf-client/provider/src/test/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/DataFormatSerializerTest.java b/restconf-client/provider/src/test/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/DataFormatSerializerTest.java
index 08fa33ee..45e8eb3f 100644
--- a/restconf-client/provider/src/test/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/DataFormatSerializerTest.java
+++ b/restconf-client/provider/src/test/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/DataFormatSerializerTest.java
@@ -20,6 +20,9 @@
package org.onap.ccsdk.sli.plugins.yangserializers.dfserializer;
+import java.util.HashMap;
+import java.util.Map;
+
import org.junit.Before;
import org.junit.Test;
import org.mockito.invocation.InvocationOnMock;
@@ -31,9 +34,6 @@ import org.onap.ccsdk.sli.plugins.restapicall.RestapiCallNode;
import org.onap.ccsdk.sli.plugins.restconfapicall.RestconfApiCallNode;
import org.opendaylight.restconf.common.context.InstanceIdentifierContext;
-import java.util.HashMap;
-import java.util.Map;
-
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.core.Is.is;
import static org.mockito.Matchers.any;
@@ -136,7 +136,7 @@ public class DataFormatSerializerTest {
*/
@Test
public void encodeToJsonId() throws SvcLogicException {
- String pre = "identity-test:test.";
+ String pre = "identity-test_test.";
SvcLogicContext ctx = createAttList(pre);
ctx.setAttribute(pre + "l", "abc");
p.put("dirPath", "src/test/resources");
@@ -156,7 +156,7 @@ public class DataFormatSerializerTest {
*/
@Test
public void encodeToJsonIdWithPut() throws SvcLogicException {
- String pre = "identity-test:test.";
+ String pre = "identity-test_test.";
SvcLogicContext ctx = createAttList(pre);
ctx.setAttribute(pre + "l", "abc");
p.put("dirPath", "src/test/resources");
@@ -176,7 +176,7 @@ public class DataFormatSerializerTest {
*/
@Test
public void encodeToJsonIdWithPatch() throws SvcLogicException {
- String pre = "identity-test:test.";
+ String pre = "identity-test_test.";
SvcLogicContext ctx = createAttList(pre);
ctx.setAttribute(pre + "l", "abc");
p.put("dirPath", "src/test/resources");
@@ -196,7 +196,7 @@ public class DataFormatSerializerTest {
*/
@Test
public void encodeToXmlId() throws SvcLogicException {
- String pre = "identity-test:test.";
+ String pre = "identity-test_test.";
SvcLogicContext ctx = createAttList(pre);
p.put("dirPath", "src/test/resources");
p.put("format", "xml");
@@ -215,7 +215,7 @@ public class DataFormatSerializerTest {
*/
@Test
public void encodeToXmlIdWithPut() throws SvcLogicException {
- String pre = "identity-test:test.";
+ String pre = "identity-test_test.";
SvcLogicContext ctx = createAttList(pre);
p.put("dirPath", "src/test/resources");
p.put("format", "xml");
@@ -234,7 +234,7 @@ public class DataFormatSerializerTest {
*/
@Test
public void encodeToXmlIdWithPatch() throws SvcLogicException {
- String pre = "identity-test:test.";
+ String pre = "identity-test_test.";
SvcLogicContext ctx = createAttList(pre);
p.put("dirPath", "src/test/resources");
p.put("format", "xml");
@@ -255,7 +255,7 @@ public class DataFormatSerializerTest {
public void decodeToJsonId() throws SvcLogicException {
createMockForDecode(ENCODE_TO_JSON_ID);
SvcLogicContext ctx = new SvcLogicContext();
- String pre = "identity-test:test.";
+ String pre = "identity-test_test.";
p.put("dirPath", "src/test/resources");
p.put("format", "json");
p.put("httpMethod", "get");
@@ -276,7 +276,7 @@ public class DataFormatSerializerTest {
public void decodeToXmlId() throws SvcLogicException {
createMockForDecode(ENCODE_TO_XML_ID);
SvcLogicContext ctx = new SvcLogicContext();
- String pre = "identity-test:test.";
+ String pre = "identity-test_test.";
p.put("dirPath", "src/test/resources");
p.put("format", "xml");
p.put("httpMethod", "get");
@@ -294,7 +294,7 @@ public class DataFormatSerializerTest {
*/
@Test
public void encodeToJsonYang() throws SvcLogicException {
- String pre = "test-yang:cont1.cont2.";
+ String pre = "test-yang_cont1.cont2.";
SvcLogicContext ctx = createAttListYang(pre);
p.put("dirPath", "src/test/resources");
p.put("format", "json");
@@ -313,7 +313,7 @@ public class DataFormatSerializerTest {
*/
@Test
public void encodeToJsonYangWithPut() throws SvcLogicException {
- String pre = "test-yang:cont1.cont2.";
+ String pre = "test-yang_cont1.cont2.";
SvcLogicContext ctx = createAttListYang(pre);
p.put("dirPath", "src/test/resources");
p.put("format", "json");
@@ -332,7 +332,7 @@ public class DataFormatSerializerTest {
*/
@Test
public void encodeToJsonYangWithPatch() throws SvcLogicException {
- String pre = "test-yang:cont1.cont2.";
+ String pre = "test-yang_cont1.cont2.";
SvcLogicContext ctx = createAttListYang(pre);
p.put("dirPath", "src/test/resources");
p.put("format", "json");
@@ -351,7 +351,7 @@ public class DataFormatSerializerTest {
*/
@Test
public void encodeToJsonWithAugAsRootChild() throws SvcLogicException {
- String pre = "test-yang:cont1.cont2.";
+ String pre = "test-yang_cont1.cont2.";
SvcLogicContext ctx = createAttListYang(pre);
p.put("dirPath", "src/test/resources");
p.put("format", "json");
@@ -372,7 +372,7 @@ public class DataFormatSerializerTest {
public void decodeToJsonYang() throws SvcLogicException {
createMockForDecode(ENCODE_TO_JSON_YANG);
SvcLogicContext ctx = new SvcLogicContext();
- String pre = "test-yang:cont1.cont2.";
+ String pre = "test-yang_cont1.cont2.";
p.put("dirPath", "src/test/resources");
p.put("format", "json");
p.put("httpMethod", "get");
@@ -390,7 +390,7 @@ public class DataFormatSerializerTest {
*/
@Test
public void encodeToXmlYang() throws SvcLogicException {
- String pre = "test-yang:cont1.cont2.";
+ String pre = "test-yang_cont1.cont2.";
SvcLogicContext ctx = createAttListYang(pre);
p.put("dirPath", "src/test/resources");
p.put("format", "xml");
@@ -409,7 +409,7 @@ public class DataFormatSerializerTest {
*/
@Test
public void encodeToXmlYangWithPut() throws SvcLogicException {
- String pre = "test-yang:cont1.cont2.";
+ String pre = "test-yang_cont1.cont2.";
SvcLogicContext ctx = createAttListYang(pre);
p.put("dirPath", "src/test/resources");
p.put("format", "xml");
@@ -428,7 +428,7 @@ public class DataFormatSerializerTest {
*/
@Test
public void encodeToXmlYangWithPatch() throws SvcLogicException {
- String pre = "test-yang:cont1.cont2.";
+ String pre = "test-yang_cont1.cont2.";
SvcLogicContext ctx = createAttListYang(pre);
p.put("dirPath", "src/test/resources");
p.put("format", "xml");
@@ -447,7 +447,7 @@ public class DataFormatSerializerTest {
*/
@Test
public void encodeToXmlWithAugAsRootChild() throws SvcLogicException {
- String pre = "test-yang:cont1.cont2.";
+ String pre = "test-yang_cont1.cont2.";
SvcLogicContext ctx = createAttListYang(pre);
p.put("dirPath", "src/test/resources");
p.put("format", "xml");
@@ -468,7 +468,7 @@ public class DataFormatSerializerTest {
public void decodeToXmlYang() throws SvcLogicException {
createMockForDecode(ENCODE_TO_XML_YANG);
SvcLogicContext ctx = new SvcLogicContext();
- String pre = "test-yang:cont1.cont2.";
+ String pre = "test-yang_cont1.cont2.";
p.put("dirPath", "src/test/resources");
p.put("format", "xml");
p.put("httpMethod", "get");
@@ -487,8 +487,8 @@ public class DataFormatSerializerTest {
@Test
public void codecToJsonRpc() throws SvcLogicException {
createMockForDecode(DECODE_FROM_JSON_RPC);
- String inPre = "test-yang:create-sfc.input.";
- String outPre = "test-yang:create-sfc.output.";
+ String inPre = "test-yang_create-sfc.input.";
+ String outPre = "test-yang_create-sfc.output.";
SvcLogicContext ctx = createAttListRpc(inPre);
p.put("dirPath", "src/test/resources");
p.put("format", "json");
@@ -509,8 +509,8 @@ public class DataFormatSerializerTest {
@Test
public void codecToXmlRpc() throws SvcLogicException {
createMockForDecode(DECODE_FROM_XML_RPC);
- String inPre = "test-yang:create-sfc.input.";
- String outPre = "test-yang:create-sfc.output.";
+ String inPre = "test-yang_create-sfc.input.";
+ String outPre = "test-yang_create-sfc.output.";
SvcLogicContext ctx = createAttListRpc(inPre);
p.put("dirPath", "src/test/resources");
p.put("format", "xml");
@@ -650,21 +650,21 @@ public class DataFormatSerializerTest {
ctx.setAttribute(pre + "leaf12", "abc");
ctx.setAttribute(pre + "ll5[0]", "abc");
ctx.setAttribute(pre + "ll5[1]", "abc");
- ctx.setAttribute(pre + "cont4.test-augment:cont5.leaf13", "true");
- ctx.setAttribute(pre + "cont4.test-augment:list7[0].leaf14", "test");
- ctx.setAttribute(pre + "cont4.test-augment:list7[1].leaf14", "create");
- ctx.setAttribute(pre + "cont4.test-augment:leaf15", "abc");
- ctx.setAttribute(pre + "cont4.test-augment:ll6[0]", "unbounded");
- ctx.setAttribute(pre + "cont4.test-augment:ll6[1]", "8");
- ctx.setAttribute(pre + "cont4.test-augment:cont13.cont12.leaf26",
+ ctx.setAttribute(pre + "cont4.test-augment_cont5.leaf13", "true");
+ ctx.setAttribute(pre + "cont4.test-augment_list7[0].leaf14", "test");
+ ctx.setAttribute(pre + "cont4.test-augment_list7[1].leaf14", "create");
+ ctx.setAttribute(pre + "cont4.test-augment_leaf15", "abc");
+ ctx.setAttribute(pre + "cont4.test-augment_ll6[0]", "unbounded");
+ ctx.setAttribute(pre + "cont4.test-augment_ll6[1]", "8");
+ ctx.setAttribute(pre + "cont4.test-augment_cont13.cont12.leaf26",
"abc");
- ctx.setAttribute(pre + "cont4.test-augment:cont13.list9[0].leaf27",
+ ctx.setAttribute(pre + "cont4.test-augment_cont13.list9[0].leaf27",
"abc");
- ctx.setAttribute(pre + "cont4.test-augment:cont13.list9[1].leaf27",
+ ctx.setAttribute(pre + "cont4.test-augment_cont13.list9[1].leaf27",
"abc");
- ctx.setAttribute(pre + "cont4.test-augment:cont13.leaf28", "abc");
- ctx.setAttribute(pre + "cont4.test-augment:cont13.ll9[0]", "abc");
- ctx.setAttribute(pre + "cont4.test-augment:cont13.ll9[1]", "abc");
+ ctx.setAttribute(pre + "cont4.test-augment_cont13.leaf28", "abc");
+ ctx.setAttribute(pre + "cont4.test-augment_cont13.ll9[0]", "abc");
+ ctx.setAttribute(pre + "cont4.test-augment_cont13.ll9[1]", "abc");
return ctx;
}
@@ -785,29 +785,29 @@ public class DataFormatSerializerTest {
assertThat(ctx.getAttribute(pre + "leaf12"), is("abc"));
assertThat(ctx.getAttribute(pre + "ll5[0]"), is("abc"));
assertThat(ctx.getAttribute(pre + "ll5[1]"), is("abc"));
- assertThat(ctx.getAttribute(pre + "cont4.test-augment:cont5.leaf13"),
+ assertThat(ctx.getAttribute(pre + "cont4.test-augment_cont5.leaf13"),
is("true"));
- assertThat(ctx.getAttribute(pre + "cont4.test-augment:list7[0].leaf14"),
+ assertThat(ctx.getAttribute(pre + "cont4.test-augment_list7[0].leaf14"),
is("test"));
- assertThat(ctx.getAttribute(pre + "cont4.test-augment:list7[1].leaf14"),
+ assertThat(ctx.getAttribute(pre + "cont4.test-augment_list7[1].leaf14"),
is("create"));
- assertThat(ctx.getAttribute(pre + "cont4.test-augment:leaf15"),
+ assertThat(ctx.getAttribute(pre + "cont4.test-augment_leaf15"),
is("abc"));
- assertThat(ctx.getAttribute(pre + "cont4.test-augment:ll6[0]"),
+ assertThat(ctx.getAttribute(pre + "cont4.test-augment_ll6[0]"),
is("unbounded"));
- assertThat(ctx.getAttribute(pre + "cont4.test-augment:ll6[1]"),
+ assertThat(ctx.getAttribute(pre + "cont4.test-augment_ll6[1]"),
is("8"));
- assertThat(ctx.getAttribute(pre + "cont4.test-augment:cont13" +
+ assertThat(ctx.getAttribute(pre + "cont4.test-augment_cont13" +
".cont12.leaf26"), is("abc"));
- assertThat(ctx.getAttribute(pre + "cont4.test-augment:cont13.list9[0]" +
+ assertThat(ctx.getAttribute(pre + "cont4.test-augment_cont13.list9[0]" +
".leaf27"), is("abc"));
- assertThat(ctx.getAttribute(pre + "cont4.test-augment:cont13.list9[1]" +
+ assertThat(ctx.getAttribute(pre + "cont4.test-augment_cont13.list9[1]" +
".leaf27"), is("abc"));
- assertThat(ctx.getAttribute(pre + "cont4.test-augment:cont13.leaf28"),
+ assertThat(ctx.getAttribute(pre + "cont4.test-augment_cont13.leaf28"),
is("abc"));
- assertThat(ctx.getAttribute(pre + "cont4.test-augment:cont13.ll9[0]"),
+ assertThat(ctx.getAttribute(pre + "cont4.test-augment_cont13.ll9[0]"),
is("abc"));
- assertThat(ctx.getAttribute(pre + "cont4.test-augment:cont13.ll9[1]"),
+ assertThat(ctx.getAttribute(pre + "cont4.test-augment_cont13.ll9[1]"),
is("abc"));
}
diff --git a/restconf-client/provider/src/test/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/DataFormatUtilsTest.java b/restconf-client/provider/src/test/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/DataFormatUtilsTest.java
index 02760448..a7814e10 100644
--- a/restconf-client/provider/src/test/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/DataFormatUtilsTest.java
+++ b/restconf-client/provider/src/test/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/DataFormatUtilsTest.java
@@ -121,7 +121,11 @@ public final class DataFormatUtilsTest {
"</test>\n";
static final String ENCODE_TO_JSON_YANG_COMMON = "\n " +
- "\"test-augment:cont13\": {\n" +
+ "\"test-augment:ll6\": [\n" +
+ " \"unbounded\",\n" +
+ " \"8\"\n" +
+ " ],\n" +
+ " \"test-augment:cont13\": {\n" +
" \"ll9\": [\n" +
" \"abc\",\n" +
" \"abc\"\n" +
@@ -148,10 +152,6 @@ public final class DataFormatUtilsTest {
" }\n" +
" ],\n" +
" \"test-augment:leaf15\": \"abc\",\n" +
- " \"test-augment:ll6\": [\n" +
- " \"unbounded\",\n" +
- " \"8\"\n" +
- " ],\n" +
" \"test-augment:cont5\": {\n" +
" \"leaf13\": \"true\"\n" +
" }";
@@ -277,6 +277,10 @@ public final class DataFormatUtilsTest {
"}";
static final String ENCODE_TO_XML_YANG_COMMON = "\n" +
+ "<ll6 xmlns=\"urn:opendaylight:params:xml:ns:yang:aug" +
+ "ment\">unbounded</ll6>\n" +
+ "<ll6 xmlns=\"urn:opendaylight:params:xml:ns:yang:aug" +
+ "ment\">8</ll6>\n" +
"<cont13 xmlns=\"urn:opendaylight:params:xml:ns:yang:" +
"augment\">\n" +
" <ll9>abc</ll9>\n" +
@@ -302,10 +306,6 @@ public final class DataFormatUtilsTest {
"</list7>\n" +
"<leaf15 xmlns=\"urn:opendaylight:params:xml:ns:yang:" +
"augment\">abc</leaf15>\n" +
- "<ll6 xmlns=\"urn:opendaylight:params:xml:ns:yang:aug" +
- "ment\">unbounded</ll6>\n" +
- "<ll6 xmlns=\"urn:opendaylight:params:xml:ns:yang:aug" +
- "ment\">8</ll6>\n" +
"<cont5 xmlns=\"urn:opendaylight:params:xml:ns:yang:a" +
"ugment\">\n" +
" <leaf13>true</leaf13>\n" +
@@ -557,8 +557,8 @@ public final class DataFormatUtilsTest {
* @param i number of space
* @return space appended string
*/
- private static String addSpace(String req, int i) {
- StringBuilder space = new StringBuilder("");
+ public static String addSpace(String req, int i) {
+ StringBuilder space = new StringBuilder();
for (int sp = 0; sp < i; sp++) {
space = space.append(" ");
}
diff --git a/restconf-client/provider/src/test/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/IdentifierValidationTest.java b/restconf-client/provider/src/test/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/IdentifierValidationTest.java
new file mode 100644
index 00000000..1109d426
--- /dev/null
+++ b/restconf-client/provider/src/test/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/IdentifierValidationTest.java
@@ -0,0 +1,762 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - CCSDK
+ * ================================================================================
+ * Copyright (C) 2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * ================================================================================
+ * 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.ccsdk.sli.plugins.yangserializers.dfserializer;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.invocation.InvocationOnMock;
+import org.mockito.stubbing.Answer;
+import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
+import org.onap.ccsdk.sli.core.sli.SvcLogicException;
+import org.onap.ccsdk.sli.plugins.restapicall.HttpResponse;
+import org.onap.ccsdk.sli.plugins.restapicall.RestapiCallNode;
+import org.onap.ccsdk.sli.plugins.restconfapicall.RestconfApiCallNode;
+import org.opendaylight.restconf.common.context.InstanceIdentifierContext;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.core.Is.is;
+import static org.mockito.Matchers.any;
+import static org.mockito.Mockito.doAnswer;
+import static org.mockito.Mockito.doCallRealMethod;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.mock;
+import static org.onap.ccsdk.sli.plugins.yangserializers.dfserializer.IdentifierValidationUtilsTest.DECODE_FROM_JSON_RPC_ID;
+import static org.onap.ccsdk.sli.plugins.yangserializers.dfserializer.IdentifierValidationUtilsTest.DECODE_FROM_XML_RPC_ID;
+import static org.onap.ccsdk.sli.plugins.yangserializers.dfserializer.IdentifierValidationUtilsTest.ENCODE_TO_JSON_RPC_ID;
+import static org.onap.ccsdk.sli.plugins.yangserializers.dfserializer.IdentifierValidationUtilsTest.ENCODE_TO_JSON_WITH_AUG_PATH;
+import static org.onap.ccsdk.sli.plugins.yangserializers.dfserializer.IdentifierValidationUtilsTest.ENCODE_TO_JSON_YANG_AUG_POST_ID;
+import static org.onap.ccsdk.sli.plugins.yangserializers.dfserializer.IdentifierValidationUtilsTest.ENCODE_TO_JSON_YANG_ID;
+import static org.onap.ccsdk.sli.plugins.yangserializers.dfserializer.IdentifierValidationUtilsTest.ENCODE_TO_JSON_YANG_PUT_ID;
+import static org.onap.ccsdk.sli.plugins.yangserializers.dfserializer.IdentifierValidationUtilsTest.ENCODE_TO_XML_RPC_ID;
+import static org.onap.ccsdk.sli.plugins.yangserializers.dfserializer.IdentifierValidationUtilsTest.ENCODE_TO_XML_YANG_AUG_POST_ID;
+import static org.onap.ccsdk.sli.plugins.yangserializers.dfserializer.IdentifierValidationUtilsTest.ENCODE_TO_XML_YANG_ID;
+import static org.onap.ccsdk.sli.plugins.yangserializers.dfserializer.IdentifierValidationUtilsTest.ENCODE_TO_XML_YANG_PUT_ID;
+
+/**
+ * Unit test cases for identifier validation test.
+ */
+public class IdentifierValidationTest {
+
+ private Map<String, String> p;
+
+ private RestconfApiCallNode restconf;
+
+ private RestapiCallNode restApi;
+
+ private DfCaptor dfCaptor;
+
+ /**
+ * Sets up the pre-requisite for each test case.
+ *
+ * @throws SvcLogicException when test case fails
+ */
+ @Before
+ public void setUp() throws SvcLogicException {
+ p = new HashMap<>();
+ p.put("restapiUser", "user1");
+ p.put("restapiPassword", "abc123");
+ p.put("responsePrefix", "response");
+ p.put("skipSending", "true");
+ restApi = new RestapiCallNode();
+ restconf = mock(RestconfApiCallNode.class);
+ dfCaptor = new DfCaptor();
+ createMethodMocks();
+ }
+
+ /**
+ * Creates method mocks using mockito for RestconfApiCallNode class.
+ *
+ * @throws SvcLogicException when test case fails
+ */
+ private void createMethodMocks() throws SvcLogicException {
+ doReturn(restApi).when(restconf).getRestapiCallNode();
+ doCallRealMethod().when(restconf).sendRequest(
+ any(Map.class), any(SvcLogicContext.class));
+ doCallRealMethod().when(restconf).sendRequest(
+ any(Map.class), any(SvcLogicContext.class), any(Integer.class));
+ doAnswer(dfCaptor).when(restconf).serializeRequest(
+ any(Map.class), any(YangParameters.class), any(String.class),
+ any(InstanceIdentifierContext.class));
+ doAnswer(dfCaptor).when(restconf).updateReq(
+ any(String.class), any(YangParameters.class),
+ any(InstanceIdentifierContext.class));
+ }
+
+ /**
+ * Creates mock using mockito with input data for decoding.
+ *
+ * @param decodeData input data
+ * @throws SvcLogicException when test case fails
+ */
+ private void createMockForDecode(String decodeData)
+ throws SvcLogicException {
+ doReturn(decodeData).when(restconf).getResponse(
+ any(SvcLogicContext.class), any(YangParameters.class),
+ any(String.class), any(HttpResponse.class));
+ doCallRealMethod().when(restconf).serializeResponse(
+ any(YangParameters.class), any(String.class), any(String.class),
+ any(InstanceIdentifierContext.class));
+ }
+
+ /**
+ * Verifies encoding of parameters to JSON data format with containers,
+ * grouping and augment.
+ *
+ * @throws SvcLogicException when test case fails
+ */
+ @Test
+ public void encodeToJsonYang() throws SvcLogicException {
+ String pre = "test_name_of_the_module_name_of_the_cont1.name_" +
+ "of_the_cont2.";
+ SvcLogicContext ctx = createAttListYang(pre);
+ p.put("dirPath", "src/test/resources");
+ p.put("format", "json");
+ p.put("httpMethod", "post");
+ p.put("restapiUrl", "http://echo.getpostman.com/restconf/operati" +
+ "ons/test_name_of_the_module:name_of_the_cont1");
+ restconf.sendRequest(p, ctx);
+ assertThat(dfCaptor.getResult(), is(ENCODE_TO_JSON_YANG_ID));
+ }
+
+ /**
+ * Verifies encoding of parameters with augment in the URL.
+ *
+ * @throws SvcLogicException when test case fails
+ */
+ @Test
+ public void encodeToJsonYangWithAugUrl() throws SvcLogicException {
+ String pre = "test_name_of_the_module_name_of_the_cont1.name_" +
+ "of_the_cont2.";
+ SvcLogicContext ctx = createAttListYang(pre);
+ p.put("dirPath", "src/test/resources");
+ p.put("format", "json");
+ p.put("httpMethod", "post");
+ p.put("restapiUrl", "http://echo.getpostman.com/restconf/operati" +
+ "ons/test_name_of_the_module:name_of_the_cont1/name_of_t" +
+ "he_cont2/name_of_the_cont4/test_augment_1_for_module:na" +
+ "me_of_the_cont5");
+ restconf.sendRequest(p, ctx);
+ assertThat(dfCaptor.getResult(), is(ENCODE_TO_JSON_WITH_AUG_PATH));
+ }
+
+ /**
+ * Verifies encoding of parameters to JSON data format with containers,
+ * grouping and augment for put operation-type.
+ *
+ * @throws SvcLogicException when test case fails
+ */
+ @Test
+ public void encodeToJsonYangWithPut() throws SvcLogicException {
+ String pre = "test_name_of_the_module_name_of_the_cont1.name_of_the_cont2.";
+ SvcLogicContext ctx = createAttListYang(pre);
+ p.put("dirPath", "src/test/resources");
+ p.put("format", "json");
+ p.put("httpMethod", "put");
+ p.put("restapiUrl", "http://echo.getpostman" +
+ ".com/restconf/operations/test_name_of_the_module:name_of" +
+ "_the_cont1/name_of_the_cont2/name_of_the_cont4");
+ restconf.sendRequest(p, ctx);
+ assertThat(dfCaptor.getResult(), is(ENCODE_TO_JSON_YANG_PUT_ID));
+ }
+
+ /**
+ * Verifies encoding of parameters to JSON data format with containers,
+ * grouping and augment for patch operation-type.
+ *
+ * @throws SvcLogicException when test case fails
+ */
+ @Test
+ public void encodeToJsonYangWithPatch() throws SvcLogicException {
+ String pre = "test_name_of_the_module_name_of_the_cont1.name_o" +
+ "f_the_cont2.";
+ SvcLogicContext ctx = createAttListYang(pre);
+ p.put("dirPath", "src/test/resources");
+ p.put("format", "json");
+ p.put("httpMethod", "patch");
+ p.put("restapiUrl", "http://echo.getpostman" +
+ ".com/restconf/operations/test_name_of_the_module:name_of_" +
+ "the_cont1/name_of_the_cont2/name_of_the_cont4");
+ restconf.sendRequest(p, ctx);
+ assertThat(dfCaptor.getResult(), is(ENCODE_TO_JSON_YANG_PUT_ID));
+ }
+
+ /**
+ * Verifies encoding of parameters to JSON data format with augment as
+ * root child.
+ *
+ * @throws SvcLogicException when test case fails
+ */
+ @Test
+ public void encodeToJsonWithAugAsRootChild() throws SvcLogicException {
+ String pre = "test_name_of_the_module_name_of_the_cont1.name_of_" +
+ "the_cont2.";
+ SvcLogicContext ctx = createAttListYang(pre);
+ p.put("dirPath", "src/test/resources");
+ p.put("format", "json");
+ p.put("httpMethod", "post");
+ p.put("restapiUrl", "http://echo.getpostman" +
+ ".com/restconf/operations/test_name_of_the_module:name_of_" +
+ "the_cont1/name_of_the_cont2/name_of_the_cont4");
+ restconf.sendRequest(p, ctx);
+ assertThat(dfCaptor.getResult(), is(ENCODE_TO_JSON_YANG_AUG_POST_ID));
+ }
+
+ /**
+ * Verifies decoding of parameters from JSON data format with containers,
+ * grouping and augment.
+ *
+ * @throws SvcLogicException when test case fails
+ */
+ @Test
+ public void decodeToJsonYang() throws SvcLogicException {
+ createMockForDecode(ENCODE_TO_JSON_YANG_ID);
+ SvcLogicContext ctx = new SvcLogicContext();
+ String pre = "test_name_of_the_module_name_of_the_cont1.name_" +
+ "of_the_cont2.";
+ p.put("dirPath", "src/test/resources");
+ p.put("format", "json");
+ p.put("httpMethod", "get");
+ p.put("restapiUrl", "http://echo.getpostman" +
+ ".com/restconf/operations/test_name_of_the_module:name" +
+ "_of_the_cont1");
+ restconf.sendRequest(p, ctx);
+ verifyAttListYang(ctx, pre);
+ }
+
+ /**
+ * Verifies encoding of parameters to XML data format with containers,
+ * grouping and augment.
+ *
+ * @throws SvcLogicException when test case fails
+ */
+ @Test
+ public void encodeToXmlYang() throws SvcLogicException {
+ String pre = "test_name_of_the_module_name_of_the_cont1.name_of" +
+ "_the_cont2.";
+ SvcLogicContext ctx = createAttListYang(pre);
+ p.put("dirPath", "src/test/resources");
+ p.put("format", "xml");
+ p.put("httpMethod", "post");
+ p.put("restapiUrl", "http://echo.getpostman.com/restconf/operations/" +
+ "test_name_of_the_module:name_of_the_cont1");
+ restconf.sendRequest(p, ctx);
+ assertThat(dfCaptor.getResult(), is(ENCODE_TO_XML_YANG_ID));
+ }
+
+ /**
+ * Verifies encoding of parameters to XML data format with containers,
+ * grouping and augment for put operation-type
+ *
+ * @throws SvcLogicException when test case fails
+ */
+ @Test
+ public void encodeToXmlYangWithPut() throws SvcLogicException {
+ String pre = "test_name_of_the_module_name_of_the_cont1.name_" +
+ "of_the_cont2.";
+ SvcLogicContext ctx = createAttListYang(pre);
+ p.put("dirPath", "src/test/resources");
+ p.put("format", "xml");
+ p.put("httpMethod", "put");
+ p.put("restapiUrl", "http://echo.getpostman.com/restconf/operations/" +
+ "test_name_of_the_module:name_of_the_cont1/name_of_the_cont2" +
+ "/name_of_the_cont4");
+ restconf.sendRequest(p, ctx);
+ assertThat(dfCaptor.getResult(), is(ENCODE_TO_XML_YANG_PUT_ID));
+ }
+
+ /**
+ * Verifies encoding of parameters to XML data format with containers,
+ * grouping and augment for patch operation-type
+ *
+ * @throws SvcLogicException when test case fails
+ */
+ @Test
+ public void encodeToXmlYangWithPatch() throws SvcLogicException {
+ String pre = "test_name_of_the_module_name_of_the_cont1.name_of" +
+ "_the_cont2.";
+ SvcLogicContext ctx = createAttListYang(pre);
+ p.put("dirPath", "src/test/resources");
+ p.put("format", "xml");
+ p.put("httpMethod", "put");
+ p.put("restapiUrl", "http://echo.getpostman.com/restconf/operation" +
+ "s/test_name_of_the_module:name_of_the_cont1/name_of_the_c" +
+ "ont2/name_of_the_cont4");
+ restconf.sendRequest(p, ctx);
+ assertThat(dfCaptor.getResult(), is(ENCODE_TO_XML_YANG_PUT_ID));
+ }
+
+ /**
+ * Verifies encoding of parameters to XML data format with augment as
+ * root child.
+ *
+ * @throws SvcLogicException when test case fails
+ */
+ @Test
+ public void encodeToXmlWithAugAsRootChild() throws SvcLogicException {
+ String pre = "test_name_of_the_module_name_of_the_cont1.name_of_the" +
+ "_cont2.";
+ SvcLogicContext ctx = createAttListYang(pre);
+ p.put("dirPath", "src/test/resources");
+ p.put("format", "xml");
+ p.put("httpMethod", "post");
+ p.put("restapiUrl", "http://echo.getpostman.com/restconf/operations/" +
+ "test_name_of_the_module:name_of_the_cont1/name_of_the_cont2" +
+ "/name_of_the_cont4");
+ restconf.sendRequest(p, ctx);
+ assertThat(dfCaptor.getResult(), is(ENCODE_TO_XML_YANG_AUG_POST_ID));
+ }
+
+ /**
+ * Verifies decoding of parameters from XML data format with containers,
+ * grouping and augment.
+ *
+ * @throws SvcLogicException when test case fails
+ */
+ @Test
+ public void decodeToXmlYang() throws SvcLogicException {
+ createMockForDecode(ENCODE_TO_XML_YANG_ID);
+ SvcLogicContext ctx = new SvcLogicContext();
+ String pre = "test_name_of_the_module_name_of_the_cont1.name_of_" +
+ "the_cont2.";
+ p.put("dirPath", "src/test/resources");
+ p.put("format", "xml");
+ p.put("httpMethod", "get");
+ p.put("restapiUrl", "http://echo.getpostman.com/restconf/operation" +
+ "s/test_name_of_the_module:name_of_the_cont1");
+ restconf.sendRequest(p, ctx);
+ verifyAttListYang(ctx, pre);
+ }
+
+ /**
+ * Verifies encoding of and decoding from, JSON respectively for data
+ * format with containers, grouping and augment.
+ *
+ * @throws SvcLogicException when test case fails
+ */
+ @Test
+ public void codecToJsonRpc() throws SvcLogicException {
+ createMockForDecode(DECODE_FROM_JSON_RPC_ID);
+ String inPre = "test_name_of_the_module_name_of_the_create-sfc.input.";
+ String outPre = "test_name_of_the_module_name_of_the_create-sfc" +
+ ".output.";
+ SvcLogicContext ctx = createAttListRpc(inPre);
+ p.put("dirPath", "src/test/resources");
+ p.put("format", "json");
+ p.put("httpMethod", "post");
+ p.put("restapiUrl", "http://echo.getpostman.com/restconf/operations" +
+ "/test_name_of_the_module:name_of_the_create-sfc");
+ restconf.sendRequest(p, ctx);
+ assertThat(dfCaptor.getResult(), is(ENCODE_TO_JSON_RPC_ID));
+ verifyAttListRpc(ctx, outPre);
+ }
+
+ /**
+ * Verifies encoding of and decoding from, XML respectively for data
+ * format with containers, grouping and augment.
+ *
+ * @throws SvcLogicException when test case fails
+ */
+ @Test
+ public void codecToXmlRpc() throws SvcLogicException {
+ createMockForDecode(DECODE_FROM_XML_RPC_ID);
+ String inPre = "test_name_of_the_module_name_of_the_create-sfc.input.";
+ String outPre = "test_name_of_the_module_name_of_the_create-sfc.output.";
+ SvcLogicContext ctx = createAttListRpc(inPre);
+ p.put("dirPath", "src/test/resources");
+ p.put("format", "xml");
+ p.put("httpMethod", "post");
+ p.put("restapiUrl", "http://echo.getpostman" +
+ ".com/restconf/operations/test_name_of_the_module" +
+ ":name_of_the_create-sfc");
+ restconf.sendRequest(p, ctx);
+ assertThat(dfCaptor.getResult(), is(ENCODE_TO_XML_RPC_ID));
+ verifyAttListRpc(ctx, outPre);
+ }
+
+ /**
+ * Creates attribute list for encoding JSON or XML with container,
+ * grouping and augmented YANG file.
+ *
+ * @param pre prefix
+ * @return service logic context
+ */
+ private SvcLogicContext createAttListYang(String pre) {
+ SvcLogicContext ctx = new SvcLogicContext();
+ ctx.setAttribute(pre + "name_of_the_cont3.name_of_the_leaf" +
+ "10", "abc");
+ ctx.setAttribute(pre + "name_of_the_list1[0].name_of_the_leaf1" +
+ "", "true");
+ ctx.setAttribute(pre + "name_of_the_list1[0].name_of_the_leaf2" +
+ "", "abc");
+ ctx.setAttribute(pre + "name_of_the_list1[0].name_of_the_leaf3" +
+ "", "abc");
+ ctx.setAttribute(pre + "name_of_the_list1[0].name_of_the_" +
+ "ll1[0]", "abc");
+ ctx.setAttribute(pre + "name_of_the_list1[0].name_of_the_" +
+ "ll1[1]", "abc");
+ ctx.setAttribute(pre + "name_of_the_list1[0].name_of_the_" +
+ "ll2[0]", "abc");
+ ctx.setAttribute(pre + "name_of_the_list1[0].name_of_the_" +
+ "ll2[1]", "abc");
+ ctx.setAttribute(pre + "name_of_the_list1[0].name_of_the_" +
+ "cont4.name_of_the_leaf11", "abc");
+ ctx.setAttribute(pre + "name_of_the_list1[0].name_of_the_" +
+ "list4[0].name_of_the_leaf8", "abc");
+ ctx.setAttribute(pre + "name_of_the_list1[0].name_of_the_" +
+ "list4[1].name_of_the_leaf8", "abc");
+ ctx.setAttribute(pre + "name_of_the_list1[0].name_of_the_" +
+ "list5[0].name_of_the_leaf9", "abc");
+ ctx.setAttribute(pre + "name_of_the_list1[0].name_of_the_" +
+ "list5[1].name_of_the_leaf9", "abc");
+ ctx.setAttribute(pre + "name_of_the_list1[1].name_of_the_" +
+ "leaf1", "true");
+ ctx.setAttribute(pre + "name_of_the_list1[1].name_of_the_" +
+ "leaf2", "abc");
+ ctx.setAttribute(pre + "name_of_the_list1[1].name_of_the_" +
+ "leaf3", "abc");
+ ctx.setAttribute(pre + "name_of_the_list1[1].name_of_the_" +
+ "ll1[0]", "abc");
+ ctx.setAttribute(pre + "name_of_the_list1[1].name_of_the_" +
+ "ll1[1]", "abc");
+ ctx.setAttribute(pre + "name_of_the_list1[1].name_of_the_" +
+ "ll2[0]", "abc");
+ ctx.setAttribute(pre + "name_of_the_list1[1].name_of_the_" +
+ "ll2[1]", "abc");
+ ctx.setAttribute(pre + "name_of_the_list1[1].name_of_the_" +
+ "cont4.name_of_the_leaf11", "abc");
+ ctx.setAttribute(pre + "name_of_the_list1[1].name_of_the_" +
+ "list4[0].name_of_the_leaf8", "abc");
+ ctx.setAttribute(pre + "name_of_the_list1[1].name_of_the_" +
+ "list4[1].name_of_the_leaf8", "abc");
+ ctx.setAttribute(pre + "name_of_the_list1[1].name_of_the_" +
+ "list5[0].name_of_the_leaf9", "abc");
+ ctx.setAttribute(pre + "name_of_the_list1[1].name_of_the_" +
+ "list5[1].name_of_the_leaf9", "abc");
+ ctx.setAttribute(pre + "name_of_the_list2[0].name_of_the_" +
+ "leaf4", "abc");
+ ctx.setAttribute(pre + "name_of_the_list2[1].name_of_the_" +
+ "leaf4", "abc");
+ ctx.setAttribute(pre + "name_of_the_leaf5", "abc");
+ ctx.setAttribute(pre + "name_of_the_leaf6", "abc");
+ ctx.setAttribute(pre + "name_of_the_ll3[0]", "abc");
+ ctx.setAttribute(pre + "name_of_the_ll3[1]", "abc");
+ ctx.setAttribute(pre + "name_of_the_ll4[0]", "abc");
+ ctx.setAttribute(pre + "name_of_the_ll4[1]", "abc");
+ ctx.setAttribute(pre + "name_of_the_cont4.name_of_the_leaf10",
+ "abc");
+ ctx.setAttribute(pre + "name_of_the_list6[0].name_of_the_leaf11",
+ "abc");
+ ctx.setAttribute(pre + "name_of_the_list6[1].name_of_the_leaf11",
+ "abc");
+ ctx.setAttribute(pre + "name_of_the_leaf12", "abc");
+ ctx.setAttribute(pre + "name_of_the_ll5[0]", "abc");
+ ctx.setAttribute(pre + "name_of_the_ll5[1]", "abc");
+ ctx.setAttribute(pre + "name_of_the_cont4.test_augment_1_for_" +
+ "module_name_of_the_cont5.name_of_the_leaf13",
+ "true");
+ ctx.setAttribute(pre + "name_of_the_cont4.test_augment_1_for_" +
+ "module_name_of_the_list7[0].name_of_the" +
+ "_leaf14", "test");
+ ctx.setAttribute(pre + "name_of_the_cont4.test_augment_1_for_" +
+ "module_name_of_the_list7[1].name_of_the" +
+ "_leaf14", "create");
+ ctx.setAttribute(pre + "name_of_the_cont4.test_augment_1_for_" +
+ "module_name_of_the_leaf15", "abc");
+ ctx.setAttribute(pre + "name_of_the_cont4.test_augment_1_for_" +
+ "module_name_of_the_ll6[0]",
+ "unbounded");
+ ctx.setAttribute(pre + "name_of_the_cont4.test_augment_1_for" +
+ "_module_name_of_the_ll6[1]", "8");
+ ctx.setAttribute(pre + "name_of_the_cont4.test_augment_1_for" +
+ "_module_name_of_the_cont13.name_of_the_" +
+ "cont12.name_of_the_leaf26",
+ "abc");
+ ctx.setAttribute(pre + "name_of_the_cont4.test_augment_1_for_" +
+ "module_name_of_the_cont13.name_of_the_" +
+ "list9[0].name_of_the_leaf27",
+ "abc");
+ ctx.setAttribute(pre + "name_of_the_cont4.test_augment_1_for" +
+ "_module_name_of_the_cont13.name_of_the_" +
+ "list9[1].name_of_the_leaf27",
+ "abc");
+ ctx.setAttribute(pre + "name_of_the_cont4.test_augment_1_for" +
+ "_module_name_of_the_cont13.name_of_the_" +
+ "leaf28", "abc");
+ ctx.setAttribute(pre + "name_of_the_cont4.test_augment_1_for" +
+ "_module_name_of_the_cont13.name_of_the_" +
+ "ll9[0]", "abc");
+ ctx.setAttribute(pre + "name_of_the_cont4.test_augment_1_for" +
+ "_module_name_of_the_cont13.name_of_the_" +
+ "ll9[1]", "abc");
+ return ctx;
+ }
+
+ /**
+ * Creates attribute list for encoding JSON or XML with RPC YANG file.
+ *
+ * @param pre prefix
+ * @return service logic context
+ */
+ private SvcLogicContext createAttListRpc(String pre) {
+ SvcLogicContext ctx = new SvcLogicContext();
+ ctx.setAttribute(pre + "name_of_the_cont14.name_of_the_leaf28",
+ "abc");
+ ctx.setAttribute(pre + "name_of_the_list10[0].name_of_the_leaf29",
+ "abc");
+ ctx.setAttribute(pre + "name_of_the_list10[1].name_of_the_leaf29",
+ "abc");
+ ctx.setAttribute(pre + "name_of_the_leaf30", "abc");
+ ctx.setAttribute(pre + "name_of_the_ll10[0]", "abc");
+ ctx.setAttribute(pre + "name_of_the_ll10[1]", "abc");
+ ctx.setAttribute(pre + "name_of_the_cont15.name_of_the_leaf31",
+ "abc");
+ ctx.setAttribute(pre + "name_of_the_cont13.name_of_the_list9[0]" +
+ ".name_of_the_leaf27", "abc");
+ ctx.setAttribute(pre + "name_of_the_cont13.name_of_the_list9[1]" +
+ ".name_of_the_leaf27", "abc");
+ ctx.setAttribute(pre + "name_of_the_cont13.name_of_the_leaf28",
+ "abc");
+ ctx.setAttribute(pre + "name_of_the_cont13.name_of_the_ll9[0]",
+ "abc");
+ ctx.setAttribute(pre + "name_of_the_cont13.name_of_the_ll9[1]",
+ "abc");
+ return ctx;
+ }
+
+ /**
+ * Verifies the attribute list for decoding from JSON or XML with
+ * container, grouping and augmented file.
+ *
+ * @param ctx service logic context
+ * @param pre prefix
+ */
+ private void verifyAttListYang(SvcLogicContext ctx, String pre) {
+ assertThat(ctx.getAttribute(pre + "name_of_the_cont3.name_of" +
+ "_the_leaf10"), is("abc"));
+ assertThat(ctx.getAttribute(pre + "name_of_the_list1[0].name" +
+ "_of_the_leaf1"), is("true"));
+ assertThat(ctx.getAttribute(pre + "name_of_the_list1[0].name" +
+ "_of_the_leaf2"), is("abc"));
+ assertThat(ctx.getAttribute(pre + "name_of_the_list1[0].name" +
+ "_of_the_leaf3"), is("abc"));
+ assertThat(ctx.getAttribute(pre + "name_of_the_list1[0].name" +
+ "_of_the_ll1[0]"), is("abc"));
+ assertThat(ctx.getAttribute(pre + "name_of_the_list1[0].name" +
+ "_of_the_ll1[1]"), is("abc"));
+ assertThat(ctx.getAttribute(pre + "name_of_the_list1[0].name" +
+ "_of_the_ll2[0]"), is("abc"));
+ assertThat(ctx.getAttribute(pre + "name_of_the_list1[0].name" +
+ "_of_the_ll2[1]"), is("abc"));
+ assertThat(ctx.getAttribute(pre + "name_of_the_list1[0].name" +
+ "_of_the_cont4.name_of_the_leaf11"),
+ is("abc"));
+ assertThat(ctx.getAttribute(pre + "name_of_the_list1[0].name_of" +
+ "_the_list4[0].name_of_the_leaf8"),
+ is("abc"));
+ assertThat(ctx.getAttribute(pre + "name_of_the_list1[0].name_of" +
+ "_the_list4[1].name_of_the_leaf8"),
+ is("abc"));
+ assertThat(ctx.getAttribute(pre + "name_of_the_list1[0].name_of" +
+ "_the_list5[0].name_of_the_leaf9"),
+ is("abc"));
+ assertThat(ctx.getAttribute(pre + "name_of_the_list1[0].name_of" +
+ "_the_list5[1].name_of_the_leaf9"),
+ is("abc"));
+ assertThat(ctx.getAttribute(pre + "name_of_the_list1[1].name_of" +
+ "_the_leaf1"), is("true"));
+ assertThat(ctx.getAttribute(pre + "name_of_the_list1[1].name_of" +
+ "_the_leaf2"), is("abc"));
+ assertThat(ctx.getAttribute(pre + "name_of_the_list1[1].name_of" +
+ "_the_leaf3"), is("abc"));
+ assertThat(ctx.getAttribute(pre + "name_of_the_list1[1].name_of" +
+ "_the_ll1[0]"), is("abc"));
+ assertThat(ctx.getAttribute(pre + "name_of_the_list1[1].name_of" +
+ "_the_ll1[1]"), is("abc"));
+ assertThat(ctx.getAttribute(pre + "name_of_the_list1[1].name_of" +
+ "_the_ll2[0]"), is("abc"));
+ assertThat(ctx.getAttribute(pre + "name_of_the_list1[1].name_of" +
+ "_the_ll2[1]"), is("abc"));
+ assertThat(ctx.getAttribute(pre + "name_of_the_list1[1].name_of" +
+ "_the_cont4.name_of_the_leaf11"),
+ is("abc"));
+ assertThat(ctx.getAttribute(pre + "name_of_the_list1[1].name_of" +
+ "_the_list4[0].name_of_the_leaf8"),
+ is("abc"));
+ assertThat(ctx.getAttribute(pre + "name_of_the_list1[1].name_of" +
+ "_the_list4[1].name_of_the_leaf8"),
+ is("abc"));
+ assertThat(ctx.getAttribute(pre + "name_of_the_list1[1].name_of" +
+ "_the_list5[0].name_of_the_leaf9"),
+ is("abc"));
+ assertThat(ctx.getAttribute(pre + "name_of_the_list1[1].name_of" +
+ "_the_list5[1].name_of_the_leaf9"),
+ is("abc"));
+ assertThat(ctx.getAttribute(pre + "name_of_the_list2[0].name_of" +
+ "_the_leaf4"), is("abc"));
+ assertThat(ctx.getAttribute(pre + "name_of_the_list2[1].name_of" +
+ "_the_leaf4"), is("abc"));
+ assertThat(ctx.getAttribute(pre + "name_of_the_leaf5"),
+ is("abc"));
+ assertThat(ctx.getAttribute(pre + "name_of_the_leaf6"),
+ is("abc"));
+ assertThat(ctx.getAttribute(pre + "name_of_the_ll3[0]"),
+ is("abc"));
+ assertThat(ctx.getAttribute(pre + "name_of_the_ll3[1]"),
+ is("abc"));
+ assertThat(ctx.getAttribute(pre + "name_of_the_ll4[0]"),
+ is("abc"));
+ assertThat(ctx.getAttribute(pre + "name_of_the_ll4[1]"),
+ is("abc"));
+ assertThat(ctx.getAttribute(pre + "name_of_the_cont4.name_of" +
+ "_the_leaf10"), is( "abc"));
+ assertThat(ctx.getAttribute(pre + "name_of_the_list6[0].name_of" +
+ "_the_leaf11"), is("abc"));
+ assertThat(ctx.getAttribute(pre + "name_of_the_list6[1].name_of" +
+ "_the_leaf11"), is("abc"));
+ assertThat(ctx.getAttribute(pre + "name_of_the_leaf12"),
+ is("abc"));
+ assertThat(ctx.getAttribute(pre + "name_of_the_ll5[0]"),
+ is("abc"));
+ assertThat(ctx.getAttribute(pre + "name_of_the_ll5[1]"),
+ is("abc"));
+ assertThat(ctx.getAttribute(pre + "name_of_the_cont4.test_" +
+ "augment_1_for_module_name_of_" +
+ "the_cont5.name_of_the_leaf13"),
+ is("true"));
+ assertThat(ctx.getAttribute(pre + "name_of_the_cont4.test_" +
+ "augment_1_for_module_name_of_" +
+ "the_list7[0].name_of_the_leaf14"),
+ is("test"));
+ assertThat(ctx.getAttribute(pre + "name_of_the_cont4.test_" +
+ "augment_1_for_module_name_of_" +
+ "the_list7[1].name_of_the_leaf14"),
+ is("create"));
+ assertThat(ctx.getAttribute(pre + "name_of_the_cont4.test_" +
+ "augment_1_for_module_name_of_" +
+ "the_leaf15"),
+ is("abc"));
+ assertThat(ctx.getAttribute(pre + "name_of_the_cont4.test_" +
+ "augment_1_for_module_name_of_" +
+ "the_ll6[0]"),
+ is("unbounded"));
+ assertThat(ctx.getAttribute(pre + "name_of_the_cont4.test_" +
+ "augment_1_for_module_name_of_" +
+ "the_ll6[1]"),
+ is("8"));
+ assertThat(ctx.getAttribute(pre + "name_of_the_cont4.test_" +
+ "augment_1_for_module_name_of_" +
+ "the_cont13" +
+ ".name_of_the_cont12.name_of_" +
+ "the_leaf26"), is("abc"));
+ assertThat(ctx.getAttribute(pre + "name_of_the_cont4.test_" +
+ "augment_1_for_module_name_of_" +
+ "the_cont13.name_of_the_list9[0]" +
+ ".name_of_the_leaf27"),
+ is("abc"));
+ assertThat(ctx.getAttribute(pre + "name_of_the_cont4.test_" +
+ "augment_1_for_module_name_of_" +
+ "the_cont13.name_of_the_list9[1]" +
+ ".name_of_the_leaf27"),
+ is("abc"));
+ assertThat(ctx.getAttribute(pre + "name_of_the_cont4.test_" +
+ "augment_1_for_module_name_of_" +
+ "the_cont13.name_of_the_leaf28"),
+ is("abc"));
+ assertThat(ctx.getAttribute(pre + "name_of_the_cont4.test_" +
+ "augment_1_for_module_name_of_" +
+ "the_cont13.name_of_the_ll9[0]"),
+ is("abc"));
+ assertThat(ctx.getAttribute(pre + "name_of_the_cont4.test_" +
+ "augment_1_for_module_name_of_" +
+ "the_cont13.name_of_the_ll9[1]"),
+ is("abc"));
+ }
+
+ /**
+ * Verifies the attribute list for decoding from JSON or XML with
+ * RPC YANG file.
+ *
+ * @param ctx service logic context
+ * @param pre prefix
+ */
+ private void verifyAttListRpc(SvcLogicContext ctx, String pre) {
+ assertThat(ctx.getAttribute(pre + "name_of_the_cont16.name_of_" +
+ "the_leaf32"), is("abc"));
+ assertThat(ctx.getAttribute(pre + "name_of_the_list11[0].name" +
+ "_of_the_leaf33"), is("abc"));
+ assertThat(ctx.getAttribute(pre + "name_of_the_list11[1].name" +
+ "_of_the_leaf33"), is("abc"));
+ assertThat(ctx.getAttribute(pre + "name_of_the_leaf34"),
+ is("abc"));
+ assertThat(ctx.getAttribute(pre + "name_of_the_ll11[0]"),
+ is("abc"));
+ assertThat(ctx.getAttribute(pre + "name_of_the_ll11[1]"),
+ is("abc"));
+ assertThat(ctx.getAttribute(pre + "name_of_the_cont17.name_of_" +
+ "the_leaf35"), is("abc"));
+ assertThat(ctx.getAttribute(pre + "name_of_the_cont13.name_of_" +
+ "the_cont12.name_of_the_leaf26"),
+ is("abc"));
+ assertThat(ctx.getAttribute(pre + "name_of_the_cont13.name_of_" +
+ "the_list9[0].name_of_the_leaf27"),
+ is("abc"));
+ assertThat(ctx.getAttribute(pre + "name_of_the_cont13.name_of_" +
+ "the_list9[1].name_of_the_leaf27"),
+ is("abc"));
+ assertThat(ctx.getAttribute(pre + "name_of_the_cont13.name_of_" +
+ "the_ll9[0]"), is("abc"));
+ assertThat(ctx.getAttribute(pre + "name_of_the_cont13.name_of_" +
+ "the_ll9[1]"), is("abc"));
+ assertThat(ctx.getAttribute(pre + "name_of_the_cont13.name_of_" +
+ "the_leaf28"), is("abc"));
+ }
+
+ /**
+ * Captures the data format messages by mocking it, which can be used in
+ * testing the value.
+ *
+ * @param <String> capturing data format
+ */
+ public class DfCaptor<String> implements Answer {
+
+ private String result;
+
+ /**
+ * Returns the captured data format message.
+ *
+ * @return data format message.
+ */
+ public String getResult() {
+ return result;
+ }
+
+ @Override
+ public String answer(InvocationOnMock invocationOnMock)
+ throws Throwable {
+ result = (String) invocationOnMock.callRealMethod();
+ return result;
+ }
+ }
+
+}
diff --git a/restconf-client/provider/src/test/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/IdentifierValidationUtilsTest.java b/restconf-client/provider/src/test/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/IdentifierValidationUtilsTest.java
new file mode 100644
index 00000000..a866f1c4
--- /dev/null
+++ b/restconf-client/provider/src/test/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/IdentifierValidationUtilsTest.java
@@ -0,0 +1,469 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - CCSDK
+ * ================================================================================
+ * Copyright (C) 2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * ================================================================================
+ * 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.ccsdk.sli.plugins.yangserializers.dfserializer;
+
+import static org.onap.ccsdk.sli.plugins.yangserializers.dfserializer.DataFormatUtilsTest.addSpace;
+
+/**
+ * Unit test case utilities for identifier validation and restconf api
+ * call node.
+ */
+public final class IdentifierValidationUtilsTest {
+
+ static final String ENCODE_TO_JSON_YANG_COMMON_ID = "\n " +
+ "\"test_augment_1_for_module:name_of_the_ll6\": [\n" +
+ " \"unbounded\",\n" +
+ " \"8\"\n" +
+ " ],\n" +
+ " \"test_augment_1_for_module:name_of_the_cont13\": {\n" +
+ " \"name_of_the_cont12\": {\n" +
+ " \"name_of_the_leaf26\": \"abc\"\n" +
+ " },\n" +
+ " \"name_of_the_ll9\": [\n" +
+ " \"abc\",\n" +
+ " \"abc\"\n" +
+ " ],\n" +
+ " \"name_of_the_leaf28\": \"abc\",\n" +
+ " \"name_of_the_list9\": [\n" +
+ " {\n" +
+ " \"name_of_the_leaf27\": \"abc\"\n" +
+ " },\n" +
+ " {\n" +
+ " \"name_of_the_leaf27\": \"abc\"\n" +
+ " }\n" +
+ " ]\n" +
+ " },\n" +
+ " \"test_augment_1_for_module:name_of_the_list7\": [\n" +
+ " {\n" +
+ " \"name_of_the_leaf14\": \"test\"\n" +
+ " },\n" +
+ " {\n" +
+ " \"name_of_the_leaf14\": \"create\"\n" +
+ " }\n" +
+ " ],\n" +
+ " \"test_augment_1_for_module:name_of_the_leaf15\": \"abc\",\n" +
+ " \"test_augment_1_for_module:name_of_the_cont5\": {\n" +
+ " \"name_of_the_leaf13\": \"true\"\n" +
+ " }";
+
+ static final String ENCODE_TO_JSON_YANG_AUG_POST_ID = "{\n" +
+ " \"test_name_of_the_module:name_of_the_leaf10\": \"abc\"," +
+ ENCODE_TO_JSON_YANG_COMMON_ID + "\n}";
+
+ static final String ENCODE_TO_JSON_YANG_ID = "{\n" +
+ " \"test_name_of_the_module:name_of_the_cont2\": {\n" +
+ " \"name_of_the_ll4\": [\n" +
+ " \"abc\",\n" +
+ " \"abc\"\n" +
+ " ],\n" +
+ " \"name_of_the_leaf5\": \"abc\",\n" +
+ " \"name_of_the_list6\": [\n" +
+ " {\n" +
+ " \"name_of_the_leaf11\": \"abc\"\n" +
+ " },\n" +
+ " {\n" +
+ " \"name_of_the_leaf11\": \"abc\"\n" +
+ " }\n" +
+ " ],\n" +
+ " \"name_of_the_ll5\": [\n" +
+ " \"abc\",\n" +
+ " \"abc\"\n" +
+ " ],\n" +
+ " \"name_of_the_ll3\": [\n" +
+ " \"abc\",\n" +
+ " \"abc\"\n" +
+ " ],\n" +
+ " \"name_of_the_leaf6\": \"abc\",\n" +
+ " \"name_of_the_cont3\": {\n" +
+ " \"name_of_the_leaf10\": \"abc\"\n" +
+ " },\n" +
+ " \"name_of_the_list2\": [\n" +
+ " {\n" +
+ " \"name_of_the_leaf4\": \"abc\"\n" +
+ " },\n" +
+ " {\n" +
+ " \"name_of_the_leaf4\": \"abc\"\n" +
+ " }\n" +
+ " ],\n" +
+ " \"name_of_the_list1\": [\n" +
+ " {\n" +
+ " \"name_of_the_ll2\": [\n" +
+ " \"abc\",\n" +
+ " \"abc\"\n" +
+ " ],\n" +
+ " \"name_of_the_list5\": [\n" +
+ " {\n" +
+ " \"name_of_the_leaf9\": \"abc\"\n" +
+ " },\n" +
+ " {\n" +
+ " \"name_of_the_leaf9\": \"abc\"\n" +
+ " }\n" +
+ " ],\n" +
+ " \"name_of_the_list4\": [\n" +
+ " {\n" +
+ " \"name_of_the_leaf8\": \"abc\"\n" +
+ " },\n" +
+ " {\n" +
+ " \"name_of_the_leaf8\": \"abc\"\n" +
+ " }\n" +
+ " ],\n" +
+ " \"name_of_the_leaf1\": \"true\",\n" +
+ " \"name_of_the_leaf3\": \"abc\",\n" +
+ " \"name_of_the_leaf2\": \"abc\",\n" +
+ " \"name_of_the_cont4\": {\n" +
+ " \"name_of_the_leaf11\": \"abc\"\n" +
+ " },\n" +
+ " \"name_of_the_ll1\": [\n" +
+ " \"abc\",\n" +
+ " \"abc\"\n" +
+ " ]\n" +
+ " },\n" +
+ " {\n" +
+ " \"name_of_the_ll2\": [\n" +
+ " \"abc\",\n" +
+ " \"abc\"\n" +
+ " ],\n" +
+ " \"name_of_the_list5\": [\n" +
+ " {\n" +
+ " \"name_of_the_leaf9\": \"abc\"\n" +
+ " },\n" +
+ " {\n" +
+ " \"name_of_the_leaf9\": \"abc\"\n" +
+ " }\n" +
+ " ],\n" +
+ " \"name_of_the_list4\": [\n" +
+ " {\n" +
+ " \"name_of_the_leaf8\": \"abc\"\n" +
+ " },\n" +
+ " {\n" +
+ " \"name_of_the_leaf8\": \"abc\"\n" +
+ " }\n" +
+ " ],\n" +
+ " \"name_of_the_leaf1\": \"true\",\n" +
+ " \"name_of_the_leaf3\": \"abc\",\n" +
+ " \"name_of_the_leaf2\": \"abc\",\n" +
+ " \"name_of_the_cont4\": {\n" +
+ " \"name_of_the_leaf11\": \"abc\"\n" +
+ " },\n" +
+ " \"name_of_the_ll1\": [\n" +
+ " \"abc\",\n" +
+ " \"abc\"\n" +
+ " ]\n" +
+ " }\n" +
+ " ],\n" +
+ " \"name_of_the_cont4\": {\n" +
+ " \"name_of_the_leaf10\": \"abc\"," +
+ addSpace(ENCODE_TO_JSON_YANG_COMMON_ID,8) + "\n" +
+ " },\n" +
+ " \"name_of_the_leaf12\": \"abc\"\n" +
+ " }\n" +
+ "}";
+
+ static final String ENCODE_TO_JSON_WITH_AUG_PATH = "{\n" +
+ " \"test_augment_1_for_module:name_of_the_leaf13\": \"true\"\n" +
+ "}";
+
+ static final String ENCODE_TO_JSON_YANG_PUT_ID = "{\n" +
+ " \"test_name_of_the_module:name_of_the_cont4\": {" + addSpace(
+ ENCODE_TO_JSON_YANG_COMMON_ID, 4) + ",\n" +
+ " \"name_of_the_leaf10\": \"abc\"\n" +
+ " }\n" +
+ "}";
+
+ static final String ENCODE_TO_XML_YANG_COMMON_ID = "\n" +
+ "<name_of_the_ll6 xmlns=\"urn:opendaylight:params:xml:ns:yang:" +
+ "test:augment:name\">unbounded</name_of_the_ll6>\n" +
+ "<name_of_the_ll6 xmlns=\"urn:opendaylight:params:xml:ns:yang:" +
+ "test:augment:name\">8</name_of_the_ll6>\n" +
+ "<name_of_the_cont13 xmlns=\"urn:opendaylight:params:xml:ns:ya" +
+ "ng:test:augment:name\">\n" +
+ " <name_of_the_cont12>\n" +
+ " <name_of_the_leaf26>abc</name_of_the_leaf26>\n" +
+ " </name_of_the_cont12>\n" +
+ " <name_of_the_ll9>abc</name_of_the_ll9>\n" +
+ " <name_of_the_ll9>abc</name_of_the_ll9>\n" +
+ " <name_of_the_leaf28>abc</name_of_the_leaf28>\n" +
+ " <name_of_the_list9>\n" +
+ " <name_of_the_leaf27>abc</name_of_the_leaf27>\n" +
+ " </name_of_the_list9>\n" +
+ " <name_of_the_list9>\n" +
+ " <name_of_the_leaf27>abc</name_of_the_leaf27>\n" +
+ " </name_of_the_list9>\n" +
+ "</name_of_the_cont13>\n" +
+ "<name_of_the_list7 xmlns=\"urn:opendaylight:params:xml:ns:yan" +
+ "g:test:augment:name\">\n" +
+ " <name_of_the_leaf14>test</name_of_the_leaf14>\n" +
+ "</name_of_the_list7>\n" +
+ "<name_of_the_list7 xmlns=\"urn:opendaylight:params:xml:ns:yan" +
+ "g:test:augment:name\">\n" +
+ " <name_of_the_leaf14>create</name_of_the_leaf14>\n" +
+ "</name_of_the_list7>\n" +
+ "<name_of_the_leaf15 xmlns=\"urn:opendaylight:params:xml:ns:ya" +
+ "ng:test:augment:name\">abc</name_of_the_leaf15>\n" +
+ "<name_of_the_cont5 xmlns=\"urn:opendaylight:params:xml:ns:yan" +
+ "g:test:augment:name\">\n" +
+ " <name_of_the_leaf13>true</name_of_the_leaf13>\n" +
+ "</name_of_the_cont5>";
+
+ static final String ENCODE_TO_XML_YANG_AUG_POST_ID = "<?xml version=\"1" +
+ ".0\" encoding=\"UTF-8\" standalone=\"no\"?>\n" +
+ "<name_of_the_leaf10 xmlns=\"urn:opendaylight:params:xml:ns:yan" +
+ "g:test:name\">abc</name_of_the_leaf10>" +
+ ENCODE_TO_XML_YANG_COMMON_ID + "\n";
+
+ static final String ENCODE_TO_XML_YANG_PUT_ID = "<?xml version=\"1.0\" " +
+ "encoding=\"UTF-8\" standalone=\"no\"?>\n" +
+ "<name_of_the_cont4 xmlns=\"urn:opendaylight:params:xml:ns:yang" +
+ ":test:name\">\n" +
+ " <name_of_the_leaf10>abc</name_of_the_leaf10>" +
+ addSpace(ENCODE_TO_XML_YANG_COMMON_ID, 4) + "\n</name_of_the_co" +
+ "nt4>\n";
+
+ static final String ENCODE_TO_XML_YANG_ID= "<?xml version=\"1.0\" " +
+ "encoding=\"UTF-8\" standalone=\"no\"?>\n" +
+ "<name_of_the_cont2 xmlns=\"urn:opendaylight:params:xml:ns:yan" +
+ "g:test:name\">\n" +
+ " <name_of_the_ll4>abc</name_of_the_ll4>\n" +
+ " <name_of_the_ll4>abc</name_of_the_ll4>\n" +
+ " <name_of_the_leaf5>abc</name_of_the_leaf5>\n" +
+ " <name_of_the_list6>\n" +
+ " <name_of_the_leaf11>abc</name_of_the_leaf11>\n" +
+ " </name_of_the_list6>\n" +
+ " <name_of_the_list6>\n" +
+ " <name_of_the_leaf11>abc</name_of_the_leaf11>\n" +
+ " </name_of_the_list6>\n" +
+ " <name_of_the_ll5>abc</name_of_the_ll5>\n" +
+ " <name_of_the_ll5>abc</name_of_the_ll5>\n" +
+ " <name_of_the_ll3>abc</name_of_the_ll3>\n" +
+ " <name_of_the_ll3>abc</name_of_the_ll3>\n" +
+ " <name_of_the_leaf6>abc</name_of_the_leaf6>\n" +
+ " <name_of_the_cont3>\n" +
+ " <name_of_the_leaf10>abc</name_of_the_leaf10>\n" +
+ " </name_of_the_cont3>\n" +
+ " <name_of_the_list2>\n" +
+ " <name_of_the_leaf4>abc</name_of_the_leaf4>\n" +
+ " </name_of_the_list2>\n" +
+ " <name_of_the_list2>\n" +
+ " <name_of_the_leaf4>abc</name_of_the_leaf4>\n" +
+ " </name_of_the_list2>\n" +
+ " <name_of_the_list1>\n" +
+ " <name_of_the_ll2>abc</name_of_the_ll2>\n" +
+ " <name_of_the_ll2>abc</name_of_the_ll2>\n" +
+ " <name_of_the_list5>\n" +
+ " <name_of_the_leaf9>abc</name_of_the_leaf9>\n" +
+ " </name_of_the_list5>\n" +
+ " <name_of_the_list5>\n" +
+ " <name_of_the_leaf9>abc</name_of_the_leaf9>\n" +
+ " </name_of_the_list5>\n" +
+ " <name_of_the_list4>\n" +
+ " <name_of_the_leaf8>abc</name_of_the_leaf8>\n" +
+ " </name_of_the_list4>\n" +
+ " <name_of_the_list4>\n" +
+ " <name_of_the_leaf8>abc</name_of_the_leaf8>\n" +
+ " </name_of_the_list4>\n" +
+ " <name_of_the_leaf1>true</name_of_the_leaf1>\n" +
+ " <name_of_the_leaf3>abc</name_of_the_leaf3>\n" +
+ " <name_of_the_leaf2>abc</name_of_the_leaf2>\n" +
+ " <name_of_the_cont4>\n" +
+ " <name_of_the_leaf11>abc</name_of_the_leaf11>\n" +
+ " </name_of_the_cont4>\n" +
+ " <name_of_the_ll1>abc</name_of_the_ll1>\n" +
+ " <name_of_the_ll1>abc</name_of_the_ll1>\n" +
+ " </name_of_the_list1>\n" +
+ " <name_of_the_list1>\n" +
+ " <name_of_the_ll2>abc</name_of_the_ll2>\n" +
+ " <name_of_the_ll2>abc</name_of_the_ll2>\n" +
+ " <name_of_the_list5>\n" +
+ " <name_of_the_leaf9>abc</name_of_the_leaf9>\n" +
+ " </name_of_the_list5>\n" +
+ " <name_of_the_list5>\n" +
+ " <name_of_the_leaf9>abc</name_of_the_leaf9>\n" +
+ " </name_of_the_list5>\n" +
+ " <name_of_the_list4>\n" +
+ " <name_of_the_leaf8>abc</name_of_the_leaf8>\n" +
+ " </name_of_the_list4>\n" +
+ " <name_of_the_list4>\n" +
+ " <name_of_the_leaf8>abc</name_of_the_leaf8>\n" +
+ " </name_of_the_list4>\n" +
+ " <name_of_the_leaf1>true</name_of_the_leaf1>\n" +
+ " <name_of_the_leaf3>abc</name_of_the_leaf3>\n" +
+ " <name_of_the_leaf2>abc</name_of_the_leaf2>\n" +
+ " <name_of_the_cont4>\n" +
+ " <name_of_the_leaf11>abc</name_of_the_leaf11>\n" +
+ " </name_of_the_cont4>\n" +
+ " <name_of_the_ll1>abc</name_of_the_ll1>\n" +
+ " <name_of_the_ll1>abc</name_of_the_ll1>\n" +
+ " </name_of_the_list1>\n" +
+ " <name_of_the_cont4>\n" +
+ " <name_of_the_leaf10>abc</name_of_the_leaf10>" +
+ addSpace(ENCODE_TO_XML_YANG_COMMON_ID, 8) + "\n" +
+ " </name_of_the_cont4>\n" +
+ " <name_of_the_leaf12>abc</name_of_the_leaf12>\n" +
+ "</name_of_the_cont2>\n";
+
+ static final String ENCODE_TO_JSON_RPC_ID = "{\n" +
+ " \"test_name_of_the_module:input\": {\n" +
+ " \"name_of_the_cont14\": {\n" +
+ " \"name_of_the_leaf28\": \"abc\"\n" +
+ " },\n" +
+ " \"name_of_the_cont13\": {\n" +
+ " \"name_of_the_ll9\": [\n" +
+ " \"abc\",\n" +
+ " \"abc\"\n" +
+ " ],\n" +
+ " \"name_of_the_leaf28\": \"abc\",\n" +
+ " \"name_of_the_list9\": [\n" +
+ " {\n" +
+ " \"name_of_the_leaf27\": \"abc\"\n" +
+ " },\n" +
+ " {\n" +
+ " \"name_of_the_leaf27\": \"abc\"\n" +
+ " }\n" +
+ " ]\n" +
+ " },\n" +
+ " \"name_of_the_leaf30\": \"abc\",\n" +
+ " \"name_of_the_ll10\": [\n" +
+ " \"abc\",\n" +
+ " \"abc\"\n" +
+ " ],\n" +
+ " \"name_of_the_list10\": [\n" +
+ " {\n" +
+ " \"name_of_the_leaf29\": \"abc\"\n" +
+ " },\n" +
+ " {\n" +
+ " \"name_of_the_leaf29\": \"abc\"\n" +
+ " }\n" +
+ " ],\n" +
+ " \"name_of_the_cont15\": {\n" +
+ " \"name_of_the_leaf31\": \"abc\"\n" +
+ " }\n" +
+ " }\n" +
+ "}";
+
+ static final String DECODE_FROM_JSON_RPC_ID = "{\n" +
+ " \"test_name_of_the_module:output\": {\n" +
+ " \"name_of_the_cont16\": {\n" +
+ " \"name_of_the_leaf32\": \"abc\"\n" +
+ " },\n" +
+ " \"name_of_the_list11\": [\n" +
+ " {\n" +
+ " \"name_of_the_leaf33\": \"abc\"\n" +
+ " },\n" +
+ " {\n" +
+ " \"name_of_the_leaf33\": \"abc\"\n" +
+ " }\n" +
+ " ],\n" +
+ " \"name_of_the_leaf34\": \"abc\",\n" +
+ " \"name_of_the_ll11\": [\n" +
+ " \"abc\",\n" +
+ " \"abc\"\n" +
+ " ],\n" +
+ " \"name_of_the_cont17\": {\n" +
+ " \"name_of_the_leaf35\": \"abc\"\n" +
+ " },\n" +
+ " \"name_of_the_cont13\": {\n" +
+ " \"name_of_the_cont12\": {\n" +
+ " \"name_of_the_leaf26\": \"abc\"\n" +
+ " },\n" +
+ " \"name_of_the_list9\": [\n" +
+ " {\n" +
+ " \"name_of_the_leaf27\": \"abc\"\n" +
+ " },\n" +
+ " {\n" +
+ " \"name_of_the_leaf27\": \"abc\"\n" +
+ " }\n" +
+ " ],\n" +
+ " \"name_of_the_ll9\": [\n" +
+ " \"abc\",\n" +
+ " \"abc\"\n" +
+ " ],\n" +
+ " \"name_of_the_leaf28\": \"abc\"\n" +
+ " }\n" +
+ " }\n" +
+ "}";
+
+ static final String ENCODE_TO_XML_RPC_ID = "<?xml version=\"1.0\" " +
+ "encoding=\"UTF-8\" standalone=\"no\"?>\n" +
+ "<input xmlns=\"urn:opendaylight:params:xml:ns:yang:test:name\"" +
+ ">\n" +
+ " <name_of_the_cont14>\n" +
+ " <name_of_the_leaf28>abc</name_of_the_leaf28>\n" +
+ " </name_of_the_cont14>\n" +
+ " <name_of_the_cont13>\n" +
+ " <name_of_the_ll9>abc</name_of_the_ll9>\n" +
+ " <name_of_the_ll9>abc</name_of_the_ll9>\n" +
+ " <name_of_the_leaf28>abc</name_of_the_leaf28>\n" +
+ " <name_of_the_list9>\n" +
+ " <name_of_the_leaf27>abc</name_of_the_leaf27>\n" +
+ " </name_of_the_list9>\n" +
+ " <name_of_the_list9>\n" +
+ " <name_of_the_leaf27>abc</name_of_the_leaf27>\n" +
+ " </name_of_the_list9>\n" +
+ " </name_of_the_cont13>\n" +
+ " <name_of_the_leaf30>abc</name_of_the_leaf30>\n" +
+ " <name_of_the_ll10>abc</name_of_the_ll10>\n" +
+ " <name_of_the_ll10>abc</name_of_the_ll10>\n" +
+ " <name_of_the_list10>\n" +
+ " <name_of_the_leaf29>abc</name_of_the_leaf29>\n" +
+ " </name_of_the_list10>\n" +
+ " <name_of_the_list10>\n" +
+ " <name_of_the_leaf29>abc</name_of_the_leaf29>\n" +
+ " </name_of_the_list10>\n" +
+ " <name_of_the_cont15>\n" +
+ " <name_of_the_leaf31>abc</name_of_the_leaf31>\n" +
+ " </name_of_the_cont15>\n" +
+ "</input>\n";
+
+ static final String DECODE_FROM_XML_RPC_ID = "<?xml version=\"1.0\" " +
+ "encoding=\"UTF-8\" standalone=\"no\"?>\n" +
+ "<output xmlns=\"urn:opendaylight:params:xml:ns:yang:test:name" +
+ "\">\n" +
+ " <name_of_the_cont16>\n" +
+ " <name_of_the_leaf32>abc</name_of_the_leaf32>\n" +
+ " </name_of_the_cont16>\n" +
+ " <name_of_the_list11>\n" +
+ " <name_of_the_leaf33>abc</name_of_the_leaf33>\n" +
+ " </name_of_the_list11>\n" +
+ " <name_of_the_list11>\n" +
+ " <name_of_the_leaf33>abc</name_of_the_leaf33>\n" +
+ " </name_of_the_list11>\n" +
+ " <name_of_the_leaf34>abc</name_of_the_leaf34>\n" +
+ " <name_of_the_ll11>abc</name_of_the_ll11>\n" +
+ " <name_of_the_ll11>abc</name_of_the_ll11>\n" +
+ " <name_of_the_cont17>\n" +
+ " <name_of_the_leaf35>abc</name_of_the_leaf35>\n" +
+ " </name_of_the_cont17>\n" +
+ " <name_of_the_cont13>\n" +
+ " <name_of_the_cont12>\n" +
+ " <name_of_the_leaf26>abc</name_of_the_leaf26>\n" +
+ " </name_of_the_cont12>\n" +
+ " <name_of_the_list9>\n" +
+ " <name_of_the_leaf27>abc</name_of_the_leaf27>\n" +
+ " </name_of_the_list9>\n" +
+ " <name_of_the_list9>\n" +
+ " <name_of_the_leaf27>abc</name_of_the_leaf27>\n" +
+ " </name_of_the_list9>\n" +
+ " <name_of_the_ll9>abc</name_of_the_ll9>\n" +
+ " <name_of_the_ll9>abc</name_of_the_ll9>\n" +
+ " <name_of_the_leaf28>abc</name_of_the_leaf28>\n" +
+ " </name_of_the_cont13>\n" +
+ "</output>";
+}
diff --git a/restconf-client/provider/src/test/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/PropertiesSerializerTest.java b/restconf-client/provider/src/test/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/PropertiesSerializerTest.java
index dc0da6f7..c3a6b4ea 100644
--- a/restconf-client/provider/src/test/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/PropertiesSerializerTest.java
+++ b/restconf-client/provider/src/test/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/PropertiesSerializerTest.java
@@ -19,15 +19,6 @@
*/
package org.onap.ccsdk.sli.plugins.yangserializers.pnserializer;
-import org.junit.Before;
-import org.junit.Test;
-
-import org.onap.ccsdk.sli.core.sli.SvcLogicException;
-import org.opendaylight.restconf.common.context.InstanceIdentifierContext;
-import org.opendaylight.restconf.nb.rfc8040.utils.parser.ParserIdentifier;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
-
import java.io.File;
import java.io.FileNotFoundException;
import java.util.ArrayList;
@@ -37,6 +28,14 @@ import java.util.LinkedList;
import java.util.List;
import java.util.Map;
+import org.junit.Before;
+import org.junit.Test;
+import org.onap.ccsdk.sli.core.sli.SvcLogicException;
+import org.opendaylight.restconf.common.context.InstanceIdentifierContext;
+import org.opendaylight.restconf.nb.rfc8040.utils.parser.ParserIdentifier;
+import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
+
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
import static org.junit.Assert.assertTrue;
@@ -53,39 +52,39 @@ public final class PropertiesSerializerTest {
public void testBasicConstructs() throws SvcLogicException {
String uri = "test-yang:cont1/cont2";
Map<String, String> params = new HashMap<>();
- params.put("test-yang:cont1.cont2.cont3.leaf10", "abc");
- params.put("test-yang:cont1.cont2.list1[0].leaf1", "abc");
- params.put("test-yang:cont1.cont2.list1[0].leaf2", "abc");
- params.put("test-yang:cont1.cont2.list1[0].leaf3", "abc");
- params.put("test-yang:cont1.cont2.list1[0].ll1[0]", "abc");
- params.put("test-yang:cont1.cont2.list1[0].ll1[1]", "abc");
- params.put("test-yang:cont1.cont2.list1[0].ll2[0]", "abc");
- params.put("test-yang:cont1.cont2.list1[0].ll2[1]", "abc");
- params.put("test-yang:cont1.cont2.list1[0].cont4.leaf11", "abc");
- params.put("test-yang:cont1.cont2.list1[0].list4[0].leaf8", "abc");
- params.put("test-yang:cont1.cont2.list1[0].list4[1].leaf8", "abc");
- params.put("test-yang:cont1.cont2.list1[0].list5[0].leaf9", "abc");
- params.put("test-yang:cont1.cont2.list1[0].list5[1].leaf9", "abc");
- params.put("test-yang:cont1.cont2.list1[1].leaf1", "abc");
- params.put("test-yang:cont1.cont2.list1[1].leaf2", "abc");
- params.put("test-yang:cont1.cont2.list1[1].leaf3", "abc");
- params.put("test-yang:cont1.cont2.list1[1].ll1[0]", "abc");
- params.put("test-yang:cont1.cont2.list1[1].ll1[1]", "abc");
- params.put("test-yang:cont1.cont2.list1[1].ll2[0]", "abc");
- params.put("test-yang:cont1.cont2.list1[1].ll2[1]", "abc");
- params.put("test-yang:cont1.cont2.list1[1].cont4.leaf11", "abc");
- params.put("test-yang:cont1.cont2.list1[1].list4[0].leaf8", "abc");
- params.put("test-yang:cont1.cont2.list1[1].list4[1].leaf8", "abc");
- params.put("test-yang:cont1.cont2.list1[1].list5[0].leaf9", "abc");
- params.put("test-yang:cont1.cont2.list1[1].list5[1].leaf9", "abc");
- params.put("test-yang:cont1.cont2.list2[0].leaf4", "abc");
- params.put("test-yang:cont1.cont2.list2[1].leaf4", "abc");
- params.put("test-yang:cont1.cont2.leaf5", "abc");
- params.put("test-yang:cont1.cont2.leaf6", "abc");
- params.put("test-yang:cont1.cont2.ll3[0]", "abc");
- params.put("test-yang:cont1.cont2.ll3[1]", "abc");
- params.put("test-yang:cont1.cont2.ll4[0]", "abc");
- params.put("test-yang:cont1.cont2.ll4[1]", "abc");
+ params.put("test-yang_cont1.cont2.cont3.leaf10", "abc");
+ params.put("test-yang_cont1.cont2.list1[0].leaf1", "abc");
+ params.put("test-yang_cont1.cont2.list1[0].leaf2", "abc");
+ params.put("test-yang_cont1.cont2.list1[0].leaf3", "abc");
+ params.put("test-yang_cont1.cont2.list1[0].ll1[0]", "abc");
+ params.put("test-yang_cont1.cont2.list1[0].ll1[1]", "abc");
+ params.put("test-yang_cont1.cont2.list1[0].ll2[0]", "abc");
+ params.put("test-yang_cont1.cont2.list1[0].ll2[1]", "abc");
+ params.put("test-yang_cont1.cont2.list1[0].cont4.leaf11", "abc");
+ params.put("test-yang_cont1.cont2.list1[0].list4[0].leaf8", "abc");
+ params.put("test-yang_cont1.cont2.list1[0].list4[1].leaf8", "abc");
+ params.put("test-yang_cont1.cont2.list1[0].list5[0].leaf9", "abc");
+ params.put("test-yang_cont1.cont2.list1[0].list5[1].leaf9", "abc");
+ params.put("test-yang_cont1.cont2.list1[1].leaf1", "abc");
+ params.put("test-yang_cont1.cont2.list1[1].leaf2", "abc");
+ params.put("test-yang_cont1.cont2.list1[1].leaf3", "abc");
+ params.put("test-yang_cont1.cont2.list1[1].ll1[0]", "abc");
+ params.put("test-yang_cont1.cont2.list1[1].ll1[1]", "abc");
+ params.put("test-yang_cont1.cont2.list1[1].ll2[0]", "abc");
+ params.put("test-yang_cont1.cont2.list1[1].ll2[1]", "abc");
+ params.put("test-yang_cont1.cont2.list1[1].cont4.leaf11", "abc");
+ params.put("test-yang_cont1.cont2.list1[1].list4[0].leaf8", "abc");
+ params.put("test-yang_cont1.cont2.list1[1].list4[1].leaf8", "abc");
+ params.put("test-yang_cont1.cont2.list1[1].list5[0].leaf9", "abc");
+ params.put("test-yang_cont1.cont2.list1[1].list5[1].leaf9", "abc");
+ params.put("test-yang_cont1.cont2.list2[0].leaf4", "abc");
+ params.put("test-yang_cont1.cont2.list2[1].leaf4", "abc");
+ params.put("test-yang_cont1.cont2.leaf5", "abc");
+ params.put("test-yang_cont1.cont2.leaf6", "abc");
+ params.put("test-yang_cont1.cont2.ll3[0]", "abc");
+ params.put("test-yang_cont1.cont2.ll3[1]", "abc");
+ params.put("test-yang_cont1.cont2.ll4[0]", "abc");
+ params.put("test-yang_cont1.cont2.ll4[1]", "abc");
InstanceIdentifierContext<?> iCtx = ParserIdentifier
.toInstanceIdentifier(uri, context, null);
@@ -283,18 +282,18 @@ public final class PropertiesSerializerTest {
public void testAugment() throws SvcLogicException {
String uri = "test-yang:cont1/cont2";
Map<String, String> params = new HashMap<>();
- params.put("test-yang:cont1.cont2.cont4.leaf10", "abc");
- params.put("test-yang:cont1.cont2.cont4.test-augment:cont5.leaf13", "abc");
- params.put("test-yang:cont1.cont2.cont4.test-augment:list7[0].leaf14", "abc");
- params.put("test-yang:cont1.cont2.cont4.test-augment:list7[1].leaf14", "abc");
- params.put("test-yang:cont1.cont2.cont4.test-augment:leaf15", "abc");
- params.put("test-yang:cont1.cont2.cont4.test-augment:ll6[0]", "abc");
- params.put("test-yang:cont1.cont2.cont4.test-augment:ll6[1]", "abc");
- params.put("test-yang:cont1.cont2.list6[0].leaf11", "abc");
- params.put("test-yang:cont1.cont2.list6[1].leaf11", "abc");
- params.put("test-yang:cont1.cont2.leaf12", "abc");
- params.put("test-yang:cont1.cont2.ll5[0]", "abc");
- params.put("test-yang:cont1.cont2.ll5[1]", "abc");
+ params.put("test-yang_cont1.cont2.cont4.leaf10", "abc");
+ params.put("test-yang_cont1.cont2.cont4.test-augment_cont5.leaf13", "abc");
+ params.put("test-yang_cont1.cont2.cont4.test-augment_list7[0].leaf14", "abc");
+ params.put("test-yang_cont1.cont2.cont4.test-augment_list7[1].leaf14", "abc");
+ params.put("test-yang_cont1.cont2.cont4.test-augment_leaf15", "abc");
+ params.put("test-yang_cont1.cont2.cont4.test-augment_ll6[0]", "abc");
+ params.put("test-yang_cont1.cont2.cont4.test-augment_ll6[1]", "abc");
+ params.put("test-yang_cont1.cont2.list6[0].leaf11", "abc");
+ params.put("test-yang_cont1.cont2.list6[1].leaf11", "abc");
+ params.put("test-yang_cont1.cont2.leaf12", "abc");
+ params.put("test-yang_cont1.cont2.ll5[0]", "abc");
+ params.put("test-yang_cont1.cont2.ll5[1]", "abc");
InstanceIdentifierContext<?> iCtx = ParserIdentifier
.toInstanceIdentifier(uri, context, null);
@@ -397,12 +396,12 @@ public final class PropertiesSerializerTest {
public void testChoiceCase1() throws SvcLogicException {
String uri = "test-yang:cont8";
Map<String, String> params = new HashMap<>();
- params.put("test-yang:cont8.cont6.leaf16", "abc");
- params.put("test-yang:cont8.list8[0].leaf18", "abc");
- params.put("test-yang:cont8.list8[1].leaf18", "abc");
- params.put("test-yang:cont8.leaf19", "abc");
- params.put("test-yang:cont8.ll7[0]", "abc");
- params.put("test-yang:cont8.ll7[1]", "abc");
+ params.put("test-yang_cont8.cont6.leaf16", "abc");
+ params.put("test-yang_cont8.list8[0].leaf18", "abc");
+ params.put("test-yang_cont8.list8[1].leaf18", "abc");
+ params.put("test-yang_cont8.leaf19", "abc");
+ params.put("test-yang_cont8.ll7[0]", "abc");
+ params.put("test-yang_cont8.ll7[1]", "abc");
InstanceIdentifierContext<?> iCtx = ParserIdentifier
.toInstanceIdentifier(uri, context, null);
@@ -459,9 +458,9 @@ public final class PropertiesSerializerTest {
public void testChoiceCase2() throws SvcLogicException {
String uri = "test-yang:cont9";
Map<String, String> params = new HashMap<>();
- params.put("test-yang:cont9.leaf20", "abc");
- params.put("test-yang:cont9.ll8[0]", "abc");
- params.put("test-yang:cont9.cont11.leaf25", "abc");
+ params.put("test-yang_cont9.leaf20", "abc");
+ params.put("test-yang_cont9.ll8[0]", "abc");
+ params.put("test-yang_cont9.cont11.leaf25", "abc");
InstanceIdentifierContext<?> iCtx = ParserIdentifier
.toInstanceIdentifier(uri, context, null);
@@ -499,7 +498,7 @@ public final class PropertiesSerializerTest {
public void testChoiceCase3() throws SvcLogicException {
String uri = "test-yang:cont8/cont6";
Map<String, String> params = new HashMap<>();
- params.put("test-yang:cont8.cont6.test-augment:leaf21", "abc");
+ params.put("test-yang_cont8.cont6.test-augment_leaf21", "abc");
InstanceIdentifierContext<?> iCtx = ParserIdentifier
.toInstanceIdentifier(uri, context, null);
@@ -538,10 +537,10 @@ public final class PropertiesSerializerTest {
public void testGrouping() throws SvcLogicException {
String uri = "test-yang:cont13";
Map<String, String> params = new HashMap<>();
- params.put("test-yang:cont13.cont12.leaf26", "abc");
- params.put("test-yang:cont13.list9[0].leaf27", "abc");
- params.put("test-yang:cont13.leaf28", "abc");
- params.put("test-yang:cont13.ll9[0]", "abc");
+ params.put("test-yang_cont13.cont12.leaf26", "abc");
+ params.put("test-yang_cont13.list9[0].leaf27", "abc");
+ params.put("test-yang_cont13.leaf28", "abc");
+ params.put("test-yang_cont13.ll9[0]", "abc");
InstanceIdentifierContext<?> iCtx = ParserIdentifier
.toInstanceIdentifier(uri, context, null);
@@ -587,11 +586,11 @@ public final class PropertiesSerializerTest {
public void testGrouping2() throws SvcLogicException {
String uri = "test-yang:cont9/cont11";
Map<String, String> params = new HashMap<>();
- params.put("test-yang:cont9.cont11.leaf25", "abc");
- params.put("test-yang:cont9.cont11.cont13.cont12.leaf26", "abc");
- params.put("test-yang:cont9.cont11.cont13.list9[0].leaf27", "abc");
- params.put("test-yang:cont9.cont11.cont13.leaf28", "abc");
- params.put("test-yang:cont9.cont11.cont13.ll9[0]", "abc");
+ params.put("test-yang_cont9.cont11.leaf25", "abc");
+ params.put("test-yang_cont9.cont11.cont13.cont12.leaf26", "abc");
+ params.put("test-yang_cont9.cont11.cont13.list9[0].leaf27", "abc");
+ params.put("test-yang_cont9.cont11.cont13.leaf28", "abc");
+ params.put("test-yang_cont9.cont11.cont13.ll9[0]", "abc");
InstanceIdentifierContext<?> iCtx = ParserIdentifier
.toInstanceIdentifier(uri, context, null);
PropertiesNodeSerializer ser = new MdsalPropertiesNodeSerializer(
@@ -642,10 +641,10 @@ public final class PropertiesSerializerTest {
public void testGrouping3() throws SvcLogicException {
String uri = "test-augment:cont13";
Map<String, String> params = new HashMap<>();
- params.put("test-augment:cont13.cont12.leaf26", "abc");
- params.put("test-augment:cont13.list9[0].leaf27", "abc");
- params.put("test-augment:cont13.leaf28", "abc");
- params.put("test-augment:cont13.ll9[0]", "abc");
+ params.put("test-augment_cont13.cont12.leaf26", "abc");
+ params.put("test-augment_cont13.list9[0].leaf27", "abc");
+ params.put("test-augment_cont13.leaf28", "abc");
+ params.put("test-augment_cont13.ll9[0]", "abc");
InstanceIdentifierContext<?> iCtx = ParserIdentifier
.toInstanceIdentifier(uri, context, null);
PropertiesNodeSerializer ser = new MdsalPropertiesNodeSerializer(
@@ -693,10 +692,10 @@ public final class PropertiesSerializerTest {
public void testGrouping4() throws SvcLogicException {
String uri = "test-yang:cont1/cont2/cont4";
Map<String, String> params = new HashMap<>();
- params.put("test-yang:cont1.cont2.cont4.test-augment:cont13.cont12.leaf26", "abc");
- params.put("test-yang:cont1.cont2.cont4.test-augment:cont13.list9[0].leaf27", "abc");
- params.put("test-yang:cont1.cont2.cont4.test-augment:cont13.leaf28", "abc");
- params.put("test-yang:cont1.cont2.cont4.test-augment:cont13.ll9[0]", "abc");
+ params.put("test-yang_cont1.cont2.cont4.test-augment_cont13.cont12.leaf26", "abc");
+ params.put("test-yang_cont1.cont2.cont4.test-augment_cont13.list9[0].leaf27", "abc");
+ params.put("test-yang_cont1.cont2.cont4.test-augment_cont13.leaf28", "abc");
+ params.put("test-yang_cont1.cont2.cont4.test-augment_cont13.ll9[0]", "abc");
InstanceIdentifierContext<?> iCtx = ParserIdentifier
.toInstanceIdentifier(uri, context, null);
@@ -755,16 +754,16 @@ public final class PropertiesSerializerTest {
public void testRpcInput() throws SvcLogicException {
String uri = "test-yang:create-sfc";
Map<String, String> params = new HashMap<>();
- params.put("test-yang:create-sfc.input.cont14.leaf28", "abc");
- params.put("test-yang:create-sfc.input.list10[0].leaf29", "abc");
- params.put("test-yang:create-sfc.input.leaf30", "abc");
- params.put("test-yang:create-sfc.input.ll10[0]", "abc");
- params.put("test-yang:create-sfc.input.cont15.leaf31", "abc");
- params.put("test-yang:create-sfc.input.cont13.cont12.leaf26", "abc");
- params.put("test-yang:create-sfc.input.cont13.list9[0].leaf27", "abc");
- params.put("test-yang:create-sfc.input.cont13.leaf28", "abc");
- params.put("test-yang:create-sfc.input.cont13.ll9[0]", "abc");
- params.put("test-yang:create-sfc.input.test-augment:leaf36", "abc");
+ params.put("test-yang_create-sfc.input.cont14.leaf28", "abc");
+ params.put("test-yang_create-sfc.input.list10[0].leaf29", "abc");
+ params.put("test-yang_create-sfc.input.leaf30", "abc");
+ params.put("test-yang_create-sfc.input.ll10[0]", "abc");
+ params.put("test-yang_create-sfc.input.cont15.leaf31", "abc");
+ params.put("test-yang_create-sfc.input.cont13.cont12.leaf26", "abc");
+ params.put("test-yang_create-sfc.input.cont13.list9[0].leaf27", "abc");
+ params.put("test-yang_create-sfc.input.cont13.leaf28", "abc");
+ params.put("test-yang_create-sfc.input.cont13.ll9[0]", "abc");
+ params.put("test-yang_create-sfc.input.test-augment_leaf36", "abc");
InstanceIdentifierContext<?> iCtx = ParserIdentifier
.toInstanceIdentifier(uri, context, null);
@@ -869,16 +868,16 @@ public final class PropertiesSerializerTest {
public void testRpcOutput() throws SvcLogicException {
String uri = "test-yang:create-sfc";
Map<String, String> params = new HashMap<>();
- params.put("test-yang:create-sfc.output.cont16.leaf32", "abc");
- params.put("test-yang:create-sfc.output.list11[0].leaf33", "abc");
- params.put("test-yang:create-sfc.output.leaf34", "abc");
- params.put("test-yang:create-sfc.output.ll11[0]", "abc");
- params.put("test-yang:create-sfc.output.cont17.leaf35", "abc");
- params.put("test-yang:create-sfc.output.cont13.cont12.leaf26", "abc");
- params.put("test-yang:create-sfc.output.cont13.list9[0].leaf27", "abc");
- params.put("test-yang:create-sfc.output.cont13.leaf28", "abc");
- params.put("test-yang:create-sfc.output.cont13.ll9[0]", "abc");
- params.put("test-yang:create-sfc.output.test-augment:leaf37", "abc");
+ params.put("test-yang_create-sfc.output.cont16.leaf32", "abc");
+ params.put("test-yang_create-sfc.output.list11[0].leaf33", "abc");
+ params.put("test-yang_create-sfc.output.leaf34", "abc");
+ params.put("test-yang_create-sfc.output.ll11[0]", "abc");
+ params.put("test-yang_create-sfc.output.cont17.leaf35", "abc");
+ params.put("test-yang_create-sfc.output.cont13.cont12.leaf26", "abc");
+ params.put("test-yang_create-sfc.output.cont13.list9[0].leaf27", "abc");
+ params.put("test-yang_create-sfc.output.cont13.leaf28", "abc");
+ params.put("test-yang_create-sfc.output.cont13.ll9[0]", "abc");
+ params.put("test-yang_create-sfc.output.test-augment_leaf37", "abc");
InstanceIdentifierContext<?> iCtx = ParserIdentifier
.toInstanceIdentifier(uri, context, null);
@@ -983,10 +982,10 @@ public final class PropertiesSerializerTest {
public void testContainerSameName() throws SvcLogicException {
String uri = "test-yang:cont18";
Map<String, String> params = new HashMap<>();
- params.put("test-yang:cont18.cont18.list12[0].list12[0].leaf36", "abc");
- params.put("test-yang:cont18.cont18.list12[0].leaf36", "hi");
- params.put("test-yang:cont18.cont18.list12[1].list12[0].leaf36", "xyz");
- params.put("test-yang:cont18.cont18.list12[1].list12[1].leaf36", "hey!");
+ params.put("test-yang_cont18.cont18.list12[0].list12[0].leaf36", "abc");
+ params.put("test-yang_cont18.cont18.list12[0].leaf36", "hi");
+ params.put("test-yang_cont18.cont18.list12[1].list12[0].leaf36", "xyz");
+ params.put("test-yang_cont18.cont18.list12[1].list12[1].leaf36", "hey!");
InstanceIdentifierContext<?> iCtx = ParserIdentifier
.toInstanceIdentifier(uri, context, null);
@@ -1055,9 +1054,9 @@ public final class PropertiesSerializerTest {
public void testPropertiesWithoutSchema() throws SvcLogicException {
String uri = "test-yang:cont18";
Map<String, String> params = new HashMap<>();
- params.put("test-yang:cont18.leaf40", "abc");
+ params.put("test-yang_cont18.leaf40", "abc");
params.put("leaf41", "hi");
- params.put("test-yang:cont18.leaf41", "abc");
+ params.put("test-yang_cont18.leaf41", "abc");
InstanceIdentifierContext<?> iCtx = ParserIdentifier
.toInstanceIdentifier(uri, context, null);
@@ -1075,11 +1074,12 @@ public final class PropertiesSerializerTest {
public void testIdentityRef() throws SvcLogicException {
String uri = "identity-test:test";
Map<String, String> params = new HashMap<>();
- params.put("identity-test:test.con1.interface", "identity-types:physical");
- params.put("identity-test:test.con1.interfaces.int-list[0].iden", "identity-test:Giga");
- params.put("identity-test:test.con1.interfaces.int-list[0].available.ll[0]", "identity-types:Loopback");
- params.put("identity-test:test.con1.interfaces.int-list[0].available.leaf1", "identity-types-second:Ethernet");
- params.put("identity-test:test.con1.interfaces.int-list[0].available.leaf2", "identity-types-second:iden2");
+ params.put("identity-test_test.con1.interface", "identity-types" +
+ ":physical");
+ params.put("identity-test_test.con1.interfaces.int-list[0].iden", "identity-test:Giga");
+ params.put("identity-test_test.con1.interfaces.int-list[0].available.ll[0]", "identity-types:Loopback");
+ params.put("identity-test_test.con1.interfaces.int-list[0].available.leaf1", "identity-types-second:Ethernet");
+ params.put("identity-test_test.con1.interfaces.int-list[0].available.leaf2", "identity-types-second:iden2");
InstanceIdentifierContext<?> iCtx = ParserIdentifier
.toInstanceIdentifier(uri, context, null);
diff --git a/restconf-client/provider/src/test/resources/yang/test_augment_1_for_module.yang b/restconf-client/provider/src/test/resources/yang/test_augment_1_for_module.yang
new file mode 100644
index 00000000..d2eeea7d
--- /dev/null
+++ b/restconf-client/provider/src/test/resources/yang/test_augment_1_for_module.yang
@@ -0,0 +1,108 @@
+module test_augment_1_for_module {
+ yang-version 1;
+ namespace "urn:opendaylight:params:xml:ns:yang:test:augment:name";
+ prefix "augment-name";
+
+ import test_name_of_the_module {
+ prefix aug;
+ }
+
+ revision "2015-01-05" {
+ description "Initial revision of hello model";
+ }
+
+ augment "/aug:name_of_the_cont1/aug:name_of_the_cont2/aug:name_of_the_cont4" {
+ container name_of_the_cont5 {
+ leaf name_of_the_leaf13 {
+ type empty;
+ }
+ }
+ list name_of_the_list7 {
+ leaf name_of_the_leaf14 {
+ type instance-identifier;
+ }
+ }
+ leaf name_of_the_leaf15 {
+ type string;
+ }
+ leaf-list name_of_the_ll6 {
+ type union {
+ type int32;
+ type enumeration {
+ enum "unbounded";
+ }
+ }
+ }
+ uses "aug:name_of_the_g1";
+ }
+
+ uses "aug:name_of_the_g1";
+
+ augment "/aug:name_of_the_cont1/aug:name_of_the_cont2/aug:name_of_the_cont3" {
+ choice name_of_the_ch2 {
+ case name_of_the_c3 {
+ leaf name_of_the_leaf21 {
+ type string;
+ }
+ }
+ case name_of_the_c4 {
+ leaf name_of_the_leaf22 {
+ type enumeration {
+ enum zero;
+ enum one;
+ enum seven {
+ value 7;
+ }
+ }
+ }
+ }
+ }
+ }
+
+ augment "/aug:name_of_the_ch1" {
+ case name_of_the_c5 {
+ container name_of_the_cont10 {
+ leaf name_of_the_leaf23 {
+ type string;
+ }
+ }
+ }
+ }
+
+ augment "/aug:name_of_the_ch1/aug:name_of_the_c1" {
+ container name_of_the_cont7 {
+ leaf name_of_the_leaf24 {
+ type string;
+ }
+ }
+ }
+
+ augment "/aug:name_of_the_cont13/aug:name_of_the_cont12" {
+ leaf name_of_the_leaf29 {
+ type string;
+ }
+ }
+
+ augment "/aug:name_of_the_create-sfc/aug:input" {
+ leaf name_of_the_leaf36 {
+ type bits {
+ bit angle {
+ position 0;
+ }
+ bit degree {
+ position 1;
+ }
+ bit movement {
+ position 2;
+ }
+ }
+ }
+ }
+
+ augment "/aug:name_of_the_create-sfc/aug:output" {
+ leaf leaf37 {
+ type boolean;
+ }
+ }
+
+} \ No newline at end of file
diff --git a/restconf-client/provider/src/test/resources/yang/test_name_of_the_module.yang b/restconf-client/provider/src/test/resources/yang/test_name_of_the_module.yang
new file mode 100644
index 00000000..973475ee
--- /dev/null
+++ b/restconf-client/provider/src/test/resources/yang/test_name_of_the_module.yang
@@ -0,0 +1,231 @@
+module test_name_of_the_module {
+ yang-version 1;
+ namespace "urn:opendaylight:params:xml:ns:yang:test:name";
+ prefix "name";
+
+ revision "2015-01-05" {
+ description "Initial revision of hello model";
+ }
+
+ container name_of_the_cont1 {
+ container name_of_the_cont2 {
+ container name_of_the_cont3 {
+ leaf name_of_the_leaf10 {
+ type string;
+ }
+ }
+ list name_of_the_list1 {
+ key "name_of_the_leaf1 name_of_the_leaf2";
+ leaf name_of_the_leaf1 {
+ type empty;
+ }
+ leaf name_of_the_leaf2 {
+ type string;
+ }
+ leaf name_of_the_leaf3 {
+ type string;
+ }
+ leaf-list name_of_the_ll1 {
+ type string;
+ }
+ leaf-list name_of_the_ll2 {
+ type string;
+ }
+ container name_of_the_cont4 {
+ leaf name_of_the_leaf11 {
+ type string;
+ }
+ }
+ list name_of_the_list4 {
+ leaf name_of_the_leaf8 {
+ type string;
+ }
+ }
+ list name_of_the_list5 {
+ leaf name_of_the_leaf9 {
+ type string;
+ }
+ }
+ }
+ list name_of_the_list2 {
+ leaf name_of_the_leaf4 {
+ type string;
+ }
+ }
+ leaf name_of_the_leaf5 {
+ type string;
+ }
+ leaf name_of_the_leaf6 {
+ type string;
+ }
+ leaf-list name_of_the_ll3 {
+ type string;
+ }
+ leaf-list name_of_the_ll4 {
+ type string;
+ }
+ }
+ }
+
+ augment "/name_of_the_cont1/name_of_the_cont2" {
+ container name_of_the_cont4 {
+ leaf name_of_the_leaf10 {
+ type string;
+ }
+ }
+ list name_of_the_list6 {
+ leaf name_of_the_leaf11 {
+ type string;
+ }
+ }
+ leaf name_of_the_leaf12 {
+ type string;
+ }
+ leaf-list name_of_the_ll5 {
+ type string;
+ }
+ }
+
+ choice name_of_the_ch1 {
+ case name_of_the_c1 {
+ container name_of_the_cont8 {
+ container name_of_the_cont6 {
+ leaf name_of_the_leaf16 {
+ type string;
+ }
+ }
+ list name_of_the_list8 {
+ leaf name_of_the_leaf18 {
+ type string;
+ }
+ }
+ leaf name_of_the_leaf19 {
+ type string;
+ }
+ leaf-list name_of_the_ll7 {
+ type string;
+ }
+ }
+ }
+ case name_of_the_c2 {
+ container name_of_the_cont9 {
+ leaf name_of_the_leaf20 {
+ type string;
+ }
+ leaf-list name_of_the_ll8 {
+ type string;
+ }
+ container name_of_the_cont11 {
+ choice name_of_the_ch3 {
+ case name_of_the_c1 {
+ leaf name_of_the_leaf25 {
+ type string;
+ }
+ uses name_of_the_g1;
+ }
+ }
+ }
+ }
+ }
+ }
+
+ grouping name_of_the_g1 {
+ container name_of_the_cont13 {
+ container name_of_the_cont12 {
+ leaf name_of_the_leaf26 {
+ type string;
+ }
+ }
+ list name_of_the_list9 {
+ leaf name_of_the_leaf27 {
+ type string;
+ }
+ }
+ leaf name_of_the_leaf28 {
+ type string;
+ }
+ leaf-list name_of_the_ll9 {
+ type string;
+ }
+ }
+ }
+
+ uses name_of_the_g1;
+
+ rpc name_of_the_create-sfc {
+ input {
+ container name_of_the_cont14 {
+ leaf name_of_the_leaf28 {
+ type string;
+ }
+ }
+ list name_of_the_list10 {
+ leaf name_of_the_leaf29 {
+ type string;
+ }
+ }
+ leaf name_of_the_leaf30 {
+ type string;
+ }
+ leaf-list name_of_the_ll10 {
+ type string;
+ }
+ choice name_of_the_ch3 {
+ case name_of_the_c1 {
+ container name_of_the_cont15 {
+ leaf name_of_the_leaf31 {
+ type string;
+ }
+ }
+ }
+ }
+ uses name_of_the_g1;
+ }
+ output {
+ container name_of_the_cont16 {
+ leaf name_of_the_leaf32 {
+ type string;
+ }
+ }
+ list name_of_the_list11 {
+ leaf name_of_the_leaf33 {
+ type string;
+ }
+ }
+ leaf name_of_the_leaf34 {
+ type string;
+ }
+ leaf-list name_of_the_ll11 {
+ type string;
+ }
+ choice name_of_the_ch4 {
+ case name_of_the_c1 {
+ container name_of_the_cont17 {
+ leaf name_of_the_leaf35 {
+ type string;
+ }
+ }
+ }
+ }
+ uses name_of_the_g1;
+ }
+ }
+
+ container name_of_the_cont18 {
+ container name_of_the_cont18 {
+ list name_of_the_list12 {
+ list name_of_the_list12 {
+ leaf name_of_the_leaf36 {
+ type string;
+ }
+ }
+ leaf name_of_the_leaf36 {
+ type string;
+ }
+ }
+ }
+ leaf name_of_the_leaf40 {
+ type string;
+ }
+ }
+} \ No newline at end of file