aboutsummaryrefslogtreecommitdiffstats
path: root/appc-outbound/appc-network-inventory-client/provider/src/test/java/org/onap
diff options
context:
space:
mode:
authorPatrick Brady <pb071s@att.com>2017-12-13 11:19:06 -0800
committerPatrick Brady <pb071s@att.com>2017-12-13 11:19:17 -0800
commit781b1a6df324419c846c84ea983c18fc8362bfd3 (patch)
tree580008010dd50ca32db2ef6dc2e36628cf8c2b5b /appc-outbound/appc-network-inventory-client/provider/src/test/java/org/onap
parent161df8a94bb3b0c34ed16fd4fdba078bd1eeef9a (diff)
Third part of onap rename
This part of the commit changes the folder structure on all other folders of appc. Change-Id: I8acfa11cdfcdcd36be0e137245d1dd7324f1abd3 Signed-off-by: Patrick Brady <pb071s@att.com> Issue-ID: APPC-13
Diffstat (limited to 'appc-outbound/appc-network-inventory-client/provider/src/test/java/org/onap')
-rw-r--r--appc-outbound/appc-network-inventory-client/provider/src/test/java/org/onap/appc/instar/interfaceImpl/TestInstarResponseHandlerImpl.java78
-rw-r--r--appc-outbound/appc-network-inventory-client/provider/src/test/java/org/onap/appc/instar/interfaceImpl/TestInstarRestClientImpl.java43
-rw-r--r--appc-outbound/appc-network-inventory-client/provider/src/test/java/org/onap/appc/instar/interfaceImpl/TestInterfaceIpAddressImpl.java65
-rw-r--r--appc-outbound/appc-network-inventory-client/provider/src/test/java/org/onap/appc/instar/node/TestDme2Client.java46
-rw-r--r--appc-outbound/appc-network-inventory-client/provider/src/test/java/org/onap/appc/instar/node/TestInstarClientNode.java83
-rw-r--r--appc-outbound/appc-network-inventory-client/provider/src/test/java/org/onap/appc/instar/node/TestSecureRestClientTrustManager.java43
6 files changed, 358 insertions, 0 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
new file mode 100644
index 000000000..1d0db357a
--- /dev/null
+++ b/appc-outbound/appc-network-inventory-client/provider/src/test/java/org/onap/appc/instar/interfaceImpl/TestInstarResponseHandlerImpl.java
@@ -0,0 +1,78 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP : APPC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Copyright (C) 2017 Amdocs
+ * =============================================================================
+ * 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 org.junit.Test;
+import org.openecomp.sdnc.config.params.data.ResponseKey;
+import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
+
+public class TestInstarResponseHandlerImpl {
+
+ @Test
+ public void testProcessResponseForIpv4(){
+ ResponseKey resKey = new ResponseKey();
+ resKey.setUniqueKeyValue("x");
+ SvcLogicContext svc = new SvcLogicContext();
+ svc.setAttribute("vnf-name", "fqdn");
+ resKey.setFieldKeyName("ipaddress-v4");
+ String instarKey = "key";
+ String instarRes ="{\"vnfConfigurationParameterDetails\":"
+ + "[{\"fqdn\":\"fqdnx\",\"v4IPAddress\":\"value2\"}]}";
+ InstarResponseHandlerImpl impl = new InstarResponseHandlerImpl(resKey,svc);
+ impl.processResponse(instarRes, instarKey);
+ }
+
+ @Test
+ public void testProcessResponseForIpv6(){
+ ResponseKey resKey = new ResponseKey();
+ resKey.setUniqueKeyValue("x");
+ SvcLogicContext svc = new SvcLogicContext();
+ svc.setAttribute("vnf-name", "fqdn");
+ resKey.setFieldKeyName("ipaddress-v6");
+ String instarKey = "key";
+ String instarRes ="{\"vnfConfigurationParameterDetails\":"
+ + "[{\"fqdn\":\"fqdnx\",\"v6IPAddress\":\"value2\"}]}";
+ InstarResponseHandlerImpl impl = new InstarResponseHandlerImpl(resKey,svc);
+ impl.processResponse(instarRes, instarKey);
+ }
+
+ @Test
+ public void testProcessResponseInstarKeyValues(){
+
+ ResponseKey resKey = new ResponseKey();
+ resKey.setUniqueKeyValue("x");
+ String json ="{\"vnfConfigurationParameterDetails\":"
+ + "[{\"fqdn\":\"fqdnx\",\"v4IPAddress\":\"value2\"}]}";
+ SvcLogicContext svc = new SvcLogicContext();
+ svc.setAttribute("vnf-name", "fqdn");
+ svc.setAttribute("INSTAR-KEY-VALUES", json);
+ resKey.setFieldKeyName("ipaddress-v6");
+ String instarKey = "key";
+ String instarRes ="{\"vnfConfigurationParameterDetails\":"
+ + "[{\"fqdn\":\"fqdnx\",\"v6IPAddress\":\"value2\"}]}";
+ InstarResponseHandlerImpl impl = new InstarResponseHandlerImpl(resKey,svc);
+ impl.processResponse(instarRes, instarKey);
+ }
+}
diff --git a/appc-outbound/appc-network-inventory-client/provider/src/test/java/org/onap/appc/instar/interfaceImpl/TestInstarRestClientImpl.java b/appc-outbound/appc-network-inventory-client/provider/src/test/java/org/onap/appc/instar/interfaceImpl/TestInstarRestClientImpl.java
new file mode 100644
index 000000000..cf2427dc1
--- /dev/null
+++ b/appc-outbound/appc-network-inventory-client/provider/src/test/java/org/onap/appc/instar/interfaceImpl/TestInstarRestClientImpl.java
@@ -0,0 +1,43 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP : APPC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Copyright (C) 2017 Amdocs
+ * =============================================================================
+ * 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 java.util.HashMap;
+import org.junit.Test;
+import org.mockito.Mockito;
+import org.onap.appc.instar.dme2client.Dme2Client;
+
+public class TestInstarRestClientImpl {
+
+ @Test(expected=Exception.class)
+ public void testSendRequest() throws Exception{
+ HashMap<String,String> map = new HashMap<>();
+ map.put("key", "value");
+ Dme2Client client = Mockito.mock(Dme2Client.class);
+ Mockito.when(client.send()).thenReturn("test");
+ InstarRestClientImpl imp = new InstarRestClientImpl(map);
+ imp.sendRequest("getIpAddressByVnf");
+ }
+}
diff --git a/appc-outbound/appc-network-inventory-client/provider/src/test/java/org/onap/appc/instar/interfaceImpl/TestInterfaceIpAddressImpl.java b/appc-outbound/appc-network-inventory-client/provider/src/test/java/org/onap/appc/instar/interfaceImpl/TestInterfaceIpAddressImpl.java
new file mode 100644
index 000000000..f29bebd7e
--- /dev/null
+++ b/appc-outbound/appc-network-inventory-client/provider/src/test/java/org/onap/appc/instar/interfaceImpl/TestInterfaceIpAddressImpl.java
@@ -0,0 +1,65 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP : APPC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Copyright (C) 2017 Amdocs
+ * =============================================================================
+ * 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 java.util.ArrayList;
+import java.util.List;
+import org.junit.Test;
+import org.openecomp.sdnc.config.params.data.Parameter;
+import org.openecomp.sdnc.config.params.data.ResponseKey;
+import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
+
+public class TestInterfaceIpAddressImpl {
+
+ @Test(expected=Exception.class)
+ public void testProcessRuleException1() throws Exception{
+ Parameter param = new Parameter();
+ param.setRuleType("test");
+ param.setName("test");
+ param.setSource("INSTAR");
+ SvcLogicContext svc = new SvcLogicContext();
+ svc.setAttribute("vnf-name", "test");
+ InterfaceIpAddressImpl impl = new InterfaceIpAddressImpl(param,svc);
+ impl.processRule();
+ }
+
+ @Test(expected=Exception.class)
+ public void testProcessRuleException2() throws Exception{
+ List<ResponseKey> list = new ArrayList<>();
+ list.add(new ResponseKey());
+ list.add(new ResponseKey());
+ Parameter param = new Parameter();
+ param.setResponseKeys(list);
+ param.setRuleType("test");
+ param.setName("test");
+ param.setSource("INSTAR");
+ SvcLogicContext svc = new SvcLogicContext();
+ svc.setAttribute("vnf-name", "test");
+ InterfaceIpAddressImpl impl = new InterfaceIpAddressImpl(param,svc);
+ impl.processRule();
+ param.setSource("INSTAR1");
+ impl.processRule();
+ }
+}
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
new file mode 100644
index 000000000..8e87ffe35
--- /dev/null
+++ b/appc-outbound/appc-network-inventory-client/provider/src/test/java/org/onap/appc/instar/node/TestDme2Client.java
@@ -0,0 +1,46 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP : APPC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Copyright (C) 2017 Amdocs
+ * =============================================================================
+ * 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 java.util.HashMap;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.onap.appc.instar.dme2client.Dme2Client;
+import org.powermock.api.mockito.PowerMockito;
+import org.powermock.modules.junit4.PowerMockRunner;
+
+@RunWith(PowerMockRunner.class)
+public class TestDme2Client {
+
+ @Test(expected=Exception.class)
+ public void testSendtoInstar() throws Exception{
+
+ HashMap<String,String> data = new HashMap<String,String>();
+ data.put("subtext","value");
+ PowerMockito.mockStatic(System.class);
+ PowerMockito.when((System.getenv("test"))).thenReturn("test");
+ Dme2Client dme2 = new Dme2Client("opt","subtext",data);
+ }
+}
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
new file mode 100644
index 000000000..285662f75
--- /dev/null
+++ b/appc-outbound/appc-network-inventory-client/provider/src/test/java/org/onap/appc/instar/node/TestInstarClientNode.java
@@ -0,0 +1,83 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP : APPC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Copyright (C) 2017 Amdocs
+ * =============================================================================
+ * 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 java.net.URI;
+import java.nio.charset.Charset;
+import java.util.HashMap;
+import java.util.Map;
+import javax.net.ssl.HostnameVerifier;
+import javax.net.ssl.SSLContext;
+import javax.ws.rs.HttpMethod;
+
+import org.apache.commons.io.IOUtils;
+import org.json.JSONObject;
+import org.junit.Assert;
+import org.junit.Test;
+import org.onap.appc.instar.dme2client.SecureRestClientTrustManager;
+import org.onap.appc.instar.utils.InstarClientConstant;
+import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
+
+import com.sun.jersey.api.client.Client;
+import com.sun.jersey.api.client.ClientResponse;
+import com.sun.jersey.api.client.WebResource;
+import com.sun.jersey.api.client.config.DefaultClientConfig;
+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>();
+ inParams.put(InstarClientConstant.INPUT_PARAM_RESPONSE_PRIFIX, "TEST");
+ inParams.put(InstarClientConstant.INSTAR_KEYS, "LOCAL_ACCESS_IP_ADDR");
+ inParams.put("operationName", InstarClientConstant.OPERATION_GET_IPADDRESS_BY_VNF_NAME);
+ ctx.setAttribute("INSTAR.LOCAL_ACCESS_IP_ADDR", key_conetent);
+ ctx.setAttribute(InstarClientConstant.INPUT_PARAM_RESPONSE_PRIFIX, "TEST");
+ ctx.setAttribute(InstarClientConstant.VNF_NAME, "basx0003v");
+ InstarClientNode icn = new InstarClientNode();
+ icn.getInstarInfo(inParams, ctx);
+ String address = (new JSONObject(ctx.getAttribute("TEST." + InstarClientConstant.INSTAR_KEY_VALUES))).getString("LOCAL_ACCESS_IP_ADDR");
+ }
+ @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);
+ inNode.getInstarData(inParams, ctx);
+
+
+ }
+}
diff --git a/appc-outbound/appc-network-inventory-client/provider/src/test/java/org/onap/appc/instar/node/TestSecureRestClientTrustManager.java b/appc-outbound/appc-network-inventory-client/provider/src/test/java/org/onap/appc/instar/node/TestSecureRestClientTrustManager.java
new file mode 100644
index 000000000..b18673a40
--- /dev/null
+++ b/appc-outbound/appc-network-inventory-client/provider/src/test/java/org/onap/appc/instar/node/TestSecureRestClientTrustManager.java
@@ -0,0 +1,43 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP : APPC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Copyright (C) 2017 Amdocs
+ * =============================================================================
+ * 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 java.security.cert.CertificateException;
+import java.security.cert.X509Certificate;
+import org.junit.Test;
+import org.mockito.Mockito;
+import org.onap.appc.instar.dme2client.SecureRestClientTrustManager;
+
+public class TestSecureRestClientTrustManager {
+
+ @Test
+ public void testSecureRestClient() throws CertificateException{
+ X509Certificate[] arg0 = new X509Certificate[1];
+ SecureRestClientTrustManager sm = Mockito.mock(SecureRestClientTrustManager.class);
+ Mockito.when(sm.getAcceptedIssuers()).thenReturn(Mockito.any());
+ Mockito.when(sm.isClientTrusted(arg0)).thenReturn(true);
+ Mockito.when(sm.isServerTrusted(arg0)).thenReturn(true);
+ }
+}