aboutsummaryrefslogtreecommitdiffstats
path: root/appc-outbound/appc-network-inventory-client/provider/src/test
diff options
context:
space:
mode:
authorDilip kumar Pampana <dp583p@att.com>2018-01-09 17:24:35 -0500
committerSkip Wonnell <skip@att.com>2018-01-10 11:13:11 -0600
commit8a10978ba382816c1497639034617928a2c003f8 (patch)
treeb39081bf167462069b0613a95799fc67fd36f0f7 /appc-outbound/appc-network-inventory-client/provider/src/test
parent14ee9cc1ceb81bd6fe963e4d3580595830885714 (diff)
Network Inventory Client Updates
Supporting IPv4/v6 Subnet and Gateway Addresses From INSTAR,Added code to process A&AI as source in PD file,New Requirement to extract vnfc information for single vserver for VM level operations Issue-ID: APPC-351 Change-Id: I5c91d03a64fc6987e58ab48681f51dc5795bed07 Signed-off-by: Dilip kumar Pampana <dp583p@att.com>
Diffstat (limited to 'appc-outbound/appc-network-inventory-client/provider/src/test')
-rw-r--r--appc-outbound/appc-network-inventory-client/provider/src/test/java/org/onap/appc/instar/interfaceImpl/TestInstarResponseHandlerImpl.java92
-rw-r--r--appc-outbound/appc-network-inventory-client/provider/src/test/java/org/onap/appc/instar/node/TestDme2Client.java14
-rw-r--r--appc-outbound/appc-network-inventory-client/provider/src/test/java/org/onap/appc/instar/node/TestInstarClientNode.java81
-rw-r--r--appc-outbound/appc-network-inventory-client/provider/src/test/resources/YamlParameter.txt16
-rw-r--r--appc-outbound/appc-network-inventory-client/provider/src/test/resources/YamlParameter2.txt18
-rw-r--r--appc-outbound/appc-network-inventory-client/provider/src/test/resources/YamlParameter3.txt18
-rw-r--r--appc-outbound/appc-network-inventory-client/provider/src/test/resources/YamlParameter4.txt16
7 files changed, 232 insertions, 23 deletions
diff --git a/appc-outbound/appc-network-inventory-client/provider/src/test/java/org/onap/appc/instar/interfaceImpl/TestInstarResponseHandlerImpl.java b/appc-outbound/appc-network-inventory-client/provider/src/test/java/org/onap/appc/instar/interfaceImpl/TestInstarResponseHandlerImpl.java
index b0ad3c184..693ff7755 100644
--- a/appc-outbound/appc-network-inventory-client/provider/src/test/java/org/onap/appc/instar/interfaceImpl/TestInstarResponseHandlerImpl.java
+++ b/appc-outbound/appc-network-inventory-client/provider/src/test/java/org/onap/appc/instar/interfaceImpl/TestInstarResponseHandlerImpl.java
@@ -9,29 +9,32 @@
* 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.
- *
+ *
* ECOMP is a trademark and service mark of AT&T Intellectual Property.
* ============LICENSE_END=========================================================
*/
package org.onap.appc.instar.interfaceImpl;
+import static org.junit.Assert.assertTrue;
+
import org.junit.Test;
+import org.onap.appc.instar.utils.InstarClientConstant;
import org.onap.sdnc.config.params.data.ResponseKey;
import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
public class TestInstarResponseHandlerImpl {
@Test
- public void testProcessResponseForIpv4(){
+ public void testProcessResponseForIpv4() {
ResponseKey resKey = new ResponseKey();
resKey.setUniqueKeyValue("x");
SvcLogicContext svc = new SvcLogicContext();
@@ -42,10 +45,10 @@ public class TestInstarResponseHandlerImpl {
+ "[{\"fqdn\":\"fqdnx\",\"v4IPAddress\":\"value2\"}]}";
InstarResponseHandlerImpl impl = new InstarResponseHandlerImpl(resKey,svc);
impl.processResponse(instarRes, instarKey);
- }
+ }
@Test
- public void testProcessResponseForIpv6(){
+ public void testProcessResponseForIpv6() {
ResponseKey resKey = new ResponseKey();
resKey.setUniqueKeyValue("x");
SvcLogicContext svc = new SvcLogicContext();
@@ -57,10 +60,9 @@ public class TestInstarResponseHandlerImpl {
InstarResponseHandlerImpl impl = new InstarResponseHandlerImpl(resKey,svc);
impl.processResponse(instarRes, instarKey);
}
-
+
@Test
- public void testProcessResponseInstarKeyValues(){
-
+ public void testProcessResponseInstarKeyValues() {
ResponseKey resKey = new ResponseKey();
resKey.setUniqueKeyValue("x");
String json ="{\"vnfConfigurationParameterDetails\":"
@@ -75,4 +77,76 @@ public class TestInstarResponseHandlerImpl {
InstarResponseHandlerImpl impl = new InstarResponseHandlerImpl(resKey,svc);
impl.processResponse(instarRes, instarKey);
}
+
+ @Test
+ public void testV4SubNet() {
+ ResponseKey resKey = new ResponseKey();
+ resKey.setUniqueKeyValue("x");
+ resKey.setFieldKeyName(InstarClientConstant.INSTAR_V4_SUBNET);
+ String json ="{\"v4IpAddress\":\"ipAddressV4\"}]}";
+ SvcLogicContext ctx = new SvcLogicContext();
+ ctx.setAttribute("vnf-name", "fqdn");
+ ctx.setAttribute("INSTAR-KEY-VALUES", json);
+ String instarKey = "V4SubnetParameter";
+ String instarRes ="{\"vnfConfigurationParameterDetails\":"
+ + "[{\"fqdn\":\"fqdnx\",\"v4Subnet\":\"subnetv4\"}]}";
+ InstarResponseHandlerImpl impl = new InstarResponseHandlerImpl(resKey,ctx);
+ impl.processResponse(instarRes, instarKey);
+ String values = ctx.getAttribute("INSTAR-KEY-VALUES");
+ assertTrue(values.contains("subnetv4"));
+ }
+
+ @Test
+ public void testV6SubNet() {
+ ResponseKey resKey = new ResponseKey();
+ resKey.setUniqueKeyValue("x");
+ resKey.setFieldKeyName(InstarClientConstant.INSTAR_V6_SUBNET);
+ String json ="{\"v6IpAddress\":\"ipAddressV6\"}]}";
+ SvcLogicContext ctx = new SvcLogicContext();
+ ctx.setAttribute("vnf-name", "fqdn");
+ ctx.setAttribute("INSTAR-KEY-VALUES", json);
+ String instarKey = "V6SubnetParameter";
+ String instarRes ="{\"vnfConfigurationParameterDetails\":"
+ + "[{\"fqdn\":\"fqdnx\",\"v6Subnet\":\"subnetv6\"}]}";
+ InstarResponseHandlerImpl impl = new InstarResponseHandlerImpl(resKey,ctx);
+ impl.processResponse(instarRes, instarKey);
+ String values = ctx.getAttribute("INSTAR-KEY-VALUES");
+ assertTrue(values.contains("subnetv6"));
+ }
+
+ @Test
+ public void testV6DefaultGateway() {
+ ResponseKey resKey = new ResponseKey();
+ resKey.setUniqueKeyValue("x");
+ resKey.setFieldKeyName(InstarClientConstant.INSTAR_V6_DEFAULT_GATEWAY);
+ String json ="{\"v6IpAddress\":\"ipAddressV6\"}]}";
+ SvcLogicContext ctx = new SvcLogicContext();
+ ctx.setAttribute("vnf-name", "fqdn");
+ ctx.setAttribute("INSTAR-KEY-VALUES", json);
+ String instarKey = "V6DefaultGatewayParameter";
+ String instarRes ="{\"vnfConfigurationParameterDetails\":"
+ + "[{\"fqdn\":\"fqdnx\",\"v6DefaultGateway\":\"defaultGatewayV6\"}]}";
+ InstarResponseHandlerImpl impl = new InstarResponseHandlerImpl(resKey,ctx);
+ impl.processResponse(instarRes, instarKey);
+ String values = ctx.getAttribute("INSTAR-KEY-VALUES");
+ assertTrue(values.contains("defaultGatewayV6"));
+ }
+
+ @Test
+ public void testV4DefaultGateway() {
+ ResponseKey resKey = new ResponseKey();
+ resKey.setUniqueKeyValue("x");
+ resKey.setFieldKeyName(InstarClientConstant.INSTAR_V4_DEFAULT_GATEWAY);
+ String json ="{\"v4IpAddress\":\"ipAddressV4\"}]}";
+ SvcLogicContext ctx = new SvcLogicContext();
+ ctx.setAttribute("vnf-name", "fqdn");
+ ctx.setAttribute("INSTAR-KEY-VALUES", json);
+ String instarKey = "V4DefaultGatewayParameter";
+ String instarRes ="{\"vnfConfigurationParameterDetails\":"
+ + "[{\"fqdn\":\"fqdnx\",\"v4DefaultGateway\":\"defaultGatewayV4\"}]}";
+ InstarResponseHandlerImpl impl = new InstarResponseHandlerImpl(resKey,ctx);
+ impl.processResponse(instarRes, instarKey);
+ String values = ctx.getAttribute("INSTAR-KEY-VALUES");
+ assertTrue(values.contains("defaultGatewayV4"));
+ }
}
diff --git a/appc-outbound/appc-network-inventory-client/provider/src/test/java/org/onap/appc/instar/node/TestDme2Client.java b/appc-outbound/appc-network-inventory-client/provider/src/test/java/org/onap/appc/instar/node/TestDme2Client.java
index 8e87ffe35..688a64af9 100644
--- a/appc-outbound/appc-network-inventory-client/provider/src/test/java/org/onap/appc/instar/node/TestDme2Client.java
+++ b/appc-outbound/appc-network-inventory-client/provider/src/test/java/org/onap/appc/instar/node/TestDme2Client.java
@@ -9,21 +9,23 @@
* 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.
- *
+ *
* ECOMP is a trademark and service mark of AT&T Intellectual Property.
* ============LICENSE_END=========================================================
*/
package org.onap.appc.instar.node;
+import static org.junit.Assert.assertTrue;
+
import java.util.HashMap;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -33,10 +35,10 @@ import org.powermock.modules.junit4.PowerMockRunner;
@RunWith(PowerMockRunner.class)
public class TestDme2Client {
-
+
@Test(expected=Exception.class)
- public void testSendtoInstar() throws Exception{
-
+ public void testSendtoInstar() throws Exception {
+
HashMap<String,String> data = new HashMap<String,String>();
data.put("subtext","value");
PowerMockito.mockStatic(System.class);
diff --git a/appc-outbound/appc-network-inventory-client/provider/src/test/java/org/onap/appc/instar/node/TestInstarClientNode.java b/appc-outbound/appc-network-inventory-client/provider/src/test/java/org/onap/appc/instar/node/TestInstarClientNode.java
index 285662f75..bca2087e8 100644
--- a/appc-outbound/appc-network-inventory-client/provider/src/test/java/org/onap/appc/instar/node/TestInstarClientNode.java
+++ b/appc-outbound/appc-network-inventory-client/provider/src/test/java/org/onap/appc/instar/node/TestInstarClientNode.java
@@ -9,21 +9,23 @@
* 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.
- *
+ *
* ECOMP is a trademark and service mark of AT&T Intellectual Property.
* ============LICENSE_END=========================================================
*/
package org.onap.appc.instar.node;
+import static org.junit.Assert.assertTrue;
+
import java.net.URI;
import java.nio.charset.Charset;
import java.util.HashMap;
@@ -33,9 +35,11 @@ import javax.net.ssl.SSLContext;
import javax.ws.rs.HttpMethod;
import org.apache.commons.io.IOUtils;
+import org.apache.commons.lang3.StringUtils;
import org.json.JSONObject;
import org.junit.Assert;
import org.junit.Test;
+import org.onap.appc.aai.utils.AaiClientConstant;
import org.onap.appc.instar.dme2client.SecureRestClientTrustManager;
import org.onap.appc.instar.utils.InstarClientConstant;
import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
@@ -48,12 +52,11 @@ import com.sun.jersey.api.client.filter.HTTPBasicAuthFilter;
public class TestInstarClientNode {
-
+
//ONAP Migration
@Test(expected=Exception.class)
public void testInstarClientNode() throws Exception {
-
SvcLogicContext ctx = new SvcLogicContext();
String key_conetent = IOUtils.toString(TestInstarClientNode.class.getClassLoader().getResourceAsStream("templates/sampleKeyContents"), Charset.defaultCharset());
Map<String, String> inParams = new HashMap<String, String>();
@@ -69,15 +72,77 @@ public class TestInstarClientNode {
}
@Test(expected=Exception.class)
public void testInstarData() throws Exception {
-
InstarClientNode inNode = new InstarClientNode();
SvcLogicContext ctx = new SvcLogicContext ();
Map<String, String> inParams = new HashMap<String, String>();
inParams.put(InstarClientConstant.VNF_NAME, "basx0003v");
- inParams.put("operationName", InstarClientConstant.OPERATION_GET_IPADDRESS_BY_VNF_NAME);
+ inParams.put("operationName", InstarClientConstant.OPERATION_GET_IPADDRESS_BY_VNF_NAME);
inNode.getInstarData(inParams, ctx);
-
+ }
+
+ @Test
+ public void TestGetAaiInfo() throws Exception {
+ InstarClientNode aaiNode=new InstarClientNode();
+ Map<String, String> inParams=new HashMap<String, String> ();
+ SvcLogicContext ctx=new SvcLogicContext();
+ String keyVals=new String("[\"LOCAL_CORE_ALT_IP_ADDR\",\"REMOTE_ACCESS_IP_ADDR\",\"PARAMETER3\",\"PARAMETER4\"]");
+ inParams.put("aaiKeys",keyVals);
+ inParams.put("responsePrefix","test");
+ String yamlParameterString=IOUtils.toString(TestInstarClientNode.class.getClassLoader().getResourceAsStream("./YamlParameter.txt"), Charset.defaultCharset());
+ ctx.setAttribute(AaiClientConstant.SOURCE_SYSTEM_AAI + "." + "LOCAL_CORE_ALT_IP_ADDR",yamlParameterString);
+ String yamlParameterString2=IOUtils.toString(TestInstarClientNode.class.getClassLoader().getResourceAsStream("./YamlParameter2.txt"), Charset.defaultCharset());
+ ctx.setAttribute(AaiClientConstant.SOURCE_SYSTEM_AAI + "." + "REMOTE_ACCESS_IP_ADDR",yamlParameterString2);
+ String yamlParameterString3=IOUtils.toString(TestInstarClientNode.class.getClassLoader().getResourceAsStream("./YamlParameter3.txt"), Charset.defaultCharset());
+ ctx.setAttribute(AaiClientConstant.SOURCE_SYSTEM_AAI + "." + "PARAMETER3",yamlParameterString3);
+ String yamlParameterString4=IOUtils.toString(TestInstarClientNode.class.getClassLoader().getResourceAsStream("./YamlParameter4.txt"), Charset.defaultCharset());
+ ctx.setAttribute(AaiClientConstant.SOURCE_SYSTEM_AAI + "." + "PARAMETER4",yamlParameterString4);
+ stubAaiVnfInfoData(ctx);
+ aaiNode.getAaiInfo(inParams, ctx);
+ String [] valToCompare={"\"LOCAL_CORE_ALT_IP_ADDR\":\"testVnf\"",
+ "\"REMOTE_ACCESS_IP_ADDR\":\"testVnfc2,testVnfc3\"",
+ "\"PARAM3\":\"testVnfcIpv4Address1\"",
+ "\"PARAM4\":\"server1,server2,server3\""};
+ String value=ctx.getAttribute("test."+AaiClientConstant.AAI_KEY_VALUES);
+ boolean pass=false;
+ for (int i=0;i<valToCompare.length;i++) {
+ if (!StringUtils.contains(value,valToCompare[i] )) {
+ //System.out.println(value+"....... "+valToCompare[i].toString());
+ pass=false;
+ break;
+ }
+ else {
+ pass=true;
+ }
+ }
+ assertTrue(pass);
+ }
+
+ public void stubAaiVnfInfoData(SvcLogicContext context) {
+
+ context.setAttribute("tmp.vnfInfo.vm-count","3");
+ context.setAttribute("tmp.vnfInfo.vnf.vnf-name","testVnf");
+ context.setAttribute("tmp.vnfInfo.vnf.vnf-oam-ipv4-address","test-ipv4-address");
+ context.setAttribute("tmp.vnfInfo.vm[0].vserver-name","server1");
+ context.setAttribute("tmp.vnfInfo.vm[0].vserver-id","serverId1");
+ context.setAttribute("tmp.vnfInfo.vm[0].vnfc-count","1");
+ context.setAttribute("tmp.vnfInfo.vm[0].vnfc-name","testVnfc1");
+ context.setAttribute("tmp.vnfInfo.vm[0].vnfc-function-code","msc");
+ context.setAttribute("tmp.vnfInfo.vm[0].vnfc-ipaddress-v4-oam-vip","testVnfcIpv4Address1");
+
+ context.setAttribute("tmp.vnfInfo.vm[1].vserver-name","server2");
+ context.setAttribute("tmp.vnfInfo.vm[1].vserver-id","serverId2");
+ context.setAttribute("tmp.vnfInfo.vm[1].vnfc-count","1");
+ context.setAttribute("tmp.vnfInfo.vm[1].vnfc-name","testVnfc2");
+ context.setAttribute("tmp.vnfInfo.vm[1].vnfc-function-code","testFnCode");
+ context.setAttribute("tmp.vnfInfo.vm[1].vnfc-ipaddress-v4-oam-vip","testVnfcIpv4Address2");
+
+ context.setAttribute("tmp.vnfInfo.vm[2].vserver-name","server3");
+ context.setAttribute("tmp.vnfInfo.vm[2].vserver-id","serverId3");
+ context.setAttribute("tmp.vnfInfo.vm[2].vnfc-count","1");
+ context.setAttribute("tmp.vnfInfo.vm[2].vnfc-name","testVnfc3");
+ context.setAttribute("tmp.vnfInfo.vm[2].vnfc-function-code","testFnCode");
+ context.setAttribute("tmp.vnfInfo.vm[2].vnfc-ipaddress-v4-oam-vip","testVnfcIpv4Address3");
}
}
diff --git a/appc-outbound/appc-network-inventory-client/provider/src/test/resources/YamlParameter.txt b/appc-outbound/appc-network-inventory-client/provider/src/test/resources/YamlParameter.txt
new file mode 100644
index 000000000..1e2d347fc
--- /dev/null
+++ b/appc-outbound/appc-network-inventory-client/provider/src/test/resources/YamlParameter.txt
@@ -0,0 +1,16 @@
+name: "LOCAL_CORE_ALT_IP_ADDR"
+description: null
+type: null
+required: false
+source: "A&AI"
+rule-type: null
+default: "0:0:0:0"
+request-keys:
+- key-name: "address_fqdn"
+ key-value: "value"
+- key-name: "address_type"
+ key-value: "v4"
+response-keys:
+- unique-key-name: "parent-name"
+- unique-key-value: "vnf"
+- field-key-name: "vnf-name"
diff --git a/appc-outbound/appc-network-inventory-client/provider/src/test/resources/YamlParameter2.txt b/appc-outbound/appc-network-inventory-client/provider/src/test/resources/YamlParameter2.txt
new file mode 100644
index 000000000..cebc0f9e1
--- /dev/null
+++ b/appc-outbound/appc-network-inventory-client/provider/src/test/resources/YamlParameter2.txt
@@ -0,0 +1,18 @@
+name: "REMOTE_ACCESS_IP_ADDR"
+description: null
+type: null
+required: false
+source: "A&AI"
+rule-type: null
+default: "0:0:0:0"
+request-keys:
+- key-name: "address_fqdn"
+ key-value: "value"
+- key-name: "address_type"
+ key-value: "v4"
+response-keys:
+- unique-key-name: "parent-name"
+- unique-key-value: "vnfc"
+- field-key-name: "vnfc-name"
+- filter-by-field: "vnfc-function-code"
+- filter-by-value: "testFnCode"
diff --git a/appc-outbound/appc-network-inventory-client/provider/src/test/resources/YamlParameter3.txt b/appc-outbound/appc-network-inventory-client/provider/src/test/resources/YamlParameter3.txt
new file mode 100644
index 000000000..060b55eae
--- /dev/null
+++ b/appc-outbound/appc-network-inventory-client/provider/src/test/resources/YamlParameter3.txt
@@ -0,0 +1,18 @@
+name: "PARAM3"
+description: null
+type: null
+required: false
+source: "A&AI"
+rule-type: null
+default: "0:0:0:0"
+request-keys:
+- key-name: "address_fqdn"
+ key-value: "value"
+- key-name: "address_type"
+ key-value: "v4"
+response-keys:
+- unique-key-name: "parent-name"
+- unique-key-value: "vnfc"
+- field-key-name: "ipaddress-v4-oam-vip"
+- filter-by-field: "vnfc-function-code"
+- filter-by-value: "msc"
diff --git a/appc-outbound/appc-network-inventory-client/provider/src/test/resources/YamlParameter4.txt b/appc-outbound/appc-network-inventory-client/provider/src/test/resources/YamlParameter4.txt
new file mode 100644
index 000000000..e334903d1
--- /dev/null
+++ b/appc-outbound/appc-network-inventory-client/provider/src/test/resources/YamlParameter4.txt
@@ -0,0 +1,16 @@
+name: "PARAM4"
+description: null
+type: null
+required: false
+source: "A&AI"
+rule-type: null
+default: "0:0:0:0"
+request-keys:
+- key-name: "address_fqdn"
+ key-value: "value"
+- key-name: "address_type"
+ key-value: "v4"
+response-keys:
+- unique-key-name: "parent-name"
+- unique-key-value: "vserver"
+- field-key-name: "vserver-name"