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 org.apache.http.HttpStatus;
24 import org.junit.Assert;
25 import org.junit.Before;
26 import org.junit.Rule;
27 import org.junit.Test;
28 import org.junit.rules.ExpectedException;
29 import org.onap.so.adapters.openstack.MsoOpenstackAdaptersApplication;
30 import org.onap.so.adapters.vnf.exceptions.VnfException;
31 import org.onap.so.cloud.CloudConfig;
32 import org.onap.so.db.catalog.beans.CloudSite;
33 import org.onap.so.entity.MsoRequest;
34 import org.springframework.beans.factory.annotation.Autowired;
35 import org.springframework.boot.web.server.LocalServerPort;
37 import javax.xml.ws.Holder;
38 import java.util.HashMap;
41 import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
42 import static com.github.tomakehurst.wiremock.client.WireMock.delete;
43 import static com.github.tomakehurst.wiremock.client.WireMock.get;
44 import static com.github.tomakehurst.wiremock.client.WireMock.post;
45 import static com.github.tomakehurst.wiremock.client.WireMock.stubFor;
46 import static com.github.tomakehurst.wiremock.client.WireMock.urlMatching;
47 import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo;
49 public class MsoVnfMulticloudAdapterImplTest extends BaseRestTestUtils{
51 public ExpectedException expectedException = ExpectedException.none();
54 private MsoVnfPluginAdapterImpl instance;
57 private CloudConfig cloudConfig;
60 public void before() throws Exception {
61 super.orchestrator = "multicloud";
62 super.cloudEndpoint = "/api/multicloud/v1/cloud_owner/cloud_region_id/infra_workload";
67 public void createVfModule() throws Exception {
69 Map<String, Object> stackInputs = new HashMap<>();
70 stackInputs.put("oof_directives", "{}");
71 stackInputs.put("sdnc_directives", "{}");
72 stackInputs.put("generic_vnf_id", "genVNFID");
73 stackInputs.put("vf_module_id", "vfMODULEID");
75 MsoRequest msoRequest = new MsoRequest();
76 msoRequest.setRequestId("12345");
77 msoRequest.setServiceInstanceId("12345");
79 stubFor(get(urlPathEqualTo("/api/multicloud/v1/cloud_owner/cloud_region_id/infra_workload/vfname")).willReturn(aResponse()
81 .withStatus(HttpStatus.SC_NOT_FOUND)));
83 stubFor(get(urlPathEqualTo("/api/multicloud/v1/cloud_owner/cloud_region_id/infra_workload/workload-id")).willReturn(aResponse()
85 .withBodyFile("MulticloudResponse_Stack.json")
86 .withStatus(HttpStatus.SC_OK)));
88 stubFor(get(urlPathEqualTo("/api/multicloud/v1/cloud_owner/cloud_region_id/infra_workload/vfname/outputs")).willReturn(aResponse()
89 .withStatus(HttpStatus.SC_NOT_FOUND)));
91 stubFor(post(urlPathEqualTo("/api/multicloud/v1/cloud_owner/cloud_region_id/infra_workload")).willReturn(aResponse()
92 .withBodyFile("MulticloudResponse_Stack_Create.json")
93 .withStatus(HttpStatus.SC_CREATED)));
95 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<>());
99 public void deleteVfModule() throws Exception {
100 MsoRequest msoRequest = new MsoRequest();
101 msoRequest.setRequestId("12345");
102 msoRequest.setServiceInstanceId("12345");
104 stubFor(get(urlPathEqualTo("/api/multicloud/v1/cloud_owner/cloud_region_id/infra_workload/workload-id")).willReturn(aResponse()
105 .withBodyFile("MulticloudResponse_Stack.json")
106 .withStatus(HttpStatus.SC_OK)));
108 stubFor(delete(urlPathEqualTo("/api/multicloud/v1/cloud_owner/cloud_region_id/infra_workload/workload-id")).willReturn(aResponse()
109 .withStatus(HttpStatus.SC_NO_CONTENT)));
111 instance.deleteVfModule("MTN13", "CloudOwner", "123", "workload-id", msoRequest, new Holder<>());
115 public void queryVfModule() throws Exception {
116 MsoRequest msoRequest = new MsoRequest();
117 msoRequest.setRequestId("12345");
118 msoRequest.setServiceInstanceId("12345");
120 stubFor(get(urlPathEqualTo("/api/multicloud/v1/cloud_owner/cloud_region_id/infra_workload/workload-id")).willReturn(aResponse()
121 .withBodyFile("MulticloudResponse_Stack.json")
122 .withStatus(HttpStatus.SC_OK)));
124 instance.queryVnf("MTN13", "CloudOwner", "123", "workload-id", msoRequest, new Holder<>(), new Holder<>(), new Holder<>(), new Holder<>());