diff options
Diffstat (limited to 'adapters/mso-openstack-adapters/src/test')
10 files changed, 143 insertions, 95 deletions
diff --git a/adapters/mso-openstack-adapters/src/test/java/db/migration/CloudConfigMigrationTest.java b/adapters/mso-openstack-adapters/src/test/java/db/migration/CloudConfigMigrationTest.java index b29e1f57a7..d83e929d6e 100644 --- a/adapters/mso-openstack-adapters/src/test/java/db/migration/CloudConfigMigrationTest.java +++ b/adapters/mso-openstack-adapters/src/test/java/db/migration/CloudConfigMigrationTest.java @@ -1,3 +1,23 @@ +/*- + * ============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 db.migration; import org.junit.Assert; diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/network/MSONetworkAdapterImplTest.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/network/MSONetworkAdapterImplTest.java index e473c4c76a..707af7b6be 100644 --- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/network/MSONetworkAdapterImplTest.java +++ b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/network/MSONetworkAdapterImplTest.java @@ -23,8 +23,6 @@ package org.onap.so.adapters.network; import org.apache.http.HttpStatus; import org.junit.Test; import org.onap.so.adapters.vnf.BaseRestTestUtils; -import org.onap.so.cloud.CloudConfig; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpEntity; import org.springframework.http.HttpMethod; import org.springframework.http.ResponseEntity; @@ -62,14 +60,10 @@ public class MSONetworkAdapterImplTest extends BaseRestTestUtils { public static final String NETWORK_ID = "43173f6a-d699-414b-888f-ab243dda6dfe"; public static final String NETWORK_NAME = "vUSP-23804-T-01-dpa2b_EVUSP-CORE-VIF-TSIG0_net_0"; - @Autowired - private CloudConfig cloudConfig; + @Test public void createNetworkByModelNameNeutronModeGetNetworkException() throws IOException{ - - cloudConfig.getIdentityService("MTN13").setIdentityUrl("http://localhost:" + wireMockPort + "/v2.0"); - mockOpenStackResponseAccess(wireMockPort); mockOpenstackGet("/mockPublicUrl/v2.0/networks",HttpStatus.SC_INTERNAL_SERVER_ERROR); @@ -83,8 +77,6 @@ public class MSONetworkAdapterImplTest extends BaseRestTestUtils { @Test public void createNetworkByModelNameNeutronModeCreateNetworkException() throws IOException{ - cloudConfig.getIdentityService("MTN13").setIdentityUrl("http://localhost:" + wireMockPort + "/v2.0"); - mockOpenStackResponseAccess(wireMockPort); mockOpenStackGetNeutronNetwork_404("dvspg-VCE_VPE-mtjnj40avbc"); @@ -102,8 +94,6 @@ public class MSONetworkAdapterImplTest extends BaseRestTestUtils { @Test public void createNetworkByModelNameNeutronMode() throws IOException{ - cloudConfig.getIdentityService("MTN13").setIdentityUrl("http://localhost:" + wireMockPort + "/v2.0"); - mockOpenStackResponseAccess(wireMockPort); mockOpenStackGetNeutronNetwork_404("dvspg-VCE_VPE-mtjnj40avbc"); @@ -121,8 +111,6 @@ public class MSONetworkAdapterImplTest extends BaseRestTestUtils { @Test public void createNetworkByModelNameAlreadyExistNeutronMode() throws IOException{ - cloudConfig.getIdentityService("MTN13").setIdentityUrl("http://localhost:" + wireMockPort + "/v2.0"); - mockOpenStackResponseAccess(wireMockPort); mockOpenStackGetAllNeutronNetworks_200("OpenstackGetNeutronNetworks.json"); @@ -136,8 +124,6 @@ public class MSONetworkAdapterImplTest extends BaseRestTestUtils { @Test public void createNetworkByModelNameAlreadyExistNeutronModeFailIfExistTrue() throws IOException{ - cloudConfig.getIdentityService("MTN13").setIdentityUrl("http://localhost:" + wireMockPort + "/v2.0"); - mockOpenStackResponseAccess(wireMockPort); mockOpenStackGetAllNeutronNetworks_200("OpenstackGetNeutronNetworks.json"); @@ -151,8 +137,6 @@ public class MSONetworkAdapterImplTest extends BaseRestTestUtils { @Test public void createNetworkByModelNameHeatMode() throws IOException{ - cloudConfig.getIdentityService("MTN13").setIdentityUrl("http://localhost:" + wireMockPort + "/v2.0"); - mockOpenStackResponseAccess(wireMockPort); mockOpenStackGetStack_404("dvspg-VCE_VPE-mtjnj40avbc"); @@ -170,8 +154,6 @@ public class MSONetworkAdapterImplTest extends BaseRestTestUtils { @Test public void createNetworkByModelNameAlreadyExistHeatMode() throws IOException{ - cloudConfig.getIdentityService("MTN13").setIdentityUrl("http://localhost:" + wireMockPort + "/v2.0"); - mockOpenStackResponseAccess(wireMockPort); mockOpenStackPostStack_200("OpenstackResponse_Stack.json"); @@ -187,8 +169,6 @@ public class MSONetworkAdapterImplTest extends BaseRestTestUtils { @Test public void createNetworkByModelNameAlreadyExistHeatModeFailIfExistTrue() throws IOException{ - cloudConfig.getIdentityService("MTN13").setIdentityUrl("http://localhost:" + wireMockPort + "/v2.0"); - mockOpenStackResponseAccess(wireMockPort); mockOpenStackGetStackCreated_200("OpenstackResponse_Stack_Created.json", "dvspg-VCE_VPE-mtjnj40avbc"); @@ -203,8 +183,6 @@ public class MSONetworkAdapterImplTest extends BaseRestTestUtils { @Test public void createNetworkByModelNameHeatModeQueryNetworkException() throws IOException{ - cloudConfig.getIdentityService("MTN13").setIdentityUrl("http://localhost:" + wireMockPort + "/v2.0"); - mockOpenStackResponseAccess(wireMockPort); mockOpenstackGet("/mockPublicUrl/stacks/dvspg-VCE_VPE-mtjnj40avbc",HttpStatus.SC_INTERNAL_SERVER_ERROR); @@ -218,8 +196,6 @@ public class MSONetworkAdapterImplTest extends BaseRestTestUtils { @Test public void createNetworkByModelNameHeatModeCreateNetworkException() throws IOException{ - cloudConfig.getIdentityService("MTN13").setIdentityUrl("http://localhost:" + wireMockPort + "/v2.0"); - mockOpenStackResponseAccess(wireMockPort); mockOpenStackGetStack_404("dvspg-VCE_VPE-mtjnj40avbc"); @@ -235,8 +211,6 @@ public class MSONetworkAdapterImplTest extends BaseRestTestUtils { @Test public void createNetworkByModelNameCloudSiteNotPresentError() throws IOException{ - cloudConfig.getIdentityService("MTN13").setIdentityUrl("http://localhost:" + wireMockPort + "/v2.0"); - mockOpenStackResponseAccess(wireMockPort); mockOpenStackPostStack_200("OpenstackResponse_Stack.json"); @@ -252,8 +226,6 @@ public class MSONetworkAdapterImplTest extends BaseRestTestUtils { @Test public void deleteNetworkHeatModeSuccess() throws IOException{ - cloudConfig.getIdentityService("MTN13").setIdentityUrl("http://localhost:" + wireMockPort + "/v2.0"); - mockOpenStackResponseAccess(wireMockPort); mockOpenStackGetStackDeleteOrUpdateComplete_200("OpenstackResponse_Stack_DeleteComplete.json"); @@ -271,8 +243,6 @@ public class MSONetworkAdapterImplTest extends BaseRestTestUtils { @Test public void deleteNetworkDeleteStackException() throws IOException{ - cloudConfig.getIdentityService("MTN13").setIdentityUrl("http://localhost:" + wireMockPort + "/v2.0"); - mockOpenStackResponseAccess(wireMockPort); mockOpenStackGetStackDeleteOrUpdateComplete_200("OpenstackResponse_Stack_DeleteComplete.json"); @@ -290,8 +260,6 @@ public class MSONetworkAdapterImplTest extends BaseRestTestUtils { @Test public void deleteNetworkError() throws IOException{ - cloudConfig.getIdentityService("MTN13").setIdentityUrl("http://localhost:" + wireMockPort + "/v2.0"); - mockOpenStackResponseAccess(wireMockPort); mockOpenStackGetStackDeleteOrUpdateComplete_200("OpenstackResponse_Stack_DeleteComplete.json"); @@ -310,8 +278,6 @@ public class MSONetworkAdapterImplTest extends BaseRestTestUtils { @Test public void deleteNetworkNeureonMode() throws IOException{ - cloudConfig.getIdentityService("MTN13").setIdentityUrl("http://localhost:" + wireMockPort + "/v2.0"); - mockOpenStackResponseAccess(wireMockPort); mockOpenStackGetNeutronNetwork("GetNeutronNetwork.json",NETWORK_ID,HttpStatus.SC_OK); @@ -327,8 +293,6 @@ public class MSONetworkAdapterImplTest extends BaseRestTestUtils { @Test public void deleteNetworkNeutronModeDeleteStackException() throws IOException{ - cloudConfig.getIdentityService("MTN13").setIdentityUrl("http://localhost:" + wireMockPort + "/v2.0"); - mockOpenStackResponseAccess(wireMockPort); mockOpenStackGetNeutronNetwork("GetNeutronNetwork.json",NETWORK_ID,HttpStatus.SC_OK); @@ -346,8 +310,6 @@ public class MSONetworkAdapterImplTest extends BaseRestTestUtils { @Test public void updateNetworkNeutronModeSuccess() throws IOException{ - cloudConfig.getIdentityService("MTN13").setIdentityUrl("http://localhost:" + wireMockPort + "/v2.0"); - mockOpenStackResponseAccess(wireMockPort); mockOpenStackGetNeutronNetwork("GetNeutronNetwork.json",NETWORK_ID,HttpStatus.SC_OK); @@ -362,8 +324,6 @@ public class MSONetworkAdapterImplTest extends BaseRestTestUtils { @Test public void updateNetworkNeutronUpdateException() throws IOException{ - cloudConfig.getIdentityService("MTN13").setIdentityUrl("http://localhost:" + wireMockPort + "/v2.0"); - mockOpenStackResponseAccess(wireMockPort); mockOpenStackGetNeutronNetwork("GetNeutronNetwork.json",NETWORK_ID,HttpStatus.SC_OK); @@ -378,8 +338,6 @@ public class MSONetworkAdapterImplTest extends BaseRestTestUtils { @Test public void updateNetworkHeatUpdateException() throws IOException{ - cloudConfig.getIdentityService("MTN13").setIdentityUrl("http://localhost:" + wireMockPort + "/v2.0"); - mockOpenStackResponseAccess(wireMockPort); mockOpenStackGetStackCreated_200("OpenstackResponse_Stack_Created.json", NETWORK_NAME); @@ -395,8 +353,6 @@ public class MSONetworkAdapterImplTest extends BaseRestTestUtils { @Test public void updateNetworkHeatQueryException() throws IOException{ - cloudConfig.getIdentityService("MTN13").setIdentityUrl("http://localhost:" + wireMockPort + "/v2.0"); - mockOpenStackResponseAccess(wireMockPort); mockOpenStackGetStack_500(NETWORK_NAME); @@ -410,8 +366,6 @@ public class MSONetworkAdapterImplTest extends BaseRestTestUtils { @Test public void updateNetworkHeatStackNotFound() throws IOException{ - cloudConfig.getIdentityService("MTN13").setIdentityUrl("http://localhost:" + wireMockPort + "/v2.0"); - mockOpenStackResponseAccess(wireMockPort); mockOpenStackGetStack_404(NETWORK_NAME); @@ -425,8 +379,6 @@ public class MSONetworkAdapterImplTest extends BaseRestTestUtils { @Test public void updateNetworkNeutronQueryException() throws IOException{ - cloudConfig.getIdentityService("MTN13").setIdentityUrl("http://localhost:" + wireMockPort + "/v2.0"); - mockOpenStackResponseAccess(wireMockPort); mockOpenStackGetNeutronNetwork(NETWORK_ID,HttpStatus.SC_INTERNAL_SERVER_ERROR); @@ -440,8 +392,6 @@ public class MSONetworkAdapterImplTest extends BaseRestTestUtils { @Test public void updateNetworkNeutronStackNotFound() throws IOException{ - cloudConfig.getIdentityService("MTN13").setIdentityUrl("http://localhost:" + wireMockPort + "/v2.0"); - mockOpenStackResponseAccess(wireMockPort); mockOpenStackGetNeutronNetwork(NETWORK_ID,HttpStatus.SC_NOT_FOUND); @@ -455,8 +405,6 @@ public class MSONetworkAdapterImplTest extends BaseRestTestUtils { @Test public void queryNetworkHeatModesuccess() throws IOException{ - cloudConfig.getIdentityService("MTN13").setIdentityUrl("http://localhost:" + wireMockPort + "/v2.0"); - mockOpenStackResponseAccess(wireMockPort); mockOpenStackGetStackCreated_200("OpenstackResponse_Stack_Created.json", NETWORK_ID); @@ -470,8 +418,6 @@ public class MSONetworkAdapterImplTest extends BaseRestTestUtils { @Test public void queryNetworkHeatModeQueryException() throws IOException{ - cloudConfig.getIdentityService("MTN13").setIdentityUrl("http://localhost:" + wireMockPort + "/v2.0"); - mockOpenStackResponseAccess(wireMockPort); mockOpenStackGetStack_500(NETWORK_ID); @@ -485,8 +431,6 @@ public class MSONetworkAdapterImplTest extends BaseRestTestUtils { @Test public void queryNetworkNeutronModeSuccess() throws IOException{ - cloudConfig.getIdentityService("MTN13").setIdentityUrl("http://localhost:" + wireMockPort + "/v2.0"); - mockOpenStackResponseAccess(wireMockPort); mockOpenStackGetNeutronNetwork("GetNeutronNetwork.json",NETWORK_ID,HttpStatus.SC_OK); @@ -500,8 +444,6 @@ public class MSONetworkAdapterImplTest extends BaseRestTestUtils { @Test public void queryNetworkNeutronModeException() throws IOException{ - cloudConfig.getIdentityService("MTN13").setIdentityUrl("http://localhost:" + wireMockPort + "/v2.0"); - mockOpenStackResponseAccess(wireMockPort); mockOpenStackGetNeutronNetwork(NETWORK_ID,HttpStatus.SC_INTERNAL_SERVER_ERROR); diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/network/NetworkAdapterRestTest.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/network/NetworkAdapterRestTest.java index a29f2df96a..6123415b41 100644 --- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/network/NetworkAdapterRestTest.java +++ b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/network/NetworkAdapterRestTest.java @@ -58,7 +58,6 @@ import org.onap.so.adapters.nwrest.UpdateNetworkRequest; import org.onap.so.adapters.nwrest.UpdateNetworkResponse; import org.onap.so.adapters.vnf.BaseRestTestUtils; import org.onap.so.client.policy.JettisonStyleMapperProvider; -import org.onap.so.cloud.CloudConfig; import org.onap.so.entity.MsoRequest; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpEntity; @@ -71,8 +70,6 @@ import com.fasterxml.jackson.databind.JsonMappingException; public class NetworkAdapterRestTest extends BaseRestTestUtils { @Autowired - private CloudConfig cloudConfig; - @Autowired private JettisonStyleMapperProvider jettisonTypeObjectMapper; private static final String CLOUDSITE_ID = "mtn13"; private static final String TENANT_ID = "ba38bc24a2ef4fb2ad2810c894f1938f"; @@ -86,7 +83,6 @@ public class NetworkAdapterRestTest extends BaseRestTestUtils { @Test public void testCreateNetwork() throws JSONException, JsonParseException, JsonMappingException, IOException { - cloudConfig.getIdentityService("MTN13").setIdentityUrl("http://localhost:" + wireMockPort + "/v2.0"); CreateNetworkRequest request = new CreateNetworkRequest(); request.setBackout(true); request.setSkipAAI(true); @@ -128,7 +124,7 @@ public class NetworkAdapterRestTest extends BaseRestTestUtils { @Test public void testCreateNetwork_JSON() throws JSONException, JsonParseException, JsonMappingException, IOException { - cloudConfig.getIdentityService("MTN13").setIdentityUrl("http://localhost:" + wireMockPort + "/v2.0"); + mockOpenStackResponseAccess(wireMockPort); @@ -146,7 +142,7 @@ public class NetworkAdapterRestTest extends BaseRestTestUtils { ResponseEntity<CreateNetworkResponse> response = restTemplate.exchange( createURLWithPort("/services/rest/v1/networks"), HttpMethod.POST, entity, CreateNetworkResponse.class); - + CreateNetworkResponse expectedResponse = jettisonTypeObjectMapper.getMapper().readValue( new File("src/test/resources/__files/CreateNetworkResponse2.json"), CreateNetworkResponse.class); @@ -154,10 +150,11 @@ public class NetworkAdapterRestTest extends BaseRestTestUtils { assertThat(response.getBody(), sameBeanAs(expectedResponse)); } + + @Test public void testDeleteNetwork() throws IOException{ - cloudConfig.getIdentityService("MTN13").setIdentityUrl("http://localhost:" + wireMockPort + "/v2.0"); DeleteNetworkRequest request = new DeleteNetworkRequest(); MsoRequest msoReq = new MsoRequest(); @@ -197,7 +194,6 @@ public class NetworkAdapterRestTest extends BaseRestTestUtils { @Test public void testQueryNetwork_Exception() throws IOException{ - cloudConfig.getIdentityService("MTN13").setIdentityUrl("http://localhost:" + wireMockPort + "/v2.0"); MsoRequest msoReq = new MsoRequest(); msoReq.setRequestId(MSO_REQUEST_ID); msoReq.setServiceInstanceId(MSO_SERVICE_INSTANCE_ID); @@ -216,7 +212,6 @@ public class NetworkAdapterRestTest extends BaseRestTestUtils { @Test public void testQueryNetwork() throws IOException{ - cloudConfig.getIdentityService("MTN13").setIdentityUrl("http://localhost:" + wireMockPort + "/v2.0"); mockOpenStackResponseAccess(wireMockPort); mockOpenStackGetStackVfModule_200(); @@ -235,7 +230,6 @@ public class NetworkAdapterRestTest extends BaseRestTestUtils { @Test public void testUpdateNetwork() throws IOException{ - cloudConfig.getIdentityService("MTN13").setIdentityUrl("http://localhost:" + wireMockPort + "/v2.0"); UpdateNetworkRequest request = new UpdateNetworkRequest(); MsoRequest msoReq = new MsoRequest(); @@ -275,6 +269,33 @@ public class NetworkAdapterRestTest extends BaseRestTestUtils { assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value()); } + @Test + public void testCreateNetworkCNRC_JSON() throws JSONException, JsonParseException, JsonMappingException, IOException { + + mockOpenStackResponseAccess(wireMockPort); + + mockOpenStackPostPublicUrlWithBodyFile_200(); + + mockOpenStackGetStackCreatedAppC_200(); + + mockOpenStackGetStackAppC_404(); + + headers.add("Content-Type", MediaType.APPLICATION_JSON); + headers.add("Accept", MediaType.APPLICATION_JSON); + + String request = readJsonFileAsString("src/test/resources/CreateNetwork3.json"); + HttpEntity<String> entity = new HttpEntity<String>(request, headers); + + ResponseEntity<CreateNetworkResponse> response = restTemplate.exchange( + createURLWithPort("/services/rest/v1/networks"), HttpMethod.POST, entity, CreateNetworkResponse.class); + + CreateNetworkResponse expectedResponse = jettisonTypeObjectMapper.getMapper().readValue( + new File("src/test/resources/__files/CreateNetworkResponse3.json"), CreateNetworkResponse.class); + + assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value()); + assertThat(response.getBody(), sameBeanAs(expectedResponse)); + } + @Override protected String readJsonFileAsString(String fileLocation) throws JsonParseException, JsonMappingException, IOException{ return new String(Files.readAllBytes(Paths.get(fileLocation))); diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tenant/TenantAdapterRestTest.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tenant/TenantAdapterRestTest.java index ea21687bc5..405118cb30 100644 --- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tenant/TenantAdapterRestTest.java +++ b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tenant/TenantAdapterRestTest.java @@ -53,7 +53,6 @@ import org.onap.so.adapters.tenantrest.DeleteTenantRequest; import org.onap.so.adapters.tenantrest.DeleteTenantResponse; import org.onap.so.adapters.vnf.BaseRestTestUtils; import org.onap.so.client.policy.JettisonStyleMapperProvider; -import org.onap.so.cloud.CloudConfig; import org.onap.so.entity.MsoRequest; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpEntity; @@ -66,14 +65,11 @@ import com.fasterxml.jackson.databind.JsonMappingException; public class TenantAdapterRestTest extends BaseRestTestUtils { @Autowired - private CloudConfig cloudConfig; - @Autowired private JettisonStyleMapperProvider jettisonTypeObjectMapper; @Test public void testCreateTenantCreated() throws JsonParseException, JsonMappingException, IOException { - cloudConfig.getIdentityService("MTN13").setIdentityUrl("http://localhost:" + wireMockPort + "/v2.0"); CreateTenantRequest request = new CreateTenantRequest(); String cloudSiteId = "MTN13"; String requestId = "62265093-277d-4388-9ba6-449838ade586"; @@ -125,7 +121,6 @@ public class TenantAdapterRestTest extends BaseRestTestUtils { @Test public void testCreateTenantExists() throws JsonParseException, JsonMappingException, IOException { - cloudConfig.getIdentityService("MTN13").setIdentityUrl("http://localhost:" + wireMockPort + "/v2.0"); CreateTenantRequest request = new CreateTenantRequest(); String cloudSiteId = "MTN13"; String requestId = "62265093-277d-4388-9ba6-449838ade586"; @@ -171,7 +166,6 @@ public class TenantAdapterRestTest extends BaseRestTestUtils { @Test public void testDeleteTenant() throws IOException { - cloudConfig.getIdentityService("MTN13").setIdentityUrl("http://localhost:" + wireMockPort + "/v2.0"); DeleteTenantRequest request = new DeleteTenantRequest(); String cloudSiteId = "mtn13"; String tenantId = "tenantId"; @@ -210,7 +204,6 @@ public class TenantAdapterRestTest extends BaseRestTestUtils { @Test public void testDeleteTenantFails() throws IOException { - cloudConfig.getIdentityService("MTN13").setIdentityUrl("http://localhost:" + wireMockPort + "/v2.0"); DeleteTenantRequest request = new DeleteTenantRequest(); String cloudSiteId = "mtn13"; String tenantId = "tenantId"; @@ -247,7 +240,6 @@ public class TenantAdapterRestTest extends BaseRestTestUtils { @Test public void testQuaryTenant() { - cloudConfig.getIdentityService("MTN13").setIdentityUrl("http://localhost:" + wireMockPort + "/v2.0"); } diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/BaseRestTestUtils.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/BaseRestTestUtils.java index d2b6d4f633..a2f57ef06f 100644 --- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/BaseRestTestUtils.java +++ b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/BaseRestTestUtils.java @@ -29,6 +29,7 @@ import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.onap.so.adapters.openstack.MsoOpenstackAdaptersApplication; +import org.onap.so.cloud.CloudConfig; import org.onap.so.db.catalog.beans.AuthenticationType; import org.onap.so.db.catalog.beans.CloudIdentity; import org.onap.so.db.catalog.beans.CloudSite; @@ -63,7 +64,9 @@ import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo; public class BaseRestTestUtils { @Value("${wiremock.server.port}") protected int wireMockPort; - + @Autowired + CloudConfig cloudConfig; + @Autowired @Qualifier("JettisonStyle") protected TestRestTemplate restTemplate; @@ -134,7 +137,7 @@ public class BaseRestTestUtils { .withBody(getBody(mapper.writeValueAsString(cloudSite),wireMockPort, "")) .withHeader(org.apache.http.HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) .withStatus(HttpStatus.SC_OK))); - stubFor(get(urlPathEqualTo("/cloudSite/default")).willReturn(aResponse() + stubFor(get(urlPathEqualTo("/cloudSite/DEFAULT")).willReturn(aResponse() .withBody(getBody(mapper.writeValueAsString(cloudSite),wireMockPort, "")) .withHeader(org.apache.http.HttpHeaders.CONTENT_TYPE,MediaType.APPLICATION_JSON) .withStatus(HttpStatus.SC_OK))); @@ -142,6 +145,8 @@ public class BaseRestTestUtils { .withBody(getBody(mapper.writeValueAsString(identity),wireMockPort, "")) .withHeader(org.apache.http.HttpHeaders.CONTENT_TYPE,MediaType.APPLICATION_JSON) .withStatus(HttpStatus.SC_OK))); + cloudConfig.getCloudSite("MTN13").get().getIdentityService().setIdentityUrl("http://localhost:" + wireMockPort + "/v2.0"); + } protected static String getBody(String body, int port, String urlPath) throws IOException { diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/VnfAdapterRestTest.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/VnfAdapterRestTest.java index 93841a5037..c502620920 100644 --- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/VnfAdapterRestTest.java +++ b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/VnfAdapterRestTest.java @@ -37,7 +37,6 @@ import org.onap.so.adapters.vnfrest.UpdateVfModuleResponse; import org.onap.so.adapters.vnfrest.VfModuleExceptionResponse; import org.onap.so.adapters.vnfrest.VfModuleRollback; import org.onap.so.client.policy.JettisonStyleMapperProvider; -import org.onap.so.cloud.CloudConfig; import org.onap.so.entity.MsoRequest; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpEntity; @@ -75,8 +74,7 @@ import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackResponseAccess; public class VnfAdapterRestTest extends BaseRestTestUtils { - @Autowired - private CloudConfig cloudConfig; + @Autowired private JettisonStyleMapperProvider jettisonTypeObjectMapper; private static final String MESSAGE_ID = "62265093-277d-4388-9ba6-449838ade586-1517252396874"; @@ -164,7 +162,6 @@ public class VnfAdapterRestTest extends BaseRestTestUtils { public void testCreateVfModuleWithEnableBridgeNull() throws JSONException, JsonParseException, JsonMappingException, IOException { - cloudConfig.getIdentityService("MTN13").setIdentityUrl("http://localhost:" + wireMockPort + "/v2.0"); CreateVfModuleRequest request = new CreateVfModuleRequest(); request.setBackout(true); request.setSkipAAI(true); @@ -232,7 +229,6 @@ public class VnfAdapterRestTest extends BaseRestTestUtils { @Test public void testCreateVfModuleFail() throws IOException{ - cloudConfig.getIdentityService("MTN13").setIdentityUrl("http://localhost:" + wireMockPort + "/v2.0"); CreateVfModuleRequest request = new CreateVfModuleRequest(); request.setBackout(true); request.setSkipAAI(true); @@ -331,7 +327,6 @@ public class VnfAdapterRestTest extends BaseRestTestUtils { @Test public void testDeleteVfModule() throws IOException{ - cloudConfig.getIdentityService("MTN13").setIdentityUrl("http://localhost:" + wireMockPort + "/v2.0"); DeleteVfModuleRequest request = new DeleteVfModuleRequest(); MsoRequest msoRequest = new MsoRequest(); String vfModuleStackId = "stackId"; @@ -382,7 +377,6 @@ public class VnfAdapterRestTest extends BaseRestTestUtils { @Test public void testUpdateVfModule() throws IOException{ - cloudConfig.getIdentityService("MTN13").setIdentityUrl("http://localhost:" + wireMockPort + "/v2.0"); UpdateVfModuleRequest request = new UpdateVfModuleRequest(); MsoRequest msoRequest = new MsoRequest(); String vfModuleStackId = "vfModuleStackId"; @@ -449,8 +443,7 @@ public class VnfAdapterRestTest extends BaseRestTestUtils { @Test public void testRollbackVfModule() throws IOException { - cloudConfig.getIdentityService("MTN13").setIdentityUrl("http://localhost:" + wireMockPort + "/v2.0"); - + MsoRequest msoRequest = new MsoRequest(); msoRequest.setRequestId(MSO_REQUEST_ID); msoRequest.setServiceInstanceId(MSO_SERVICE_INSTANCE_ID); @@ -488,7 +481,6 @@ public class VnfAdapterRestTest extends BaseRestTestUtils { @Test public void testQueryVfModule() throws IOException{ - cloudConfig.getIdentityService("MTN13").setIdentityUrl("http://localhost:" + wireMockPort + "/v2.0"); String testUrl = createURLWithPort("/services/rest/v1/vnfs/" + AAI_VNF_ID + "/vf-modules/" + VF_MODULE_ID); String testUri = UriBuilder.fromPath("/services/rest/v1/vnfs/" + AAI_VNF_ID + "/vf-modules/" + VF_MODULE_ID ) .host("localhost").port(wireMockPort).scheme("http") @@ -512,7 +504,6 @@ public class VnfAdapterRestTest extends BaseRestTestUtils { } private CreateVfModuleRequest populateCreateVfModuleRequest(){ - cloudConfig.getIdentityService("MTN13").setIdentityUrl("http://localhost:" + wireMockPort + "/v2.0"); CreateVfModuleRequest request = new CreateVfModuleRequest(); request.setBackout(true); request.setSkipAAI(true); diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/VolumeGroupAdapterCommon.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/VolumeGroupAdapterCommon.java index d8177363f4..68982799f1 100644 --- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/VolumeGroupAdapterCommon.java +++ b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/VolumeGroupAdapterCommon.java @@ -25,17 +25,14 @@ import org.onap.so.adapters.vnfrest.DeleteVolumeGroupRequest; import org.onap.so.adapters.vnfrest.RollbackVolumeGroupRequest; import org.onap.so.adapters.vnfrest.UpdateVolumeGroupRequest; import org.onap.so.adapters.vnfrest.VolumeGroupRollback; -import org.onap.so.cloud.CloudConfig; import org.onap.so.entity.MsoRequest; -import org.springframework.beans.factory.annotation.Autowired; import java.util.HashMap; import java.util.Map; public class VolumeGroupAdapterCommon extends BaseRestTestUtils { - @Autowired - protected CloudConfig cloudConfig; + protected static final String MSO_REQUEST_ID = "62265093-277d-4388-9ba6-449838ade586"; protected static final String MSO_SERVICE_INSTANCE_ID = "4147e06f-1b89-49c5-b21f-4faf8dc9805a"; @@ -93,7 +90,6 @@ public class VolumeGroupAdapterCommon extends BaseRestTestUtils { } protected CreateVolumeGroupRequest buildCreateVfModuleRequest() { - cloudConfig.getIdentityService("MTN13").setIdentityUrl("http://localhost:" + wireMockPort + "/v2.0"); CreateVolumeGroupRequest request = new CreateVolumeGroupRequest(); request.setCloudSiteId(CLOUDSITE_ID); request.setTenantId(TENANT_ID); diff --git a/adapters/mso-openstack-adapters/src/test/resources/CreateNetwork3.json b/adapters/mso-openstack-adapters/src/test/resources/CreateNetwork3.json new file mode 100644 index 0000000000..accd9e9a54 --- /dev/null +++ b/adapters/mso-openstack-adapters/src/test/resources/CreateNetwork3.json @@ -0,0 +1,42 @@ +{ + "createNetworkRequest": { + "skipAAI": true, + "messageId": "c4c44af4-4310-4d8b-a1eb-656fc99fe709", + "synchronous": true, + "cloudSiteId": "mtn13", + "tenantId": "ba38bc24a2ef4fb2ad2810c894f1938f", + "networkId": "da886914-efb2-4917-b335-c8381528d90b", + "networkName": "APP-C-24595-T-IST-04AShared_untrusted_vDBE_net_3", + "networkType": "CONTRAIL30_BASIC", + "modelCustomizationUuid": "3bdbb104-ffff-483e-9f8b-c095b3d30844", + "networkTechnology": "NEUTRON", + "subnets": [{ + "subnetName": "APP-C-24595-T-IST-04AShared_untrusted_vDBE_net_3_subnet_1", + "subnetId": "da60501d-9aa8-48d2-99b7-26644fa01093", + "cidr": "20", + "gatewayIp": "", + "ipVersion": "4", + "enableDHCP": false, + "addrFromStart": true, + "hostRoutes": [] + }], + "providerVlanNetwork": { + "physicalNetworkName": "FALSE", + "vlans": [] + }, + "contrailNetwork": { + "shared": "false", + "external": "false", + "routeTargets": [], + "policyFqdns": [], + "routeTableFqdns": [] + }, + "failIfExists": true, + "backout": false, + "msoRequest": { + "requestId": "5349f419-b3e9-4546-b3a1-094bd568d6b7", + "serviceInstanceId": "cf965caf-a003-4189-abf9-e0ed77056dd6" + }, + "contrailRequest": false + } +}
\ No newline at end of file diff --git a/adapters/mso-openstack-adapters/src/test/resources/__files/CreateNetworkResponse3.json b/adapters/mso-openstack-adapters/src/test/resources/__files/CreateNetworkResponse3.json new file mode 100644 index 0000000000..2e5517cebb --- /dev/null +++ b/adapters/mso-openstack-adapters/src/test/resources/__files/CreateNetworkResponse3.json @@ -0,0 +1,25 @@ +{ + "createNetworkResponse": { + "networkId": "da886914-efb2-4917-b335-c8381528d90b", + "neutronNetworkId": null, + "networkStackId": "stackname/stackId", + "networkFqdn": null, + "networkCreated": true, + "subnetMap": { + + }, + "rollback": { + "networkStackId": "stackname/stackId", + "tenantId": "ba38bc24a2ef4fb2ad2810c894f1938f", + "cloudId": "mtn13", + "networkType": "CONTRAIL30_BASIC", + "modelCustomizationUuid": "3bdbb104-ffff-483e-9f8b-c095b3d30844", + "networkCreated": true, + "msoRequest": { + "requestId": "5349f419-b3e9-4546-b3a1-094bd568d6b7", + "serviceInstanceId": "cf965caf-a003-4189-abf9-e0ed77056dd6" + } + }, + "messageId": "c4c44af4-4310-4d8b-a1eb-656fc99fe709" + } +}
\ No newline at end of file diff --git a/adapters/mso-openstack-adapters/src/test/resources/data.sql b/adapters/mso-openstack-adapters/src/test/resources/data.sql index d16ca4528c..960f483e46 100644 --- a/adapters/mso-openstack-adapters/src/test/resources/data.sql +++ b/adapters/mso-openstack-adapters/src/test/resources/data.sql @@ -71,6 +71,20 @@ insert into network_resource_customization(model_customization_uuid, model_insta ('3bdbb104-476c-483e-9f8b-c095b3d30844', 'CONTRAIL30_BASIC', '', 'CONTRAIL30_BASIC', '', '', '2017-04-19 14:28:32', '10b36f65-f4e6-4be6-ae49-9596dc1c4789'), ('3bdbb104-476c-483e-9f8b-c095b3d3068c', 'CONTRAIL31_BASIC', '', 'CONTRAIL31_BASIC', '', '', '2017-04-19 14:28:32', '10b36f65-f4e6-4be6-ae49-9596dc1c4790'); +insert into instance_group(model_uuid, model_name, model_invariant_uuid, model_version, tosca_node_type, role, object_type, cr_model_uuid, instance_group_type) values +('21e43a7c-d823-4f5b-a427-5235f63035ff', 'dror_cr_network_resource_1806..NetworkCollection..0', '81c94263-c01e-4046-b0c7-51878d658eab', '1', 'org.openecomp.groups.NetworkCollection', 'SUB_INTERFACE', 'L3_NETWORK', '5e3fca45-e2d8-4987-bef1-016d9bda1a8c', 'L3_NETWORK'); + +insert into collection_resource(model_uuid, model_name, model_invariant_uuid, model_version, tosca_node_type, description) values +('5e3fca45-e2d8-4987-bef1-016d9bda1a8c', 'Dror_CR_Network_Resource_1806', 'fe243154-ac18-405f-94c2-ef629d26b8bb', '2.0', 'org.openecomp.resource.cr.DrorCrNetworkResource1806', 'Creation date: 07/25/18'); + +insert into collection_resource_customization(model_customization_uuid, model_instance_name, role, object_type, function, collection_resource_type, cr_model_uuid) values +('c51096a4-6081-41f4-a540-3ed015a8064a', 'Dror_CR_Network_Resource_1806', 'Dror2', 'NetworkCollection', 'Dror1', 'Dror3', '5e3fca45-e2d8-4987-bef1-016d9bda1a8c'); + +insert into collection_network_resource_customization(model_customization_uuid, model_instance_name, network_technology, network_type, network_role, network_scope, network_resource_model_uuid, instance_group_model_uuid, crc_model_customization_uuid) values +('3bdbb104-ffff-483e-9f8b-c095b3d30844', 'ExtVL 0', 'CONTRAIL', 'L3-NETWORK', '', '', '10b36f65-f4e6-4be6-ae49-9596dc1c4789', '21e43a7c-d823-4f5b-a427-5235f63035ff', 'c51096a4-6081-41f4-a540-3ed015a8064a'), +('3bdbb104-ffff-483e-9f8b-c095b3d3068c', 'ExtVL 0', 'CONTRAIL', 'L3-NETWORK', '', '', '10b36f65-f4e6-4be6-ae49-9596dc1c4790', '21e43a7c-d823-4f5b-a427-5235f63035ff', 'c51096a4-6081-41f4-a540-3ed015a8064a'); + + insert into vnf_resource(orchestration_mode, description, creation_timestamp, model_uuid, aic_version_min, aic_version_max, model_invariant_uuid, model_version, model_name, tosca_node_type, heat_template_artifact_uuid) values ('HEAT', '1607 vSAMP10a - inherent network', '2017-04-14 21:46:28', 'ff2ae348-214a-11e7-93ae-92361f002672', '', '', '2fff5b20-214b-11e7-93ae-92361f002671', '2.0', 'vSAMP10a', 'VF', null); |