summaryrefslogtreecommitdiffstats
path: root/plugins/properties-node/provider/src
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/properties-node/provider/src')
-rw-r--r--plugins/properties-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/prop/JsonParser.java94
-rw-r--r--plugins/properties-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/prop/Parameters.java31
-rw-r--r--plugins/properties-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/prop/PropertiesNode.java194
-rw-r--r--plugins/properties-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/prop/XmlParser.java176
-rwxr-xr-xplugins/properties-node/provider/src/main/resources/OSGI-INF/blueprint/properties-node-blueprint.xml16
-rwxr-xr-xplugins/properties-node/provider/src/main/resources/org/opendaylight/blueprint/properties-node-blueprint.xml16
-rw-r--r--plugins/properties-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/prop/TestJsonParser.java73
-rw-r--r--plugins/properties-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/prop/TestPropertiesNode.java608
-rw-r--r--plugins/properties-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/prop/TestXmlParser.java121
-rw-r--r--plugins/properties-node/provider/src/test/resources/invalidlength.xml49
-rw-r--r--plugins/properties-node/provider/src/test/resources/test30
-rw-r--r--plugins/properties-node/provider/src/test/resources/test-invalid.json29
-rw-r--r--plugins/properties-node/provider/src/test/resources/test-invalid.xml170
-rw-r--r--plugins/properties-node/provider/src/test/resources/test.json30
-rw-r--r--plugins/properties-node/provider/src/test/resources/test.txt31
-rw-r--r--plugins/properties-node/provider/src/test/resources/test.xml182
-rw-r--r--plugins/properties-node/provider/src/test/resources/test3.xml82
17 files changed, 1932 insertions, 0 deletions
diff --git a/plugins/properties-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/prop/JsonParser.java b/plugins/properties-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/prop/JsonParser.java
new file mode 100644
index 000000000..89243a055
--- /dev/null
+++ b/plugins/properties-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/prop/JsonParser.java
@@ -0,0 +1,94 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : SDN-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. 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.prop;
+
+import org.codehaus.jettison.json.JSONArray;
+import org.codehaus.jettison.json.JSONException;
+import org.codehaus.jettison.json.JSONObject;
+import org.onap.ccsdk.sli.core.sli.SvcLogicException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+public final class JsonParser {
+
+ private static final Logger log = LoggerFactory.getLogger(JsonParser.class);
+
+ private JsonParser() {
+ // Preventing instantiation of the same.
+ }
+
+ @SuppressWarnings("unchecked")
+ public static Map<String, String> convertToProperties(String s)
+ throws SvcLogicException {
+
+ checkNotNull(s, "Input should not be null.");
+
+ try {
+ JSONObject json = new JSONObject(s);
+ Map<String, Object> wm = new HashMap<>();
+ Iterator<String> ii = json.keys();
+ while (ii.hasNext()) {
+ String key1 = ii.next();
+ wm.put(key1, json.get(key1));
+ }
+
+ Map<String, String> mm = new HashMap<>();
+
+ while (!wm.isEmpty())
+ for (String key : new ArrayList<>(wm.keySet())) {
+ Object o = wm.get(key);
+ wm.remove(key);
+
+ if (o instanceof Boolean || o instanceof Number || o instanceof String) {
+ mm.put(key, o.toString());
+
+ log.info("Added property: {} : {}", key, o.toString());
+ } else if (o instanceof JSONObject) {
+ JSONObject jo = (JSONObject) o;
+ Iterator<String> i = jo.keys();
+ while (i.hasNext()) {
+ String key1 = i.next();
+ wm.put(key + "." + key1, jo.get(key1));
+ }
+ } else if (o instanceof JSONArray) {
+ JSONArray ja = (JSONArray) o;
+ mm.put(key + "_length", String.valueOf(ja.length()));
+
+ log.info("Added property: {}_length: {}", key, String.valueOf(ja.length()));
+
+ for (int i = 0; i < ja.length(); i++)
+ wm.put(key + '[' + i + ']', ja.get(i));
+ }
+ }
+ return mm;
+ } catch (JSONException e) {
+ throw new SvcLogicException("Unable to convert JSON to properties " + e.getLocalizedMessage(), e);
+ }
+ }
+}
diff --git a/plugins/properties-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/prop/Parameters.java b/plugins/properties-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/prop/Parameters.java
new file mode 100644
index 000000000..99e4647d7
--- /dev/null
+++ b/plugins/properties-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/prop/Parameters.java
@@ -0,0 +1,31 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : SDN-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. 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.prop;
+
+import java.util.Set;
+
+public class Parameters {
+ public String fileName;
+ public String contextPrefix;
+ public Set<String> listNameList;
+ public boolean fileBasedParsing;
+}
diff --git a/plugins/properties-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/prop/PropertiesNode.java b/plugins/properties-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/prop/PropertiesNode.java
new file mode 100644
index 000000000..b4bc84747
--- /dev/null
+++ b/plugins/properties-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/prop/PropertiesNode.java
@@ -0,0 +1,194 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : SDN-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. 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.prop;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Properties;
+import java.util.Set;
+import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
+import org.onap.ccsdk.sli.core.sli.SvcLogicException;
+import org.onap.ccsdk.sli.core.sli.SvcLogicJavaPlugin;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class PropertiesNode implements SvcLogicJavaPlugin {
+
+ private static final Logger log = LoggerFactory.getLogger(PropertiesNode.class);
+
+ public void readProperties(Map<String, String> paramMap, SvcLogicContext ctx) throws SvcLogicException {
+ Parameters param = getParameters(paramMap);
+ Properties prop = new Properties();
+ try {
+ File file = new File(param.fileName);
+ try (InputStream in = new FileInputStream(file)) {
+ Map<String, String> mm = null;
+ String pfx = param.contextPrefix != null ? param.contextPrefix + '.' : "";
+ if (param.fileBasedParsing) {
+ byte[] data = new byte[(int) file.length()];
+ if ("json".equalsIgnoreCase(getFileExtension(param.fileName))) {
+ in.read(data);
+ String str = new String(data, "UTF-8");
+ mm = JsonParser.convertToProperties(str);
+ } else if ("xml".equalsIgnoreCase(getFileExtension(param.fileName))) {
+ in.read(data);
+ String str = new String(data, "UTF-8");
+ mm = XmlParser.convertToProperties(str, param.listNameList);
+ } else {
+ prop.load(in);
+ for (Object key : prop.keySet()) {
+ String name = (String) key;
+ String value = prop.getProperty(name);
+ if (value != null && value.trim().length() > 0) {
+ ctx.setAttribute(pfx + name, getObfuscatedVal(value.trim()));
+ log.info("+++ " + pfx + name + ": [" + maskPassword(pfx + name, value) + "]");
+ }
+ }
+ }
+ if (mm != null) {
+ for (Map.Entry<String, String> entry : mm.entrySet()) {
+ ctx.setAttribute(pfx + entry.getKey(), getObfuscatedVal(entry.getValue()));
+ log.info("+++ " + pfx + entry.getKey() + ": ["
+ + maskPassword(pfx + entry.getKey(), entry.getValue()) + "]");
+ }
+ }
+ } else {
+ prop.load(in);
+ for (Object key : prop.keySet()) {
+ String name = (String) key;
+ String value = prop.getProperty(name);
+ if (value != null && value.trim().length() > 0) {
+ ctx.setAttribute(pfx + name, getObfuscatedVal(value.trim()));
+ log.info("+++ " + pfx + name + ": [" + maskPassword(pfx + name, value) + "]");
+ }
+ }
+ }
+ }
+ } catch (IOException e) {
+ throw new SvcLogicException("Cannot read property file: " + param.fileName + ": " + e.getMessage(), e);
+ }
+ }
+
+ /* Unobfuscate param value */
+ private static String getObfuscatedVal(String paramValue) {
+ String resValue = paramValue;
+ if (paramValue != null && paramValue.startsWith("${") && paramValue.endsWith("}"))
+ {
+ String paramStr = paramValue.substring(2, paramValue.length()-1);
+ if (paramStr != null && paramStr.length() > 0)
+ {
+ String val = System.getenv(paramStr);
+ if (val != null && val.length() > 0)
+ {
+ resValue=val;
+ log.info("Obfuscated value RESET for param value:" + paramValue);
+ }
+ }
+ }
+ return resValue;
+ }
+
+ /*
+ * Getting extension has to do the following "" --> "" "name" --> "" "name.txt" --> "txt"
+ * ".htpasswd" --> "" "name.with.many.dots.myext" --> "myext"
+ */
+ private static String getFileExtension(String fileName) {
+ if (fileName.lastIndexOf(".") != -1 && fileName.lastIndexOf(".") != 0) {
+ return fileName.substring(fileName.lastIndexOf(".") + 1);
+ } else {
+ return "";
+ }
+ }
+
+ protected Parameters getParameters(Map<String, String> paramMap) throws SvcLogicException {
+ Parameters p = new Parameters();
+ p.fileName = parseParam(paramMap, "fileName", true, null);
+ p.contextPrefix = parseParam(paramMap, "contextPrefix", false, null);
+ p.listNameList = getListNameList(paramMap);
+ String fileBasedParsingStr = paramMap.get("fileBasedParsing");
+ p.fileBasedParsing = "true".equalsIgnoreCase(fileBasedParsingStr);
+ return p;
+ }
+
+ protected Set<String> getListNameList(Map<String, String> paramMap) {
+ Set<String> ll = new HashSet<>();
+ for (Map.Entry<String, String> entry : paramMap.entrySet()) {
+ if (entry.getKey().startsWith("listName")) {
+ ll.add(entry.getValue());
+ }
+ }
+ return ll;
+ }
+
+ private String parseParam(Map<String, String> paramMap, String name, boolean required, String def)
+ throws SvcLogicException {
+ String s = paramMap.get(name);
+
+ if (s == null || s.trim().length() == 0) {
+ if (!required) {
+ return def;
+ }
+ throw new SvcLogicException("Parameter " + name + " is required in PropertiesNode");
+ }
+
+ s = s.trim();
+ String value = "";
+ int i = 0;
+ int i1 = s.indexOf('%');
+ while (i1 >= 0) {
+ int i2 = s.indexOf('%', i1 + 1);
+ if (i2 < 0) {
+ throw new SvcLogicException("Cannot parse parameter " + name + ": " + s + ": no matching %");
+ }
+
+ String varName = s.substring(i1 + 1, i2);
+ String varValue = System.getenv(varName);
+ if (varValue == null) {
+ varValue = "";
+ }
+
+ value += s.substring(i, i1);
+ value += varValue;
+
+ i = i2 + 1;
+ i1 = s.indexOf('%', i);
+ }
+ value += s.substring(i);
+
+ log.info("Parameter " + name + ": " + maskPassword(name, value));
+ return value;
+ }
+
+ private static Object maskPassword(String name, Object value) {
+ String[] pwdNames = {"pwd", "passwd", "password", "Pwd", "Passwd", "Password"};
+ for (String pwdName : pwdNames) {
+ if (name.contains(pwdName)) {
+ return "**********";
+ }
+ }
+ return value;
+ }
+}
diff --git a/plugins/properties-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/prop/XmlParser.java b/plugins/properties-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/prop/XmlParser.java
new file mode 100644
index 000000000..f48a21e9d
--- /dev/null
+++ b/plugins/properties-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/prop/XmlParser.java
@@ -0,0 +1,176 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : SDN-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. *
+ * Modifications Copyright © 2018 IBM.
+ * ================================================================================
+ * 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.prop;
+
+import org.onap.ccsdk.sli.core.sli.SvcLogicException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.xml.sax.Attributes;
+import org.xml.sax.SAXException;
+import org.xml.sax.helpers.DefaultHandler;
+
+import javax.xml.XMLConstants;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.parsers.SAXParser;
+import javax.xml.parsers.SAXParserFactory;
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+public final class XmlParser {
+
+ private static final Logger log = LoggerFactory.getLogger(XmlParser.class);
+
+ private XmlParser() {
+ // Preventing instantiation of the same.
+ }
+
+ public static Map<String, String> convertToProperties(String s, Set<String> listNameList)
+ throws SvcLogicException {
+
+ checkNotNull(s, "Input should not be null.");
+
+ Handler handler = new Handler(listNameList);
+ try {
+ SAXParserFactory factory = SAXParserFactory.newInstance();
+
+ factory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
+ factory.setFeature("http://xml.org/sax/features/external-general-entities", false);
+ factory.setFeature("http://xml.org/sax/features/external-parameter-entities", false);
+ SAXParser saxParser = factory.newSAXParser();
+ InputStream in = new ByteArrayInputStream(s.getBytes());
+ saxParser.parse(in, handler);
+ } catch (ParserConfigurationException | IOException | SAXException | NumberFormatException e) {
+ throw new SvcLogicException("Unable to convert XML to properties" + e.getLocalizedMessage(), e);
+ }
+ return handler.getProperties();
+ }
+
+ private static class Handler extends DefaultHandler {
+
+ private Set<String> listNameList;
+
+ private Map<String, String> properties = new HashMap<>();
+
+ StringBuilder currentName = new StringBuilder();
+ StringBuilder currentValue = new StringBuilder();
+
+ public Handler(Set<String> listNameList) {
+ super();
+ this.listNameList = listNameList;
+ if (this.listNameList == null)
+ this.listNameList = new HashSet<>();
+ }
+
+ public Map<String, String> getProperties() {
+ return properties;
+ }
+
+ @Override
+ public void startElement(String uri, String localName, String qName, Attributes attributes)
+ throws SAXException {
+ super.startElement(uri, localName, qName, attributes);
+
+ String name = localName;
+ if (name == null || name.trim().length() == 0)
+ name = qName;
+ int i2 = name.indexOf(':');
+ if (i2 >= 0)
+ name = name.substring(i2 + 1);
+
+ if (currentName.length() > 0)
+ currentName.append(Character.toString('.'));
+ currentName.append(name);
+
+ String listName = removeIndexes(currentName.toString());
+
+ if (listNameList.contains(listName)) {
+ String n = currentName.toString() + "_length";
+ int len = getInt(properties, n);
+ properties.put(n, String.valueOf(len + 1));
+ currentName.append("[").append(len).append("]");
+ }
+ }
+
+ @Override
+ public void endElement(String uri, String localName, String qName) throws SAXException {
+ super.endElement(uri, localName, qName);
+
+ String name = localName;
+ if (name == null || name.trim().length() == 0)
+ name = qName;
+ int i2 = name.indexOf(':');
+ if (i2 >= 0)
+ name = name.substring(i2 + 1);
+
+ String s = currentValue.toString().trim();
+ if (s.length() > 0) {
+ properties.put(currentName.toString(), s);
+
+ log.info("Added property: {} : {}", currentName, s);
+ currentValue = new StringBuilder();
+ }
+
+ int i1 = currentName.lastIndexOf("." + name);
+ if (i1 <= 0)
+ currentName = new StringBuilder();
+ else
+ currentName = new StringBuilder(currentName.substring(0, i1));
+ }
+
+ @Override
+ public void characters(char[] ch, int start, int length) throws SAXException {
+ super.characters(ch, start, length);
+
+ String value = new String(ch, start, length);
+ currentValue.append(value);
+ }
+
+ private static int getInt(Map<String, String> mm, String name) {
+ String s = mm.get(name);
+ if (s == null)
+ return 0;
+ return Integer.parseInt(s);
+ }
+
+ private String removeIndexes(String currentName) {
+ StringBuilder b = new StringBuilder();
+ boolean add = true;
+ for (int i = 0; i < currentName.length(); i++) {
+ char c = currentName.charAt(i);
+ if (c == '[')
+ add = false;
+ else if (c == ']')
+ add = true;
+ else if (add)
+ b.append(Character.toString(c));
+ }
+ return b.toString();
+ }
+ }
+}
diff --git a/plugins/properties-node/provider/src/main/resources/OSGI-INF/blueprint/properties-node-blueprint.xml b/plugins/properties-node/provider/src/main/resources/OSGI-INF/blueprint/properties-node-blueprint.xml
new file mode 100755
index 000000000..6e1d48efd
--- /dev/null
+++ b/plugins/properties-node/provider/src/main/resources/OSGI-INF/blueprint/properties-node-blueprint.xml
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
+ xmlns:odl="http://opendaylight.org/xmlns/blueprint/v1.0.0"
+ odl:use-default-for-reference-types="true">
+
+ <bean id="propNodeProvider" class="org.onap.ccsdk.sli.plugins.prop.PropertiesNode" />
+
+
+
+ <service ref="propNodeProvider">
+ <interfaces>
+ <value>org.onap.ccsdk.sli.plugins.prop.PropertiesNode</value>
+ </interfaces>
+ </service>
+
+</blueprint> \ No newline at end of file
diff --git a/plugins/properties-node/provider/src/main/resources/org/opendaylight/blueprint/properties-node-blueprint.xml b/plugins/properties-node/provider/src/main/resources/org/opendaylight/blueprint/properties-node-blueprint.xml
new file mode 100755
index 000000000..6e1d48efd
--- /dev/null
+++ b/plugins/properties-node/provider/src/main/resources/org/opendaylight/blueprint/properties-node-blueprint.xml
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
+ xmlns:odl="http://opendaylight.org/xmlns/blueprint/v1.0.0"
+ odl:use-default-for-reference-types="true">
+
+ <bean id="propNodeProvider" class="org.onap.ccsdk.sli.plugins.prop.PropertiesNode" />
+
+
+
+ <service ref="propNodeProvider">
+ <interfaces>
+ <value>org.onap.ccsdk.sli.plugins.prop.PropertiesNode</value>
+ </interfaces>
+ </service>
+
+</blueprint> \ No newline at end of file
diff --git a/plugins/properties-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/prop/TestJsonParser.java b/plugins/properties-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/prop/TestJsonParser.java
new file mode 100644
index 000000000..0681124d9
--- /dev/null
+++ b/plugins/properties-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/prop/TestJsonParser.java
@@ -0,0 +1,73 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : SDN-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. 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 jtest.org.onap.ccsdk.sli.plugins.prop;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+
+import org.junit.Test;
+import org.onap.ccsdk.sli.core.sli.SvcLogicException;
+import org.onap.ccsdk.sli.plugins.prop.JsonParser;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class TestJsonParser {
+
+ private static final Logger log = LoggerFactory.getLogger(TestJsonParser.class);
+
+ @Test
+ public void test() throws SvcLogicException, IOException {
+ BufferedReader in = new BufferedReader(
+ new InputStreamReader(ClassLoader.getSystemResourceAsStream("test.json"))
+ );
+ StringBuilder b = new StringBuilder();
+ String line;
+ while ((line = in.readLine()) != null)
+ b.append(line).append('\n');
+
+ Map<String, String> mm = JsonParser.convertToProperties(b.toString());
+
+ logProperties(mm);
+
+ in.close();
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void testNullString() throws SvcLogicException {
+ JsonParser.convertToProperties(null);
+ }
+
+ private void logProperties(Map<String, String> mm) {
+ List<String> ll = new ArrayList<>();
+ for (Object o : mm.keySet())
+ ll.add((String) o);
+ Collections.sort(ll);
+ log.info("Properties:");
+ for (String name : ll)
+ log.info("--- {}: {}", name, mm.get(name));
+ }
+}
diff --git a/plugins/properties-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/prop/TestPropertiesNode.java b/plugins/properties-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/prop/TestPropertiesNode.java
new file mode 100644
index 000000000..a858c49b3
--- /dev/null
+++ b/plugins/properties-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/prop/TestPropertiesNode.java
@@ -0,0 +1,608 @@
+package jtest.org.onap.ccsdk.sli.plugins.prop;
+
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.contrib.java.lang.system.EnvironmentVariables;
+import static org.junit.Assert.assertEquals;
+import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
+import org.onap.ccsdk.sli.core.sli.SvcLogicException;
+import org.onap.ccsdk.sli.plugins.prop.PropertiesNode;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class TestPropertiesNode {
+
+ private static final Logger log = LoggerFactory.getLogger(TestPropertiesNode.class);
+ @Rule
+ public EnvironmentVariables environmentVariables = new EnvironmentVariables();
+
+ @Test
+ public void testJSONFileParsing() throws SvcLogicException {
+ SvcLogicContext ctx = new SvcLogicContext();
+
+ Map<String, String> p = new HashMap<String, String>();
+ p.put("fileName", "src/test/resources/test.json");
+ p.put("contextPrefix", "test-json");
+ p.put("fileBasedParsing","true");
+
+ PropertiesNode rcn = new PropertiesNode();
+ rcn.readProperties(p, ctx);
+
+ assertEquals(ctx.getAttribute("test-json.message"),"The provisioned access " +
+ "bandwidth is at or exceeds 50% of the total server capacity.");
+ }
+
+ @Test
+ public void testJSONFileArrayParsing() throws SvcLogicException {
+ SvcLogicContext ctx = new SvcLogicContext();
+
+ Map<String, String> p = new HashMap<String, String>();
+ p.put("fileName", "src/test/resources/test.json");
+ p.put("contextPrefix", "test-json");
+ p.put("fileBasedParsing","true");
+
+ PropertiesNode rcn = new PropertiesNode();
+ rcn.readProperties(p, ctx);
+
+ assertEquals(ctx.getAttribute("test-json.equipment-data[0].max-server-speed"),"1600000");
+ assertEquals(ctx.getAttribute("test-json.resource-state.used"),"1605000");
+ assertEquals(ctx.getAttribute("test-json.resource-rule.service-model"),"DUMMY");
+ assertEquals(ctx.getAttribute("test-json.resource-rule.endpoint-position"),"VCE-Cust");
+ }
+
+ @Test
+ public void testJSONFileParsingPrefixCheck() throws SvcLogicException {
+ SvcLogicContext ctx = new SvcLogicContext();
+
+ Map<String, String> p = new HashMap<String, String>();
+ p.put("fileName", "src/test/resources/test.json");
+ p.put("contextPrefix", "");
+ p.put("fileBasedParsing","true");
+
+ PropertiesNode rcn = new PropertiesNode();
+ rcn.readProperties(p, ctx);
+
+ assertEquals(ctx.getAttribute("equipment-data[0].max-server-speed"),"1600000");
+ assertEquals(ctx.getAttribute("resource-state.used"),"1605000");
+ assertEquals(ctx.getAttribute("resource-rule.service-model"),"DUMMY");
+ assertEquals(ctx.getAttribute("resource-rule.endpoint-position"),"VCE-Cust");
+ assertEquals(ctx.getAttribute("resource-rule.hard-limit-expression"),"max-server-" +
+ "speed * number-primary-servers");
+ }
+
+ @Test
+ public void testJSONFileParsingNoPrefix() throws SvcLogicException {
+ SvcLogicContext ctx = new SvcLogicContext();
+
+ Map<String, String> p = new HashMap<String, String>();
+ p.put("fileName", "src/test/resources/test.json");
+ p.put("fileBasedParsing","true");
+
+ PropertiesNode rcn = new PropertiesNode();
+ rcn.readProperties(p, ctx);
+
+ assertEquals(ctx.getAttribute("equipment-data[0].max-server-speed"),"1600000");
+ assertEquals(ctx.getAttribute("resource-state.used"),"1605000");
+ assertEquals(ctx.getAttribute("resource-rule.service-model"),"DUMMY");
+ assertEquals(ctx.getAttribute("resource-rule.endpoint-position"),"VCE-Cust");
+ assertEquals(ctx.getAttribute("resource-rule.hard-limit-expression"),"max-server-" +
+ "speed * number-primary-servers");
+ }
+
+ @Test
+ public void testJSONFileParsingCtxCheck() throws SvcLogicException {
+ SvcLogicContext ctx = new SvcLogicContext();
+ ctx.setAttribute("tmp.sdn-circuit-req-row_length", "1");
+
+ Map<String, String> p = new HashMap<String, String>();
+ p.put("fileName", "src/test/resources/test.json");
+ p.put("fileBasedParsing","true");
+
+ PropertiesNode rcn = new PropertiesNode();
+ rcn.readProperties(p, ctx);
+
+ assertEquals(ctx.getAttribute("equipment-data[0].max-server-speed"),"1600000");
+ assertEquals(ctx.getAttribute("resource-state.used"),"1605000");
+ assertEquals(ctx.getAttribute("resource-rule.service-model"),"DUMMY");
+ assertEquals(ctx.getAttribute("resource-rule.endpoint-position"),"VCE-Cust");
+ assertEquals(ctx.getAttribute("resource-rule.hard-limit-expression"),"max-server-" +
+ "speed * number-primary-servers");
+ assertEquals(ctx.getAttribute("tmp.sdn-circuit-req-row_length"),"1");
+ }
+
+ @Test(expected = SvcLogicException.class)
+ public void testToPropertiesInvalidJson() throws SvcLogicException {
+ SvcLogicContext ctx = new SvcLogicContext();
+ ctx.setAttribute("tmp.sdn-circuit-req-row_length", "1");
+
+ Map<String, String> p = new HashMap<String, String>();
+ p.put("fileName", "src/test/resources/test-invalid.json");
+ p.put("contextPrefix", "invalid");
+ p.put("fileBasedParsing","true");
+
+ PropertiesNode rcn = new PropertiesNode();
+ rcn.readProperties(p, ctx);
+
+ assertEquals(ctx.getAttribute("tmp.sdn-circuit-req-row_length"),"1");
+ }
+
+ @Test
+ public void testTXTFileParsing() throws SvcLogicException {
+
+ environmentVariables.set("deployer_pass", "sdncp-123");
+ assertEquals("sdncp-123", System.getenv("deployer_pass"));
+
+ SvcLogicContext ctx = new SvcLogicContext();
+
+ Map<String, String> p = new HashMap<String, String>();
+ p.put("fileName", "src/test/resources/test.txt");
+ p.put("contextPrefix", "test-txt");
+ p.put("fileBasedParsing","true");
+
+ PropertiesNode rcn = new PropertiesNode();
+ rcn.readProperties(p, ctx);
+
+ assertEquals(ctx.getAttribute("test-txt.service-data.service-information.service-type"),"AVPN");
+ assertEquals(ctx.getAttribute("test-txt.service-configuration-notification-input.response-code"),"0");
+ assertEquals(ctx.getAttribute("test-txt.operational-data.avpn-ip-port-information.port-" +
+ "level-cos.queueing.pe-per-class-queueing-behaviors.cos3-queueing"),"WRED");
+ assertEquals(ctx.getAttribute("test-txt.service-data.avpn-ip-port-information.avpn-" +
+ "access-information.l1-customer-handoff"),"_1000BASELX");
+ assertEquals(ctx.getAttribute("test-txt.service-data.avpn-ip-port-information.avpn-" +
+ "access-information.vlan-tag-control"),"_1Q");
+ assertEquals(ctx.getAttribute("test-txt.obfuscated-var"), "sdncp-123");
+ }
+
+ @Test
+ public void testTXTFileParsingPrefixCheck() throws SvcLogicException {
+ SvcLogicContext ctx = new SvcLogicContext();
+
+ Map<String, String> p = new HashMap<String, String>();
+ p.put("fileName", "src/test/resources/test.txt");
+ p.put("contextPrefix", "");
+ p.put("fileBasedParsing","true");
+
+ PropertiesNode rcn = new PropertiesNode();
+ rcn.readProperties(p, ctx);
+
+ assertEquals(ctx.getAttribute("service-data.service-information.service-type"),"AVPN");
+ assertEquals(ctx.getAttribute("service-configuration-notification-input.response-code"),"0");
+ assertEquals(ctx.getAttribute("operational-data.avpn-ip-port-information.port-" +
+ "level-cos.queueing.pe-per-class-queueing-behaviors.cos3-queueing"),"WRED");
+ assertEquals(ctx.getAttribute("service-data.avpn-ip-port-information.avpn-" +
+ "access-information.l1-customer-handoff"),"_1000BASELX");
+ assertEquals(ctx.getAttribute("service-data.avpn-ip-port-information.avpn-" +
+ "access-information.vlan-tag-control"),"_1Q");
+ }
+
+ @Test
+ public void testTXTFileParsingNoPrefix() throws SvcLogicException {
+ SvcLogicContext ctx = new SvcLogicContext();
+
+ Map<String, String> p = new HashMap<String, String>();
+ p.put("fileName", "src/test/resources/test.txt");
+ p.put("fileBasedParsing","true");
+
+ PropertiesNode rcn = new PropertiesNode();
+ rcn.readProperties(p, ctx);
+
+ assertEquals(ctx.getAttribute("service-data.service-information.service-type"),"AVPN");
+ assertEquals(ctx.getAttribute("service-configuration-notification-input.response-code"),"0");
+ assertEquals(ctx.getAttribute("operational-data.avpn-ip-port-information.port-" +
+ "level-cos.queueing.pe-per-class-queueing-behaviors.cos3-queueing"),"WRED");
+ assertEquals(ctx.getAttribute("service-data.avpn-ip-port-information.avpn-" +
+ "access-information.l1-customer-handoff"),"_1000BASELX");
+ assertEquals(ctx.getAttribute("service-data.avpn-ip-port-information.avpn-" +
+ "access-information.vlan-tag-control"),"_1Q");
+ }
+
+ @Test
+ public void testTXTFileParsingCtxCheck() throws SvcLogicException {
+ SvcLogicContext ctx = new SvcLogicContext();
+ ctx.setAttribute("tmp.sdn-circuit-req-row_length", "1");
+
+ Map<String, String> p = new HashMap<String, String>();
+ p.put("fileName", "src/test/resources/test.txt");
+ p.put("fileBasedParsing","true");
+
+ PropertiesNode rcn = new PropertiesNode();
+ rcn.readProperties(p, ctx);
+
+ assertEquals(ctx.getAttribute("service-data.service-information.service-type"),"AVPN");
+ assertEquals(ctx.getAttribute("service-configuration-notification-input.response-code"),"0");
+ assertEquals(ctx.getAttribute("operational-data.avpn-ip-port-information.port-" +
+ "level-cos.queueing.pe-per-class-queueing-behaviors.cos3-queueing"),"WRED");
+ assertEquals(ctx.getAttribute("service-data.avpn-ip-port-information.avpn-" +
+ "access-information.l1-customer-handoff"),"_1000BASELX");
+ assertEquals(ctx.getAttribute("service-data.avpn-ip-port-information.avpn-" +
+ "access-information.vlan-tag-control"),"_1Q");
+ assertEquals(ctx.getAttribute("tmp.sdn-circuit-req-row_length"),"1");
+ }
+
+ @Test(expected = SvcLogicException.class)
+ public void testToPropertiesInvalidParam() throws SvcLogicException {
+ SvcLogicContext ctx = new SvcLogicContext();
+ ctx.setAttribute("tmp.sdn-circuit-req-row_length", "1");
+
+ Map<String, String> p = new HashMap<String, String>();
+ p.put("responsePrefix", "response");
+ p.put("skipSending", "true");
+ p.put("fileBasedParsing","true");
+
+ PropertiesNode rcn = new PropertiesNode();
+ rcn.readProperties(p, ctx);
+
+ assertEquals(ctx.getAttribute("tmp.sdn-circuit-req-row_length"),"1");
+ }
+
+ @Test(expected = SvcLogicException.class)
+ public void testToPropertiesNoParam() throws SvcLogicException {
+ SvcLogicContext ctx = new SvcLogicContext();
+ ctx.setAttribute("tmp.sdn-circuit-req-row_length", "1");
+
+ Map<String, String> p = new HashMap<String, String>();
+ p.put("fileBasedParsing","true");
+
+ PropertiesNode rcn = new PropertiesNode();
+ rcn.readProperties(p, ctx);
+
+ assertEquals(ctx.getAttribute("tmp.sdn-circuit-req-row_length"),"1");
+ }
+
+ @Test(expected = SvcLogicException.class)
+ public void testToPropertiesFilePathError() throws SvcLogicException {
+ SvcLogicContext ctx = new SvcLogicContext();
+ ctx.setAttribute("tmp.sdn-circuit-req-row_length", "1");
+
+ Map<String, String> p = new HashMap<String, String>();
+ p.put("fileName", "src/tests/resources/test.txt");
+ p.put("fileBasedParsing","true");
+
+ PropertiesNode rcn = new PropertiesNode();
+ rcn.readProperties(p, ctx);
+
+ assertEquals(ctx.getAttribute("tmp.sdn-circuit-req-row_length"),"1");
+ }
+
+ @Test
+ public void testXMLFileParsing() throws SvcLogicException {
+ SvcLogicContext ctx = new SvcLogicContext();
+
+ Map<String, String> p = new HashMap<String, String>();
+ p.put("fileName", "src/test/resources/test.xml");
+ p.put("contextPrefix", "test-xml");
+ p.put("listName", "project.build");
+ p.put("fileBasedParsing","true");
+
+ PropertiesNode rcn = new PropertiesNode();
+ rcn.readProperties(p, ctx);
+
+ assertEquals(ctx.getAttribute("test-xml.project.modelVersion"),"4.0.0");
+ }
+
+ @Test
+ public void testXMLFileInnerParsing() throws SvcLogicException {
+ SvcLogicContext ctx = new SvcLogicContext();
+
+ Map<String, String> p = new HashMap<String, String>();
+ p.put("fileName", "src/test/resources/test.xml");
+ p.put("contextPrefix", "test-xml");
+ p.put("listName", "project.modelVersion");
+ p.put("fileBasedParsing","true");
+
+ PropertiesNode rcn = new PropertiesNode();
+ rcn.readProperties(p, ctx);
+
+ assertEquals(ctx.getAttribute("test-xml.project.properties.project.build.sourceEncoding"),"UTF-8");
+ assertEquals(ctx.getAttribute("test-xml.project.dependencies.dependency.scope"),"provided");
+ assertEquals(ctx.getAttribute("test-xml.project.build.pluginManagement.plugins.plugin.configuration" +
+ ".lifecycleMappingMetadata.pluginExecutions.pluginExecution." +
+ "pluginExecutionFilter.versionRange"),"[1.2.0.100,)");
+ assertEquals(ctx.getAttribute("test-xml.project.build.plugins.plugin.configuration." +
+ "instructions.Import-Package"),"*");
+ }
+
+ @Test
+ public void testXMLFileParsingPrefixCheck() throws SvcLogicException {
+ SvcLogicContext ctx = new SvcLogicContext();
+
+ Map<String, String> p = new HashMap<String, String>();
+ p.put("fileName", "src/test/resources/test.xml");
+ p.put("contextPrefix", "");
+ p.put("fileBasedParsing","true");
+
+ PropertiesNode rcn = new PropertiesNode();
+ rcn.readProperties(p, ctx);
+
+ assertEquals(ctx.getAttribute("project.properties.project.build.sourceEncoding"),"UTF-8");
+ assertEquals(ctx.getAttribute("project.dependencies.dependency.scope"),"provided");
+ assertEquals(ctx.getAttribute("project.build.pluginManagement.plugins.plugin.configuration" +
+ ".lifecycleMappingMetadata.pluginExecutions.pluginExecution." +
+ "pluginExecutionFilter.versionRange"),"[1.2.0.100,)");
+ assertEquals(ctx.getAttribute("project.build.plugins.plugin.configuration." +
+ "instructions.Import-Package"),"*");
+ }
+
+ @Test
+ public void testXMLFileParsingNoPrefix() throws SvcLogicException {
+ SvcLogicContext ctx = new SvcLogicContext();
+
+ Map<String, String> p = new HashMap<String, String>();
+ p.put("fileName", "src/test/resources/test.xml");
+ p.put("fileBasedParsing","true");
+
+ PropertiesNode rcn = new PropertiesNode();
+ rcn.readProperties(p, ctx);
+
+ assertEquals(ctx.getAttribute("project.properties.project.build.sourceEncoding"),"UTF-8");
+ assertEquals(ctx.getAttribute("project.dependencies.dependency.scope"),"provided");
+ assertEquals(ctx.getAttribute("project.build.pluginManagement.plugins.plugin.configuration" +
+ ".lifecycleMappingMetadata.pluginExecutions.pluginExecution." +
+ "pluginExecutionFilter.versionRange"),"[1.2.0.100,)");
+ assertEquals(ctx.getAttribute("project.build.plugins.plugin.configuration." +
+ "instructions.Import-Package"),"*");
+ }
+
+ @Test
+ public void testXMLFileParsingCtxCheck() throws SvcLogicException {
+ SvcLogicContext ctx = new SvcLogicContext();
+ ctx.setAttribute("tmp.sdn-circuit-req-row_length", "1");
+
+ Map<String, String> p = new HashMap<String, String>();
+ p.put("fileName", "src/test/resources/test.xml");
+ p.put("fileBasedParsing","true");
+
+ PropertiesNode rcn = new PropertiesNode();
+ rcn.readProperties(p, ctx);
+
+ assertEquals(ctx.getAttribute("project.properties.project.build.sourceEncoding"),"UTF-8");
+ assertEquals(ctx.getAttribute("project.dependencies.dependency.scope"),"provided");
+ assertEquals(ctx.getAttribute("project.build.pluginManagement.plugins.plugin.configuration" +
+ ".lifecycleMappingMetadata.pluginExecutions.pluginExecution." +
+ "pluginExecutionFilter.versionRange"),"[1.2.0.100,)");
+ assertEquals(ctx.getAttribute("project.build.plugins.plugin.configuration." +
+ "instructions.Import-Package"),"*");
+ assertEquals(ctx.getAttribute("tmp.sdn-circuit-req-row_length"),"1");
+ }
+
+ @Test(expected = SvcLogicException.class)
+ public void testToPropertiesInvalidXML() throws SvcLogicException {
+ SvcLogicContext ctx = new SvcLogicContext();
+ ctx.setAttribute("tmp.sdn-circuit-req-row_length", "1");
+
+ Map<String, String> p = new HashMap<String, String>();
+ p.put("fileName", "src/test/resources/test-invalid.xml");
+ p.put("contextPrefix", "invalid");
+ p.put("fileBasedParsing","true");
+
+ PropertiesNode rcn = new PropertiesNode();
+ rcn.readProperties(p, ctx);
+
+ assertEquals(ctx.getAttribute("tmp.sdn-circuit-req-row_length"),"1");
+ }
+
+ @Test
+ public void testXMLFileParsingListName() throws SvcLogicException {
+ SvcLogicContext ctx = new SvcLogicContext();
+
+ Map<String, String> p = new HashMap<String, String>();
+ p.put("fileName", "src/test/resources/test.xml");
+ p.put("contextPrefix", "test-xml-listName");
+ p.put("fileBasedParsing","true");
+ p.put("listName", "project.build.pluginManagement");
+
+ PropertiesNode rcn = new PropertiesNode();
+ rcn.readProperties(p, ctx);
+
+ assertEquals(ctx.getAttribute("test-xml-listName.project.build." +
+ "pluginManagement.plugins.plugin.version"),null);
+ assertEquals(ctx.getAttribute("test-xml-listName.project.build." +
+ "plugins.plugin.groupId"),"org.apache.felix");
+ }
+
+ @Test
+ public void testXMLFileParsingListNameAnother() throws SvcLogicException {
+ SvcLogicContext ctx = new SvcLogicContext();
+
+ Map<String, String> p = new HashMap<String, String>();
+ p.put("fileName", "src/test/resources/test.xml");
+ p.put("contextPrefix", "test-xml-listName");
+ p.put("fileBasedParsing","true");
+ p.put("listName", "project.modelVersion");
+
+ PropertiesNode rcn = new PropertiesNode();
+ rcn.readProperties(p, ctx);
+
+ assertEquals(ctx.getAttribute("test-xml-listName.project.modelVersion"),null);
+ assertEquals(ctx.getAttribute("test-xml-listName.project.build." +
+ "plugins.plugin.groupId"),"org.apache.felix");
+ }
+
+ @Test
+ public void testTXTFileParsingNotFileBased() throws SvcLogicException {
+ SvcLogicContext ctx = new SvcLogicContext();
+
+ Map<String, String> p = new HashMap<String, String>();
+ p.put("fileName", "src/test/resources/test.txt");
+ p.put("contextPrefix", "test-txt");
+
+ PropertiesNode rcn = new PropertiesNode();
+ rcn.readProperties(p, ctx);
+
+ assertEquals(ctx.getAttribute("test-txt.service-data.service-information.service-type"),"AVPN");
+ assertEquals(ctx.getAttribute("test-txt.service-configuration-notification-input.response-code"),"0");
+ assertEquals(ctx.getAttribute("test-txt.operational-data.avpn-ip-port-information.port-" +
+ "level-cos.queueing.pe-per-class-queueing-behaviors.cos3-queueing"),"WRED");
+ assertEquals(ctx.getAttribute("test-txt.service-data.avpn-ip-port-information.avpn-" +
+ "access-information.l1-customer-handoff"),"_1000BASELX");
+ assertEquals(ctx.getAttribute("test-txt.service-data.avpn-ip-port-information.avpn-" +
+ "access-information.vlan-tag-control"),"_1Q");
+ }
+
+ @Test
+ public void testTXTFileParsingPrefixCheckNotFileBased() throws SvcLogicException {
+ SvcLogicContext ctx = new SvcLogicContext();
+
+ Map<String, String> p = new HashMap<String, String>();
+ p.put("fileName", "src/test/resources/test.txt");
+ p.put("contextPrefix", "");
+
+ PropertiesNode rcn = new PropertiesNode();
+ rcn.readProperties(p, ctx);
+
+ assertEquals(ctx.getAttribute("service-data.service-information.service-type"),"AVPN");
+ assertEquals(ctx.getAttribute("service-configuration-notification-input.response-code"),"0");
+ assertEquals(ctx.getAttribute("operational-data.avpn-ip-port-information.port-" +
+ "level-cos.queueing.pe-per-class-queueing-behaviors.cos3-queueing"),"WRED");
+ assertEquals(ctx.getAttribute("service-data.avpn-ip-port-information.avpn-" +
+ "access-information.l1-customer-handoff"),"_1000BASELX");
+ assertEquals(ctx.getAttribute("service-data.avpn-ip-port-information.avpn-" +
+ "access-information.vlan-tag-control"),"_1Q");
+ }
+
+ @Test
+ public void testTXTFileParsingNoPrefixNotFileBased() throws SvcLogicException {
+ SvcLogicContext ctx = new SvcLogicContext();
+
+ Map<String, String> p = new HashMap<String, String>();
+ p.put("fileName", "src/test/resources/test.txt");
+
+ PropertiesNode rcn = new PropertiesNode();
+ rcn.readProperties(p, ctx);
+
+ assertEquals(ctx.getAttribute("service-data.service-information.service-type"),"AVPN");
+ assertEquals(ctx.getAttribute("service-configuration-notification-input.response-code"),"0");
+ assertEquals(ctx.getAttribute("operational-data.avpn-ip-port-information.port-" +
+ "level-cos.queueing.pe-per-class-queueing-behaviors.cos3-queueing"),"WRED");
+ assertEquals(ctx.getAttribute("service-data.avpn-ip-port-information.avpn-" +
+ "access-information.l1-customer-handoff"),"_1000BASELX");
+ assertEquals(ctx.getAttribute("service-data.avpn-ip-port-information.avpn-" +
+ "access-information.vlan-tag-control"),"_1Q");
+ }
+
+ @Test
+ public void testTXTFileParsingCtxCheckNotFileBased() throws SvcLogicException {
+ SvcLogicContext ctx = new SvcLogicContext();
+ ctx.setAttribute("tmp.sdn-circuit-req-row_length", "1");
+
+ Map<String, String> p = new HashMap<String, String>();
+ p.put("fileName", "src/test/resources/test.txt");
+
+ PropertiesNode rcn = new PropertiesNode();
+ rcn.readProperties(p, ctx);
+
+ assertEquals(ctx.getAttribute("service-data.service-information.service-type"),"AVPN");
+ assertEquals(ctx.getAttribute("service-configuration-notification-input.response-code"),"0");
+ assertEquals(ctx.getAttribute("operational-data.avpn-ip-port-information.port-" +
+ "level-cos.queueing.pe-per-class-queueing-behaviors.cos3-queueing"),"WRED");
+ assertEquals(ctx.getAttribute("service-data.avpn-ip-port-information.avpn-" +
+ "access-information.l1-customer-handoff"),"_1000BASELX");
+ assertEquals(ctx.getAttribute("service-data.avpn-ip-port-information.avpn-" +
+ "access-information.vlan-tag-control"),"_1Q");
+ assertEquals(ctx.getAttribute("tmp.sdn-circuit-req-row_length"),"1");
+ }
+
+ @Test
+ public void testJSONFileArrayParsingNotFileBased() throws SvcLogicException {
+ SvcLogicContext ctx = new SvcLogicContext();
+
+ Map<String, String> p = new HashMap<String, String>();
+ p.put("fileName", "src/test/resources/test.json");
+ p.put("contextPrefix", "NotFileBased");
+
+ PropertiesNode rcn = new PropertiesNode();
+ rcn.readProperties(p, ctx);
+
+ assertEquals(ctx.getAttribute("NotFileBased.\"limit-value\""),"\"1920000\"");
+ assertEquals(ctx.getAttribute("NotFileBased.\"hard-limit-expression\""),"\"max-server-speed * number-primary-servers\",");
+ assertEquals(ctx.getAttribute("NotFileBased.\"test-inner-node\""),"\"Test-Value\"");
+ }
+
+ @Test
+ public void testXMLFileInnerParsingNotFileBased() throws SvcLogicException {
+ SvcLogicContext ctx = new SvcLogicContext();
+
+ Map<String, String> p = new HashMap<String, String>();
+ p.put("fileName", "src/test/resources/test.xml");
+ p.put("contextPrefix", "NotFileBased");
+ p.put("listName", "project.modelVersion");
+
+ PropertiesNode rcn = new PropertiesNode();
+ rcn.readProperties(p, ctx);
+
+ assertEquals(ctx.getAttribute("NotFileBased.<name>RESTAPI"),"Call Node - Provider</name>");
+ assertEquals(ctx.getAttribute("NotFileBased.<project"),
+ "xmlns=\"http://maven.apache.org/POM/4.0.0\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"" +
+ " xsi:schemaLocation=\"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd\">");
+ assertEquals(ctx.getAttribute("NotFileBased.openECOMP"),"SDN-C");
+ assertEquals(ctx.getAttribute("NotFileBased.<ignore"),"/>");
+ }
+
+ @Test
+ public void testNoFileTypeNoPrefixNotFileBased() throws SvcLogicException {
+ SvcLogicContext ctx = new SvcLogicContext();
+
+ Map<String, String> p = new HashMap<String, String>();
+ p.put("fileName", "src/test/resources/test");
+ p.put("fileBasedParsing","true");
+
+ PropertiesNode rcn = new PropertiesNode();
+ rcn.readProperties(p, ctx);
+
+ assertEquals(ctx.getAttribute("service-data.service-information.service-type"),"AVPN");
+ assertEquals(ctx.getAttribute("service-configuration-notification-input.response-code"),"0");
+ assertEquals(ctx.getAttribute("operational-data.avpn-ip-port-information.port-" +
+ "level-cos.queueing.pe-per-class-queueing-behaviors.cos3-queueing"),"WRED");
+ assertEquals(ctx.getAttribute("service-data.avpn-ip-port-information.avpn-" +
+ "access-information.l1-customer-handoff"),"_1000BASELX");
+ assertEquals(ctx.getAttribute("service-data.avpn-ip-port-information.avpn-" +
+ "access-information.vlan-tag-control"),"_1Q");
+ }
+
+ @Test(expected = SvcLogicException.class)
+ public void testNoFileTypeParseReqError() throws SvcLogicException {
+ SvcLogicContext ctx = new SvcLogicContext();
+
+ Map<String, String> p = new HashMap<String, String>();
+ p.put("file Name", "src/test/resources/test");
+ p.put("fileBasedParsing","true");
+
+ PropertiesNode rcn = new PropertiesNode();
+ rcn.readProperties(p, ctx);
+
+ assertEquals(ctx.getAttribute("service-data.service-information.service-type"),"AVPN");
+ assertEquals(ctx.getAttribute("service-configuration-notification-input.response-code"),"0");
+ assertEquals(ctx.getAttribute("operational-data.avpn-ip-port-information.port-" +
+ "level-cos.queueing.pe-per-class-queueing-behaviors.cos3-queueing"),"WRED");
+ assertEquals(ctx.getAttribute("service-data.avpn-ip-port-information.avpn-" +
+ "access-information.l1-customer-handoff"),"_1000BASELX");
+ assertEquals(ctx.getAttribute("service-data.avpn-ip-port-information.avpn-" +
+ "access-information.vlan-tag-control"),"_1Q");
+ }
+
+ @Test
+ public void testNoFileTypeParseError() throws SvcLogicException {
+ SvcLogicContext ctx = new SvcLogicContext();
+
+ Map<String, String> p = new HashMap<String, String>();
+ p.put("fileName", "src/test/resources/test");
+ p.put("file Based % Parsing","true");
+
+ PropertiesNode rcn = new PropertiesNode();
+ rcn.readProperties(p, ctx);
+
+ assertEquals(ctx.getAttribute("service-data.service-information.service-type"),"AVPN");
+ assertEquals(ctx.getAttribute("service-configuration-notification-input.response-code"),"0");
+ assertEquals(ctx.getAttribute("operational-data.avpn-ip-port-information.port-" +
+ "level-cos.queueing.pe-per-class-queueing-behaviors.cos3-queueing"),"WRED");
+ assertEquals(ctx.getAttribute("service-data.avpn-ip-port-information.avpn-" +
+ "access-information.l1-customer-handoff"),"_1000BASELX");
+ assertEquals(ctx.getAttribute("service-data.avpn-ip-port-information.avpn-" +
+ "access-information.vlan-tag-control"),"_1Q");
+ }
+}
diff --git a/plugins/properties-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/prop/TestXmlParser.java b/plugins/properties-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/prop/TestXmlParser.java
new file mode 100644
index 000000000..7cd072ed8
--- /dev/null
+++ b/plugins/properties-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/prop/TestXmlParser.java
@@ -0,0 +1,121 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : SDN-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. 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 jtest.org.onap.ccsdk.sli.plugins.prop;
+
+import org.junit.Test;
+import org.onap.ccsdk.sli.core.sli.SvcLogicException;
+import org.onap.ccsdk.sli.plugins.prop.XmlParser;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.BufferedReader;
+import java.io.InputStreamReader;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.core.Is.is;
+
+public class TestXmlParser {
+
+ private static final Logger log = LoggerFactory.getLogger(TestXmlParser.class);
+
+ @Test
+ public void test() throws Exception {
+ BufferedReader in = new BufferedReader(
+ new InputStreamReader(ClassLoader.getSystemResourceAsStream("test3.xml"))
+ );
+ StringBuilder b = new StringBuilder();
+ String line;
+ while ((line = in.readLine()) != null)
+ b.append(line).append('\n');
+
+ Set<String> listNameList = new HashSet<String>();
+ listNameList.add("project.dependencies.dependency");
+ listNameList.add("project.build.plugins.plugin");
+ listNameList.add("project.build.plugins.plugin.executions.execution");
+ listNameList.add("project.build.pluginManagement.plugins.plugin");
+ listNameList.add("project.build.pluginManagement." +
+ "plugins.plugin.configuration.lifecycleMappingMetadata.pluginExecutions.pluginExecution");
+
+ Map<String, String> mm = XmlParser.convertToProperties(b.toString(), listNameList);
+ logProperties(mm);
+ in.close();
+ }
+
+ @Test
+ public void testValidLength() throws Exception {
+ BufferedReader in = new BufferedReader(
+ new InputStreamReader(ClassLoader.getSystemResourceAsStream("test3.xml"))
+ );
+ StringBuilder b = new StringBuilder();
+ String line;
+ while ((line = in.readLine()) != null)
+ b.append(line).append('\n');
+
+ Set<String> listNameList = new HashSet<String>();
+ listNameList.add("ApplyGroupResponse.ApplyGroupResponseData.VrfDetails.VrfImport");
+ listNameList.add("ApplyGroupResponse.ApplyGroupResponseData.VrfDetails.VrfExport");
+
+ Map<String, String> mm = XmlParser.convertToProperties(b.toString(), listNameList);
+
+ assertThat(mm.get("ApplyGroupResponse.ApplyGroupResponseData.VrfDetails.VrfExport[5]"), is("SET_RESET_LP"));
+ assertThat(mm.get("ApplyGroupResponse.ApplyGroupResponseData.VrfDetails.VrfImport[0]"), is("SET_BVOIP_IN"));
+
+ logProperties(mm);
+ in.close();
+ }
+
+ @Test(expected = SvcLogicException.class)
+ public void testInvalidLength() throws Exception {
+ BufferedReader in = new BufferedReader(
+ new InputStreamReader(ClassLoader.getSystemResourceAsStream("invalidlength.xml"))
+ );
+ StringBuilder b = new StringBuilder();
+ String line;
+ while ((line = in.readLine()) != null)
+ b.append(line).append('\n');
+
+ Set<String> listNameList = new HashSet<String>();
+ listNameList.add("ApplyGroupResponse.ApplyGroupResponseData.VrfDetails.VrfImport");
+ listNameList.add("ApplyGroupResponse.ApplyGroupResponseData.VrfDetails.VrfExport");
+
+ Map<String, String> mm = XmlParser.convertToProperties(b.toString(), listNameList);
+ logProperties(mm);
+ in.close();
+ }
+
+ private void logProperties(Map<String, String> mm) {
+ List<String> ll = new ArrayList<>();
+ for (Object o : mm.keySet())
+ ll.add((String) o);
+ Collections.sort(ll);
+
+ log.info("Properties:");
+ for (String name : ll)
+ log.info("--- " + name + ": " + mm.get(name));
+ }
+}
diff --git a/plugins/properties-node/provider/src/test/resources/invalidlength.xml b/plugins/properties-node/provider/src/test/resources/invalidlength.xml
new file mode 100644
index 000000000..c086d564e
--- /dev/null
+++ b/plugins/properties-node/provider/src/test/resources/invalidlength.xml
@@ -0,0 +1,49 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<!--
+ ============LICENSE_START=======================================================
+ openECOMP : SDN-C
+ ================================================================================
+ Copyright (C) 2017 AT&T Intellectual Property. 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=========================================================
+ -->
+
+<ApplyGroupResponse xmlns="http://onap.org/vpn/schema/v1"
+ xmlns:ns2="http://onap.org/prov/vpn/schema/v2">
+ <ApplyGroupResponseData>
+ <ServiceInstanceId>ICOREPVC-81114561</ServiceInstanceId>
+ <VrfDetails>
+ <End2EndVpnKey>VPNL811182</End2EndVpnKey>
+ <VpnId>811182</VpnId>
+ <VrfName>21302:811182</VrfName>
+ <VrfImport>SET_BVOIP_IN</VrfImport>
+ <VrfImport>SET6_BVOIP_IN</VrfImport>
+ <VrfExport_length>a</VrfExport_length>
+ <VrfExport>SET6_DSU</VrfExport>
+ <VrfExport>SET_DSU</VrfExport>
+ <VrfExport>SET6_MANAGED</VrfExport>
+ <VrfExport>SET_MANAGED</VrfExport>
+ <VrfExport>SET_LOVRF_COMMUNITY</VrfExport>
+ <VrfExport>SET_RESET_LP</VrfExport>
+ <ApplyGroup>
+ <ns2:ApplyGroup>AG_MAX_MCASTROUTES</ns2:ApplyGroup>
+ </ApplyGroup>
+ </VrfDetails>
+ </ApplyGroupResponseData>
+ <response-code>200</response-code>
+ <response-message>Success</response-message>
+ <ack-final-indicator>Y</ack-final-indicator>
+</ApplyGroupResponse>
+
diff --git a/plugins/properties-node/provider/src/test/resources/test b/plugins/properties-node/provider/src/test/resources/test
new file mode 100644
index 000000000..79e8acff4
--- /dev/null
+++ b/plugins/properties-node/provider/src/test/resources/test
@@ -0,0 +1,30 @@
+operational-data.avpn-ip-port-information.port-level-cos.queueing.pe-egress-class-queueing-policing-codes.cos2v-queueing-code = P
+operational-data.avpn-ip-port-information.port-level-cos.queueing.pe-egress-class-queueing-policing-codes.cos3-queueing-code = W
+operational-data.avpn-ip-port-information.port-level-cos.queueing.pe-per-class-queueing-behaviors.cos2-queueing = WRED
+operational-data.avpn-ip-port-information.port-level-cos.queueing.pe-per-class-queueing-behaviors.cos2v-queueing = QueueLimit
+operational-data.avpn-ip-port-information.port-level-cos.queueing.pe-per-class-queueing-behaviors.cos3-queueing = WRED
+operational-data.avpn-ip-port-information.port-level-cos.shaping.pe-egress-per-class-shaping-behaviors.cos2-shaping = Disable
+operational-data.avpn-ip-port-information.port-level-cos.shaping.pe-egress-per-class-shaping-behaviors.cos2v-shaping = Enable
+operational-data.avpn-ip-port-information.port-level-cos.shaping.pe-egress-per-class-shaping-behaviors.cos3-shaping = Disable
+operational-data.avpn-ip-port-information.port-level-cos.shaping.pe-egress-per-class-shaping-codes.cos2-shaping-code = W
+operational-data.avpn-ip-port-information.port-level-cos.shaping.pe-egress-per-class-shaping-codes.cos2v-shaping-code = P
+service-configuration-notification-input.ack-final-indicator = Y
+service-configuration-notification-input.response-code = 0
+service-configuration-notification-input.response-message = Plc Activation Failed: Device gblond2005me6 Sync-from Failed. Please check device IP address and NCS setup.
+service-configuration-notification-input.service-information.service-instance-id = TEST7
+service-configuration-notification-input.service-information.service-type = AVPN
+service-configuration-notification-input.svc-request-id = TEST7
+service-data.avpn-ip-port-information.avpn-access-information.access-circuit-id = DHEC.54831.170.ATI
+service-data.avpn-ip-port-information.avpn-access-information.access-interface = _1G
+service-data.avpn-ip-port-information.avpn-access-information.access-speed = 10000
+service-data.avpn-ip-port-information.avpn-access-information.access-speed-units = Kbps
+service-data.avpn-ip-port-information.avpn-access-information.l1-customer-handoff = _1000BASELX
+service-data.avpn-ip-port-information.avpn-access-information.managed-ce = N
+service-data.avpn-ip-port-information.avpn-access-information.vlan-tag-control = _1Q
+service-data.avpn-ip-port-information.clli = LONDENEH
+service-data.avpn-ip-port-information.contracted-port-speed = 10000
+service-data.avpn-ip-port-information.contracted-port-speed-units = Kbps
+service-data.avpn-ip-port-information.endpoint-information.bundle-id = 33
+service-data.avpn-ip-port-information.endpoint-information.interface-string = ae0
+service-data.service-information.service-instance-id = ICORESITE-2751508
+service-data.service-information.service-type = AVPN \ No newline at end of file
diff --git a/plugins/properties-node/provider/src/test/resources/test-invalid.json b/plugins/properties-node/provider/src/test/resources/test-invalid.json
new file mode 100644
index 000000000..21af3ac1d
--- /dev/null
+++ b/plugins/properties-node/provider/src/test/resources/test-invalid.json
@@ -0,0 +1,29 @@
+ "equipment-data": [
+ {
+ "server-count": "4",
+ "max-server-speed": "1600000",
+ "number-primary-servers": "2",
+ "equipment-id": "Server1",
+ "server-model": "Unknown",
+ "server-id": "Server1",
+ "test-node" : {
+ "test-inner-node" : "Test-Value"
+ }
+ }
+ ],
+ "resource-state": {
+ "threshold-value": "1600000",
+ "last-added": "1605000",
+ "used": "1605000",
+ "limit-value": "1920000"
+ },
+ "resource-rule": {
+ "endpoint-position": "VCE-Cust",
+ "soft-limit-expression": "0.6 * max-server-speed * number-primary-servers",
+ "resource-name": "Bandwidth",
+ "service-model": "DUMMY",
+ "hard-limit-expression": "max-server-speed * number-primary-servers",
+ "equipment-level": "Server"
+ },
+ "message": "The provisioned access bandwidth is at or exceeds 50% of the total server capacity."
+}
diff --git a/plugins/properties-node/provider/src/test/resources/test-invalid.xml b/plugins/properties-node/provider/src/test/resources/test-invalid.xml
new file mode 100644
index 000000000..50bd0fff2
--- /dev/null
+++ b/plugins/properties-node/provider/src/test/resources/test-invalid.xml
@@ -0,0 +1,170 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ============LICENSE_START=======================================================
+ openECOMP : SDN-C
+ ================================================================================
+ Copyright (C) 2017 AT&T Intellectual Property. 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=========================================================
+ -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.onap.ccsdk.sli.plugins</groupId>
+ <artifactId>restapi-call-node</artifactId>
+ <version>6.0.0-SNAPSHOT</version>
+ </parent>
+ <artifactId>restapi-call-node-provider</artifactId>
+ <packaging>bundle</packaging>
+ <name>RESTAPI Call Node - Provider</name>
+ <url>http://maven.apache.org</url>
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ </properties>
+ <dependencies>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-test</artifactId>
+ <version>3.1.4.RELEASE</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.onap.ccsdk.sli</groupId>
+ <artifactId>sli-common</artifactId>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.onap.ccsdk.sli</groupId>
+ <artifactId>sli-provider</artifactId>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ <version>${slf4j.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>jcl-over-slf4j</artifactId>
+ <version>${slf4j.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-beans</artifactId>
+ <version>3.1.4.RELEASE</version>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-context</artifactId>
+ <version>3.1.4.RELEASE</version>
+ </dependency>
+ <dependency>
+ <groupId>xerces</groupId>
+ <artifactId>xerces</artifactId>
+ <version>2.4.0</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>com.sun.jersey</groupId>
+ <artifactId>jersey-client</artifactId>
+ <version>1.17</version>
+ </dependency>
+ <dependency>
+ <groupId>com.s
+
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>com.brocade.developer</groupId>
+ <artifactId>providermodule-plugin</artifactId>
+ <configuration>
+ <packageId>org.onap.ccsdk.sli.plugins</packageId>
+ <appName>restapi-call-node</appName>
+ </configuration>
+ <executions>
+ <execution>
+ <phase>process-sources</phase>
+ <goals>
+ <goal>process</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+
+
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <extensions>true</extensions>
+ <configuration>
+ <instructions>
+ <Bundle-SymbolicName>org.onap.ccsdk.sli.plugins.restapicall</Bundle-SymbolicName>
+ <Export-Package>org.onap.ccsdk.sli.plugins.restapicall</Export-Package>
+ <Import-Package>*</Import-Package>
+ </instructions>
+
+ <manifestLocation>${project.basedir}/src/main/resources/META-INF</manifestLocation>
+
+ </configuration>
+
+ </plugin>
+
+
+ </plugins>
+ <pluginManagement>
+ <plugins>
+ <!--This plugin's configuration is used to store Eclipse m2e settings
+ only. It has no influence on the Maven build itself. -->
+ <plugin>
+ <groupId>org.eclipse.m2e</groupId>
+ <artifactId>lifecycle-mapping</artifactId>
+ <version>1.0.0</version>
+ <configuration>
+ <lifecycleMappingMetadata>
+ <pluginExecutions>
+ <pluginExecution>
+ <pluginExecutionFilter>
+ <groupId>
+ com.brocade.developer
+ </groupId>
+ <artifactId>
+ providermodule-plugin
+ </artifactId>
+ <versionRange>
+ [1.2.0.100-SNAPSHOT,)
+ </versionRange>
+ <goals>
+ <goal>process</goal>
+ </goals>
+ </pluginExecutionFilter>
+ <action>
+ <ignore />
+ </action>
+ </pluginExecution>
+ </pluginExecutions>
+ </lifecycleMappingMetadata>
+ </configuration>
+ </plugin>
+ </plugins>
+ </pluginManagement>
+ </build>
+</project>
diff --git a/plugins/properties-node/provider/src/test/resources/test.json b/plugins/properties-node/provider/src/test/resources/test.json
new file mode 100644
index 000000000..75155393c
--- /dev/null
+++ b/plugins/properties-node/provider/src/test/resources/test.json
@@ -0,0 +1,30 @@
+{
+ "equipment-data": [
+ {
+ "server-count": "4",
+ "max-server-speed": "1600000",
+ "number-primary-servers": "2",
+ "equipment-id": "Server1",
+ "server-model": "Unknown",
+ "server-id": "Server1",
+ "test-node" : {
+ "test-inner-node" : "Test-Value"
+ }
+ }
+ ],
+ "resource-state": {
+ "threshold-value": "1600000",
+ "last-added": "1605000",
+ "used": "1605000",
+ "limit-value": "1920000"
+ },
+ "resource-rule": {
+ "endpoint-position": "VCE-Cust",
+ "soft-limit-expression": "0.6 * max-server-speed * number-primary-servers",
+ "resource-name": "Bandwidth",
+ "service-model": "DUMMY",
+ "hard-limit-expression": "max-server-speed * number-primary-servers",
+ "equipment-level": "Server"
+ },
+ "message": "The provisioned access bandwidth is at or exceeds 50% of the total server capacity."
+}
diff --git a/plugins/properties-node/provider/src/test/resources/test.txt b/plugins/properties-node/provider/src/test/resources/test.txt
new file mode 100644
index 000000000..68b916cbb
--- /dev/null
+++ b/plugins/properties-node/provider/src/test/resources/test.txt
@@ -0,0 +1,31 @@
+operational-data.avpn-ip-port-information.port-level-cos.queueing.pe-egress-class-queueing-policing-codes.cos2v-queueing-code = P
+operational-data.avpn-ip-port-information.port-level-cos.queueing.pe-egress-class-queueing-policing-codes.cos3-queueing-code = W
+operational-data.avpn-ip-port-information.port-level-cos.queueing.pe-per-class-queueing-behaviors.cos2-queueing = WRED
+operational-data.avpn-ip-port-information.port-level-cos.queueing.pe-per-class-queueing-behaviors.cos2v-queueing = QueueLimit
+operational-data.avpn-ip-port-information.port-level-cos.queueing.pe-per-class-queueing-behaviors.cos3-queueing = WRED
+operational-data.avpn-ip-port-information.port-level-cos.shaping.pe-egress-per-class-shaping-behaviors.cos2-shaping = Disable
+operational-data.avpn-ip-port-information.port-level-cos.shaping.pe-egress-per-class-shaping-behaviors.cos2v-shaping = Enable
+operational-data.avpn-ip-port-information.port-level-cos.shaping.pe-egress-per-class-shaping-behaviors.cos3-shaping = Disable
+operational-data.avpn-ip-port-information.port-level-cos.shaping.pe-egress-per-class-shaping-codes.cos2-shaping-code = W
+operational-data.avpn-ip-port-information.port-level-cos.shaping.pe-egress-per-class-shaping-codes.cos2v-shaping-code = P
+service-configuration-notification-input.ack-final-indicator = Y
+service-configuration-notification-input.response-code = 0
+service-configuration-notification-input.response-message = Plc Activation Failed: Device gblond2005me6 Sync-from Failed. Please check device IP address and NCS setup.
+service-configuration-notification-input.service-information.service-instance-id = TEST7
+service-configuration-notification-input.service-information.service-type = AVPN
+service-configuration-notification-input.svc-request-id = TEST7
+service-data.avpn-ip-port-information.avpn-access-information.access-circuit-id = DHEC.54831.170.ATI
+service-data.avpn-ip-port-information.avpn-access-information.access-interface = _1G
+service-data.avpn-ip-port-information.avpn-access-information.access-speed = 10000
+service-data.avpn-ip-port-information.avpn-access-information.access-speed-units = Kbps
+service-data.avpn-ip-port-information.avpn-access-information.l1-customer-handoff = _1000BASELX
+service-data.avpn-ip-port-information.avpn-access-information.managed-ce = N
+service-data.avpn-ip-port-information.avpn-access-information.vlan-tag-control = _1Q
+service-data.avpn-ip-port-information.clli = LONDENEH
+service-data.avpn-ip-port-information.contracted-port-speed = 10000
+service-data.avpn-ip-port-information.contracted-port-speed-units = Kbps
+service-data.avpn-ip-port-information.endpoint-information.bundle-id = 33
+service-data.avpn-ip-port-information.endpoint-information.interface-string = ae0
+service-data.service-information.service-instance-id = ICORESITE-2751508
+service-data.service-information.service-type = AVPN
+obfuscated-var=${deployer_pass}
diff --git a/plugins/properties-node/provider/src/test/resources/test.xml b/plugins/properties-node/provider/src/test/resources/test.xml
new file mode 100644
index 000000000..19e3b7139
--- /dev/null
+++ b/plugins/properties-node/provider/src/test/resources/test.xml
@@ -0,0 +1,182 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ============LICENSE_START=======================================================
+ openECOMP : SDN-C
+ ================================================================================
+ Copyright (C) 2017 AT&T Intellectual Property. 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=========================================================
+ -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.onap.ccsdk.sli.plugins</groupId>
+ <artifactId>restapi-call-node</artifactId>
+ <version>6.0.0-SNAPSHOT</version>
+ </parent>
+ <artifactId>restapi-call-node-provider</artifactId>
+ <packaging>bundle</packaging>
+ <name>RESTAPI Call Node - Provider</name>
+ <url>http://maven.apache.org</url>
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ </properties>
+ <dependencies>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-test</artifactId>
+ <version>3.1.4.RELEASE</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.onap.ccsdk.sli</groupId>
+ <artifactId>sli-common</artifactId>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.onap.ccsdk.sli</groupId>
+ <artifactId>sli-provider</artifactId>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ <version>${slf4j.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>jcl-over-slf4j</artifactId>
+ <version>${slf4j.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-beans</artifactId>
+ <version>3.1.4.RELEASE</version>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-context</artifactId>
+ <version>3.1.4.RELEASE</version>
+ </dependency>
+ <dependency>
+ <groupId>xerces</groupId>
+ <artifactId>xerces</artifactId>
+ <version>2.4.0</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>com.sun.jersey</groupId>
+ <artifactId>jersey-client</artifactId>
+ <version>1.17</version>
+ </dependency>
+ <dependency>
+ <groupId>com.sun.jersey.contribs.jersey-oauth</groupId>
+ <artifactId>oauth-signature</artifactId>
+ <version>1.17</version>
+ </dependency>
+ <dependency>
+ <groupId>com.sun.jersey.contribs.jersey-oauth</groupId>
+ <artifactId>oauth-client</artifactId>
+ <version>1.17</version>
+ </dependency>
+ <dependency>
+ <groupId>commons-codec</groupId>
+ <artifactId>commons-codec</artifactId>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>com.brocade.developer</groupId>
+ <artifactId>providermodule-plugin</artifactId>
+ <configuration>
+ <packageId>org.onap.ccsdk.sli.plugins</packageId>
+ <appName>restapi-call-node</appName>
+ </configuration>
+ <executions>
+ <execution>
+ <phase>process-sources</phase>
+ <goals>
+ <goal>process</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+
+
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <extensions>true</extensions>
+ <configuration>
+ <instructions>
+ <Bundle-SymbolicName>org.onap.ccsdk.sli.plugins.restapicall</Bundle-SymbolicName>
+ <Export-Package>org.onap.ccsdk.sli.plugins.restapicall</Export-Package>
+ <Import-Package>*</Import-Package>
+ </instructions>
+
+ <manifestLocation>${project.basedir}/src/main/resources/META-INF</manifestLocation>
+
+ </configuration>
+
+ </plugin>
+
+
+ </plugins>
+ <pluginManagement>
+ <plugins>
+ <!--This plugin's configuration is used to store Eclipse m2e settings
+ only. It has no influence on the Maven build itself. -->
+ <plugin>
+ <groupId>org.eclipse.m2e</groupId>
+ <artifactId>lifecycle-mapping</artifactId>
+ <version>1.0.0</version>
+ <configuration>
+ <lifecycleMappingMetadata>
+ <pluginExecutions>
+ <pluginExecution>
+ <pluginExecutionFilter>
+ <groupId>
+ com.brocade.developer
+ </groupId>
+ <artifactId>
+ providermodule-plugin
+ </artifactId>
+ <versionRange>
+ [1.2.0.100,)
+ </versionRange>
+ <goals>
+ <goal>process</goal>
+ </goals>
+ </pluginExecutionFilter>
+ <action>
+ <ignore />
+ </action>
+ </pluginExecution>
+ </pluginExecutions>
+ </lifecycleMappingMetadata>
+ </configuration>
+ </plugin>
+ </plugins>
+ </pluginManagement>
+ </build>
+</project>
diff --git a/plugins/properties-node/provider/src/test/resources/test3.xml b/plugins/properties-node/provider/src/test/resources/test3.xml
new file mode 100644
index 000000000..ade412681
--- /dev/null
+++ b/plugins/properties-node/provider/src/test/resources/test3.xml
@@ -0,0 +1,82 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<!--
+ ============LICENSE_START=======================================================
+ openECOMP : SDN-C
+ ================================================================================
+ Copyright (C) 2017 AT&T Intellectual Property. 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=========================================================
+ -->
+
+<ApplyGroupResponse xmlns="http://onap.org/vpn/schema/v1"
+ xmlns:ns2="http://onap.org/prov/vpn/schema/v2">
+ <ApplyGroupResponseData>
+ <ServiceInstanceId>ICOREPVC-81114561</ServiceInstanceId>
+ <VrfDetails>
+ <End2EndVpnKey>VPNL811182</End2EndVpnKey>
+ <VpnId>811182</VpnId>
+ <VrfName>21302:811182</VrfName>
+ <VrfImport>SET_BVOIP_IN</VrfImport>
+ <VrfImport>SET6_BVOIP_IN</VrfImport>
+ <VrfExport>SET6_DSU</VrfExport>
+ <VrfExport>SET_DSU</VrfExport>
+ <VrfExport>SET6_MANAGED</VrfExport>
+ <VrfExport>SET_MANAGED</VrfExport>
+ <VrfExport>SET_LOVRF_COMMUNITY</VrfExport>
+ <VrfExport>SET_RESET_LP</VrfExport>
+ <ApplyGroup>
+ <ns2:ApplyGroup>AG_MAX_MCASTROUTES</ns2:ApplyGroup>
+ </ApplyGroup>
+ </VrfDetails>
+ <RoutingApplyGroups>
+ <RoutingProtocol>BGP4_PROTOCOL</RoutingProtocol>
+ <Family>v4</Family>
+ <PeerGroupName>gp_21302:811182</PeerGroupName>
+ <ApplyGroupPeer>
+ <ns2:ApplyGroup>AG_L3VPN_EBGP</ns2:ApplyGroup>
+ </ApplyGroupPeer>
+ <ApplyGroupPeer>
+ <ns2:ApplyGroup>AG_MAX_PREFIX</ns2:ApplyGroup>
+ </ApplyGroupPeer>
+ <ApplyGroupNeighbour>
+ <ns2:ApplyGroup>AG_BGP_UNMANAGED</ns2:ApplyGroup>
+ </ApplyGroupNeighbour>
+ <ApplyGroupNeighbour>
+ <ns2:ApplyGroup>AG_BFD_BGP_3000</ns2:ApplyGroup>
+ </ApplyGroupNeighbour>
+ </RoutingApplyGroups>
+ <RoutingApplyGroups>
+ <RoutingProtocol>BGP4_PROTOCOL</RoutingProtocol>
+ <Family>v6</Family>
+ <PeerGroupName>gp6_21302:811182</PeerGroupName>
+ <ApplyGroupPeer>
+ <ns2:ApplyGroup>AG6_L3VPN_EBGP</ns2:ApplyGroup>
+ </ApplyGroupPeer>
+ <ApplyGroupPeer>
+ <ns2:ApplyGroup>AG6_MAX_PREFIX</ns2:ApplyGroup>
+ </ApplyGroupPeer>
+ <ApplyGroupNeighbour>
+ <ns2:ApplyGroup>AG6_BGP_UNMANAGED</ns2:ApplyGroup>
+ </ApplyGroupNeighbour>
+ <ApplyGroupNeighbour>
+ <ns2:ApplyGroup>AG6_BFD_BGP_3000</ns2:ApplyGroup>
+ </ApplyGroupNeighbour>
+ </RoutingApplyGroups>
+ </ApplyGroupResponseData>
+ <response-code>200</response-code>
+ <response-message>Success</response-message>
+ <ack-final-indicator>Y</ack-final-indicator>
+</ApplyGroupResponse>
+