diff options
author | Eric Multanen <eric.w.multanen@intel.com> | 2019-05-01 23:07:07 -0700 |
---|---|---|
committer | Eric Multanen <eric.w.multanen@intel.com> | 2019-05-01 23:11:13 -0700 |
commit | 3d74a5add7424aa490f70e2a4453048028f5d882 (patch) | |
tree | bbfbdfdceb83c14bed193b258442d149c39d46e5 /adapters/mso-openstack-adapters/src | |
parent | 5e1bc9f09bec49b57bde13a1c96158eb2b8290da (diff) |
Fixup handling of multicloud post response
Make the handling of the multicloud post response
more flexible. Add additional parameters that may
come back.
Change-Id: I0a5c7016f11dbfe832c81e2fcafc398a998b622b
Issue-ID: SO-1833
Signed-off-by: Eric Multanen <eric.w.multanen@intel.com>
Diffstat (limited to 'adapters/mso-openstack-adapters/src')
2 files changed, 60 insertions, 2 deletions
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 index 5f2057524f..48ca0fd79c 100644 --- 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 @@ -55,8 +55,6 @@ public class MsoVnfMulticloudAdapterImplTest extends BaseRestTestUtils { @Autowired private CloudConfig cloudConfig; - private static final String CREATE_STACK_RESPONSE = "{\"template_type\": \"TEST-template\", \"workload_id\": " - + "\"workload-id\", \"template_response\": {\"stack\": {\"id\": \"TEST-stack\", \"links\": []}}}"; 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\": " @@ -125,6 +123,51 @@ public class MsoVnfMulticloudAdapterImplTest extends BaseRestTestUtils { } @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<>(); diff --git a/adapters/mso-openstack-adapters/src/test/resources/__files/MulticloudResponse_Stack_Create2.json b/adapters/mso-openstack-adapters/src/test/resources/__files/MulticloudResponse_Stack_Create2.json new file mode 100644 index 0000000000..8532fae97c --- /dev/null +++ b/adapters/mso-openstack-adapters/src/test/resources/__files/MulticloudResponse_Stack_Create2.json @@ -0,0 +1,15 @@ +{ + "template_type": "HEAT", + "workload_id": "workload-id", + "workload_status_reason": + { + "id": "workload-id", + "links": [ + { + "href": "http://localhost:1234/v1/id12345678/stacks/workload-id/abcdef00-1234-abcd-5678-ef9123456789", + "rel": "self" + } + ] + }, + "workload_status": "CREATE_IN_PROGRESS" +} |