2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 - 2018 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
21 package org.onap.so.db.catalog.client;
24 import static org.junit.Assert.assertEquals;
25 import static org.junit.Assert.assertNotNull;
26 import static org.junit.Assert.assertTrue;
27 import java.util.List;
28 import java.util.UUID;
29 import org.junit.Assert;
30 import org.junit.Before;
31 import org.junit.Test;
32 import org.junit.runner.RunWith;
33 import org.onap.so.adapters.catalogdb.CatalogDBApplication;
34 import org.onap.so.adapters.catalogdb.CatalogDbAdapterBaseTest;
35 import org.onap.so.db.catalog.beans.AuthenticationType;
36 import org.onap.so.db.catalog.beans.CloudIdentity;
37 import org.onap.so.db.catalog.beans.CloudSite;
38 import org.onap.so.db.catalog.beans.CloudifyManager;
39 import org.onap.so.db.catalog.beans.ExternalServiceToInternalService;
40 import org.onap.so.db.catalog.beans.HomingInstance;
41 import org.onap.so.db.catalog.beans.InstanceGroup;
42 import org.onap.so.db.catalog.beans.NetworkResourceCustomization;
43 import org.onap.so.db.catalog.beans.PnfResource;
44 import org.onap.so.db.catalog.beans.PnfResourceCustomization;
45 import org.onap.so.db.catalog.beans.ServerType;
46 import org.onap.so.db.catalog.beans.Service;
47 import org.onap.so.db.catalog.beans.ServiceRecipe;
48 import org.onap.so.db.catalog.beans.VfModule;
49 import org.onap.so.db.catalog.beans.VfModuleCustomization;
50 import org.onap.so.db.catalog.beans.VnfComponentsRecipe;
51 import org.onap.so.db.catalog.beans.VnfRecipe;
52 import org.onap.so.db.catalog.beans.VnfResource;
53 import org.onap.so.db.catalog.beans.VnfResourceCustomization;
54 import org.onap.so.db.catalog.beans.Workflow;
55 import org.onap.so.db.catalog.beans.macro.NorthBoundRequest;
56 import org.onap.so.db.catalog.beans.macro.RainyDayHandlerStatus;
57 import org.springframework.beans.factory.annotation.Autowired;
58 import org.springframework.beans.factory.annotation.Value;
59 import org.springframework.boot.test.context.SpringBootTest;
60 import org.springframework.boot.web.server.LocalServerPort;
61 import org.springframework.test.context.ActiveProfiles;
62 import org.springframework.test.context.junit4.SpringRunner;
64 public class CatalogDbClientTest extends CatalogDbAdapterBaseTest {
66 public static final String MTN13 = "mtn13";
71 @Value("${mso.db.auth}")
72 private String msoAdaptersAuth;
75 CatalogDbClientPortChanger client;
78 public void initialize() {
79 client.wiremockPort = String.valueOf(port);
84 public void testGetRainyDayHandler_Regex() {
85 RainyDayHandlerStatus rainyDayHandlerStatus = client.getRainyDayHandlerStatus("AssignServiceInstanceBB", "*",
86 "*", "*", "*", "The Flavor ID (nd.c6r16d20) could not be found.");
87 Assert.assertEquals("Rollback", rainyDayHandlerStatus.getPolicy());
91 public void testGetCloudSiteHappyPath() throws Exception {
92 CloudSite cloudSite = client.getCloudSite(MTN13);
93 Assert.assertNotNull(cloudSite);
94 Assert.assertNotNull(cloudSite.getIdentityService());
95 Assert.assertEquals("MDT13", cloudSite.getClli());
96 Assert.assertEquals("mtn13", cloudSite.getRegionId());
97 Assert.assertEquals("MTN13", cloudSite.getIdentityServiceId());
101 public void testGetCloudSiteNotFound() throws Exception {
102 CloudSite cloudSite = client.getCloudSite(UUID.randomUUID().toString());
103 Assert.assertNull(cloudSite);
107 public void testGetCloudifyManagerHappyPath() throws Exception {
108 CloudifyManager cloudifyManager = client.getCloudifyManager("mtn13");
109 Assert.assertNotNull(cloudifyManager);
110 Assert.assertEquals("http://localhost:28090/v2.0", cloudifyManager.getCloudifyUrl());
115 public void testGetCloudifyManagerNotFound() throws Exception {
116 CloudifyManager cloudifyManager = client.getCloudifyManager(UUID.randomUUID().toString());
117 Assert.assertNull(cloudifyManager);
122 public void testGetCloudSiteByClliAndAicVersionHappyPath() throws Exception {
123 CloudSite cloudSite = client.getCloudSiteByClliAndAicVersion("MDT13", "2.5");
124 Assert.assertNotNull(cloudSite);
128 public void testGetCloudSiteByClliAndAicVersionNotFound() throws Exception {
129 CloudSite cloudSite = client.getCloudSiteByClliAndAicVersion("MDT13", "232496239746328");
130 Assert.assertNull(cloudSite);
134 public void testGetServiceByID() throws Exception {
135 Service serviceByID = client.getServiceByID("5df8b6de-2083-11e7-93ae-92361f002671");
136 Assert.assertNotNull(serviceByID);
137 Assert.assertEquals("MSOTADevInfra_vSAMP10a_Service", serviceByID.getModelName());
138 Assert.assertEquals("NA", serviceByID.getServiceType());
139 Assert.assertEquals("NA", serviceByID.getServiceRole());
143 public void testGetServiceByIDNotFound() throws Exception {
144 Service serviceByID = client.getServiceByID(UUID.randomUUID().toString());
145 Assert.assertNull(serviceByID);
149 public void testGetVfModuleByModelUUID() throws Exception {
150 VfModule vfModule = client.getVfModuleByModelUUID("20c4431c-246d-11e7-93ae-92361f002671");
151 Assert.assertNotNull(vfModule);
152 Assert.assertNotNull(vfModule.getVfModuleCustomization());
153 Assert.assertEquals("78ca26d0-246d-11e7-93ae-92361f002671", vfModule.getModelInvariantUUID());
154 Assert.assertEquals("vSAMP10aDEV::base::module-0", vfModule.getModelName());
158 public void testGetVfModuleByModelUUIDNotFound() throws Exception {
159 VfModule vfModule = client.getVfModuleByModelUUID(UUID.randomUUID().toString());
160 Assert.assertNull(vfModule);
164 public void testGetVnfResourceByModelUUID() throws Exception {
165 VnfResource vnfResource = client.getVnfResourceByModelUUID("ff2ae348-214a-11e7-93ae-92361f002671");
166 Assert.assertNotNull(vnfResource);
167 Assert.assertEquals("vSAMP10a", vnfResource.getModelName());
171 public void testGetVnfResourceByModelUUIDNotFound() throws Exception {
172 VnfResource vnfResource = client.getVnfResourceByModelUUID(UUID.randomUUID().toString());
173 Assert.assertNull(vnfResource);
177 public void testGetVnfResourceCustomizationByModelCustomizationUUID() {
178 VnfResourceCustomization vnfResourceCustomization =
179 client.getVnfResourceCustomizationByModelCustomizationUUID("68dc9a92-214c-11e7-93ae-92361f002671");
180 Assert.assertNotNull(vnfResourceCustomization);
181 Assert.assertEquals("vSAMP", vnfResourceCustomization.getNfRole());
182 Assert.assertNotNull(vnfResourceCustomization.getModelCustomizationUUID());
183 Assert.assertNotNull(vnfResourceCustomization.getVnfResources());
184 Assert.assertNotNull(vnfResourceCustomization.getVfModuleCustomizations());
185 Assert.assertEquals("vSAMP10a", vnfResourceCustomization.getVnfResources().getModelName());
186 assertTrue("skip post instantiation configuration", vnfResourceCustomization.isSkipPostInstConf());
190 public void testGetVnfResourceCustomizationByModelCustomizationUUINotFound() {
191 VnfResourceCustomization vnfResourceCustomization =
192 client.getVnfResourceCustomizationByModelCustomizationUUID(UUID.randomUUID().toString());
193 Assert.assertNull(vnfResourceCustomization);
197 public void testGetInstanceGroupByModelUUID() {
198 InstanceGroup instanceGroup = client.getInstanceGroupByModelUUID("0c8692ef-b9c0-435d-a738-edf31e71f38b");
199 Assert.assertNotNull(instanceGroup);
200 Assert.assertEquals("network_collection_resource_1806..NetworkCollection..0", instanceGroup.getModelName());
201 Assert.assertEquals("org.openecomp.resource.cr.NetworkCollectionResource1806",
202 instanceGroup.getToscaNodeType().toString());
206 public void testGetVfModuleCustomizationByModelCuztomizationUUID() {
207 VfModuleCustomization vfModuleCustomization =
208 client.getVfModuleCustomizationByModelCuztomizationUUID("cb82ffd8-252a-11e7-93ae-92361f002671");
209 Assert.assertNotNull(vfModuleCustomization);
210 Assert.assertNotNull(vfModuleCustomization.getModelCustomizationUUID());
211 Assert.assertEquals("base", vfModuleCustomization.getLabel());
215 public void testGetVfModuleCustomizationByModelCuztomizationUUIDNotFound() {
216 VfModuleCustomization vfModuleCustomization =
217 client.getVfModuleCustomizationByModelCuztomizationUUID(UUID.randomUUID().toString());
218 Assert.assertNull(vfModuleCustomization);
222 public void testGetNetworkResourceCustomizationByModelCustomizationUUID() {
223 NetworkResourceCustomization networkResourceCustomization =
224 client.getNetworkResourceCustomizationByModelCustomizationUUID("3bdbb104-476c-483e-9f8b-c095b3d308ac");
225 Assert.assertNotNull(networkResourceCustomization);
226 Assert.assertNotNull(networkResourceCustomization.getModelCustomizationUUID());
227 Assert.assertEquals("CONTRAIL30_GNDIRECT 9", networkResourceCustomization.getModelInstanceName());
228 Assert.assertNotNull(networkResourceCustomization.getNetworkResource());
232 public void testGetNetworkResourceCustomizationByModelCustomizationUUIDNotFound() {
233 NetworkResourceCustomization networkResourceCustomization =
234 client.getNetworkResourceCustomizationByModelCustomizationUUID(UUID.randomUUID().toString());
235 Assert.assertNull(networkResourceCustomization);
239 public void testGgetVfModuleCustomizationByModelCustomizationUUIDAndVfModuleModelUUID() {
240 VfModuleCustomization vfModuleCustomization =
241 client.getVfModuleCustomizationByModelCustomizationUUIDAndVfModuleModelUUID(
242 "cb82ffd8-252a-11e7-93ae-92361f002672", "20c4431c-246d-11e7-93ae-92361f002672");
243 Assert.assertNotNull(vfModuleCustomization);
244 Assert.assertNotNull(vfModuleCustomization.getModelCustomizationUUID());
245 Assert.assertNotNull(vfModuleCustomization.getVfModule());
246 Assert.assertEquals("base", vfModuleCustomization.getLabel());
250 public void testGgetVfModuleCustomizationByModelCustomizationUUIDAndVfModuleModelUUIDNotFound() {
251 VfModuleCustomization vfModuleCustomization =
252 client.getVfModuleCustomizationByModelCustomizationUUIDAndVfModuleModelUUID(
253 "cb82ffd8-252a-11e7-93ae-92361f002672", UUID.randomUUID().toString());
254 Assert.assertNull(vfModuleCustomization);
258 public void testGetFirstByServiceModelUUIDAndAction() {
259 ServiceRecipe serviceRecipe =
260 client.getFirstByServiceModelUUIDAndAction("4694a55f-58b3-4f17-92a5-796d6f5ffd0d", "createInstance");
261 Assert.assertNotNull(serviceRecipe);
262 Assert.assertNotNull(serviceRecipe.getServiceModelUUID());
263 Assert.assertNotNull(serviceRecipe.getAction());
264 Assert.assertEquals("/mso/async/services/CreateGenericALaCarteServiceInstance",
265 serviceRecipe.getOrchestrationUri());
266 Assert.assertEquals("MSOTADevInfra aLaCarte", serviceRecipe.getDescription());
270 public void testGetFirstByServiceModelUUIDAndActionNotFound() {
271 ServiceRecipe serviceRecipe = client.getFirstByServiceModelUUIDAndAction("5df8b6de-2083-11e7-93ae-92361f002671",
272 UUID.randomUUID().toString());
273 Assert.assertNull(serviceRecipe);
277 public void testGetFirstVnfResourceByModelInvariantUUIDAndModelVersion() {
278 VnfResource vnfResource = client
279 .getFirstVnfResourceByModelInvariantUUIDAndModelVersion("2fff5b20-214b-11e7-93ae-92361f002671", "2.0");
280 Assert.assertNotNull(vnfResource);
281 Assert.assertNotNull(vnfResource.getModelInvariantId());
282 Assert.assertNotNull(vnfResource.getModelVersion());
283 Assert.assertNotNull(vnfResource.getHeatTemplates());
284 Assert.assertEquals("vSAMP10a", vnfResource.getModelName());
288 public void testGetFirstVnfResourceByModelInvariantUUIDAndModelVersionNotFound() {
289 VnfResource vnfResource = client.getFirstVnfResourceByModelInvariantUUIDAndModelVersion(
290 "2fff5b20-214b-11e7-93ae-92361f002671", UUID.randomUUID().toString());
291 Assert.assertNull(vnfResource);
295 public void testGetFirstVnfResourceCustomizationByModelInstanceNameAndVnfResources() {
296 VnfResource vnfr = new VnfResource();
297 vnfr.setModelUUID("ff2ae348-214a-11e7-93ae-92361f002671");
298 VnfResourceCustomization firstVnfResourceCustomizationByModelInstanceNameAndVnfResources =
299 client.getFirstVnfResourceCustomizationByModelInstanceNameAndVnfResources("vSAMP10a 1", vnfr);
300 Assert.assertNotNull(firstVnfResourceCustomizationByModelInstanceNameAndVnfResources);
301 Assert.assertEquals("vSAMP", firstVnfResourceCustomizationByModelInstanceNameAndVnfResources.getNfRole());
302 Assert.assertEquals("vSAMP10a 1",
303 firstVnfResourceCustomizationByModelInstanceNameAndVnfResources.getModelInstanceName());
304 Assert.assertNotNull(firstVnfResourceCustomizationByModelInstanceNameAndVnfResources.getVnfResources());
305 Assert.assertNotNull(
306 firstVnfResourceCustomizationByModelInstanceNameAndVnfResources.getVfModuleCustomizations());
310 public void testGetFirstVnfRecipeByNfRoleAndAction() {
311 VnfRecipe vnfRecipe = client.getFirstVnfRecipeByNfRoleAndAction("GR-API-DEFAULT", "createInstance");
312 Assert.assertNotNull(vnfRecipe);
313 Assert.assertNotNull(vnfRecipe.getNfRole());
314 Assert.assertNotNull(vnfRecipe.getAction());
315 Assert.assertEquals("Gr api recipe to create vnf", vnfRecipe.getDescription());
316 Assert.assertEquals("/mso/async/services/WorkflowActionBB", vnfRecipe.getOrchestrationUri());
320 public void testGetFirstVnfRecipeByNfRoleAndActionNotFound() {
321 VnfRecipe vnfRecipe = client.getFirstVnfRecipeByNfRoleAndAction(UUID.randomUUID().toString(), "createInstance");
322 Assert.assertNull(vnfRecipe);
326 public void testGetFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction() {
327 VnfComponentsRecipe vnfComponentsRecipe =
328 client.getFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction(
329 "20c4431c-246d-11e7-93ae-92361f002671", "volumeGroup", "createInstance");
330 Assert.assertNotNull(vnfComponentsRecipe);
331 Assert.assertNotNull(vnfComponentsRecipe.getAction());
332 Assert.assertNotNull(vnfComponentsRecipe.getVfModuleModelUUID());
333 Assert.assertNotNull(vnfComponentsRecipe.getVnfComponentType());
334 Assert.assertEquals("Gr api recipe to create volume-group", vnfComponentsRecipe.getDescription());
335 Assert.assertEquals("/mso/async/services/WorkflowActionBB", vnfComponentsRecipe.getOrchestrationUri());
341 public void testGetFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndActionNotFound() {
342 VnfComponentsRecipe vnfComponentsRecipe =
343 client.getFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction(
344 UUID.randomUUID().toString(), "volumeGroup", "createInstance");
345 Assert.assertNull(vnfComponentsRecipe);
349 public void testGetFirstVnfComponentsRecipeByVnfComponentTypeAndAction() {
350 VnfComponentsRecipe vnfComponentsRecipe =
351 client.getFirstVnfComponentsRecipeByVnfComponentTypeAndAction("volumeGroup", "createInstance");
352 Assert.assertNotNull(vnfComponentsRecipe);
353 Assert.assertNotNull(vnfComponentsRecipe.getAction());
354 Assert.assertNotNull(vnfComponentsRecipe.getVnfComponentType());
355 Assert.assertEquals("VID_DEFAULT recipe t", vnfComponentsRecipe.getDescription());
356 Assert.assertEquals("/mso/async/services/CreateVfModuleVolumeInfraV1",
357 vnfComponentsRecipe.getOrchestrationUri());
361 public void testGetServiceByModelVersionAndModelInvariantUUID() {
363 client.getServiceByModelVersionAndModelInvariantUUID("2.0", "9647dfc4-2083-11e7-93ae-92361f002671");
364 Assert.assertNotNull(service);
365 Assert.assertNotNull(service.getModelVersion());
366 Assert.assertNotNull(service.getModelInvariantUUID());
367 Assert.assertEquals("MSOTADevInfra_vSAMP10a_Service", service.getModelName());
368 Assert.assertEquals("NA", service.getServiceRole());
372 public void testGetServiceByModelVersionAndModelInvariantUUIDNotFound() {
373 Service service = client.getServiceByModelVersionAndModelInvariantUUID("2.0", UUID.randomUUID().toString());
374 Assert.assertNull(service);
378 public void testGetVfModuleByModelInvariantUUIDAndModelVersion() {
380 client.getVfModuleByModelInvariantUUIDAndModelVersion("78ca26d0-246d-11e7-93ae-92361f002671", "2");
381 Assert.assertNotNull(vfModule);
382 Assert.assertNotNull(vfModule.getModelVersion());
383 Assert.assertNotNull(vfModule.getModelInvariantUUID());
384 Assert.assertEquals("vSAMP10aDEV::base::module-0", vfModule.getModelName());
385 Assert.assertEquals("vSAMP10a DEV Base", vfModule.getDescription());
389 public void testGetVfModuleByModelInvariantUUIDAndModelVersionNotFound() {
390 VfModule vfModule = client.getVfModuleByModelInvariantUUIDAndModelVersion(UUID.randomUUID().toString(), "2");
391 Assert.assertNull(vfModule);
395 public void testGetServiceByModelInvariantUUIDOrderByModelVersionDesc() {
396 List<Service> serviceList =
397 client.getServiceByModelInvariantUUIDOrderByModelVersionDesc("9647dfc4-2083-11e7-93ae-92361f002671");
398 Assert.assertFalse(serviceList.isEmpty());
399 Assert.assertEquals(2, serviceList.size());
400 Service service = serviceList.get(0);
401 Assert.assertEquals("2.0", service.getModelVersion());
405 public void testGetServiceByModelInvariantUUIDOrderByModelVersionDescNotFound() {
406 List<Service> serviceList =
407 client.getServiceByModelInvariantUUIDOrderByModelVersionDesc(UUID.randomUUID().toString());
408 Assert.assertTrue(serviceList.isEmpty());
412 public void testGetVfModuleByModelInvariantUUIDOrderByModelVersionDesc() {
413 List<VfModule> moduleList =
414 client.getVfModuleByModelInvariantUUIDOrderByModelVersionDesc("78ca26d0-246d-11e7-93ae-92361f002671");
415 Assert.assertFalse(moduleList.isEmpty());
416 Assert.assertEquals(2, moduleList.size());
417 VfModule module = moduleList.get(0);
418 Assert.assertEquals("vSAMP10a DEV Base", module.getDescription());
422 public void testPostCloudSite() {
423 CatalogDbClientPortChanger localClient = new CatalogDbClientPortChanger(
424 "http://localhost:" + client.wiremockPort, msoAdaptersAuth, client.wiremockPort);
425 CloudSite cloudSite = new CloudSite();
426 cloudSite.setId("MTN6");
427 cloudSite.setClli("TESTCLLI");
428 cloudSite.setRegionId("regionId");
429 cloudSite.setCloudVersion("VERSION");
430 cloudSite.setPlatform("PLATFORM");
432 CloudIdentity cloudIdentity = new CloudIdentity();
433 cloudIdentity.setId("RANDOMID");
434 cloudIdentity.setIdentityUrl("URL");
435 cloudIdentity.setMsoId("MSO_ID");
436 cloudIdentity.setMsoPass("MSO_PASS");
437 cloudIdentity.setAdminTenant("ADMIN_TENANT");
438 cloudIdentity.setMemberRole("ROLE");
439 cloudIdentity.setIdentityServerType(ServerType.KEYSTONE);
440 cloudIdentity.setIdentityAuthenticationType(AuthenticationType.RACKSPACE_APIKEY);
441 cloudSite.setIdentityService(cloudIdentity);
442 localClient.postCloudSite(cloudSite);
443 CloudSite getCloudSite = this.client.getCloudSite("MTN6");
444 Assert.assertNotNull(getCloudSite);
445 Assert.assertNotNull(getCloudSite.getIdentityService());
446 Assert.assertEquals("TESTCLLI", getCloudSite.getClli());
447 Assert.assertEquals("regionId", getCloudSite.getRegionId());
448 Assert.assertEquals("RANDOMID", getCloudSite.getIdentityServiceId());
452 public void testGetHomingInstance() {
453 HomingInstance homingInstance = client.getHomingInstance("5df8b6de-2083-11e7-93ae-92361f232671");
454 Assert.assertNotNull(homingInstance);
455 Assert.assertNotNull(homingInstance.getCloudOwner());
456 Assert.assertNotNull(homingInstance.getCloudRegionId());
457 Assert.assertNotNull(homingInstance.getOofDirectives());
461 public void testPostHomingInstance() {
462 CatalogDbClientPortChanger localClient = new CatalogDbClientPortChanger(
463 "http://localhost:" + client.wiremockPort, msoAdaptersAuth, client.wiremockPort);
464 HomingInstance homingInstance = new HomingInstance();
465 homingInstance.setServiceInstanceId("5df8d6be-2083-11e7-93ae-92361f232671");
466 homingInstance.setCloudOwner("CloudOwner-1");
467 homingInstance.setCloudRegionId("CloudRegionOne");
468 homingInstance.setOofDirectives("{\n" + "\"directives\": [\n" + "{\n" + "\"directives\": [\n" + "{\n"
469 + "\"attributes\": [\n" + "{\n" + "\"attribute_value\": \"onap.hpa.flavor31\",\n"
470 + "\"attribute_name\": \"firewall_flavor_name\"\n" + "}\n" + "],\n"
471 + "\"type\": \"flavor_directives\"\n" + "}\n" + "],\n" + "\"type\": \"vnfc\",\n" + "\"id\": \"vfw\"\n"
472 + "},\n" + "{\n" + "\"directives\": [\n" + "{\n" + "\"attributes\": [\n" + "{\n"
473 + "\"attribute_value\": \"onap.hpa.flavor32\",\n" + "\"attribute_name\": \"packetgen_flavor_name\"\n"
474 + "}\n" + "],\n" + "\"type\": \"flavor_directives\"\n" + "}\n" + "],\n" + "\"type\": \"vnfc\",\n"
475 + "\"id\": \"vgenerator\"\n" + "},\n" + "{\n" + "\"directives\": [\n" + "{\n" + "\"attributes\": [\n"
476 + "{\n" + "\"attribute_value\": \"onap.hpa.flavor31\",\n" + "\"attribute_name\": \"sink_flavor_name\"\n"
477 + "}\n" + "],\n" + "\"type\": \"flavor_directives\"\n" + "}\n" + "],\n" + "\"type\": \"vnfc\",\n"
478 + "\"id\": \"vsink\"\n" + "}\n" + "]\n" + "}");
479 localClient.postHomingInstance(homingInstance);
480 HomingInstance getHomingInstance = this.client.getHomingInstance("5df8d6be-2083-11e7-93ae-92361f232671");
481 Assert.assertNotNull(getHomingInstance);
482 Assert.assertNotNull(getHomingInstance.getCloudRegionId());
483 Assert.assertNotNull(getHomingInstance.getCloudOwner());
484 Assert.assertEquals("CloudOwner-1", getHomingInstance.getCloudOwner());
485 Assert.assertEquals("CloudRegionOne", getHomingInstance.getCloudRegionId());
489 public void testGetServiceByModelName() {
490 Service service = client.getServiceByModelName("MSOTADevInfra_Test_Service");
491 Assert.assertNotNull(service);
492 Assert.assertNotNull(service.getModelVersion());
493 Assert.assertNotNull(service.getModelInvariantUUID());
494 Assert.assertEquals("MSOTADevInfra_Test_Service", service.getModelName());
495 Assert.assertEquals("NA", service.getServiceRole());
499 public void testGetServiceByModelNameNotFound() {
500 Service service = client.getServiceByModelName("Not_Found");
501 Assert.assertNull(service);
505 public void testGetServiceByModelUUID() {
506 Service service = client.getServiceByModelUUID("5df8b6de-2083-11e7-93ae-92361f002679");
507 Assert.assertNotNull(service);
508 Assert.assertNotNull(service.getModelVersion());
509 Assert.assertNotNull(service.getModelInvariantUUID());
510 Assert.assertEquals("5df8b6de-2083-11e7-93ae-92361f002679", service.getModelUUID());
511 Assert.assertEquals("NA", service.getServiceRole());
515 public void testGetServiceByModelUUIDNotFound() {
516 Service service = client.getServiceByModelUUID("Not_Found");
517 Assert.assertNull(service);
521 public void testGetNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner() {
522 NorthBoundRequest northBoundRequest = new NorthBoundRequest();
523 northBoundRequest.setAction("createService");
524 northBoundRequest.setRequestScope("service");
525 northBoundRequest.setIsAlacarte(true);
526 northBoundRequest.setCloudOwner("my-custom-cloud-owner");
527 client.getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner("createService", "service", true,
528 "my-custom-cloud-owner");
529 Assert.assertNotNull(northBoundRequest);
530 Assert.assertEquals("createService", northBoundRequest.getAction());
531 Assert.assertEquals("service", northBoundRequest.getRequestScope());
532 Assert.assertEquals(true, northBoundRequest.getIsAlacarte());
533 Assert.assertEquals("my-custom-cloud-owner", northBoundRequest.getCloudOwner());
537 public void testFindServiceRecipeByActionAndServiceModelUUID() {
538 ServiceRecipe serviceRecipe = client.findServiceRecipeByActionAndServiceModelUUID("createInstance",
539 "4694a55f-58b3-4f17-92a5-796d6f5ffd0d");
540 Assert.assertNotNull(serviceRecipe);
541 Assert.assertNotNull(serviceRecipe.getServiceModelUUID());
542 Assert.assertNotNull(serviceRecipe.getAction());
543 Assert.assertEquals("/mso/async/services/CreateGenericALaCarteServiceInstance",
544 serviceRecipe.getOrchestrationUri());
545 Assert.assertEquals("MSOTADevInfra aLaCarte", serviceRecipe.getDescription());
549 public void testFindServiceRecipeByActionAndServiceModelUUIDNotFound() {
550 ServiceRecipe serviceRecipe =
551 client.findServiceRecipeByActionAndServiceModelUUID("not_found", "5df8b6de-2083-11e7-93ae-test");
552 Assert.assertNull(serviceRecipe);
556 public void testFindExternalToInternalServiceByServiceName() {
557 ExternalServiceToInternalService externalServiceToInternalService =
558 client.findExternalToInternalServiceByServiceName("MySpecialServiceName");
559 Assert.assertNotNull(externalServiceToInternalService);
560 Assert.assertNotNull(externalServiceToInternalService.getServiceName());
561 Assert.assertNotNull(externalServiceToInternalService.getServiceModelUUID());
562 Assert.assertEquals("MySpecialServiceName", externalServiceToInternalService.getServiceName());
566 public void testFindExternalToInternalServiceByServiceNameNotFound() {
567 ExternalServiceToInternalService externalServiceToInternalService =
568 client.findExternalToInternalServiceByServiceName("Not_Found");
569 Assert.assertNull(externalServiceToInternalService);
573 public void getPnfResourceByModelUUID_validUuid_expectedOutput() {
574 PnfResource pnfResource = client.getPnfResourceByModelUUID("ff2ae348-214a-11e7-93ae-92361f002680");
575 Assert.assertNotNull(pnfResource);
576 assertEquals("PNFResource modelUUID", "ff2ae348-214a-11e7-93ae-92361f002680", pnfResource.getModelUUID());
577 assertEquals("PNFResource modelInvariantUUID", "2fff5b20-214b-11e7-93ae-92361f002680",
578 pnfResource.getModelInvariantUUID());
579 assertEquals("PNFResource modelVersion", "1.0", pnfResource.getModelVersion());
580 assertEquals("PNFResource orchestration mode", "", pnfResource.getOrchestrationMode());
584 public void getPnfResourceByModelUUID_invalidUuid_NullOutput() {
585 PnfResource pnfResource = client.getPnfResourceByModelUUID(UUID.randomUUID().toString());
586 Assert.assertNull(pnfResource);
590 public void getPnfResourceCustomizationByModelCustomizationUUID_validUuid_expectedOutput() {
591 PnfResourceCustomization pnfResourceCustomization =
592 client.getPnfResourceCustomizationByModelCustomizationUUID("68dc9a92-214c-11e7-93ae-92361f002680");
593 assertEquals("modelInstanceName", "PNF routing", pnfResourceCustomization.getModelInstanceName());
594 assertEquals("blueprintName", "test_configuration_restconf", pnfResourceCustomization.getBlueprintName());
595 assertEquals("blueprintVersion", "1.0.0", pnfResourceCustomization.getBlueprintVersion());
596 assertTrue("skip post instantiation configuration", pnfResourceCustomization.isSkipPostInstConf());
597 PnfResource pnfResource = pnfResourceCustomization.getPnfResources();
598 assertNotNull(pnfResource);
599 assertEquals("PNFResource modelUUID", "ff2ae348-214a-11e7-93ae-92361f002680", pnfResource.getModelUUID());
600 assertEquals("PNFResource modelInvariantUUID", "2fff5b20-214b-11e7-93ae-92361f002680",
601 pnfResource.getModelInvariantUUID());
602 assertEquals("PNFResource modelVersion", "1.0", pnfResource.getModelVersion());
603 assertEquals("PNFResource orchestration mode", "", pnfResource.getOrchestrationMode());
607 public void getPnfResourceCustomizationByModelCustomizationUUID_invalidUuid_nullOutput() {
608 PnfResourceCustomization pnfResourceCustomization =
609 client.getPnfResourceCustomizationByModelCustomizationUUID(UUID.randomUUID().toString());
610 Assert.assertNull(pnfResourceCustomization);
614 public void getPnfResourceCustomizationFromJoinTable_validServiceUuid_expectedOutput() {
615 List<PnfResourceCustomization> pnfResourceCustomizationList =
616 client.getPnfResourceCustomizationByModelUuid("5df8b6de-2083-11e7-93ae-92361f002676");
617 assertEquals(1, pnfResourceCustomizationList.size());
619 PnfResourceCustomization pnfResourceCustomization = pnfResourceCustomizationList.get(0);
620 assertEquals("modelInstanceName", "PNF routing", pnfResourceCustomization.getModelInstanceName());
621 assertEquals("blueprintName", "test_configuration_restconf", pnfResourceCustomization.getBlueprintName());
622 assertEquals("blueprintVersion", "1.0.0", pnfResourceCustomization.getBlueprintVersion());
623 PnfResource pnfResource = pnfResourceCustomization.getPnfResources();
624 assertNotNull(pnfResource);
626 assertEquals("PNFResource modelUUID", "ff2ae348-214a-11e7-93ae-92361f002680", pnfResource.getModelUUID());
627 assertEquals("PNFResource modelInvariantUUID", "2fff5b20-214b-11e7-93ae-92361f002680",
628 pnfResource.getModelInvariantUUID());
629 assertEquals("PNFResource modelVersion", "1.0", pnfResource.getModelVersion());
630 assertEquals("PNFResource orchestration mode", "", pnfResource.getOrchestrationMode());
634 public void getPnfResourceCustomizationFromJoinTable_invalidServiceUuid_nullOutput() {
635 List<PnfResourceCustomization> pnfResourceCustomizationList =
636 client.getPnfResourceCustomizationByModelUuid(UUID.randomUUID().toString());
637 assertEquals(0, pnfResourceCustomizationList.size());
641 public void getWorkflowByArtifactUUID_validUuid_expectedOutput() {
642 Workflow workflow = client.findWorkflowByArtifactUUID("5b0c4322-643d-4c9f-b184-4516049e99b1");
643 assertEquals("artifactName", "testingWorkflow", workflow.getArtifactName());
647 public void getWorkflowByArtifactUUID_invalidUuid_nullOutput() {
648 Workflow workflow = client.findWorkflowByArtifactUUID(UUID.randomUUID().toString());
649 Assert.assertNull(workflow);
653 public void getWorkflowByModelUUID_validUuid_expectedOutput() {
654 List<Workflow> workflows = client.findWorkflowByModelUUID("ff2ae348-214a-11e7-93ae-92361f002671");
655 assertTrue(workflows != null);
656 assertTrue(workflows.size() != 0);
658 assertEquals("testingWorkflow", workflows.get(0).getArtifactName());
662 public void getWorkflowByModelUUID_invalidUuid_nullOutput() {
663 Workflow workflow = client.findWorkflowByArtifactUUID(UUID.randomUUID().toString());
664 Assert.assertNull(workflow);