Junit for APPC for Network Client 39/8839/3
authorAnand Chaturvedi <ac204h@att.com>
Fri, 25 Aug 2017 23:17:38 +0000 (19:17 -0400)
committerSkip Wonnell <skip@att.com>
Fri, 25 Aug 2017 23:54:37 +0000 (23:54 +0000)
Issue-ID: APPC-168
Change-Id: I0654a0d6123b5827458cd3e15e12a1b5b254f918
Signed-off-by: Anand Chaturvedi <ac204h@att.com>
appc-config/appc-data-services/provider/src/test/java/org/openecomp/appc/data/services/db/TestDGGeneralDBService.java
appc-config/appc-data-services/provider/src/test/java/org/openecomp/appc/data/services/db/TestSQLSaveQuery.java
appc-config/appc-encryption-tool/provider/src/test/java/org/openecomp/appc/encryptiontool/TestEncryptionTool.java
appc-outbound/appc-network-inventory-client/provider/src/test/java/org/openecomp/appc/instar/interfaceImpl/TestInstarResponseHandlerImpl.java [new file with mode: 0644]
appc-outbound/appc-network-inventory-client/provider/src/test/java/org/openecomp/appc/instar/interfaceImpl/TestInstarRestClientImpl.java [new file with mode: 0644]
appc-outbound/appc-network-inventory-client/provider/src/test/java/org/openecomp/appc/instar/interfaceImpl/TestInterfaceIpAddressImpl.java [new file with mode: 0644]
appc-outbound/appc-network-inventory-client/provider/src/test/java/org/openecomp/appc/instar/node/Dme2ClientTest.java [deleted file]
appc-outbound/appc-network-inventory-client/provider/src/test/java/org/openecomp/appc/instar/node/TestDme2Client.java [new file with mode: 0644]
appc-outbound/appc-network-inventory-client/provider/src/test/java/org/openecomp/appc/instar/node/TestSecureRestClientTrustManager.java [new file with mode: 0644]

index ec17314..e064406 100644 (file)
@@ -1,9 +1,11 @@
 /*-
  * ============LICENSE_START=======================================================
- * ONAP : APP-C
+ * ONAP : APPC
  * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property.  All rights reserved.
+ * 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
@@ -15,6 +17,8 @@
  * 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.data.services.db;
index b49c887..fd0f3da 100644 (file)
@@ -1,9 +1,11 @@
 /*-
  * ============LICENSE_START=======================================================
- * ONAP : APP-C
+ * ONAP : APPC
  * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property.  All rights reserved.
+ * 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
@@ -15,6 +17,8 @@
  * 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=========================================================
  */
 
index 2ad0a1b..e993007 100644 (file)
@@ -1,9 +1,11 @@
 /*-
  * ============LICENSE_START=======================================================
- * ONAP : APP-C
+ * ONAP : APPC
  * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property.  All rights reserved.
+ * 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
@@ -15,6 +17,8 @@
  * 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=========================================================
  */
 
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 (file)
index 0000000..d5b0824
--- /dev/null
@@ -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 (file)
index 0000000..eaedea4
--- /dev/null
@@ -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 (file)
index 0000000..6b71bb1
--- /dev/null
@@ -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 (file)
index e69de29..0000000
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 (file)
index 0000000..072050d
--- /dev/null
@@ -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 (file)
index 0000000..11fe58b
--- /dev/null
@@ -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);
+    }
+}