diff options
Diffstat (limited to 'adapters')
6 files changed, 344 insertions, 42 deletions
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 d77fb097ae..5cd2559ef2 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 @@ -53,19 +53,6 @@ min and initial counts can be 0. max can be null to indicate no maximum. Once the network-level distribution artifacts are defined, similar updates can be made to the NETWORK_RESOURCE table. */ -import java.util.ArrayList; -import java.util.List; - -import javax.ws.rs.GET; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; -import javax.ws.rs.core.GenericEntity; -import javax.ws.rs.core.HttpHeaders; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; - import org.apache.http.HttpStatus; import org.onap.so.adapters.catalogdb.catalogrest.CatalogQuery; import org.onap.so.adapters.catalogdb.catalogrest.CatalogQueryException; @@ -107,6 +94,18 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import org.springframework.transaction.annotation.Transactional; +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.QueryParam; +import javax.ws.rs.core.GenericEntity; +import javax.ws.rs.core.HttpHeaders; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; +import java.util.ArrayList; +import java.util.List; + /** * This class services calls to the REST interface for VF Modules (http://host:port/ecomp/mso/catalog/v1) * Both XML and JSON can be produced/consumed. Set Accept: and Content-Type: headers appropriately. XML is the default. @@ -203,7 +202,7 @@ public class CatalogDbAdapterRest { service = serviceRepo.findFirstOneByModelUUIDOrderByModelVersionDesc(serviceModelUUID); else if (smiUuid != null && !"".equals(smiUuid)) if (smVer != null && !"".equals(smVer)) - service = serviceRepo.findByModelVersionAndModelInvariantUUID(smVer,smiUuid); + service = serviceRepo.findFirstByModelVersionAndModelInvariantUUID(smVer,smiUuid); else service = serviceRepo.findFirstByModelInvariantUUIDOrderByModelVersionDesc(smiUuid); else if (smName != null && !"".equals(smName)) { @@ -287,7 +286,7 @@ public class CatalogDbAdapterRest { else if (serviceModelInvariantUuid != null && !"".equals(serviceModelInvariantUuid)) { uuid = serviceModelInvariantUuid; if (serviceModelVersion != null && !"".equals(serviceModelVersion)) { - service = serviceRepo.findByModelVersionAndModelInvariantUUID(serviceModelVersion, uuid); + service = serviceRepo.findFirstByModelVersionAndModelInvariantUUID(serviceModelVersion, uuid); } else { service = serviceRepo.findFirstByModelInvariantUUIDOrderByModelVersionDesc(uuid); @@ -347,7 +346,7 @@ public class CatalogDbAdapterRest { uuid = modelInvariantUUID; if (modelVersion != null && !"".equals(modelVersion)) { logger.debug ("Query serviceMacroHolder getAllResourcesByServiceModelInvariantUuid serviceModelInvariantUuid: {} serviceModelVersion: {}",uuid, modelVersion); - Service serv = serviceRepo.findByModelVersionAndModelInvariantUUID(modelVersion, uuid); + Service serv = serviceRepo.findFirstByModelVersionAndModelInvariantUUID(modelVersion, uuid); ret.setService(serv); } else { @@ -419,7 +418,7 @@ public class CatalogDbAdapterRest { else if (serviceModelInvariantUuid != null && !"".equals(serviceModelInvariantUuid)) { uuid = serviceModelInvariantUuid; if (smVer != null && !"".equals(smVer)) { - service = serviceRepo.findByModelVersionAndModelInvariantUUID(smVer, uuid); + service = serviceRepo.findFirstByModelVersionAndModelInvariantUUID(smVer, uuid); } else { service = serviceRepo.findFirstByModelInvariantUUIDOrderByModelVersionDesc(uuid); @@ -558,10 +557,10 @@ public class CatalogDbAdapterRest { logger.debug("Query recipe by resource model uuid: {}", rmUuid); //check vnf and network and ar, the resource could be any resource. VnfResource vnf = vnfResourceRepo.findResourceByModelUUID(rmUuid); - Recipe recipe = vnfRecipeRepo.findVnfRecipeByNfRoleAndAction(vnf.getModelName(), action); + Recipe recipe = vnfRecipeRepo.findFirstVnfRecipeByNfRoleAndAction(vnf.getModelName(), action); if (null == recipe) { NetworkResource nResource = networkResourceRepo.findResourceByModelUUID(rmUuid); - recipe = networkRecipeRepo.findByModelNameAndAction(nResource.getModelName(), action); + recipe = networkRecipeRepo.findFirstByModelNameAndAction(nResource.getModelName(), action); } if (null == recipe) { AllottedResource arResource = arResourceRepo.findResourceByModelUUID(rmUuid); diff --git a/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/NetworkCollectionCatalogDbQueryTest.java b/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/NetworkCollectionCatalogDbQueryTest.java index f09df8823c..fcc3eb4d66 100644 --- a/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/NetworkCollectionCatalogDbQueryTest.java +++ b/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/NetworkCollectionCatalogDbQueryTest.java @@ -39,7 +39,7 @@ 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.client.CatalogDbClient; +import org.onap.so.db.catalog.client.CatalogDbClientPortChanger; import org.onap.so.logger.MsoLogger; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.embedded.LocalServerPort; @@ -59,14 +59,14 @@ public class NetworkCollectionCatalogDbQueryTest { @LocalServerPort private int port; - + boolean isInitialized; + @Autowired - private CatalogDbClient client; - + CatalogDbClientPortChanger client; + @Before - public void setPort() { - client.removePortFromEndpoint(); - client.setPortToEndpoint(Integer.toString(port)); + public void initialize(){ + client.wiremockPort= String.valueOf(port); } @Test diff --git a/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/db/catalog/client/CatalogDbClientPortChanger.java b/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/db/catalog/client/CatalogDbClientPortChanger.java new file mode 100644 index 0000000000..b52cf73fe5 --- /dev/null +++ b/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/db/catalog/client/CatalogDbClientPortChanger.java @@ -0,0 +1,20 @@ +package org.onap.so.db.catalog.client; + +import org.springframework.stereotype.Component; + +import java.net.URI; + +@Component() +public class CatalogDbClientPortChanger extends CatalogDbClient { + + public String wiremockPort; + + protected URI getUri(String template) { + URI uri = URI.create(template); + String path = uri.getPath(); + String prefix = "http://localhost:" + wiremockPort; + String query = uri.getQuery(); + + return URI.create(prefix + path + (query == null || query.isEmpty()?"":"?"+query)); + } +} diff --git a/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/db/catalog/client/CatalogDbClientTest.java b/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/db/catalog/client/CatalogDbClientTest.java index f75adc62c0..b1c3bdb29c 100644 --- a/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/db/catalog/client/CatalogDbClientTest.java +++ b/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/db/catalog/client/CatalogDbClientTest.java @@ -2,18 +2,29 @@ package org.onap.so.db.catalog.client; import org.junit.Assert; import org.junit.Before; +import org.junit.Ignore; 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.onap.so.db.catalog.beans.InstanceGroup; +import org.onap.so.db.catalog.beans.NetworkResourceCustomization; +import org.onap.so.db.catalog.beans.Service; +import org.onap.so.db.catalog.beans.ServiceRecipe; +import org.onap.so.db.catalog.beans.VfModule; +import org.onap.so.db.catalog.beans.VfModuleCustomization; +import org.onap.so.db.catalog.beans.VnfComponentsRecipe; +import org.onap.so.db.catalog.beans.VnfRecipe; +import org.onap.so.db.catalog.beans.VnfResource; +import org.onap.so.db.catalog.beans.VnfResourceCustomization; 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.List; import java.util.UUID; @RunWith(SpringRunner.class) @@ -24,12 +35,11 @@ public class CatalogDbClientTest { @LocalServerPort private int port; @Autowired - CatalogDbClient client; + CatalogDbClientPortChanger client; @Before - public void setPort() { - client.removePortFromEndpoint(); - client.setPortToEndpoint(Integer.toString(port)); + public void initialize() { + client.wiremockPort = String.valueOf(port); } @Test @@ -63,16 +73,274 @@ public class CatalogDbClientTest { } - @Test - public void testGetCloudSiteByClliAndAicVersionHappyPath() throws Exception{ - CloudSite cloudSite = client.getCloudSiteByClliAndAicVersion("MDT13","2.5"); + 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"); + public void testGetCloudSiteByClliAndAicVersionNotFound() throws Exception { + CloudSite cloudSite = client.getCloudSiteByClliAndAicVersion("MDT13", "232496239746328"); Assert.assertNull(cloudSite); } + + @Test + public void testGetServiceByID() throws Exception { + Service serviceByID = client.getServiceByID("5df8b6de-2083-11e7-93ae-92361f002671"); + Assert.assertNotNull(serviceByID); + Assert.assertEquals("MSOTADevInfra_vSAMP10a_Service", serviceByID.getModelName()); + Assert.assertEquals("NA", serviceByID.getServiceType()); + Assert.assertEquals("NA", serviceByID.getServiceRole()); + } + + @Test + public void testGetServiceByIDNotFound() throws Exception { + Service serviceByID = client.getServiceByID(UUID.randomUUID().toString()); + Assert.assertNull(serviceByID); + } + + @Test + public void testGetVfModuleByModelUUID() throws Exception { + VfModule vfModule = client.getVfModuleByModelUUID("20c4431c-246d-11e7-93ae-92361f002671"); + Assert.assertNotNull(vfModule); + Assert.assertNotNull(vfModule.getVfModuleCustomization()); + Assert.assertEquals("78ca26d0-246d-11e7-93ae-92361f002671", vfModule.getModelInvariantUUID()); + Assert.assertEquals("vSAMP10aDEV::base::module-0", vfModule.getModelName()); + } + + @Test + public void testGetVfModuleByModelUUIDNotFound() throws Exception { + VfModule vfModule = client.getVfModuleByModelUUID(UUID.randomUUID().toString()); + Assert.assertNull(vfModule); + } + + @Test + public void testGetVnfResourceByModelUUID() throws Exception { + VnfResource vnfResource = client.getVnfResourceByModelUUID("ff2ae348-214a-11e7-93ae-92361f002671"); + Assert.assertNotNull(vnfResource); + Assert.assertEquals("vSAMP10a", vnfResource.getModelName()); + } + + @Test + public void testGetVnfResourceByModelUUIDNotFound() throws Exception { + VnfResource vnfResource = client.getVnfResourceByModelUUID(UUID.randomUUID().toString()); + Assert.assertNull(vnfResource); + } + + @Test + public void testGetVnfResourceCustomizationByModelCustomizationUUID() { + VnfResourceCustomization vnfResourceCustomization = client.getVnfResourceCustomizationByModelCustomizationUUID("68dc9a92-214c-11e7-93ae-92361f002671"); + Assert.assertNotNull(vnfResourceCustomization); + Assert.assertEquals("vSAMP", vnfResourceCustomization.getNfRole()); + Assert.assertNotNull(vnfResourceCustomization.getModelCustomizationUUID()); + Assert.assertNotNull(vnfResourceCustomization.getVnfResources()); + Assert.assertNotNull(vnfResourceCustomization.getVfModuleCustomizations()); + Assert.assertEquals("vSAMP10a", vnfResourceCustomization.getVnfResources().getModelName()); + + } + + @Test + public void testGetVnfResourceCustomizationByModelCustomizationUUINotFound() { + VnfResourceCustomization vnfResourceCustomization = client.getVnfResourceCustomizationByModelCustomizationUUID(UUID.randomUUID().toString()); + Assert.assertNull(vnfResourceCustomization); + } + + @Test + public void testGetInstanceGroupByModelUUID() { + InstanceGroup instanceGroup = client.getInstanceGroupByModelUUID("0c8692ef-b9c0-435d-a738-edf31e71f38b"); + Assert.assertNotNull(instanceGroup); + Assert.assertEquals("network_collection_resource_1806..NetworkCollection..0", instanceGroup.getModelName()); + Assert.assertEquals("org.openecomp.resource.cr.NetworkCollectionResource1806", instanceGroup.getToscaNodeType().toString()); + } + + @Test + public void testGetVfModuleCustomizationByModelCuztomizationUUID() { + VfModuleCustomization vfModuleCustomization = client.getVfModuleCustomizationByModelCuztomizationUUID("cb82ffd8-252a-11e7-93ae-92361f002671"); + Assert.assertNotNull(vfModuleCustomization); + Assert.assertNotNull(vfModuleCustomization.getModelCustomizationUUID()); + Assert.assertEquals("base", vfModuleCustomization.getLabel()); + } + + @Test + public void testGetVfModuleCustomizationByModelCuztomizationUUIDNotFound() { + VfModuleCustomization vfModuleCustomization = client.getVfModuleCustomizationByModelCuztomizationUUID(UUID.randomUUID().toString()); + Assert.assertNull(vfModuleCustomization); + } + + @Test + public void testGetNetworkResourceCustomizationByModelCustomizationUUID() { + NetworkResourceCustomization networkResourceCustomization = client.getNetworkResourceCustomizationByModelCustomizationUUID("3bdbb104-476c-483e-9f8b-c095b3d308ac"); + Assert.assertNotNull(networkResourceCustomization); + Assert.assertNotNull(networkResourceCustomization.getModelCustomizationUUID()); + Assert.assertEquals("CONTRAIL30_GNDIRECT 9", networkResourceCustomization.getModelInstanceName()); + Assert.assertNotNull(networkResourceCustomization.getNetworkResource()); + } + + @Test + public void testGetNetworkResourceCustomizationByModelCustomizationUUIDNotFound() { + NetworkResourceCustomization networkResourceCustomization = client.getNetworkResourceCustomizationByModelCustomizationUUID(UUID.randomUUID().toString()); + Assert.assertNull(networkResourceCustomization); + } + + @Test + public void testGgetVfModuleCustomizationByModelCustomizationUUIDAndVfModuleModelUUID() { + VfModuleCustomization vfModuleCustomization = client.getVfModuleCustomizationByModelCustomizationUUIDAndVfModuleModelUUID("cb82ffd8-252a-11e7-93ae-92361f002672", "20c4431c-246d-11e7-93ae-92361f002672"); + Assert.assertNotNull(vfModuleCustomization); + Assert.assertNotNull(vfModuleCustomization.getModelCustomizationUUID()); + Assert.assertNotNull(vfModuleCustomization.getVfModule()); + Assert.assertEquals("base", vfModuleCustomization.getLabel()); + } + + @Test + public void testGgetVfModuleCustomizationByModelCustomizationUUIDAndVfModuleModelUUIDNotFound() { + VfModuleCustomization vfModuleCustomization = client.getVfModuleCustomizationByModelCustomizationUUIDAndVfModuleModelUUID("cb82ffd8-252a-11e7-93ae-92361f002672", UUID.randomUUID().toString()); + Assert.assertNull(vfModuleCustomization); + } + + @Test + public void testGetFirstByServiceModelUUIDAndAction() { + ServiceRecipe serviceRecipe = client.getFirstByServiceModelUUIDAndAction("4694a55f-58b3-4f17-92a5-796d6f5ffd0d", "createInstance"); + Assert.assertNotNull(serviceRecipe); + Assert.assertNotNull(serviceRecipe.getServiceModelUUID()); + Assert.assertNotNull(serviceRecipe.getAction()); + Assert.assertEquals("/mso/async/services/CreateGenericALaCarteServiceInstance", serviceRecipe.getOrchestrationUri()); + Assert.assertEquals("MSOTADevInfra aLaCarte", serviceRecipe.getDescription()); + } + + @Test + public void testGetFirstByServiceModelUUIDAndActionNotFound() { + ServiceRecipe serviceRecipe = client.getFirstByServiceModelUUIDAndAction("5df8b6de-2083-11e7-93ae-92361f002671", UUID.randomUUID().toString()); + Assert.assertNull(serviceRecipe); + } + + @Test + public void testGetFirstVnfResourceByModelInvariantUUIDAndModelVersion() { + VnfResource vnfResource = client.getFirstVnfResourceByModelInvariantUUIDAndModelVersion("2fff5b20-214b-11e7-93ae-92361f002671", "2.0"); + Assert.assertNotNull(vnfResource); + Assert.assertNotNull(vnfResource.getModelInvariantId()); + Assert.assertNotNull(vnfResource.getModelVersion()); + Assert.assertNotNull(vnfResource.getHeatTemplates()); + Assert.assertNotNull(vnfResource.getVnfResourceCustomizations()); + Assert.assertEquals("vSAMP10a", vnfResource.getModelName()); + } + + @Test + public void testGetFirstVnfResourceByModelInvariantUUIDAndModelVersionNotFound() { + VnfResource vnfResource = client.getFirstVnfResourceByModelInvariantUUIDAndModelVersion("2fff5b20-214b-11e7-93ae-92361f002671", UUID.randomUUID().toString()); + Assert.assertNull(vnfResource); + } + + @Test + public void testGetFirstVnfResourceCustomizationByModelInstanceNameAndVnfResources() { + VnfResource vnfr = new VnfResource(); + vnfr.setModelUUID("ff2ae348-214a-11e7-93ae-92361f002671"); + VnfResourceCustomization firstVnfResourceCustomizationByModelInstanceNameAndVnfResources = client.getFirstVnfResourceCustomizationByModelInstanceNameAndVnfResources("vSAMP10a 1", vnfr); + Assert.assertNotNull(firstVnfResourceCustomizationByModelInstanceNameAndVnfResources); + Assert.assertEquals("vSAMP", firstVnfResourceCustomizationByModelInstanceNameAndVnfResources.getNfRole()); + Assert.assertEquals("vSAMP10a 1", firstVnfResourceCustomizationByModelInstanceNameAndVnfResources.getModelInstanceName()); + Assert.assertNotNull(firstVnfResourceCustomizationByModelInstanceNameAndVnfResources.getVnfResources()); + Assert.assertNotNull(firstVnfResourceCustomizationByModelInstanceNameAndVnfResources.getVfModuleCustomizations()); + } + + @Test + public void testGetFirstVnfRecipeByNfRoleAndAction() { + VnfRecipe vnfRecipe = client.getFirstVnfRecipeByNfRoleAndAction("GR-API-DEFAULT", "createInstance"); + Assert.assertNotNull(vnfRecipe); + Assert.assertNotNull(vnfRecipe.getNfRole()); + Assert.assertNotNull(vnfRecipe.getAction()); + Assert.assertEquals("Gr api recipe to create vnf", vnfRecipe.getDescription()); + Assert.assertEquals("/mso/async/services/WorkflowActionBB", vnfRecipe.getOrchestrationUri()); + } + + @Test + public void testGetFirstVnfRecipeByNfRoleAndActionNotFound() { + VnfRecipe vnfRecipe = client.getFirstVnfRecipeByNfRoleAndAction(UUID.randomUUID().toString(), "createInstance"); + Assert.assertNull(vnfRecipe); + } + + @Test + public void testGetFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction() { + VnfComponentsRecipe vnfComponentsRecipe = client.getFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction("20c4431c-246d-11e7-93ae-92361f002671", "volumeGroup", "createInstance"); + Assert.assertNotNull(vnfComponentsRecipe); + Assert.assertNotNull(vnfComponentsRecipe.getAction()); + Assert.assertNotNull(vnfComponentsRecipe.getVfModuleModelUUID()); + Assert.assertNotNull(vnfComponentsRecipe.getVnfComponentType()); + Assert.assertEquals("Gr api recipe to create volume-group", vnfComponentsRecipe.getDescription()); + Assert.assertEquals("/mso/async/services/WorkflowActionBB", vnfComponentsRecipe.getOrchestrationUri()); + + } + + + @Test + public void testGetFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndActionNotFound() { + VnfComponentsRecipe vnfComponentsRecipe = client.getFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction(UUID.randomUUID().toString(), "volumeGroup", "createInstance"); + Assert.assertNull(vnfComponentsRecipe); + } + + @Test + public void testGetFirstVnfComponentsRecipeByVnfComponentTypeAndAction() { + VnfComponentsRecipe vnfComponentsRecipe = client.getFirstVnfComponentsRecipeByVnfComponentTypeAndAction("volumeGroup", "createInstance"); + Assert.assertNotNull(vnfComponentsRecipe); + Assert.assertNotNull(vnfComponentsRecipe.getAction()); + Assert.assertNotNull(vnfComponentsRecipe.getVnfComponentType()); + Assert.assertEquals("VID_DEFAULT recipe t", vnfComponentsRecipe.getDescription()); + Assert.assertEquals("/mso/async/services/CreateVfModuleVolumeInfraV1", vnfComponentsRecipe.getOrchestrationUri()); + } + + @Test + public void testGetServiceByModelVersionAndModelInvariantUUID() { + Service service = client.getServiceByModelVersionAndModelInvariantUUID("2.0", "9647dfc4-2083-11e7-93ae-92361f002671"); + Assert.assertNotNull(service); + Assert.assertNotNull(service.getModelVersion()); + Assert.assertNotNull(service.getModelInvariantUUID()); + Assert.assertEquals("MSOTADevInfra_vSAMP10a_Service", service.getModelName()); + Assert.assertEquals("NA", service.getServiceRole()); + } + + @Test + public void testGetServiceByModelVersionAndModelInvariantUUIDNotFound() { + Service service = client.getServiceByModelVersionAndModelInvariantUUID("2.0", UUID.randomUUID().toString()); + Assert.assertNull(service); + } + + @Test + public void testGetVfModuleByModelInvariantUUIDAndModelVersion() { + VfModule vfModule = client.getVfModuleByModelInvariantUUIDAndModelVersion("78ca26d0-246d-11e7-93ae-92361f002671", "2"); + Assert.assertNotNull(vfModule); + Assert.assertNotNull(vfModule.getModelVersion()); + Assert.assertNotNull(vfModule.getModelInvariantUUID()); + Assert.assertEquals("vSAMP10aDEV::base::module-0", vfModule.getModelName()); + Assert.assertEquals("vSAMP10a DEV Base", vfModule.getDescription()); + } + + @Test + public void testGetVfModuleByModelInvariantUUIDAndModelVersionNotFound() { + VfModule vfModule = client.getVfModuleByModelInvariantUUIDAndModelVersion(UUID.randomUUID().toString(), "2"); + Assert.assertNull(vfModule); + } + + @Test + public void testGetServiceByModelInvariantUUIDOrderByModelVersionDesc() { + List<Service> serviceList = client.getServiceByModelInvariantUUIDOrderByModelVersionDesc("9647dfc4-2083-11e7-93ae-92361f002671"); + Assert.assertFalse(serviceList.isEmpty()); + Assert.assertEquals(2, serviceList.size()); + Service service = serviceList.get(0); + Assert.assertEquals("2.0", service.getModelVersion()); + } + + @Test + public void testGetServiceByModelInvariantUUIDOrderByModelVersionDescNotFound() { + List<Service> serviceList = client.getServiceByModelInvariantUUIDOrderByModelVersionDesc(UUID.randomUUID().toString()); + Assert.assertTrue(serviceList.isEmpty()); + } + + @Test + public void testGetVfModuleByModelInvariantUUIDOrderByModelVersionDesc() { + List<VfModule> moduleList = client.getVfModuleByModelInvariantUUIDOrderByModelVersionDesc("78ca26d0-246d-11e7-93ae-92361f002671"); + Assert.assertFalse(moduleList.isEmpty()); + Assert.assertEquals(2, moduleList.size()); + VfModule module = moduleList.get(0); + Assert.assertEquals("vSAMP10a DEV Base",module.getDescription()); + } } 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 c3969b4a51..d5cdb18a0c 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 @@ -95,7 +95,7 @@ insert into heat_environment(artifact_uuid, name, version, description, body, ar ('fefb1751-4333-11e7-9252-005056850d2e', 'module_nso.env', '2', 'Auto-generated HEAT Environment deployment artifact', 'parameters:\n availability_zone_0: \"alln-zone-1\"\n nso_flavor_name: \"citeis.1vCPUx2GB\"\n nso_image_name: \"RHEL-6.8-BASE-20160912\"\n nso_name_0: \"zrdm3vamp01nso001\"\n nso_oam_ip_0: \"172.18.25.175\"\n nso_oam_net_gw: \"172.18.25.1\"\n nso_oam_net_mask: \"255.255.255.0\"\n nso_sec_grp_id: \"36f48d82-f099-4437-bfbc-70d9e5d420d1\"\n nso_srv_grp_id: \"e431c477-5bd1-476a-bfa9-e4ce16b8356b\"\n oam_net_id: \"nso_oam\"\n vf_module_id: \"145cd730797234b4a40aa99335abc143\"\n vnf_id: \"730797234b4a40aa99335157b02871cd\"\n vnf_name: \"Mobisupport\"\n', 'MWI2ODY0Yjc1NDJjNWU1NjdkMTAyMjVkNzFmZDU0MzA=', '2017-11-27 08:42:58'); 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-92361f002671', '', '', '2fff5b20-214b-11e7-93ae-92361f002671', '1.0', 'vSAMP10a', 'VF', null); +('HEAT', '1607 vSAMP10a - inherent network', '2017-04-14 21:46:28', 'ff2ae348-214a-11e7-93ae-92361f002671', '', '', '2fff5b20-214b-11e7-93ae-92361f002671', '1.0', 'vSAMP10a', 'VF', 'ff874603-4222-11e7-9252-005056850d2e'); insert into vnf_resource_customization(model_customization_uuid, model_instance_name, min_instances, max_instances, availability_zone_max_count, nf_type, nf_role, nf_function, nf_naming_code, creation_timestamp, vnf_resource_model_uuid, multi_stage_design) values ('68dc9a92-214c-11e7-93ae-92361f002671', 'vSAMP10a 1', '0', '0', '0', 'vSAMP', 'vSAMP', 'vSAMP', 'vSAMP', '2017-05-26 15:08:24', 'ff2ae348-214a-11e7-93ae-92361f002671', null); @@ -135,7 +135,7 @@ insert into collection_network_resource_customization(model_customization_uuid, ('1a61be4b-3378-4c9a-91c8-c919519b2d01', 'CONTRAIL30_GNDIRECT 9', '', '', '', '', '2017-04-19 14:28:32', '10b36f65-f4e6-4be6-ae49-9596dc1c47fc', '0c8692ef-b9c0-435d-a738-edf31e71f38b', 'a07a5826-3281-485c-8f40-6988011ef3f2'); 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); +('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', 'ff874603-4222-11e7-9252-005056850d2e'); insert into vnf_resource_customization(model_customization_uuid, model_instance_name, min_instances, max_instances, availability_zone_max_count, nf_type, nf_role, nf_function, nf_naming_code, creation_timestamp, vnf_resource_model_uuid, multi_stage_design) values @@ -189,4 +189,15 @@ INSERT INTO `cloudify_managers` (`ID`, `CLOUDIFY_URL`, `USERNAME`, `PASSWORD`, ` 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 +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'); + +INSERT INTO service_recipe(ID, ACTION, VERSION_STR, DESCRIPTION, ORCHESTRATION_URI, SERVICE_PARAM_XSD, RECIPE_TIMEOUT, SERVICE_TIMEOUT_INTERIM, CREATION_TIMESTAMP, SERVICE_MODEL_UUID) VALUES +('8', 'createInstance', '8', 'MSOTADevInfra aLaCarte', '/mso/async/services/CreateGenericALaCarteServiceInstance', null, '180', '0', '2017-04-14 19:18:20', '4694a55f-58b3-4f17-92a5-796d6f5ffd0d'); + +INSERT INTO vnf_recipe (nf_role, ACTION, VERSION_STR, DESCRIPTION, ORCHESTRATION_URI, RECIPE_TIMEOUT) +VALUES +('GR-API-DEFAULT', 'createInstance', '1', 'Gr api recipe to create vnf', '/mso/async/services/WorkflowActionBB', 180); + +INSERT INTO vnf_components_recipe (VNF_COMPONENT_TYPE, ACTION, VERSION, DESCRIPTION, ORCHESTRATION_URI, RECIPE_TIMEOUT, VF_MODULE_MODEL_UUID) +VALUES +('volumeGroup', 'createInstance', '1', 'Gr api recipe to create volume-group', '/mso/async/services/WorkflowActionBB', 180, '20c4431c-246d-11e7-93ae-92361f002671');
\ No newline at end of file diff --git a/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/MsoRequestsDbAdapterImpl.java b/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/MsoRequestsDbAdapterImpl.java index 2f6a5839b7..d0eae88c9e 100644 --- a/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/MsoRequestsDbAdapterImpl.java +++ b/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/MsoRequestsDbAdapterImpl.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 @@ -51,6 +53,8 @@ public class MsoRequestsDbAdapterImpl implements MsoRequestsDbAdapter { private static final String SUCCESSFUL = "Successful"; private static final String GET_INFRA_REQUEST = "Get Infra request"; + + private static final String ERROR = "Error "; private static MsoLogger logger = MsoLogger.getMsoLogger(MsoLogger.Catalog.RA, MsoRequestsDbAdapterImpl.class); @@ -131,7 +135,7 @@ public class MsoRequestsDbAdapterImpl implements MsoRequestsDbAdapter { } catch (Exception e) { String error = "Error retrieving MSO Infra Requests DB for Request ID " + requestId; - logger.error("Error " + MsoLogger.ErrorCode.BusinessProcesssError + " for " + GET_INFRA_REQUEST + " - " + MessageEnum.RA_DB_REQUEST_NOT_EXIST + " - " + error, e); + logger.error(ERROR + MsoLogger.ErrorCode.BusinessProcesssError + " for " + GET_INFRA_REQUEST + " - " + MessageEnum.RA_DB_REQUEST_NOT_EXIST + " - " + error, e); logger.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DBAccessError, error); throw new MsoRequestsDbException(error, e); } @@ -165,7 +169,7 @@ public class MsoRequestsDbAdapterImpl implements MsoRequestsDbAdapter { } } catch (Exception e) { String error = "Error retrieving MSO Infra Requests DB for Request ID " + requestId; - logger.error("Error " + MsoLogger.ErrorCode.BusinessProcesssError + " for " + GET_INFRA_REQUEST + " - " + MessageEnum.RA_DB_REQUEST_NOT_EXIST + " - " + error, e); + logger.error(ERROR + MsoLogger.ErrorCode.BusinessProcesssError + " for " + GET_INFRA_REQUEST + " - " + MessageEnum.RA_DB_REQUEST_NOT_EXIST + " - " + error, e); logger.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DBAccessError, error); throw new MsoRequestsDbException(error, e); } @@ -223,7 +227,7 @@ public class MsoRequestsDbAdapterImpl implements MsoRequestsDbAdapter { String error = "Entity not found. Unable to retrieve OperationStatus Object ServiceId: " + serviceId + " operationId: " + operationId; MsoRequestsDbException e = new MsoRequestsDbException(error); - logger.error("Error "+ MsoLogger.ErrorCode.BusinessProcesssError + " - " + MessageEnum.RA_DB_REQUEST_NOT_EXIST + " - " + error, e); + logger.error(ERROR+ MsoLogger.ErrorCode.BusinessProcesssError + " - " + MessageEnum.RA_DB_REQUEST_NOT_EXIST + " - " + error, e); throw e; } |