diff options
Diffstat (limited to 'appc-outbound')
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); + } +} |