From a9662dd25e81873dfb84a0830e248a43d8bd9f70 Mon Sep 17 00:00:00 2001 From: seshukm Date: Mon, 19 Mar 2018 17:17:11 +0530 Subject: testcases refactored for MsoVnfAdapter Issue-ID: SO-369 Change-Id: I9561825683ecd823dfd55b3feb29f7b03a07cd1c Signed-off-by: seshukm --- .../adapters/vnf/MsoVnfAdapterAsyncImplTest.java | 114 +++++++++++++++++ .../mso/adapters/vnf/MsoVnfAdapterImplTest.java | 91 ++++++++++++++ .../org/openecomp/mso/adapters/vnf/QueryTest.java | 136 +++++++++++++++++++++ .../openecomp/mso/adapters/vnf/VnfCreateTest.java | 87 +++++++++++++ .../openecomp/mso/adapters/vnf/VnfDeleteTest.java | 52 ++++++++ .../openecomp/mso/adapters/vnf/VnfQueryTest.java | 64 ++++++++++ .../vnf/test/MsoVnfAdapterAsyncImplTest.java | 114 ----------------- .../adapters/vnf/test/MsoVnfAdapterImplTest.java | 91 -------------- .../openecomp/mso/adapters/vnf/test/QueryTest.java | 136 --------------------- .../mso/adapters/vnf/test/VnfCreateTest.java | 87 ------------- .../mso/adapters/vnf/test/VnfDeleteTest.java | 52 -------- .../mso/adapters/vnf/test/VnfQueryTest.java | 64 ---------- 12 files changed, 544 insertions(+), 544 deletions(-) create mode 100644 adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/adapters/vnf/MsoVnfAdapterAsyncImplTest.java create mode 100644 adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/adapters/vnf/MsoVnfAdapterImplTest.java create mode 100644 adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/adapters/vnf/QueryTest.java create mode 100644 adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/adapters/vnf/VnfCreateTest.java create mode 100644 adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/adapters/vnf/VnfDeleteTest.java create mode 100644 adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/adapters/vnf/VnfQueryTest.java delete mode 100644 adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/adapters/vnf/test/MsoVnfAdapterAsyncImplTest.java delete mode 100644 adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/adapters/vnf/test/MsoVnfAdapterImplTest.java delete mode 100644 adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/adapters/vnf/test/QueryTest.java delete mode 100644 adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/adapters/vnf/test/VnfCreateTest.java delete mode 100644 adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/adapters/vnf/test/VnfDeleteTest.java delete mode 100644 adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/adapters/vnf/test/VnfQueryTest.java (limited to 'adapters/mso-vnf-adapter/src/test/java/org/openecomp') diff --git a/adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/adapters/vnf/MsoVnfAdapterAsyncImplTest.java b/adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/adapters/vnf/MsoVnfAdapterAsyncImplTest.java new file mode 100644 index 0000000000..acde3153ab --- /dev/null +++ b/adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/adapters/vnf/MsoVnfAdapterAsyncImplTest.java @@ -0,0 +1,114 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.adapters.vnf.test; + +import java.util.HashMap; +import java.util.Map; +import org.junit.Test; +import org.openecomp.mso.adapters.vnf.MsoVnfAdapterAsyncImpl; +import org.openecomp.mso.entity.MsoRequest; +import org.openecomp.mso.openstack.beans.VnfRollback; + +public class MsoVnfAdapterAsyncImplTest { + + @Test + public void healthCheckVNFTest() { + MsoVnfAdapterAsyncImpl instance = new MsoVnfAdapterAsyncImpl(); + instance.healthCheckA(); + } + + @Test + public void createVNFTest() { + MsoVnfAdapterAsyncImpl instance = new MsoVnfAdapterAsyncImpl(); + MsoRequest msoRequest = new MsoRequest(); + msoRequest.setRequestId("12345"); + msoRequest.setServiceInstanceId("12345"); + try { + + instance.createVnfA("mdt1", "88a6ca3ee0394ade9403f075db23167e", "vnf", "1", "vSAMP12", "VFMOD", + "volumeGroupHeatStackId|1", new HashMap<>(), Boolean.FALSE, Boolean.TRUE, "messageId", + null, "http://org.openecomp.mso/notify/adapterNotify/updateVnfNotificationRequest"); + } catch (Exception e) { + + } + } + + @Test + public void updateVnfTest() { + MsoVnfAdapterAsyncImpl instance = new MsoVnfAdapterAsyncImpl(); + MsoRequest msoRequest = new MsoRequest(); + msoRequest.setRequestId("12345"); + msoRequest.setServiceInstanceId("12345"); + + Map map = new HashMap<>(); + map.put("key1", "value1"); + try { + instance.updateVnfA("mdt1", "88a6ca3ee0394ade9403f075db23167e", "vnf", "1", "vSAMP12", "VFMOD", + "volumeGroupHeatStackId|1", map, "messageId", msoRequest, + "http://org.openecomp.mso/notify/adapterNotify/updateVnfNotificationRequest"); + } catch (Exception e) { + + } + } + + @Test + public void queryVnfTest() { + MsoVnfAdapterAsyncImpl instance = new MsoVnfAdapterAsyncImpl(); + MsoRequest msoRequest = new MsoRequest(); + msoRequest.setRequestId("12345"); + msoRequest.setServiceInstanceId("12345"); + try { + instance.queryVnfA("mdt1", "88a6ca3ee0394ade9403f075db23167e", "vSAMP12", "messageId", msoRequest, + "http://org.openecomp.mso/notify/adapterNotify/updateVnfNotificationRequest"); + } catch (Exception e) { + + } + } + + @Test + public void deleteVnfTest() { + MsoVnfAdapterAsyncImpl instance = new MsoVnfAdapterAsyncImpl(); + MsoRequest msoRequest = new MsoRequest(); + msoRequest.setRequestId("12345"); + msoRequest.setServiceInstanceId("12345"); + try { + instance.deleteVnfA("mdt1", "88a6ca3ee0394ade9403f075db23167e", "vSAMP12", "messageId", msoRequest, + "http://org.openecomp.mso/notify/adapterNotify/updateVnfNotificationRequest"); + } catch (Exception e) { + + } + } + + @Test + public void rollbackVnfTest() { + MsoVnfAdapterAsyncImpl instance = new MsoVnfAdapterAsyncImpl(); + VnfRollback vnfRollBack = new VnfRollback(); + vnfRollBack.setCloudSiteId("mdt1"); + vnfRollBack.setTenantId("88a6ca3ee0394ade9403f075db23167e"); + vnfRollBack.setVnfId("ff5256d1-5a33-55df-13ab-12abad84e7ff"); + try { + instance.rollbackVnfA(vnfRollBack, "messageId", + "http://org.openecomp.mso/notify/adapterNotify/updateVnfNotificationRequest"); + } catch (Exception e) { + + } + } +} diff --git a/adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/adapters/vnf/MsoVnfAdapterImplTest.java b/adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/adapters/vnf/MsoVnfAdapterImplTest.java new file mode 100644 index 0000000000..eec2257c7f --- /dev/null +++ b/adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/adapters/vnf/MsoVnfAdapterImplTest.java @@ -0,0 +1,91 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.adapters.vnf.test; + +import java.util.HashMap; +import java.util.Map; +import javax.xml.ws.Holder; +import org.junit.Test; +import org.openecomp.mso.adapters.vnf.MsoVnfAdapterImpl; +import org.openecomp.mso.entity.MsoRequest; +import org.openecomp.mso.openstack.beans.VnfRollback; + +public class MsoVnfAdapterImplTest { + + @Test + public void healthCheckVNFTest() { + MsoVnfAdapterImpl instance = new MsoVnfAdapterImpl(); + instance.healthCheck(); + } + + @Test + public void createVnfTest() { + MsoVnfAdapterImpl instance = new MsoVnfAdapterImpl(); + MsoRequest msoRequest = new MsoRequest(); + msoRequest.setRequestId("12345"); + msoRequest.setServiceInstanceId("12345"); + + Map map = new HashMap<>(); + map.put("key1", "value1"); + try { + instance.createVfModule("mdt1", "88a6ca3ee0394ade9403f075db23167e", "vnf", "1", "vSAMP12", "VFMOD", + "volumeGroupHeatStackId|1", "baseVfHeatStackId", "88a6ca3ee0394ade9403f075db23167e", map, + Boolean.FALSE, Boolean.TRUE, msoRequest, new Holder<>(), new Holder<>(), + new Holder<>()); + } catch (Exception e) { + + } + } + + @Test + public void updateVnfTest() { + MsoVnfAdapterImpl instance = new MsoVnfAdapterImpl(); + MsoRequest msoRequest = new MsoRequest(); + msoRequest.setRequestId("12345"); + msoRequest.setServiceInstanceId("12345"); + + Map map = new HashMap<>(); + map.put("key1", "value1"); + try { + instance.updateVfModule("mdt1", "88a6ca3ee0394ade9403f075db23167e", "vnf", "1", "vSAMP12", "VFMOD", + "volumeGroupHeatStackId|1", "baseVfHeatStackId", "vfModuleStackId", + "88a6ca3ee0394ade9403f075db23167e", map, msoRequest, new Holder<>(), + new Holder<>()); + } catch (Exception e) { + + } + } + + @Test + public void deleteVnfTest() { + MsoVnfAdapterImpl instance = new MsoVnfAdapterImpl(); + MsoRequest msoRequest = new MsoRequest(); + msoRequest.setRequestId("12345"); + msoRequest.setServiceInstanceId("12345"); + try { + instance.deleteVfModule("mdt1", "88a6ca3ee0394ade9403f075db23167e", "vSAMP12", msoRequest, + new Holder<>()); + } catch (Exception e) { + + } + } + +} diff --git a/adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/adapters/vnf/QueryTest.java b/adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/adapters/vnf/QueryTest.java new file mode 100644 index 0000000000..282b3b15cd --- /dev/null +++ b/adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/adapters/vnf/QueryTest.java @@ -0,0 +1,136 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.adapters.vnf.test; + + +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import java.util.Map; +import javax.xml.ws.Holder; +import mockit.Mock; +import mockit.MockUp; +import org.junit.Ignore; +import org.junit.Test; +import org.openecomp.mso.adapters.vnf.MsoVnfAdapter; +import org.openecomp.mso.adapters.vnf.MsoVnfAdapterImpl; +import org.openecomp.mso.adapters.vnf.exceptions.VnfException; +import org.openecomp.mso.openstack.beans.HeatStatus; +import org.openecomp.mso.openstack.beans.StackInfo; +import org.openecomp.mso.openstack.beans.VnfStatus; +import org.openecomp.mso.openstack.exceptions.MsoException; +import org.openecomp.mso.openstack.utils.MsoHeatUtils; + +import org.openecomp.mso.cloud.CloudConfigFactory; +import org.openecomp.mso.properties.MsoJavaProperties; +import org.openecomp.mso.properties.MsoPropertiesFactory; + +public class QueryTest { + + @Test + public void testQueryCreatedVnf() throws VnfException { + { + new MockUp() { + @Mock + public StackInfo queryStack(String cloudSiteId, String tenantId, String stackName) throws MsoException { + StackInfo info = new StackInfo("stackName", HeatStatus.CREATED); + return info; + } + }; + + MsoVnfAdapter vnfAdapter = new MsoVnfAdapterImpl(); + String cloudId = "MT"; + String tenantId = "MSO_Test"; + String vnfName = "VNF_TEST1"; + Holder vnfExists = new Holder<>(); + Holder vnfId = new Holder<>(); + Holder status = new Holder<>(); + Holder> outputs = new Holder<>(); + + vnfAdapter.queryVnf(cloudId, tenantId, vnfName, null, + vnfExists, vnfId, status, outputs); + + assertTrue(vnfExists.value); + } + } + + @Test + public void testQueryNotFoundVnf() throws VnfException { + { + new MockUp() { + @Mock + public StackInfo queryStack(String cloudSiteId, String tenantId, String stackName) throws MsoException { + StackInfo info = new StackInfo("stackName", HeatStatus.NOTFOUND); + return info; + } + }; + + MsoVnfAdapter vnfAdapter = new MsoVnfAdapterImpl(); + String cloudId = "MT"; + String tenantId = "MSO_Test"; + String vnfName = "VNF_TEST1"; + Holder vnfExists = new Holder<>(); + Holder vnfId = new Holder<>(); + Holder status = new Holder<>(); + Holder> outputs = new Holder<>(); + + vnfAdapter.queryVnf(cloudId, tenantId, vnfName, null, + vnfExists, vnfId, status, outputs); + + assertFalse(vnfExists.value); + } + } + + @Test(expected = VnfException.class) + // @Ignore // 1802 merge + public void testQueryVnfWithException() throws VnfException { + { + String propFile = MsoJavaProperties.class.getClassLoader().getResource("mso.properties").getPath(); + String cloudConfigJsonFilePath = MsoJavaProperties.class.getClassLoader().getResource("cloud_config.json").getPath(); + + MsoPropertiesFactory msoPropFactory = new MsoPropertiesFactory(); + CloudConfigFactory cloudConfigFact = new CloudConfigFactory(); + try { + msoPropFactory.initializeMsoProperties("MSO_PROP_VNF_ADAPTER", propFile); + cloudConfigFact.initializeCloudConfig(cloudConfigJsonFilePath, 1); + } catch (org.openecomp.mso.properties.MsoPropertiesException e) { + // System.err.println("!?!?!?!! mso config exception: " + e); + // e.printStackTrace(); + } catch (org.openecomp.mso.openstack.exceptions.MsoCloudIdentityNotFound e) { + // System.err.println("!?!?!?!! cloud config exception: " + e); + // e.printStackTrace(); + } + + MsoVnfAdapter vnfAdapter = new MsoVnfAdapterImpl(msoPropFactory, cloudConfigFact); + + String cloudId = "MT"; + String tenantId = "MSO_Test"; + String vnfName = "VNF_TEST1"; + Holder vnfExists = new Holder<>(); + Holder vnfId = new Holder<>(); + Holder status = new Holder<>(); + Holder> outputs = new Holder<>(); + + vnfAdapter.queryVnf(cloudId, tenantId, vnfName, null, + vnfExists, vnfId, status, outputs); + } + } +} diff --git a/adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/adapters/vnf/VnfCreateTest.java b/adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/adapters/vnf/VnfCreateTest.java new file mode 100644 index 0000000000..000ed8aef3 --- /dev/null +++ b/adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/adapters/vnf/VnfCreateTest.java @@ -0,0 +1,87 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.adapters.vnf.test; + + +import java.util.HashMap; +import java.util.Map; + +import javax.xml.ws.Holder; + +import org.openecomp.mso.adapters.vnf.MsoVnfAdapter; +import org.openecomp.mso.adapters.vnf.MsoVnfAdapterImpl; +import org.openecomp.mso.openstack.beans.VnfRollback; +import org.openecomp.mso.adapters.vnf.exceptions.VnfException; + +public class VnfCreateTest { + public final static void main (String args[]) + { + MsoVnfAdapter vnfAdapter = new MsoVnfAdapterImpl(); + log ("Got a VnfAdapter"); + + // Web Service Inputs + String cloudId = "MT"; + String tenantName = "John_Test"; + String vnfType = "ApacheDemo"; + String vnfName = "AdapterTest"; + Map inputs = new HashMap<>(); + inputs.put("vnf_id", "abc"); + inputs.put("extra", "whocares"); + inputs.put("private_subnet_gateway", "10.4.1.1"); + inputs.put("private_subnet_cidr", "10.4.1.0/29"); + + // Web Service Outputs + Holder vnfId = new Holder<>(); + Holder> outputs = new Holder<>(); + Holder vnfRollback = new Holder<>(); + + try { + vnfAdapter.createVnf(cloudId, tenantName, vnfType,null, vnfName, null, null, inputs, false, true, null, + vnfId, outputs, vnfRollback); + } catch (VnfException e) { + log ("Got a Create Exception: " + e); + System.exit(1); + } + + log ("Created VNF, ID = " + vnfId.value); + for (String key : outputs.value.keySet()) { + log (" " + key + " = " + outputs.value.get(key)); + } + if (vnfRollback.value != null) + log (vnfRollback.value.toString()); + + try { + Thread.sleep(5000); + } catch (InterruptedException e) {} + + log ("Rolling Back VNF"); + try { + vnfAdapter.rollbackVnf(vnfRollback.value); + } catch (VnfException e) { + log ("Got a Rollback Exception: " + e); + } + log ("VNF Rolled Back"); + } + + private static void log (String msg) { + System.out.println (msg); + } +} diff --git a/adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/adapters/vnf/VnfDeleteTest.java b/adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/adapters/vnf/VnfDeleteTest.java new file mode 100644 index 0000000000..e9b33eb24a --- /dev/null +++ b/adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/adapters/vnf/VnfDeleteTest.java @@ -0,0 +1,52 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.adapters.vnf.test; + + + +import org.openecomp.mso.adapters.vnf.MsoVnfAdapter; +import org.openecomp.mso.adapters.vnf.MsoVnfAdapterImpl; +import org.openecomp.mso.adapters.vnf.exceptions.VnfException; + +public class VnfDeleteTest { + public final static void main (String args[]) + { + MsoVnfAdapter vnfAdapter = new MsoVnfAdapterImpl(); + log ("Got a VnfAdapter"); + + // Web Service Inputs + String cloudId = "MT"; + String tenantName = "MSO_Test"; + String vnfName = "AdapterTest"; + + try { + vnfAdapter.deleteVnf(cloudId, tenantName, vnfName, null); + } catch (VnfException e) { + log ("Got an Exception: " + e); + } + + log ("Deleted VNF"); + } + + private static void log (String msg) { + System.out.println (msg); + } +} diff --git a/adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/adapters/vnf/VnfQueryTest.java b/adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/adapters/vnf/VnfQueryTest.java new file mode 100644 index 0000000000..bbffddfd15 --- /dev/null +++ b/adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/adapters/vnf/VnfQueryTest.java @@ -0,0 +1,64 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.adapters.vnf.test; + + +import java.util.Map; + +import javax.xml.ws.Holder; + +import org.openecomp.mso.adapters.vnf.MsoVnfAdapter; +import org.openecomp.mso.adapters.vnf.MsoVnfAdapterImpl; +import org.openecomp.mso.openstack.beans.VnfStatus; +import org.openecomp.mso.adapters.vnf.exceptions.VnfException; + +public class VnfQueryTest { + public final static void main (String args[]) + { + MsoVnfAdapter vnfAdapter = new MsoVnfAdapterImpl(); + log ("Got a VnfAdapter"); + + String cloudId = "MT"; + String tenantId = "MSO_Test"; + String vnfName = "VNF_TEST1"; + Holder vnfExists = new Holder<>(); + Holder vnfId = new Holder<>(); + Holder status = new Holder<>(); + Holder> outputs = new Holder<>(); + + try { + vnfAdapter.queryVnf(cloudId, tenantId, vnfName, null, + vnfExists, vnfId, status, outputs); + } catch (VnfException e) { + log ("Got an Exception: " + e); + } + + if (! vnfExists.value){ + log ("VNF Not Found"); + } else { + log ("Found VNF, ID = " + vnfId.value + ", status=" + status.value); + } + } + + private static void log (String msg) { + System.out.println (msg); + } +} diff --git a/adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/adapters/vnf/test/MsoVnfAdapterAsyncImplTest.java b/adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/adapters/vnf/test/MsoVnfAdapterAsyncImplTest.java deleted file mode 100644 index acde3153ab..0000000000 --- a/adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/adapters/vnf/test/MsoVnfAdapterAsyncImplTest.java +++ /dev/null @@ -1,114 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * 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. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.adapters.vnf.test; - -import java.util.HashMap; -import java.util.Map; -import org.junit.Test; -import org.openecomp.mso.adapters.vnf.MsoVnfAdapterAsyncImpl; -import org.openecomp.mso.entity.MsoRequest; -import org.openecomp.mso.openstack.beans.VnfRollback; - -public class MsoVnfAdapterAsyncImplTest { - - @Test - public void healthCheckVNFTest() { - MsoVnfAdapterAsyncImpl instance = new MsoVnfAdapterAsyncImpl(); - instance.healthCheckA(); - } - - @Test - public void createVNFTest() { - MsoVnfAdapterAsyncImpl instance = new MsoVnfAdapterAsyncImpl(); - MsoRequest msoRequest = new MsoRequest(); - msoRequest.setRequestId("12345"); - msoRequest.setServiceInstanceId("12345"); - try { - - instance.createVnfA("mdt1", "88a6ca3ee0394ade9403f075db23167e", "vnf", "1", "vSAMP12", "VFMOD", - "volumeGroupHeatStackId|1", new HashMap<>(), Boolean.FALSE, Boolean.TRUE, "messageId", - null, "http://org.openecomp.mso/notify/adapterNotify/updateVnfNotificationRequest"); - } catch (Exception e) { - - } - } - - @Test - public void updateVnfTest() { - MsoVnfAdapterAsyncImpl instance = new MsoVnfAdapterAsyncImpl(); - MsoRequest msoRequest = new MsoRequest(); - msoRequest.setRequestId("12345"); - msoRequest.setServiceInstanceId("12345"); - - Map map = new HashMap<>(); - map.put("key1", "value1"); - try { - instance.updateVnfA("mdt1", "88a6ca3ee0394ade9403f075db23167e", "vnf", "1", "vSAMP12", "VFMOD", - "volumeGroupHeatStackId|1", map, "messageId", msoRequest, - "http://org.openecomp.mso/notify/adapterNotify/updateVnfNotificationRequest"); - } catch (Exception e) { - - } - } - - @Test - public void queryVnfTest() { - MsoVnfAdapterAsyncImpl instance = new MsoVnfAdapterAsyncImpl(); - MsoRequest msoRequest = new MsoRequest(); - msoRequest.setRequestId("12345"); - msoRequest.setServiceInstanceId("12345"); - try { - instance.queryVnfA("mdt1", "88a6ca3ee0394ade9403f075db23167e", "vSAMP12", "messageId", msoRequest, - "http://org.openecomp.mso/notify/adapterNotify/updateVnfNotificationRequest"); - } catch (Exception e) { - - } - } - - @Test - public void deleteVnfTest() { - MsoVnfAdapterAsyncImpl instance = new MsoVnfAdapterAsyncImpl(); - MsoRequest msoRequest = new MsoRequest(); - msoRequest.setRequestId("12345"); - msoRequest.setServiceInstanceId("12345"); - try { - instance.deleteVnfA("mdt1", "88a6ca3ee0394ade9403f075db23167e", "vSAMP12", "messageId", msoRequest, - "http://org.openecomp.mso/notify/adapterNotify/updateVnfNotificationRequest"); - } catch (Exception e) { - - } - } - - @Test - public void rollbackVnfTest() { - MsoVnfAdapterAsyncImpl instance = new MsoVnfAdapterAsyncImpl(); - VnfRollback vnfRollBack = new VnfRollback(); - vnfRollBack.setCloudSiteId("mdt1"); - vnfRollBack.setTenantId("88a6ca3ee0394ade9403f075db23167e"); - vnfRollBack.setVnfId("ff5256d1-5a33-55df-13ab-12abad84e7ff"); - try { - instance.rollbackVnfA(vnfRollBack, "messageId", - "http://org.openecomp.mso/notify/adapterNotify/updateVnfNotificationRequest"); - } catch (Exception e) { - - } - } -} diff --git a/adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/adapters/vnf/test/MsoVnfAdapterImplTest.java b/adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/adapters/vnf/test/MsoVnfAdapterImplTest.java deleted file mode 100644 index eec2257c7f..0000000000 --- a/adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/adapters/vnf/test/MsoVnfAdapterImplTest.java +++ /dev/null @@ -1,91 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * 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. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.adapters.vnf.test; - -import java.util.HashMap; -import java.util.Map; -import javax.xml.ws.Holder; -import org.junit.Test; -import org.openecomp.mso.adapters.vnf.MsoVnfAdapterImpl; -import org.openecomp.mso.entity.MsoRequest; -import org.openecomp.mso.openstack.beans.VnfRollback; - -public class MsoVnfAdapterImplTest { - - @Test - public void healthCheckVNFTest() { - MsoVnfAdapterImpl instance = new MsoVnfAdapterImpl(); - instance.healthCheck(); - } - - @Test - public void createVnfTest() { - MsoVnfAdapterImpl instance = new MsoVnfAdapterImpl(); - MsoRequest msoRequest = new MsoRequest(); - msoRequest.setRequestId("12345"); - msoRequest.setServiceInstanceId("12345"); - - Map map = new HashMap<>(); - map.put("key1", "value1"); - try { - instance.createVfModule("mdt1", "88a6ca3ee0394ade9403f075db23167e", "vnf", "1", "vSAMP12", "VFMOD", - "volumeGroupHeatStackId|1", "baseVfHeatStackId", "88a6ca3ee0394ade9403f075db23167e", map, - Boolean.FALSE, Boolean.TRUE, msoRequest, new Holder<>(), new Holder<>(), - new Holder<>()); - } catch (Exception e) { - - } - } - - @Test - public void updateVnfTest() { - MsoVnfAdapterImpl instance = new MsoVnfAdapterImpl(); - MsoRequest msoRequest = new MsoRequest(); - msoRequest.setRequestId("12345"); - msoRequest.setServiceInstanceId("12345"); - - Map map = new HashMap<>(); - map.put("key1", "value1"); - try { - instance.updateVfModule("mdt1", "88a6ca3ee0394ade9403f075db23167e", "vnf", "1", "vSAMP12", "VFMOD", - "volumeGroupHeatStackId|1", "baseVfHeatStackId", "vfModuleStackId", - "88a6ca3ee0394ade9403f075db23167e", map, msoRequest, new Holder<>(), - new Holder<>()); - } catch (Exception e) { - - } - } - - @Test - public void deleteVnfTest() { - MsoVnfAdapterImpl instance = new MsoVnfAdapterImpl(); - MsoRequest msoRequest = new MsoRequest(); - msoRequest.setRequestId("12345"); - msoRequest.setServiceInstanceId("12345"); - try { - instance.deleteVfModule("mdt1", "88a6ca3ee0394ade9403f075db23167e", "vSAMP12", msoRequest, - new Holder<>()); - } catch (Exception e) { - - } - } - -} diff --git a/adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/adapters/vnf/test/QueryTest.java b/adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/adapters/vnf/test/QueryTest.java deleted file mode 100644 index 282b3b15cd..0000000000 --- a/adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/adapters/vnf/test/QueryTest.java +++ /dev/null @@ -1,136 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * 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. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.adapters.vnf.test; - - -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; - -import java.util.Map; -import javax.xml.ws.Holder; -import mockit.Mock; -import mockit.MockUp; -import org.junit.Ignore; -import org.junit.Test; -import org.openecomp.mso.adapters.vnf.MsoVnfAdapter; -import org.openecomp.mso.adapters.vnf.MsoVnfAdapterImpl; -import org.openecomp.mso.adapters.vnf.exceptions.VnfException; -import org.openecomp.mso.openstack.beans.HeatStatus; -import org.openecomp.mso.openstack.beans.StackInfo; -import org.openecomp.mso.openstack.beans.VnfStatus; -import org.openecomp.mso.openstack.exceptions.MsoException; -import org.openecomp.mso.openstack.utils.MsoHeatUtils; - -import org.openecomp.mso.cloud.CloudConfigFactory; -import org.openecomp.mso.properties.MsoJavaProperties; -import org.openecomp.mso.properties.MsoPropertiesFactory; - -public class QueryTest { - - @Test - public void testQueryCreatedVnf() throws VnfException { - { - new MockUp() { - @Mock - public StackInfo queryStack(String cloudSiteId, String tenantId, String stackName) throws MsoException { - StackInfo info = new StackInfo("stackName", HeatStatus.CREATED); - return info; - } - }; - - MsoVnfAdapter vnfAdapter = new MsoVnfAdapterImpl(); - String cloudId = "MT"; - String tenantId = "MSO_Test"; - String vnfName = "VNF_TEST1"; - Holder vnfExists = new Holder<>(); - Holder vnfId = new Holder<>(); - Holder status = new Holder<>(); - Holder> outputs = new Holder<>(); - - vnfAdapter.queryVnf(cloudId, tenantId, vnfName, null, - vnfExists, vnfId, status, outputs); - - assertTrue(vnfExists.value); - } - } - - @Test - public void testQueryNotFoundVnf() throws VnfException { - { - new MockUp() { - @Mock - public StackInfo queryStack(String cloudSiteId, String tenantId, String stackName) throws MsoException { - StackInfo info = new StackInfo("stackName", HeatStatus.NOTFOUND); - return info; - } - }; - - MsoVnfAdapter vnfAdapter = new MsoVnfAdapterImpl(); - String cloudId = "MT"; - String tenantId = "MSO_Test"; - String vnfName = "VNF_TEST1"; - Holder vnfExists = new Holder<>(); - Holder vnfId = new Holder<>(); - Holder status = new Holder<>(); - Holder> outputs = new Holder<>(); - - vnfAdapter.queryVnf(cloudId, tenantId, vnfName, null, - vnfExists, vnfId, status, outputs); - - assertFalse(vnfExists.value); - } - } - - @Test(expected = VnfException.class) - // @Ignore // 1802 merge - public void testQueryVnfWithException() throws VnfException { - { - String propFile = MsoJavaProperties.class.getClassLoader().getResource("mso.properties").getPath(); - String cloudConfigJsonFilePath = MsoJavaProperties.class.getClassLoader().getResource("cloud_config.json").getPath(); - - MsoPropertiesFactory msoPropFactory = new MsoPropertiesFactory(); - CloudConfigFactory cloudConfigFact = new CloudConfigFactory(); - try { - msoPropFactory.initializeMsoProperties("MSO_PROP_VNF_ADAPTER", propFile); - cloudConfigFact.initializeCloudConfig(cloudConfigJsonFilePath, 1); - } catch (org.openecomp.mso.properties.MsoPropertiesException e) { - // System.err.println("!?!?!?!! mso config exception: " + e); - // e.printStackTrace(); - } catch (org.openecomp.mso.openstack.exceptions.MsoCloudIdentityNotFound e) { - // System.err.println("!?!?!?!! cloud config exception: " + e); - // e.printStackTrace(); - } - - MsoVnfAdapter vnfAdapter = new MsoVnfAdapterImpl(msoPropFactory, cloudConfigFact); - - String cloudId = "MT"; - String tenantId = "MSO_Test"; - String vnfName = "VNF_TEST1"; - Holder vnfExists = new Holder<>(); - Holder vnfId = new Holder<>(); - Holder status = new Holder<>(); - Holder> outputs = new Holder<>(); - - vnfAdapter.queryVnf(cloudId, tenantId, vnfName, null, - vnfExists, vnfId, status, outputs); - } - } -} diff --git a/adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/adapters/vnf/test/VnfCreateTest.java b/adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/adapters/vnf/test/VnfCreateTest.java deleted file mode 100644 index 000ed8aef3..0000000000 --- a/adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/adapters/vnf/test/VnfCreateTest.java +++ /dev/null @@ -1,87 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * 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. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.adapters.vnf.test; - - -import java.util.HashMap; -import java.util.Map; - -import javax.xml.ws.Holder; - -import org.openecomp.mso.adapters.vnf.MsoVnfAdapter; -import org.openecomp.mso.adapters.vnf.MsoVnfAdapterImpl; -import org.openecomp.mso.openstack.beans.VnfRollback; -import org.openecomp.mso.adapters.vnf.exceptions.VnfException; - -public class VnfCreateTest { - public final static void main (String args[]) - { - MsoVnfAdapter vnfAdapter = new MsoVnfAdapterImpl(); - log ("Got a VnfAdapter"); - - // Web Service Inputs - String cloudId = "MT"; - String tenantName = "John_Test"; - String vnfType = "ApacheDemo"; - String vnfName = "AdapterTest"; - Map inputs = new HashMap<>(); - inputs.put("vnf_id", "abc"); - inputs.put("extra", "whocares"); - inputs.put("private_subnet_gateway", "10.4.1.1"); - inputs.put("private_subnet_cidr", "10.4.1.0/29"); - - // Web Service Outputs - Holder vnfId = new Holder<>(); - Holder> outputs = new Holder<>(); - Holder vnfRollback = new Holder<>(); - - try { - vnfAdapter.createVnf(cloudId, tenantName, vnfType,null, vnfName, null, null, inputs, false, true, null, - vnfId, outputs, vnfRollback); - } catch (VnfException e) { - log ("Got a Create Exception: " + e); - System.exit(1); - } - - log ("Created VNF, ID = " + vnfId.value); - for (String key : outputs.value.keySet()) { - log (" " + key + " = " + outputs.value.get(key)); - } - if (vnfRollback.value != null) - log (vnfRollback.value.toString()); - - try { - Thread.sleep(5000); - } catch (InterruptedException e) {} - - log ("Rolling Back VNF"); - try { - vnfAdapter.rollbackVnf(vnfRollback.value); - } catch (VnfException e) { - log ("Got a Rollback Exception: " + e); - } - log ("VNF Rolled Back"); - } - - private static void log (String msg) { - System.out.println (msg); - } -} diff --git a/adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/adapters/vnf/test/VnfDeleteTest.java b/adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/adapters/vnf/test/VnfDeleteTest.java deleted file mode 100644 index e9b33eb24a..0000000000 --- a/adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/adapters/vnf/test/VnfDeleteTest.java +++ /dev/null @@ -1,52 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * 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. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.adapters.vnf.test; - - - -import org.openecomp.mso.adapters.vnf.MsoVnfAdapter; -import org.openecomp.mso.adapters.vnf.MsoVnfAdapterImpl; -import org.openecomp.mso.adapters.vnf.exceptions.VnfException; - -public class VnfDeleteTest { - public final static void main (String args[]) - { - MsoVnfAdapter vnfAdapter = new MsoVnfAdapterImpl(); - log ("Got a VnfAdapter"); - - // Web Service Inputs - String cloudId = "MT"; - String tenantName = "MSO_Test"; - String vnfName = "AdapterTest"; - - try { - vnfAdapter.deleteVnf(cloudId, tenantName, vnfName, null); - } catch (VnfException e) { - log ("Got an Exception: " + e); - } - - log ("Deleted VNF"); - } - - private static void log (String msg) { - System.out.println (msg); - } -} diff --git a/adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/adapters/vnf/test/VnfQueryTest.java b/adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/adapters/vnf/test/VnfQueryTest.java deleted file mode 100644 index bbffddfd15..0000000000 --- a/adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/adapters/vnf/test/VnfQueryTest.java +++ /dev/null @@ -1,64 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * 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. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.adapters.vnf.test; - - -import java.util.Map; - -import javax.xml.ws.Holder; - -import org.openecomp.mso.adapters.vnf.MsoVnfAdapter; -import org.openecomp.mso.adapters.vnf.MsoVnfAdapterImpl; -import org.openecomp.mso.openstack.beans.VnfStatus; -import org.openecomp.mso.adapters.vnf.exceptions.VnfException; - -public class VnfQueryTest { - public final static void main (String args[]) - { - MsoVnfAdapter vnfAdapter = new MsoVnfAdapterImpl(); - log ("Got a VnfAdapter"); - - String cloudId = "MT"; - String tenantId = "MSO_Test"; - String vnfName = "VNF_TEST1"; - Holder vnfExists = new Holder<>(); - Holder vnfId = new Holder<>(); - Holder status = new Holder<>(); - Holder> outputs = new Holder<>(); - - try { - vnfAdapter.queryVnf(cloudId, tenantId, vnfName, null, - vnfExists, vnfId, status, outputs); - } catch (VnfException e) { - log ("Got an Exception: " + e); - } - - if (! vnfExists.value){ - log ("VNF Not Found"); - } else { - log ("Found VNF, ID = " + vnfId.value + ", status=" + status.value); - } - } - - private static void log (String msg) { - System.out.println (msg); - } -} -- cgit 1.2.3-korg