aboutsummaryrefslogtreecommitdiffstats
path: root/adapters/mso-adapter-utils/src/test
diff options
context:
space:
mode:
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.java38
1 files changed, 32 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 41cb7746c0..e066c4eec6 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
@@ -36,6 +36,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 +68,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());
}
@@ -143,7 +169,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(),
@@ -158,7 +184,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(),