replace all fixed wiremock ports
[so.git] / adapters / mso-openstack-adapters / src / test / java / org / onap / so / adapters / vnf / MsoVnfAdapterAsyncImplTest.java
index cbf252e..02fbe2c 100644 (file)
 package org.onap.so.adapters.vnf;
 
 
-import org.apache.http.HttpStatus;
-import org.junit.Ignore;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
-import org.onap.so.adapters.vnf.exceptions.VnfException;
-import org.onap.so.entity.MsoRequest;
-import org.onap.so.openstack.beans.VnfRollback;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.boot.test.mock.mockito.SpyBean;
-
-import java.util.HashMap;
-import java.util.Map;
-
 import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
 import static com.github.tomakehurst.wiremock.client.WireMock.containing;
 import static com.github.tomakehurst.wiremock.client.WireMock.post;
 import static com.github.tomakehurst.wiremock.client.WireMock.postRequestedFor;
-import static com.github.tomakehurst.wiremock.client.WireMock.stubFor;
 import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo;
 import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo;
-import static com.github.tomakehurst.wiremock.client.WireMock.verify;
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.Mockito.doThrow;
 import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackGetStackVfModule_200;
 import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackResponseAccess;
 
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.http.HttpStatus;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+import org.onap.so.entity.MsoRequest;
+import org.onap.so.openstack.beans.VnfRollback;
+import org.springframework.beans.factory.annotation.Autowired;
+
 public class MsoVnfAdapterAsyncImplTest extends BaseRestTestUtils {
 
        @Autowired
@@ -67,9 +60,9 @@ public class MsoVnfAdapterAsyncImplTest extends BaseRestTestUtils {
                msoRequest.setRequestId("12345");
                msoRequest.setServiceInstanceId("12345");
 
-               mockOpenStackResponseAccess(wireMockPort);
-               mockOpenStackGetStackVfModule_200();
-               stubFor(post(urlPathEqualTo("/notify/adapterNotify/updateVnfNotificationRequest")).withRequestBody
+               mockOpenStackResponseAccess(wireMockServer, wireMockPort);
+               mockOpenStackGetStackVfModule_200(wireMockServer);
+               wireMockServer.stubFor(post(urlPathEqualTo("/notify/adapterNotify/updateVnfNotificationRequest")).withRequestBody
                                (containing("messageId"))
                                .willReturn(aResponse().withStatus(HttpStatus.SC_OK)));
 
@@ -79,7 +72,7 @@ public class MsoVnfAdapterAsyncImplTest extends BaseRestTestUtils {
                                "volumeGroupHeatStackId|1", new HashMap<String, Object>(), Boolean.FALSE, Boolean.TRUE, Boolean.FALSE, "messageId",
                                msoRequest, notificationUrl);
 
-               verify(1,postRequestedFor(urlEqualTo("/notify/adapterNotify/updateVnfNotificationRequest")));
+       wireMockServer.verify(1,postRequestedFor(urlEqualTo("/notify/adapterNotify/updateVnfNotificationRequest")));
        }
 
        @Test
@@ -89,7 +82,7 @@ public class MsoVnfAdapterAsyncImplTest extends BaseRestTestUtils {
                                "volumeGroupHeatStackId|1", new HashMap<String, Object>(), Boolean.FALSE, Boolean.TRUE, Boolean.FALSE, "messageId",
                                null, notificationUrl);
 
-               verify(1,postRequestedFor(urlEqualTo("/notify/adapterNotify/updateVnfNotificationRequest")));
+       wireMockServer.verify(1,postRequestedFor(urlEqualTo("/notify/adapterNotify/updateVnfNotificationRequest")));
 
        }
 
@@ -101,7 +94,7 @@ public class MsoVnfAdapterAsyncImplTest extends BaseRestTestUtils {
 
                Map<String, Object> map = new HashMap<>();
                map.put("key1", "value1");
-               stubFor(post(urlPathEqualTo("/notify/adapterNotify/updateVnfNotificationRequest")).withRequestBody
+               wireMockServer.stubFor(post(urlPathEqualTo("/notify/adapterNotify/updateVnfNotificationRequest")).withRequestBody
                                (containing("messageId"))
                                .willReturn(aResponse().withStatus(HttpStatus.SC_OK)));
                String notificationUrl = "http://localhost:"+wireMockPort+"/notify/adapterNotify/updateVnfNotificationRequest";
@@ -118,14 +111,14 @@ public class MsoVnfAdapterAsyncImplTest extends BaseRestTestUtils {
 
                Map<String, Object> map = new HashMap<>();
                map.put("key1", "value1");
-               stubFor(post(urlPathEqualTo("/notify/adapterNotify/updateVnfNotificationRequest")).withRequestBody
+               wireMockServer.stubFor(post(urlPathEqualTo("/notify/adapterNotify/updateVnfNotificationRequest")).withRequestBody
                                (containing("messageId"))
                                .willReturn(aResponse().withStatus(HttpStatus.SC_OK)));
                String notificationUrl = "http://localhost:"+wireMockPort+"/notify/adapterNotify/updateVnfNotificationRequest";
                instance.updateVnfA("mdt1", "CloudOwner", "88a6ca3ee0394ade9403f075db23167e", "vnf", "1", "vSAMP12", "VFMOD",
                                "volumeGroupHeatStackId|1", map, "messageId", msoRequest,
                                notificationUrl);
-               verify(1,postRequestedFor(urlEqualTo("/notify/adapterNotify/updateVnfNotificationRequest")));
+       wireMockServer.verify(1,postRequestedFor(urlEqualTo("/notify/adapterNotify/updateVnfNotificationRequest")));
        }
 
        @Test