summaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
Diffstat (limited to 'common')
-rw-r--r--common/src/test/java/org/onap/so/client/HttpClientTest.java11
-rw-r--r--common/src/test/java/org/onap/so/client/aai/AAIConfigurationClientTest.java25
-rw-r--r--common/src/test/java/org/onap/so/client/aai/AAIResourcesClientWithServiceInstanceUriTest.java5
-rw-r--r--common/src/test/java/org/onap/so/client/aai/entities/uri/ServiceInstanceUriTest.java3
4 files changed, 9 insertions, 35 deletions
diff --git a/common/src/test/java/org/onap/so/client/HttpClientTest.java b/common/src/test/java/org/onap/so/client/HttpClientTest.java
index 75ce5f322f..346bf1426d 100644
--- a/common/src/test/java/org/onap/so/client/HttpClientTest.java
+++ b/common/src/test/java/org/onap/so/client/HttpClientTest.java
@@ -25,18 +25,19 @@ import static com.github.tomakehurst.wiremock.client.WireMock.equalTo;
import static com.github.tomakehurst.wiremock.client.WireMock.exactly;
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.verify;
import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.wireMockConfig;
-import com.github.tomakehurst.wiremock.junit.WireMockRule;
import java.net.MalformedURLException;
import java.net.URL;
+
import org.junit.Rule;
import org.junit.Test;
import org.onap.so.utils.TargetEntity;
+import com.github.tomakehurst.wiremock.junit.WireMockRule;
+
public class HttpClientTest{
@@ -47,7 +48,7 @@ public class HttpClientTest{
@Test
public void testPost_success() throws MalformedURLException{
- stubFor(post(urlEqualTo("/services/sdnc/post"))
+ wireMockRule.stubFor(post(urlEqualTo("/services/sdnc/post"))
.willReturn(aResponse().withStatus(200)
.withHeader("Content-Type", "application/json")
.withBody("")));
@@ -66,7 +67,7 @@ public class HttpClientTest{
@Test
public void testPost_nullHeader() throws MalformedURLException{
- stubFor(post(urlEqualTo("/services/sdnc/post"))
+ wireMockRule.stubFor(post(urlEqualTo("/services/sdnc/post"))
.willReturn(aResponse().withStatus(200)
.withHeader("Content-Type", "application/json")
.withBody("")));
@@ -86,7 +87,7 @@ public class HttpClientTest{
@Test
public void testPost_nullBasicAuth() throws MalformedURLException{
- stubFor(post(urlEqualTo("/services/sdnc/post"))
+ wireMockRule.stubFor(post(urlEqualTo("/services/sdnc/post"))
.willReturn(aResponse().withStatus(200)
.withHeader("Content-Type", "application/json")
.withBody("")));
diff --git a/common/src/test/java/org/onap/so/client/aai/AAIConfigurationClientTest.java b/common/src/test/java/org/onap/so/client/aai/AAIConfigurationClientTest.java
index f30d2e17aa..525dff7562 100644
--- a/common/src/test/java/org/onap/so/client/aai/AAIConfigurationClientTest.java
+++ b/common/src/test/java/org/onap/so/client/aai/AAIConfigurationClientTest.java
@@ -20,10 +20,6 @@
package org.onap.so.client.aai;
-import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
-import static com.github.tomakehurst.wiremock.client.WireMock.get;
-import static com.github.tomakehurst.wiremock.client.WireMock.urlMatching;
-import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.wireMockConfig;
import static org.junit.Assert.assertEquals;
import static org.mockito.ArgumentMatchers.isA;
import static org.mockito.Mockito.doNothing;
@@ -34,7 +30,6 @@ import static org.mockito.Mockito.verify;
import java.util.Optional;
import java.util.UUID;
-import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
@@ -42,18 +37,12 @@ import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
import org.onap.so.client.aai.entities.Configuration;
import org.onap.so.client.aai.entities.uri.AAIResourceUri;
-import org.onap.so.client.aai.entities.uri.AAIUri;
import org.onap.so.client.aai.entities.uri.AAIUriFactory;
import org.onap.so.serviceinstancebeans.ModelInfo;
import org.onap.so.serviceinstancebeans.RequestDetails;
-
-import com.github.tomakehurst.wiremock.junit.WireMockRule;
@RunWith(MockitoJUnitRunner.class)
public class AAIConfigurationClientTest {
- @Rule
- public WireMockRule wireMockRule = new WireMockRule(wireMockConfig().port(8443));
-
@Mock
AAIResourcesClient aaiClient;
@@ -163,18 +152,4 @@ public class AAIConfigurationClientTest {
AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.CONFIGURATION, uuid);
assertEquals(uri, aaiConfigurationClient.getConfigurationURI(uuid));
}
-
- @Test
- public void verifyNotExists() {
- AAIUri path = AAIUriFactory.createResourceUri(AAIObjectType.CONFIGURATION, "test2");
- wireMockRule.stubFor(get(
- urlMatching("/aai/v[0-9]+" + path.build() + ".*"))
- .willReturn(
- aResponse()
- .withHeader("Content-Type", "text/plain")
- .withBody("hello")
- .withStatus(404)));
- boolean result = aaiConfigurationClient.configurationExists("test2");
- assertEquals("path not found", false, result);
- }
}
diff --git a/common/src/test/java/org/onap/so/client/aai/AAIResourcesClientWithServiceInstanceUriTest.java b/common/src/test/java/org/onap/so/client/aai/AAIResourcesClientWithServiceInstanceUriTest.java
index 5493d6778e..46e4c98b3e 100644
--- a/common/src/test/java/org/onap/so/client/aai/AAIResourcesClientWithServiceInstanceUriTest.java
+++ b/common/src/test/java/org/onap/so/client/aai/AAIResourcesClientWithServiceInstanceUriTest.java
@@ -55,7 +55,7 @@ import com.github.tomakehurst.wiremock.junit.WireMockRule;
public class AAIResourcesClientWithServiceInstanceUriTest {
@Rule
- public WireMockRule wireMockRule = new WireMockRule(wireMockConfig().port(8443));
+ public WireMockRule wireMockRule = new WireMockRule(wireMockConfig().dynamicPort());
@Rule
public ExpectedException thrown = ExpectedException.none();
@@ -69,8 +69,7 @@ public class AAIResourcesClientWithServiceInstanceUriTest {
private ServiceInstanceUri uri;
@Before
public void setUp() {
-
- doReturn(new DefaultAAIPropertiesImpl()).when(client).getRestProperties();
+ doReturn(new DefaultAAIPropertiesImpl(wireMockRule.port())).when(client).getRestProperties();
wireMockRule.stubFor(get(urlMatching("/aai/v[0-9]+/nodes.*"))
.willReturn(aResponse()
.withStatus(404)
diff --git a/common/src/test/java/org/onap/so/client/aai/entities/uri/ServiceInstanceUriTest.java b/common/src/test/java/org/onap/so/client/aai/entities/uri/ServiceInstanceUriTest.java
index 979ca39489..c369767e38 100644
--- a/common/src/test/java/org/onap/so/client/aai/entities/uri/ServiceInstanceUriTest.java
+++ b/common/src/test/java/org/onap/so/client/aai/entities/uri/ServiceInstanceUriTest.java
@@ -22,7 +22,6 @@ package org.onap.so.client.aai.entities.uri;
import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
import static com.github.tomakehurst.wiremock.client.WireMock.get;
-import static com.github.tomakehurst.wiremock.client.WireMock.stubFor;
import static com.github.tomakehurst.wiremock.client.WireMock.urlPathMatching;
import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.wireMockConfig;
import static org.hamcrest.MatcherAssert.assertThat;
@@ -197,7 +196,7 @@ public class ServiceInstanceUriTest {
ServiceInstanceUri spy = spy(instance);
AAIResourcesClient client = aaiClient;
doReturn(client).when(spy).getResourcesClient();
- stubFor(get(urlPathMatching("/aai/v[0-9]+/nodes/service-instances/service-instance/key3"))
+ wireMockRule.stubFor(get(urlPathMatching("/aai/v[0-9]+/nodes/service-instances/service-instance/key3"))
.willReturn(aResponse()
.withStatus(404)
.withHeader("Content-Type", "application/json")