2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. 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;
24 import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
25 import static com.github.tomakehurst.wiremock.client.WireMock.containing;
26 import static com.github.tomakehurst.wiremock.client.WireMock.post;
27 import static com.github.tomakehurst.wiremock.client.WireMock.postRequestedFor;
28 import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo;
29 import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo;
30 import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackGetStackVfModule_200;
31 import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackResponseAccess;
32 import java.util.HashMap;
33 import org.apache.http.HttpStatus;
34 import org.junit.Rule;
35 import org.junit.Test;
36 import org.junit.rules.ExpectedException;
37 import org.onap.so.entity.MsoRequest;
38 import org.springframework.beans.factory.annotation.Autowired;
40 public class MsoVnfAdapterAsyncImplTest extends BaseRestTestUtils {
43 MsoVnfAdapterAsyncImpl instance;
46 public ExpectedException expectedException = ExpectedException.none();
49 public void healthCheckVNFTest() {
50 instance.healthCheckA();
54 public void createVNFTest() throws Exception {
55 MsoRequest msoRequest = new MsoRequest();
56 msoRequest.setRequestId("12345");
57 msoRequest.setServiceInstanceId("12345");
59 mockOpenStackResponseAccess(wireMockServer, wireMockPort);
60 mockOpenStackGetStackVfModule_200(wireMockServer);
61 wireMockServer.stubFor(post(urlPathEqualTo("/notify/adapterNotify/updateVnfNotificationRequest"))
62 .withRequestBody(containing("messageId")).willReturn(aResponse().withStatus(HttpStatus.SC_OK)));
64 String vnfName = "DEV-VF-1802-it3-pwt3-v6-vSAMP10a-addon2-Replace-1001/stackId";
65 String notificationUrl =
66 "http://localhost:" + wireMockPort + "/notify/adapterNotify/updateVnfNotificationRequest";
67 instance.createVnfA("mtn13", "CloudOwner", "88a6ca3ee0394ade9403f075db23167e", "vnf", "1", vnfName, "VFMOD",
68 "volumeGroupHeatStackId|1", new HashMap<String, Object>(), Boolean.FALSE, Boolean.TRUE, Boolean.FALSE,
69 "messageId", msoRequest, notificationUrl);
71 wireMockServer.verify(1, postRequestedFor(urlEqualTo("/notify/adapterNotify/updateVnfNotificationRequest")));
75 public void createVNFTest_Exception() throws Exception {
76 String notificationUrl =
77 "http://localhost:" + wireMockPort + "/notify/adapterNotify/updateVnfNotificationRequest";
78 instance.createVnfA("mdt1", "CloudOwner", "88a6ca3ee0394ade9403f075db23167e", "vnf", "1", "vSAMP12", "VFMOD",
79 "volumeGroupHeatStackId|1", new HashMap<String, Object>(), Boolean.FALSE, Boolean.TRUE, Boolean.FALSE,
80 "messageId", null, notificationUrl);
82 wireMockServer.verify(1, postRequestedFor(urlEqualTo("/notify/adapterNotify/updateVnfNotificationRequest")));
87 public void deleteVnfTest() {
88 MsoRequest msoRequest = new MsoRequest();
89 msoRequest.setRequestId("12345");
90 msoRequest.setServiceInstanceId("12345");
91 instance.deleteVnfA("mdt1", "CloudOwner", "88a6ca3ee0394ade9403f075db23167e", "vSAMP12", "messageId",
92 msoRequest, "http://org.onap.so/notify/adapterNotify/updateVnfNotificationRequest");