summaryrefslogtreecommitdiffstats
path: root/adapters/mso-adapter-utils/src/test
diff options
context:
space:
mode:
authorEric Multanen <eric.w.multanen@intel.com>2019-04-04 01:56:42 -0700
committerMarcus Williams <marcus.williams@intel.com>2019-04-04 20:20:04 +0000
commitbd1d892b2334c5f4b23022763b0c316224494637 (patch)
tree73b426bbda5d26787eaa65a0d8ed2a1d4e411c96 /adapters/mso-adapter-utils/src/test
parentf81920304c7b62637d32473e672a1e51275ce54b (diff)
Call multicloud aai update from mc vnf plugin
After successful vfmodule create, invoke the multicloud api to trigger update in aai. Change-Id: I3f6ceee7a8ea5f907fefcbe1a57ba35b9a666cb1 Issue-ID: SO-1444 Signed-off-by: Eric Multanen <eric.w.multanen@intel.com>
Diffstat (limited to 'adapters/mso-adapter-utils/src/test')
-rw-r--r--adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoMulticloudUtilsTest.java39
1 files changed, 33 insertions, 6 deletions
diff --git a/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoMulticloudUtilsTest.java b/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoMulticloudUtilsTest.java
index fbe532d1fe..669e47f94d 100644
--- a/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoMulticloudUtilsTest.java
+++ b/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoMulticloudUtilsTest.java
@@ -23,6 +23,7 @@
package org.onap.so.openstack.utils;
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.post;
import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo;
import static org.junit.Assert.assertEquals;
@@ -36,6 +37,7 @@ import java.util.HashMap;
import java.util.Optional;
import org.apache.http.HttpStatus;
+import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import org.mockito.InjectMocks;
@@ -67,18 +69,43 @@ public class MsoMulticloudUtilsTest extends BaseTest {
private static final String CREATE_STACK_RESPONSE = "{\"template_type\": \"TEST-template\", \"workload_id\": "
+ "\"TEST-workload\", \"template_response\": {\"stack\": {\"id\": \"TEST-stack\", \"links\": []}}}";
+ private static final String UPDATE_STACK_RESPONSE = "{\"template_type\": \"TEST-template\", \"workload_id\": "
+ + "\"TEST-workload\"}";
+ private static final String GET_CREATE_STACK_RESPONSE = "{\"template_type\": \"TEST-template\", \"workload_id\": "
+ + "\"TEST-workload\", \"workload_status\": \"CREATE_COMPLETE\"}";
+ private static final String GET_UPDATE_STACK_RESPONSE = "{\"template_type\": \"TEST-template\", \"workload_id\": "
+ + "\"TEST-workload\", \"workload_status\": \"UPDATE_COMPLETE\"}";
- private static final String MULTICLOUD_PATH = "/api/multicloud/v1/CloudOwner/MTN14/infra_workload";
+ private static final String MULTICLOUD_CREATE_PATH = "/api/multicloud/v1/CloudOwner/MTN14/infra_workload";
+ private static final String MULTICLOUD_UPDATE_PATH = "/api/multicloud/v1/CloudOwner/MTN14/infra_workload/TEST-workload";
+ private static final String MULTICLOUD_GET_PATH = "/api/multicloud/v1/CloudOwner/MTN14/infra_workload/TEST-workload";
@Test
public void createStackSuccess() throws MsoException, IOException {
- wireMockServer.stubFor(post(urlPathEqualTo(MULTICLOUD_PATH))
+ wireMockServer.stubFor(post(urlPathEqualTo(MULTICLOUD_CREATE_PATH)).inScenario("CREATE")
.willReturn(aResponse().withHeader("Content-Type", "application/json")
.withBody(CREATE_STACK_RESPONSE)
- .withStatus(HttpStatus.SC_CREATED)));
+ .withStatus(HttpStatus.SC_CREATED))
+ .willSetStateTo("CREATING"));
+ wireMockServer.stubFor(get(urlPathEqualTo(MULTICLOUD_GET_PATH))
+ .inScenario("CREATE").whenScenarioStateIs("CREATING")
+ .willReturn(aResponse().withHeader("Content-Type", "application/json")
+ .withBody(GET_CREATE_STACK_RESPONSE)
+ .withStatus(HttpStatus.SC_OK)));
+ 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"));
+ wireMockServer.stubFor(get(urlPathEqualTo(MULTICLOUD_GET_PATH))
+ .inScenario("CREATE").whenScenarioStateIs("UPDATING")
+ .willReturn(aResponse().withHeader("Content-Type", "application/json")
+ .withBody(GET_UPDATE_STACK_RESPONSE)
+ .withStatus(HttpStatus.SC_OK)));
StackInfo result = multicloudUtils.createStack("MTN14", "CloudOwner", "TEST-tenant", "TEST-stack", new VduModelInfo(),
- "TEST-heat", new HashMap<>(), false, 200, "TEST-env",
+ "TEST-heat", new HashMap<>(), true, 200, "TEST-env",
new HashMap<>(), new HashMap<>(), false);
+ wireMockServer.resetScenarios();
assertNotNull(result);
assertEquals("TEST-stack", result.getName());
}
@@ -131,7 +158,7 @@ public class MsoMulticloudUtilsTest extends BaseTest {
@Test
public void createStackBadRequest() {
try {
- wireMockServer.stubFor(post(urlPathEqualTo(MULTICLOUD_PATH))
+ wireMockServer.stubFor(post(urlPathEqualTo(MULTICLOUD_CREATE_PATH))
.willReturn(aResponse().withHeader("Content-Type", "application/json")
.withStatus(HttpStatus.SC_BAD_REQUEST)));
multicloudUtils.createStack("MTN14", "CloudOwner", "TEST-tenant", "TEST-stack", new VduModelInfo(),
@@ -146,7 +173,7 @@ public class MsoMulticloudUtilsTest extends BaseTest {
@Test
public void createStackEmptyResponseEntity() throws MsoException {
- wireMockServer.stubFor(post(urlPathEqualTo(MULTICLOUD_PATH))
+ wireMockServer.stubFor(post(urlPathEqualTo(MULTICLOUD_CREATE_PATH))
.willReturn(aResponse().withHeader("Content-Type", "application/json")
.withStatus(HttpStatus.SC_CREATED)));
StackInfo result = multicloudUtils.createStack("MTN14", "CloudOwner", "TEST-tenant", "TEST-stack", new VduModelInfo(),