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;
39 import static org.junit.Assert.assertNotNull;
41 public class MsoVnfAdapterAsyncImplTest extends BaseRestTestUtils {
44 MsoVnfAdapterAsyncImpl instance;
47 public ExpectedException expectedException = ExpectedException.none();
50 public void healthCheckVNFTest() {
51 instance.healthCheckA();
55 public void createVNFTest() throws Exception {
56 MsoRequest msoRequest = new MsoRequest();
57 msoRequest.setRequestId("12345");
58 msoRequest.setServiceInstanceId("12345");
60 mockOpenStackResponseAccess(wireMockServer, wireMockPort);
61 mockOpenStackGetStackVfModule_200(wireMockServer);
62 wireMockServer.stubFor(post(urlPathEqualTo("/notify/adapterNotify/updateVnfNotificationRequest"))
63 .withRequestBody(containing("messageId")).willReturn(aResponse().withStatus(HttpStatus.SC_OK)));
65 String vnfName = "DEV-VF-1802-it3-pwt3-v6-vSAMP10a-addon2-Replace-1001/stackId";
66 String notificationUrl =
67 "http://localhost:" + wireMockPort + "/notify/adapterNotify/updateVnfNotificationRequest";
68 instance.createVnfA("mtn13", "CloudOwner", "88a6ca3ee0394ade9403f075db23167e", "vnf", "1", vnfName, "VFMOD",
69 "volumeGroupHeatStackId|1", new HashMap<String, Object>(), Boolean.FALSE, Boolean.TRUE, Boolean.FALSE,
70 "messageId", msoRequest, notificationUrl);
72 wireMockServer.verify(1, postRequestedFor(urlEqualTo("/notify/adapterNotify/updateVnfNotificationRequest")));
76 public void createVNFTest_Exception() throws Exception {
77 String notificationUrl =
78 "http://localhost:" + wireMockPort + "/notify/adapterNotify/updateVnfNotificationRequest";
79 instance.createVnfA("mdt1", "CloudOwner", "88a6ca3ee0394ade9403f075db23167e", "vnf", "1", "vSAMP12", "VFMOD",
80 "volumeGroupHeatStackId|1", new HashMap<String, Object>(), Boolean.FALSE, Boolean.TRUE, Boolean.FALSE,
81 "messageId", null, notificationUrl);
83 wireMockServer.verify(1, postRequestedFor(urlEqualTo("/notify/adapterNotify/updateVnfNotificationRequest")));
88 public void deleteVnfTest() {
89 MsoRequest msoRequest = new MsoRequest();
90 msoRequest.setRequestId("12345");
91 msoRequest.setServiceInstanceId("12345");
92 instance.deleteVnfA("mdt1", "CloudOwner", "88a6ca3ee0394ade9403f075db23167e", "vSAMP12", "messageId",
93 msoRequest, "http://org.onap.so/notify/adapterNotify/updateVnfNotificationRequest");
94 assertNotNull(msoRequest);