diff options
Diffstat (limited to 'adapters')
31 files changed, 166 insertions, 180 deletions
diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloud/CloudConfig.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloud/CloudConfig.java index 5560282fda..b32ca1833f 100644 --- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloud/CloudConfig.java +++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloud/CloudConfig.java @@ -24,7 +24,6 @@ import java.util.Optional; import com.fasterxml.jackson.annotation.JsonRootName; -import org.onap.so.db.catalog.beans.CloudIdentity; import org.onap.so.db.catalog.beans.CloudSite; import org.onap.so.db.catalog.beans.CloudifyManager; import org.onap.so.db.catalog.client.CatalogDbClient; @@ -51,7 +50,7 @@ import org.springframework.stereotype.Component; public class CloudConfig { private static final String CLOUD_SITE_VERSION = "2.5"; - private static final String DEFAULT_CLOUD_SITE_ID = "default"; + private static final String DEFAULT_CLOUD_SITE_ID = "DEFAULT"; @Autowired private CatalogDbClient catalogDbClient; @@ -108,17 +107,6 @@ public class CloudConfig { } } - /** - * Get a specific CloudIdentity, based on an ID. - * - * @param id - * the ID to match - * @return a CloudIdentity, or null of no match found - */ - public CloudIdentity getIdentityService(String id) { - return catalogDbClient.getCloudIdentity(id); - } - /** * Get a specific CloudifyManager, based on an ID. * @param id the ID to match diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloudify/utils/MsoCloudifyUtils.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloudify/utils/MsoCloudifyUtils.java index 59996fa3d1..677f6395ff 100644 --- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloudify/utils/MsoCloudifyUtils.java +++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloudify/utils/MsoCloudifyUtils.java @@ -1376,9 +1376,9 @@ public class MsoCloudifyUtils extends MsoCommonUtils implements VduPlugin{ protected OpenstackConfig getOpenstackConfig (CloudSite cloudSite, String tenantId) { OpenstackConfig openstackConfig = new OpenstackConfig(); openstackConfig.setRegion (cloudSite.getRegionId()); - openstackConfig.setAuthUrl (cloudConfig.getIdentityService(cloudSite.getIdentityServiceId()).getIdentityUrl()); - openstackConfig.setUsername (cloudConfig.getIdentityService(cloudSite.getIdentityServiceId()).getMsoId()); - openstackConfig.setPassword (CryptoUtils.decryptCloudConfigPassword(cloudConfig.getIdentityService(cloudSite.getIdentityServiceId()).getMsoPass())); + openstackConfig.setAuthUrl (cloudSite.getIdentityService().getIdentityUrl()); + openstackConfig.setUsername (cloudSite.getIdentityService().getMsoId()); + openstackConfig.setPassword (CryptoUtils.decryptCloudConfigPassword(cloudSite.getIdentityService().getMsoPass())); openstackConfig.setTenantName (tenantId); return openstackConfig; } diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoHeatUtils.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoHeatUtils.java index 1d5b1a006d..6b66970ea0 100644 --- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoHeatUtils.java +++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoHeatUtils.java @@ -382,7 +382,7 @@ public class MsoHeatUtils extends MsoCommonUtils implements VduPlugin{ OpenStackRequest <Stack> request = heatClient.getStacks ().create (stack); // Begin X-Auth-User // Obtain an MSO token for the tenant - CloudIdentity cloudIdentity = cloudConfig.getIdentityService(cloudSite.getIdentityServiceId()); + CloudIdentity cloudIdentity = cloudSite.getIdentityService(); // cloudIdentity.getMsoId(), cloudIdentity.getMsoPass() //req request.header ("X-Auth-User", cloudIdentity.getMsoId ()); @@ -965,7 +965,7 @@ public class MsoHeatUtils extends MsoCommonUtils implements VduPlugin{ } // Obtain an MSO token for the tenant - CloudIdentity cloudIdentity = cloudConfig.getIdentityService(cloudSite.getIdentityServiceId()); + CloudIdentity cloudIdentity = cloudSite.getIdentityService(); LOGGER.debug("Found: " + cloudIdentity.toString()); MsoTenantUtils tenantUtils = tenantUtilsFactory.getTenantUtilsByServerType(cloudIdentity.getIdentityServerType()); String keystoneUrl = tenantUtils.getKeystoneUrl(cloudId, cloudIdentity); @@ -1488,7 +1488,7 @@ public class MsoHeatUtils extends MsoCommonUtils implements VduPlugin{ String keystone_url = null; try { CloudSite cloudSite = cloudConfig.getCloudSite(cloudSiteId).orElseThrow(() -> new MsoCloudSiteNotFound(cloudSiteId)); - CloudIdentity cloudIdentity = cloudConfig.getIdentityService(cloudSite.getIdentityServiceId()); + CloudIdentity cloudIdentity = cloudSite.getIdentityService(); keystone_url = cloudIdentity.getIdentityUrl(); } catch (Exception e) { throw new MsoCloudSiteNotFound(cloudSiteId); diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoKeystoneUtils.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoKeystoneUtils.java index 2f2a457bed..759c116e05 100644 --- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoKeystoneUtils.java +++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoKeystoneUtils.java @@ -138,7 +138,7 @@ public class MsoKeystoneUtils extends MsoTenantUtils { // Add MSO User to the tenant as a member and // apply tenant metadata if supported by the cloud site try { - CloudIdentity cloudIdentity = cloudConfig.getIdentityService(cloudSiteOpt.get().getIdentityServiceId()); + CloudIdentity cloudIdentity = cloudSiteOpt.get().getIdentityService(); User msoUser = findUserByNameOrId (keystoneAdminClient, cloudIdentity.getMsoId ()); Role memberRole = findRoleByNameOrId (keystoneAdminClient, cloudIdentity.getMemberRole ()); @@ -221,7 +221,7 @@ public class MsoKeystoneUtils extends MsoTenantUtils { } Map <String, String> metadata = new HashMap <String, String> (); - if (cloudConfig.getIdentityService(cloudSite.getIdentityServiceId()).getTenantMetadata ()) { + if (cloudSite.getIdentityService().getTenantMetadata ()) { OpenStackRequest <Metadata> request = keystoneAdminClient.tenants ().showMetadata (tenant.getId ()); Metadata tenantMetadata = executeAndRecordOpenstackRequest (request); if (tenantMetadata != null) { @@ -267,7 +267,7 @@ public class MsoKeystoneUtils extends MsoTenantUtils { } Map <String, String> metadata = new HashMap <String, String> (); - if (cloudConfig.getIdentityService(cloudSite.getIdentityServiceId()).getTenantMetadata ()) { + if (cloudSite.getIdentityService().getTenantMetadata ()) { OpenStackRequest <Metadata> request = keystoneAdminClient.tenants ().showMetadata (tenant.getId ()); Metadata tenantMetadata = executeAndRecordOpenstackRequest (request); if (tenantMetadata != null) { @@ -401,7 +401,7 @@ public class MsoKeystoneUtils extends MsoTenantUtils { * @return an authenticated Keystone object */ public Keystone getKeystoneAdminClient (CloudSite cloudSite) throws MsoException { - CloudIdentity cloudIdentity = cloudConfig.getIdentityService(cloudSite.getIdentityServiceId()); + CloudIdentity cloudIdentity = cloudSite.getIdentityService(); String cloudId = cloudIdentity.getId (); String adminTenantName = cloudIdentity.getAdminTenant (); diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoNeutronUtils.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoNeutronUtils.java index 18ed94112c..a9f0a39235 100644 --- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoNeutronUtils.java +++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoNeutronUtils.java @@ -375,7 +375,7 @@ public class MsoNeutronUtils extends MsoCommonUtils } // Obtain an MSO token for the tenant from the identity service - CloudIdentity cloudIdentity = cloudConfig.getIdentityService(cloudSite.getIdentityServiceId()); + CloudIdentity cloudIdentity = cloudSite.getIdentityService(); MsoTenantUtils tenantUtils = tenantUtilsFactory.getTenantUtilsByServerType(cloudIdentity.getIdentityServerType()); final String keystoneUrl = tenantUtils.getKeystoneUrl(cloudId, cloudIdentity); Keystone keystoneTenantClient = new Keystone(keystoneUrl); diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoTenantUtilsFactory.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoTenantUtilsFactory.java index da9f79aa89..79934ccd28 100644 --- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoTenantUtilsFactory.java +++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoTenantUtilsFactory.java @@ -42,7 +42,7 @@ public class MsoTenantUtilsFactory { CloudSite cloudSite = cloudConfig.getCloudSite(cloudSiteId).orElseThrow( () -> new MsoCloudSiteNotFound(cloudSiteId)); - return getTenantUtilsByServerType(cloudConfig.getIdentityService(cloudSite.getIdentityServiceId()).getIdentityServerType()); + return getTenantUtilsByServerType(cloudSite.getIdentityService().getIdentityServerType()); } public MsoTenantUtils getTenantUtilsByServerType(ServerType serverType) { 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 36a50fd77e..087ac6f17b 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 @@ -76,7 +76,7 @@ public abstract class BaseTest extends TestDataSetup { .withBody(getBody(mapper.writeValueAsString(cloudSite),wireMockPort, "")) .withHeader(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(HttpHeaders.CONTENT_TYPE,MediaType.APPLICATION_JSON) .withStatus(HttpStatus.SC_OK))); diff --git a/adapters/mso-adapter-utils/src/test/java/org/onap/so/adapter_utils/tests/MsoHeatUtilsRefactorTest.java b/adapters/mso-adapter-utils/src/test/java/org/onap/so/adapter_utils/tests/MsoHeatUtilsRefactorTest.java index 012805e774..c3777ca810 100644 --- a/adapters/mso-adapter-utils/src/test/java/org/onap/so/adapter_utils/tests/MsoHeatUtilsRefactorTest.java +++ b/adapters/mso-adapter-utils/src/test/java/org/onap/so/adapter_utils/tests/MsoHeatUtilsRefactorTest.java @@ -74,7 +74,7 @@ public class MsoHeatUtilsRefactorTest extends BaseTest { cloudSite.setIdentityService(identity); - stubFor(get(urlPathEqualTo("/cloudSite/default")).willReturn(aResponse() + stubFor(get(urlPathEqualTo("/cloudSite/DEFAULT")).willReturn(aResponse() .withBody(getBody(mapper.writeValueAsString(cloudSite),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/cloud/CloudConfigTest.java b/adapters/mso-adapter-utils/src/test/java/org/onap/so/cloud/CloudConfigTest.java index c6db998b2b..ea25fe580d 100644 --- a/adapters/mso-adapter-utils/src/test/java/org/onap/so/cloud/CloudConfigTest.java +++ b/adapters/mso-adapter-utils/src/test/java/org/onap/so/cloud/CloudConfigTest.java @@ -56,26 +56,6 @@ public class CloudConfigTest extends BaseTest{ assertEquals ("3.0", site1.getCloudVersion()); } - - /** - * This method implements a test for the getIdentityServices method. - * @throws MsoException - */ - @Test - public final void testGetIdentityServices () throws MsoException { - - CloudIdentity identity1 = con.getIdentityService("mtn13"); - - assertEquals("m93945", identity1.getMsoId()); - assertEquals("93937EA01B94A10A49279D4572B48369", identity1.getMsoPass()); - assertEquals("admin", identity1.getAdminTenant()); - assertEquals("admin", identity1.getMemberRole()); - assertTrue(identity1.getIdentityUrl().contains("http://localhost:")); - assertEquals(ServerType.KEYSTONE, identity1.getIdentityServerType()); - assertEquals(AuthenticationType.USERNAME_PASSWORD, identity1.getIdentityAuthenticationType()); - - } - /** * This method implements a test for the getCloudSite method. */ diff --git a/adapters/mso-adapters-rest-interface/.gitignore b/adapters/mso-adapters-rest-interface/.gitignore new file mode 100644 index 0000000000..ae3c172604 --- /dev/null +++ b/adapters/mso-adapters-rest-interface/.gitignore @@ -0,0 +1 @@ +/bin/ diff --git a/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/QueryServiceNetworks.java b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/QueryServiceNetworks.java index 4afc24ea10..a2256f724a 100644 --- a/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/QueryServiceNetworks.java +++ b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/QueryServiceNetworks.java @@ -4,6 +4,8 @@ * ================================================================================ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. * ================================================================================ + * Modifications Copyright (C) 2018 IBM. + * ================================================================================ * 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 @@ -28,7 +30,6 @@ import java.util.Map; import javax.xml.bind.annotation.XmlRootElement; import org.onap.so.db.catalog.beans.NetworkResourceCustomization; -import org.onap.so.logger.MsoLogger; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/rest/CatalogDbAdapterRest.java b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/rest/CatalogDbAdapterRest.java index a69e66cc69..d77fb097ae 100644 --- a/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/rest/CatalogDbAdapterRest.java +++ b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/rest/CatalogDbAdapterRest.java @@ -4,6 +4,8 @@ * ================================================================================ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. * ================================================================================ + * Copyright (C) 2018 IBM. + * ================================================================================ * 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 @@ -99,8 +101,6 @@ import org.onap.so.db.catalog.data.repository.VnfCustomizationRepository; import org.onap.so.db.catalog.data.repository.VnfRecipeRepository; import org.onap.so.db.catalog.data.repository.VnfResourceRepository; import org.onap.so.db.catalog.rest.beans.ServiceMacroHolder; -import org.onap.so.logger.MessageEnum; -import org.onap.so.logger.MsoLogger; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; diff --git a/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V4.2__ScaleOutRecipe.sql b/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V4.3__ScaleOutRecipe.sql index b3d8b98176..3ae135fc56 100644 --- a/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V4.2__ScaleOutRecipe.sql +++ b/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V4.3__ScaleOutRecipe.sql @@ -1,5 +1,5 @@ use catalogdb; -INSERT INTO vnf_components_recipe (VNF_COMPONENT_TYPE, ACTION, VERSION, DESCRIPTION, ORCHESTRATION_URI, RECIPE_TIMEOUT, VF_MODULE_MODEL_UUID) +INSERT IGNORE INTO vnf_components_recipe (VNF_COMPONENT_TYPE, ACTION, VERSION, DESCRIPTION, ORCHESTRATION_URI, RECIPE_TIMEOUT, VF_MODULE_MODEL_UUID) VALUES ('vfModule', 'scaleOut', '1', 'Gr api recipe to scale out vfModule', '/mso/async/services/WorkflowActionBB', '180', 'GR-API-DEFAULT'); diff --git a/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V4.4__CreateTableControllerSelectionRefence.sql b/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V4.4__CreateTableControllerSelectionRefence.sql new file mode 100644 index 0000000000..dbeba53acc --- /dev/null +++ b/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V4.4__CreateTableControllerSelectionRefence.sql @@ -0,0 +1,8 @@ +use catalogdb; + +CREATE TABLE IF NOT EXISTS `controller_selection_reference` ( + `VNF_TYPE` VARCHAR(50) NOT NULL, + `CONTROLLER_NAME` VARCHAR(100) NOT NULL, + `ACTION_CATEGORY` VARCHAR(15) NOT NULL, + PRIMARY KEY (`VNF_TYPE`, `CONTROLLER_NAME`, `ACTION_CATEGORY`) + ) ENGINE = InnoDB DEFAULT CHARSET=latin1; diff --git a/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V4.6__Remove1802StyleAssignNetwork.sql b/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V4.6__Remove1802StyleAssignNetwork.sql new file mode 100644 index 0000000000..126710e879 --- /dev/null +++ b/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V4.6__Remove1802StyleAssignNetwork.sql @@ -0,0 +1,8 @@ +use catalogdb; + +DELETE FROM building_block_detail WHERE BUILDING_BLOCK_NAME = 'AssignNetwork1802BB'; +DELETE FROM building_block_detail WHERE BUILDING_BLOCK_NAME = 'UnassignNetwork1802BB'; + +UPDATE orchestration_flow_reference SET `FLOW_NAME`='UnassignNetworkBB' WHERE `COMPOSITE_ACTION`='Network-Delete' and `FLOW_NAME`='UnassignNetwork1802BB'; +UPDATE orchestration_flow_reference SET `FLOW_NAME`='AssignNetworkBB' WHERE `COMPOSITE_ACTION`='Network-Create' and `FLOW_NAME`='AssignNetwork1802BB'; + 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 9ed61b33a3..0606848b04 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 @@ -21,33 +21,16 @@ package org.onap.so.adapters.catalogdb.catalogrest; import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; -import java.net.URI; -import java.util.List; - import javax.transaction.Transactional; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; -import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.onap.so.adapters.catalogdb.CatalogDBApplication; import org.onap.so.db.catalog.beans.AuthenticationType; -import org.onap.so.db.catalog.beans.BuildingBlockDetail; import org.onap.so.db.catalog.beans.CloudIdentity; import org.onap.so.db.catalog.beans.CloudSite; -import org.onap.so.db.catalog.beans.CollectionNetworkResourceCustomization; -import org.onap.so.db.catalog.beans.CollectionResourceCustomization; -import org.onap.so.db.catalog.beans.CollectionResourceInstanceGroupCustomization; -import org.onap.so.db.catalog.beans.InstanceGroup; -import org.onap.so.db.catalog.beans.NetworkCollectionResourceCustomization; import org.onap.so.db.catalog.beans.ServerType; -import org.onap.so.db.catalog.client.CatalogDbClient; -import org.onap.so.logger.MsoLogger; -import org.onap.so.logging.jaxrs.filter.jersey.SpringClientFilter; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.context.embedded.LocalServerPort; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.web.client.TestRestTemplate; @@ -55,15 +38,9 @@ import org.springframework.http.HttpEntity; import org.springframework.http.HttpHeaders; import org.springframework.http.HttpMethod; import org.springframework.http.ResponseEntity; -import org.springframework.http.client.BufferingClientHttpRequestFactory; -import org.springframework.http.client.ClientHttpRequestFactory; -import org.springframework.http.client.SimpleClientHttpRequestFactory; import org.springframework.test.context.ActiveProfiles; import org.springframework.test.context.junit4.SpringRunner; import org.springframework.web.util.UriComponentsBuilder; -import uk.co.blackpepper.bowman.Client; -import uk.co.blackpepper.bowman.ClientFactory; -import uk.co.blackpepper.bowman.Configuration; import static com.shazam.shazamcrest.MatcherAssert.assertThat; import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs; 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 new file mode 100644 index 0000000000..f75adc62c0 --- /dev/null +++ b/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/db/catalog/client/CatalogDbClientTest.java @@ -0,0 +1,78 @@ +package org.onap.so.db.catalog.client; + +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.onap.so.adapters.catalogdb.CatalogDBApplication; +import org.onap.so.db.catalog.beans.CloudIdentity; +import org.onap.so.db.catalog.beans.CloudSite; +import org.onap.so.db.catalog.beans.CloudifyManager; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.context.embedded.LocalServerPort; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.ActiveProfiles; +import org.springframework.test.context.junit4.SpringRunner; + +import java.util.UUID; + +@RunWith(SpringRunner.class) +@SpringBootTest(classes = CatalogDBApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) +@ActiveProfiles("test") +public class CatalogDbClientTest { + public static final String MTN13 = "mtn13"; + @LocalServerPort + private int port; + @Autowired + CatalogDbClient client; + + @Before + public void setPort() { + client.removePortFromEndpoint(); + client.setPortToEndpoint(Integer.toString(port)); + } + + @Test + public void testGetCloudSiteHappyPath() throws Exception { + CloudSite cloudSite = client.getCloudSite(MTN13); + Assert.assertNotNull(cloudSite); + Assert.assertNotNull(cloudSite.getIdentityService()); + Assert.assertEquals("MDT13", cloudSite.getClli()); + Assert.assertEquals("mtn13", cloudSite.getRegionId()); + Assert.assertEquals("MTN13", cloudSite.getIdentityServiceId()); + } + + @Test + public void testGetCloudSiteNotFound() throws Exception { + CloudSite cloudSite = client.getCloudSite(UUID.randomUUID().toString()); + Assert.assertNull(cloudSite); + } + + @Test + public void testGetCloudifyManagerHappyPath() throws Exception { + CloudifyManager cloudifyManager = client.getCloudifyManager("mtn13"); + Assert.assertNotNull(cloudifyManager); + Assert.assertEquals("http://localhost:28090/v2.0", cloudifyManager.getCloudifyUrl()); + + } + + @Test + public void testGetCloudifyManagerNotFound() throws Exception { + CloudifyManager cloudifyManager = client.getCloudifyManager(UUID.randomUUID().toString()); + Assert.assertNull(cloudifyManager); + } + + + + @Test + public void testGetCloudSiteByClliAndAicVersionHappyPath() throws Exception{ + CloudSite cloudSite = client.getCloudSiteByClliAndAicVersion("MDT13","2.5"); + Assert.assertNotNull(cloudSite); + } + + @Test + public void testGetCloudSiteByClliAndAicVersionNotFound() throws Exception{ + CloudSite cloudSite = client.getCloudSiteByClliAndAicVersion("MDT13","232496239746328"); + Assert.assertNull(cloudSite); + } +} diff --git a/adapters/mso-catalog-db-adapter/src/test/resources/db/migration/afterMigrate.sql b/adapters/mso-catalog-db-adapter/src/test/resources/db/migration/afterMigrate.sql index 4106e8ac6d..c3969b4a51 100644 --- a/adapters/mso-catalog-db-adapter/src/test/resources/db/migration/afterMigrate.sql +++ b/adapters/mso-catalog-db-adapter/src/test/resources/db/migration/afterMigrate.sql @@ -183,3 +183,10 @@ insert into allotted_resource_customization_to_service(service_model_uuid, resou insert into vnf_components(vnf_id, component_type, heat_template_id, heat_environment_id, creation_timestamp) values ('13961', 'VOLUME', '13843', '13961', '2016-05-19 20:22:02'); + + +INSERT INTO `cloudify_managers` (`ID`, `CLOUDIFY_URL`, `USERNAME`, `PASSWORD`, `VERSION`, `LAST_UPDATED_BY`, `CREATION_TIMESTAMP`, `UPDATE_TIMESTAMP`) VALUES ('mtn13', 'http://localhost:28090/v2.0', 'm93945', '93937EA01B94A10A49279D4572B48369', NULL, 'MSO_USER', '2018-07-17 14:05:08', '2018-07-17 14:05:08'); + +INSERT INTO `identity_services` (`ID`, `IDENTITY_URL`, `MSO_ID`, `MSO_PASS`, `ADMIN_TENANT`, `MEMBER_ROLE`, `TENANT_METADATA`, `IDENTITY_SERVER_TYPE`, `IDENTITY_AUTHENTICATION_TYPE`, `LAST_UPDATED_BY`, `CREATION_TIMESTAMP`, `UPDATE_TIMESTAMP`) VALUES ('MTN13', 'http://localhost:28090/v2.0', 'm93945', '93937EA01B94A10A49279D4572B48369', 'admin', 'admin', 1, 'KEYSTONE', 'USERNAME_PASSWORD', 'MSO_USER', '2018-07-17 14:02:33', '2018-07-17 14:02:33'); + +INSERT INTO `cloud_sites` (`ID`, `REGION_ID`, `IDENTITY_SERVICE_ID`, `CLOUD_VERSION`, `CLLI`, `CLOUDIFY_ID`, `PLATFORM`, `ORCHESTRATOR`, `LAST_UPDATED_BY`, `CREATION_TIMESTAMP`, `UPDATE_TIMESTAMP`) VALUES ('mtn13', 'mtn13', 'MTN13', '2.5', 'MDT13', 'mtn13', NULL, 'orchestrator', 'MSO_USER', '2018-07-17 14:06:28', '2018-07-17 14:06:28');
\ No newline at end of file diff --git a/adapters/mso-openstack-adapters/.gitignore b/adapters/mso-openstack-adapters/.gitignore index 2af7cefb0a..3467f05c98 100644 --- a/adapters/mso-openstack-adapters/.gitignore +++ b/adapters/mso-openstack-adapters/.gitignore @@ -21,4 +21,5 @@ build/ nbbuild/ dist/ nbdist/ -.nb-gradle/
\ No newline at end of file +.nb-gradle/ +/bin/ diff --git a/adapters/mso-openstack-adapters/src/main/java/db/migration/R__CloudConfigMigration.java b/adapters/mso-openstack-adapters/src/main/java/db/migration/R__CloudConfigMigration.java index ed64abd982..fbafdd052e 100644 --- a/adapters/mso-openstack-adapters/src/main/java/db/migration/R__CloudConfigMigration.java +++ b/adapters/mso-openstack-adapters/src/main/java/db/migration/R__CloudConfigMigration.java @@ -2,6 +2,8 @@ package db.migration; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.core.JsonParseException; +import com.fasterxml.jackson.databind.JsonMappingException; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.dataformat.yaml.YAMLFactory; import org.flywaydb.core.api.MigrationVersion; @@ -14,10 +16,12 @@ import org.onap.so.db.catalog.beans.CloudifyManager; import org.onap.so.logger.MsoLogger; import java.io.FileInputStream; +import java.io.IOException; import java.io.InputStream; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; +import java.sql.SQLException; import java.sql.Statement; import java.util.Collection; @@ -74,8 +78,8 @@ public class R__CloudConfigMigration implements JdbcMigration , MigrationInfoPro this.cloudConfig = cloudConfig; } - private CloudConfig loadCloudConfig(InputStream stream) throws Exception { - ObjectMapper mapper = new ObjectMapper(new YAMLFactory()); + private CloudConfig loadCloudConfig(InputStream stream) throws JsonMappingException, IOException { + ObjectMapper mapper = new ObjectMapper(new YAMLFactory()); R__CloudConfigMigration cloudConfigMigration = mapper.readValue(stream, R__CloudConfigMigration.class); CloudConfig cloudConfig = cloudConfigMigration.getCloudConfig(); @@ -92,7 +96,7 @@ public class R__CloudConfigMigration implements JdbcMigration , MigrationInfoPro return "/application" + profile + ".yaml"; } - private void migrateCloudIdentity(Collection<CloudIdentity> entities, Connection connection) throws Exception { + private void migrateCloudIdentity(Collection<CloudIdentity> entities, Connection connection) throws SQLException { LOGGER.debug("Starting migration for CloudConfig-->IdentityService"); String insert = "INSERT INTO `identity_services` (`ID`, `IDENTITY_URL`, `MSO_ID`, `MSO_PASS`, `ADMIN_TENANT`, `MEMBER_ROLE`, `TENANT_METADATA`, `IDENTITY_SERVER_TYPE`, `IDENTITY_AUTHENTICATION_TYPE`, `LAST_UPDATED_BY`) " + "VALUES (?,?,?,?,?,?,?,?,?,?);"; @@ -122,7 +126,7 @@ public class R__CloudConfigMigration implements JdbcMigration , MigrationInfoPro } } - private void migrateCloudSite(Collection<CloudSite> entities, Connection connection) throws Exception { + private void migrateCloudSite(Collection<CloudSite> entities, Connection connection) throws SQLException { LOGGER.debug("Starting migration for CloudConfig-->CloudSite"); String insert = "INSERT INTO `cloud_sites` (`ID`, `REGION_ID`, `IDENTITY_SERVICE_ID`, `CLOUD_VERSION`, `CLLI`, `CLOUDIFY_ID`, `PLATFORM`, `ORCHESTRATOR`, `LAST_UPDATED_BY`) " + "VALUES (?,?,?,?,?,?,?,?,?);"; @@ -151,7 +155,7 @@ public class R__CloudConfigMigration implements JdbcMigration , MigrationInfoPro } } - private void migrateCloudifyManagers(Collection<CloudifyManager> entities, Connection connection) throws Exception { + private void migrateCloudifyManagers(Collection<CloudifyManager> entities, Connection connection) throws SQLException { String insert = "INSERT INTO `cloudify_managers` (`ID`, `CLOUDIFY_URL`, `USERNAME`, `PASSWORD`, `VERSION`, `LAST_UPDATED_BY`)" + " VALUES (?,?,?,?,?,?);"; diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/MsoNetworkAdapterAsyncImpl.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/MsoNetworkAdapterAsyncImpl.java index 83db2add0a..500b0b32e3 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/MsoNetworkAdapterAsyncImpl.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/MsoNetworkAdapterAsyncImpl.java @@ -66,7 +66,10 @@ public class MsoNetworkAdapterAsyncImpl implements MsoNetworkAdapterAsync { private static final MsoAlarmLogger alarmLogger = new MsoAlarmLogger (); private static final String BPEL_AUTH_PROP = "org.onap.so.adapters.network.bpelauth"; private static final String ENCRYPTION_KEY = "aa3871669d893c7fb8abbcda31b88b4f"; - + private static final String NETWORK_EXCEPTION_MSG="Got a NetworkException on createNetwork: "; + private static final String CREATE_NETWORK_ERROR_MSG="Error sending createNetwork notification "; + private static final String CREATE_NETWORK_EXCEPTON_MSG="Exception sending createNetwork notification"; + private static final String MSO_INTERNAL_ERROR_MSG="MsoInternalError"; @Autowired private Environment environment; @@ -160,7 +163,7 @@ public class MsoNetworkAdapterAsyncImpl implements MsoNetworkAdapterAsync { subnetIdMap, networkRollback); } catch (NetworkException e) { - LOGGER.debug ("Got a NetworkException on createNetwork: ", e); + LOGGER.debug (NETWORK_EXCEPTION_MSG, e); MsoExceptionCategory exCat = null; String eMsg = null; try { @@ -174,9 +177,9 @@ public class MsoNetworkAdapterAsyncImpl implements MsoNetworkAdapterAsync { NetworkAdapterNotify notifyPort = getNotifyEP (notificationUrl); notifyPort.createNetworkNotification (messageId, false, exCat, eMsg, null, null, null, null); } catch (Exception e1) { - error = "Error sending createNetwork notification " + e1.getMessage (); - LOGGER.error (MessageEnum.RA_CREATE_NETWORK_NOTIF_EXC, "", "", MsoLogger.ErrorCode.DataError, "Exception sending createNetwork notification", e1); - alarmLogger.sendAlarm ("MsoInternalError", MsoAlarmLogger.CRITICAL, error); + error = CREATE_NETWORK_ERROR_MSG + e1.getMessage (); + LOGGER.error (MessageEnum.RA_CREATE_NETWORK_NOTIF_EXC, "", "", MsoLogger.ErrorCode.DataError,CREATE_NETWORK_EXCEPTON_MSG, e1); + alarmLogger.sendAlarm (MSO_INTERNAL_ERROR_MSG, MsoAlarmLogger.CRITICAL, error); } return; } 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..2a4564bcb2 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); @@ -157,7 +153,6 @@ public class NetworkAdapterRestTest extends BaseRestTestUtils { @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 +192,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 +210,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 +228,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(); 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-requests-db-adapter/src/main/resources/application-local.yaml b/adapters/mso-requests-db-adapter/src/main/resources/application-local.yaml index 2b4e7808b5..102b52985c 100644 --- a/adapters/mso-requests-db-adapter/src/main/resources/application-local.yaml +++ b/adapters/mso-requests-db-adapter/src/main/resources/application-local.yaml @@ -6,6 +6,10 @@ server: max-threads: 50 ssl-enable: false mso: + adapters: + requestDb: + auth: Basic YnBlbDptc28tZGItMTUwNyE= + endpoint: http://localhost:8081 logPath: logs site-name: localSite spring: diff --git a/adapters/mso-requests-db-adapter/src/test/resources/application-test.yaml b/adapters/mso-requests-db-adapter/src/test/resources/application-test.yaml index 6a5db78f8b..49582ec513 100644 --- a/adapters/mso-requests-db-adapter/src/test/resources/application-test.yaml +++ b/adapters/mso-requests-db-adapter/src/test/resources/application-test.yaml @@ -6,6 +6,10 @@ server: max-threads: 50 ssl-enable: false mso: + adapters: + requestDb: + auth: Basic YnBlbDptc28tZGItMTUwNyE= + endpoint: http://localhost:8081 logPath: logs site-name: localSite infra-requests: diff --git a/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/rest/HealthCheckHandlerTest.java b/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/rest/HealthCheckHandlerTest.java index 10fa02a1d1..d53e467865 100644 --- a/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/rest/HealthCheckHandlerTest.java +++ b/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/rest/HealthCheckHandlerTest.java @@ -26,10 +26,10 @@ import static org.junit.Assert.*; import javax.ws.rs.core.Response; -import org.json.JSONException; import org.junit.Test; import org.junit.runner.RunWith; import org.onap.so.adapters.vfc.MSOVfcApplication; +import org.springframework.boot.configurationprocessor.json.JSONException; import org.springframework.boot.context.embedded.LocalServerPort; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.web.client.TestRestTemplate; diff --git a/adapters/mso-vfc-adapter/src/test/resources/application-test.yaml b/adapters/mso-vfc-adapter/src/test/resources/application-test.yaml index 64de62c2d6..d558d247d7 100644 --- a/adapters/mso-vfc-adapter/src/test/resources/application-test.yaml +++ b/adapters/mso-vfc-adapter/src/test/resources/application-test.yaml @@ -5,6 +5,10 @@ server: max-threads: 50 ssl-enable: false mso: + adapters: + requestDb: + auth: Basic YnBlbDptc28tZGItMTUwNyE= + endpoint: http://localhost:8081 logPath: logs site-name: localSite infra-requests: |