summaryrefslogtreecommitdiffstats
path: root/adapters/mso-catalog-db-adapter/src/test
diff options
context:
space:
mode:
authorSteve Smokowski <ss835w@att.com>2019-03-12 12:35:57 +0000
committerGerrit Code Review <gerrit@onap.org>2019-03-12 12:35:57 +0000
commit308c3c2085864e04848e53a589773ff2e6e2c76a (patch)
tree736534e374d9710c5866883102a348b063467c0d /adapters/mso-catalog-db-adapter/src/test
parentc068ba17e06cc1aab0616c4ad11f8be8c2d23e45 (diff)
parent53bb2f2c36358c9d60bfc2ed0a6de0a63f04c08f (diff)
Merge "DB Schema Change for SO Catalog"
Diffstat (limited to 'adapters/mso-catalog-db-adapter/src/test')
-rw-r--r--adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/db/catalog/client/CatalogDbClientTest.java307
-rw-r--r--adapters/mso-catalog-db-adapter/src/test/resources/db/migration/afterMigrate.sql12
2 files changed, 211 insertions, 108 deletions
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 4479e1ba4a..d28784bb93 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
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -22,6 +22,7 @@ package org.onap.so.db.catalog.client;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
import static org.mockito.Mockito.when;
import java.util.List;
@@ -42,6 +43,8 @@ import org.onap.so.db.catalog.beans.ExternalServiceToInternalService;
import org.onap.so.db.catalog.beans.HomingInstance;
import org.onap.so.db.catalog.beans.InstanceGroup;
import org.onap.so.db.catalog.beans.NetworkResourceCustomization;
+import org.onap.so.db.catalog.beans.PnfResource;
+import org.onap.so.db.catalog.beans.PnfResourceCustomization;
import org.onap.so.db.catalog.beans.ServerType;
import org.onap.so.db.catalog.beans.Service;
import org.onap.so.db.catalog.beans.ServiceRecipe;
@@ -59,6 +62,7 @@ import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.web.server.LocalServerPort;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.mock.mockito.MockBean;
+import org.springframework.security.core.parameters.P;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.junit4.SpringRunner;
@@ -68,31 +72,36 @@ import com.fasterxml.jackson.databind.ObjectMapper;
@SpringBootTest(classes = CatalogDBApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
@ActiveProfiles("test")
public class CatalogDbClientTest {
+
public static final String MTN13 = "mtn13";
-
+
@LocalServerPort
private int port;
@Value("${mso.db.auth}")
private String msoAdaptersAuth;
-
+
@Autowired
CatalogDbClientPortChanger client;
@Before
- public void initialize(){
- client.wiremockPort= String.valueOf(port);
+ public void initialize() {
+ client.wiremockPort = String.valueOf(port);
}
@Test
- public void testGetRainyDayHandlerStatusByFlowNameAndServiceTypeAndVnfTypeAndErrorCodeAndWorkStep(){
- RainyDayHandlerStatus rainyDayHandlerStatus = client.getRainyDayHandlerStatusByFlowNameAndServiceTypeAndVnfTypeAndErrorCodeAndWorkStep("AssignServiceInstanceBB", "*", "*", "*", "*");
+ public void testGetRainyDayHandlerStatusByFlowNameAndServiceTypeAndVnfTypeAndErrorCodeAndWorkStep() {
+ RainyDayHandlerStatus rainyDayHandlerStatus = client
+ .getRainyDayHandlerStatusByFlowNameAndServiceTypeAndVnfTypeAndErrorCodeAndWorkStep(
+ "AssignServiceInstanceBB", "*", "*", "*", "*");
Assert.assertEquals("Rollback", rainyDayHandlerStatus.getPolicy());
}
@Test
- public void testGetRainyDayHandlerStatusByFlowNameAndServiceTypeAndVnfTypeAndErrorCodeAndWorkStepRecordNotFound(){
- RainyDayHandlerStatus rainyDayHandlerStatus = client.getRainyDayHandlerStatusByFlowNameAndServiceTypeAndVnfTypeAndErrorCodeAndWorkStep(UUID.randomUUID().toString(), "*", "*", "*", "*");
+ public void testGetRainyDayHandlerStatusByFlowNameAndServiceTypeAndVnfTypeAndErrorCodeAndWorkStepRecordNotFound() {
+ RainyDayHandlerStatus rainyDayHandlerStatus = client
+ .getRainyDayHandlerStatusByFlowNameAndServiceTypeAndVnfTypeAndErrorCodeAndWorkStep(
+ UUID.randomUUID().toString(), "*", "*", "*", "*");
Assert.assertNull(rainyDayHandlerStatus);
}
@@ -184,7 +193,8 @@ public class CatalogDbClientTest {
@Test
public void testGetVnfResourceCustomizationByModelCustomizationUUID() {
- VnfResourceCustomization vnfResourceCustomization = client.getVnfResourceCustomizationByModelCustomizationUUID("68dc9a92-214c-11e7-93ae-92361f002671");
+ VnfResourceCustomization vnfResourceCustomization = client
+ .getVnfResourceCustomizationByModelCustomizationUUID("68dc9a92-214c-11e7-93ae-92361f002671");
Assert.assertNotNull(vnfResourceCustomization);
Assert.assertEquals("vSAMP", vnfResourceCustomization.getNfRole());
Assert.assertNotNull(vnfResourceCustomization.getModelCustomizationUUID());
@@ -196,7 +206,8 @@ public class CatalogDbClientTest {
@Test
public void testGetVnfResourceCustomizationByModelCustomizationUUINotFound() {
- VnfResourceCustomization vnfResourceCustomization = client.getVnfResourceCustomizationByModelCustomizationUUID(UUID.randomUUID().toString());
+ VnfResourceCustomization vnfResourceCustomization = client
+ .getVnfResourceCustomizationByModelCustomizationUUID(UUID.randomUUID().toString());
Assert.assertNull(vnfResourceCustomization);
}
@@ -205,12 +216,14 @@ public class CatalogDbClientTest {
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());
+ Assert.assertEquals("org.openecomp.resource.cr.NetworkCollectionResource1806",
+ instanceGroup.getToscaNodeType().toString());
}
@Test
public void testGetVfModuleCustomizationByModelCuztomizationUUID() {
- VfModuleCustomization vfModuleCustomization = client.getVfModuleCustomizationByModelCuztomizationUUID("cb82ffd8-252a-11e7-93ae-92361f002671");
+ VfModuleCustomization vfModuleCustomization = client
+ .getVfModuleCustomizationByModelCuztomizationUUID("cb82ffd8-252a-11e7-93ae-92361f002671");
Assert.assertNotNull(vfModuleCustomization);
Assert.assertNotNull(vfModuleCustomization.getModelCustomizationUUID());
Assert.assertEquals("base", vfModuleCustomization.getLabel());
@@ -218,13 +231,15 @@ public class CatalogDbClientTest {
@Test
public void testGetVfModuleCustomizationByModelCuztomizationUUIDNotFound() {
- VfModuleCustomization vfModuleCustomization = client.getVfModuleCustomizationByModelCuztomizationUUID(UUID.randomUUID().toString());
+ VfModuleCustomization vfModuleCustomization = client
+ .getVfModuleCustomizationByModelCuztomizationUUID(UUID.randomUUID().toString());
Assert.assertNull(vfModuleCustomization);
}
@Test
public void testGetNetworkResourceCustomizationByModelCustomizationUUID() {
- NetworkResourceCustomization networkResourceCustomization = client.getNetworkResourceCustomizationByModelCustomizationUUID("3bdbb104-476c-483e-9f8b-c095b3d308ac");
+ NetworkResourceCustomization networkResourceCustomization = client
+ .getNetworkResourceCustomizationByModelCustomizationUUID("3bdbb104-476c-483e-9f8b-c095b3d308ac");
Assert.assertNotNull(networkResourceCustomization);
Assert.assertNotNull(networkResourceCustomization.getModelCustomizationUUID());
Assert.assertEquals("CONTRAIL30_GNDIRECT 9", networkResourceCustomization.getModelInstanceName());
@@ -233,13 +248,16 @@ public class CatalogDbClientTest {
@Test
public void testGetNetworkResourceCustomizationByModelCustomizationUUIDNotFound() {
- NetworkResourceCustomization networkResourceCustomization = client.getNetworkResourceCustomizationByModelCustomizationUUID(UUID.randomUUID().toString());
+ 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");
+ 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());
@@ -248,29 +266,35 @@ public class CatalogDbClientTest {
@Test
public void testGgetVfModuleCustomizationByModelCustomizationUUIDAndVfModuleModelUUIDNotFound() {
- VfModuleCustomization vfModuleCustomization = client.getVfModuleCustomizationByModelCustomizationUUIDAndVfModuleModelUUID("cb82ffd8-252a-11e7-93ae-92361f002672", UUID.randomUUID().toString());
+ 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");
+ 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("/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());
+ 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");
+ VnfResource vnfResource = client
+ .getFirstVnfResourceByModelInvariantUUIDAndModelVersion("2fff5b20-214b-11e7-93ae-92361f002671", "2.0");
Assert.assertNotNull(vnfResource);
Assert.assertNotNull(vnfResource.getModelInvariantId());
Assert.assertNotNull(vnfResource.getModelVersion());
@@ -281,7 +305,9 @@ public class CatalogDbClientTest {
@Test
public void testGetFirstVnfResourceByModelInvariantUUIDAndModelVersionNotFound() {
- VnfResource vnfResource = client.getFirstVnfResourceByModelInvariantUUIDAndModelVersion("2fff5b20-214b-11e7-93ae-92361f002671", UUID.randomUUID().toString());
+ VnfResource vnfResource = client
+ .getFirstVnfResourceByModelInvariantUUIDAndModelVersion("2fff5b20-214b-11e7-93ae-92361f002671",
+ UUID.randomUUID().toString());
Assert.assertNull(vnfResource);
}
@@ -289,12 +315,15 @@ public class CatalogDbClientTest {
public void testGetFirstVnfResourceCustomizationByModelInstanceNameAndVnfResources() {
VnfResource vnfr = new VnfResource();
vnfr.setModelUUID("ff2ae348-214a-11e7-93ae-92361f002671");
- VnfResourceCustomization firstVnfResourceCustomizationByModelInstanceNameAndVnfResources = client.getFirstVnfResourceCustomizationByModelInstanceNameAndVnfResources("vSAMP10a 1", vnfr);
+ VnfResourceCustomization firstVnfResourceCustomizationByModelInstanceNameAndVnfResources = client
+ .getFirstVnfResourceCustomizationByModelInstanceNameAndVnfResources("vSAMP10a 1", vnfr);
Assert.assertNotNull(firstVnfResourceCustomizationByModelInstanceNameAndVnfResources);
Assert.assertEquals("vSAMP", firstVnfResourceCustomizationByModelInstanceNameAndVnfResources.getNfRole());
- Assert.assertEquals("vSAMP10a 1", firstVnfResourceCustomizationByModelInstanceNameAndVnfResources.getModelInstanceName());
+ Assert.assertEquals("vSAMP10a 1",
+ firstVnfResourceCustomizationByModelInstanceNameAndVnfResources.getModelInstanceName());
Assert.assertNotNull(firstVnfResourceCustomizationByModelInstanceNameAndVnfResources.getVnfResources());
- Assert.assertNotNull(firstVnfResourceCustomizationByModelInstanceNameAndVnfResources.getVfModuleCustomizations());
+ Assert
+ .assertNotNull(firstVnfResourceCustomizationByModelInstanceNameAndVnfResources.getVfModuleCustomizations());
}
@Test
@@ -315,7 +344,9 @@ public class CatalogDbClientTest {
@Test
public void testGetFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction() {
- VnfComponentsRecipe vnfComponentsRecipe = client.getFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction("20c4431c-246d-11e7-93ae-92361f002671", "volumeGroup", "createInstance");
+ VnfComponentsRecipe vnfComponentsRecipe = client
+ .getFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction(
+ "20c4431c-246d-11e7-93ae-92361f002671", "volumeGroup", "createInstance");
Assert.assertNotNull(vnfComponentsRecipe);
Assert.assertNotNull(vnfComponentsRecipe.getAction());
Assert.assertNotNull(vnfComponentsRecipe.getVfModuleModelUUID());
@@ -328,23 +359,28 @@ public class CatalogDbClientTest {
@Test
public void testGetFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndActionNotFound() {
- VnfComponentsRecipe vnfComponentsRecipe = client.getFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction(UUID.randomUUID().toString(), "volumeGroup", "createInstance");
+ VnfComponentsRecipe vnfComponentsRecipe = client
+ .getFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction(UUID.randomUUID().toString(),
+ "volumeGroup", "createInstance");
Assert.assertNull(vnfComponentsRecipe);
}
@Test
public void testGetFirstVnfComponentsRecipeByVnfComponentTypeAndAction() {
- VnfComponentsRecipe vnfComponentsRecipe = client.getFirstVnfComponentsRecipeByVnfComponentTypeAndAction("volumeGroup", "createInstance");
+ 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());
+ Assert
+ .assertEquals("/mso/async/services/CreateVfModuleVolumeInfraV1", vnfComponentsRecipe.getOrchestrationUri());
}
@Test
public void testGetServiceByModelVersionAndModelInvariantUUID() {
- Service service = client.getServiceByModelVersionAndModelInvariantUUID("2.0", "9647dfc4-2083-11e7-93ae-92361f002671");
+ Service service = client
+ .getServiceByModelVersionAndModelInvariantUUID("2.0", "9647dfc4-2083-11e7-93ae-92361f002671");
Assert.assertNotNull(service);
Assert.assertNotNull(service.getModelVersion());
Assert.assertNotNull(service.getModelInvariantUUID());
@@ -360,7 +396,8 @@ public class CatalogDbClientTest {
@Test
public void testGetVfModuleByModelInvariantUUIDAndModelVersion() {
- VfModule vfModule = client.getVfModuleByModelInvariantUUIDAndModelVersion("78ca26d0-246d-11e7-93ae-92361f002671", "2");
+ VfModule vfModule = client
+ .getVfModuleByModelInvariantUUIDAndModelVersion("78ca26d0-246d-11e7-93ae-92361f002671", "2");
Assert.assertNotNull(vfModule);
Assert.assertNotNull(vfModule.getModelVersion());
Assert.assertNotNull(vfModule.getModelInvariantUUID());
@@ -373,10 +410,11 @@ public class CatalogDbClientTest {
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");
+ List<Service> serviceList = client
+ .getServiceByModelInvariantUUIDOrderByModelVersionDesc("9647dfc4-2083-11e7-93ae-92361f002671");
Assert.assertFalse(serviceList.isEmpty());
Assert.assertEquals(2, serviceList.size());
Service service = serviceList.get(0);
@@ -385,22 +423,25 @@ public class CatalogDbClientTest {
@Test
public void testGetServiceByModelInvariantUUIDOrderByModelVersionDescNotFound() {
- List<Service> serviceList = client.getServiceByModelInvariantUUIDOrderByModelVersionDesc(UUID.randomUUID().toString());
+ 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");
+ 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());
+ Assert.assertEquals("vSAMP10a DEV Base", module.getDescription());
}
@Test
public void testPostCloudSite() {
- CatalogDbClientPortChanger localClient = new CatalogDbClientPortChanger("http://localhost:" + client.wiremockPort, msoAdaptersAuth, client.wiremockPort);
+ CatalogDbClientPortChanger localClient = new CatalogDbClientPortChanger(
+ "http://localhost:" + client.wiremockPort, msoAdaptersAuth, client.wiremockPort);
CloudSite cloudSite = new CloudSite();
cloudSite.setId("MTN6");
cloudSite.setClli("TESTCLLI");
@@ -438,60 +479,61 @@ public class CatalogDbClientTest {
@Test
public void testPostHomingInstance() {
- CatalogDbClientPortChanger localClient = new CatalogDbClientPortChanger("http://localhost:" + client.wiremockPort, msoAdaptersAuth, client.wiremockPort);
+ CatalogDbClientPortChanger localClient = new CatalogDbClientPortChanger(
+ "http://localhost:" + client.wiremockPort, msoAdaptersAuth, client.wiremockPort);
HomingInstance homingInstance = new HomingInstance();
homingInstance.setServiceInstanceId("5df8d6be-2083-11e7-93ae-92361f232671");
homingInstance.setCloudOwner("CloudOwner-1");
homingInstance.setCloudRegionId("CloudRegionOne");
homingInstance.setOofDirectives("{\n" +
- "\"directives\": [\n" +
- "{\n" +
- "\"directives\": [\n" +
- "{\n" +
- "\"attributes\": [\n" +
- "{\n" +
- "\"attribute_value\": \"onap.hpa.flavor31\",\n" +
- "\"attribute_name\": \"firewall_flavor_name\"\n" +
- "}\n" +
- "],\n" +
- "\"type\": \"flavor_directives\"\n" +
- "}\n" +
- "],\n" +
- "\"type\": \"vnfc\",\n" +
- "\"id\": \"vfw\"\n" +
- "},\n" +
- "{\n" +
- "\"directives\": [\n" +
- "{\n" +
- "\"attributes\": [\n" +
- "{\n" +
- "\"attribute_value\": \"onap.hpa.flavor32\",\n" +
- "\"attribute_name\": \"packetgen_flavor_name\"\n" +
- "}\n" +
- "],\n" +
- "\"type\": \"flavor_directives\"\n" +
- "}\n" +
- "],\n" +
- "\"type\": \"vnfc\",\n" +
- "\"id\": \"vgenerator\"\n" +
- "},\n" +
- "{\n" +
- "\"directives\": [\n" +
- "{\n" +
- "\"attributes\": [\n" +
- "{\n" +
- "\"attribute_value\": \"onap.hpa.flavor31\",\n" +
- "\"attribute_name\": \"sink_flavor_name\"\n" +
- "}\n" +
- "],\n" +
- "\"type\": \"flavor_directives\"\n" +
- "}\n" +
- "],\n" +
- "\"type\": \"vnfc\",\n" +
- "\"id\": \"vsink\"\n" +
- "}\n" +
- "]\n" +
- "}");
+ "\"directives\": [\n" +
+ "{\n" +
+ "\"directives\": [\n" +
+ "{\n" +
+ "\"attributes\": [\n" +
+ "{\n" +
+ "\"attribute_value\": \"onap.hpa.flavor31\",\n" +
+ "\"attribute_name\": \"firewall_flavor_name\"\n" +
+ "}\n" +
+ "],\n" +
+ "\"type\": \"flavor_directives\"\n" +
+ "}\n" +
+ "],\n" +
+ "\"type\": \"vnfc\",\n" +
+ "\"id\": \"vfw\"\n" +
+ "},\n" +
+ "{\n" +
+ "\"directives\": [\n" +
+ "{\n" +
+ "\"attributes\": [\n" +
+ "{\n" +
+ "\"attribute_value\": \"onap.hpa.flavor32\",\n" +
+ "\"attribute_name\": \"packetgen_flavor_name\"\n" +
+ "}\n" +
+ "],\n" +
+ "\"type\": \"flavor_directives\"\n" +
+ "}\n" +
+ "],\n" +
+ "\"type\": \"vnfc\",\n" +
+ "\"id\": \"vgenerator\"\n" +
+ "},\n" +
+ "{\n" +
+ "\"directives\": [\n" +
+ "{\n" +
+ "\"attributes\": [\n" +
+ "{\n" +
+ "\"attribute_value\": \"onap.hpa.flavor31\",\n" +
+ "\"attribute_name\": \"sink_flavor_name\"\n" +
+ "}\n" +
+ "],\n" +
+ "\"type\": \"flavor_directives\"\n" +
+ "}\n" +
+ "],\n" +
+ "\"type\": \"vnfc\",\n" +
+ "\"id\": \"vsink\"\n" +
+ "}\n" +
+ "]\n" +
+ "}");
localClient.postHomingInstance(homingInstance);
HomingInstance getHomingInstance = this.client.getHomingInstance("5df8d6be-2083-11e7-93ae-92361f232671");
Assert.assertNotNull(getHomingInstance);
@@ -501,7 +543,7 @@ public class CatalogDbClientTest {
Assert.assertEquals("CloudRegionOne", getHomingInstance.getCloudRegionId());
}
- @Test
+ @Test
public void testGetServiceByModelName() {
Service service = client.getServiceByModelName("MSOTADevInfra_Test_Service");
Assert.assertNotNull(service);
@@ -534,39 +576,44 @@ public class CatalogDbClientTest {
}
@Test
- public void testGetNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner(){
- NorthBoundRequest northBoundRequest = new NorthBoundRequest();
- northBoundRequest.setAction("createService");
- northBoundRequest.setRequestScope("service");
- northBoundRequest.setIsAlacarte(true);
- northBoundRequest.setCloudOwner("my-custom-cloud-owner");
- client.getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner("createService", "service", true, "my-custom-cloud-owner");
- Assert.assertNotNull(northBoundRequest);
- Assert.assertEquals("createService",northBoundRequest.getAction());
- Assert.assertEquals("service",northBoundRequest.getRequestScope());
- Assert.assertEquals(true,northBoundRequest.getIsAlacarte() );
- Assert.assertEquals("my-custom-cloud-owner", northBoundRequest.getCloudOwner());
+ public void testGetNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner() {
+ NorthBoundRequest northBoundRequest = new NorthBoundRequest();
+ northBoundRequest.setAction("createService");
+ northBoundRequest.setRequestScope("service");
+ northBoundRequest.setIsAlacarte(true);
+ northBoundRequest.setCloudOwner("my-custom-cloud-owner");
+ client.getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner("createService", "service", true,
+ "my-custom-cloud-owner");
+ Assert.assertNotNull(northBoundRequest);
+ Assert.assertEquals("createService", northBoundRequest.getAction());
+ Assert.assertEquals("service", northBoundRequest.getRequestScope());
+ Assert.assertEquals(true, northBoundRequest.getIsAlacarte());
+ Assert.assertEquals("my-custom-cloud-owner", northBoundRequest.getCloudOwner());
}
-
+
@Test
public void testFindServiceRecipeByActionAndServiceModelUUID() {
- ServiceRecipe serviceRecipe = client.findServiceRecipeByActionAndServiceModelUUID("createInstance","4694a55f-58b3-4f17-92a5-796d6f5ffd0d" );
+ ServiceRecipe serviceRecipe = client
+ .findServiceRecipeByActionAndServiceModelUUID("createInstance", "4694a55f-58b3-4f17-92a5-796d6f5ffd0d");
Assert.assertNotNull(serviceRecipe);
Assert.assertNotNull(serviceRecipe.getServiceModelUUID());
Assert.assertNotNull(serviceRecipe.getAction());
- Assert.assertEquals("/mso/async/services/CreateGenericALaCarteServiceInstance", serviceRecipe.getOrchestrationUri());
+ Assert.assertEquals("/mso/async/services/CreateGenericALaCarteServiceInstance",
+ serviceRecipe.getOrchestrationUri());
Assert.assertEquals("MSOTADevInfra aLaCarte", serviceRecipe.getDescription());
}
@Test
public void testFindServiceRecipeByActionAndServiceModelUUIDNotFound() {
- ServiceRecipe serviceRecipe = client.findServiceRecipeByActionAndServiceModelUUID("not_found","5df8b6de-2083-11e7-93ae-test" );
+ ServiceRecipe serviceRecipe = client
+ .findServiceRecipeByActionAndServiceModelUUID("not_found", "5df8b6de-2083-11e7-93ae-test");
Assert.assertNull(serviceRecipe);
}
@Test
public void testFindExternalToInternalServiceByServiceName() {
- ExternalServiceToInternalService externalServiceToInternalService = client.findExternalToInternalServiceByServiceName("MySpecialServiceName");
+ ExternalServiceToInternalService externalServiceToInternalService = client
+ .findExternalToInternalServiceByServiceName("MySpecialServiceName");
Assert.assertNotNull(externalServiceToInternalService);
Assert.assertNotNull(externalServiceToInternalService.getServiceName());
Assert.assertNotNull(externalServiceToInternalService.getServiceModelUUID());
@@ -575,7 +622,51 @@ public class CatalogDbClientTest {
@Test
public void testFindExternalToInternalServiceByServiceNameNotFound() {
- ExternalServiceToInternalService externalServiceToInternalService = client.findExternalToInternalServiceByServiceName("Not_Found");
+ ExternalServiceToInternalService externalServiceToInternalService = client
+ .findExternalToInternalServiceByServiceName("Not_Found");
Assert.assertNull(externalServiceToInternalService);
}
+
+ @Test
+ public void getPnfResourceByModelUUID_validUuid_expectedOutput() {
+ PnfResource pnfResource = client.getPnfResourceByModelUUID("ff2ae348-214a-11e7-93ae-92361f002680");
+ Assert.assertNotNull(pnfResource);
+ assertEquals("PNFResource modelUUID", "ff2ae348-214a-11e7-93ae-92361f002680", pnfResource.getModelUUID());
+ assertEquals("PNFResource modelInvariantUUID", "2fff5b20-214b-11e7-93ae-92361f002680",
+ pnfResource.getModelInvariantUUID());
+ assertEquals("PNFResource modelVersion", "1.0", pnfResource.getModelVersion());
+ assertEquals("PNFResource orchestration mode", "", pnfResource.getOrchestrationMode());
+ }
+
+ @Test
+ public void getPnfResourceByModelUUID_invalidUuid_NullOutput() {
+ PnfResource pnfResource = client.getPnfResourceByModelUUID(UUID.randomUUID().toString());
+ Assert.assertNull(pnfResource);
+ }
+
+ @Test
+ public void getPnfResourceCustomizationByModelCustomizationUUID_validUuid_expectedOutput() {
+ PnfResourceCustomization pnfResourceCustomization = client
+ .getPnfResourceCustomizationByModelCustomizationUUID("68dc9a92-214c-11e7-93ae-92361f002680");
+ assertEquals("modelInstanceName", "PNF routing", pnfResourceCustomization.getModelInstanceName());
+ assertEquals("blueprintName", "test_configuration_restconf", pnfResourceCustomization.getBlueprintName());
+ assertEquals("blueprintVersion", "1.0.0", pnfResourceCustomization.getBlueprintVersion());
+ PnfResource pnfResource = pnfResourceCustomization.getPnfResources();
+ assertNotNull(pnfResource);
+
+ assertEquals("PNFResource modelUUID", "ff2ae348-214a-11e7-93ae-92361f002680", pnfResource.getModelUUID());
+ assertEquals("PNFResource modelInvariantUUID", "2fff5b20-214b-11e7-93ae-92361f002680",
+ pnfResource.getModelInvariantUUID());
+ assertEquals("PNFResource modelVersion", "1.0", pnfResource.getModelVersion());
+ assertEquals("PNFResource orchestration mode", "", pnfResource.getOrchestrationMode());
+
+ }
+
+ @Test
+ public void getPnfResourceCustomizationByModelCustomizationUUID_invalidUuid_nullOutput() {
+ PnfResourceCustomization pnfResourceCustomization = client
+ .getPnfResourceCustomizationByModelCustomizationUUID(UUID.randomUUID().toString());
+ Assert.assertNull(pnfResourceCustomization);
+ }
+
}
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 1223080e59..91deab8fff 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
@@ -293,3 +293,15 @@ VALUES ( '1',
'68dc9a92-214c-11e7-93ae-92361f002671',
'cb82ffd8-252a-11e7-93ae-92361f002671',
'9bcce658-9b37-11e8-98d0-529269fb1459');
+
+insert into service(model_uuid, model_name, model_invariant_uuid, model_version, description, creation_timestamp, tosca_csar_artifact_uuid, service_type, service_role, environment_context, workload_context) values
+('5df8b6de-2083-11e7-93ae-92361f002676', 'PNF_routing_service', '9647dfc4-2083-11e7-93ae-92361f002676', '1.0', 'PNF service', '2019-03-08 12:00:29', null, 'NA', 'NA', 'Luna', 'Oxygen');
+
+insert into pnf_resource(orchestration_mode, description, creation_timestamp, model_uuid, model_invariant_uuid, model_version, model_name, tosca_node_type) values
+('', 'PNF routing', '2019-03-08 12:00:28', 'ff2ae348-214a-11e7-93ae-92361f002680', '2fff5b20-214b-11e7-93ae-92361f002680', '1.0', 'PNF resource', null);
+
+insert into pnf_resource_customization(model_customization_uuid, model_instance_name, nf_type, nf_role, nf_function, nf_naming_code, creation_timestamp, pnf_resource_model_uuid, multi_stage_design, cds_blueprint_name, cds_blueprint_version) values
+('68dc9a92-214c-11e7-93ae-92361f002680', 'PNF routing', 'routing', 'routing', 'routing', 'routing', '2019-03-08 12:00:29', 'ff2ae348-214a-11e7-93ae-92361f002680', null, "test_configuration_restconf", "1.0.0");
+
+insert into pnf_resource_customization_to_service(service_model_uuid, resource_model_customization_uuid) values
+('5df8b6de-2083-11e7-93ae-92361f002676', '68dc9a92-214c-11e7-93ae-92361f002680'); \ No newline at end of file