summaryrefslogtreecommitdiffstats
path: root/adapters/mso-openstack-adapters/src/test/java/org
diff options
context:
space:
mode:
authorBoslet, Cory <cory.boslet@att.com>2020-04-15 10:54:48 -0400
committerBenjamin, Max (mb388a) <mb388a@att.com>2020-04-15 10:54:48 -0400
commit8c93916cc7129e9b0a4c3b814aabbfe7b97499c9 (patch)
tree42d46386af63bf5349bbd1dd39126f461aae41b6 /adapters/mso-openstack-adapters/src/test/java/org
parent312ee1ae732b0c904a25273b88322634d31ae0e6 (diff)
remove vnfadapterrest flow and interface
Removed unused soap vnf adapter apis and implements Removed unused apis and implements from vnf adapter Updates and removed dead code that is never used Add back override method to the healthcheck in vnf imp Removed the vnfadapter rest v2 interface and test. Removed references to v2 rest interfaces from CXF config. Reverted change to the cxf configuration file. Removed more unused code and updated unit test to account for removed apis and v2 being removed Updated the att openstack adapter cfx to remove v2 classes Initial commit of cleaning up the vnf adapter and removing the rest subflow. Issue-ID: SO-2812 Signed-off-by: Benjamin, Max (mb388a) <mb388a@att.com> Change-Id: Ia093a5ac2dffd21d27a1ba74a813198b806d0786
Diffstat (limited to 'adapters/mso-openstack-adapters/src/test/java/org')
-rw-r--r--adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfAdapterAsyncImplTest.java58
-rw-r--r--adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfCloudifyAdapterImplTest.java308
-rw-r--r--adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfMulticloudAdapterImplTest.java231
-rw-r--r--adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfPluginAdapterImplTest.java166
-rw-r--r--adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/QueryTest.java110
-rw-r--r--adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/VnfAdapterRestTest.java557
-rw-r--r--adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/VolumeAdapterRestTest.java194
-rw-r--r--adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/VolumeAdapterRestV2Test.java190
-rw-r--r--adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/VolumeGroupAdapterCommon.java129
9 files changed, 2 insertions, 1941 deletions
diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfAdapterAsyncImplTest.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfAdapterAsyncImplTest.java
index 46d9f89303..1a308b7c4c 100644
--- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfAdapterAsyncImplTest.java
+++ b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfAdapterAsyncImplTest.java
@@ -7,9 +7,9 @@
* 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.
@@ -30,13 +30,11 @@ import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo;
import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackGetStackVfModule_200;
import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackResponseAccess;
import java.util.HashMap;
-import java.util.Map;
import org.apache.http.HttpStatus;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.onap.so.entity.MsoRequest;
-import org.onap.so.openstack.beans.VnfRollback;
import org.springframework.beans.factory.annotation.Autowired;
public class MsoVnfAdapterAsyncImplTest extends BaseRestTestUtils {
@@ -86,48 +84,6 @@ public class MsoVnfAdapterAsyncImplTest extends BaseRestTestUtils {
}
@Test
- public void updateVnfTest() throws Exception {
- MsoRequest msoRequest = new MsoRequest();
- msoRequest.setRequestId("12345");
- msoRequest.setServiceInstanceId("12345");
-
- Map<String, Object> map = new HashMap<>();
- map.put("key1", "value1");
- wireMockServer.stubFor(post(urlPathEqualTo("/notify/adapterNotify/updateVnfNotificationRequest"))
- .withRequestBody(containing("messageId")).willReturn(aResponse().withStatus(HttpStatus.SC_OK)));
- String notificationUrl =
- "http://localhost:" + wireMockPort + "/notify/adapterNotify/updateVnfNotificationRequest";
- instance.updateVnfA("mdt1", "CloudOwner", "88a6ca3ee0394ade9403f075db23167e", "vnf", "1", "vSAMP12", "VFMOD",
- "volumeGroupHeatStackId|1", map, "messageId", msoRequest, notificationUrl);
- }
-
- @Test
- public void updateVnfTest_Exception() throws Exception {
- MsoRequest msoRequest = new MsoRequest();
- msoRequest.setRequestId("12345");
- msoRequest.setServiceInstanceId("12345");
-
- Map<String, Object> map = new HashMap<>();
- map.put("key1", "value1");
- wireMockServer.stubFor(post(urlPathEqualTo("/notify/adapterNotify/updateVnfNotificationRequest"))
- .withRequestBody(containing("messageId")).willReturn(aResponse().withStatus(HttpStatus.SC_OK)));
- String notificationUrl =
- "http://localhost:" + wireMockPort + "/notify/adapterNotify/updateVnfNotificationRequest";
- instance.updateVnfA("mdt1", "CloudOwner", "88a6ca3ee0394ade9403f075db23167e", "vnf", "1", "vSAMP12", "VFMOD",
- "volumeGroupHeatStackId|1", map, "messageId", msoRequest, notificationUrl);
- wireMockServer.verify(1, postRequestedFor(urlEqualTo("/notify/adapterNotify/updateVnfNotificationRequest")));
- }
-
- @Test
- public void queryVnfTest() {
- MsoRequest msoRequest = new MsoRequest();
- msoRequest.setRequestId("12345");
- msoRequest.setServiceInstanceId("12345");
- instance.queryVnfA("mdt1", "CloudOwner", "88a6ca3ee0394ade9403f075db23167e", "vSAMP12", "messageId", msoRequest,
- "http://org.onap.so/notify/adapterNotify/updateVnfNotificationRequest");
- }
-
- @Test
public void deleteVnfTest() {
MsoRequest msoRequest = new MsoRequest();
msoRequest.setRequestId("12345");
@@ -136,14 +92,4 @@ public class MsoVnfAdapterAsyncImplTest extends BaseRestTestUtils {
msoRequest, "http://org.onap.so/notify/adapterNotify/updateVnfNotificationRequest");
}
- @Test
- public void rollbackVnfTest() {
- VnfRollback vnfRollBack = new VnfRollback();
- vnfRollBack.setCloudSiteId("mdt1");
- vnfRollBack.setCloudOwner("CloudOwner");
- vnfRollBack.setTenantId("88a6ca3ee0394ade9403f075db23167e");
- vnfRollBack.setVnfId("ff5256d1-5a33-55df-13ab-12abad84e7ff");
- instance.rollbackVnfA(vnfRollBack, "messageId",
- "http://org.onap.so/notify/adapterNotify/updateVnfNotificationRequest");
- }
}
diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfCloudifyAdapterImplTest.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfCloudifyAdapterImplTest.java
deleted file mode 100644
index 45504fcab5..0000000000
--- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfCloudifyAdapterImplTest.java
+++ /dev/null
@@ -1,308 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
- * Copyright (C) 2018 Huawei 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.onap.so.adapters.vnf;
-
-import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
-import static com.github.tomakehurst.wiremock.client.WireMock.get;
-import static com.github.tomakehurst.wiremock.client.WireMock.urlMatching;
-import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo;
-import static org.junit.Assert.assertTrue;
-import java.util.HashMap;
-import java.util.Map;
-import javax.xml.ws.Holder;
-import org.apache.http.HttpStatus;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
-import org.onap.so.adapters.vnf.exceptions.VnfException;
-import org.onap.so.cloud.CloudConfig;
-import org.onap.so.db.catalog.beans.CloudifyManager;
-import org.onap.so.entity.MsoRequest;
-import org.onap.so.openstack.beans.VnfRollback;
-import org.springframework.beans.factory.annotation.Autowired;
-
-public class MsoVnfCloudifyAdapterImplTest extends BaseRestTestUtils {
-
- @Rule
- public ExpectedException expectedException = ExpectedException.none();
-
- @Autowired
- private MsoVnfCloudifyAdapterImpl instance;
-
- @Autowired
- private CloudConfig cloudConfig;
-
- @Before
- public void before() throws Exception {
- super.setUp();
- CloudifyManager cloudifyManager = new CloudifyManager();
- cloudifyManager.setId("mtn13");
- cloudifyManager.setCloudifyUrl("http://localhost:" + wireMockPort + "/v2.0");
- cloudifyManager.setUsername("m93945");
- cloudifyManager.setPassword("93937EA01B94A10A49279D4572B48369");
- }
-
- /*
- * @Test public void queryVnfExceptionTest() throws Exception { MsoRequest msoRequest = new MsoRequest();
- * msoRequest.setRequestId("12345"); msoRequest.setServiceInstanceId("12345"); Holder<Map<String, String>> outputs =
- * new Holder<>(); instance.queryVnf("siteid", "CloudOwner", "1234", "vfname", msoRequest, new Holder<>(), new
- * Holder<>(), new Holder<>(), outputs);
- *
- * assertTrue(outputs.value.isEmpty()); }
- */
-
- /*
- * @Test public void queryVnfTest() throws Exception {
- *
- *
- * MsoRequest msoRequest = new MsoRequest(); msoRequest.setRequestId("12345");
- * msoRequest.setServiceInstanceId("12345");
- * wireMockServer.stubFor(get(urlPathEqualTo("/v2.0/api/v3/deployments/vfname"))
- * .willReturn(aResponse().withBody("{ \"id\": \"123\" }").withStatus(HttpStatus.SC_OK)));
- *
- * wireMockServer.stubFor(get(urlPathEqualTo("/v2.0/api/v3/deployments/vfname/outputs"))
- * .willReturn(aResponse().withBody("{ \"deployment_id\": \"123\",\"outputs\":{\"abc\":\"abc\"} }")
- * .withStatus(HttpStatus.SC_OK)));
- *
- * wireMockServer.stubFor(get(urlMatching("/v2.0/api/v3/executions?.*")).willReturn(aResponse()
- * .withBody("{ \"items\": {\"id\": \"123\",\"workflow_id\":\"install\",\"status\":\"terminated\" } } ")
- * .withStatus(HttpStatus.SC_OK)));
- *
- * instance.queryVnf("mtn13", "CloudOwner", "1234", "vfname", msoRequest, new Holder<>(), new Holder<>(), new
- * Holder<>(), new Holder<>());
- *
- * }
- */
-
- @Test
- public void deleteVfModuleTest_ExceptionWhileQueryDeployment() throws Exception {
- expectedException.expect(VnfException.class);
- MsoRequest msoRequest = new MsoRequest();
- msoRequest.setRequestId("12345");
- msoRequest.setServiceInstanceId("12345");
-
- instance.deleteVfModule("mtn13", "CloudOwner", "1234", "vfname", "5aae1e49-805c-4f9f-bd78-055bf7451157",
- "11420693-3f69-4c61-b3ee-9787c744e760", "customizationId", msoRequest, new Holder<>());
- }
-
- @Test
- public void deleteVfModuleTest_ExceptionWhileDeleteDeployment() throws Exception {
- expectedException.expect(VnfException.class);
- MsoRequest msoRequest = new MsoRequest();
- msoRequest.setRequestId("12345");
- msoRequest.setServiceInstanceId("12345");
- wireMockServer.stubFor(get(urlPathEqualTo("/v2.0/api/v3/deployments/vfname"))
- .willReturn(aResponse().withBody("{ \"id\": \"123\" }").withStatus(HttpStatus.SC_OK)));
-
- wireMockServer.stubFor(get(urlPathEqualTo("/v2.0/api/v3/deployments/vfname/outputs"))
- .willReturn(aResponse().withBody("{ \"deployment_id\": \"123\",\"outputs\":{\"abc\":\"abc\"} }")
- .withStatus(HttpStatus.SC_OK)));
-
- wireMockServer.stubFor(get(urlMatching("/v2.0/api/v3/executions?.*")).willReturn(aResponse()
- .withBody("{ \"items\": {\"id\": \"123\",\"workflow_id\":\"install\",\"status\":\"terminated\" } } ")
- .withStatus(HttpStatus.SC_OK)));
-
- wireMockServer.stubFor(get(urlPathEqualTo("/v2.0/api/v3/tokens"))
- .willReturn(aResponse().withBodyFile("OpenstackResponse_Access.json").withStatus(HttpStatus.SC_OK)));
-
- instance.deleteVfModule("mtn13", "CloudOwner", "1234", "vfname", "5aae1e49-805c-4f9f-bd78-055bf7451157",
- "11420693-3f69-4c61-b3ee-9787c744e760", "customizationId", msoRequest, new Holder<>());
- }
-
- @Test
- public void deleteVnfVnfExceptionTest() throws Exception {
- expectedException.expect(VnfException.class);
- MsoRequest msoRequest = new MsoRequest();
- msoRequest.setRequestId("12345");
- msoRequest.setServiceInstanceId("12345");
-
- instance.deleteVnf("12344", "CloudOwner", "234", "vnfname", msoRequest);
-
- }
-
- @Test
- public void rollbackVnf() throws Exception {
- MsoRequest msoRequest = new MsoRequest();
- msoRequest.setRequestId("12345");
- msoRequest.setServiceInstanceId("12345");
-
- VnfRollback vnfRollback = new VnfRollback();
- vnfRollback.setModelCustomizationUuid("1234");
- vnfRollback.setVfModuleStackId("2134");
- vnfRollback.setVnfId("123");
- vnfRollback.setModelCustomizationUuid("1234");
-
- instance.rollbackVnf(vnfRollback);
- }
-
- @Test
- public void rollbackVnf_Created() throws Exception {
- expectedException.expect(VnfException.class);
- MsoRequest msoRequest = new MsoRequest();
- msoRequest.setRequestId("12345");
- msoRequest.setServiceInstanceId("12345");
-
- VnfRollback vnfRollback = new VnfRollback();
- vnfRollback.setModelCustomizationUuid("1234");
- vnfRollback.setVfModuleStackId("2134");
- vnfRollback.setVnfId("123");
- vnfRollback.setModelCustomizationUuid("1234");
- vnfRollback.setVnfCreated(true);
-
- instance.rollbackVnf(vnfRollback);
- }
-
- @Test
- public void createVfModuleVnfException() throws Exception {
- expectedException.expect(VnfException.class);
- MsoRequest msoRequest = new MsoRequest();
- msoRequest.setRequestId("12345");
- msoRequest.setServiceInstanceId("12345");
-
- instance.createVfModule("123", "CloudOwner", "123", "vf", "v1", "", "module-005", "", "create", "3245", "234",
- "123", new HashMap<>(), true, true, true, msoRequest, new Holder<>(), new Holder<>(), new Holder<>());
- }
-
- @Test
- public void createVfModule_ModelCustUuidIsNull() throws Exception {
- expectedException.expect(VnfException.class);
- MsoRequest msoRequest = new MsoRequest();
- msoRequest.setRequestId("12345");
- msoRequest.setServiceInstanceId("12345");
-
- instance.createVfModule("123", "CloudOwner", "123", "vf", "v1", "", "module-005", "", "create", "3245", "234",
- null, new HashMap<>(), true, true, true, msoRequest, new Holder<>(), new Holder<>(), new Holder<>());
- }
-
- @Test
- public void createVfModule_CloudSiteIdNotFound() throws Exception {
- expectedException.expect(VnfException.class);
- MsoRequest msoRequest = new MsoRequest();
- msoRequest.setRequestId("12345");
- msoRequest.setServiceInstanceId("12345");
-
- instance.createVfModule("123", "CloudOwner", "123", "vf", "v1", "", "module-005", "", "create", "3245", "234",
- "9b339a61-69ca-465f-86b8-1c72c582b8e8", new HashMap<>(), true, true, true, msoRequest, new Holder<>(),
- new Holder<>(), new Holder<>());
- }
-
- @Test
- public void createVfModule_MsoCloudifyManagerNotFound() throws Exception {
- expectedException.expect(VnfException.class);
- MsoRequest msoRequest = new MsoRequest();
- msoRequest.setRequestId("12345");
- msoRequest.setServiceInstanceId("12345");
-
- instance.createVfModule("mtn13", "CloudOwner", "123", "vf", "v1", "", "module-005", "", "create", "3245", "234",
- "9b339a61-69ca-465f-86b8-1c72c582b8e8", new HashMap<>(), true, true, true, msoRequest, new Holder<>(),
- new Holder<>(), new Holder<>());
- }
-
- @Test
- public void createVfModule() throws Exception {
- expectedException.expect(VnfException.class);
- MsoRequest msoRequest = new MsoRequest();
- msoRequest.setRequestId("12345");
- msoRequest.setServiceInstanceId("12345");
-
- wireMockServer.stubFor(get(urlPathEqualTo("/v2.0/api/v3/deployments/vfname"))
- .willReturn(aResponse().withBody("{ \"id\": \"123\" }").withStatus(HttpStatus.SC_OK)));
-
- wireMockServer.stubFor(get(urlPathEqualTo("/v2.0/api/v3/deployments/vfname/outputs"))
- .willReturn(aResponse().withBody("{ \"deployment_id\": \"123\",\"outputs\":{\"abc\":\"abc\"} }")
- .withStatus(HttpStatus.SC_OK)));
-
- wireMockServer.stubFor(get(urlMatching("/v2.0/api/v3/executions?.*")).willReturn(aResponse()
- .withBody("{ \"items\": {\"id\": \"123\",\"workflow_id\":\"install\",\"status\":\"terminated\" } } ")
- .withStatus(HttpStatus.SC_OK)));
-
- wireMockServer.stubFor(get(urlPathEqualTo("/v2.0/api/v3/tokens"))
- .willReturn(aResponse().withBodyFile("OpenstackResponse_Access.json").withStatus(HttpStatus.SC_OK)));
-
- instance.createVfModule("mtn13", "CloudOwner", "123", "vf", "v1", "", "vfname", "", "create", "3245", "234",
- "9b339a61-69ca-465f-86b8-1c72c582b8e8", new HashMap<>(), true, true, true, msoRequest, new Holder<>(),
- new Holder<>(), new Holder<>());
- }
-
- @Test
- public void updateVfModuleVnfException() throws Exception {
- expectedException.expect(VnfException.class);
- MsoRequest msoRequest = new MsoRequest();
- msoRequest.setRequestId("12345");
- msoRequest.setServiceInstanceId("12345");
-
- instance.updateVfModule("123", "CloudOwner", "1234", "fw", "v2", "vnf1", "create", "123", "12", "233", "234",
- new HashMap<>(), msoRequest, new Holder<>(), new Holder<>());
- }
-
- @Test
- public void healthCheckVNFTest() {
- instance.healthCheck();
- }
-
- @Test
- public void createVnfTest() {
- MsoRequest msoRequest = new MsoRequest();
- msoRequest.setRequestId("12345");
- msoRequest.setServiceInstanceId("12345");
-
- Map<String, Object> map = new HashMap<>();
- map.put("key1", "value1");
- try {
- instance.createVnf("mdt1", "CloudOwner", "88a6ca3ee0394ade9403f075db23167e", "vnf", "1", "vSAMP12", "VFMOD",
- "volumeGroupHeatStackId|1", map, Boolean.FALSE, Boolean.TRUE, Boolean.TRUE, msoRequest,
- new Holder<>(), new Holder<>(), new Holder<>());
- } catch (Exception e) {
- }
- }
-
- @Test
- public void updateVnfTest() {
- MsoRequest msoRequest = new MsoRequest();
- msoRequest.setRequestId("12345");
- msoRequest.setServiceInstanceId("12345");
-
- Map<String, Object> map = new HashMap<>();
-
- map.put("key1", "value1");
- try {
- instance.updateVnf("mdt1", "CloudOwner", "88a6ca3ee0394ade9403f075db23167e", "vnf", "1", "vSAMP12", "VFMOD",
- "volumeGroupHeatStackId|1", map, msoRequest, new Holder<>(), new Holder<>());
- } catch (Exception e) {
-
- }
- }
-
- @Test
- public void deleteVnfTest() {
- MsoRequest msoRequest = new MsoRequest();
- msoRequest.setRequestId("12345");
- msoRequest.setServiceInstanceId("12345");
- try {
- instance.deleteVnf("mdt1", "CloudOwner", "88a6ca3ee0394ade9403f075db23167e", "vSAMP12", msoRequest);
- } catch (Exception e) {
-
- }
- }
-
-}
diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfMulticloudAdapterImplTest.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfMulticloudAdapterImplTest.java
deleted file mode 100644
index 3bf784c50b..0000000000
--- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfMulticloudAdapterImplTest.java
+++ /dev/null
@@ -1,231 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2018 Intel Corp. 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.onap.so.adapters.vnf;
-
-import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
-import static com.github.tomakehurst.wiremock.client.WireMock.delete;
-import static com.github.tomakehurst.wiremock.client.WireMock.get;
-import static com.github.tomakehurst.wiremock.client.WireMock.post;
-import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo;
-import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-import java.util.HashMap;
-import java.util.Map;
-import javax.xml.ws.Holder;
-import org.apache.http.HttpStatus;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
-import org.onap.so.adapters.vdu.VduModelInfo;
-import org.onap.so.adapters.vnf.exceptions.VnfException;
-import org.onap.so.cloud.CloudConfig;
-import org.onap.so.entity.MsoRequest;
-import org.onap.so.openstack.beans.StackInfo;
-import org.onap.so.openstack.exceptions.MsoException;
-import org.springframework.beans.factory.annotation.Autowired;
-
-public class MsoVnfMulticloudAdapterImplTest extends BaseRestTestUtils {
- @Rule
- public ExpectedException expectedException = ExpectedException.none();
-
- @Autowired
- private MsoVnfPluginAdapterImpl instance;
-
- @Autowired
- private CloudConfig cloudConfig;
-
- private static final String UPDATE_STACK_RESPONSE =
- "{\"template_type\": \"heat\", \"workload_id\": " + "\"workload-id\"}";
- private static final String GET_CREATE_STACK_RESPONSE = "{\"template_type\": \"heat\", \"workload_id\": "
- + "\"workload-id\", \"workload_status\": \"CREATE_COMPLETE\"}";
- private static final String GET_UPDATE_STACK_RESPONSE = "{\"template_type\": \"heat\", \"workload_id\": "
- + "\"workload-id\", \"workload_status\": \"UPDATE_COMPLETE\"}";
-
- private static final String MULTICLOUD_CREATE_PATH = "/api/multicloud/v1/CloudOwner/MTN13/infra_workload";
- private static final String MULTICLOUD_UPDATE_PATH =
- "/api/multicloud/v1/CloudOwner/MTN13/infra_workload/workload-id";
- private static final String MULTICLOUD_GET_PATH_BY_NAME =
- "/api/multicloud/v1/CloudOwner/MTN13/infra_workload/vfname";
- private static final String MULTICLOUD_GET_PATH_BY_ID =
- "/api/multicloud/v1/CloudOwner/MTN13/infra_workload/workload-id";
-
- @Before
- public void before() throws Exception {
- super.orchestrator = "multicloud";
- super.cloudEndpoint = "/api/multicloud/v1/CloudOwner/MTN13/infra_workload";
- super.setUp();
- }
-
- @Test
- public void createVfModule() throws Exception {
-
- Map<String, Object> stackInputs = new HashMap<>();
- stackInputs.put("oof_directives", "{}");
- stackInputs.put("sdnc_directives", "{}");
- stackInputs.put("user_directives", "{}");
- stackInputs.put("generic_vnf_id", "genVNFID");
- stackInputs.put("vf_module_id", "vfMODULEID");
-
- MsoRequest msoRequest = new MsoRequest();
- msoRequest.setRequestId("12345");
- msoRequest.setServiceInstanceId("12345");
-
- wireMockServer.stubFor(get(urlPathEqualTo(MULTICLOUD_GET_PATH_BY_NAME)).willReturn(
- aResponse().withHeader("Content-Type", "application/json").withStatus(HttpStatus.SC_NOT_FOUND)));
-
- wireMockServer.stubFor(get(urlPathEqualTo(MULTICLOUD_GET_PATH_BY_ID)).inScenario("CREATE")
- .whenScenarioStateIs("CREATING").willReturn(aResponse().withHeader("Content-Type", "application/json")
- .withBody(GET_CREATE_STACK_RESPONSE).withStatus(HttpStatus.SC_OK)));
-
- wireMockServer.stubFor(get(urlPathEqualTo(MULTICLOUD_GET_PATH_BY_ID)).inScenario("CREATE")
- .whenScenarioStateIs("UPDATING").willReturn(aResponse().withHeader("Content-Type", "application/json")
- .withBody(GET_UPDATE_STACK_RESPONSE).withStatus(HttpStatus.SC_OK)));
-
- wireMockServer.stubFor(post(urlPathEqualTo(MULTICLOUD_CREATE_PATH)).inScenario("CREATE")
- .willReturn(aResponse().withHeader("Content-Type", "application/json")
- .withBodyFile("MulticloudResponse_Stack_Create.json").withStatus(HttpStatus.SC_CREATED))
- .willSetStateTo("CREATING"));
-
- wireMockServer.stubFor(post(urlPathEqualTo(MULTICLOUD_UPDATE_PATH))
- .inScenario("CREATE").willReturn(aResponse().withHeader("Content-Type", "application/json")
- .withBody(UPDATE_STACK_RESPONSE).withStatus(HttpStatus.SC_ACCEPTED))
- .willSetStateTo("UPDATING"));
-
- try {
- instance.createVfModule("MTN13", "CloudOwner", "123", "vf", "v1", "genericVnfId", "vfname", "vfModuleId",
- "create", null, "234", "9b339a61-69ca-465f-86b8-1c72c582b8e8", stackInputs, true, true, true,
- msoRequest, new Holder<>(), new Holder<>(), new Holder<>());
- } catch (VnfException e) {
- fail("createVfModule success expected, failed with exception: " + e.toString());
- }
- wireMockServer.resetScenarios();
- }
-
- @Test
- public void createVfModule2() throws Exception {
-
- Map<String, Object> stackInputs = new HashMap<>();
- stackInputs.put("oof_directives", "{}");
- stackInputs.put("sdnc_directives", "{}");
- stackInputs.put("user_directives", "{}");
- stackInputs.put("generic_vnf_id", "genVNFID");
- stackInputs.put("vf_module_id", "vfMODULEID");
-
- MsoRequest msoRequest = new MsoRequest();
- msoRequest.setRequestId("12345");
- msoRequest.setServiceInstanceId("12345");
-
- wireMockServer.stubFor(get(urlPathEqualTo(MULTICLOUD_GET_PATH_BY_NAME)).willReturn(
- aResponse().withHeader("Content-Type", "application/json").withStatus(HttpStatus.SC_NOT_FOUND)));
-
- wireMockServer.stubFor(get(urlPathEqualTo(MULTICLOUD_GET_PATH_BY_ID)).inScenario("CREATE")
- .whenScenarioStateIs("CREATING").willReturn(aResponse().withHeader("Content-Type", "application/json")
- .withBody(GET_CREATE_STACK_RESPONSE).withStatus(HttpStatus.SC_OK)));
-
- wireMockServer.stubFor(get(urlPathEqualTo(MULTICLOUD_GET_PATH_BY_ID)).inScenario("CREATE")
- .whenScenarioStateIs("UPDATING").willReturn(aResponse().withHeader("Content-Type", "application/json")
- .withBody(GET_UPDATE_STACK_RESPONSE).withStatus(HttpStatus.SC_OK)));
-
- wireMockServer.stubFor(post(urlPathEqualTo(MULTICLOUD_CREATE_PATH)).inScenario("CREATE")
- .willReturn(aResponse().withHeader("Content-Type", "application/json")
- .withBodyFile("MulticloudResponse_Stack_Create2.json").withStatus(HttpStatus.SC_CREATED))
- .willSetStateTo("CREATING"));
-
- wireMockServer.stubFor(post(urlPathEqualTo(MULTICLOUD_UPDATE_PATH))
- .inScenario("CREATE").willReturn(aResponse().withHeader("Content-Type", "application/json")
- .withBody(UPDATE_STACK_RESPONSE).withStatus(HttpStatus.SC_ACCEPTED))
- .willSetStateTo("UPDATING"));
-
- try {
- instance.createVfModule("MTN13", "CloudOwner", "123", "vf", "v1", "genericVnfId", "vfname", "vfModuleId",
- "create", null, "234", "9b339a61-69ca-465f-86b8-1c72c582b8e8", stackInputs, true, true, true,
- msoRequest, new Holder<>(), new Holder<>(), new Holder<>());
- } catch (VnfException e) {
- fail("createVfModule success expected, failed with exception: " + e.toString());
- }
- wireMockServer.resetScenarios();
- }
-
- @Test
- public void createVfModuleAlreadyExists() throws Exception {
-
- Map<String, Object> stackInputs = new HashMap<>();
- stackInputs.put("oof_directives", "{}");
- stackInputs.put("sdnc_directives", "{}");
- stackInputs.put("user_directives", "{}");
- stackInputs.put("generic_vnf_id", "genVNFID");
- stackInputs.put("vf_module_id", "vfMODULEID");
-
- MsoRequest msoRequest = new MsoRequest();
- msoRequest.setRequestId("12345");
- msoRequest.setServiceInstanceId("12345");
-
- wireMockServer.stubFor(
- get(urlEqualTo("/api/multicloud/v1/CloudOwner/MTN13/infra_workload?name=vfname")).willReturn(aResponse()
- // .withHeader()
- .withBodyFile("MulticloudGetStackExists.json").withStatus(HttpStatus.SC_OK)));
-
- try {
- instance.createVfModule("MTN13", "CloudOwner", "123", "vf", "v1", "genericVnfId", "vfname", "vfModuleId",
- "create", null, "234", "9b339a61-69ca-465f-86b8-1c72c582b8e8", stackInputs, true, true, true,
- msoRequest, new Holder<>(), new Holder<>(), new Holder<>());
- } catch (VnfException e) {
- assertTrue(e.toString().contains(
- "Resource vfname already exists in owner/cloud/tenant CloudOwner/MTN13/123 with ID vfname/vfname"));
- return;
- }
- fail("VnfAlreadyExists Exception expected!");
- }
-
- @Test
- public void deleteVfModule() throws Exception {
- MsoRequest msoRequest = new MsoRequest();
- msoRequest.setRequestId("12345");
- msoRequest.setServiceInstanceId("12345");
-
- wireMockServer.stubFor(get(urlPathEqualTo("/api/multicloud/v1/CloudOwner/MTN13/infra_workload/workload-id"))
- .willReturn(aResponse().withBodyFile("MulticloudResponse_Stack.json").withStatus(HttpStatus.SC_OK)));
-
- wireMockServer.stubFor(delete(urlPathEqualTo("/api/multicloud/v1/CloudOwner/MTN13/infra_workload/workload-id"))
- .willReturn(aResponse().withStatus(HttpStatus.SC_NO_CONTENT)));
-
- instance.deleteVfModule("MTN13", "CloudOwner", "123", "workload-id", "5aae1e49-805c-4f9f-bd78-055bf7451157",
- "11420693-3f69-4c61-b3ee-9787c744e760", "customizationId", msoRequest, new Holder<>());
- }
-
- @Test
- public void queryVfModule() throws Exception {
- MsoRequest msoRequest = new MsoRequest();
- msoRequest.setRequestId("12345");
- msoRequest.setServiceInstanceId("12345");
-
- wireMockServer.stubFor(get(urlPathEqualTo("/api/multicloud/v1/CloudOwner/MTN13/infra_workload/workload-id"))
- .willReturn(aResponse().withBodyFile("MulticloudResponse_Stack.json").withStatus(HttpStatus.SC_OK)));
-
- instance.queryVnf("MTN13", "CloudOwner", "123", "workload-id", msoRequest, new Holder<>(), new Holder<>(),
- new Holder<>(), new Holder<>());
- }
-
- // TODO Error Tests
-}
diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfPluginAdapterImplTest.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfPluginAdapterImplTest.java
deleted file mode 100644
index a68efbe130..0000000000
--- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfPluginAdapterImplTest.java
+++ /dev/null
@@ -1,166 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 - 2018 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.onap.so.adapters.vnf;
-
-import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
-import static com.github.tomakehurst.wiremock.client.WireMock.delete;
-import static com.github.tomakehurst.wiremock.client.WireMock.get;
-import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo;
-import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackGetStackVfModule_200;
-import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackGetStackVfModule_404;
-import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackResponseAccess;
-import java.util.HashMap;
-import java.util.Map;
-import javax.xml.ws.Holder;
-import org.apache.http.HttpStatus;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
-import org.onap.so.adapters.vnf.exceptions.VnfException;
-import org.onap.so.entity.MsoRequest;
-import org.onap.so.openstack.beans.VnfRollback;
-import org.springframework.beans.factory.annotation.Autowired;
-
-public class MsoVnfPluginAdapterImplTest extends BaseRestTestUtils {
-
- @Rule
- public ExpectedException expectedException = ExpectedException.none();
-
- @Autowired
- MsoVnfPluginAdapterImpl msoVnfPluginAdapter;
-
- String vnfName = "DEV-VF-1802-it3-pwt3-v6-vSAMP10a-addon2-Replace-1001/stackId";
-
- @Test
- public void createVfModule_ModelCustUuidIsNull() throws Exception {
- expectedException.expect(VnfException.class);
- MsoRequest msoRequest = getMsoRequest();
- Map<String, Object> map = new HashMap<>();
- map.put("key1", "value1");
- msoVnfPluginAdapter.createVfModule("mtn13", "CloudOwner", "88a6ca3ee0394ade9403f075db23167e", "vnf", "1", "",
- vnfName, "", "VFMOD", "volumeGroupHeatStackId|1", "baseVfHeatStackId", null, map, Boolean.FALSE,
- Boolean.TRUE, Boolean.FALSE, msoRequest, new Holder<>(), new Holder<Map<String, String>>(),
- new Holder<VnfRollback>());
- }
-
- @Test
- public void createVfModule_ModelCustUuidIsNotFound() throws Exception {
- expectedException.expect(VnfException.class);
- MsoRequest msoRequest = getMsoRequest();
- Map<String, Object> map = new HashMap<>();
- map.put("key1", "value1");
- msoVnfPluginAdapter.createVfModule("mtn13", "CloudOwner", "88a6ca3ee0394ade9403f075db23167e", "vnf", "1", "",
- vnfName, "", "VFMOD", "volumeGroupHeatStackId|1", "baseVfHeatStackId",
- "88a6ca3ee0394ade9403f075db23167e", map, Boolean.FALSE, Boolean.TRUE, Boolean.FALSE, msoRequest,
- new Holder<>(), new Holder<Map<String, String>>(), new Holder<VnfRollback>());
- }
-
- @Test
- public void createVfModule_VduException() throws Exception {
- expectedException.expect(VnfException.class);
- MsoRequest msoRequest = getMsoRequest();
- Map<String, Object> map = new HashMap<>();
- map.put("key1", "value1");
- msoVnfPluginAdapter.createVfModule("mtn13", "CloudOwner", "88a6ca3ee0394ade9403f075db23167e", "vnf", "1", "",
- vnfName, "", "VFMOD", "volumeGroupHeatStackId|1", "baseVfHeatStackId",
- "9b339a61-69ca-465f-86b8-1c72c582b8e8", map, Boolean.FALSE, Boolean.TRUE, Boolean.FALSE, msoRequest,
- new Holder<>(), new Holder<Map<String, String>>(), new Holder<VnfRollback>());
- }
-
- @Test
- public void createVfModule_INSTANTIATED() throws Exception {
- mockOpenStackResponseAccess(wireMockServer, wireMockPort);
- mockOpenStackGetStackVfModule_200(wireMockServer);
-
- MsoRequest msoRequest = getMsoRequest();
- Map<String, Object> map = new HashMap<>();
- map.put("key1", "value1");
- msoVnfPluginAdapter.createVfModule("mtn13", "CloudOwner", "88a6ca3ee0394ade9403f075db23167e", "vnf", "1", "",
- vnfName, "", "VFMOD", null, "baseVfHeatStackId", "9b339a61-69ca-465f-86b8-1c72c582b8e8", map,
- Boolean.FALSE, Boolean.TRUE, Boolean.FALSE, msoRequest, new Holder<>(),
- new Holder<Map<String, String>>(), new Holder<VnfRollback>());
- }
-
- @Test
- public void createVfModule_queryVduNotFoundWithVolumeGroupId() throws Exception {
- expectedException.expect(VnfException.class);
- mockOpenStackResponseAccess(wireMockServer, wireMockPort);
- MsoRequest msoRequest = getMsoRequest();
- Map<String, Object> map = new HashMap<>();
- map.put("key1", "value1");
- msoVnfPluginAdapter.createVfModule("mtn13", "CloudOwner", "88a6ca3ee0394ade9403f075db23167e", "vnf", "1", "",
- vnfName, "", "VFMOD", "volumeGroupHeatStackId|1", "baseVfHeatStackId",
- "9b339a61-69ca-465f-86b8-1c72c582b8e8", map, Boolean.FALSE, Boolean.TRUE, Boolean.FALSE, msoRequest,
- new Holder<>(), new Holder<Map<String, String>>(), new Holder<VnfRollback>());
- }
-
- @Test
- public void createVfModule_CreateVduException() throws Exception {
- expectedException.expect(VnfException.class);
- mockOpenStackResponseAccess(wireMockServer, wireMockPort);
- mockOpenStackGetStackVfModule_404(wireMockServer);
- wireMockServer.stubFor(get(urlPathEqualTo("/mockPublicUrl/stacks/volumeGroupHeatStackId"))
- .willReturn(aResponse().withHeader("Content-Type", "application/json")
- .withBodyFile("OpenstackResponse_Stack_Created_VfModule.json").withStatus(HttpStatus.SC_OK)));
- MsoRequest msoRequest = getMsoRequest();
- Map<String, Object> map = new HashMap<>();
- map.put("key1", "value1");
- msoVnfPluginAdapter.createVfModule("mtn13", "CloudOwner", "88a6ca3ee0394ade9403f075db23167e", "vnf", "1", "",
- vnfName, "", "VFMOD", "volumeGroupHeatStackId", "baseVfHeatStackId",
- "9b339a61-69ca-465f-86b8-1c72c582b8e8", map, Boolean.FALSE, Boolean.TRUE, Boolean.FALSE, msoRequest,
- new Holder<>(), new Holder<Map<String, String>>(), new Holder<VnfRollback>());
- }
-
- @Test
- public void deleteVfModule_QueryVduException() throws Exception {
- expectedException.expect(VnfException.class);
- MsoRequest msoRequest = getMsoRequest();
- msoVnfPluginAdapter.deleteVfModule("mtn13", "CloudOwner", "88a6ca3ee0394ade9403f075db23167e", "vSAMP12",
- "5aae1e49-805c-4f9f-bd78-055bf7451157", "11420693-3f69-4c61-b3ee-9787c744e760", "customizationId",
- msoRequest, new Holder<Map<String, String>>());
- }
-
- @Test
- public void deleteVfModule_DeleteVduException() throws Exception {
- expectedException.expect(VnfException.class);
- mockOpenStackResponseAccess(wireMockServer, wireMockPort);
- mockOpenStackGetStackVfModule_200(wireMockServer);
- wireMockServer.stubFor(get(urlPathEqualTo("/mockPublicUrl/stacks/vSAMP12"))
- .willReturn(aResponse().withHeader("Content-Type", "application/json")
- .withBodyFile("OpenstackResponse_Stack_Created_VfModule.json").withStatus(HttpStatus.SC_OK)));
- wireMockServer.stubFor(delete(
- urlPathEqualTo("/mockPublicUrl/stacks/DEV-VF-1802-it3-pwt3-v6-vSAMP10a-addon2-Replace-1001/stackId"))
- .willReturn(aResponse().withHeader("Content-Type", "application/json")
- .withStatus(HttpStatus.SC_INTERNAL_SERVER_ERROR)));
- MsoRequest msoRequest = getMsoRequest();
- msoVnfPluginAdapter.deleteVfModule("mtn13", "CloudOwner", "88a6ca3ee0394ade9403f075db23167e", "vSAMP12",
- "5aae1e49-805c-4f9f-bd78-055bf7451157", "11420693-3f69-4c61-b3ee-9787c744e760", "customizationId",
- msoRequest, new Holder<Map<String, String>>());
- }
-
- private MsoRequest getMsoRequest() {
- MsoRequest msoRequest = new MsoRequest();
- msoRequest.setRequestId("12345");
- msoRequest.setServiceInstanceId("12345");
- return msoRequest;
- }
-
-}
diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/QueryTest.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/QueryTest.java
deleted file mode 100644
index 7e7c130e33..0000000000
--- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/QueryTest.java
+++ /dev/null
@@ -1,110 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2018 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.onap.so.adapters.vnf;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.Matchers.hasProperty;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-import static org.mockito.Mockito.when;
-import java.util.Map;
-import javax.xml.ws.Holder;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
-import org.junit.runner.RunWith;
-import org.mockito.InjectMocks;
-import org.mockito.Mock;
-import org.mockito.Mockito;
-import org.mockito.junit.MockitoJUnitRunner;
-import org.onap.so.adapters.vnf.exceptions.VnfException;
-import org.onap.so.openstack.beans.HeatStatus;
-import org.onap.so.openstack.beans.StackInfo;
-import org.onap.so.openstack.beans.VnfStatus;
-import org.onap.so.openstack.exceptions.MsoException;
-import org.onap.so.openstack.exceptions.MsoOpenstackException;
-import org.onap.so.openstack.utils.MsoHeatUtils;
-
-@RunWith(MockitoJUnitRunner.class)
-public class QueryTest {
-
- @Mock
- private MsoHeatUtils heat;
- @InjectMocks
- private MsoVnfAdapterImpl vnfAdapter = new MsoVnfAdapterImpl();
-
- @Rule
- public ExpectedException thrown = ExpectedException.none();
-
- @Test
- public void testQueryCreatedVnf() throws VnfException, MsoException {
- StackInfo info = new StackInfo("stackName", HeatStatus.CREATED);
- when(heat.queryStack(Mockito.any(), Mockito.any(), Mockito.any(), Mockito.any())).thenReturn(info);
- String cloudId = "MT";
- String cloudOwner = "CloudOwner";
- String tenantId = "MSO_Test";
- String vnfName = "VNF_TEST1";
- Holder<Boolean> vnfExists = new Holder<>();
- Holder<String> vnfId = new Holder<>();
- Holder<VnfStatus> status = new Holder<>();
- Holder<Map<String, String>> outputs = new Holder<>();
-
- vnfAdapter.queryVnf(cloudId, cloudOwner, tenantId, vnfName, null, vnfExists, vnfId, status, outputs);
-
- assertTrue(vnfExists.value);
- }
-
- @Test
- public void testQueryNotFoundVnf() throws VnfException, MsoException {
- StackInfo info = new StackInfo("stackName", HeatStatus.NOTFOUND);
- when(heat.queryStack(Mockito.any(), Mockito.any(), Mockito.any(), Mockito.any())).thenReturn(info);
- String cloudId = "MT";
- String cloudOwner = "CloudOwner";
- String tenantId = "MSO_Test";
- String vnfName = "VNF_TEST1";
- Holder<Boolean> vnfExists = new Holder<>();
- Holder<String> vnfId = new Holder<>();
- Holder<VnfStatus> status = new Holder<>();
- Holder<Map<String, String>> outputs = new Holder<>();
-
- vnfAdapter.queryVnf(cloudId, cloudOwner, tenantId, vnfName, null, vnfExists, vnfId, status, outputs);
-
- assertFalse(vnfExists.value);
- }
-
- @Test()
- // @Ignore // 1802 merge
- public void testQueryVnfWithException() throws VnfException, MsoException {
- String cloudId = "MT";
- String cloudOwner = "CloudOwner";
- String tenantId = "MSO_Test";
- String vnfName = "VNF_TEST1";
- Holder<Boolean> vnfExists = new Holder<>();
- Holder<String> vnfId = new Holder<>();
- Holder<VnfStatus> status = new Holder<>();
- Holder<Map<String, String>> outputs = new Holder<>();
- thrown.expect(VnfException.class);
- thrown.expectCause(hasProperty("context", is("QueryVNF")));
- when(heat.queryStack(Mockito.any(), Mockito.any(), Mockito.any(), Mockito.any()))
- .thenThrow(new MsoOpenstackException(1, "test messsage", "test detail"));
- vnfAdapter.queryVnf(cloudId, cloudOwner, tenantId, vnfName, null, vnfExists, vnfId, status, outputs);
- }
-}
diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/VnfAdapterRestTest.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/VnfAdapterRestTest.java
deleted file mode 100644
index 9655e90e46..0000000000
--- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/VnfAdapterRestTest.java
+++ /dev/null
@@ -1,557 +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.onap.so.adapters.vnf;
-
-import com.fasterxml.jackson.core.JsonParseException;
-import com.fasterxml.jackson.databind.JsonMappingException;
-import com.github.tomakehurst.wiremock.WireMockServer;
-import org.apache.http.HttpStatus;
-import org.json.JSONException;
-import org.junit.Ignore;
-import org.junit.Test;
-import org.onap.so.adapters.vnfrest.CreateVfModuleRequest;
-import org.onap.so.adapters.vnfrest.CreateVfModuleResponse;
-import org.onap.so.adapters.vnfrest.DeleteVfModuleRequest;
-import org.onap.so.adapters.vnfrest.DeleteVfModuleResponse;
-import org.onap.so.adapters.vnfrest.QueryVfModuleResponse;
-import org.onap.so.adapters.vnfrest.RollbackVfModuleRequest;
-import org.onap.so.adapters.vnfrest.RollbackVfModuleResponse;
-import org.onap.so.adapters.vnfrest.UpdateVfModuleRequest;
-import org.onap.so.adapters.vnfrest.UpdateVfModuleResponse;
-import org.onap.so.adapters.vnfrest.VfModuleExceptionResponse;
-import org.onap.so.adapters.vnfrest.VfModuleRollback;
-import org.onap.so.client.policy.JettisonStyleMapperProvider;
-import org.onap.so.entity.MsoRequest;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.http.HttpEntity;
-import org.springframework.http.HttpMethod;
-import org.springframework.http.ResponseEntity;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
-import javax.ws.rs.core.UriBuilder;
-import java.io.File;
-import java.io.IOException;
-import java.util.HashMap;
-import java.util.Map;
-import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
-import static com.github.tomakehurst.wiremock.client.WireMock.patch;
-import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo;
-import static com.shazam.shazamcrest.MatcherAssert.assertThat;
-import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs;
-import static org.junit.Assert.assertEquals;
-import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackDeletePublicUrlStackByNameAndID_204;
-import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackDeleteStacks;
-import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackGetPublicUrlStackByNameAndID_200;
-import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackGetStackVfModule_200;
-import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackGetStackVfModule_404;
-import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackGetStacksBaseStack_200;
-import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackGetStacksStackId_200;
-import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackGetStacksStackId_404;
-import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackGetStacksVUSP_404;
-import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackGetStacksVfModuleWithLocationHeader_200;
-import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackGetStacksVfModule_200;
-import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackGetStacksWithBody_200;
-import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackGetStacksWithBody_404;
-import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackGetStacks_404;
-import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackPostStacks_200;
-import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackPutStacks_200;
-import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackResponseAccess;
-
-public class VnfAdapterRestTest extends BaseRestTestUtils {
-
-
- @Autowired
- private JettisonStyleMapperProvider jettisonTypeObjectMapper;
- private static final String MESSAGE_ID = "62265093-277d-4388-9ba6-449838ade586-1517252396874";
- private static final String AAI_VNF_ID = "c93e0d34-5b63-45de-bbae-b0fe49dd3bd9";
- private static final String MSO_REQUEST_ID = "62265093-277d-4388-9ba6-449838ade586";
- private static final String MSO_SERVICE_INSTANCE_ID = "4147e06f-1b89-49c5-b21f-4faf8dc9805a";
- private static final String CLOUDSITE_ID = "mtn13";
- private static final String CLOUD_OWNER = "CloudOwner";
- private static final String TENANT_ID = "0422ffb57ba042c0800a29dc85ca70f8";
- private static final String VNF_TYPE = "MSOTADevInfra_vSAMP10a_Service/vSAMP10a 1";
- private static final String VNF_NAME = "MSO-DEV-VNF-1802-it3-pwt3-vSAMP10a-1XXX-Replace";
- private static final String VNF_VERSION = "1.0";
- private static final String VF_MODULE_ID = "1d48aaec-b7f3-4c24-ba4a-4e798ed3223c";
- private static final String VF_MODULE_NAME = "DEV-VF-1802-it3-pwt3-v6-vSAMP10a-addon2-Replace-1001";
- private static final String VF_MODULE_TYPE = "vSAMP10aDEV::PCM::module-2";
- private static final String MODEL_CUSTOMIZATION_UUID = "cb82ffd8-252a-11e7-93ae-92361f002671";
- private static final String BASE_VF_MODULE_ID = "3d7ff7b4-720b-4604-be0a-1974fc58ed96";
- // vfModuleParams specific variables
- private static final String NETWORK_NAME = "Dev-vSAMP10a-ntwk-1802-pwt3-v6-Replace-1001";
- private static final String SERVER_NAME = "Dev-vSAMP10a-addon2-1802-pwt3-v6-Replace-1001";
- private static final String IMAGE = "ubuntu_14.04_IPv6";
- private static final String EXN_DIRECT_NET_FQDN = "direct";
- private static final String EXN_HSL_NET_FQDN = "hsl";
- private static final String AVAILABILITY_ZONE_0 = "nova";
- private static final String VF_MODULE_INDEX = "0";
-
- @Test
- public void testCreateVfModule() throws JSONException, JsonParseException, JsonMappingException, IOException {
-
- CreateVfModuleRequest request = populateCreateVfModuleRequest();
-
- mockOpenStackResponseAccess(wireMockServer, wireMockPort);
-
- mockOpenStackGetStackVfModule_404(wireMockServer);
-
- mockOpenStackPostStacks_200(wireMockServer);
-
- mockOpenStackGetStackVfModule_200(wireMockServer);
-
- mockUpdateRequestDb(wireMockServer, "62265093-277d-4388-9ba6-449838ade586");
-
- headers.add("Accept", MediaType.APPLICATION_JSON);
- HttpEntity<CreateVfModuleRequest> entity = new HttpEntity<CreateVfModuleRequest>(request, headers);
-
- ResponseEntity<CreateVfModuleResponse> response =
- restTemplate.exchange(createURLWithPort("/services/rest/v1/vnfs/" + AAI_VNF_ID + "/vf-modules"),
- HttpMethod.POST, entity, CreateVfModuleResponse.class);
-
- ResponseEntity<CreateVfModuleResponse> responseV2 =
- restTemplate.exchange(createURLWithPort("/services/rest/v2/vnfs/" + AAI_VNF_ID + "/vf-modules"),
- HttpMethod.POST, entity, CreateVfModuleResponse.class);
-
- CreateVfModuleResponse expectedResponse = jettisonTypeObjectMapper.getMapper().readValue(
- new File("src/test/resources/__files/CreateVfModuleResponse.json"), CreateVfModuleResponse.class);
-
- assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
- assertThat(response.getBody(), sameBeanAs(expectedResponse));
-
- assertEquals(Response.Status.OK.getStatusCode(), responseV2.getStatusCode().value());
- assertThat(responseV2.getBody(), sameBeanAs(expectedResponse));
- }
-
- @Test
- public void testCreateVfModuleAsyncCall() throws Exception {
- CreateVfModuleRequest request = populateCreateVfModuleRequest();
- request.setNotificationUrl(createURLWithPort("/mso/WorkflowMesssage"));
-
- mockOpenStackResponseAccess(wireMockServer, wireMockPort);
- mockOpenStackGetStackVfModule_404(wireMockServer);
- mockOpenStackPostStacks_200(wireMockServer);
- mockOpenStackGetStackVfModule_200(wireMockServer);
-
- headers.add("Accept", MediaType.APPLICATION_JSON);
- HttpEntity<CreateVfModuleRequest> entity = new HttpEntity<CreateVfModuleRequest>(request, headers);
-
- ResponseEntity<CreateVfModuleResponse> response =
- restTemplate.exchange(createURLWithPort("/services/rest/v1/vnfs/" + AAI_VNF_ID + "/vf-modules"),
- HttpMethod.POST, entity, CreateVfModuleResponse.class);
-
- CreateVfModuleResponse expectedResponse = jettisonTypeObjectMapper.getMapper().readValue(
- new File("src/test/resources/__files/CreateVfModuleResponse.json"), CreateVfModuleResponse.class);
-
- assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
- }
-
- @Test
- public void testCreateVfModuleWithEnableBridgeNull()
- throws JSONException, JsonParseException, JsonMappingException, IOException {
-
- CreateVfModuleRequest request = new CreateVfModuleRequest();
- request.setBackout(true);
- request.setSkipAAI(true);
- request.setFailIfExists(false);
- MsoRequest msoReq = new MsoRequest();
- boolean failIfExists = true;
- Boolean enableBridge = null;
- Map<String, Object> vfModuleParams = new HashMap<>();
-
-
- vfModuleParams.put("vf_module_id", VF_MODULE_ID);
- vfModuleParams.put("vnf_id", AAI_VNF_ID);
- vfModuleParams.put("network_name", NETWORK_NAME);
- vfModuleParams.put("vnf_name", VNF_NAME);
- vfModuleParams.put("environment_context", "");
- vfModuleParams.put("server_name", SERVER_NAME);
- vfModuleParams.put("image", IMAGE);
- vfModuleParams.put("workload_context", "");
- vfModuleParams.put("vf_module_index", VF_MODULE_INDEX);
- vfModuleParams.put("vf_module_name", VF_MODULE_NAME);
- vfModuleParams.put("availability_zone_0", AVAILABILITY_ZONE_0);
- vfModuleParams.put("exn_direct_net_fqdn", EXN_DIRECT_NET_FQDN);
- vfModuleParams.put("exn_hsl_net_fqdn", EXN_HSL_NET_FQDN);
-
- msoReq.setRequestId(MSO_REQUEST_ID);
- msoReq.setServiceInstanceId(MSO_SERVICE_INSTANCE_ID);
- request.setMsoRequest(msoReq);
- request.setCloudSiteId(CLOUDSITE_ID);
- request.setTenantId(TENANT_ID);
- request.setModelCustomizationUuid(MODEL_CUSTOMIZATION_UUID);
- request.setVnfId(AAI_VNF_ID);
- request.setVnfVersion(VNF_VERSION);
- request.setVfModuleId(VF_MODULE_ID);
- request.setVfModuleName(VF_MODULE_NAME);
- request.setBaseVfModuleId(BASE_VF_MODULE_ID);
- request.setFailIfExists(failIfExists);
- request.setEnableBridge(enableBridge);
- request.setVfModuleParams(vfModuleParams);
- request.setMessageId(MESSAGE_ID);
-
- mockOpenStackResponseAccess(wireMockServer, wireMockPort);
-
- mockOpenStackGetStackVfModule_404(wireMockServer);
-
- mockOpenStackPostStacks_200(wireMockServer);
-
- mockOpenStackGetStackVfModule_200(wireMockServer);
-
- mockUpdateRequestDb(wireMockServer, "62265093-277d-4388-9ba6-449838ade586");
-
-
- headers.add("Accept", MediaType.APPLICATION_JSON);
- HttpEntity<CreateVfModuleRequest> entity = new HttpEntity<CreateVfModuleRequest>(request, headers);
-
- ResponseEntity<CreateVfModuleResponse> response =
- restTemplate.exchange(createURLWithPort("/services/rest/v1/vnfs/" + AAI_VNF_ID + "/vf-modules"),
- HttpMethod.POST, entity, CreateVfModuleResponse.class);
-
- CreateVfModuleResponse expectedResponse = jettisonTypeObjectMapper.getMapper().readValue(
- new File("src/test/resources/__files/CreateVfModuleResponse.json"), CreateVfModuleResponse.class);
-
- assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
- assertThat(response.getBody(), sameBeanAs(expectedResponse));
- }
-
- @Test
- public void testCreateVfModuleFail() throws IOException {
-
- CreateVfModuleRequest request = new CreateVfModuleRequest();
- request.setBackout(true);
- request.setSkipAAI(true);
- request.setFailIfExists(false);
- MsoRequest msoReq = new MsoRequest();
- boolean failIfExists = true;
- boolean enableBridge = false;
- Map<String, Object> vfModuleParams = new HashMap<>();
-
- vfModuleParams.put("vf_module_id", VF_MODULE_ID);
- vfModuleParams.put("vnf_id", AAI_VNF_ID);
- vfModuleParams.put("network_name", NETWORK_NAME);
- vfModuleParams.put("vnf_name", VNF_NAME);
- vfModuleParams.put("environment_context", "");
- vfModuleParams.put("server_name", SERVER_NAME);
- vfModuleParams.put("image", IMAGE);
- vfModuleParams.put("workload_context", "");
- vfModuleParams.put("vf_module_index", VF_MODULE_INDEX);
- vfModuleParams.put("vf_module_name", VF_MODULE_NAME);
- vfModuleParams.put("availability_zone_0", AVAILABILITY_ZONE_0);
- vfModuleParams.put("exn_direct_net_fqdn", EXN_DIRECT_NET_FQDN);
- vfModuleParams.put("exn_hsl_net_fqdn", EXN_HSL_NET_FQDN);
-
- msoReq.setRequestId(MSO_REQUEST_ID);
- msoReq.setServiceInstanceId(MSO_SERVICE_INSTANCE_ID);
- request.setMsoRequest(msoReq);
- request.setCloudSiteId(CLOUDSITE_ID);
- request.setTenantId(TENANT_ID);
- request.setModelCustomizationUuid(MODEL_CUSTOMIZATION_UUID);
- request.setVnfId(AAI_VNF_ID);
- request.setVnfType(VNF_TYPE);
- request.setVnfVersion(VNF_VERSION);
- request.setVfModuleId(VF_MODULE_ID);
- request.setVfModuleName(VF_MODULE_NAME);
- request.setVfModuleType(VF_MODULE_TYPE);
- request.setBaseVfModuleStackId(BASE_VF_MODULE_ID);
- request.setFailIfExists(failIfExists);
- request.setEnableBridge(enableBridge);
- request.setVfModuleParams(vfModuleParams);
- request.setMessageId(MESSAGE_ID);
-
- mockOpenStackResponseAccess(wireMockServer, wireMockPort);
-
- mockOpenStackGetStackVfModule_404(wireMockServer);
-
- mockOpenStackGetStacks_404(wireMockServer);
-
- mockOpenStackPostStacks_200(wireMockServer);
-
- mockOpenStackGetStackVfModule_200(wireMockServer);
-
- headers.add("Accept", MediaType.APPLICATION_JSON);
- HttpEntity<CreateVfModuleRequest> entity = new HttpEntity<CreateVfModuleRequest>(request, headers);
-
- ResponseEntity<VfModuleExceptionResponse> response =
- restTemplate.exchange(createURLWithPort("/services/rest/v1/vnfs/" + AAI_VNF_ID + "/vf-modules"),
- HttpMethod.POST, entity, VfModuleExceptionResponse.class);
-
- assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
-
- mockOpenStackGetStacksWithBody_200(wireMockServer, "DELETE_IN_PROGRESS");
-
- response = restTemplate.exchange(createURLWithPort("/services/rest/v1/vnfs/" + AAI_VNF_ID + "/vf-modules"),
- HttpMethod.POST, entity, VfModuleExceptionResponse.class);
-
- assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
-
- mockOpenStackGetStacksWithBody_200(wireMockServer, "DELETE_FAILED");
-
- response = restTemplate.exchange(createURLWithPort("/services/rest/v1/vnfs/" + AAI_VNF_ID + "/vf-modules"),
- HttpMethod.POST, entity, VfModuleExceptionResponse.class);
-
- assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
-
- mockOpenStackGetStacksWithBody_200(wireMockServer, "UPDATE_COMPLETE");
-
- response = restTemplate.exchange(createURLWithPort("/services/rest/v1/vnfs/" + AAI_VNF_ID + "/vf-modules"),
- HttpMethod.POST, entity, VfModuleExceptionResponse.class);
-
- assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
-
- mockOpenStackGetStacksWithBody_404(wireMockServer);
-
- response = restTemplate.exchange(createURLWithPort("/services/rest/v1/vnfs/" + AAI_VNF_ID + "/vf-modules"),
- HttpMethod.POST, entity, VfModuleExceptionResponse.class);
-
- assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
-
- }
-
- @Test
- public void testDeleteVfModule() throws IOException {
-
- DeleteVfModuleRequest request = new DeleteVfModuleRequest();
- MsoRequest msoRequest = new MsoRequest();
- String vfModuleStackId = "stackId";
-
- msoRequest.setRequestId(MSO_REQUEST_ID);
- msoRequest.setServiceInstanceId(MSO_SERVICE_INSTANCE_ID);
- request.setCloudSiteId(CLOUDSITE_ID);
- request.setTenantId(TENANT_ID);
- request.setVfModuleId(VF_MODULE_ID);
- request.setVfModuleStackId(vfModuleStackId);
- request.setVnfId(AAI_VNF_ID);
- request.setMsoRequest(msoRequest);
-
- mockOpenStackResponseAccess(wireMockServer, wireMockPort);
-
- mockOpenStackPostStacks_200(wireMockServer);
-
- mockOpenStackGetStacksStackId_404(wireMockServer);
-
- mockOpenStackGetPublicUrlStackByNameAndID_200(wireMockServer, wireMockPort);
-
- mockOpenStackDeletePublicUrlStackByNameAndID_204(wireMockServer);
-
- mockUpdateRequestDb(wireMockServer, "62265093-277d-4388-9ba6-449838ade586");
-
- headers.add("Accept", MediaType.APPLICATION_JSON);
- HttpEntity<DeleteVfModuleRequest> entity = new HttpEntity<DeleteVfModuleRequest>(request, headers);
-
- ResponseEntity<DeleteVfModuleResponse> response = restTemplate.exchange(
- createURLWithPort("/services/rest/v1/vnfs/" + AAI_VNF_ID + "/vf-modules/" + VF_MODULE_ID),
- HttpMethod.DELETE, entity, DeleteVfModuleResponse.class);
-
- ResponseEntity<DeleteVfModuleResponse> responseV2 = restTemplate.exchange(
- createURLWithPort("/services/rest/v2/vnfs/" + AAI_VNF_ID + "/vf-modules/" + VF_MODULE_ID),
- HttpMethod.DELETE, entity, DeleteVfModuleResponse.class);
-
-
- DeleteVfModuleResponse expectedResponse = jettisonTypeObjectMapper.getMapper().readValue(
- new File("src/test/resources/__files/DeleteVfModuleResponse.json"), DeleteVfModuleResponse.class);
-
-
- assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
- assertThat(response.getBody(), sameBeanAs(expectedResponse));
-
- assertEquals(Response.Status.OK.getStatusCode(), responseV2.getStatusCode().value());
- assertThat(responseV2.getBody(), sameBeanAs(expectedResponse));
- }
-
- @Test
- public void testUpdateVfModule() throws IOException {
-
- UpdateVfModuleRequest request = new UpdateVfModuleRequest();
- MsoRequest msoRequest = new MsoRequest();
- String vfModuleStackId = "vfModuleStackId";
- Boolean failIfExists = false;
- Boolean backout = false;
- msoRequest.setRequestId(MSO_REQUEST_ID);
- msoRequest.setServiceInstanceId(MSO_SERVICE_INSTANCE_ID);
-
- Map<String, Object> vfModuleParams = new HashMap<>();
-
- vfModuleParams.put("exn_direct_net_fqdn", EXN_DIRECT_NET_FQDN);
- vfModuleParams.put("exn_hsl_net_fqdn", EXN_HSL_NET_FQDN);
-
- Map<String, String> vfModuleOutputs = new HashMap<String, String>();
-
- vfModuleOutputs.put("output name", "output value");
-
- request.setBackout(backout);
- request.setCloudSiteId(CLOUDSITE_ID);
- request.setFailIfExists(failIfExists);
- request.setModelCustomizationUuid(MODEL_CUSTOMIZATION_UUID);
- request.setMsoRequest(msoRequest);
- request.setTenantId(TENANT_ID);
- request.setVfModuleId(VF_MODULE_ID);
- request.setVfModuleName(VF_MODULE_NAME);
- request.setVfModuleStackId(vfModuleStackId);
- request.setBackout(backout);
- request.setVfModuleParams(vfModuleParams);
-
- mockOpenStackResponseAccess(wireMockServer, wireMockPort);
-
- mockOpenStackGetStacksVfModuleWithLocationHeader_200(wireMockServer, wireMockPort);
-
- mockOpenStackGetStacksVfModule_200(wireMockServer, wireMockPort);
-
- mockOpenStackGetStacksBaseStack_200(wireMockServer, wireMockPort);
-
- mockOpenStackPutStacks_200(wireMockServer);
-
- UpdateVfModuleResponse expectedResponse = jettisonTypeObjectMapper.getMapper().readValue(
- new File("src/test/resources/__files/UpdateVfModuleResponse.json"), UpdateVfModuleResponse.class);
- expectedResponse.setVfModuleOutputs(vfModuleOutputs);
-
- headers.add("Accept", MediaType.APPLICATION_JSON);
- HttpEntity<UpdateVfModuleRequest> entity = new HttpEntity<UpdateVfModuleRequest>(request, headers);
-
- ResponseEntity<UpdateVfModuleResponse> response = restTemplate.exchange(
- createURLWithPort("/services/rest/v1/vnfs/" + AAI_VNF_ID + "/vf-modules/" + VF_MODULE_TYPE),
- HttpMethod.PUT, entity, UpdateVfModuleResponse.class);
-
- ResponseEntity<UpdateVfModuleResponse> responseV2 = restTemplate.exchange(
- createURLWithPort("/services/rest/v2/vnfs/" + AAI_VNF_ID + "/vf-modules/" + VF_MODULE_TYPE),
- HttpMethod.PUT, entity, UpdateVfModuleResponse.class);
-
- assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
- assertThat(response.getBody(), sameBeanAs(expectedResponse));
-
- assertEquals(Response.Status.OK.getStatusCode(), responseV2.getStatusCode().value());
- assertThat(responseV2.getBody(), sameBeanAs(expectedResponse));
-
- }
-
- @Test
- public void testRollbackVfModule() throws IOException {
-
-
- MsoRequest msoRequest = new MsoRequest();
- msoRequest.setRequestId(MSO_REQUEST_ID);
- msoRequest.setServiceInstanceId(MSO_SERVICE_INSTANCE_ID);
-
- VfModuleRollback vfModuleRollback = new VfModuleRollback(AAI_VNF_ID, VF_MODULE_ID, "StackId", false, TENANT_ID,
- CLOUD_OWNER, CLOUDSITE_ID, msoRequest, "messageId");
-
- RollbackVfModuleRequest request = new RollbackVfModuleRequest();
- request.setVfModuleRollback(vfModuleRollback);
-
- mockOpenStackResponseAccess(wireMockServer, wireMockPort);
-
- mockOpenStackGetStacksStackId_200(wireMockServer, wireMockPort);
-
- mockOpenStackDeleteStacks(wireMockServer);
-
- mockOpenStackGetStacksVUSP_404(wireMockServer);
-
- headers.add("Accept", MediaType.APPLICATION_JSON);
- HttpEntity<RollbackVfModuleRequest> entity = new HttpEntity<RollbackVfModuleRequest>(request, headers);
-
- ResponseEntity<RollbackVfModuleResponse> response = restTemplate.exchange(
- createURLWithPort("/services/rest/v1/vnfs/" + AAI_VNF_ID + "/vf-modules/" + VF_MODULE_ID + "/rollback"),
- HttpMethod.DELETE, entity, RollbackVfModuleResponse.class);
-
- RollbackVfModuleResponse expectedResponse = jettisonTypeObjectMapper.getMapper().readValue(
- new File("src/test/resources/__files/RollbackVfModuleResponse.json"), RollbackVfModuleResponse.class);
-
- assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
- assertThat(response.getBody(), sameBeanAs(expectedResponse));
-
- }
-
- @Ignore
- @Test
- public void testQueryVfModule() throws IOException {
-
- String testUrl = createURLWithPort("/services/rest/v1/vnfs/" + AAI_VNF_ID + "/vf-modules/" + VF_MODULE_ID);
- String testUri = UriBuilder.fromPath("/services/rest/v1/vnfs/" + AAI_VNF_ID + "/vf-modules/" + VF_MODULE_ID)
- .host("localhost").port(wireMockPort).scheme("http")
- // .queryParam("cloudSiteId", CLOUDSITE_ID).queryParam("tenantId", TENANT_ID)
- .build().toString();
- System.out.println(testUri);
-
- mockOpenStackResponseAccess(wireMockServer, wireMockPort);
-
-
- headers.add("Accept", MediaType.APPLICATION_JSON);
- // HttpEntity entity = new HttpEntity(null, headers);
- ResponseEntity<QueryVfModuleResponse> response =
- restTemplate.getForEntity(testUri, QueryVfModuleResponse.class);
- // System.out.println(response);
-
- QueryVfModuleResponse expectedResponse = jettisonTypeObjectMapper.getMapper().readValue(
- new File("src/test/resources/__files/QueryVfModuleResponse.json"), QueryVfModuleResponse.class);
-
- assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
- assertThat(response.getBody(), sameBeanAs(expectedResponse));
- }
-
- private CreateVfModuleRequest populateCreateVfModuleRequest() {
- CreateVfModuleRequest request = new CreateVfModuleRequest();
- request.setBackout(true);
- request.setSkipAAI(true);
- request.setFailIfExists(false);
- MsoRequest msoReq = new MsoRequest();
- boolean failIfExists = true;
- boolean enableBridge = false;
- Map<String, Object> vfModuleParams = new HashMap<>();
-
- vfModuleParams.put("vf_module_id", VF_MODULE_ID);
- vfModuleParams.put("vnf_id", AAI_VNF_ID);
- vfModuleParams.put("network_name", NETWORK_NAME);
- vfModuleParams.put("vnf_name", VNF_NAME);
- vfModuleParams.put("environment_context", "");
- vfModuleParams.put("server_name", SERVER_NAME);
- vfModuleParams.put("image", IMAGE);
- vfModuleParams.put("workload_context", "");
- vfModuleParams.put("vf_module_index", VF_MODULE_INDEX);
- vfModuleParams.put("vf_module_name", VF_MODULE_NAME);
- vfModuleParams.put("availability_zone_0", AVAILABILITY_ZONE_0);
- vfModuleParams.put("exn_direct_net_fqdn", EXN_DIRECT_NET_FQDN);
- vfModuleParams.put("exn_hsl_net_fqdn", EXN_HSL_NET_FQDN);
-
- msoReq.setRequestId(MSO_REQUEST_ID);
- msoReq.setServiceInstanceId(MSO_SERVICE_INSTANCE_ID);
- request.setMsoRequest(msoReq);
- request.setCloudSiteId(CLOUDSITE_ID);
- request.setTenantId(TENANT_ID);
- request.setModelCustomizationUuid(MODEL_CUSTOMIZATION_UUID);
- request.setVnfId(AAI_VNF_ID);
- request.setVnfType(VNF_TYPE);
- request.setVnfVersion(VNF_VERSION);
- request.setVfModuleId(VF_MODULE_ID);
- request.setVfModuleName(VF_MODULE_NAME);
- request.setVfModuleType(VF_MODULE_TYPE);
- request.setBaseVfModuleId(BASE_VF_MODULE_ID);
- request.setFailIfExists(failIfExists);
- request.setEnableBridge(enableBridge);
- request.setVfModuleParams(vfModuleParams);
- request.setMessageId(MESSAGE_ID);
-
- return request;
- }
-
- public static void mockUpdateRequestDb(WireMockServer wireMockServer, String requestId) throws IOException {
- wireMockServer.stubFor(patch(urlPathEqualTo("/infraActiveRequests/" + requestId))
- .willReturn(aResponse().withHeader("Content-Type", "application/json").withStatus(HttpStatus.SC_OK)));
- }
-}
diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/VolumeAdapterRestTest.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/VolumeAdapterRestTest.java
deleted file mode 100644
index c2e2b567f1..0000000000
--- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/VolumeAdapterRestTest.java
+++ /dev/null
@@ -1,194 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 - 2018 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.onap.so.adapters.vnf;
-
-import org.apache.http.HttpStatus;
-import org.junit.Test;
-import org.onap.so.adapters.vnfrest.CreateVolumeGroupRequest;
-import org.onap.so.adapters.vnfrest.CreateVolumeGroupResponse;
-import org.onap.so.adapters.vnfrest.DeleteVolumeGroupRequest;
-import org.onap.so.adapters.vnfrest.DeleteVolumeGroupResponse;
-import org.onap.so.adapters.vnfrest.QueryVolumeGroupResponse;
-import org.onap.so.adapters.vnfrest.RollbackVolumeGroupRequest;
-import org.onap.so.adapters.vnfrest.RollbackVolumeGroupResponse;
-import org.onap.so.adapters.vnfrest.UpdateVolumeGroupRequest;
-import org.onap.so.adapters.vnfrest.UpdateVolumeGroupResponse;
-import org.onap.so.adapters.vnfrest.VolumeGroupExceptionResponse;
-import org.springframework.http.HttpEntity;
-import org.springframework.http.HttpMethod;
-import org.springframework.http.ResponseEntity;
-import javax.ws.rs.core.Response;
-import javax.ws.rs.core.UriBuilder;
-import java.io.IOException;
-import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
-import static com.github.tomakehurst.wiremock.client.WireMock.patch;
-import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo;
-import static org.junit.Assert.assertEquals;
-import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackGetStackVfModule_200;
-import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackGetStackWithBody_200;
-import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackGetStacksWithBody_200;
-import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackPostStacks_200;
-import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackPutStack;
-import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackResponseAccess;
-
-public class VolumeAdapterRestTest extends VolumeGroupAdapterCommon {
-
- @Test
- public void testCreateVNFVolumes() throws IOException {
-
- wireMockServer.stubFor(patch(urlPathEqualTo("/infraActiveRequests/62265093-277d-4388-9ba6-449838ade586"))
- .willReturn(aResponse().withHeader("Content-Type", "application/json").withStatus(HttpStatus.SC_OK)));
-
- mockOpenStackResponseAccess(wireMockServer, wireMockPort);
- mockOpenStackPostStacks_200(wireMockServer);
- mockOpenStackGetStackVfModule_200(wireMockServer);
- CreateVolumeGroupRequest request = buildCreateVfModuleRequest();
-
- HttpEntity<CreateVolumeGroupRequest> entity = new HttpEntity<>(request, headers);
- ResponseEntity<CreateVolumeGroupResponse> response =
- restTemplate.exchange(createURLWithPort("/services/rest/v1/volume-groups"), HttpMethod.POST, entity,
- CreateVolumeGroupResponse.class);
- assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
- }
-
- @Test
- public void testCreateVNFVolumesAsync() throws IOException {
-
- mockOpenStackResponseAccess(wireMockServer, wireMockPort);
- mockOpenStackPostStacks_200(wireMockServer);
- mockOpenStackGetStackVfModule_200(wireMockServer);
- CreateVolumeGroupRequest request = buildCreateVfModuleRequest();
- request.setNotificationUrl("http://localhost:8080");
-
- HttpEntity<CreateVolumeGroupRequest> entity = new HttpEntity<>(request, headers);
- ResponseEntity<CreateVolumeGroupResponse> response =
- restTemplate.exchange(createURLWithPort("/services/rest/v1/volume-groups"), HttpMethod.POST, entity,
- CreateVolumeGroupResponse.class);
- assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
- }
-
- @Test
- public void testDeleteVNFVolumes() throws IOException {
- mockOpenStackResponseAccess(wireMockServer, wireMockPort);
- DeleteVolumeGroupRequest request = buildDeleteVolumeGroupRequest();
- HttpEntity<DeleteVolumeGroupRequest> entity = new HttpEntity<>(request, headers);
- ResponseEntity<DeleteVolumeGroupResponse> response =
- restTemplate.exchange(createURLWithPort("/services/rest/v1/volume-groups/" + VOLUME_GROUP_ID),
- HttpMethod.DELETE, entity, DeleteVolumeGroupResponse.class);
- assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
- }
-
- @Test
- public void testDeleteVNFVolumesAsync() throws IOException {
- mockOpenStackResponseAccess(wireMockServer, wireMockPort);
- DeleteVolumeGroupRequest request = buildDeleteVolumeGroupRequest();
- request.setNotificationUrl("http://localhost:8080");
- HttpEntity<DeleteVolumeGroupRequest> entity = new HttpEntity<>(request, headers);
- ResponseEntity<DeleteVolumeGroupResponse> response =
- restTemplate.exchange(createURLWithPort("/services/rest/v1/volume-groups/" + VOLUME_GROUP_ID),
- HttpMethod.DELETE, entity, DeleteVolumeGroupResponse.class);
- assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
- }
-
- @Test
- public void testRollbackVNFVolumes() throws IOException {
- mockOpenStackResponseAccess(wireMockServer, wireMockPort);
- RollbackVolumeGroupRequest request = buildRollbackVolumeGroupRequest();
- HttpEntity<RollbackVolumeGroupRequest> entity = new HttpEntity<>(request, headers);
- ResponseEntity<RollbackVolumeGroupResponse> response = restTemplate.exchange(
- createURLWithPort("/services/rest/v1/volume-groups/" + VOLUME_GROUP_ID + "/rollback"),
- HttpMethod.DELETE, entity, RollbackVolumeGroupResponse.class);
- assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
- }
-
- @Test
- public void testRollbackVNFVolumesAsync() throws IOException {
- mockOpenStackResponseAccess(wireMockServer, wireMockPort);
- RollbackVolumeGroupRequest request = buildRollbackVolumeGroupRequest();
- request.setNotificationUrl("http://localhost:8080");
- HttpEntity<RollbackVolumeGroupRequest> entity = new HttpEntity<>(request, headers);
- ResponseEntity<RollbackVolumeGroupResponse> response = restTemplate.exchange(
- createURLWithPort("/services/rest/v1/volume-groups/" + VOLUME_GROUP_ID + "/rollback"),
- HttpMethod.DELETE, entity, RollbackVolumeGroupResponse.class);
- assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
- }
-
- @Test
- public void testQueryVNFVolumes() throws IOException {
- mockOpenStackResponseAccess(wireMockServer, wireMockPort);
- mockOpenStackGetStacksWithBody_200(wireMockServer, "UPDATE_COMPLETE");
- javax.ws.rs.core.UriBuilder builder = UriBuilder.fromPath("/services/rest/v1/volume-groups/" + VOLUME_GROUP_ID);
- builder.queryParam("cloudSiteId", CLOUDSITE_ID).queryParam("tenantId", TENANT_ID)
- .queryParam("volumeGroupStackId", VOUME_GROUP_NAME).queryParam("skipAAI", true)
- .queryParam("msoRequest.requestId", MSO_REQUEST_ID)
- .queryParam("msoRequest.serviceInstanceId", MSO_SERVICE_INSTANCE_ID);
-
- ResponseEntity<QueryVolumeGroupResponse> response = restTemplate.exchange(
- createURLWithPort(builder.build().toString()), HttpMethod.GET, null, QueryVolumeGroupResponse.class);
- assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
- }
-
- @Test
- public void testQueryVNFVolumesError() throws IOException {
- mockOpenStackResponseAccess(wireMockServer, wireMockPort);
- mockOpenStackGetStacksWithBody_200(wireMockServer, "UPDATE_COMPLETE");
- javax.ws.rs.core.UriBuilder builder = UriBuilder.fromPath("/services/rest/v1/volume-groups/" + VOLUME_GROUP_ID);
- builder.queryParam("tenantId", TENANT_ID).queryParam("volumeGroupStackId", VOUME_GROUP_NAME)
- .queryParam("skipAAI", true).queryParam("msoRequest.requestId", MSO_REQUEST_ID)
- .queryParam("msoRequest.serviceInstanceId", MSO_SERVICE_INSTANCE_ID);
-
- ResponseEntity<VolumeGroupExceptionResponse> response =
- restTemplate.exchange(createURLWithPort(builder.build().toString()), HttpMethod.GET, null,
- VolumeGroupExceptionResponse.class);
- assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
- }
-
- @Test
- public void testUpdateVNFVolumes() throws IOException {
- mockOpenStackResponseAccess(wireMockServer, wireMockPort);
- mockOpenStackGetStacksWithBody_200(wireMockServer, "CREATE_COMPLETE");
- mockOpenStackPutStack(wireMockServer, VOUME_GROUP_NAME + "/stackId", 200);
- mockOpenStackGetStackWithBody_200(wireMockServer, "UPDATE_COMPLETE");
- UpdateVolumeGroupRequest request = buildUpdateVolumeGroupRequest();
- HttpEntity<UpdateVolumeGroupRequest> entity = new HttpEntity<>(request, headers);
- ResponseEntity<UpdateVolumeGroupResponse> response =
- restTemplate.exchange(createURLWithPort("/services/rest/v1/volume-groups/" + VOLUME_GROUP_ID),
- HttpMethod.PUT, entity, UpdateVolumeGroupResponse.class);
- assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
- }
-
- @Test
- public void testUpdateVNFVolumesAsync() throws IOException {
- mockOpenStackResponseAccess(wireMockServer, wireMockPort);
- mockOpenStackGetStacksWithBody_200(wireMockServer, "CREATE_COMPLETE");
- mockOpenStackPutStack(wireMockServer, VOUME_GROUP_NAME + "/stackId", 200);
- mockOpenStackGetStackWithBody_200(wireMockServer, "UPDATE_COMPLETE");
- UpdateVolumeGroupRequest request = buildUpdateVolumeGroupRequest();
- request.setNotificationUrl("http://localhost:8080");
- HttpEntity<UpdateVolumeGroupRequest> entity = new HttpEntity<>(request, headers);
- ResponseEntity<UpdateVolumeGroupResponse> response =
- restTemplate.exchange(createURLWithPort("/services/rest/v1/volume-groups/" + VOLUME_GROUP_ID),
- HttpMethod.PUT, entity, UpdateVolumeGroupResponse.class);
- assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
- }
-
-
-}
diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/VolumeAdapterRestV2Test.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/VolumeAdapterRestV2Test.java
deleted file mode 100644
index 6fd9f02cfe..0000000000
--- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/VolumeAdapterRestV2Test.java
+++ /dev/null
@@ -1,190 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 - 2018 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.onap.so.adapters.vnf;
-
-import org.apache.http.HttpStatus;
-import org.junit.Test;
-import org.onap.so.adapters.vnfrest.CreateVolumeGroupRequest;
-import org.onap.so.adapters.vnfrest.CreateVolumeGroupResponse;
-import org.onap.so.adapters.vnfrest.DeleteVolumeGroupRequest;
-import org.onap.so.adapters.vnfrest.DeleteVolumeGroupResponse;
-import org.onap.so.adapters.vnfrest.QueryVolumeGroupResponse;
-import org.onap.so.adapters.vnfrest.RollbackVolumeGroupRequest;
-import org.onap.so.adapters.vnfrest.RollbackVolumeGroupResponse;
-import org.onap.so.adapters.vnfrest.UpdateVolumeGroupRequest;
-import org.onap.so.adapters.vnfrest.UpdateVolumeGroupResponse;
-import org.onap.so.adapters.vnfrest.VolumeGroupExceptionResponse;
-import org.springframework.http.HttpEntity;
-import org.springframework.http.HttpMethod;
-import org.springframework.http.ResponseEntity;
-import javax.ws.rs.core.Response;
-import javax.ws.rs.core.UriBuilder;
-import java.io.IOException;
-import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
-import static com.github.tomakehurst.wiremock.client.WireMock.patch;
-import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo;
-import static org.junit.Assert.assertEquals;
-import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackGetStackVfModule_200;
-import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackGetStackWithBody_200;
-import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackGetStacksWithBody_200;
-import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackPostStacks_200;
-import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackPutStack;
-import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackResponseAccess;
-
-public class VolumeAdapterRestV2Test extends VolumeGroupAdapterCommon {
-
- @Test
- public void testCreateVNFVolumes() throws IOException {
- mockOpenStackResponseAccess(wireMockServer, wireMockPort);
- mockOpenStackPostStacks_200(wireMockServer);
- mockOpenStackGetStackVfModule_200(wireMockServer);
- wireMockServer.stubFor(patch(urlPathEqualTo("/infraActiveRequests/62265093-277d-4388-9ba6-449838ade586"))
- .willReturn(aResponse().withHeader("Content-Type", "application/json").withStatus(HttpStatus.SC_OK)));
-
- CreateVolumeGroupRequest request = buildCreateVfModuleRequest();
-
- HttpEntity<CreateVolumeGroupRequest> entity = new HttpEntity<>(request, headers);
- ResponseEntity<CreateVolumeGroupResponse> response =
- restTemplate.exchange(createURLWithPort("/services/rest/v2/volume-groups"), HttpMethod.POST, entity,
- CreateVolumeGroupResponse.class);
- assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
- }
-
- @Test
- public void testCreateVNFVolumesAsync() throws IOException {
-
- mockOpenStackResponseAccess(wireMockServer, wireMockPort);
- mockOpenStackPostStacks_200(wireMockServer);
- mockOpenStackGetStackVfModule_200(wireMockServer);
- CreateVolumeGroupRequest request = buildCreateVfModuleRequest();
- request.setNotificationUrl("http://localhost:8080");
- HttpEntity<CreateVolumeGroupRequest> entity = new HttpEntity<>(request, headers);
- ResponseEntity<CreateVolumeGroupResponse> response =
- restTemplate.exchange(createURLWithPort("/services/rest/v2/volume-groups"), HttpMethod.POST, entity,
- CreateVolumeGroupResponse.class);
- assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
- }
-
- @Test
- public void testDeleteVNFVolumes() throws IOException {
- mockOpenStackResponseAccess(wireMockServer, wireMockPort);
- DeleteVolumeGroupRequest request = buildDeleteVolumeGroupRequest();
- HttpEntity<DeleteVolumeGroupRequest> entity = new HttpEntity<>(request, headers);
- ResponseEntity<DeleteVolumeGroupResponse> response =
- restTemplate.exchange(createURLWithPort("/services/rest/v2/volume-groups/" + VOLUME_GROUP_ID),
- HttpMethod.DELETE, entity, DeleteVolumeGroupResponse.class);
- assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
- }
-
- @Test
- public void testDeleteVNFVolumesAsync() throws IOException {
- mockOpenStackResponseAccess(wireMockServer, wireMockPort);
- DeleteVolumeGroupRequest request = buildDeleteVolumeGroupRequest();
- request.setNotificationUrl("http://localhost:8080");
- HttpEntity<DeleteVolumeGroupRequest> entity = new HttpEntity<>(request, headers);
- ResponseEntity<DeleteVolumeGroupResponse> response =
- restTemplate.exchange(createURLWithPort("/services/rest/v2/volume-groups/" + VOLUME_GROUP_ID),
- HttpMethod.DELETE, entity, DeleteVolumeGroupResponse.class);
- assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
- }
-
- @Test
- public void testRollbackVNFVolumes() throws IOException {
- mockOpenStackResponseAccess(wireMockServer, wireMockPort);
- RollbackVolumeGroupRequest request = buildRollbackVolumeGroupRequest();
- HttpEntity<RollbackVolumeGroupRequest> entity = new HttpEntity<>(request, headers);
- ResponseEntity<RollbackVolumeGroupResponse> response = restTemplate.exchange(
- createURLWithPort("/services/rest/v2/volume-groups/" + VOLUME_GROUP_ID + "/rollback"),
- HttpMethod.DELETE, entity, RollbackVolumeGroupResponse.class);
- assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
- }
-
- @Test
- public void testRollbackVNFVolumesAsync() throws IOException {
- mockOpenStackResponseAccess(wireMockServer, wireMockPort);
- RollbackVolumeGroupRequest request = buildRollbackVolumeGroupRequest();
- request.setNotificationUrl("http://localhost:8080");
- HttpEntity<RollbackVolumeGroupRequest> entity = new HttpEntity<>(request, headers);
- ResponseEntity<RollbackVolumeGroupResponse> response = restTemplate.exchange(
- createURLWithPort("/services/rest/v2/volume-groups/" + VOLUME_GROUP_ID + "/rollback"),
- HttpMethod.DELETE, entity, RollbackVolumeGroupResponse.class);
- assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
- }
-
- @Test
- public void testQueryVNFVolumes() throws IOException {
- mockOpenStackResponseAccess(wireMockServer, wireMockPort);
- mockOpenStackGetStacksWithBody_200(wireMockServer, "UPDATE_COMPLETE");
- javax.ws.rs.core.UriBuilder builder = UriBuilder.fromPath("/services/rest/v2/volume-groups/" + VOLUME_GROUP_ID);
- builder.queryParam("cloudSiteId", CLOUDSITE_ID).queryParam("tenantId", TENANT_ID)
- .queryParam("volumeGroupStackId", VOUME_GROUP_NAME).queryParam("skipAAI", true)
- .queryParam("msoRequest.requestId", MSO_REQUEST_ID)
- .queryParam("msoRequest.serviceInstanceId", MSO_SERVICE_INSTANCE_ID);
-
- ResponseEntity<QueryVolumeGroupResponse> response = restTemplate.exchange(
- createURLWithPort(builder.build().toString()), HttpMethod.GET, null, QueryVolumeGroupResponse.class);
- assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
- }
-
- @Test
- public void testQueryVNFVolumesError() throws IOException {
- mockOpenStackResponseAccess(wireMockServer, wireMockPort);
- mockOpenStackGetStacksWithBody_200(wireMockServer, "UPDATE_COMPLETE");
- javax.ws.rs.core.UriBuilder builder = UriBuilder.fromPath("/services/rest/v2/volume-groups/" + VOLUME_GROUP_ID);
- builder.queryParam("tenantId", TENANT_ID).queryParam("volumeGroupStackId", VOUME_GROUP_NAME)
- .queryParam("skipAAI", true).queryParam("msoRequest.requestId", MSO_REQUEST_ID)
- .queryParam("msoRequest.serviceInstanceId", MSO_SERVICE_INSTANCE_ID);
-
- ResponseEntity<VolumeGroupExceptionResponse> response =
- restTemplate.exchange(createURLWithPort(builder.build().toString()), HttpMethod.GET, null,
- VolumeGroupExceptionResponse.class);
- assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
- }
-
- @Test
- public void testUpdateVNFVolumes() throws IOException {
- mockOpenStackResponseAccess(wireMockServer, wireMockPort);
- mockOpenStackGetStacksWithBody_200(wireMockServer, "CREATE_COMPLETE");
- mockOpenStackPutStack(wireMockServer, VOUME_GROUP_NAME + "/stackId", 200);
- mockOpenStackGetStackWithBody_200(wireMockServer, "UPDATE_COMPLETE");
- UpdateVolumeGroupRequest request = buildUpdateVolumeGroupRequest();
- HttpEntity<UpdateVolumeGroupRequest> entity = new HttpEntity<>(request, headers);
- ResponseEntity<UpdateVolumeGroupResponse> response =
- restTemplate.exchange(createURLWithPort("/services/rest/v2/volume-groups/" + VOLUME_GROUP_ID),
- HttpMethod.PUT, entity, UpdateVolumeGroupResponse.class);
- assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
- }
-
- @Test
- public void testUpdateVNFVolumesAsync() throws IOException {
- mockOpenStackResponseAccess(wireMockServer, wireMockPort);
- mockOpenStackGetStacksWithBody_200(wireMockServer, "CREATE_COMPLETE");
- mockOpenStackPutStack(wireMockServer, VOUME_GROUP_NAME + "/stackId", 200);
- mockOpenStackGetStackWithBody_200(wireMockServer, "UPDATE_COMPLETE");
- UpdateVolumeGroupRequest request = buildUpdateVolumeGroupRequest();
- request.setNotificationUrl("http://localhost:8080");
- HttpEntity<UpdateVolumeGroupRequest> entity = new HttpEntity<>(request, headers);
- ResponseEntity<UpdateVolumeGroupResponse> response =
- restTemplate.exchange(createURLWithPort("/services/rest/v2/volume-groups/" + VOLUME_GROUP_ID),
- HttpMethod.PUT, entity, UpdateVolumeGroupResponse.class);
- assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
- }
-}
diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/VolumeGroupAdapterCommon.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/VolumeGroupAdapterCommon.java
deleted file mode 100644
index 14fa1df6c9..0000000000
--- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/VolumeGroupAdapterCommon.java
+++ /dev/null
@@ -1,129 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 - 2018 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.onap.so.adapters.vnf;
-
-import org.onap.so.adapters.vnfrest.CreateVolumeGroupRequest;
-import org.onap.so.adapters.vnfrest.DeleteVolumeGroupRequest;
-import org.onap.so.adapters.vnfrest.RollbackVolumeGroupRequest;
-import org.onap.so.adapters.vnfrest.UpdateVolumeGroupRequest;
-import org.onap.so.adapters.vnfrest.VolumeGroupRollback;
-import org.onap.so.entity.MsoRequest;
-import java.util.HashMap;
-import java.util.Map;
-
-public class VolumeGroupAdapterCommon extends BaseRestTestUtils {
-
-
-
- protected static final String MSO_REQUEST_ID = "62265093-277d-4388-9ba6-449838ade586";
- protected static final String MSO_SERVICE_INSTANCE_ID = "4147e06f-1b89-49c5-b21f-4faf8dc9805a";
- protected static final String CLOUDSITE_ID = "mtn13";
- protected static final String TENANT_ID = "0422ffb57ba042c0800a29dc85ca70f8";
- protected static final String VOUME_GROUP_NAME = "DEV-VF-1802-it3-pwt3-v6-vSAMP10a-addon2-Replace-1001";
- protected static final String VOLUME_GROUP_ID = "0422ffb57ba042c0800a29dc85ca70v1";
- protected static final String VNF_TYPE = "TestVnfType";
- protected static final String VNF_VERSION = "1.0";
- protected static final String VF_MODULE_TYPE = "TestModule-0";
- protected static final String MODEL_CUSTOMIZATION_UUID = "9b339a61-69ca-465f-86b8-1c72c582b8e8";
-
- protected UpdateVolumeGroupRequest buildUpdateVolumeGroupRequest() {
- UpdateVolumeGroupRequest request = new UpdateVolumeGroupRequest();
- request.setCloudSiteId(CLOUDSITE_ID);
- request.setTenantId(TENANT_ID);
- request.setVolumeGroupId(VOLUME_GROUP_ID);
- request.setVnfType(VNF_TYPE);
- request.setVnfVersion(VNF_VERSION);
- request.setVfModuleType(VF_MODULE_TYPE);
- request.setModelCustomizationUuid(MODEL_CUSTOMIZATION_UUID);
- request.setSkipAAI(true);
- request.setVolumeGroupStackId(VOUME_GROUP_NAME);
- Map<String, Object> volumeGroupParams = getVolumeGroupParamsMap();
- request.setVolumeGroupParams(volumeGroupParams);
- MsoRequest msoReq = getMsoRequest();
- request.setMsoRequest(msoReq);
- return request;
- }
-
- protected RollbackVolumeGroupRequest buildRollbackVolumeGroupRequest() {
- RollbackVolumeGroupRequest request = new RollbackVolumeGroupRequest();
- VolumeGroupRollback volumeGroupRollback = new VolumeGroupRollback();
- volumeGroupRollback.setCloudSiteId(CLOUDSITE_ID);
- volumeGroupRollback.setMessageId(MSO_REQUEST_ID);
- volumeGroupRollback.setTenantId(TENANT_ID);
- MsoRequest msoReq = getMsoRequest();
- volumeGroupRollback.setVolumeGroupCreated(true);
- volumeGroupRollback.setVolumeGroupId(VOLUME_GROUP_ID);
- volumeGroupRollback.setVolumeGroupStackId(VOLUME_GROUP_ID);
- volumeGroupRollback.setMsoRequest(msoReq);
- request.setVolumeGroupRollback(volumeGroupRollback);
- return request;
- }
-
- protected DeleteVolumeGroupRequest buildDeleteVolumeGroupRequest() {
- DeleteVolumeGroupRequest request = new DeleteVolumeGroupRequest();
- request.setCloudSiteId(CLOUDSITE_ID);
- request.setTenantId(TENANT_ID);
- request.setVolumeGroupStackId("testStackId");
- request.setVolumeGroupId(VOLUME_GROUP_ID);
- MsoRequest msoReq = getMsoRequest();
- request.setMsoRequest(msoReq);
- return request;
- }
-
- protected CreateVolumeGroupRequest buildCreateVfModuleRequest() {
- CreateVolumeGroupRequest request = new CreateVolumeGroupRequest();
- request.setCloudSiteId(CLOUDSITE_ID);
- request.setTenantId(TENANT_ID);
- request.setVolumeGroupName(VOUME_GROUP_NAME);
- request.setVolumeGroupId(VOLUME_GROUP_ID);
- request.setVnfType(VNF_TYPE);
- request.setVnfVersion(VNF_VERSION);
- request.setVfModuleType(VF_MODULE_TYPE);
- request.setModelCustomizationUuid(MODEL_CUSTOMIZATION_UUID);
- request.setSkipAAI(true);
- request.setFailIfExists(false);
- request.setFailIfExists(true);
- request.setEnableBridge(false);
- request.setSuppressBackout(true);
- Map<String, Object> volumeGroupParams = getVolumeGroupParamsMap();
- request.setVolumeGroupParams(volumeGroupParams);
- MsoRequest msoReq = getMsoRequest();
- request.setMsoRequest(msoReq);
-
- return request;
- }
-
- private Map<String, Object> getVolumeGroupParamsMap() {
- Map<String, Object> volumeGroupParams = new HashMap<>();
- volumeGroupParams.put("fsb_volume_type_0", "volume_type");
- volumeGroupParams.put("fsb_volume_image_name_1", "vol_img_1");
- volumeGroupParams.put("fsb_volume_image_name_0", "vol_img_0");
- volumeGroupParams.put("fsb_volume_size_0", "100");
- return volumeGroupParams;
- }
-
- private MsoRequest getMsoRequest() {
- MsoRequest msoReq = new MsoRequest();
- msoReq.setRequestId(MSO_REQUEST_ID);
- msoReq.setServiceInstanceId(MSO_SERVICE_INSTANCE_ID);
- return msoReq;
- }
-}