From aaa93d4351b712762d6951a8c82bbe84c2077795 Mon Sep 17 00:00:00 2001 From: "Benjamin, Max (mb388a)" Date: Wed, 20 Mar 2019 14:12:06 -0400 Subject: replace all fixed wiremock ports trying to get the tests that can be threaded to pass started to remove fixed port references Change-Id: I7bfe067a8f36c908039700646571681321e9a6f5 Issue-ID: SO-1676 Signed-off-by: Benjamin, Max (mb388a) --- adapters/mso-adapter-utils/pom.xml | 18 ++ .../test/java/org/onap/so/AllTestsTestSuite.java | 32 +++ .../src/test/java/org/onap/so/BaseTest.java | 32 ++- .../src/test/java/org/onap/so/StubOpenStack.java | 76 +++--- .../onap/so/openstack/utils/MsoHeatUtilsTest.java | 37 +-- .../so/openstack/utils/MsoKeystoneUtilsTest.java | 32 +-- .../so/openstack/utils/MsoMulticloudUtilsTest.java | 8 +- .../so/openstack/utils/MsoNeutronUtilsTest.java | 22 +- adapters/mso-catalog-db-adapter/pom.xml | 18 ++ .../so/adapters/catalogdb/AllTestsTestSuite.java | 32 +++ .../catalogdb/CatalogDbAdapterBaseTest.java | 21 ++ .../catalogdb/catalogrest/CatalogDBRestTest.java | 28 +-- .../catalogdb/catalogrest/CloudConfigTest.java | 6 +- .../catalogrest/CvnfcCatalogDbQueryTest.java | 6 +- .../NetworkCollectionCatalogDbQueryTest.java | 6 +- .../so/db/catalog/client/CatalogDbClientTest.java | 6 +- adapters/mso-openstack-adapters/pom.xml | 18 ++ .../network/MSONetworkAdapterImplTest.java | 148 +++++------ .../network/MsoNetworkAdapterAsyncImplTest.java | 77 +++--- .../adapters/network/NetworkAdapterRestTest.java | 62 ++--- .../so/adapters/tenant/TenantAdapterRestTest.java | 32 +-- .../onap/so/adapters/valet/ValetClientTest.java | 10 +- .../onap/so/adapters/vnf/AllTestsTestSuite.java | 32 +++ .../onap/so/adapters/vnf/BaseRestTestUtils.java | 45 ++-- .../adapters/vnf/MsoVnfAdapterAsyncImplTest.java | 45 ++-- .../so/adapters/vnf/MsoVnfAdapterImplTest.java | 172 ++++++------- .../vnf/MsoVnfCloudifyAdapterImplTest.java | 49 ++-- .../vnf/MsoVnfMulticloudAdapterImplTest.java | 42 ++-- .../adapters/vnf/MsoVnfPluginAdapterImplTest.java | 46 ++-- .../onap/so/adapters/vnf/VnfAdapterRestTest.java | 72 +++--- .../so/adapters/vnf/VolumeAdapterRestTest.java | 44 ++-- .../so/adapters/vnf/VolumeAdapterRestV2Test.java | 44 ++-- .../java/org/onap/so/bpmn/mock/StubOpenStack.java | 279 +++++++++++---------- adapters/mso-requests-db-adapter/pom.xml | 18 ++ .../so/adapters/requestsdb/AllTestsTestSuite.java | 32 +++ .../ArchiveInfraRequestsSchedulerTest.java | 16 +- ...tiveRequestsRepositoryCustomControllerTest.java | 34 +-- .../adapters/requestsdb/RequestsAdapterBase.java | 14 ++ .../adapters/HealthCheckHandlerTest.java | 19 +- .../requestsdb/adapters/MSORequestDBImplTest.java | 56 +++-- .../requestsdb/client/RequestsDbClientTest.java | 6 +- adapters/mso-sdnc-adapter/pom.xml | 18 ++ .../onap/so/adapters/sdnc/AllTestsTestSuite.java | 32 +++ .../java/org/onap/so/adapters/sdnc/BaseTest.java | 8 +- .../so/adapters/sdnc/impl/SDNCRestClientTest.java | 5 +- .../adapters/sdnc/sdncrest/BPRestCallbackTest.java | 12 +- .../adapters/sdnc/sdncrest/SDNCConnectorTest.java | 13 +- 47 files changed, 1068 insertions(+), 812 deletions(-) create mode 100644 adapters/mso-adapter-utils/src/test/java/org/onap/so/AllTestsTestSuite.java create mode 100644 adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/AllTestsTestSuite.java create mode 100644 adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/CatalogDbAdapterBaseTest.java create mode 100644 adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/AllTestsTestSuite.java create mode 100644 adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/AllTestsTestSuite.java create mode 100644 adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/RequestsAdapterBase.java create mode 100644 adapters/mso-sdnc-adapter/src/test/java/org/onap/so/adapters/sdnc/AllTestsTestSuite.java (limited to 'adapters') diff --git a/adapters/mso-adapter-utils/pom.xml b/adapters/mso-adapter-utils/pom.xml index f94d5d60b8..ed76354792 100644 --- a/adapters/mso-adapter-utils/pom.xml +++ b/adapters/mso-adapter-utils/pom.xml @@ -55,6 +55,24 @@ org.jacoco jacoco-maven-plugin + + org.apache.maven.plugins + maven-surefire-plugin + + + default-test + + test + + + + **/AllTestsTestSuite.java + + suites + + + + diff --git a/adapters/mso-adapter-utils/src/test/java/org/onap/so/AllTestsTestSuite.java b/adapters/mso-adapter-utils/src/test/java/org/onap/so/AllTestsTestSuite.java new file mode 100644 index 0000000000..a74dbf614b --- /dev/null +++ b/adapters/mso-adapter-utils/src/test/java/org/onap/so/AllTestsTestSuite.java @@ -0,0 +1,32 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 - 2018 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so; +import org.junit.runner.RunWith; + +import com.googlecode.junittoolbox.SuiteClasses; +import com.googlecode.junittoolbox.WildcardPatternSuite; + +@RunWith(WildcardPatternSuite.class) +@SuiteClasses("**/*Test.class") +public class AllTestsTestSuite { + // the class remains empty, + // used only as a holder for the above annotations +} diff --git a/adapters/mso-adapter-utils/src/test/java/org/onap/so/BaseTest.java b/adapters/mso-adapter-utils/src/test/java/org/onap/so/BaseTest.java index 9cfdf53094..82b18d86ed 100644 --- a/adapters/mso-adapter-utils/src/test/java/org/onap/so/BaseTest.java +++ b/adapters/mso-adapter-utils/src/test/java/org/onap/so/BaseTest.java @@ -23,7 +23,16 @@ package org.onap.so; -import com.github.tomakehurst.wiremock.client.WireMock; +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.urlPathEqualTo; + +import java.io.BufferedReader; +import java.io.FileReader; +import java.io.IOException; + +import javax.ws.rs.core.MediaType; + import org.apache.http.HttpHeaders; import org.apache.http.HttpStatus; import org.junit.After; @@ -33,20 +42,15 @@ import org.onap.so.db.catalog.beans.AuthenticationType; import org.onap.so.db.catalog.beans.CloudIdentity; import org.onap.so.db.catalog.beans.CloudSite; import org.onap.so.db.catalog.beans.ServerType; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.cloud.contract.wiremock.AutoConfigureWireMock; import org.springframework.test.context.ActiveProfiles; import org.springframework.test.context.junit4.SpringRunner; -import javax.ws.rs.core.MediaType; -import java.io.BufferedReader; -import java.io.FileReader; -import java.io.IOException; - -import static com.github.tomakehurst.wiremock.client.WireMock.*; -import static com.github.tomakehurst.wiremock.client.WireMock.aResponse; -import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo; +import com.github.tomakehurst.wiremock.WireMockServer; +import com.github.tomakehurst.wiremock.client.WireMock; @RunWith(SpringRunner.class) @SpringBootTest(classes = TestApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) @@ -56,10 +60,12 @@ public abstract class BaseTest extends TestDataSetup { @Value("${wiremock.server.port}") protected int wireMockPort; + @Autowired + protected WireMockServer wireMockServer; @After public void after() { - WireMock.reset(); + wireMockServer.resetAll(); } protected static String getBody(String body, int port, String urlPath) throws IOException { @@ -74,15 +80,15 @@ public abstract class BaseTest extends TestDataSetup { } private void mockCloud(CloudIdentity identity, CloudSite cloudSite) throws IOException { - stubFor(get(urlPathEqualTo("/cloudSite/MTN13")).willReturn(aResponse() + wireMockServer.stubFor(get(urlPathEqualTo("/cloudSite/MTN13")).willReturn(aResponse() .withBody(getBody(mapper.writeValueAsString(cloudSite),wireMockPort, "")) .withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) .withStatus(HttpStatus.SC_OK))); - stubFor(get(urlPathEqualTo("/cloudSite/DEFAULT")).willReturn(aResponse() + wireMockServer.stubFor(get(urlPathEqualTo("/cloudSite/DEFAULT")).willReturn(aResponse() .withBody(getBody(mapper.writeValueAsString(cloudSite),wireMockPort, "")) .withHeader(HttpHeaders.CONTENT_TYPE,MediaType.APPLICATION_JSON) .withStatus(HttpStatus.SC_OK))); - stubFor(get(urlPathEqualTo("/cloudIdentity/mtn13")).willReturn(aResponse() + wireMockServer.stubFor(get(urlPathEqualTo("/cloudIdentity/mtn13")).willReturn(aResponse() .withBody(getBody(mapper.writeValueAsString(identity),wireMockPort, "")) .withHeader(HttpHeaders.CONTENT_TYPE,MediaType.APPLICATION_JSON) .withStatus(HttpStatus.SC_OK))); diff --git a/adapters/mso-adapter-utils/src/test/java/org/onap/so/StubOpenStack.java b/adapters/mso-adapter-utils/src/test/java/org/onap/so/StubOpenStack.java index 0820076c66..ae3fb8271a 100644 --- a/adapters/mso-adapter-utils/src/test/java/org/onap/so/StubOpenStack.java +++ b/adapters/mso-adapter-utils/src/test/java/org/onap/so/StubOpenStack.java @@ -27,38 +27,40 @@ import static com.github.tomakehurst.wiremock.client.WireMock.delete; import static com.github.tomakehurst.wiremock.client.WireMock.get; import static com.github.tomakehurst.wiremock.client.WireMock.post; import static com.github.tomakehurst.wiremock.client.WireMock.put; -import static com.github.tomakehurst.wiremock.client.WireMock.stubFor; import static com.github.tomakehurst.wiremock.client.WireMock.urlMatching; import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo; import java.io.BufferedReader; import java.io.FileReader; import java.io.IOException; + import org.apache.http.HttpStatus; +import com.github.tomakehurst.wiremock.WireMockServer; + public class StubOpenStack { - public static void mockOpenStackResponseAccess(int port) throws IOException { - stubFor(post(urlPathEqualTo("/v2.0/tokens")).willReturn(aResponse().withHeader("Content-Type", "application/json") + public static void mockOpenStackResponseAccess(WireMockServer wireMockServer, int port) throws IOException { + wireMockServer.stubFor(post(urlPathEqualTo("/v2.0/tokens")).willReturn(aResponse().withHeader("Content-Type", "application/json") .withBody(getBodyFromFile("OpenstackResponse_Access.json", port, "/mockPublicUrl")) .withStatus(HttpStatus.SC_OK))); } - public static void mockOpenStackResponseUnauthorized(int port) throws IOException { - stubFor( + public static void mockOpenStackResponseUnauthorized(WireMockServer wireMockServer, int port) throws IOException { + wireMockServer.stubFor( post(urlPathEqualTo("/v2.0/tokens")) .willReturn(aResponse().withHeader("Content-Type", "application/json") .withBody(getBodyFromFile("OpenstackResponse_Access.json", port, "/mockPublicUrl")) .withStatus(HttpStatus.SC_UNAUTHORIZED))); } - public static void mockOpenStackDelete(String id) { - stubFor(delete(urlMatching("/mockPublicUrl/stacks/" + id)).willReturn(aResponse() + public static void mockOpenStackDelete(WireMockServer wireMockServer, String id) { + wireMockServer.stubFor(delete(urlMatching("/mockPublicUrl/stacks/" + id)).willReturn(aResponse() .withHeader("Content-Type", "application/json").withStatus(HttpStatus.SC_OK))); } - public static void mockOpenStackGet(String id) { - stubFor( + public static void mockOpenStackGet(WireMockServer wireMockServer, String id) { + wireMockServer.stubFor( get(urlPathEqualTo("/mockPublicUrl/stacks/" + id)) .willReturn(aResponse().withHeader("Content-Type", "application/json") .withBodyFile("OpenstackResponse_Stack_Created.json") @@ -66,82 +68,82 @@ public class StubOpenStack { } - public static void mockOpenStackPostStack_200(String filename) { - stubFor(post(urlPathEqualTo("/mockPublicUrl/stacks")).willReturn(aResponse() + public static void mockOpenStackPostStack_200(WireMockServer wireMockServer, String filename) { + wireMockServer.stubFor(post(urlPathEqualTo("/mockPublicUrl/stacks")).willReturn(aResponse() .withHeader("Content-Type", "application/json") .withBodyFile(filename).withStatus(HttpStatus.SC_OK))); } - public static void mockOpenStackPostTenantWithBodyFile_200() throws IOException { - stubFor(post(urlPathEqualTo("/mockPublicUrl/tenants")) + public static void mockOpenStackPostTenantWithBodyFile_200(WireMockServer wireMockServer) throws IOException { + wireMockServer.stubFor(post(urlPathEqualTo("/mockPublicUrl/tenants")) .willReturn(aResponse().withBodyFile("OpenstackResponse_Tenant.json").withStatus(HttpStatus.SC_OK))); } - public static void mockOpenStackGetTenantByName(String tenantName) throws IOException { - stubFor(get(urlMatching("/mockPublicUrl/tenants/[?]name=" + tenantName)) + public static void mockOpenStackGetTenantByName(WireMockServer wireMockServer, String tenantName) throws IOException { + wireMockServer.stubFor(get(urlMatching("/mockPublicUrl/tenants/[?]name=" + tenantName)) .willReturn(aResponse().withBodyFile("OpenstackResponse_Tenant.json").withStatus(HttpStatus.SC_OK))); } - public static void mockOpenStackGetTenantById(String tenantId) throws IOException { - stubFor(get(urlPathEqualTo("/mockPublicUrl/tenants/tenantId")) + public static void mockOpenStackGetTenantById(WireMockServer wireMockServer, String tenantId) throws IOException { + wireMockServer.stubFor(get(urlPathEqualTo("/mockPublicUrl/tenants/tenantId")) .willReturn(aResponse().withBodyFile("OpenstackResponse_Tenant.json").withStatus(HttpStatus.SC_OK))); } - public static void mockOpenStackDeleteTenantById_200(String tenantId) { - stubFor(delete(urlPathEqualTo("/mockPublicUrl/tenants/" + tenantId)).willReturn(aResponse() + public static void mockOpenStackDeleteTenantById_200(WireMockServer wireMockServer, String tenantId) { + wireMockServer.stubFor(delete(urlPathEqualTo("/mockPublicUrl/tenants/" + tenantId)).willReturn(aResponse() .withHeader("Content-Type", "application/json").withStatus(HttpStatus.SC_OK))); } - public static void mockOpenStackGetUserById(String user) { - stubFor(get(urlPathEqualTo("/mockPublicUrl/users/" + user)).willReturn(aResponse() + public static void mockOpenStackGetUserById(WireMockServer wireMockServer, String user) { + wireMockServer.stubFor(get(urlPathEqualTo("/mockPublicUrl/users/" + user)).willReturn(aResponse() .withHeader("Content-Type", "application/json") .withBodyFile("OpenstackResponse_User.json").withStatus(HttpStatus.SC_OK))); } - public static void mockOpenStackGetUserByName(String userName) { - stubFor(get(urlMatching("/mockPublicUrl/users/[?]name=" + userName)).willReturn(aResponse() + public static void mockOpenStackGetUserByName(WireMockServer wireMockServer, String userName) { + wireMockServer.stubFor(get(urlMatching("/mockPublicUrl/users/[?]name=" + userName)).willReturn(aResponse() .withHeader("Content-Type", "application/json") .withBodyFile("OpenstackResponse_User.json").withStatus(HttpStatus.SC_OK))); } - public static void mockOpenStackGetUserByName_500(String userName) { - stubFor(get(urlMatching("/mockPublicUrl/users/[?]name=" + userName)).willReturn(aResponse() + public static void mockOpenStackGetUserByName_500(WireMockServer wireMockServer, String userName) { + wireMockServer.stubFor(get(urlMatching("/mockPublicUrl/users/[?]name=" + userName)).willReturn(aResponse() .withStatus(HttpStatus.SC_INTERNAL_SERVER_ERROR))); } - public static void mockOpenStackGetRoles_200(String roleFor) { - stubFor(get(urlPathEqualTo("/mockPublicUrl/" + roleFor + "/roles")).willReturn(aResponse() + public static void mockOpenStackGetRoles_200(WireMockServer wireMockServer, String roleFor) { + wireMockServer.stubFor(get(urlPathEqualTo("/mockPublicUrl/" + roleFor + "/roles")).willReturn(aResponse() .withHeader("Content-Type", "application/json") .withBodyFile("OpenstackResponse_Roles.json").withStatus(HttpStatus.SC_OK))); } - public static void mockOpenstackPostNetwork(String responseFile) { - stubFor(post(urlPathEqualTo("/mockPublicUrl/v2.0/networks")).willReturn(aResponse() + public static void mockOpenstackPostNetwork(WireMockServer wireMockServer, String responseFile) { + wireMockServer.stubFor(post(urlPathEqualTo("/mockPublicUrl/v2.0/networks")).willReturn(aResponse() .withHeader("Content-Type", "application/json") .withBodyFile(responseFile) .withStatus(HttpStatus.SC_OK))); } - public static void mockOpenstackPutNetwork(String responseFile, String networkId) { - stubFor(put(urlPathEqualTo("/mockPublicUrl/v2.0/networks/"+networkId)).willReturn(aResponse() + public static void mockOpenstackPutNetwork(WireMockServer wireMockServer, String responseFile, String networkId) { + wireMockServer.stubFor(put(urlPathEqualTo("/mockPublicUrl/v2.0/networks/"+networkId)).willReturn(aResponse() .withHeader("Content-Type", "application/json") .withBodyFile(responseFile) .withStatus(HttpStatus.SC_OK))); } - public static void mockOpenStackGetNeutronNetwork(String filename,String networkId) { - stubFor(get(urlPathEqualTo("/mockPublicUrl/v2.0/networks/"+ networkId)) + public static void mockOpenStackGetNeutronNetwork(WireMockServer wireMockServer, String filename,String networkId) { + wireMockServer.stubFor(get(urlPathEqualTo("/mockPublicUrl/v2.0/networks/"+ networkId)) .willReturn(aResponse().withHeader("Content-Type", "application/json") .withBodyFile(filename).withStatus(HttpStatus.SC_OK))); } - public static void mockOpenStackGetNeutronNetwork_500(String networkId) { - stubFor(get(urlPathEqualTo("/mockPublicUrl/v2.0/networks/"+ networkId)) + public static void mockOpenStackGetNeutronNetwork_500(WireMockServer wireMockServer, String networkId) { + wireMockServer.stubFor(get(urlPathEqualTo("/mockPublicUrl/v2.0/networks/"+ networkId)) .willReturn(aResponse().withStatus(HttpStatus.SC_INTERNAL_SERVER_ERROR))); } - public static void mockOpenStackDeleteNeutronNetwork(String networkId) { - stubFor(delete(urlPathEqualTo("/mockPublicUrl/v2.0/networks/" + networkId)) + public static void mockOpenStackDeleteNeutronNetwork(WireMockServer wireMockServer, String networkId) { + wireMockServer.stubFor(delete(urlPathEqualTo("/mockPublicUrl/v2.0/networks/" + networkId)) .willReturn(aResponse().withStatus(HttpStatus.SC_OK))); } diff --git a/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoHeatUtilsTest.java b/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoHeatUtilsTest.java index c771a75976..925365f00e 100644 --- a/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoHeatUtilsTest.java +++ b/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoHeatUtilsTest.java @@ -24,19 +24,17 @@ package org.onap.so.openstack.utils; 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.urlPathEqualTo; import static com.shazam.shazamcrest.MatcherAssert.assertThat; import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs; import static org.junit.Assert.assertNotNull; -import com.woorea.openstack.heat.Heat; -import com.woorea.openstack.heat.model.CreateStackParam; import java.io.IOException; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; + import org.apache.http.HttpStatus; import org.junit.Assert; import org.junit.Test; @@ -59,6 +57,9 @@ import org.onap.so.openstack.exceptions.MsoIOException; import org.onap.so.openstack.exceptions.MsoOpenstackException; import org.springframework.beans.factory.annotation.Autowired; +import com.woorea.openstack.heat.Heat; +import com.woorea.openstack.heat.model.CreateStackParam; + public class MsoHeatUtilsTest extends BaseTest{ @Autowired @@ -94,10 +95,10 @@ public class MsoHeatUtilsTest extends BaseTest{ Map inputs = new HashMap<>(); boolean rollbackOnFailure = true; - StubOpenStack.mockOpenStackResponseAccess(wireMockPort); - StubOpenStack.mockOpenStackPostStack_200("OpenstackResponse_Stack_Created.json"); + StubOpenStack.mockOpenStackResponseAccess(wireMockServer, wireMockPort); + StubOpenStack.mockOpenStackPostStack_200(wireMockServer, "OpenstackResponse_Stack_Created.json"); - stubFor(get(urlPathEqualTo("/mockPublicUrl/stacks/instanceName/stackId")) + wireMockServer.stubFor(get(urlPathEqualTo("/mockPublicUrl/stacks/instanceName/stackId")) .willReturn(aResponse().withHeader("Content-Type", "application/json") .withBodyFile("OpenstackResponse_StackId.json") .withStatus(HttpStatus.SC_OK))); @@ -123,10 +124,10 @@ public class MsoHeatUtilsTest extends BaseTest{ cloudInfo.setTenantId("tenantId"); String instanceId = "instanceId"; - StubOpenStack.mockOpenStackResponseAccess(wireMockPort); - StubOpenStack.mockOpenStackPostStack_200("OpenstackResponse_Stack_Created.json"); + StubOpenStack.mockOpenStackResponseAccess(wireMockServer, wireMockPort); + StubOpenStack.mockOpenStackPostStack_200(wireMockServer, "OpenstackResponse_Stack_Created.json"); - stubFor(get(urlPathEqualTo("/mockPublicUrl/stacks/instanceId")) + wireMockServer.stubFor(get(urlPathEqualTo("/mockPublicUrl/stacks/instanceId")) .willReturn(aResponse().withHeader("Content-Type", "application/json") .withBodyFile("OpenstackResponse_StackId.json") .withStatus(HttpStatus.SC_OK))); @@ -152,10 +153,10 @@ public class MsoHeatUtilsTest extends BaseTest{ int timeoutInMinutes = 1; - StubOpenStack.mockOpenStackResponseAccess(wireMockPort); - stubFor(get(urlPathEqualTo("/mockPublicUrl/stacks/instanceId")).willReturn(aResponse().withBodyFile("OpenstackResponse_StackId.json").withStatus(HttpStatus.SC_OK))); - StubOpenStack.mockOpenStackDelete("name/da886914-efb2-4917-b335-c8381528d90b"); - stubFor(get(urlPathEqualTo("/mockPublicUrl/stacks/name/da886914-efb2-4917-b335-c8381528d90b")).willReturn(aResponse().withBodyFile("OpenstackResponse_Stack_DeleteComplete.json").withStatus(HttpStatus.SC_OK))); + StubOpenStack.mockOpenStackResponseAccess(wireMockServer, wireMockPort); + wireMockServer.stubFor(get(urlPathEqualTo("/mockPublicUrl/stacks/instanceId")).willReturn(aResponse().withBodyFile("OpenstackResponse_StackId.json").withStatus(HttpStatus.SC_OK))); + StubOpenStack.mockOpenStackDelete(wireMockServer, "name/da886914-efb2-4917-b335-c8381528d90b"); + wireMockServer.stubFor(get(urlPathEqualTo("/mockPublicUrl/stacks/name/da886914-efb2-4917-b335-c8381528d90b")).willReturn(aResponse().withBodyFile("OpenstackResponse_Stack_DeleteComplete.json").withStatus(HttpStatus.SC_OK))); VduInstance actual = heatUtils.deleteVdu(cloudInfo, instanceId, timeoutInMinutes); @@ -195,7 +196,7 @@ public class MsoHeatUtilsTest extends BaseTest{ @Test public final void getHeatClientSuccessTest() throws MsoException, IOException { CloudSite cloudSite = getCloudSite(getCloudIdentity()); - StubOpenStack.mockOpenStackResponseAccess(wireMockPort); + StubOpenStack.mockOpenStackResponseAccess(wireMockServer, wireMockPort); Heat heatClient = heatUtils.getHeatClient(cloudSite, "TEST-tenant"); assertNotNull(heatClient); } @@ -210,7 +211,7 @@ public class MsoHeatUtilsTest extends BaseTest{ @Test(expected = MsoAdapterException.class) public final void getHeatClientOpenStackResponseException401Test() throws MsoException, IOException { CloudSite cloudSite = getCloudSite(getCloudIdentity()); - StubOpenStack.mockOpenStackResponseUnauthorized(wireMockPort); + StubOpenStack.mockOpenStackResponseUnauthorized(wireMockServer, wireMockPort); heatUtils.getHeatClient(cloudSite, "TEST-tenant"); } @@ -226,9 +227,9 @@ public class MsoHeatUtilsTest extends BaseTest{ @Test public final void createStackSuccessTest() throws MsoException, IOException { CloudSite cloudSite = getCloudSite(getCloudIdentity()); - StubOpenStack.mockOpenStackResponseAccess(wireMockPort); - StubOpenStack.mockOpenStackPostStack_200("OpenstackResponse_Stack_Created.json"); - StubOpenStack.mockOpenStackGet("TEST-stack/stackId"); + StubOpenStack.mockOpenStackResponseAccess(wireMockServer, wireMockPort); + StubOpenStack.mockOpenStackPostStack_200(wireMockServer, "OpenstackResponse_Stack_Created.json"); + StubOpenStack.mockOpenStackGet(wireMockServer, "TEST-stack/stackId"); StackInfo stackInfo = heatUtils.createStack(cloudSite.getId(), "CloudOwner", "tenantId", "TEST-stack", null, "TEST-heat", new HashMap<>(), false, 1, "TEST-env", new HashMap<>(), new HashMap<>(), false); diff --git a/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoKeystoneUtilsTest.java b/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoKeystoneUtilsTest.java index 5100407633..3526a68ef6 100644 --- a/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoKeystoneUtilsTest.java +++ b/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoKeystoneUtilsTest.java @@ -39,15 +39,15 @@ public class MsoKeystoneUtilsTest extends BaseTest { @Before public void before() throws IOException { - StubOpenStack.mockOpenStackResponseAccess(wireMockPort); + StubOpenStack.mockOpenStackResponseAccess(wireMockServer, wireMockPort); } @Test public void createTenantTest() throws Exception { - StubOpenStack.mockOpenStackPostTenantWithBodyFile_200(); + StubOpenStack.mockOpenStackPostTenantWithBodyFile_200(wireMockServer); - StubOpenStack.mockOpenStackGetUserById("john"); - StubOpenStack.mockOpenStackGetRoles_200("OS-KSADM"); + StubOpenStack.mockOpenStackGetUserById(wireMockServer, "john"); + StubOpenStack.mockOpenStackGetRoles_200(wireMockServer, "OS-KSADM"); String response = msoKeystoneUtils.createTenant("tenant", "MTN13", new HashMap<>(), true); Assert.assertEquals("tenantId", response); @@ -55,10 +55,10 @@ public class MsoKeystoneUtilsTest extends BaseTest { @Test public void createTenantTest_FindUserByName() throws Exception { - StubOpenStack.mockOpenStackPostTenantWithBodyFile_200(); + StubOpenStack.mockOpenStackPostTenantWithBodyFile_200(wireMockServer); - StubOpenStack.mockOpenStackGetUserByName("john"); - StubOpenStack.mockOpenStackGetRoles_200("OS-KSADM"); + StubOpenStack.mockOpenStackGetUserByName(wireMockServer, "john"); + StubOpenStack.mockOpenStackGetRoles_200(wireMockServer, "OS-KSADM"); String response = msoKeystoneUtils.createTenant("tenant", "MTN13", new HashMap<>(), true); Assert.assertEquals("tenantId", response); @@ -67,15 +67,15 @@ public class MsoKeystoneUtilsTest extends BaseTest { @Test public void createTenantTest_Exception() throws Exception { expectedException.expect(MsoException.class); - StubOpenStack.mockOpenStackPostTenantWithBodyFile_200(); - StubOpenStack.mockOpenStackGetUserByName_500("john"); - StubOpenStack.mockOpenStackGetRoles_200("OS-KSADM"); + StubOpenStack.mockOpenStackPostTenantWithBodyFile_200(wireMockServer); + StubOpenStack.mockOpenStackGetUserByName_500(wireMockServer, "john"); + StubOpenStack.mockOpenStackGetRoles_200(wireMockServer, "OS-KSADM"); msoKeystoneUtils.createTenant("tenant", "Test", new HashMap<>(), true); } @Test public void queryTenantTest() throws Exception { - StubOpenStack.mockOpenStackGetTenantById("tenantId"); + StubOpenStack.mockOpenStackGetTenantById(wireMockServer, "tenantId"); MsoTenant msoTenant = msoKeystoneUtils.queryTenant("tenantId", "MTN13"); @@ -84,7 +84,7 @@ public class MsoKeystoneUtilsTest extends BaseTest { @Test public void queryTenantByNameTest() throws Exception { - StubOpenStack.mockOpenStackGetTenantByName("tenant"); + StubOpenStack.mockOpenStackGetTenantByName(wireMockServer, "tenant"); MsoTenant msoTenant = msoKeystoneUtils.queryTenantByName("tenant", "MTN13"); @@ -93,8 +93,8 @@ public class MsoKeystoneUtilsTest extends BaseTest { @Test public void deleteTenantTest() throws Exception { - StubOpenStack.mockOpenStackGetTenantById("tenantId"); - StubOpenStack.mockOpenStackDeleteTenantById_200("tenantId"); + StubOpenStack.mockOpenStackGetTenantById(wireMockServer, "tenantId"); + StubOpenStack.mockOpenStackDeleteTenantById_200(wireMockServer, "tenantId"); boolean result = msoKeystoneUtils.deleteTenant("tenantId", "MTN13"); Assert.assertTrue(result); @@ -102,8 +102,8 @@ public class MsoKeystoneUtilsTest extends BaseTest { @Test public void deleteTenantByNameTest() throws Exception { - StubOpenStack.mockOpenStackGetTenantByName("tenant"); - StubOpenStack.mockOpenStackDeleteTenantById_200("tenantId"); + StubOpenStack.mockOpenStackGetTenantByName(wireMockServer, "tenant"); + StubOpenStack.mockOpenStackDeleteTenantById_200(wireMockServer, "tenantId"); boolean result = msoKeystoneUtils.deleteTenantByName("tenant", "MTN13"); Assert.assertTrue(result); diff --git a/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoMulticloudUtilsTest.java b/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoMulticloudUtilsTest.java index b2a69ded46..3b3e30183b 100644 --- a/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoMulticloudUtilsTest.java +++ b/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoMulticloudUtilsTest.java @@ -22,7 +22,6 @@ package org.onap.so.openstack.utils; import static com.github.tomakehurst.wiremock.client.WireMock.aResponse; import static com.github.tomakehurst.wiremock.client.WireMock.post; -import static com.github.tomakehurst.wiremock.client.WireMock.stubFor; import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; @@ -32,6 +31,7 @@ import static org.mockito.Mockito.when; import java.io.IOException; import java.util.HashMap; import java.util.Optional; + import org.apache.http.HttpStatus; import org.junit.Test; import org.mockito.InjectMocks; @@ -61,7 +61,7 @@ public class MsoMulticloudUtilsTest extends BaseTest { @Test public void createStackSuccess() throws MsoException, IOException { - stubFor(post(urlPathEqualTo("/v2.0")) + wireMockServer.stubFor(post(urlPathEqualTo("/v2.0")) .willReturn(aResponse().withHeader("Content-Type", "application/json") .withBody(CREATE_STACK_RESPONSE) .withStatus(HttpStatus.SC_CREATED))); @@ -93,7 +93,7 @@ public class MsoMulticloudUtilsTest extends BaseTest { @Test public void createStackBadRequest() { try { - stubFor(post(urlPathEqualTo("/v2.0")) + wireMockServer.stubFor(post(urlPathEqualTo("/v2.0")) .willReturn(aResponse().withHeader("Content-Type", "application/json") .withStatus(HttpStatus.SC_BAD_REQUEST))); multicloudUtils.createStack("MTN13", "CloudOwner", "TEST-tenant", "TEST-stack", new VduModelInfo(), @@ -108,7 +108,7 @@ public class MsoMulticloudUtilsTest extends BaseTest { @Test public void createStackEmptyResponseEntity() throws MsoException { - stubFor(post(urlPathEqualTo("/v2.0")) + wireMockServer.stubFor(post(urlPathEqualTo("/v2.0")) .willReturn(aResponse().withHeader("Content-Type", "application/json") .withStatus(HttpStatus.SC_CREATED))); StackInfo result = multicloudUtils.createStack("MTN13", "CloudOwner", "TEST-tenant", "TEST-stack", new VduModelInfo(), diff --git a/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoNeutronUtilsTest.java b/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoNeutronUtilsTest.java index f679e1f776..8c337865df 100644 --- a/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoNeutronUtilsTest.java +++ b/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoNeutronUtilsTest.java @@ -44,7 +44,7 @@ public class MsoNeutronUtilsTest extends BaseTest{ public void before() throws IOException { vlans = new ArrayList<>(); vlans.add(3014); - StubOpenStack.mockOpenStackResponseAccess(wireMockPort); + StubOpenStack.mockOpenStackResponseAccess(wireMockServer, wireMockPort); } @Test @@ -56,7 +56,7 @@ public class MsoNeutronUtilsTest extends BaseTest{ @Test public void createNetworkTest_NetworkTypeAsMultiProvider() throws Exception { - StubOpenStack.mockOpenstackPostNetwork("OpenstackCreateNeutronNetworkResponse.json"); + StubOpenStack.mockOpenstackPostNetwork(wireMockServer, "OpenstackCreateNeutronNetworkResponse.json"); NetworkInfo networkInfo = msoNeutronUtils.createNetwork("MTN13", "tenantId", MsoNeutronUtils.NetworkType.MULTI_PROVIDER,"networkName","PROVIDER", vlans); @@ -65,7 +65,7 @@ public class MsoNeutronUtilsTest extends BaseTest{ @Test public void createNetworkTest() throws Exception { - StubOpenStack.mockOpenstackPostNetwork("OpenstackCreateNeutronNetworkResponse.json"); + StubOpenStack.mockOpenstackPostNetwork(wireMockServer, "OpenstackCreateNeutronNetworkResponse.json"); NetworkInfo networkInfo = msoNeutronUtils.createNetwork("MTN13", "tenantId", MsoNeutronUtils.NetworkType.PROVIDER,"networkName","PROVIDER", vlans); @@ -74,7 +74,7 @@ public class MsoNeutronUtilsTest extends BaseTest{ @Test public void queryNetworkTest() throws Exception { - StubOpenStack.mockOpenStackGetNeutronNetwork("GetNeutronNetwork.json", "43173f6a-d699-414b-888f-ab243dda6dfe"); + StubOpenStack.mockOpenStackGetNeutronNetwork(wireMockServer, "GetNeutronNetwork.json", "43173f6a-d699-414b-888f-ab243dda6dfe"); NetworkInfo networkInfo = msoNeutronUtils.queryNetwork("43173f6a-d699-414b-888f-ab243dda6dfe", "tenantId","MTN13"); Assert.assertEquals("net1",networkInfo.getName()); @@ -89,15 +89,15 @@ public class MsoNeutronUtilsTest extends BaseTest{ @Test public void queryNetworkTest_500() throws Exception { expectedException.expect(MsoException.class); - StubOpenStack.mockOpenStackGetNeutronNetwork_500("43173f6a-d699-414b-888f-ab243dda6dfe"); + StubOpenStack.mockOpenStackGetNeutronNetwork_500(wireMockServer, "43173f6a-d699-414b-888f-ab243dda6dfe"); msoNeutronUtils.queryNetwork("43173f6a-d699-414b-888f-ab243dda6dfe", "tenantId","MTN13"); } @Test public void deleteNetworkkTest() throws Exception { - StubOpenStack.mockOpenStackGetNeutronNetwork("GetNeutronNetwork.json", "43173f6a-d699-414b-888f-ab243dda6dfe"); - StubOpenStack.mockOpenStackDeleteNeutronNetwork("43173f6a-d699-414b-888f-ab243dda6dfe"); + StubOpenStack.mockOpenStackGetNeutronNetwork(wireMockServer, "GetNeutronNetwork.json", "43173f6a-d699-414b-888f-ab243dda6dfe"); + StubOpenStack.mockOpenStackDeleteNeutronNetwork(wireMockServer, "43173f6a-d699-414b-888f-ab243dda6dfe"); Boolean result = msoNeutronUtils.deleteNetwork("43173f6a-d699-414b-888f-ab243dda6dfe", "tenantId","MTN13"); Assert.assertTrue(result); @@ -105,8 +105,8 @@ public class MsoNeutronUtilsTest extends BaseTest{ @Test public void updateNetworkTest() throws Exception { - StubOpenStack.mockOpenStackGetNeutronNetwork("GetNeutronNetwork.json", "43173f6a-d699-414b-888f-ab243dda6dfe"); - StubOpenStack.mockOpenstackPutNetwork("OpenstackCreateNeutronNetworkResponse.json", "43173f6a-d699-414b-888f-ab243dda6dfe"); + StubOpenStack.mockOpenStackGetNeutronNetwork(wireMockServer, "GetNeutronNetwork.json", "43173f6a-d699-414b-888f-ab243dda6dfe"); + StubOpenStack.mockOpenstackPutNetwork(wireMockServer, "OpenstackCreateNeutronNetworkResponse.json", "43173f6a-d699-414b-888f-ab243dda6dfe"); NetworkInfo networkInfo = msoNeutronUtils.updateNetwork("MTN13", "tenantId", "43173f6a-d699-414b-888f-ab243dda6dfe",MsoNeutronUtils.NetworkType.PROVIDER,"PROVIDER", vlans); @@ -115,8 +115,8 @@ public class MsoNeutronUtilsTest extends BaseTest{ @Test public void updateNetworkTest_NetworkTypeAsMultiProvider() throws Exception { - StubOpenStack.mockOpenStackGetNeutronNetwork("GetNeutronNetwork.json", "43173f6a-d699-414b-888f-ab243dda6dfe"); - StubOpenStack.mockOpenstackPutNetwork("OpenstackCreateNeutronNetworkResponse.json", "43173f6a-d699-414b-888f-ab243dda6dfe"); + StubOpenStack.mockOpenStackGetNeutronNetwork(wireMockServer, "GetNeutronNetwork.json", "43173f6a-d699-414b-888f-ab243dda6dfe"); + StubOpenStack.mockOpenstackPutNetwork(wireMockServer, "OpenstackCreateNeutronNetworkResponse.json", "43173f6a-d699-414b-888f-ab243dda6dfe"); NetworkInfo networkInfo = msoNeutronUtils.updateNetwork("MTN13", "tenantId", "43173f6a-d699-414b-888f-ab243dda6dfe",MsoNeutronUtils.NetworkType.MULTI_PROVIDER,"PROVIDER", vlans); diff --git a/adapters/mso-catalog-db-adapter/pom.xml b/adapters/mso-catalog-db-adapter/pom.xml index 390c775cb2..1f6ea413ec 100644 --- a/adapters/mso-catalog-db-adapter/pom.xml +++ b/adapters/mso-catalog-db-adapter/pom.xml @@ -63,6 +63,24 @@ + + org.apache.maven.plugins + maven-surefire-plugin + + + default-test + + test + + + + **/AllTestsTestSuite.java + + suites + + + + diff --git a/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/AllTestsTestSuite.java b/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/AllTestsTestSuite.java new file mode 100644 index 0000000000..3c05f8164b --- /dev/null +++ b/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/AllTestsTestSuite.java @@ -0,0 +1,32 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 - 2018 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.adapters.catalogdb; +import org.junit.runner.RunWith; + +import com.googlecode.junittoolbox.SuiteClasses; +import com.googlecode.junittoolbox.WildcardPatternSuite; + +@RunWith(WildcardPatternSuite.class) +@SuiteClasses("**/*Test.class") +public class AllTestsTestSuite { + // the class remains empty, + // used only as a holder for the above annotations +} diff --git a/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/CatalogDbAdapterBaseTest.java b/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/CatalogDbAdapterBaseTest.java new file mode 100644 index 0000000000..b2a20681d9 --- /dev/null +++ b/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/CatalogDbAdapterBaseTest.java @@ -0,0 +1,21 @@ +package org.onap.so.adapters.catalogdb; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.boot.web.server.LocalServerPort; +import org.springframework.test.context.ActiveProfiles; +import org.springframework.test.context.junit4.SpringRunner; + +@RunWith(SpringRunner.class) +@SpringBootTest(classes = CatalogDBApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) +@ActiveProfiles("test") +public class CatalogDbAdapterBaseTest { + + @LocalServerPort + protected int port; + + + @Test + public void testNothing(){} +} diff --git a/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/CatalogDBRestTest.java b/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/CatalogDBRestTest.java index a97029ef5b..bd8c5bc3e3 100644 --- a/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/CatalogDBRestTest.java +++ b/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/CatalogDBRestTest.java @@ -20,7 +20,8 @@ package org.onap.so.adapters.catalogdb.catalogrest; -import static org.junit.Assert.*; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; import static org.onap.so.logger.MdcConstants.ENDTIME; import static org.onap.so.logger.MdcConstants.INVOCATION_ID; import static org.onap.so.logger.MdcConstants.PARTNERNAME; @@ -29,45 +30,29 @@ import static org.onap.so.logger.MdcConstants.RESPONSEDESC; import static org.onap.so.logger.MdcConstants.SERVICE_NAME; import static org.onap.so.logger.MdcConstants.STATUSCODE; - import java.io.IOException; import java.util.Map; -import java.util.regex.Matcher; -import java.util.regex.Pattern; + import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; - import org.json.JSONException; -import org.junit.Before; -import org.junit.BeforeClass; import org.junit.Test; -import org.junit.runner.RunWith; import org.onap.logging.ref.slf4j.ONAPLogConstants; -import org.onap.so.adapters.catalogdb.CatalogDBApplication; - +import org.onap.so.adapters.catalogdb.CatalogDbAdapterBaseTest; import org.skyscreamer.jsonassert.JSONAssert; import org.skyscreamer.jsonassert.JSONCompareMode; -import org.springframework.boot.web.server.LocalServerPort; -import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.web.client.TestRestTemplate; import org.springframework.http.HttpEntity; import org.springframework.http.HttpHeaders; import org.springframework.http.HttpMethod; import org.springframework.http.ResponseEntity; -import org.springframework.test.annotation.DirtiesContext; -import org.springframework.test.annotation.DirtiesContext.ClassMode; -import org.springframework.test.context.ActiveProfiles; -import org.springframework.test.context.junit4.SpringRunner; import org.springframework.web.util.UriComponentsBuilder; import ch.qos.logback.classic.spi.ILoggingEvent; -@RunWith(SpringRunner.class) -@SpringBootTest(classes = CatalogDBApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) -@ActiveProfiles("test") -public class CatalogDBRestTest { +public class CatalogDBRestTest extends CatalogDbAdapterBaseTest { private static final String ECOMP_MSO_CATALOG_V2_VF_MODULES = "ecomp/mso/catalog/v2/vfModules"; @@ -81,9 +66,6 @@ public class CatalogDBRestTest { private static final String ECOMP_MSO_CATALOG_V2_SERVICE_RESOURCES = "ecomp/mso/catalog/v2/serviceResources"; - @LocalServerPort - private int port; - TestRestTemplate restTemplate = new TestRestTemplate("test", "test"); HttpHeaders headers = new HttpHeaders(); diff --git a/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/CloudConfigTest.java b/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/CloudConfigTest.java index 5a6ab747c5..f2f06d7f3d 100644 --- a/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/CloudConfigTest.java +++ b/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/CloudConfigTest.java @@ -27,6 +27,7 @@ import javax.ws.rs.core.Response; import org.junit.Test; import org.junit.runner.RunWith; import org.onap.so.adapters.catalogdb.CatalogDBApplication; +import org.onap.so.adapters.catalogdb.CatalogDbAdapterBaseTest; import org.onap.so.db.catalog.beans.AuthenticationType; import org.onap.so.db.catalog.beans.CloudIdentity; import org.onap.so.db.catalog.beans.CloudSite; @@ -44,10 +45,7 @@ import org.springframework.web.util.UriComponentsBuilder; import static com.shazam.shazamcrest.MatcherAssert.assertThat; import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs; -@RunWith(SpringRunner.class) -@SpringBootTest(classes = CatalogDBApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) -@ActiveProfiles("test") -public class CloudConfigTest { +public class CloudConfigTest extends CatalogDbAdapterBaseTest { protected TestRestTemplate restTemplate = new TestRestTemplate("test", "test"); diff --git a/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/CvnfcCatalogDbQueryTest.java b/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/CvnfcCatalogDbQueryTest.java index 898e8eadf1..78ac4ca095 100644 --- a/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/CvnfcCatalogDbQueryTest.java +++ b/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/CvnfcCatalogDbQueryTest.java @@ -36,6 +36,7 @@ import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.onap.so.adapters.catalogdb.CatalogDBApplication; +import org.onap.so.adapters.catalogdb.CatalogDbAdapterBaseTest; import org.onap.so.db.catalog.beans.ConfigurationResource; import org.onap.so.db.catalog.beans.CvnfcCustomization; import org.onap.so.db.catalog.beans.VfModule; @@ -56,10 +57,7 @@ import org.springframework.test.context.junit4.SpringRunner; import org.springframework.beans.BeanUtils; -@RunWith(SpringRunner.class) -@SpringBootTest(classes = CatalogDBApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) -@ActiveProfiles("test") -public class CvnfcCatalogDbQueryTest { +public class CvnfcCatalogDbQueryTest extends CatalogDbAdapterBaseTest { @Autowired private CvnfcCustomizationRepository cvnfcCustomizationRepository; diff --git a/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/NetworkCollectionCatalogDbQueryTest.java b/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/NetworkCollectionCatalogDbQueryTest.java index 89a7ba3d17..e6a281a375 100644 --- a/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/NetworkCollectionCatalogDbQueryTest.java +++ b/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/NetworkCollectionCatalogDbQueryTest.java @@ -35,6 +35,7 @@ import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.onap.so.adapters.catalogdb.CatalogDBApplication; +import org.onap.so.adapters.catalogdb.CatalogDbAdapterBaseTest; import org.onap.so.db.catalog.beans.BuildingBlockDetail; import org.onap.so.db.catalog.beans.CollectionNetworkResourceCustomization; import org.onap.so.db.catalog.beans.CollectionResourceCustomization; @@ -50,10 +51,7 @@ import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.ActiveProfiles; import org.springframework.test.context.junit4.SpringRunner; -@RunWith(SpringRunner.class) -@SpringBootTest(classes = CatalogDBApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) -@ActiveProfiles("test") -public class NetworkCollectionCatalogDbQueryTest { +public class NetworkCollectionCatalogDbQueryTest extends CatalogDbAdapterBaseTest { private static final Logger logger = LoggerFactory.getLogger(NetworkCollectionCatalogDbQueryTest.class); private static final String NETWORKCOLLECTION = "NetworkCollection"; diff --git a/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/db/catalog/client/CatalogDbClientTest.java b/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/db/catalog/client/CatalogDbClientTest.java index ea8cb5d616..461fce555f 100644 --- a/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/db/catalog/client/CatalogDbClientTest.java +++ b/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/db/catalog/client/CatalogDbClientTest.java @@ -31,6 +31,7 @@ import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.onap.so.adapters.catalogdb.CatalogDBApplication; +import org.onap.so.adapters.catalogdb.CatalogDbAdapterBaseTest; import org.onap.so.db.catalog.beans.AuthenticationType; import org.onap.so.db.catalog.beans.CloudIdentity; import org.onap.so.db.catalog.beans.CloudSite; @@ -59,10 +60,7 @@ import org.springframework.boot.web.server.LocalServerPort; import org.springframework.test.context.ActiveProfiles; import org.springframework.test.context.junit4.SpringRunner; -@RunWith(SpringRunner.class) -@SpringBootTest(classes = CatalogDBApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) -@ActiveProfiles("test") -public class CatalogDbClientTest { +public class CatalogDbClientTest extends CatalogDbAdapterBaseTest { public static final String MTN13 = "mtn13"; diff --git a/adapters/mso-openstack-adapters/pom.xml b/adapters/mso-openstack-adapters/pom.xml index 73f50ed908..9c3ef2578f 100644 --- a/adapters/mso-openstack-adapters/pom.xml +++ b/adapters/mso-openstack-adapters/pom.xml @@ -37,6 +37,24 @@ + + org.apache.maven.plugins + maven-surefire-plugin + + + default-test + + test + + + + **/AllTestsTestSuite.java + + suites + + + +