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.assertFalse;
26 import static org.junit.Assert.assertNotEquals;
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.BBNameSelectionReference;
37 import org.onap.so.db.catalog.beans.CloudIdentity;
38 import org.onap.so.db.catalog.beans.CloudSite;
39 import org.onap.so.db.catalog.beans.CloudifyManager;
40 import org.onap.so.db.catalog.beans.ExternalServiceToInternalService;
41 import org.onap.so.db.catalog.beans.HomingInstance;
42 import org.onap.so.db.catalog.beans.InstanceGroup;
43 import org.onap.so.db.catalog.beans.NetworkResourceCustomization;
44 import org.onap.so.db.catalog.beans.PnfResource;
45 import org.onap.so.db.catalog.beans.PnfResourceCustomization;
46 import org.onap.so.db.catalog.beans.ServerType;
47 import org.onap.so.db.catalog.beans.Service;
48 import org.onap.so.db.catalog.beans.ServiceRecipe;
49 import org.onap.so.db.catalog.beans.VfModule;
50 import org.onap.so.db.catalog.beans.VfModuleCustomization;
51 import org.onap.so.db.catalog.beans.VnfComponentsRecipe;
52 import org.onap.so.db.catalog.beans.VnfRecipe;
53 import org.onap.so.db.catalog.beans.VnfResource;
54 import org.onap.so.db.catalog.beans.VnfResourceCustomization;
55 import org.onap.so.db.catalog.beans.Workflow;
56 import org.onap.so.db.catalog.beans.macro.NorthBoundRequest;
57 import org.onap.so.db.catalog.beans.macro.RainyDayHandlerStatus;
58 import org.springframework.beans.factory.annotation.Autowired;
59 import org.springframework.beans.factory.annotation.Value;
60 import org.springframework.boot.web.server.LocalServerPort;
62 public class CatalogDbClientTest extends CatalogDbAdapterBaseTest {
64 public static final String MTN13 = "mtn13";
69 @Value("${mso.db.auth}")
70 private String msoAdaptersAuth;
73 CatalogDbClientPortChanger client;
78 public void initialize() {
79 client.wiremockPort = String.valueOf(port);
80 client.setEndpoint(getEndpoint(port));
83 protected String getEndpoint(int port) {
84 return "http://localhost:" + port;
88 public void testGetRainyDayHandler_Regex() {
89 RainyDayHandlerStatus rainyDayHandlerStatus = client.getRainyDayHandlerStatus("AssignServiceInstanceBB", "*",
90 "*", "*", "*", "The Flavor ID (nd.c6r16d20) could not be found.", "*");
91 assertEquals("Rollback", rainyDayHandlerStatus.getPolicy());
95 public void testGetRainyDayHandler__Encoding_Regex() {
96 RainyDayHandlerStatus rainyDayHandlerStatus = client.getRainyDayHandlerStatus("AssignServiceInstanceBB", "*",
98 "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",
100 assertEquals("Rollback", rainyDayHandlerStatus.getPolicy());
104 public void testGetCloudSiteHappyPath() throws Exception {
105 CloudSite cloudSite = client.getCloudSite(MTN13);
106 assertNotNull(cloudSite);
107 assertNotNull(cloudSite.getIdentityService());
108 assertEquals("MDT13", cloudSite.getClli());
109 assertEquals("mtn13", cloudSite.getRegionId());
110 assertEquals("MTN13", cloudSite.getIdentityServiceId());
114 public void testGetCloudSiteNotFound() throws Exception {
115 CloudSite cloudSite = client.getCloudSite(UUID.randomUUID().toString());
116 assertNull(cloudSite);
120 public void testGetCloudifyManagerHappyPath() throws Exception {
121 CloudifyManager cloudifyManager = client.getCloudifyManager("mtn13");
122 assertNotNull(cloudifyManager);
123 assertEquals("http://localhost:28090/v2.0", cloudifyManager.getCloudifyUrl());
128 public void testGetCloudifyManagerNotFound() throws Exception {
129 CloudifyManager cloudifyManager = client.getCloudifyManager(UUID.randomUUID().toString());
130 assertNull(cloudifyManager);
135 public void testGetCloudSiteByClliAndAicVersionHappyPath() throws Exception {
136 CloudSite cloudSite = client.getCloudSiteByClliAndAicVersion("MDT13", "2.5");
137 assertNotNull(cloudSite);
141 public void testGetCloudSiteByClliAndAicVersionNotFound() throws Exception {
142 CloudSite cloudSite = client.getCloudSiteByClliAndAicVersion("MDT13", "232496239746328");
143 assertNull(cloudSite);
147 public void testGetServiceByID() throws Exception {
148 Service serviceByID = client.getServiceByID("5df8b6de-2083-11e7-93ae-92361f002671");
149 assertNotNull(serviceByID);
150 assertEquals("MSOTADevInfra_vSAMP10a_Service", serviceByID.getModelName());
151 assertEquals("NA", serviceByID.getServiceType());
152 assertEquals("NA", serviceByID.getServiceRole());
156 public void testGetServiceByIDNotFound() throws Exception {
157 Service serviceByID = client.getServiceByID(UUID.randomUUID().toString());
158 assertNull(serviceByID);
162 public void testGetVfModuleByModelUUID() throws Exception {
163 VfModule vfModule = client.getVfModuleByModelUUID("20c4431c-246d-11e7-93ae-92361f002671");
164 assertNotNull(vfModule);
165 assertNotNull(vfModule.getVfModuleCustomization());
166 assertEquals("78ca26d0-246d-11e7-93ae-92361f002671", vfModule.getModelInvariantUUID());
167 assertEquals("vSAMP10aDEV::base::module-0", vfModule.getModelName());
171 public void testGetVfModuleByModelUUIDNotFound() throws Exception {
172 VfModule vfModule = client.getVfModuleByModelUUID(UUID.randomUUID().toString());
173 assertNull(vfModule);
177 public void testGetVnfResourceByModelUUID() throws Exception {
178 VnfResource vnfResource = client.getVnfResourceByModelUUID("ff2ae348-214a-11e7-93ae-92361f002671");
179 assertNotNull(vnfResource);
180 assertEquals("vSAMP10a", vnfResource.getModelName());
184 public void testGetVnfResourceByModelUUIDNotFound() throws Exception {
185 VnfResource vnfResource = client.getVnfResourceByModelUUID(UUID.randomUUID().toString());
186 assertNull(vnfResource);
190 public void testGetVnfResourceCustomizationByModelCustomizationUUID() {
191 VnfResourceCustomization vnfResourceCustomization =
192 client.getVnfResourceCustomizationByModelCustomizationUUID("68dc9a92-214c-11e7-93ae-92361f002671");
193 assertNotNull(vnfResourceCustomization);
194 assertEquals("vSAMP", vnfResourceCustomization.getNfRole());
195 assertNotNull(vnfResourceCustomization.getModelCustomizationUUID());
196 assertNotNull(vnfResourceCustomization.getVnfResources());
197 assertNotNull(vnfResourceCustomization.getVfModuleCustomizations());
198 assertEquals("vSAMP10a", vnfResourceCustomization.getVnfResources().getModelName());
199 assertTrue("skip post instantiation configuration", vnfResourceCustomization.isSkipPostInstConf());
203 public void testGetVnfResourceCustomizationByModelCustomizationUUINotFound() {
204 VnfResourceCustomization vnfResourceCustomization =
205 client.getVnfResourceCustomizationByModelCustomizationUUID(UUID.randomUUID().toString());
206 assertNull(vnfResourceCustomization);
210 public void testGetInstanceGroupByModelUUID() {
211 InstanceGroup instanceGroup = client.getInstanceGroupByModelUUID("0c8692ef-b9c0-435d-a738-edf31e71f38b");
212 assertNotNull(instanceGroup);
213 assertEquals("network_collection_resource_1806..NetworkCollection..0", instanceGroup.getModelName());
214 assertEquals("org.openecomp.resource.cr.NetworkCollectionResource1806",
215 instanceGroup.getToscaNodeType().toString());
219 public void testGetVfModuleCustomizationByModelCuztomizationUUID() {
220 VfModuleCustomization vfModuleCustomization =
221 client.getVfModuleCustomizationByModelCuztomizationUUID("cb82ffd8-252a-11e7-93ae-92361f002671");
222 assertNotNull(vfModuleCustomization);
223 assertNotNull(vfModuleCustomization.getModelCustomizationUUID());
224 assertEquals("base", vfModuleCustomization.getLabel());
228 public void testGetVfModuleCustomizationByModelCuztomizationUUIDNotFound() {
229 VfModuleCustomization vfModuleCustomization =
230 client.getVfModuleCustomizationByModelCuztomizationUUID(UUID.randomUUID().toString());
231 assertNull(vfModuleCustomization);
235 public void testGetNetworkResourceCustomizationByModelCustomizationUUID() {
236 NetworkResourceCustomization networkResourceCustomization =
237 client.getNetworkResourceCustomizationByModelCustomizationUUID("3bdbb104-476c-483e-9f8b-c095b3d308ac");
238 assertNotNull(networkResourceCustomization);
239 assertNotNull(networkResourceCustomization.getModelCustomizationUUID());
240 assertEquals("CONTRAIL30_GNDIRECT 9", networkResourceCustomization.getModelInstanceName());
241 assertNotNull(networkResourceCustomization.getNetworkResource());
245 public void testGetNetworkResourceCustomizationByModelCustomizationUUIDNotFound() {
246 NetworkResourceCustomization networkResourceCustomization =
247 client.getNetworkResourceCustomizationByModelCustomizationUUID(UUID.randomUUID().toString());
248 assertNull(networkResourceCustomization);
252 public void testGgetVfModuleCustomizationByModelCustomizationUUIDAndVfModuleModelUUID() {
253 VfModuleCustomization vfModuleCustomization =
254 client.getVfModuleCustomizationByModelCustomizationUUIDAndVfModuleModelUUID(
255 "cb82ffd8-252a-11e7-93ae-92361f002672", "20c4431c-246d-11e7-93ae-92361f002672");
256 assertNotNull(vfModuleCustomization);
257 assertNotNull(vfModuleCustomization.getModelCustomizationUUID());
258 assertNotNull(vfModuleCustomization.getVfModule());
259 assertEquals("base", vfModuleCustomization.getLabel());
263 public void testGgetVfModuleCustomizationByModelCustomizationUUIDAndVfModuleModelUUIDNotFound() {
264 VfModuleCustomization vfModuleCustomization =
265 client.getVfModuleCustomizationByModelCustomizationUUIDAndVfModuleModelUUID(
266 "cb82ffd8-252a-11e7-93ae-92361f002672", UUID.randomUUID().toString());
267 assertNull(vfModuleCustomization);
271 public void testGetFirstByServiceModelUUIDAndAction() {
272 ServiceRecipe serviceRecipe =
273 client.getFirstByServiceModelUUIDAndAction("4694a55f-58b3-4f17-92a5-796d6f5ffd0d", "createInstance");
274 assertNotNull(serviceRecipe);
275 assertNotNull(serviceRecipe.getServiceModelUUID());
276 assertNotNull(serviceRecipe.getAction());
277 assertEquals("/mso/async/services/CreateGenericALaCarteServiceInstance", serviceRecipe.getOrchestrationUri());
278 assertEquals("MSOTADevInfra aLaCarte", serviceRecipe.getDescription());
282 public void testGetFirstByServiceModelUUIDAndActionNotFound() {
283 ServiceRecipe serviceRecipe = client.getFirstByServiceModelUUIDAndAction("5df8b6de-2083-11e7-93ae-92361f002671",
284 UUID.randomUUID().toString());
285 assertNull(serviceRecipe);
289 public void testGetFirstVnfResourceByModelInvariantUUIDAndModelVersion() {
290 VnfResource vnfResource = client
291 .getFirstVnfResourceByModelInvariantUUIDAndModelVersion("2fff5b20-214b-11e7-93ae-92361f002671", "2.0");
292 assertNotNull(vnfResource);
293 assertNotNull(vnfResource.getModelInvariantId());
294 assertNotNull(vnfResource.getModelVersion());
295 assertNotNull(vnfResource.getHeatTemplates());
296 assertEquals("vSAMP10a", vnfResource.getModelName());
300 public void testGetFirstVnfResourceByModelInvariantUUIDAndModelVersionNotFound() {
301 VnfResource vnfResource = client.getFirstVnfResourceByModelInvariantUUIDAndModelVersion(
302 "2fff5b20-214b-11e7-93ae-92361f002671", UUID.randomUUID().toString());
303 assertNull(vnfResource);
307 public void testGetFirstVnfResourceCustomizationByModelInstanceNameAndVnfResources() {
308 VnfResource vnfr = new VnfResource();
309 vnfr.setModelUUID("ff2ae348-214a-11e7-93ae-92361f002671");
310 VnfResourceCustomization firstVnfResourceCustomizationByModelInstanceNameAndVnfResources =
311 client.getFirstVnfResourceCustomizationByModelInstanceNameAndVnfResources("vSAMP10a 1", vnfr);
312 assertNotNull(firstVnfResourceCustomizationByModelInstanceNameAndVnfResources);
313 assertEquals("vSAMP", firstVnfResourceCustomizationByModelInstanceNameAndVnfResources.getNfRole());
314 assertEquals("vSAMP10a 1",
315 firstVnfResourceCustomizationByModelInstanceNameAndVnfResources.getModelInstanceName());
316 assertNotNull(firstVnfResourceCustomizationByModelInstanceNameAndVnfResources.getVnfResources());
317 assertNotNull(firstVnfResourceCustomizationByModelInstanceNameAndVnfResources.getVfModuleCustomizations());
321 public void testGetFirstVnfRecipeByNfRoleAndAction() {
322 VnfRecipe vnfRecipe = client.getFirstVnfRecipeByNfRoleAndAction("GR-API-DEFAULT", "createInstance");
323 assertNotNull(vnfRecipe);
324 assertNotNull(vnfRecipe.getNfRole());
325 assertNotNull(vnfRecipe.getAction());
326 assertEquals("Gr api recipe to create vnf", vnfRecipe.getDescription());
327 assertEquals("/mso/async/services/WorkflowActionBB", vnfRecipe.getOrchestrationUri());
331 public void testGetFirstVnfRecipeByNfRoleAndActionNotFound() {
332 VnfRecipe vnfRecipe = client.getFirstVnfRecipeByNfRoleAndAction(UUID.randomUUID().toString(), "createInstance");
333 assertNull(vnfRecipe);
337 public void testGetFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction() {
338 VnfComponentsRecipe vnfComponentsRecipe =
339 client.getFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction(
340 "20c4431c-246d-11e7-93ae-92361f002671", "volumeGroup", "createInstance");
341 assertNotNull(vnfComponentsRecipe);
342 assertNotNull(vnfComponentsRecipe.getAction());
343 assertNotNull(vnfComponentsRecipe.getVfModuleModelUUID());
344 assertNotNull(vnfComponentsRecipe.getVnfComponentType());
345 assertEquals("Gr api recipe to create volume-group", vnfComponentsRecipe.getDescription());
346 assertEquals("/mso/async/services/WorkflowActionBB", vnfComponentsRecipe.getOrchestrationUri());
352 public void testGetFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndActionNotFound() {
353 VnfComponentsRecipe vnfComponentsRecipe =
354 client.getFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction(
355 UUID.randomUUID().toString(), "volumeGroup", "createInstance");
356 assertNull(vnfComponentsRecipe);
360 public void testGetFirstVnfComponentsRecipeByVnfComponentTypeAndAction() {
361 VnfComponentsRecipe vnfComponentsRecipe =
362 client.getFirstVnfComponentsRecipeByVnfComponentTypeAndAction("volumeGroup", "createInstance");
363 assertNotNull(vnfComponentsRecipe);
364 assertNotNull(vnfComponentsRecipe.getAction());
365 assertNotNull(vnfComponentsRecipe.getVnfComponentType());
366 assertEquals("VID_DEFAULT recipe t", vnfComponentsRecipe.getDescription());
367 assertEquals("/mso/async/services/CreateVfModuleVolumeInfraV1", vnfComponentsRecipe.getOrchestrationUri());
371 public void testGetServiceByModelVersionAndModelInvariantUUID() {
373 client.getServiceByModelVersionAndModelInvariantUUID("2.0", "9647dfc4-2083-11e7-93ae-92361f002671");
374 assertNotNull(service);
375 assertNotNull(service.getModelVersion());
376 assertNotNull(service.getModelInvariantUUID());
377 assertEquals("MSOTADevInfra_vSAMP10a_Service", service.getModelName());
378 assertEquals("NA", service.getServiceRole());
382 public void testGetServiceByModelVersionAndModelInvariantUUIDNotFound() {
383 Service service = client.getServiceByModelVersionAndModelInvariantUUID("2.0", UUID.randomUUID().toString());
388 public void testGetVfModuleByModelInvariantUUIDAndModelVersion() {
390 client.getVfModuleByModelInvariantUUIDAndModelVersion("78ca26d0-246d-11e7-93ae-92361f002671", "2");
391 assertNotNull(vfModule);
392 assertNotNull(vfModule.getModelVersion());
393 assertNotNull(vfModule.getModelInvariantUUID());
394 assertEquals("vSAMP10aDEV::base::module-0", vfModule.getModelName());
395 assertEquals("vSAMP10a DEV Base", vfModule.getDescription());
399 public void testGetVfModuleByModelInvariantUUIDAndModelVersionNotFound() {
400 VfModule vfModule = client.getVfModuleByModelInvariantUUIDAndModelVersion(UUID.randomUUID().toString(), "2");
401 assertNull(vfModule);
405 public void testGetServiceByModelInvariantUUIDOrderByModelVersionDesc() {
406 List<Service> serviceList =
407 client.getServiceByModelInvariantUUIDOrderByModelVersionDesc("9647dfc4-2083-11e7-93ae-92361f002671");
408 assertFalse(serviceList.isEmpty());
409 assertEquals(2, serviceList.size());
410 Service service = serviceList.get(0);
411 assertEquals("2.0", service.getModelVersion());
415 public void testGetServiceByModelInvariantUUIDOrderByModelVersionDescNotFound() {
416 List<Service> serviceList =
417 client.getServiceByModelInvariantUUIDOrderByModelVersionDesc(UUID.randomUUID().toString());
418 assertTrue(serviceList.isEmpty());
422 public void testGetVfModuleByModelInvariantUUIDOrderByModelVersionDesc() {
423 List<VfModule> moduleList =
424 client.getVfModuleByModelInvariantUUIDOrderByModelVersionDesc("78ca26d0-246d-11e7-93ae-92361f002671");
425 assertFalse(moduleList.isEmpty());
426 assertEquals(2, moduleList.size());
427 VfModule module = moduleList.get(0);
428 assertEquals("vSAMP10a DEV Base", module.getDescription());
432 public void testCloudSiteClient() {
433 CatalogDbClientPortChanger localClient = new CatalogDbClientPortChanger(
434 "http://localhost:" + client.wiremockPort, msoAdaptersAuth, client.wiremockPort);
435 CloudSite cloudSite = new CloudSite();
436 cloudSite.setId("MTN6");
437 cloudSite.setClli("TESTCLLI");
438 cloudSite.setRegionId("regionId");
439 cloudSite.setCloudVersion("VERSION");
440 cloudSite.setPlatform("PLATFORM");
442 CloudIdentity cloudIdentity = new CloudIdentity();
443 cloudIdentity.setId("RANDOMID");
444 cloudIdentity.setIdentityUrl("URL");
445 cloudIdentity.setMsoId("MSO_ID");
446 cloudIdentity.setMsoPass("MSO_PASS");
447 cloudIdentity.setAdminTenant("ADMIN_TENANT");
448 cloudIdentity.setMemberRole("ROLE");
449 cloudIdentity.setIdentityServerType(ServerType.KEYSTONE);
450 cloudIdentity.setIdentityAuthenticationType(AuthenticationType.RACKSPACE_APIKEY);
451 cloudSite.setIdentityService(cloudIdentity);
452 localClient.postCloudSite(cloudSite);
453 CloudSite getCloudSite = this.client.getCloudSite("MTN6");
454 assertNotNull(getCloudSite);
455 assertNotNull(getCloudSite.getIdentityService());
456 assertEquals("TESTCLLI", getCloudSite.getClli());
457 assertEquals("regionId", getCloudSite.getRegionId());
458 assertEquals("RANDOMID", getCloudSite.getIdentityServiceId());
460 getCloudSite.setClli("clli2");
461 getCloudSite.setRegionId("region2");
463 CloudSite updatedCloudSite = this.client.updateCloudSite(getCloudSite);
464 assertNotNull(updatedCloudSite);
465 assertNotNull(updatedCloudSite.getIdentityService());
466 assertEquals("clli2", updatedCloudSite.getClli());
467 assertEquals("region2", updatedCloudSite.getRegionId());
469 this.client.deleteCloudSite(getCloudSite.getId());
470 getCloudSite = this.client.getCloudSite("MTN6");
471 assertNull(getCloudSite);
475 public void testGetHomingInstance() {
476 HomingInstance homingInstance = client.getHomingInstance("5df8b6de-2083-11e7-93ae-92361f232671");
477 assertNotNull(homingInstance);
478 assertNotNull(homingInstance.getCloudOwner());
479 assertNotNull(homingInstance.getCloudRegionId());
480 assertNotNull(homingInstance.getOofDirectives());
484 public void testPostHomingInstance() {
485 CatalogDbClientPortChanger localClient = new CatalogDbClientPortChanger(
486 "http://localhost:" + client.wiremockPort, msoAdaptersAuth, client.wiremockPort);
487 HomingInstance homingInstance = new HomingInstance();
488 homingInstance.setServiceInstanceId("5df8d6be-2083-11e7-93ae-92361f232671");
489 homingInstance.setCloudOwner("CloudOwner-1");
490 homingInstance.setCloudRegionId("CloudRegionOne");
491 homingInstance.setOofDirectives("{\n" + "\"directives\": [\n" + "{\n" + "\"directives\": [\n" + "{\n"
492 + "\"attributes\": [\n" + "{\n" + "\"attribute_value\": \"onap.hpa.flavor31\",\n"
493 + "\"attribute_name\": \"firewall_flavor_name\"\n" + "}\n" + "],\n"
494 + "\"type\": \"flavor_directives\"\n" + "}\n" + "],\n" + "\"type\": \"vnfc\",\n" + "\"id\": \"vfw\"\n"
495 + "},\n" + "{\n" + "\"directives\": [\n" + "{\n" + "\"attributes\": [\n" + "{\n"
496 + "\"attribute_value\": \"onap.hpa.flavor32\",\n" + "\"attribute_name\": \"packetgen_flavor_name\"\n"
497 + "}\n" + "],\n" + "\"type\": \"flavor_directives\"\n" + "}\n" + "],\n" + "\"type\": \"vnfc\",\n"
498 + "\"id\": \"vgenerator\"\n" + "},\n" + "{\n" + "\"directives\": [\n" + "{\n" + "\"attributes\": [\n"
499 + "{\n" + "\"attribute_value\": \"onap.hpa.flavor31\",\n" + "\"attribute_name\": \"sink_flavor_name\"\n"
500 + "}\n" + "],\n" + "\"type\": \"flavor_directives\"\n" + "}\n" + "],\n" + "\"type\": \"vnfc\",\n"
501 + "\"id\": \"vsink\"\n" + "}\n" + "]\n" + "}");
502 localClient.postHomingInstance(homingInstance);
503 HomingInstance getHomingInstance = this.client.getHomingInstance("5df8d6be-2083-11e7-93ae-92361f232671");
504 assertNotNull(getHomingInstance);
505 assertNotNull(getHomingInstance.getCloudRegionId());
506 assertNotNull(getHomingInstance.getCloudOwner());
507 assertEquals("CloudOwner-1", getHomingInstance.getCloudOwner());
508 assertEquals("CloudRegionOne", getHomingInstance.getCloudRegionId());
512 public void testGetServiceByModelName() {
513 Service service = client.getServiceByModelName("MSOTADevInfra_Test_Service");
514 assertNotNull(service);
515 assertNotNull(service.getModelVersion());
516 assertNotNull(service.getModelInvariantUUID());
517 assertEquals("MSOTADevInfra_Test_Service", service.getModelName());
518 assertEquals("NA", service.getServiceRole());
522 public void testGetServiceByModelNameNotFound() {
523 Service service = client.getServiceByModelName("Not_Found");
528 public void testGetServiceByModelUUID() {
529 Service service = client.getServiceByModelUUID("5df8b6de-2083-11e7-93ae-92361f002679");
530 assertNotNull(service);
531 assertNotNull(service.getModelVersion());
532 assertNotNull(service.getModelInvariantUUID());
533 assertEquals("5df8b6de-2083-11e7-93ae-92361f002679", service.getModelUUID());
534 assertEquals("NA", service.getServiceRole());
538 public void testGetServiceByModelUUIDNotFound() {
539 Service service = client.getServiceByModelUUID("Not_Found");
544 public void testGetNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner() {
545 NorthBoundRequest northBoundRequest = new NorthBoundRequest();
546 northBoundRequest.setAction("createService");
547 northBoundRequest.setRequestScope("service");
548 northBoundRequest.setIsAlacarte(true);
549 northBoundRequest.setCloudOwner("my-custom-cloud-owner");
550 client.getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner("createService", "service", true,
551 "my-custom-cloud-owner");
552 assertNotNull(northBoundRequest);
553 assertEquals("createService", northBoundRequest.getAction());
554 assertEquals("service", northBoundRequest.getRequestScope());
555 assertEquals(true, northBoundRequest.getIsAlacarte());
556 assertEquals("my-custom-cloud-owner", northBoundRequest.getCloudOwner());
560 public void testFindServiceRecipeByActionAndServiceModelUUID() {
561 ServiceRecipe serviceRecipe = client.findServiceRecipeByActionAndServiceModelUUID("createInstance",
562 "4694a55f-58b3-4f17-92a5-796d6f5ffd0d");
563 assertNotNull(serviceRecipe);
564 assertNotNull(serviceRecipe.getServiceModelUUID());
565 assertNotNull(serviceRecipe.getAction());
566 assertEquals("/mso/async/services/CreateGenericALaCarteServiceInstance", serviceRecipe.getOrchestrationUri());
567 assertEquals("MSOTADevInfra aLaCarte", serviceRecipe.getDescription());
571 public void testFindServiceRecipeByActionAndServiceModelUUIDNotFound() {
572 ServiceRecipe serviceRecipe =
573 client.findServiceRecipeByActionAndServiceModelUUID("not_found", "5df8b6de-2083-11e7-93ae-test");
574 assertNull(serviceRecipe);
578 public void testFindExternalToInternalServiceByServiceName() {
579 ExternalServiceToInternalService externalServiceToInternalService =
580 client.findExternalToInternalServiceByServiceName("MySpecialServiceName");
581 assertNotNull(externalServiceToInternalService);
582 assertNotNull(externalServiceToInternalService.getServiceName());
583 assertNotNull(externalServiceToInternalService.getServiceModelUUID());
584 assertEquals("MySpecialServiceName", externalServiceToInternalService.getServiceName());
588 public void testFindExternalToInternalServiceByServiceNameNotFound() {
589 ExternalServiceToInternalService externalServiceToInternalService =
590 client.findExternalToInternalServiceByServiceName("Not_Found");
591 assertNull(externalServiceToInternalService);
595 public void getPnfResourceByModelUUID_validUuid_expectedOutput() {
596 PnfResource pnfResource = client.getPnfResourceByModelUUID("ff2ae348-214a-11e7-93ae-92361f002680");
597 assertNotNull(pnfResource);
598 assertEquals("PNFResource modelUUID", "ff2ae348-214a-11e7-93ae-92361f002680", pnfResource.getModelUUID());
599 assertEquals("PNFResource modelInvariantUUID", "2fff5b20-214b-11e7-93ae-92361f002680",
600 pnfResource.getModelInvariantUUID());
601 assertEquals("PNFResource modelVersion", "1.0", pnfResource.getModelVersion());
602 assertEquals("PNFResource orchestration mode", "", pnfResource.getOrchestrationMode());
606 public void getPnfResourceByModelUUID_invalidUuid_NullOutput() {
607 PnfResource pnfResource = client.getPnfResourceByModelUUID(UUID.randomUUID().toString());
608 assertNull(pnfResource);
612 public void getPnfResourceCustomizationByModelCustomizationUUID_validUuid_expectedOutput() {
613 PnfResourceCustomization pnfResourceCustomization =
614 client.getPnfResourceCustomizationByModelCustomizationUUID("68dc9a92-214c-11e7-93ae-92361f002680");
615 assertEquals("modelInstanceName", "PNF routing", pnfResourceCustomization.getModelInstanceName());
616 assertEquals("blueprintName", "test_configuration_restconf", pnfResourceCustomization.getBlueprintName());
617 assertEquals("blueprintVersion", "1.0.0", pnfResourceCustomization.getBlueprintVersion());
618 assertTrue("skip post instantiation configuration", pnfResourceCustomization.isSkipPostInstConf());
619 PnfResource pnfResource = pnfResourceCustomization.getPnfResources();
620 assertNotNull(pnfResource);
621 assertEquals("PNFResource modelUUID", "ff2ae348-214a-11e7-93ae-92361f002680", pnfResource.getModelUUID());
622 assertEquals("PNFResource modelInvariantUUID", "2fff5b20-214b-11e7-93ae-92361f002680",
623 pnfResource.getModelInvariantUUID());
624 assertEquals("PNFResource modelVersion", "1.0", pnfResource.getModelVersion());
625 assertEquals("PNFResource orchestration mode", "", pnfResource.getOrchestrationMode());
629 public void getPnfResourceCustomizationByModelCustomizationUUID_invalidUuid_nullOutput() {
630 PnfResourceCustomization pnfResourceCustomization =
631 client.getPnfResourceCustomizationByModelCustomizationUUID(UUID.randomUUID().toString());
632 assertNull(pnfResourceCustomization);
636 public void getPnfResourceCustomizationFromJoinTable_validServiceUuid_expectedOutput() {
637 List<PnfResourceCustomization> pnfResourceCustomizationList =
638 client.getPnfResourceCustomizationByModelUuid("5df8b6de-2083-11e7-93ae-92361f002676");
639 assertEquals(1, pnfResourceCustomizationList.size());
641 PnfResourceCustomization pnfResourceCustomization = pnfResourceCustomizationList.get(0);
642 assertEquals("modelInstanceName", "PNF routing", pnfResourceCustomization.getModelInstanceName());
643 assertEquals("blueprintName", "test_configuration_restconf", pnfResourceCustomization.getBlueprintName());
644 assertEquals("blueprintVersion", "1.0.0", pnfResourceCustomization.getBlueprintVersion());
645 PnfResource pnfResource = pnfResourceCustomization.getPnfResources();
646 assertNotNull(pnfResource);
648 assertEquals("PNFResource modelUUID", "ff2ae348-214a-11e7-93ae-92361f002680", pnfResource.getModelUUID());
649 assertEquals("PNFResource modelInvariantUUID", "2fff5b20-214b-11e7-93ae-92361f002680",
650 pnfResource.getModelInvariantUUID());
651 assertEquals("PNFResource modelVersion", "1.0", pnfResource.getModelVersion());
652 assertEquals("PNFResource orchestration mode", "", pnfResource.getOrchestrationMode());
656 public void getPnfResourceCustomizationFromJoinTable_invalidServiceUuid_nullOutput() {
657 List<PnfResourceCustomization> pnfResourceCustomizationList =
658 client.getPnfResourceCustomizationByModelUuid(UUID.randomUUID().toString());
659 assertEquals(0, pnfResourceCustomizationList.size());
663 public void testGetServiceTopologyById() throws Exception {
664 org.onap.so.rest.catalog.beans.Service serviceByID =
665 client.getServiceModelInformation("5df8b6de-2083-11e7-93ae-92361f002671", "2");
666 assertNotNull(serviceByID);
667 assertEquals("MSOTADevInfra_vSAMP10a_Service", serviceByID.getModelName());
668 assertEquals("NA", serviceByID.getServiceType());
669 assertEquals("NA", serviceByID.getServiceRole());
673 public void testGetServices() throws Exception {
674 List<org.onap.so.rest.catalog.beans.Service> services = client.getServices();
675 assertEquals(false, services.isEmpty());
679 public void testVnf() throws Exception {
680 org.onap.so.rest.catalog.beans.Vnf vnf = client.getVnfModelInformation("5df8b6de-2083-11e7-93ae-92361f002671",
681 "68dc9a92-214c-11e7-93ae-92361f002671", "0");
683 assertEquals("vSAMP10a", vnf.getModelName());
684 assertEquals(false, vnf.getNfDataValid());
685 assertEquals("vSAMP", vnf.getNfFunction());
686 assertEquals("vSAMP", vnf.getNfNamingCode());
687 assertEquals("vSAMP", vnf.getNfRole());
688 assertEquals("vSAMP", vnf.getNfType());
690 vnf.setNfDataValid(true);
691 vnf.setNfFunction("nfFunction");
692 vnf.setNfRole("nfRole");
693 vnf.setNfType("nfType");
694 vnf.setNfNamingCode("nfNamingCode");
696 client.updateVnf("5df8b6de-2083-11e7-93ae-92361f002671", vnf);
697 vnf = client.getVnfModelInformation("5df8b6de-2083-11e7-93ae-92361f002671",
698 "68dc9a92-214c-11e7-93ae-92361f002671", "0");
699 assertEquals("vSAMP10a", vnf.getModelName());
700 assertEquals(true, vnf.getNfDataValid());
701 assertEquals("nfFunction", vnf.getNfFunction());
702 assertEquals("nfNamingCode", vnf.getNfNamingCode());
703 assertEquals("nfRole", vnf.getNfRole());
704 assertEquals("nfType", vnf.getNfType());
710 public void getWorkflowByArtifactUUID_validUuid_expectedOutput() {
711 Workflow workflow = client.findWorkflowByArtifactUUID("5b0c4322-643d-4c9f-b184-4516049e99b1");
712 assertEquals("artifactName", "testingWorkflow.bpmn", workflow.getArtifactName());
716 public void getWorkflowByArtifactUUID_invalidUuid_nullOutput() {
717 Workflow workflow = client.findWorkflowByArtifactUUID(UUID.randomUUID().toString());
718 assertNull(workflow);
722 public void getWorkflowByVnfModelUUID_validUuid_expectedOutput() {
723 List<Workflow> workflows = client.findWorkflowByVnfModelUUID("ff2ae348-214a-11e7-93ae-92361f002671");
724 assertTrue(workflows != null);
725 assertTrue(workflows.size() != 0);
727 assertEquals("testingWorkflow.bpmn", workflows.get(0).getArtifactName());
731 public void getWorkflowByModelUUID_invalidUuid_nullOutput() {
732 Workflow workflow = client.findWorkflowByArtifactUUID(UUID.randomUUID().toString());
733 assertNull(workflow);
737 public void getWorkflowBySource_validSource_expectedOutput() {
738 List<Workflow> workflows = client.findWorkflowBySource("sdc");
739 assertTrue(workflows != null);
740 assertTrue(workflows.size() != 0);
742 assertEquals("testingWorkflow.bpmn", workflows.get(0).getArtifactName());
746 public void getWorkflowBySource_invalidSource_nullOutput() {
747 List<Workflow> workflow = client.findWorkflowBySource("abc");
748 assertNull(workflow);
752 public void getCloudSites() {
753 List<CloudSite> cloudSites = client.getCloudSites();
754 assertNotNull(cloudSites);
755 assertNotEquals(0, cloudSites.size());
759 public void getBBNameSelectionReference_validData_expectedOutput() {
760 BBNameSelectionReference bbNameSelectionReference =
761 client.getBBNameSelectionReference("APPC", "vfModule", "healthCheck");
762 assertNotNull(bbNameSelectionReference);
763 assertEquals("GenericVnfHealthCheckBB", bbNameSelectionReference.getBbName());
767 public void getBBNameSelectionReference_invalidData_nullOutput() {
768 BBNameSelectionReference bbNameSelectionReference =
769 client.getBBNameSelectionReference("ABC", "vfModule", "healthCheck");
770 assertNull(bbNameSelectionReference);