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.context.embedded.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 {
68 //expectedException.expect(VnfException.class);
69 Map<String, String> stackInputs = new HashMap<>();
70 stackInputs.put("oof_directives", "{oofDIRECTIVES}");
71 stackInputs.put("sdnc_directives", "{sdncDIRECTIVES}");
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/vfname/outputs")).willReturn(aResponse()
84 .withStatus(HttpStatus.SC_NOT_FOUND)));
86 stubFor(post(urlPathEqualTo("/api/multicloud/v1/cloud_owner/cloud_region_id/infra_workload")).willReturn(aResponse()
87 .withBodyFile("MulticloudResponse_Stack_Create.json")
88 .withStatus(HttpStatus.SC_CREATED)));
90 instance.createVfModule("MTN13", "123", "vf", "v1", "vfname", "create", null, "234", "9b339a61-69ca-465f-86b8-1c72c582b8e8", stackInputs, true, true, true, msoRequest, new Holder<>(), new Holder<>(), new Holder<>());
94 public void deleteVfModule() throws Exception {
95 MsoRequest msoRequest = new MsoRequest();
96 msoRequest.setRequestId("12345");
97 msoRequest.setServiceInstanceId("12345");
99 stubFor(get(urlPathEqualTo("/api/multicloud/v1/cloud_owner/cloud_region_id/infra_workload/workload-id")).willReturn(aResponse()
100 .withBodyFile("MulticloudResponse_Stack.json")
101 .withStatus(HttpStatus.SC_OK)));
103 stubFor(delete(urlPathEqualTo("/api/multicloud/v1/cloud_owner/cloud_region_id/infra_workload/workload-id")).willReturn(aResponse()
104 .withStatus(HttpStatus.SC_NO_CONTENT)));
106 instance.deleteVfModule("MTN13", "123", "workload-id", msoRequest, new Holder<>());
110 public void queryVfModule() throws Exception {
111 MsoRequest msoRequest = new MsoRequest();
112 msoRequest.setRequestId("12345");
113 msoRequest.setServiceInstanceId("12345");
115 stubFor(get(urlPathEqualTo("/api/multicloud/v1/cloud_owner/cloud_region_id/infra_workload/workload-id")).willReturn(aResponse()
116 .withBodyFile("MulticloudResponse_Stack.json")
117 .withStatus(HttpStatus.SC_OK)));
119 instance.queryVnf("MTN13", "123", "workload-id", msoRequest, new Holder<>(), new Holder<>(), new Holder<>(), new Holder<>());