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.assertNotEquals;
26 import static org.junit.Assert.assertFalse;
27 import static org.junit.Assert.assertNotNull;
28 import static org.junit.Assert.assertNull;
29 import static org.junit.Assert.assertTrue;
30 import java.util.List;
31 import java.util.UUID;
32 import org.junit.Before;
33 import org.junit.Test;
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.web.server.LocalServerPort;
61 public class CatalogDbClientTest extends CatalogDbAdapterBaseTest {
63 public static final String MTN13 = "mtn13";
68 @Value("${mso.db.auth}")
69 private String msoAdaptersAuth;
72 CatalogDbClientPortChanger client;
77 public void initialize() {
78 client.wiremockPort = String.valueOf(port);
79 client.setEndpoint(getEndpoint(port));
82 protected String getEndpoint(int port) {
83 return "http://localhost:" + port;
87 public void testGetRainyDayHandler_Regex() {
88 RainyDayHandlerStatus rainyDayHandlerStatus = client.getRainyDayHandlerStatus("AssignServiceInstanceBB", "*",
89 "*", "*", "*", "The Flavor ID (nd.c6r16d20) could not be found.", "*");
90 assertEquals("Rollback", rainyDayHandlerStatus.getPolicy());
94 public void testGetRainyDayHandler__Encoding_Regex() {
95 RainyDayHandlerStatus rainyDayHandlerStatus = client.getRainyDayHandlerStatus("AssignServiceInstanceBB", "*",
97 "resources.lba_0_dmz_vmi_0: Unknown id: Error: oper 1 url /fqname-to-id body {\"fq_name\": [\"zrdm6bvota05-dmz_sec_group\"], \"type\": \"security-group\"} response Name ['zrdm6bvota05-dmz_sec_group'] not found",
99 assertEquals("Rollback", rainyDayHandlerStatus.getPolicy());
103 public void testGetCloudSiteHappyPath() throws Exception {
104 CloudSite cloudSite = client.getCloudSite(MTN13);
105 assertNotNull(cloudSite);
106 assertNotNull(cloudSite.getIdentityService());
107 assertEquals("MDT13", cloudSite.getClli());
108 assertEquals("mtn13", cloudSite.getRegionId());
109 assertEquals("MTN13", cloudSite.getIdentityServiceId());
113 public void testGetCloudSiteNotFound() throws Exception {
114 CloudSite cloudSite = client.getCloudSite(UUID.randomUUID().toString());
115 assertNull(cloudSite);
119 public void testGetCloudifyManagerHappyPath() throws Exception {
120 CloudifyManager cloudifyManager = client.getCloudifyManager("mtn13");
121 assertNotNull(cloudifyManager);
122 assertEquals("http://localhost:28090/v2.0", cloudifyManager.getCloudifyUrl());
127 public void testGetCloudifyManagerNotFound() throws Exception {
128 CloudifyManager cloudifyManager = client.getCloudifyManager(UUID.randomUUID().toString());
129 assertNull(cloudifyManager);
134 public void testGetCloudSiteByClliAndAicVersionHappyPath() throws Exception {
135 CloudSite cloudSite = client.getCloudSiteByClliAndAicVersion("MDT13", "2.5");
136 assertNotNull(cloudSite);
140 public void testGetCloudSiteByClliAndAicVersionNotFound() throws Exception {
141 CloudSite cloudSite = client.getCloudSiteByClliAndAicVersion("MDT13", "232496239746328");
142 assertNull(cloudSite);
146 public void testGetServiceByID() throws Exception {
147 Service serviceByID = client.getServiceByID("5df8b6de-2083-11e7-93ae-92361f002671");
148 assertNotNull(serviceByID);
149 assertEquals("MSOTADevInfra_vSAMP10a_Service", serviceByID.getModelName());
150 assertEquals("NA", serviceByID.getServiceType());
151 assertEquals("NA", serviceByID.getServiceRole());
155 public void testGetServiceByIDNotFound() throws Exception {
156 Service serviceByID = client.getServiceByID(UUID.randomUUID().toString());
157 assertNull(serviceByID);
161 public void testGetVfModuleByModelUUID() throws Exception {
162 VfModule vfModule = client.getVfModuleByModelUUID("20c4431c-246d-11e7-93ae-92361f002671");
163 assertNotNull(vfModule);
164 assertNotNull(vfModule.getVfModuleCustomization());
165 assertEquals("78ca26d0-246d-11e7-93ae-92361f002671", vfModule.getModelInvariantUUID());
166 assertEquals("vSAMP10aDEV::base::module-0", vfModule.getModelName());
170 public void testGetVfModuleByModelUUIDNotFound() throws Exception {
171 VfModule vfModule = client.getVfModuleByModelUUID(UUID.randomUUID().toString());
172 assertNull(vfModule);
176 public void testGetVnfResourceByModelUUID() throws Exception {
177 VnfResource vnfResource = client.getVnfResourceByModelUUID("ff2ae348-214a-11e7-93ae-92361f002671");
178 assertNotNull(vnfResource);
179 assertEquals("vSAMP10a", vnfResource.getModelName());
183 public void testGetVnfResourceByModelUUIDNotFound() throws Exception {
184 VnfResource vnfResource = client.getVnfResourceByModelUUID(UUID.randomUUID().toString());
185 assertNull(vnfResource);
189 public void testGetVnfResourceCustomizationByModelCustomizationUUID() {
190 VnfResourceCustomization vnfResourceCustomization =
191 client.getVnfResourceCustomizationByModelCustomizationUUID("68dc9a92-214c-11e7-93ae-92361f002671");
192 assertNotNull(vnfResourceCustomization);
193 assertEquals("vSAMP", vnfResourceCustomization.getNfRole());
194 assertNotNull(vnfResourceCustomization.getModelCustomizationUUID());
195 assertNotNull(vnfResourceCustomization.getVnfResources());
196 assertNotNull(vnfResourceCustomization.getVfModuleCustomizations());
197 assertEquals("vSAMP10a", vnfResourceCustomization.getVnfResources().getModelName());
198 assertTrue("skip post instantiation configuration", vnfResourceCustomization.isSkipPostInstConf());
202 public void testGetVnfResourceCustomizationByModelCustomizationUUINotFound() {
203 VnfResourceCustomization vnfResourceCustomization =
204 client.getVnfResourceCustomizationByModelCustomizationUUID(UUID.randomUUID().toString());
205 assertNull(vnfResourceCustomization);
209 public void testGetInstanceGroupByModelUUID() {
210 InstanceGroup instanceGroup = client.getInstanceGroupByModelUUID("0c8692ef-b9c0-435d-a738-edf31e71f38b");
211 assertNotNull(instanceGroup);
212 assertEquals("network_collection_resource_1806..NetworkCollection..0", instanceGroup.getModelName());
213 assertEquals("org.openecomp.resource.cr.NetworkCollectionResource1806",
214 instanceGroup.getToscaNodeType().toString());
218 public void testGetVfModuleCustomizationByModelCuztomizationUUID() {
219 VfModuleCustomization vfModuleCustomization =
220 client.getVfModuleCustomizationByModelCuztomizationUUID("cb82ffd8-252a-11e7-93ae-92361f002671");
221 assertNotNull(vfModuleCustomization);
222 assertNotNull(vfModuleCustomization.getModelCustomizationUUID());
223 assertEquals("base", vfModuleCustomization.getLabel());
227 public void testGetVfModuleCustomizationByModelCuztomizationUUIDNotFound() {
228 VfModuleCustomization vfModuleCustomization =
229 client.getVfModuleCustomizationByModelCuztomizationUUID(UUID.randomUUID().toString());
230 assertNull(vfModuleCustomization);
234 public void testGetNetworkResourceCustomizationByModelCustomizationUUID() {
235 NetworkResourceCustomization networkResourceCustomization =
236 client.getNetworkResourceCustomizationByModelCustomizationUUID("3bdbb104-476c-483e-9f8b-c095b3d308ac");
237 assertNotNull(networkResourceCustomization);
238 assertNotNull(networkResourceCustomization.getModelCustomizationUUID());
239 assertEquals("CONTRAIL30_GNDIRECT 9", networkResourceCustomization.getModelInstanceName());
240 assertNotNull(networkResourceCustomization.getNetworkResource());
244 public void testGetNetworkResourceCustomizationByModelCustomizationUUIDNotFound() {
245 NetworkResourceCustomization networkResourceCustomization =
246 client.getNetworkResourceCustomizationByModelCustomizationUUID(UUID.randomUUID().toString());
247 assertNull(networkResourceCustomization);
251 public void testGgetVfModuleCustomizationByModelCustomizationUUIDAndVfModuleModelUUID() {
252 VfModuleCustomization vfModuleCustomization =
253 client.getVfModuleCustomizationByModelCustomizationUUIDAndVfModuleModelUUID(
254 "cb82ffd8-252a-11e7-93ae-92361f002672", "20c4431c-246d-11e7-93ae-92361f002672");
255 assertNotNull(vfModuleCustomization);
256 assertNotNull(vfModuleCustomization.getModelCustomizationUUID());
257 assertNotNull(vfModuleCustomization.getVfModule());
258 assertEquals("base", vfModuleCustomization.getLabel());
262 public void testGgetVfModuleCustomizationByModelCustomizationUUIDAndVfModuleModelUUIDNotFound() {
263 VfModuleCustomization vfModuleCustomization =
264 client.getVfModuleCustomizationByModelCustomizationUUIDAndVfModuleModelUUID(
265 "cb82ffd8-252a-11e7-93ae-92361f002672", UUID.randomUUID().toString());
266 assertNull(vfModuleCustomization);
270 public void testGetFirstByServiceModelUUIDAndAction() {
271 ServiceRecipe serviceRecipe =
272 client.getFirstByServiceModelUUIDAndAction("4694a55f-58b3-4f17-92a5-796d6f5ffd0d", "createInstance");
273 assertNotNull(serviceRecipe);
274 assertNotNull(serviceRecipe.getServiceModelUUID());
275 assertNotNull(serviceRecipe.getAction());
276 assertEquals("/mso/async/services/CreateGenericALaCarteServiceInstance", serviceRecipe.getOrchestrationUri());
277 assertEquals("MSOTADevInfra aLaCarte", serviceRecipe.getDescription());
281 public void testGetFirstByServiceModelUUIDAndActionNotFound() {
282 ServiceRecipe serviceRecipe = client.getFirstByServiceModelUUIDAndAction("5df8b6de-2083-11e7-93ae-92361f002671",
283 UUID.randomUUID().toString());
284 assertNull(serviceRecipe);
288 public void testGetFirstVnfResourceByModelInvariantUUIDAndModelVersion() {
289 VnfResource vnfResource = client
290 .getFirstVnfResourceByModelInvariantUUIDAndModelVersion("2fff5b20-214b-11e7-93ae-92361f002671", "2.0");
291 assertNotNull(vnfResource);
292 assertNotNull(vnfResource.getModelInvariantId());
293 assertNotNull(vnfResource.getModelVersion());
294 assertNotNull(vnfResource.getHeatTemplates());
295 assertEquals("vSAMP10a", vnfResource.getModelName());
299 public void testGetFirstVnfResourceByModelInvariantUUIDAndModelVersionNotFound() {
300 VnfResource vnfResource = client.getFirstVnfResourceByModelInvariantUUIDAndModelVersion(
301 "2fff5b20-214b-11e7-93ae-92361f002671", UUID.randomUUID().toString());
302 assertNull(vnfResource);
306 public void testGetFirstVnfResourceCustomizationByModelInstanceNameAndVnfResources() {
307 VnfResource vnfr = new VnfResource();
308 vnfr.setModelUUID("ff2ae348-214a-11e7-93ae-92361f002671");
309 VnfResourceCustomization firstVnfResourceCustomizationByModelInstanceNameAndVnfResources =
310 client.getFirstVnfResourceCustomizationByModelInstanceNameAndVnfResources("vSAMP10a 1", vnfr);
311 assertNotNull(firstVnfResourceCustomizationByModelInstanceNameAndVnfResources);
312 assertEquals("vSAMP", firstVnfResourceCustomizationByModelInstanceNameAndVnfResources.getNfRole());
313 assertEquals("vSAMP10a 1",
314 firstVnfResourceCustomizationByModelInstanceNameAndVnfResources.getModelInstanceName());
315 assertNotNull(firstVnfResourceCustomizationByModelInstanceNameAndVnfResources.getVnfResources());
316 assertNotNull(firstVnfResourceCustomizationByModelInstanceNameAndVnfResources.getVfModuleCustomizations());
320 public void testGetFirstVnfRecipeByNfRoleAndAction() {
321 VnfRecipe vnfRecipe = client.getFirstVnfRecipeByNfRoleAndAction("GR-API-DEFAULT", "createInstance");
322 assertNotNull(vnfRecipe);
323 assertNotNull(vnfRecipe.getNfRole());
324 assertNotNull(vnfRecipe.getAction());
325 assertEquals("Gr api recipe to create vnf", vnfRecipe.getDescription());
326 assertEquals("/mso/async/services/WorkflowActionBB", vnfRecipe.getOrchestrationUri());
330 public void testGetFirstVnfRecipeByNfRoleAndActionNotFound() {
331 VnfRecipe vnfRecipe = client.getFirstVnfRecipeByNfRoleAndAction(UUID.randomUUID().toString(), "createInstance");
332 assertNull(vnfRecipe);
336 public void testGetFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction() {
337 VnfComponentsRecipe vnfComponentsRecipe =
338 client.getFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction(
339 "20c4431c-246d-11e7-93ae-92361f002671", "volumeGroup", "createInstance");
340 assertNotNull(vnfComponentsRecipe);
341 assertNotNull(vnfComponentsRecipe.getAction());
342 assertNotNull(vnfComponentsRecipe.getVfModuleModelUUID());
343 assertNotNull(vnfComponentsRecipe.getVnfComponentType());
344 assertEquals("Gr api recipe to create volume-group", vnfComponentsRecipe.getDescription());
345 assertEquals("/mso/async/services/WorkflowActionBB", vnfComponentsRecipe.getOrchestrationUri());
351 public void testGetFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndActionNotFound() {
352 VnfComponentsRecipe vnfComponentsRecipe =
353 client.getFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction(
354 UUID.randomUUID().toString(), "volumeGroup", "createInstance");
355 assertNull(vnfComponentsRecipe);
359 public void testGetFirstVnfComponentsRecipeByVnfComponentTypeAndAction() {
360 VnfComponentsRecipe vnfComponentsRecipe =
361 client.getFirstVnfComponentsRecipeByVnfComponentTypeAndAction("volumeGroup", "createInstance");
362 assertNotNull(vnfComponentsRecipe);
363 assertNotNull(vnfComponentsRecipe.getAction());
364 assertNotNull(vnfComponentsRecipe.getVnfComponentType());
365 assertEquals("VID_DEFAULT recipe t", vnfComponentsRecipe.getDescription());
366 assertEquals("/mso/async/services/CreateVfModuleVolumeInfraV1", vnfComponentsRecipe.getOrchestrationUri());
370 public void testGetServiceByModelVersionAndModelInvariantUUID() {
372 client.getServiceByModelVersionAndModelInvariantUUID("2.0", "9647dfc4-2083-11e7-93ae-92361f002671");
373 assertNotNull(service);
374 assertNotNull(service.getModelVersion());
375 assertNotNull(service.getModelInvariantUUID());
376 assertEquals("MSOTADevInfra_vSAMP10a_Service", service.getModelName());
377 assertEquals("NA", service.getServiceRole());
381 public void testGetServiceByModelVersionAndModelInvariantUUIDNotFound() {
382 Service service = client.getServiceByModelVersionAndModelInvariantUUID("2.0", UUID.randomUUID().toString());
387 public void testGetVfModuleByModelInvariantUUIDAndModelVersion() {
389 client.getVfModuleByModelInvariantUUIDAndModelVersion("78ca26d0-246d-11e7-93ae-92361f002671", "2");
390 assertNotNull(vfModule);
391 assertNotNull(vfModule.getModelVersion());
392 assertNotNull(vfModule.getModelInvariantUUID());
393 assertEquals("vSAMP10aDEV::base::module-0", vfModule.getModelName());
394 assertEquals("vSAMP10a DEV Base", vfModule.getDescription());
398 public void testGetVfModuleByModelInvariantUUIDAndModelVersionNotFound() {
399 VfModule vfModule = client.getVfModuleByModelInvariantUUIDAndModelVersion(UUID.randomUUID().toString(), "2");
400 assertNull(vfModule);
404 public void testGetServiceByModelInvariantUUIDOrderByModelVersionDesc() {
405 List<Service> serviceList =
406 client.getServiceByModelInvariantUUIDOrderByModelVersionDesc("9647dfc4-2083-11e7-93ae-92361f002671");
407 assertFalse(serviceList.isEmpty());
408 assertEquals(2, serviceList.size());
409 Service service = serviceList.get(0);
410 assertEquals("2.0", service.getModelVersion());
414 public void testGetServiceByModelInvariantUUIDOrderByModelVersionDescNotFound() {
415 List<Service> serviceList =
416 client.getServiceByModelInvariantUUIDOrderByModelVersionDesc(UUID.randomUUID().toString());
417 assertTrue(serviceList.isEmpty());
421 public void testGetVfModuleByModelInvariantUUIDOrderByModelVersionDesc() {
422 List<VfModule> moduleList =
423 client.getVfModuleByModelInvariantUUIDOrderByModelVersionDesc("78ca26d0-246d-11e7-93ae-92361f002671");
424 assertFalse(moduleList.isEmpty());
425 assertEquals(2, moduleList.size());
426 VfModule module = moduleList.get(0);
427 assertEquals("vSAMP10a DEV Base", module.getDescription());
431 public void testPostCloudSite() {
432 CatalogDbClientPortChanger localClient = new CatalogDbClientPortChanger(
433 "http://localhost:" + client.wiremockPort, msoAdaptersAuth, client.wiremockPort);
434 CloudSite cloudSite = new CloudSite();
435 cloudSite.setId("MTN6");
436 cloudSite.setClli("TESTCLLI");
437 cloudSite.setRegionId("regionId");
438 cloudSite.setCloudVersion("VERSION");
439 cloudSite.setPlatform("PLATFORM");
441 CloudIdentity cloudIdentity = new CloudIdentity();
442 cloudIdentity.setId("RANDOMID");
443 cloudIdentity.setIdentityUrl("URL");
444 cloudIdentity.setMsoId("MSO_ID");
445 cloudIdentity.setMsoPass("MSO_PASS");
446 cloudIdentity.setAdminTenant("ADMIN_TENANT");
447 cloudIdentity.setMemberRole("ROLE");
448 cloudIdentity.setIdentityServerType(ServerType.KEYSTONE);
449 cloudIdentity.setIdentityAuthenticationType(AuthenticationType.RACKSPACE_APIKEY);
450 cloudSite.setIdentityService(cloudIdentity);
451 localClient.postCloudSite(cloudSite);
452 CloudSite getCloudSite = this.client.getCloudSite("MTN6");
453 assertNotNull(getCloudSite);
454 assertNotNull(getCloudSite.getIdentityService());
455 assertEquals("TESTCLLI", getCloudSite.getClli());
456 assertEquals("regionId", getCloudSite.getRegionId());
457 assertEquals("RANDOMID", getCloudSite.getIdentityServiceId());
461 public void testGetHomingInstance() {
462 HomingInstance homingInstance = client.getHomingInstance("5df8b6de-2083-11e7-93ae-92361f232671");
463 assertNotNull(homingInstance);
464 assertNotNull(homingInstance.getCloudOwner());
465 assertNotNull(homingInstance.getCloudRegionId());
466 assertNotNull(homingInstance.getOofDirectives());
470 public void testPostHomingInstance() {
471 CatalogDbClientPortChanger localClient = new CatalogDbClientPortChanger(
472 "http://localhost:" + client.wiremockPort, msoAdaptersAuth, client.wiremockPort);
473 HomingInstance homingInstance = new HomingInstance();
474 homingInstance.setServiceInstanceId("5df8d6be-2083-11e7-93ae-92361f232671");
475 homingInstance.setCloudOwner("CloudOwner-1");
476 homingInstance.setCloudRegionId("CloudRegionOne");
477 homingInstance.setOofDirectives("{\n" + "\"directives\": [\n" + "{\n" + "\"directives\": [\n" + "{\n"
478 + "\"attributes\": [\n" + "{\n" + "\"attribute_value\": \"onap.hpa.flavor31\",\n"
479 + "\"attribute_name\": \"firewall_flavor_name\"\n" + "}\n" + "],\n"
480 + "\"type\": \"flavor_directives\"\n" + "}\n" + "],\n" + "\"type\": \"vnfc\",\n" + "\"id\": \"vfw\"\n"
481 + "},\n" + "{\n" + "\"directives\": [\n" + "{\n" + "\"attributes\": [\n" + "{\n"
482 + "\"attribute_value\": \"onap.hpa.flavor32\",\n" + "\"attribute_name\": \"packetgen_flavor_name\"\n"
483 + "}\n" + "],\n" + "\"type\": \"flavor_directives\"\n" + "}\n" + "],\n" + "\"type\": \"vnfc\",\n"
484 + "\"id\": \"vgenerator\"\n" + "},\n" + "{\n" + "\"directives\": [\n" + "{\n" + "\"attributes\": [\n"
485 + "{\n" + "\"attribute_value\": \"onap.hpa.flavor31\",\n" + "\"attribute_name\": \"sink_flavor_name\"\n"
486 + "}\n" + "],\n" + "\"type\": \"flavor_directives\"\n" + "}\n" + "],\n" + "\"type\": \"vnfc\",\n"
487 + "\"id\": \"vsink\"\n" + "}\n" + "]\n" + "}");
488 localClient.postHomingInstance(homingInstance);
489 HomingInstance getHomingInstance = this.client.getHomingInstance("5df8d6be-2083-11e7-93ae-92361f232671");
490 assertNotNull(getHomingInstance);
491 assertNotNull(getHomingInstance.getCloudRegionId());
492 assertNotNull(getHomingInstance.getCloudOwner());
493 assertEquals("CloudOwner-1", getHomingInstance.getCloudOwner());
494 assertEquals("CloudRegionOne", getHomingInstance.getCloudRegionId());
498 public void testGetServiceByModelName() {
499 Service service = client.getServiceByModelName("MSOTADevInfra_Test_Service");
500 assertNotNull(service);
501 assertNotNull(service.getModelVersion());
502 assertNotNull(service.getModelInvariantUUID());
503 assertEquals("MSOTADevInfra_Test_Service", service.getModelName());
504 assertEquals("NA", service.getServiceRole());
508 public void testGetServiceByModelNameNotFound() {
509 Service service = client.getServiceByModelName("Not_Found");
514 public void testGetServiceByModelUUID() {
515 Service service = client.getServiceByModelUUID("5df8b6de-2083-11e7-93ae-92361f002679");
516 assertNotNull(service);
517 assertNotNull(service.getModelVersion());
518 assertNotNull(service.getModelInvariantUUID());
519 assertEquals("5df8b6de-2083-11e7-93ae-92361f002679", service.getModelUUID());
520 assertEquals("NA", service.getServiceRole());
524 public void testGetServiceByModelUUIDNotFound() {
525 Service service = client.getServiceByModelUUID("Not_Found");
530 public void testGetNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner() {
531 NorthBoundRequest northBoundRequest = new NorthBoundRequest();
532 northBoundRequest.setAction("createService");
533 northBoundRequest.setRequestScope("service");
534 northBoundRequest.setIsAlacarte(true);
535 northBoundRequest.setCloudOwner("my-custom-cloud-owner");
536 client.getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner("createService", "service", true,
537 "my-custom-cloud-owner");
538 assertNotNull(northBoundRequest);
539 assertEquals("createService", northBoundRequest.getAction());
540 assertEquals("service", northBoundRequest.getRequestScope());
541 assertEquals(true, northBoundRequest.getIsAlacarte());
542 assertEquals("my-custom-cloud-owner", northBoundRequest.getCloudOwner());
546 public void testFindServiceRecipeByActionAndServiceModelUUID() {
547 ServiceRecipe serviceRecipe = client.findServiceRecipeByActionAndServiceModelUUID("createInstance",
548 "4694a55f-58b3-4f17-92a5-796d6f5ffd0d");
549 assertNotNull(serviceRecipe);
550 assertNotNull(serviceRecipe.getServiceModelUUID());
551 assertNotNull(serviceRecipe.getAction());
552 assertEquals("/mso/async/services/CreateGenericALaCarteServiceInstance", serviceRecipe.getOrchestrationUri());
553 assertEquals("MSOTADevInfra aLaCarte", serviceRecipe.getDescription());
557 public void testFindServiceRecipeByActionAndServiceModelUUIDNotFound() {
558 ServiceRecipe serviceRecipe =
559 client.findServiceRecipeByActionAndServiceModelUUID("not_found", "5df8b6de-2083-11e7-93ae-test");
560 assertNull(serviceRecipe);
564 public void testFindExternalToInternalServiceByServiceName() {
565 ExternalServiceToInternalService externalServiceToInternalService =
566 client.findExternalToInternalServiceByServiceName("MySpecialServiceName");
567 assertNotNull(externalServiceToInternalService);
568 assertNotNull(externalServiceToInternalService.getServiceName());
569 assertNotNull(externalServiceToInternalService.getServiceModelUUID());
570 assertEquals("MySpecialServiceName", externalServiceToInternalService.getServiceName());
574 public void testFindExternalToInternalServiceByServiceNameNotFound() {
575 ExternalServiceToInternalService externalServiceToInternalService =
576 client.findExternalToInternalServiceByServiceName("Not_Found");
577 assertNull(externalServiceToInternalService);
581 public void getPnfResourceByModelUUID_validUuid_expectedOutput() {
582 PnfResource pnfResource = client.getPnfResourceByModelUUID("ff2ae348-214a-11e7-93ae-92361f002680");
583 assertNotNull(pnfResource);
584 assertEquals("PNFResource modelUUID", "ff2ae348-214a-11e7-93ae-92361f002680", pnfResource.getModelUUID());
585 assertEquals("PNFResource modelInvariantUUID", "2fff5b20-214b-11e7-93ae-92361f002680",
586 pnfResource.getModelInvariantUUID());
587 assertEquals("PNFResource modelVersion", "1.0", pnfResource.getModelVersion());
588 assertEquals("PNFResource orchestration mode", "", pnfResource.getOrchestrationMode());
592 public void getPnfResourceByModelUUID_invalidUuid_NullOutput() {
593 PnfResource pnfResource = client.getPnfResourceByModelUUID(UUID.randomUUID().toString());
594 assertNull(pnfResource);
598 public void getPnfResourceCustomizationByModelCustomizationUUID_validUuid_expectedOutput() {
599 PnfResourceCustomization pnfResourceCustomization =
600 client.getPnfResourceCustomizationByModelCustomizationUUID("68dc9a92-214c-11e7-93ae-92361f002680");
601 assertEquals("modelInstanceName", "PNF routing", pnfResourceCustomization.getModelInstanceName());
602 assertEquals("blueprintName", "test_configuration_restconf", pnfResourceCustomization.getBlueprintName());
603 assertEquals("blueprintVersion", "1.0.0", pnfResourceCustomization.getBlueprintVersion());
604 assertTrue("skip post instantiation configuration", pnfResourceCustomization.isSkipPostInstConf());
605 PnfResource pnfResource = pnfResourceCustomization.getPnfResources();
606 assertNotNull(pnfResource);
607 assertEquals("PNFResource modelUUID", "ff2ae348-214a-11e7-93ae-92361f002680", pnfResource.getModelUUID());
608 assertEquals("PNFResource modelInvariantUUID", "2fff5b20-214b-11e7-93ae-92361f002680",
609 pnfResource.getModelInvariantUUID());
610 assertEquals("PNFResource modelVersion", "1.0", pnfResource.getModelVersion());
611 assertEquals("PNFResource orchestration mode", "", pnfResource.getOrchestrationMode());
615 public void getPnfResourceCustomizationByModelCustomizationUUID_invalidUuid_nullOutput() {
616 PnfResourceCustomization pnfResourceCustomization =
617 client.getPnfResourceCustomizationByModelCustomizationUUID(UUID.randomUUID().toString());
618 assertNull(pnfResourceCustomization);
622 public void getPnfResourceCustomizationFromJoinTable_validServiceUuid_expectedOutput() {
623 List<PnfResourceCustomization> pnfResourceCustomizationList =
624 client.getPnfResourceCustomizationByModelUuid("5df8b6de-2083-11e7-93ae-92361f002676");
625 assertEquals(1, pnfResourceCustomizationList.size());
627 PnfResourceCustomization pnfResourceCustomization = pnfResourceCustomizationList.get(0);
628 assertEquals("modelInstanceName", "PNF routing", pnfResourceCustomization.getModelInstanceName());
629 assertEquals("blueprintName", "test_configuration_restconf", pnfResourceCustomization.getBlueprintName());
630 assertEquals("blueprintVersion", "1.0.0", pnfResourceCustomization.getBlueprintVersion());
631 PnfResource pnfResource = pnfResourceCustomization.getPnfResources();
632 assertNotNull(pnfResource);
634 assertEquals("PNFResource modelUUID", "ff2ae348-214a-11e7-93ae-92361f002680", pnfResource.getModelUUID());
635 assertEquals("PNFResource modelInvariantUUID", "2fff5b20-214b-11e7-93ae-92361f002680",
636 pnfResource.getModelInvariantUUID());
637 assertEquals("PNFResource modelVersion", "1.0", pnfResource.getModelVersion());
638 assertEquals("PNFResource orchestration mode", "", pnfResource.getOrchestrationMode());
642 public void getPnfResourceCustomizationFromJoinTable_invalidServiceUuid_nullOutput() {
643 List<PnfResourceCustomization> pnfResourceCustomizationList =
644 client.getPnfResourceCustomizationByModelUuid(UUID.randomUUID().toString());
645 assertEquals(0, pnfResourceCustomizationList.size());
649 public void testGetServiceTopologyById() throws Exception {
650 org.onap.so.rest.catalog.beans.Service serviceByID =
651 client.getServiceModelInformation("5df8b6de-2083-11e7-93ae-92361f002671", "2");
652 assertNotNull(serviceByID);
653 assertEquals("MSOTADevInfra_vSAMP10a_Service", serviceByID.getModelName());
654 assertEquals("NA", serviceByID.getServiceType());
655 assertEquals("NA", serviceByID.getServiceRole());
659 public void testGetServices() throws Exception {
660 List<org.onap.so.rest.catalog.beans.Service> services = client.getServices();
661 assertEquals(false, services.isEmpty());
665 public void testVnf() throws Exception {
666 org.onap.so.rest.catalog.beans.Vnf vnf = client.getVnfModelInformation("5df8b6de-2083-11e7-93ae-92361f002671",
667 "68dc9a92-214c-11e7-93ae-92361f002671", "0");
669 assertEquals("vSAMP10a", vnf.getModelName());
670 assertEquals(false, vnf.getNfDataValid());
671 assertEquals("vSAMP", vnf.getNfFunction());
672 assertEquals("vSAMP", vnf.getNfNamingCode());
673 assertEquals("vSAMP", vnf.getNfRole());
674 assertEquals("vSAMP", vnf.getNfType());
676 vnf.setNfDataValid(true);
677 vnf.setNfFunction("nfFunction");
678 vnf.setNfRole("nfRole");
679 vnf.setNfType("nfType");
680 vnf.setNfNamingCode("nfNamingCode");
682 client.updateVnf("5df8b6de-2083-11e7-93ae-92361f002671", vnf);
683 vnf = client.getVnfModelInformation("5df8b6de-2083-11e7-93ae-92361f002671",
684 "68dc9a92-214c-11e7-93ae-92361f002671", "0");
685 assertEquals("vSAMP10a", vnf.getModelName());
686 assertEquals(true, vnf.getNfDataValid());
687 assertEquals("nfFunction", vnf.getNfFunction());
688 assertEquals("nfNamingCode", vnf.getNfNamingCode());
689 assertEquals("nfRole", vnf.getNfRole());
690 assertEquals("nfType", vnf.getNfType());
696 public void getWorkflowByArtifactUUID_validUuid_expectedOutput() {
697 Workflow workflow = client.findWorkflowByArtifactUUID("5b0c4322-643d-4c9f-b184-4516049e99b1");
698 assertEquals("artifactName", "testingWorkflow.bpmn", workflow.getArtifactName());
702 public void getWorkflowByArtifactUUID_invalidUuid_nullOutput() {
703 Workflow workflow = client.findWorkflowByArtifactUUID(UUID.randomUUID().toString());
704 assertNull(workflow);
708 public void getWorkflowByModelUUID_validUuid_expectedOutput() {
709 List<Workflow> workflows = client.findWorkflowByModelUUID("ff2ae348-214a-11e7-93ae-92361f002671");
710 assertTrue(workflows != null);
711 assertTrue(workflows.size() != 0);
713 assertEquals("testingWorkflow.bpmn", workflows.get(0).getArtifactName());
717 public void getWorkflowByModelUUID_invalidUuid_nullOutput() {
718 Workflow workflow = client.findWorkflowByArtifactUUID(UUID.randomUUID().toString());
719 assertNull(workflow);
723 public void getWorkflowBySource_validSource_expectedOutput() {
724 List<Workflow> workflows = client.findWorkflowBySource("sdc");
725 assertTrue(workflows != null);
726 assertTrue(workflows.size() != 0);
728 assertEquals("testingWorkflow.bpmn", workflows.get(0).getArtifactName());
732 public void getWorkflowBySource_invalidSource_nullOutput() {
733 List<Workflow> workflow = client.findWorkflowBySource("abc");
734 assertNull(workflow);
738 public void getCloudSites() {
739 List<CloudSite> cloudSites = client.getCloudSites();
740 assertNotNull(cloudSites);
741 assertNotEquals(0, cloudSites.size());