2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2018 Intel Corp. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
21 package org.onap.so.adapters.vnf;
23 import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
24 import static com.github.tomakehurst.wiremock.client.WireMock.delete;
25 import static com.github.tomakehurst.wiremock.client.WireMock.get;
26 import static com.github.tomakehurst.wiremock.client.WireMock.post;
27 import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo;
29 import java.util.HashMap;
32 import javax.xml.ws.Holder;
34 import org.apache.http.HttpStatus;
35 import org.junit.Before;
36 import org.junit.Rule;
37 import org.junit.Test;
38 import org.junit.rules.ExpectedException;
39 import org.onap.so.cloud.CloudConfig;
40 import org.onap.so.entity.MsoRequest;
41 import org.springframework.beans.factory.annotation.Autowired;
43 public class MsoVnfMulticloudAdapterImplTest extends BaseRestTestUtils{
45 public ExpectedException expectedException = ExpectedException.none();
48 private MsoVnfPluginAdapterImpl instance;
51 private CloudConfig cloudConfig;
54 public void before() throws Exception {
55 super.orchestrator = "multicloud";
56 super.cloudEndpoint = "/api/multicloud/v1/cloud_owner/cloud_region_id/infra_workload";
61 public void createVfModule() throws Exception {
63 Map<String, Object> stackInputs = new HashMap<>();
64 stackInputs.put("oof_directives", "{}");
65 stackInputs.put("sdnc_directives", "{}");
66 stackInputs.put("generic_vnf_id", "genVNFID");
67 stackInputs.put("vf_module_id", "vfMODULEID");
69 MsoRequest msoRequest = new MsoRequest();
70 msoRequest.setRequestId("12345");
71 msoRequest.setServiceInstanceId("12345");
73 wireMockServer.stubFor(get(urlPathEqualTo("/api/multicloud/v1/cloud_owner/cloud_region_id/infra_workload/vfname")).willReturn(aResponse()
75 .withStatus(HttpStatus.SC_NOT_FOUND)));
77 wireMockServer.stubFor(get(urlPathEqualTo("/api/multicloud/v1/cloud_owner/cloud_region_id/infra_workload/workload-id")).willReturn(aResponse()
79 .withBodyFile("MulticloudResponse_Stack.json")
80 .withStatus(HttpStatus.SC_OK)));
82 wireMockServer.stubFor(get(urlPathEqualTo("/api/multicloud/v1/cloud_owner/cloud_region_id/infra_workload/vfname/outputs")).willReturn(aResponse()
83 .withStatus(HttpStatus.SC_NOT_FOUND)));
85 wireMockServer.stubFor(post(urlPathEqualTo("/api/multicloud/v1/cloud_owner/cloud_region_id/infra_workload")).willReturn(aResponse()
86 .withBodyFile("MulticloudResponse_Stack_Create.json")
87 .withStatus(HttpStatus.SC_CREATED)));
89 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<>());
93 public void deleteVfModule() throws Exception {
94 MsoRequest msoRequest = new MsoRequest();
95 msoRequest.setRequestId("12345");
96 msoRequest.setServiceInstanceId("12345");
98 wireMockServer.stubFor(get(urlPathEqualTo("/api/multicloud/v1/cloud_owner/cloud_region_id/infra_workload/workload-id")).willReturn(aResponse()
99 .withBodyFile("MulticloudResponse_Stack.json")
100 .withStatus(HttpStatus.SC_OK)));
102 wireMockServer.stubFor(delete(urlPathEqualTo("/api/multicloud/v1/cloud_owner/cloud_region_id/infra_workload/workload-id")).willReturn(aResponse()
103 .withStatus(HttpStatus.SC_NO_CONTENT)));
105 instance.deleteVfModule("MTN13", "CloudOwner", "123", "workload-id", msoRequest, new Holder<>());
109 public void queryVfModule() throws Exception {
110 MsoRequest msoRequest = new MsoRequest();
111 msoRequest.setRequestId("12345");
112 msoRequest.setServiceInstanceId("12345");
114 wireMockServer.stubFor(get(urlPathEqualTo("/api/multicloud/v1/cloud_owner/cloud_region_id/infra_workload/workload-id")).willReturn(aResponse()
115 .withBodyFile("MulticloudResponse_Stack.json")
116 .withStatus(HttpStatus.SC_OK)));
118 instance.queryVnf("MTN13", "CloudOwner", "123", "workload-id", msoRequest, new Holder<>(), new Holder<>(), new Holder<>(), new Holder<>());