summaryrefslogtreecommitdiffstats
path: root/appc-outbound/appc-network-inventory-client/provider
diff options
context:
space:
mode:
authorAnand Chaturvedi <ac204h@att.com>2017-08-25 19:17:38 -0400
committerSkip Wonnell <skip@att.com>2017-08-25 23:54:37 +0000
commit8c5324203efa73fdd6e00e52e92cf1f1bc3910f4 (patch)
treed0f1f357692362334877abb5025cfda3c31bb060 /appc-outbound/appc-network-inventory-client/provider
parent25b7ed894e566f954b51fc5487e9e678557eb2e5 (diff)
Junit for APPC for Network Client
Issue-ID: APPC-168 Change-Id: I0654a0d6123b5827458cd3e15e12a1b5b254f918 Signed-off-by: Anand Chaturvedi <ac204h@att.com>
Diffstat (limited to 'appc-outbound/appc-network-inventory-client/provider')
-rw-r--r--appc-outbound/appc-network-inventory-client/provider/src/test/java/org/openecomp/appc/instar/interfaceImpl/TestInstarResponseHandlerImpl.java78
-rw-r--r--appc-outbound/appc-network-inventory-client/provider/src/test/java/org/openecomp/appc/instar/interfaceImpl/TestInstarRestClientImpl.java43
-rw-r--r--appc-outbound/appc-network-inventory-client/provider/src/test/java/org/openecomp/appc/instar/interfaceImpl/TestInterfaceIpAddressImpl.java65
-rw-r--r--appc-outbound/appc-network-inventory-client/provider/src/test/java/org/openecomp/appc/instar/node/Dme2ClientTest.java0
-rw-r--r--appc-outbound/appc-network-inventory-client/provider/src/test/java/org/openecomp/appc/instar/node/TestDme2Client.java46
-rw-r--r--appc-outbound/appc-network-inventory-client/provider/src/test/java/org/openecomp/appc/instar/node/TestSecureRestClientTrustManager.java43
6 files changed, 275 insertions, 0 deletions
diff --git a/appc-outbound/appc-network-inventory-client/provider/src/test/java/org/openecomp/appc/instar/interfaceImpl/TestInstarResponseHandlerImpl.java b/appc-outbound/appc-network-inventory-client/provider/src/test/java/org/openecomp/appc/instar/interfaceImpl/TestInstarResponseHandlerImpl.java
new file mode 100644
index 000000000..d5b082472
--- /dev/null
+++ b/appc-outbound/appc-network-inventory-client/provider/src/test/java/org/openecomp/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.openecomp.appc.instar.interfaceImpl;
+
+import org.junit.Test;
+import org.openecomp.sdnc.config.params.data.ResponseKey;
+import org.openecomp.sdnc.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/openecomp/appc/instar/interfaceImpl/TestInstarRestClientImpl.java b/appc-outbound/appc-network-inventory-client/provider/src/test/java/org/openecomp/appc/instar/interfaceImpl/TestInstarRestClientImpl.java
new file mode 100644
index 000000000..eaedea476
--- /dev/null
+++ b/appc-outbound/appc-network-inventory-client/provider/src/test/java/org/openecomp/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.openecomp.appc.instar.interfaceImpl;
+
+import java.util.HashMap;
+import org.junit.Test;
+import org.mockito.Mockito;
+import org.openecomp.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/openecomp/appc/instar/interfaceImpl/TestInterfaceIpAddressImpl.java b/appc-outbound/appc-network-inventory-client/provider/src/test/java/org/openecomp/appc/instar/interfaceImpl/TestInterfaceIpAddressImpl.java
new file mode 100644
index 000000000..6b71bb1d3
--- /dev/null
+++ b/appc-outbound/appc-network-inventory-client/provider/src/test/java/org/openecomp/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.openecomp.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.openecomp.sdnc.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/openecomp/appc/instar/node/Dme2ClientTest.java b/appc-outbound/appc-network-inventory-client/provider/src/test/java/org/openecomp/appc/instar/node/Dme2ClientTest.java
deleted file mode 100644
index e69de29bb..000000000
--- a/appc-outbound/appc-network-inventory-client/provider/src/test/java/org/openecomp/appc/instar/node/Dme2ClientTest.java
+++ /dev/null
diff --git a/appc-outbound/appc-network-inventory-client/provider/src/test/java/org/openecomp/appc/instar/node/TestDme2Client.java b/appc-outbound/appc-network-inventory-client/provider/src/test/java/org/openecomp/appc/instar/node/TestDme2Client.java
new file mode 100644
index 000000000..072050d76
--- /dev/null
+++ b/appc-outbound/appc-network-inventory-client/provider/src/test/java/org/openecomp/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.openecomp.appc.instar.node;
+
+import java.util.HashMap;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.openecomp.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/openecomp/appc/instar/node/TestSecureRestClientTrustManager.java b/appc-outbound/appc-network-inventory-client/provider/src/test/java/org/openecomp/appc/instar/node/TestSecureRestClientTrustManager.java
new file mode 100644
index 000000000..11fe58b67
--- /dev/null
+++ b/appc-outbound/appc-network-inventory-client/provider/src/test/java/org/openecomp/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.openecomp.appc.instar.node;
+
+import java.security.cert.CertificateException;
+import java.security.cert.X509Certificate;
+import org.junit.Test;
+import org.mockito.Mockito;
+import org.openecomp.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);
+ }
+}