2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 - 2018 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
21 package org.onap.so.db.catalog.client;
24 import static org.junit.Assert.assertEquals;
25 import static org.junit.Assert.assertNotNull;
26 import static org.junit.Assert.assertTrue;
27 import java.util.List;
28 import java.util.UUID;
29 import org.junit.Assert;
30 import org.junit.Before;
31 import org.junit.Test;
32 import org.junit.runner.RunWith;
33 import org.onap.so.adapters.catalogdb.CatalogDBApplication;
34 import org.onap.so.adapters.catalogdb.CatalogDbAdapterBaseTest;
35 import org.onap.so.db.catalog.beans.AuthenticationType;
36 import org.onap.so.db.catalog.beans.CloudIdentity;
37 import org.onap.so.db.catalog.beans.CloudSite;
38 import org.onap.so.db.catalog.beans.CloudifyManager;
39 import org.onap.so.db.catalog.beans.ExternalServiceToInternalService;
40 import org.onap.so.db.catalog.beans.HomingInstance;
41 import org.onap.so.db.catalog.beans.InstanceGroup;
42 import org.onap.so.db.catalog.beans.NetworkResourceCustomization;
43 import org.onap.so.db.catalog.beans.PnfResource;
44 import org.onap.so.db.catalog.beans.PnfResourceCustomization;
45 import org.onap.so.db.catalog.beans.ServerType;
46 import org.onap.so.db.catalog.beans.Service;
47 import org.onap.so.db.catalog.beans.ServiceRecipe;
48 import org.onap.so.db.catalog.beans.VfModule;
49 import org.onap.so.db.catalog.beans.VfModuleCustomization;
50 import org.onap.so.db.catalog.beans.VnfComponentsRecipe;
51 import org.onap.so.db.catalog.beans.VnfRecipe;
52 import org.onap.so.db.catalog.beans.VnfResource;
53 import org.onap.so.db.catalog.beans.VnfResourceCustomization;
54 import org.onap.so.db.catalog.beans.Workflow;
55 import org.onap.so.db.catalog.beans.macro.NorthBoundRequest;
56 import org.onap.so.db.catalog.beans.macro.RainyDayHandlerStatus;
57 import org.springframework.beans.factory.annotation.Autowired;
58 import org.springframework.beans.factory.annotation.Value;
59 import org.springframework.boot.test.context.SpringBootTest;
60 import org.springframework.boot.web.server.LocalServerPort;
61 import org.springframework.test.context.ActiveProfiles;
62 import org.springframework.test.context.junit4.SpringRunner;
64 public class CatalogDbClientTest extends CatalogDbAdapterBaseTest {
66 public static final String MTN13 = "mtn13";
71 @Value("${mso.db.auth}")
72 private String msoAdaptersAuth;
75 CatalogDbClientPortChanger client;
78 public void initialize() {
79 client.wiremockPort = String.valueOf(port);
83 public void testGetRainyDayHandlerStatusByFlowNameAndServiceTypeAndVnfTypeAndErrorCodeAndWorkStep() {
84 RainyDayHandlerStatus rainyDayHandlerStatus =
85 client.getRainyDayHandlerStatusByFlowNameAndServiceTypeAndVnfTypeAndErrorCodeAndWorkStep(
86 "AssignServiceInstanceBB", "*", "*", "*", "*");
87 Assert.assertEquals("Rollback", rainyDayHandlerStatus.getPolicy());
91 public void testGetRainyDayHandlerStatusByFlowNameAndServiceTypeAndVnfTypeAndErrorCodeAndWorkStepRecordNotFound() {
92 RainyDayHandlerStatus rainyDayHandlerStatus =
93 client.getRainyDayHandlerStatusByFlowNameAndServiceTypeAndVnfTypeAndErrorCodeAndWorkStep(
94 UUID.randomUUID().toString(), "*", "*", "*", "*");
95 Assert.assertNull(rainyDayHandlerStatus);
99 public void testGetCloudSiteHappyPath() throws Exception {
100 CloudSite cloudSite = client.getCloudSite(MTN13);
101 Assert.assertNotNull(cloudSite);
102 Assert.assertNotNull(cloudSite.getIdentityService());
103 Assert.assertEquals("MDT13", cloudSite.getClli());
104 Assert.assertEquals("mtn13", cloudSite.getRegionId());
105 Assert.assertEquals("MTN13", cloudSite.getIdentityServiceId());
109 public void testGetCloudSiteNotFound() throws Exception {
110 CloudSite cloudSite = client.getCloudSite(UUID.randomUUID().toString());
111 Assert.assertNull(cloudSite);
115 public void testGetCloudifyManagerHappyPath() throws Exception {
116 CloudifyManager cloudifyManager = client.getCloudifyManager("mtn13");
117 Assert.assertNotNull(cloudifyManager);
118 Assert.assertEquals("http://localhost:28090/v2.0", cloudifyManager.getCloudifyUrl());
123 public void testGetCloudifyManagerNotFound() throws Exception {
124 CloudifyManager cloudifyManager = client.getCloudifyManager(UUID.randomUUID().toString());
125 Assert.assertNull(cloudifyManager);
130 public void testGetCloudSiteByClliAndAicVersionHappyPath() throws Exception {
131 CloudSite cloudSite = client.getCloudSiteByClliAndAicVersion("MDT13", "2.5");
132 Assert.assertNotNull(cloudSite);
136 public void testGetCloudSiteByClliAndAicVersionNotFound() throws Exception {
137 CloudSite cloudSite = client.getCloudSiteByClliAndAicVersion("MDT13", "232496239746328");
138 Assert.assertNull(cloudSite);
142 public void testGetServiceByID() throws Exception {
143 Service serviceByID = client.getServiceByID("5df8b6de-2083-11e7-93ae-92361f002671");
144 Assert.assertNotNull(serviceByID);
145 Assert.assertEquals("MSOTADevInfra_vSAMP10a_Service", serviceByID.getModelName());
146 Assert.assertEquals("NA", serviceByID.getServiceType());
147 Assert.assertEquals("NA", serviceByID.getServiceRole());
151 public void testGetServiceByIDNotFound() throws Exception {
152 Service serviceByID = client.getServiceByID(UUID.randomUUID().toString());
153 Assert.assertNull(serviceByID);
157 public void testGetVfModuleByModelUUID() throws Exception {
158 VfModule vfModule = client.getVfModuleByModelUUID("20c4431c-246d-11e7-93ae-92361f002671");
159 Assert.assertNotNull(vfModule);
160 Assert.assertNotNull(vfModule.getVfModuleCustomization());
161 Assert.assertEquals("78ca26d0-246d-11e7-93ae-92361f002671", vfModule.getModelInvariantUUID());
162 Assert.assertEquals("vSAMP10aDEV::base::module-0", vfModule.getModelName());
166 public void testGetVfModuleByModelUUIDNotFound() throws Exception {
167 VfModule vfModule = client.getVfModuleByModelUUID(UUID.randomUUID().toString());
168 Assert.assertNull(vfModule);
172 public void testGetVnfResourceByModelUUID() throws Exception {
173 VnfResource vnfResource = client.getVnfResourceByModelUUID("ff2ae348-214a-11e7-93ae-92361f002671");
174 Assert.assertNotNull(vnfResource);
175 Assert.assertEquals("vSAMP10a", vnfResource.getModelName());
179 public void testGetVnfResourceByModelUUIDNotFound() throws Exception {
180 VnfResource vnfResource = client.getVnfResourceByModelUUID(UUID.randomUUID().toString());
181 Assert.assertNull(vnfResource);
185 public void testGetVnfResourceCustomizationByModelCustomizationUUID() {
186 VnfResourceCustomization vnfResourceCustomization =
187 client.getVnfResourceCustomizationByModelCustomizationUUID("68dc9a92-214c-11e7-93ae-92361f002671");
188 Assert.assertNotNull(vnfResourceCustomization);
189 Assert.assertEquals("vSAMP", vnfResourceCustomization.getNfRole());
190 Assert.assertNotNull(vnfResourceCustomization.getModelCustomizationUUID());
191 Assert.assertNotNull(vnfResourceCustomization.getVnfResources());
192 Assert.assertNotNull(vnfResourceCustomization.getVfModuleCustomizations());
193 Assert.assertEquals("vSAMP10a", vnfResourceCustomization.getVnfResources().getModelName());
194 assertTrue("skip post instantiation configuration", vnfResourceCustomization.isSkipPostInstConf());
198 public void testGetVnfResourceCustomizationByModelCustomizationUUINotFound() {
199 VnfResourceCustomization vnfResourceCustomization =
200 client.getVnfResourceCustomizationByModelCustomizationUUID(UUID.randomUUID().toString());
201 Assert.assertNull(vnfResourceCustomization);
205 public void testGetInstanceGroupByModelUUID() {
206 InstanceGroup instanceGroup = client.getInstanceGroupByModelUUID("0c8692ef-b9c0-435d-a738-edf31e71f38b");
207 Assert.assertNotNull(instanceGroup);
208 Assert.assertEquals("network_collection_resource_1806..NetworkCollection..0", instanceGroup.getModelName());
209 Assert.assertEquals("org.openecomp.resource.cr.NetworkCollectionResource1806",
210 instanceGroup.getToscaNodeType().toString());
214 public void testGetVfModuleCustomizationByModelCuztomizationUUID() {
215 VfModuleCustomization vfModuleCustomization =
216 client.getVfModuleCustomizationByModelCuztomizationUUID("cb82ffd8-252a-11e7-93ae-92361f002671");
217 Assert.assertNotNull(vfModuleCustomization);
218 Assert.assertNotNull(vfModuleCustomization.getModelCustomizationUUID());
219 Assert.assertEquals("base", vfModuleCustomization.getLabel());
223 public void testGetVfModuleCustomizationByModelCuztomizationUUIDNotFound() {
224 VfModuleCustomization vfModuleCustomization =
225 client.getVfModuleCustomizationByModelCuztomizationUUID(UUID.randomUUID().toString());
226 Assert.assertNull(vfModuleCustomization);
230 public void testGetNetworkResourceCustomizationByModelCustomizationUUID() {
231 NetworkResourceCustomization networkResourceCustomization =
232 client.getNetworkResourceCustomizationByModelCustomizationUUID("3bdbb104-476c-483e-9f8b-c095b3d308ac");
233 Assert.assertNotNull(networkResourceCustomization);
234 Assert.assertNotNull(networkResourceCustomization.getModelCustomizationUUID());
235 Assert.assertEquals("CONTRAIL30_GNDIRECT 9", networkResourceCustomization.getModelInstanceName());
236 Assert.assertNotNull(networkResourceCustomization.getNetworkResource());
240 public void testGetNetworkResourceCustomizationByModelCustomizationUUIDNotFound() {
241 NetworkResourceCustomization networkResourceCustomization =
242 client.getNetworkResourceCustomizationByModelCustomizationUUID(UUID.randomUUID().toString());
243 Assert.assertNull(networkResourceCustomization);
247 public void testGgetVfModuleCustomizationByModelCustomizationUUIDAndVfModuleModelUUID() {
248 VfModuleCustomization vfModuleCustomization =
249 client.getVfModuleCustomizationByModelCustomizationUUIDAndVfModuleModelUUID(
250 "cb82ffd8-252a-11e7-93ae-92361f002672", "20c4431c-246d-11e7-93ae-92361f002672");
251 Assert.assertNotNull(vfModuleCustomization);
252 Assert.assertNotNull(vfModuleCustomization.getModelCustomizationUUID());
253 Assert.assertNotNull(vfModuleCustomization.getVfModule());
254 Assert.assertEquals("base", vfModuleCustomization.getLabel());
258 public void testGgetVfModuleCustomizationByModelCustomizationUUIDAndVfModuleModelUUIDNotFound() {
259 VfModuleCustomization vfModuleCustomization =
260 client.getVfModuleCustomizationByModelCustomizationUUIDAndVfModuleModelUUID(
261 "cb82ffd8-252a-11e7-93ae-92361f002672", UUID.randomUUID().toString());
262 Assert.assertNull(vfModuleCustomization);
266 public void testGetFirstByServiceModelUUIDAndAction() {
267 ServiceRecipe serviceRecipe =
268 client.getFirstByServiceModelUUIDAndAction("4694a55f-58b3-4f17-92a5-796d6f5ffd0d", "createInstance");
269 Assert.assertNotNull(serviceRecipe);
270 Assert.assertNotNull(serviceRecipe.getServiceModelUUID());
271 Assert.assertNotNull(serviceRecipe.getAction());
272 Assert.assertEquals("/mso/async/services/CreateGenericALaCarteServiceInstance",
273 serviceRecipe.getOrchestrationUri());
274 Assert.assertEquals("MSOTADevInfra aLaCarte", serviceRecipe.getDescription());
278 public void testGetFirstByServiceModelUUIDAndActionNotFound() {
279 ServiceRecipe serviceRecipe = client.getFirstByServiceModelUUIDAndAction("5df8b6de-2083-11e7-93ae-92361f002671",
280 UUID.randomUUID().toString());
281 Assert.assertNull(serviceRecipe);
285 public void testGetFirstVnfResourceByModelInvariantUUIDAndModelVersion() {
286 VnfResource vnfResource = client
287 .getFirstVnfResourceByModelInvariantUUIDAndModelVersion("2fff5b20-214b-11e7-93ae-92361f002671", "2.0");
288 Assert.assertNotNull(vnfResource);
289 Assert.assertNotNull(vnfResource.getModelInvariantId());
290 Assert.assertNotNull(vnfResource.getModelVersion());
291 Assert.assertNotNull(vnfResource.getHeatTemplates());
292 Assert.assertNotNull(vnfResource.getVnfResourceCustomizations());
293 Assert.assertEquals("vSAMP10a", vnfResource.getModelName());
297 public void testGetFirstVnfResourceByModelInvariantUUIDAndModelVersionNotFound() {
298 VnfResource vnfResource = client.getFirstVnfResourceByModelInvariantUUIDAndModelVersion(
299 "2fff5b20-214b-11e7-93ae-92361f002671", UUID.randomUUID().toString());
300 Assert.assertNull(vnfResource);
304 public void testGetFirstVnfResourceCustomizationByModelInstanceNameAndVnfResources() {
305 VnfResource vnfr = new VnfResource();
306 vnfr.setModelUUID("ff2ae348-214a-11e7-93ae-92361f002671");
307 VnfResourceCustomization firstVnfResourceCustomizationByModelInstanceNameAndVnfResources =
308 client.getFirstVnfResourceCustomizationByModelInstanceNameAndVnfResources("vSAMP10a 1", vnfr);
309 Assert.assertNotNull(firstVnfResourceCustomizationByModelInstanceNameAndVnfResources);
310 Assert.assertEquals("vSAMP", firstVnfResourceCustomizationByModelInstanceNameAndVnfResources.getNfRole());
311 Assert.assertEquals("vSAMP10a 1",
312 firstVnfResourceCustomizationByModelInstanceNameAndVnfResources.getModelInstanceName());
313 Assert.assertNotNull(firstVnfResourceCustomizationByModelInstanceNameAndVnfResources.getVnfResources());
314 Assert.assertNotNull(
315 firstVnfResourceCustomizationByModelInstanceNameAndVnfResources.getVfModuleCustomizations());
319 public void testGetFirstVnfRecipeByNfRoleAndAction() {
320 VnfRecipe vnfRecipe = client.getFirstVnfRecipeByNfRoleAndAction("GR-API-DEFAULT", "createInstance");
321 Assert.assertNotNull(vnfRecipe);
322 Assert.assertNotNull(vnfRecipe.getNfRole());
323 Assert.assertNotNull(vnfRecipe.getAction());
324 Assert.assertEquals("Gr api recipe to create vnf", vnfRecipe.getDescription());
325 Assert.assertEquals("/mso/async/services/WorkflowActionBB", vnfRecipe.getOrchestrationUri());
329 public void testGetFirstVnfRecipeByNfRoleAndActionNotFound() {
330 VnfRecipe vnfRecipe = client.getFirstVnfRecipeByNfRoleAndAction(UUID.randomUUID().toString(), "createInstance");
331 Assert.assertNull(vnfRecipe);
335 public void testGetFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction() {
336 VnfComponentsRecipe vnfComponentsRecipe =
337 client.getFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction(
338 "20c4431c-246d-11e7-93ae-92361f002671", "volumeGroup", "createInstance");
339 Assert.assertNotNull(vnfComponentsRecipe);
340 Assert.assertNotNull(vnfComponentsRecipe.getAction());
341 Assert.assertNotNull(vnfComponentsRecipe.getVfModuleModelUUID());
342 Assert.assertNotNull(vnfComponentsRecipe.getVnfComponentType());
343 Assert.assertEquals("Gr api recipe to create volume-group", vnfComponentsRecipe.getDescription());
344 Assert.assertEquals("/mso/async/services/WorkflowActionBB", vnfComponentsRecipe.getOrchestrationUri());
350 public void testGetFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndActionNotFound() {
351 VnfComponentsRecipe vnfComponentsRecipe =
352 client.getFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction(
353 UUID.randomUUID().toString(), "volumeGroup", "createInstance");
354 Assert.assertNull(vnfComponentsRecipe);
358 public void testGetFirstVnfComponentsRecipeByVnfComponentTypeAndAction() {
359 VnfComponentsRecipe vnfComponentsRecipe =
360 client.getFirstVnfComponentsRecipeByVnfComponentTypeAndAction("volumeGroup", "createInstance");
361 Assert.assertNotNull(vnfComponentsRecipe);
362 Assert.assertNotNull(vnfComponentsRecipe.getAction());
363 Assert.assertNotNull(vnfComponentsRecipe.getVnfComponentType());
364 Assert.assertEquals("VID_DEFAULT recipe t", vnfComponentsRecipe.getDescription());
365 Assert.assertEquals("/mso/async/services/CreateVfModuleVolumeInfraV1",
366 vnfComponentsRecipe.getOrchestrationUri());
370 public void testGetServiceByModelVersionAndModelInvariantUUID() {
372 client.getServiceByModelVersionAndModelInvariantUUID("2.0", "9647dfc4-2083-11e7-93ae-92361f002671");
373 Assert.assertNotNull(service);
374 Assert.assertNotNull(service.getModelVersion());
375 Assert.assertNotNull(service.getModelInvariantUUID());
376 Assert.assertEquals("MSOTADevInfra_vSAMP10a_Service", service.getModelName());
377 Assert.assertEquals("NA", service.getServiceRole());
381 public void testGetServiceByModelVersionAndModelInvariantUUIDNotFound() {
382 Service service = client.getServiceByModelVersionAndModelInvariantUUID("2.0", UUID.randomUUID().toString());
383 Assert.assertNull(service);
387 public void testGetVfModuleByModelInvariantUUIDAndModelVersion() {
389 client.getVfModuleByModelInvariantUUIDAndModelVersion("78ca26d0-246d-11e7-93ae-92361f002671", "2");
390 Assert.assertNotNull(vfModule);
391 Assert.assertNotNull(vfModule.getModelVersion());
392 Assert.assertNotNull(vfModule.getModelInvariantUUID());
393 Assert.assertEquals("vSAMP10aDEV::base::module-0", vfModule.getModelName());
394 Assert.assertEquals("vSAMP10a DEV Base", vfModule.getDescription());
398 public void testGetVfModuleByModelInvariantUUIDAndModelVersionNotFound() {
399 VfModule vfModule = client.getVfModuleByModelInvariantUUIDAndModelVersion(UUID.randomUUID().toString(), "2");
400 Assert.assertNull(vfModule);
404 public void testGetServiceByModelInvariantUUIDOrderByModelVersionDesc() {
405 List<Service> serviceList =
406 client.getServiceByModelInvariantUUIDOrderByModelVersionDesc("9647dfc4-2083-11e7-93ae-92361f002671");
407 Assert.assertFalse(serviceList.isEmpty());
408 Assert.assertEquals(2, serviceList.size());
409 Service service = serviceList.get(0);
410 Assert.assertEquals("2.0", service.getModelVersion());
414 public void testGetServiceByModelInvariantUUIDOrderByModelVersionDescNotFound() {
415 List<Service> serviceList =
416 client.getServiceByModelInvariantUUIDOrderByModelVersionDesc(UUID.randomUUID().toString());
417 Assert.assertTrue(serviceList.isEmpty());
421 public void testGetVfModuleByModelInvariantUUIDOrderByModelVersionDesc() {
422 List<VfModule> moduleList =
423 client.getVfModuleByModelInvariantUUIDOrderByModelVersionDesc("78ca26d0-246d-11e7-93ae-92361f002671");
424 Assert.assertFalse(moduleList.isEmpty());
425 Assert.assertEquals(2, moduleList.size());
426 VfModule module = moduleList.get(0);
427 Assert.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 Assert.assertNotNull(getCloudSite);
454 Assert.assertNotNull(getCloudSite.getIdentityService());
455 Assert.assertEquals("TESTCLLI", getCloudSite.getClli());
456 Assert.assertEquals("regionId", getCloudSite.getRegionId());
457 Assert.assertEquals("RANDOMID", getCloudSite.getIdentityServiceId());
461 public void testGetHomingInstance() {
462 HomingInstance homingInstance = client.getHomingInstance("5df8b6de-2083-11e7-93ae-92361f232671");
463 Assert.assertNotNull(homingInstance);
464 Assert.assertNotNull(homingInstance.getCloudOwner());
465 Assert.assertNotNull(homingInstance.getCloudRegionId());
466 Assert.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 Assert.assertNotNull(getHomingInstance);
491 Assert.assertNotNull(getHomingInstance.getCloudRegionId());
492 Assert.assertNotNull(getHomingInstance.getCloudOwner());
493 Assert.assertEquals("CloudOwner-1", getHomingInstance.getCloudOwner());
494 Assert.assertEquals("CloudRegionOne", getHomingInstance.getCloudRegionId());
498 public void testGetServiceByModelName() {
499 Service service = client.getServiceByModelName("MSOTADevInfra_Test_Service");
500 Assert.assertNotNull(service);
501 Assert.assertNotNull(service.getModelVersion());
502 Assert.assertNotNull(service.getModelInvariantUUID());
503 Assert.assertEquals("MSOTADevInfra_Test_Service", service.getModelName());
504 Assert.assertEquals("NA", service.getServiceRole());
508 public void testGetServiceByModelNameNotFound() {
509 Service service = client.getServiceByModelName("Not_Found");
510 Assert.assertNull(service);
514 public void testGetServiceByModelUUID() {
515 Service service = client.getServiceByModelUUID("5df8b6de-2083-11e7-93ae-92361f002679");
516 Assert.assertNotNull(service);
517 Assert.assertNotNull(service.getModelVersion());
518 Assert.assertNotNull(service.getModelInvariantUUID());
519 Assert.assertEquals("5df8b6de-2083-11e7-93ae-92361f002679", service.getModelUUID());
520 Assert.assertEquals("NA", service.getServiceRole());
524 public void testGetServiceByModelUUIDNotFound() {
525 Service service = client.getServiceByModelUUID("Not_Found");
526 Assert.assertNull(service);
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 Assert.assertNotNull(northBoundRequest);
539 Assert.assertEquals("createService", northBoundRequest.getAction());
540 Assert.assertEquals("service", northBoundRequest.getRequestScope());
541 Assert.assertEquals(true, northBoundRequest.getIsAlacarte());
542 Assert.assertEquals("my-custom-cloud-owner", northBoundRequest.getCloudOwner());
546 public void testFindServiceRecipeByActionAndServiceModelUUID() {
547 ServiceRecipe serviceRecipe = client.findServiceRecipeByActionAndServiceModelUUID("createInstance",
548 "4694a55f-58b3-4f17-92a5-796d6f5ffd0d");
549 Assert.assertNotNull(serviceRecipe);
550 Assert.assertNotNull(serviceRecipe.getServiceModelUUID());
551 Assert.assertNotNull(serviceRecipe.getAction());
552 Assert.assertEquals("/mso/async/services/CreateGenericALaCarteServiceInstance",
553 serviceRecipe.getOrchestrationUri());
554 Assert.assertEquals("MSOTADevInfra aLaCarte", serviceRecipe.getDescription());
558 public void testFindServiceRecipeByActionAndServiceModelUUIDNotFound() {
559 ServiceRecipe serviceRecipe =
560 client.findServiceRecipeByActionAndServiceModelUUID("not_found", "5df8b6de-2083-11e7-93ae-test");
561 Assert.assertNull(serviceRecipe);
565 public void testFindExternalToInternalServiceByServiceName() {
566 ExternalServiceToInternalService externalServiceToInternalService =
567 client.findExternalToInternalServiceByServiceName("MySpecialServiceName");
568 Assert.assertNotNull(externalServiceToInternalService);
569 Assert.assertNotNull(externalServiceToInternalService.getServiceName());
570 Assert.assertNotNull(externalServiceToInternalService.getServiceModelUUID());
571 Assert.assertEquals("MySpecialServiceName", externalServiceToInternalService.getServiceName());
575 public void testFindExternalToInternalServiceByServiceNameNotFound() {
576 ExternalServiceToInternalService externalServiceToInternalService =
577 client.findExternalToInternalServiceByServiceName("Not_Found");
578 Assert.assertNull(externalServiceToInternalService);
582 public void getPnfResourceByModelUUID_validUuid_expectedOutput() {
583 PnfResource pnfResource = client.getPnfResourceByModelUUID("ff2ae348-214a-11e7-93ae-92361f002680");
584 Assert.assertNotNull(pnfResource);
585 assertEquals("PNFResource modelUUID", "ff2ae348-214a-11e7-93ae-92361f002680", pnfResource.getModelUUID());
586 assertEquals("PNFResource modelInvariantUUID", "2fff5b20-214b-11e7-93ae-92361f002680",
587 pnfResource.getModelInvariantUUID());
588 assertEquals("PNFResource modelVersion", "1.0", pnfResource.getModelVersion());
589 assertEquals("PNFResource orchestration mode", "", pnfResource.getOrchestrationMode());
593 public void getPnfResourceByModelUUID_invalidUuid_NullOutput() {
594 PnfResource pnfResource = client.getPnfResourceByModelUUID(UUID.randomUUID().toString());
595 Assert.assertNull(pnfResource);
599 public void getPnfResourceCustomizationByModelCustomizationUUID_validUuid_expectedOutput() {
600 PnfResourceCustomization pnfResourceCustomization =
601 client.getPnfResourceCustomizationByModelCustomizationUUID("68dc9a92-214c-11e7-93ae-92361f002680");
602 assertEquals("modelInstanceName", "PNF routing", pnfResourceCustomization.getModelInstanceName());
603 assertEquals("blueprintName", "test_configuration_restconf", pnfResourceCustomization.getBlueprintName());
604 assertEquals("blueprintVersion", "1.0.0", pnfResourceCustomization.getBlueprintVersion());
605 assertTrue("skip post instantiation configuration", pnfResourceCustomization.isSkipPostInstConf());
606 PnfResource pnfResource = pnfResourceCustomization.getPnfResources();
607 assertNotNull(pnfResource);
608 assertEquals("PNFResource modelUUID", "ff2ae348-214a-11e7-93ae-92361f002680", pnfResource.getModelUUID());
609 assertEquals("PNFResource modelInvariantUUID", "2fff5b20-214b-11e7-93ae-92361f002680",
610 pnfResource.getModelInvariantUUID());
611 assertEquals("PNFResource modelVersion", "1.0", pnfResource.getModelVersion());
612 assertEquals("PNFResource orchestration mode", "", pnfResource.getOrchestrationMode());
616 public void getPnfResourceCustomizationByModelCustomizationUUID_invalidUuid_nullOutput() {
617 PnfResourceCustomization pnfResourceCustomization =
618 client.getPnfResourceCustomizationByModelCustomizationUUID(UUID.randomUUID().toString());
619 Assert.assertNull(pnfResourceCustomization);
623 public void getPnfResourceCustomizationFromJoinTable_validServiceUuid_expectedOutput() {
624 List<PnfResourceCustomization> pnfResourceCustomizationList =
625 client.getPnfResourceCustomizationByModelUuid("5df8b6de-2083-11e7-93ae-92361f002676");
626 assertEquals(1, pnfResourceCustomizationList.size());
628 PnfResourceCustomization pnfResourceCustomization = pnfResourceCustomizationList.get(0);
629 assertEquals("modelInstanceName", "PNF routing", pnfResourceCustomization.getModelInstanceName());
630 assertEquals("blueprintName", "test_configuration_restconf", pnfResourceCustomization.getBlueprintName());
631 assertEquals("blueprintVersion", "1.0.0", pnfResourceCustomization.getBlueprintVersion());
632 PnfResource pnfResource = pnfResourceCustomization.getPnfResources();
633 assertNotNull(pnfResource);
635 assertEquals("PNFResource modelUUID", "ff2ae348-214a-11e7-93ae-92361f002680", pnfResource.getModelUUID());
636 assertEquals("PNFResource modelInvariantUUID", "2fff5b20-214b-11e7-93ae-92361f002680",
637 pnfResource.getModelInvariantUUID());
638 assertEquals("PNFResource modelVersion", "1.0", pnfResource.getModelVersion());
639 assertEquals("PNFResource orchestration mode", "", pnfResource.getOrchestrationMode());
643 public void getPnfResourceCustomizationFromJoinTable_invalidServiceUuid_nullOutput() {
644 List<PnfResourceCustomization> pnfResourceCustomizationList =
645 client.getPnfResourceCustomizationByModelUuid(UUID.randomUUID().toString());
646 assertEquals(0, pnfResourceCustomizationList.size());
650 public void getWorkflowByArtifactUUID_validUuid_expectedOutput() {
651 Workflow workflow = client.findWorkflowByArtifactUUID("5b0c4322-643d-4c9f-b184-4516049e99b1");
652 assertEquals("artifactName", "testingWorkflow", workflow.getArtifactName());
656 public void getWorkflowByArtifactUUID_invalidUuid_nullOutput() {
657 Workflow workflow = client.findWorkflowByArtifactUUID(UUID.randomUUID().toString());
658 Assert.assertNull(workflow);