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