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;
28 import java.util.List;
29 import java.util.UUID;
30 import org.junit.Assert;
31 import org.junit.Before;
32 import org.junit.Test;
33 import org.junit.runner.RunWith;
34 import org.onap.so.adapters.catalogdb.CatalogDBApplication;
35 import org.onap.so.adapters.catalogdb.CatalogDbAdapterBaseTest;
36 import org.onap.so.db.catalog.beans.AuthenticationType;
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.test.context.SpringBootTest;
61 import org.springframework.boot.web.server.LocalServerPort;
62 import org.springframework.test.context.ActiveProfiles;
63 import org.springframework.test.context.junit4.SpringRunner;
65 public class CatalogDbClientTest extends CatalogDbAdapterBaseTest {
67 public static final String MTN13 = "mtn13";
72 @Value("${mso.db.auth}")
73 private String msoAdaptersAuth;
76 CatalogDbClientPortChanger client;
79 public void initialize() {
80 client.wiremockPort = String.valueOf(port);
84 public void testGetRainyDayHandlerStatusByFlowNameAndServiceTypeAndVnfTypeAndErrorCodeAndWorkStep() {
85 RainyDayHandlerStatus rainyDayHandlerStatus = client
86 .getRainyDayHandlerStatusByFlowNameAndServiceTypeAndVnfTypeAndErrorCodeAndWorkStep(
87 "AssignServiceInstanceBB", "*", "*", "*", "*");
88 Assert.assertEquals("Rollback", rainyDayHandlerStatus.getPolicy());
92 public void testGetRainyDayHandlerStatusByFlowNameAndServiceTypeAndVnfTypeAndErrorCodeAndWorkStepRecordNotFound() {
93 RainyDayHandlerStatus rainyDayHandlerStatus = client
94 .getRainyDayHandlerStatusByFlowNameAndServiceTypeAndVnfTypeAndErrorCodeAndWorkStep(
95 UUID.randomUUID().toString(), "*", "*", "*", "*");
96 Assert.assertNull(rainyDayHandlerStatus);
100 public void testGetCloudSiteHappyPath() throws Exception {
101 CloudSite cloudSite = client.getCloudSite(MTN13);
102 Assert.assertNotNull(cloudSite);
103 Assert.assertNotNull(cloudSite.getIdentityService());
104 Assert.assertEquals("MDT13", cloudSite.getClli());
105 Assert.assertEquals("mtn13", cloudSite.getRegionId());
106 Assert.assertEquals("MTN13", cloudSite.getIdentityServiceId());
110 public void testGetCloudSiteNotFound() throws Exception {
111 CloudSite cloudSite = client.getCloudSite(UUID.randomUUID().toString());
112 Assert.assertNull(cloudSite);
116 public void testGetCloudifyManagerHappyPath() throws Exception {
117 CloudifyManager cloudifyManager = client.getCloudifyManager("mtn13");
118 Assert.assertNotNull(cloudifyManager);
119 Assert.assertEquals("http://localhost:28090/v2.0", cloudifyManager.getCloudifyUrl());
124 public void testGetCloudifyManagerNotFound() throws Exception {
125 CloudifyManager cloudifyManager = client.getCloudifyManager(UUID.randomUUID().toString());
126 Assert.assertNull(cloudifyManager);
131 public void testGetCloudSiteByClliAndAicVersionHappyPath() throws Exception {
132 CloudSite cloudSite = client.getCloudSiteByClliAndAicVersion("MDT13", "2.5");
133 Assert.assertNotNull(cloudSite);
137 public void testGetCloudSiteByClliAndAicVersionNotFound() throws Exception {
138 CloudSite cloudSite = client.getCloudSiteByClliAndAicVersion("MDT13", "232496239746328");
139 Assert.assertNull(cloudSite);
143 public void testGetServiceByID() throws Exception {
144 Service serviceByID = client.getServiceByID("5df8b6de-2083-11e7-93ae-92361f002671");
145 Assert.assertNotNull(serviceByID);
146 Assert.assertEquals("MSOTADevInfra_vSAMP10a_Service", serviceByID.getModelName());
147 Assert.assertEquals("NA", serviceByID.getServiceType());
148 Assert.assertEquals("NA", serviceByID.getServiceRole());
152 public void testGetServiceByIDNotFound() throws Exception {
153 Service serviceByID = client.getServiceByID(UUID.randomUUID().toString());
154 Assert.assertNull(serviceByID);
158 public void testGetVfModuleByModelUUID() throws Exception {
159 VfModule vfModule = client.getVfModuleByModelUUID("20c4431c-246d-11e7-93ae-92361f002671");
160 Assert.assertNotNull(vfModule);
161 Assert.assertNotNull(vfModule.getVfModuleCustomization());
162 Assert.assertEquals("78ca26d0-246d-11e7-93ae-92361f002671", vfModule.getModelInvariantUUID());
163 Assert.assertEquals("vSAMP10aDEV::base::module-0", vfModule.getModelName());
167 public void testGetVfModuleByModelUUIDNotFound() throws Exception {
168 VfModule vfModule = client.getVfModuleByModelUUID(UUID.randomUUID().toString());
169 Assert.assertNull(vfModule);
173 public void testGetVnfResourceByModelUUID() throws Exception {
174 VnfResource vnfResource = client.getVnfResourceByModelUUID("ff2ae348-214a-11e7-93ae-92361f002671");
175 Assert.assertNotNull(vnfResource);
176 Assert.assertEquals("vSAMP10a", vnfResource.getModelName());
180 public void testGetVnfResourceByModelUUIDNotFound() throws Exception {
181 VnfResource vnfResource = client.getVnfResourceByModelUUID(UUID.randomUUID().toString());
182 Assert.assertNull(vnfResource);
186 public void testGetVnfResourceCustomizationByModelCustomizationUUID() {
187 VnfResourceCustomization vnfResourceCustomization = client
188 .getVnfResourceCustomizationByModelCustomizationUUID("68dc9a92-214c-11e7-93ae-92361f002671");
189 Assert.assertNotNull(vnfResourceCustomization);
190 Assert.assertEquals("vSAMP", vnfResourceCustomization.getNfRole());
191 Assert.assertNotNull(vnfResourceCustomization.getModelCustomizationUUID());
192 Assert.assertNotNull(vnfResourceCustomization.getVnfResources());
193 Assert.assertNotNull(vnfResourceCustomization.getVfModuleCustomizations());
194 Assert.assertEquals("vSAMP10a", vnfResourceCustomization.getVnfResources().getModelName());
195 assertTrue("skip post instantiation configuration", vnfResourceCustomization.isSkipPostInstConf());
199 public void testGetVnfResourceCustomizationByModelCustomizationUUINotFound() {
200 VnfResourceCustomization vnfResourceCustomization = client
201 .getVnfResourceCustomizationByModelCustomizationUUID(UUID.randomUUID().toString());
202 Assert.assertNull(vnfResourceCustomization);
206 public void testGetInstanceGroupByModelUUID() {
207 InstanceGroup instanceGroup = client.getInstanceGroupByModelUUID("0c8692ef-b9c0-435d-a738-edf31e71f38b");
208 Assert.assertNotNull(instanceGroup);
209 Assert.assertEquals("network_collection_resource_1806..NetworkCollection..0", instanceGroup.getModelName());
210 Assert.assertEquals("org.openecomp.resource.cr.NetworkCollectionResource1806",
211 instanceGroup.getToscaNodeType().toString());
215 public void testGetVfModuleCustomizationByModelCuztomizationUUID() {
216 VfModuleCustomization vfModuleCustomization = client
217 .getVfModuleCustomizationByModelCuztomizationUUID("cb82ffd8-252a-11e7-93ae-92361f002671");
218 Assert.assertNotNull(vfModuleCustomization);
219 Assert.assertNotNull(vfModuleCustomization.getModelCustomizationUUID());
220 Assert.assertEquals("base", vfModuleCustomization.getLabel());
224 public void testGetVfModuleCustomizationByModelCuztomizationUUIDNotFound() {
225 VfModuleCustomization vfModuleCustomization = client
226 .getVfModuleCustomizationByModelCuztomizationUUID(UUID.randomUUID().toString());
227 Assert.assertNull(vfModuleCustomization);
231 public void testGetNetworkResourceCustomizationByModelCustomizationUUID() {
232 NetworkResourceCustomization networkResourceCustomization = client
233 .getNetworkResourceCustomizationByModelCustomizationUUID("3bdbb104-476c-483e-9f8b-c095b3d308ac");
234 Assert.assertNotNull(networkResourceCustomization);
235 Assert.assertNotNull(networkResourceCustomization.getModelCustomizationUUID());
236 Assert.assertEquals("CONTRAIL30_GNDIRECT 9", networkResourceCustomization.getModelInstanceName());
237 Assert.assertNotNull(networkResourceCustomization.getNetworkResource());
241 public void testGetNetworkResourceCustomizationByModelCustomizationUUIDNotFound() {
242 NetworkResourceCustomization networkResourceCustomization = client
243 .getNetworkResourceCustomizationByModelCustomizationUUID(UUID.randomUUID().toString());
244 Assert.assertNull(networkResourceCustomization);
248 public void testGgetVfModuleCustomizationByModelCustomizationUUIDAndVfModuleModelUUID() {
249 VfModuleCustomization vfModuleCustomization = client
250 .getVfModuleCustomizationByModelCustomizationUUIDAndVfModuleModelUUID(
251 "cb82ffd8-252a-11e7-93ae-92361f002672", "20c4431c-246d-11e7-93ae-92361f002672");
252 Assert.assertNotNull(vfModuleCustomization);
253 Assert.assertNotNull(vfModuleCustomization.getModelCustomizationUUID());
254 Assert.assertNotNull(vfModuleCustomization.getVfModule());
255 Assert.assertEquals("base", vfModuleCustomization.getLabel());
259 public void testGgetVfModuleCustomizationByModelCustomizationUUIDAndVfModuleModelUUIDNotFound() {
260 VfModuleCustomization vfModuleCustomization = client
261 .getVfModuleCustomizationByModelCustomizationUUIDAndVfModuleModelUUID(
262 "cb82ffd8-252a-11e7-93ae-92361f002672", UUID.randomUUID().toString());
263 Assert.assertNull(vfModuleCustomization);
267 public void testGetFirstByServiceModelUUIDAndAction() {
268 ServiceRecipe serviceRecipe = client
269 .getFirstByServiceModelUUIDAndAction("4694a55f-58b3-4f17-92a5-796d6f5ffd0d", "createInstance");
270 Assert.assertNotNull(serviceRecipe);
271 Assert.assertNotNull(serviceRecipe.getServiceModelUUID());
272 Assert.assertNotNull(serviceRecipe.getAction());
273 Assert.assertEquals("/mso/async/services/CreateGenericALaCarteServiceInstance",
274 serviceRecipe.getOrchestrationUri());
275 Assert.assertEquals("MSOTADevInfra aLaCarte", serviceRecipe.getDescription());
279 public void testGetFirstByServiceModelUUIDAndActionNotFound() {
280 ServiceRecipe serviceRecipe = client
281 .getFirstByServiceModelUUIDAndAction("5df8b6de-2083-11e7-93ae-92361f002671", UUID.randomUUID().toString());
282 Assert.assertNull(serviceRecipe);
286 public void testGetFirstVnfResourceByModelInvariantUUIDAndModelVersion() {
287 VnfResource vnfResource = client
288 .getFirstVnfResourceByModelInvariantUUIDAndModelVersion("2fff5b20-214b-11e7-93ae-92361f002671", "2.0");
289 Assert.assertNotNull(vnfResource);
290 Assert.assertNotNull(vnfResource.getModelInvariantId());
291 Assert.assertNotNull(vnfResource.getModelVersion());
292 Assert.assertNotNull(vnfResource.getHeatTemplates());
293 Assert.assertNotNull(vnfResource.getVnfResourceCustomizations());
294 Assert.assertEquals("vSAMP10a", vnfResource.getModelName());
298 public void testGetFirstVnfResourceByModelInvariantUUIDAndModelVersionNotFound() {
299 VnfResource vnfResource = client
300 .getFirstVnfResourceByModelInvariantUUIDAndModelVersion("2fff5b20-214b-11e7-93ae-92361f002671",
301 UUID.randomUUID().toString());
302 Assert.assertNull(vnfResource);
306 public void testGetFirstVnfResourceCustomizationByModelInstanceNameAndVnfResources() {
307 VnfResource vnfr = new VnfResource();
308 vnfr.setModelUUID("ff2ae348-214a-11e7-93ae-92361f002671");
309 VnfResourceCustomization firstVnfResourceCustomizationByModelInstanceNameAndVnfResources = client
310 .getFirstVnfResourceCustomizationByModelInstanceNameAndVnfResources("vSAMP10a 1", vnfr);
311 Assert.assertNotNull(firstVnfResourceCustomizationByModelInstanceNameAndVnfResources);
312 Assert.assertEquals("vSAMP", firstVnfResourceCustomizationByModelInstanceNameAndVnfResources.getNfRole());
313 Assert.assertEquals("vSAMP10a 1",
314 firstVnfResourceCustomizationByModelInstanceNameAndVnfResources.getModelInstanceName());
315 Assert.assertNotNull(firstVnfResourceCustomizationByModelInstanceNameAndVnfResources.getVnfResources());
317 .assertNotNull(firstVnfResourceCustomizationByModelInstanceNameAndVnfResources.getVfModuleCustomizations());
321 public void testGetFirstVnfRecipeByNfRoleAndAction() {
322 VnfRecipe vnfRecipe = client.getFirstVnfRecipeByNfRoleAndAction("GR-API-DEFAULT", "createInstance");
323 Assert.assertNotNull(vnfRecipe);
324 Assert.assertNotNull(vnfRecipe.getNfRole());
325 Assert.assertNotNull(vnfRecipe.getAction());
326 Assert.assertEquals("Gr api recipe to create vnf", vnfRecipe.getDescription());
327 Assert.assertEquals("/mso/async/services/WorkflowActionBB", vnfRecipe.getOrchestrationUri());
331 public void testGetFirstVnfRecipeByNfRoleAndActionNotFound() {
332 VnfRecipe vnfRecipe = client.getFirstVnfRecipeByNfRoleAndAction(UUID.randomUUID().toString(), "createInstance");
333 Assert.assertNull(vnfRecipe);
337 public void testGetFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction() {
338 VnfComponentsRecipe vnfComponentsRecipe = client
339 .getFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction(
340 "20c4431c-246d-11e7-93ae-92361f002671", "volumeGroup", "createInstance");
341 Assert.assertNotNull(vnfComponentsRecipe);
342 Assert.assertNotNull(vnfComponentsRecipe.getAction());
343 Assert.assertNotNull(vnfComponentsRecipe.getVfModuleModelUUID());
344 Assert.assertNotNull(vnfComponentsRecipe.getVnfComponentType());
345 Assert.assertEquals("Gr api recipe to create volume-group", vnfComponentsRecipe.getDescription());
346 Assert.assertEquals("/mso/async/services/WorkflowActionBB", vnfComponentsRecipe.getOrchestrationUri());
352 public void testGetFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndActionNotFound() {
353 VnfComponentsRecipe vnfComponentsRecipe = client
354 .getFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction(UUID.randomUUID().toString(),
355 "volumeGroup", "createInstance");
356 Assert.assertNull(vnfComponentsRecipe);
360 public void testGetFirstVnfComponentsRecipeByVnfComponentTypeAndAction() {
361 VnfComponentsRecipe vnfComponentsRecipe = client
362 .getFirstVnfComponentsRecipeByVnfComponentTypeAndAction("volumeGroup", "createInstance");
363 Assert.assertNotNull(vnfComponentsRecipe);
364 Assert.assertNotNull(vnfComponentsRecipe.getAction());
365 Assert.assertNotNull(vnfComponentsRecipe.getVnfComponentType());
366 Assert.assertEquals("VID_DEFAULT recipe t", vnfComponentsRecipe.getDescription());
368 .assertEquals("/mso/async/services/CreateVfModuleVolumeInfraV1", vnfComponentsRecipe.getOrchestrationUri());
372 public void testGetServiceByModelVersionAndModelInvariantUUID() {
373 Service service = client
374 .getServiceByModelVersionAndModelInvariantUUID("2.0", "9647dfc4-2083-11e7-93ae-92361f002671");
375 Assert.assertNotNull(service);
376 Assert.assertNotNull(service.getModelVersion());
377 Assert.assertNotNull(service.getModelInvariantUUID());
378 Assert.assertEquals("MSOTADevInfra_vSAMP10a_Service", service.getModelName());
379 Assert.assertEquals("NA", service.getServiceRole());
383 public void testGetServiceByModelVersionAndModelInvariantUUIDNotFound() {
384 Service service = client.getServiceByModelVersionAndModelInvariantUUID("2.0", UUID.randomUUID().toString());
385 Assert.assertNull(service);
389 public void testGetVfModuleByModelInvariantUUIDAndModelVersion() {
390 VfModule vfModule = client
391 .getVfModuleByModelInvariantUUIDAndModelVersion("78ca26d0-246d-11e7-93ae-92361f002671", "2");
392 Assert.assertNotNull(vfModule);
393 Assert.assertNotNull(vfModule.getModelVersion());
394 Assert.assertNotNull(vfModule.getModelInvariantUUID());
395 Assert.assertEquals("vSAMP10aDEV::base::module-0", vfModule.getModelName());
396 Assert.assertEquals("vSAMP10a DEV Base", vfModule.getDescription());
400 public void testGetVfModuleByModelInvariantUUIDAndModelVersionNotFound() {
401 VfModule vfModule = client.getVfModuleByModelInvariantUUIDAndModelVersion(UUID.randomUUID().toString(), "2");
402 Assert.assertNull(vfModule);
406 public void testGetServiceByModelInvariantUUIDOrderByModelVersionDesc() {
407 List<Service> serviceList = client
408 .getServiceByModelInvariantUUIDOrderByModelVersionDesc("9647dfc4-2083-11e7-93ae-92361f002671");
409 Assert.assertFalse(serviceList.isEmpty());
410 Assert.assertEquals(2, serviceList.size());
411 Service service = serviceList.get(0);
412 Assert.assertEquals("2.0", service.getModelVersion());
416 public void testGetServiceByModelInvariantUUIDOrderByModelVersionDescNotFound() {
417 List<Service> serviceList = client
418 .getServiceByModelInvariantUUIDOrderByModelVersionDesc(UUID.randomUUID().toString());
419 Assert.assertTrue(serviceList.isEmpty());
423 public void testGetVfModuleByModelInvariantUUIDOrderByModelVersionDesc() {
424 List<VfModule> moduleList = client
425 .getVfModuleByModelInvariantUUIDOrderByModelVersionDesc("78ca26d0-246d-11e7-93ae-92361f002671");
426 Assert.assertFalse(moduleList.isEmpty());
427 Assert.assertEquals(2, moduleList.size());
428 VfModule module = moduleList.get(0);
429 Assert.assertEquals("vSAMP10a DEV Base", module.getDescription());
433 public void testPostCloudSite() {
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 Assert.assertNotNull(getCloudSite);
456 Assert.assertNotNull(getCloudSite.getIdentityService());
457 Assert.assertEquals("TESTCLLI", getCloudSite.getClli());
458 Assert.assertEquals("regionId", getCloudSite.getRegionId());
459 Assert.assertEquals("RANDOMID", getCloudSite.getIdentityServiceId());
463 public void testGetHomingInstance() {
464 HomingInstance homingInstance = client.getHomingInstance("5df8b6de-2083-11e7-93ae-92361f232671");
465 Assert.assertNotNull(homingInstance);
466 Assert.assertNotNull(homingInstance.getCloudOwner());
467 Assert.assertNotNull(homingInstance.getCloudRegionId());
468 Assert.assertNotNull(homingInstance.getOofDirectives());
472 public void testPostHomingInstance() {
473 CatalogDbClientPortChanger localClient = new CatalogDbClientPortChanger(
474 "http://localhost:" + client.wiremockPort, msoAdaptersAuth, client.wiremockPort);
475 HomingInstance homingInstance = new HomingInstance();
476 homingInstance.setServiceInstanceId("5df8d6be-2083-11e7-93ae-92361f232671");
477 homingInstance.setCloudOwner("CloudOwner-1");
478 homingInstance.setCloudRegionId("CloudRegionOne");
479 homingInstance.setOofDirectives("{\n" +
480 "\"directives\": [\n" +
482 "\"directives\": [\n" +
484 "\"attributes\": [\n" +
486 "\"attribute_value\": \"onap.hpa.flavor31\",\n" +
487 "\"attribute_name\": \"firewall_flavor_name\"\n" +
490 "\"type\": \"flavor_directives\"\n" +
493 "\"type\": \"vnfc\",\n" +
494 "\"id\": \"vfw\"\n" +
497 "\"directives\": [\n" +
499 "\"attributes\": [\n" +
501 "\"attribute_value\": \"onap.hpa.flavor32\",\n" +
502 "\"attribute_name\": \"packetgen_flavor_name\"\n" +
505 "\"type\": \"flavor_directives\"\n" +
508 "\"type\": \"vnfc\",\n" +
509 "\"id\": \"vgenerator\"\n" +
512 "\"directives\": [\n" +
514 "\"attributes\": [\n" +
516 "\"attribute_value\": \"onap.hpa.flavor31\",\n" +
517 "\"attribute_name\": \"sink_flavor_name\"\n" +
520 "\"type\": \"flavor_directives\"\n" +
523 "\"type\": \"vnfc\",\n" +
524 "\"id\": \"vsink\"\n" +
528 localClient.postHomingInstance(homingInstance);
529 HomingInstance getHomingInstance = this.client.getHomingInstance("5df8d6be-2083-11e7-93ae-92361f232671");
530 Assert.assertNotNull(getHomingInstance);
531 Assert.assertNotNull(getHomingInstance.getCloudRegionId());
532 Assert.assertNotNull(getHomingInstance.getCloudOwner());
533 Assert.assertEquals("CloudOwner-1", getHomingInstance.getCloudOwner());
534 Assert.assertEquals("CloudRegionOne", getHomingInstance.getCloudRegionId());
538 public void testGetServiceByModelName() {
539 Service service = client.getServiceByModelName("MSOTADevInfra_Test_Service");
540 Assert.assertNotNull(service);
541 Assert.assertNotNull(service.getModelVersion());
542 Assert.assertNotNull(service.getModelInvariantUUID());
543 Assert.assertEquals("MSOTADevInfra_Test_Service", service.getModelName());
544 Assert.assertEquals("NA", service.getServiceRole());
548 public void testGetServiceByModelNameNotFound() {
549 Service service = client.getServiceByModelName("Not_Found");
550 Assert.assertNull(service);
554 public void testGetServiceByModelUUID() {
555 Service service = client.getServiceByModelUUID("5df8b6de-2083-11e7-93ae-92361f002679");
556 Assert.assertNotNull(service);
557 Assert.assertNotNull(service.getModelVersion());
558 Assert.assertNotNull(service.getModelInvariantUUID());
559 Assert.assertEquals("5df8b6de-2083-11e7-93ae-92361f002679", service.getModelUUID());
560 Assert.assertEquals("NA", service.getServiceRole());
564 public void testGetServiceByModelUUIDNotFound() {
565 Service service = client.getServiceByModelUUID("Not_Found");
566 Assert.assertNull(service);
570 public void testGetNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner() {
571 NorthBoundRequest northBoundRequest = new NorthBoundRequest();
572 northBoundRequest.setAction("createService");
573 northBoundRequest.setRequestScope("service");
574 northBoundRequest.setIsAlacarte(true);
575 northBoundRequest.setCloudOwner("my-custom-cloud-owner");
576 client.getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner("createService", "service", true,
577 "my-custom-cloud-owner");
578 Assert.assertNotNull(northBoundRequest);
579 Assert.assertEquals("createService", northBoundRequest.getAction());
580 Assert.assertEquals("service", northBoundRequest.getRequestScope());
581 Assert.assertEquals(true, northBoundRequest.getIsAlacarte());
582 Assert.assertEquals("my-custom-cloud-owner", northBoundRequest.getCloudOwner());
586 public void testFindServiceRecipeByActionAndServiceModelUUID() {
587 ServiceRecipe serviceRecipe = client
588 .findServiceRecipeByActionAndServiceModelUUID("createInstance", "4694a55f-58b3-4f17-92a5-796d6f5ffd0d");
589 Assert.assertNotNull(serviceRecipe);
590 Assert.assertNotNull(serviceRecipe.getServiceModelUUID());
591 Assert.assertNotNull(serviceRecipe.getAction());
592 Assert.assertEquals("/mso/async/services/CreateGenericALaCarteServiceInstance",
593 serviceRecipe.getOrchestrationUri());
594 Assert.assertEquals("MSOTADevInfra aLaCarte", serviceRecipe.getDescription());
598 public void testFindServiceRecipeByActionAndServiceModelUUIDNotFound() {
599 ServiceRecipe serviceRecipe = client
600 .findServiceRecipeByActionAndServiceModelUUID("not_found", "5df8b6de-2083-11e7-93ae-test");
601 Assert.assertNull(serviceRecipe);
605 public void testFindExternalToInternalServiceByServiceName() {
606 ExternalServiceToInternalService externalServiceToInternalService = client
607 .findExternalToInternalServiceByServiceName("MySpecialServiceName");
608 Assert.assertNotNull(externalServiceToInternalService);
609 Assert.assertNotNull(externalServiceToInternalService.getServiceName());
610 Assert.assertNotNull(externalServiceToInternalService.getServiceModelUUID());
611 Assert.assertEquals("MySpecialServiceName", externalServiceToInternalService.getServiceName());
615 public void testFindExternalToInternalServiceByServiceNameNotFound() {
616 ExternalServiceToInternalService externalServiceToInternalService = client
617 .findExternalToInternalServiceByServiceName("Not_Found");
618 Assert.assertNull(externalServiceToInternalService);
622 public void getPnfResourceByModelUUID_validUuid_expectedOutput() {
623 PnfResource pnfResource = client.getPnfResourceByModelUUID("ff2ae348-214a-11e7-93ae-92361f002680");
624 Assert.assertNotNull(pnfResource);
625 assertEquals("PNFResource modelUUID", "ff2ae348-214a-11e7-93ae-92361f002680", pnfResource.getModelUUID());
626 assertEquals("PNFResource modelInvariantUUID", "2fff5b20-214b-11e7-93ae-92361f002680",
627 pnfResource.getModelInvariantUUID());
628 assertEquals("PNFResource modelVersion", "1.0", pnfResource.getModelVersion());
629 assertEquals("PNFResource orchestration mode", "", pnfResource.getOrchestrationMode());
633 public void getPnfResourceByModelUUID_invalidUuid_NullOutput() {
634 PnfResource pnfResource = client.getPnfResourceByModelUUID(UUID.randomUUID().toString());
635 Assert.assertNull(pnfResource);
639 public void getPnfResourceCustomizationByModelCustomizationUUID_validUuid_expectedOutput() {
640 PnfResourceCustomization pnfResourceCustomization = client
641 .getPnfResourceCustomizationByModelCustomizationUUID("68dc9a92-214c-11e7-93ae-92361f002680");
642 assertEquals("modelInstanceName", "PNF routing", pnfResourceCustomization.getModelInstanceName());
643 assertEquals("blueprintName", "test_configuration_restconf", pnfResourceCustomization.getBlueprintName());
644 assertEquals("blueprintVersion", "1.0.0", pnfResourceCustomization.getBlueprintVersion());
645 assertTrue("skip post instantiation configuration", pnfResourceCustomization.isSkipPostInstConf());
646 PnfResource pnfResource = pnfResourceCustomization.getPnfResources();
647 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 getPnfResourceCustomizationByModelCustomizationUUID_invalidUuid_nullOutput() {
657 PnfResourceCustomization pnfResourceCustomization = client
658 .getPnfResourceCustomizationByModelCustomizationUUID(UUID.randomUUID().toString());
659 Assert.assertNull(pnfResourceCustomization);
663 public void getPnfResourceCustomizationFromJoinTable_validServiceUuid_expectedOutput() {
664 List<PnfResourceCustomization> pnfResourceCustomizationList = client
665 .getPnfResourceCustomizationByModelUuid("5df8b6de-2083-11e7-93ae-92361f002676");
666 assertEquals(1, pnfResourceCustomizationList.size());
668 PnfResourceCustomization pnfResourceCustomization= pnfResourceCustomizationList.get(0);
669 assertEquals("modelInstanceName", "PNF routing", pnfResourceCustomization.getModelInstanceName());
670 assertEquals("blueprintName", "test_configuration_restconf", pnfResourceCustomization.getBlueprintName());
671 assertEquals("blueprintVersion", "1.0.0", pnfResourceCustomization.getBlueprintVersion());
672 PnfResource pnfResource = pnfResourceCustomization.getPnfResources();
673 assertNotNull(pnfResource);
675 assertEquals("PNFResource modelUUID", "ff2ae348-214a-11e7-93ae-92361f002680", pnfResource.getModelUUID());
676 assertEquals("PNFResource modelInvariantUUID", "2fff5b20-214b-11e7-93ae-92361f002680",
677 pnfResource.getModelInvariantUUID());
678 assertEquals("PNFResource modelVersion", "1.0", pnfResource.getModelVersion());
679 assertEquals("PNFResource orchestration mode", "", pnfResource.getOrchestrationMode());
683 public void getPnfResourceCustomizationFromJoinTable_invalidServiceUuid_nullOutput() {
684 List<PnfResourceCustomization> pnfResourceCustomizationList = client
685 .getPnfResourceCustomizationByModelUuid(UUID.randomUUID().toString());
686 assertEquals(0, pnfResourceCustomizationList.size());
690 public void getWorkflowByArtifactUUID_validUuid_expectedOutput() {
691 Workflow workflow = client
692 .findWorkflowByArtifactUUID("5b0c4322-643d-4c9f-b184-4516049e99b1");
693 assertEquals("artifactName", "testingWorkflow", workflow.getArtifactName());
697 public void getWorkflowByArtifactUUID_invalidUuid_nullOutput() {
698 Workflow workflow = client
699 .findWorkflowByArtifactUUID(UUID.randomUUID().toString());
700 Assert.assertNull(workflow);