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.assertEquals("vSAMP10a", vnfResource.getModelName());
296 public void testGetFirstVnfResourceByModelInvariantUUIDAndModelVersionNotFound() {
297 VnfResource vnfResource = client.getFirstVnfResourceByModelInvariantUUIDAndModelVersion(
298 "2fff5b20-214b-11e7-93ae-92361f002671", UUID.randomUUID().toString());
299 Assert.assertNull(vnfResource);
303 public void testGetFirstVnfResourceCustomizationByModelInstanceNameAndVnfResources() {
304 VnfResource vnfr = new VnfResource();
305 vnfr.setModelUUID("ff2ae348-214a-11e7-93ae-92361f002671");
306 VnfResourceCustomization firstVnfResourceCustomizationByModelInstanceNameAndVnfResources =
307 client.getFirstVnfResourceCustomizationByModelInstanceNameAndVnfResources("vSAMP10a 1", vnfr);
308 Assert.assertNotNull(firstVnfResourceCustomizationByModelInstanceNameAndVnfResources);
309 Assert.assertEquals("vSAMP", firstVnfResourceCustomizationByModelInstanceNameAndVnfResources.getNfRole());
310 Assert.assertEquals("vSAMP10a 1",
311 firstVnfResourceCustomizationByModelInstanceNameAndVnfResources.getModelInstanceName());
312 Assert.assertNotNull(firstVnfResourceCustomizationByModelInstanceNameAndVnfResources.getVnfResources());
313 Assert.assertNotNull(
314 firstVnfResourceCustomizationByModelInstanceNameAndVnfResources.getVfModuleCustomizations());
318 public void testGetFirstVnfRecipeByNfRoleAndAction() {
319 VnfRecipe vnfRecipe = client.getFirstVnfRecipeByNfRoleAndAction("GR-API-DEFAULT", "createInstance");
320 Assert.assertNotNull(vnfRecipe);
321 Assert.assertNotNull(vnfRecipe.getNfRole());
322 Assert.assertNotNull(vnfRecipe.getAction());
323 Assert.assertEquals("Gr api recipe to create vnf", vnfRecipe.getDescription());
324 Assert.assertEquals("/mso/async/services/WorkflowActionBB", vnfRecipe.getOrchestrationUri());
328 public void testGetFirstVnfRecipeByNfRoleAndActionNotFound() {
329 VnfRecipe vnfRecipe = client.getFirstVnfRecipeByNfRoleAndAction(UUID.randomUUID().toString(), "createInstance");
330 Assert.assertNull(vnfRecipe);
334 public void testGetFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction() {
335 VnfComponentsRecipe vnfComponentsRecipe =
336 client.getFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction(
337 "20c4431c-246d-11e7-93ae-92361f002671", "volumeGroup", "createInstance");
338 Assert.assertNotNull(vnfComponentsRecipe);
339 Assert.assertNotNull(vnfComponentsRecipe.getAction());
340 Assert.assertNotNull(vnfComponentsRecipe.getVfModuleModelUUID());
341 Assert.assertNotNull(vnfComponentsRecipe.getVnfComponentType());
342 Assert.assertEquals("Gr api recipe to create volume-group", vnfComponentsRecipe.getDescription());
343 Assert.assertEquals("/mso/async/services/WorkflowActionBB", vnfComponentsRecipe.getOrchestrationUri());
349 public void testGetFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndActionNotFound() {
350 VnfComponentsRecipe vnfComponentsRecipe =
351 client.getFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction(
352 UUID.randomUUID().toString(), "volumeGroup", "createInstance");
353 Assert.assertNull(vnfComponentsRecipe);
357 public void testGetFirstVnfComponentsRecipeByVnfComponentTypeAndAction() {
358 VnfComponentsRecipe vnfComponentsRecipe =
359 client.getFirstVnfComponentsRecipeByVnfComponentTypeAndAction("volumeGroup", "createInstance");
360 Assert.assertNotNull(vnfComponentsRecipe);
361 Assert.assertNotNull(vnfComponentsRecipe.getAction());
362 Assert.assertNotNull(vnfComponentsRecipe.getVnfComponentType());
363 Assert.assertEquals("VID_DEFAULT recipe t", vnfComponentsRecipe.getDescription());
364 Assert.assertEquals("/mso/async/services/CreateVfModuleVolumeInfraV1",
365 vnfComponentsRecipe.getOrchestrationUri());
369 public void testGetServiceByModelVersionAndModelInvariantUUID() {
371 client.getServiceByModelVersionAndModelInvariantUUID("2.0", "9647dfc4-2083-11e7-93ae-92361f002671");
372 Assert.assertNotNull(service);
373 Assert.assertNotNull(service.getModelVersion());
374 Assert.assertNotNull(service.getModelInvariantUUID());
375 Assert.assertEquals("MSOTADevInfra_vSAMP10a_Service", service.getModelName());
376 Assert.assertEquals("NA", service.getServiceRole());
380 public void testGetServiceByModelVersionAndModelInvariantUUIDNotFound() {
381 Service service = client.getServiceByModelVersionAndModelInvariantUUID("2.0", UUID.randomUUID().toString());
382 Assert.assertNull(service);
386 public void testGetVfModuleByModelInvariantUUIDAndModelVersion() {
388 client.getVfModuleByModelInvariantUUIDAndModelVersion("78ca26d0-246d-11e7-93ae-92361f002671", "2");
389 Assert.assertNotNull(vfModule);
390 Assert.assertNotNull(vfModule.getModelVersion());
391 Assert.assertNotNull(vfModule.getModelInvariantUUID());
392 Assert.assertEquals("vSAMP10aDEV::base::module-0", vfModule.getModelName());
393 Assert.assertEquals("vSAMP10a DEV Base", vfModule.getDescription());
397 public void testGetVfModuleByModelInvariantUUIDAndModelVersionNotFound() {
398 VfModule vfModule = client.getVfModuleByModelInvariantUUIDAndModelVersion(UUID.randomUUID().toString(), "2");
399 Assert.assertNull(vfModule);
403 public void testGetServiceByModelInvariantUUIDOrderByModelVersionDesc() {
404 List<Service> serviceList =
405 client.getServiceByModelInvariantUUIDOrderByModelVersionDesc("9647dfc4-2083-11e7-93ae-92361f002671");
406 Assert.assertFalse(serviceList.isEmpty());
407 Assert.assertEquals(2, serviceList.size());
408 Service service = serviceList.get(0);
409 Assert.assertEquals("2.0", service.getModelVersion());
413 public void testGetServiceByModelInvariantUUIDOrderByModelVersionDescNotFound() {
414 List<Service> serviceList =
415 client.getServiceByModelInvariantUUIDOrderByModelVersionDesc(UUID.randomUUID().toString());
416 Assert.assertTrue(serviceList.isEmpty());
420 public void testGetVfModuleByModelInvariantUUIDOrderByModelVersionDesc() {
421 List<VfModule> moduleList =
422 client.getVfModuleByModelInvariantUUIDOrderByModelVersionDesc("78ca26d0-246d-11e7-93ae-92361f002671");
423 Assert.assertFalse(moduleList.isEmpty());
424 Assert.assertEquals(2, moduleList.size());
425 VfModule module = moduleList.get(0);
426 Assert.assertEquals("vSAMP10a DEV Base", module.getDescription());
430 public void testPostCloudSite() {
431 CatalogDbClientPortChanger localClient = new CatalogDbClientPortChanger(
432 "http://localhost:" + client.wiremockPort, msoAdaptersAuth, client.wiremockPort);
433 CloudSite cloudSite = new CloudSite();
434 cloudSite.setId("MTN6");
435 cloudSite.setClli("TESTCLLI");
436 cloudSite.setRegionId("regionId");
437 cloudSite.setCloudVersion("VERSION");
438 cloudSite.setPlatform("PLATFORM");
440 CloudIdentity cloudIdentity = new CloudIdentity();
441 cloudIdentity.setId("RANDOMID");
442 cloudIdentity.setIdentityUrl("URL");
443 cloudIdentity.setMsoId("MSO_ID");
444 cloudIdentity.setMsoPass("MSO_PASS");
445 cloudIdentity.setAdminTenant("ADMIN_TENANT");
446 cloudIdentity.setMemberRole("ROLE");
447 cloudIdentity.setIdentityServerType(ServerType.KEYSTONE);
448 cloudIdentity.setIdentityAuthenticationType(AuthenticationType.RACKSPACE_APIKEY);
449 cloudSite.setIdentityService(cloudIdentity);
450 localClient.postCloudSite(cloudSite);
451 CloudSite getCloudSite = this.client.getCloudSite("MTN6");
452 Assert.assertNotNull(getCloudSite);
453 Assert.assertNotNull(getCloudSite.getIdentityService());
454 Assert.assertEquals("TESTCLLI", getCloudSite.getClli());
455 Assert.assertEquals("regionId", getCloudSite.getRegionId());
456 Assert.assertEquals("RANDOMID", getCloudSite.getIdentityServiceId());
460 public void testGetHomingInstance() {
461 HomingInstance homingInstance = client.getHomingInstance("5df8b6de-2083-11e7-93ae-92361f232671");
462 Assert.assertNotNull(homingInstance);
463 Assert.assertNotNull(homingInstance.getCloudOwner());
464 Assert.assertNotNull(homingInstance.getCloudRegionId());
465 Assert.assertNotNull(homingInstance.getOofDirectives());
469 public void testPostHomingInstance() {
470 CatalogDbClientPortChanger localClient = new CatalogDbClientPortChanger(
471 "http://localhost:" + client.wiremockPort, msoAdaptersAuth, client.wiremockPort);
472 HomingInstance homingInstance = new HomingInstance();
473 homingInstance.setServiceInstanceId("5df8d6be-2083-11e7-93ae-92361f232671");
474 homingInstance.setCloudOwner("CloudOwner-1");
475 homingInstance.setCloudRegionId("CloudRegionOne");
476 homingInstance.setOofDirectives("{\n" + "\"directives\": [\n" + "{\n" + "\"directives\": [\n" + "{\n"
477 + "\"attributes\": [\n" + "{\n" + "\"attribute_value\": \"onap.hpa.flavor31\",\n"
478 + "\"attribute_name\": \"firewall_flavor_name\"\n" + "}\n" + "],\n"
479 + "\"type\": \"flavor_directives\"\n" + "}\n" + "],\n" + "\"type\": \"vnfc\",\n" + "\"id\": \"vfw\"\n"
480 + "},\n" + "{\n" + "\"directives\": [\n" + "{\n" + "\"attributes\": [\n" + "{\n"
481 + "\"attribute_value\": \"onap.hpa.flavor32\",\n" + "\"attribute_name\": \"packetgen_flavor_name\"\n"
482 + "}\n" + "],\n" + "\"type\": \"flavor_directives\"\n" + "}\n" + "],\n" + "\"type\": \"vnfc\",\n"
483 + "\"id\": \"vgenerator\"\n" + "},\n" + "{\n" + "\"directives\": [\n" + "{\n" + "\"attributes\": [\n"
484 + "{\n" + "\"attribute_value\": \"onap.hpa.flavor31\",\n" + "\"attribute_name\": \"sink_flavor_name\"\n"
485 + "}\n" + "],\n" + "\"type\": \"flavor_directives\"\n" + "}\n" + "],\n" + "\"type\": \"vnfc\",\n"
486 + "\"id\": \"vsink\"\n" + "}\n" + "]\n" + "}");
487 localClient.postHomingInstance(homingInstance);
488 HomingInstance getHomingInstance = this.client.getHomingInstance("5df8d6be-2083-11e7-93ae-92361f232671");
489 Assert.assertNotNull(getHomingInstance);
490 Assert.assertNotNull(getHomingInstance.getCloudRegionId());
491 Assert.assertNotNull(getHomingInstance.getCloudOwner());
492 Assert.assertEquals("CloudOwner-1", getHomingInstance.getCloudOwner());
493 Assert.assertEquals("CloudRegionOne", getHomingInstance.getCloudRegionId());
497 public void testGetServiceByModelName() {
498 Service service = client.getServiceByModelName("MSOTADevInfra_Test_Service");
499 Assert.assertNotNull(service);
500 Assert.assertNotNull(service.getModelVersion());
501 Assert.assertNotNull(service.getModelInvariantUUID());
502 Assert.assertEquals("MSOTADevInfra_Test_Service", service.getModelName());
503 Assert.assertEquals("NA", service.getServiceRole());
507 public void testGetServiceByModelNameNotFound() {
508 Service service = client.getServiceByModelName("Not_Found");
509 Assert.assertNull(service);
513 public void testGetServiceByModelUUID() {
514 Service service = client.getServiceByModelUUID("5df8b6de-2083-11e7-93ae-92361f002679");
515 Assert.assertNotNull(service);
516 Assert.assertNotNull(service.getModelVersion());
517 Assert.assertNotNull(service.getModelInvariantUUID());
518 Assert.assertEquals("5df8b6de-2083-11e7-93ae-92361f002679", service.getModelUUID());
519 Assert.assertEquals("NA", service.getServiceRole());
523 public void testGetServiceByModelUUIDNotFound() {
524 Service service = client.getServiceByModelUUID("Not_Found");
525 Assert.assertNull(service);
529 public void testGetNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner() {
530 NorthBoundRequest northBoundRequest = new NorthBoundRequest();
531 northBoundRequest.setAction("createService");
532 northBoundRequest.setRequestScope("service");
533 northBoundRequest.setIsAlacarte(true);
534 northBoundRequest.setCloudOwner("my-custom-cloud-owner");
535 client.getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner("createService", "service", true,
536 "my-custom-cloud-owner");
537 Assert.assertNotNull(northBoundRequest);
538 Assert.assertEquals("createService", northBoundRequest.getAction());
539 Assert.assertEquals("service", northBoundRequest.getRequestScope());
540 Assert.assertEquals(true, northBoundRequest.getIsAlacarte());
541 Assert.assertEquals("my-custom-cloud-owner", northBoundRequest.getCloudOwner());
545 public void testFindServiceRecipeByActionAndServiceModelUUID() {
546 ServiceRecipe serviceRecipe = client.findServiceRecipeByActionAndServiceModelUUID("createInstance",
547 "4694a55f-58b3-4f17-92a5-796d6f5ffd0d");
548 Assert.assertNotNull(serviceRecipe);
549 Assert.assertNotNull(serviceRecipe.getServiceModelUUID());
550 Assert.assertNotNull(serviceRecipe.getAction());
551 Assert.assertEquals("/mso/async/services/CreateGenericALaCarteServiceInstance",
552 serviceRecipe.getOrchestrationUri());
553 Assert.assertEquals("MSOTADevInfra aLaCarte", serviceRecipe.getDescription());
557 public void testFindServiceRecipeByActionAndServiceModelUUIDNotFound() {
558 ServiceRecipe serviceRecipe =
559 client.findServiceRecipeByActionAndServiceModelUUID("not_found", "5df8b6de-2083-11e7-93ae-test");
560 Assert.assertNull(serviceRecipe);
564 public void testFindExternalToInternalServiceByServiceName() {
565 ExternalServiceToInternalService externalServiceToInternalService =
566 client.findExternalToInternalServiceByServiceName("MySpecialServiceName");
567 Assert.assertNotNull(externalServiceToInternalService);
568 Assert.assertNotNull(externalServiceToInternalService.getServiceName());
569 Assert.assertNotNull(externalServiceToInternalService.getServiceModelUUID());
570 Assert.assertEquals("MySpecialServiceName", externalServiceToInternalService.getServiceName());
574 public void testFindExternalToInternalServiceByServiceNameNotFound() {
575 ExternalServiceToInternalService externalServiceToInternalService =
576 client.findExternalToInternalServiceByServiceName("Not_Found");
577 Assert.assertNull(externalServiceToInternalService);
581 public void getPnfResourceByModelUUID_validUuid_expectedOutput() {
582 PnfResource pnfResource = client.getPnfResourceByModelUUID("ff2ae348-214a-11e7-93ae-92361f002680");
583 Assert.assertNotNull(pnfResource);
584 assertEquals("PNFResource modelUUID", "ff2ae348-214a-11e7-93ae-92361f002680", pnfResource.getModelUUID());
585 assertEquals("PNFResource modelInvariantUUID", "2fff5b20-214b-11e7-93ae-92361f002680",
586 pnfResource.getModelInvariantUUID());
587 assertEquals("PNFResource modelVersion", "1.0", pnfResource.getModelVersion());
588 assertEquals("PNFResource orchestration mode", "", pnfResource.getOrchestrationMode());
592 public void getPnfResourceByModelUUID_invalidUuid_NullOutput() {
593 PnfResource pnfResource = client.getPnfResourceByModelUUID(UUID.randomUUID().toString());
594 Assert.assertNull(pnfResource);
598 public void getPnfResourceCustomizationByModelCustomizationUUID_validUuid_expectedOutput() {
599 PnfResourceCustomization pnfResourceCustomization =
600 client.getPnfResourceCustomizationByModelCustomizationUUID("68dc9a92-214c-11e7-93ae-92361f002680");
601 assertEquals("modelInstanceName", "PNF routing", pnfResourceCustomization.getModelInstanceName());
602 assertEquals("blueprintName", "test_configuration_restconf", pnfResourceCustomization.getBlueprintName());
603 assertEquals("blueprintVersion", "1.0.0", pnfResourceCustomization.getBlueprintVersion());
604 assertTrue("skip post instantiation configuration", pnfResourceCustomization.isSkipPostInstConf());
605 PnfResource pnfResource = pnfResourceCustomization.getPnfResources();
606 assertNotNull(pnfResource);
607 assertEquals("PNFResource modelUUID", "ff2ae348-214a-11e7-93ae-92361f002680", pnfResource.getModelUUID());
608 assertEquals("PNFResource modelInvariantUUID", "2fff5b20-214b-11e7-93ae-92361f002680",
609 pnfResource.getModelInvariantUUID());
610 assertEquals("PNFResource modelVersion", "1.0", pnfResource.getModelVersion());
611 assertEquals("PNFResource orchestration mode", "", pnfResource.getOrchestrationMode());
615 public void getPnfResourceCustomizationByModelCustomizationUUID_invalidUuid_nullOutput() {
616 PnfResourceCustomization pnfResourceCustomization =
617 client.getPnfResourceCustomizationByModelCustomizationUUID(UUID.randomUUID().toString());
618 Assert.assertNull(pnfResourceCustomization);
622 public void getPnfResourceCustomizationFromJoinTable_validServiceUuid_expectedOutput() {
623 List<PnfResourceCustomization> pnfResourceCustomizationList =
624 client.getPnfResourceCustomizationByModelUuid("5df8b6de-2083-11e7-93ae-92361f002676");
625 assertEquals(1, pnfResourceCustomizationList.size());
627 PnfResourceCustomization pnfResourceCustomization = pnfResourceCustomizationList.get(0);
628 assertEquals("modelInstanceName", "PNF routing", pnfResourceCustomization.getModelInstanceName());
629 assertEquals("blueprintName", "test_configuration_restconf", pnfResourceCustomization.getBlueprintName());
630 assertEquals("blueprintVersion", "1.0.0", pnfResourceCustomization.getBlueprintVersion());
631 PnfResource pnfResource = pnfResourceCustomization.getPnfResources();
632 assertNotNull(pnfResource);
634 assertEquals("PNFResource modelUUID", "ff2ae348-214a-11e7-93ae-92361f002680", pnfResource.getModelUUID());
635 assertEquals("PNFResource modelInvariantUUID", "2fff5b20-214b-11e7-93ae-92361f002680",
636 pnfResource.getModelInvariantUUID());
637 assertEquals("PNFResource modelVersion", "1.0", pnfResource.getModelVersion());
638 assertEquals("PNFResource orchestration mode", "", pnfResource.getOrchestrationMode());
642 public void getPnfResourceCustomizationFromJoinTable_invalidServiceUuid_nullOutput() {
643 List<PnfResourceCustomization> pnfResourceCustomizationList =
644 client.getPnfResourceCustomizationByModelUuid(UUID.randomUUID().toString());
645 assertEquals(0, pnfResourceCustomizationList.size());
649 public void getWorkflowByArtifactUUID_validUuid_expectedOutput() {
650 Workflow workflow = client.findWorkflowByArtifactUUID("5b0c4322-643d-4c9f-b184-4516049e99b1");
651 assertEquals("artifactName", "testingWorkflow", workflow.getArtifactName());
655 public void getWorkflowByArtifactUUID_invalidUuid_nullOutput() {
656 Workflow workflow = client.findWorkflowByArtifactUUID(UUID.randomUUID().toString());
657 Assert.assertNull(workflow);
661 public void getWorkflowByModelUUID_validUuid_expectedOutput() {
662 List<Workflow> workflows = client.findWorkflowByModelUUID("ff2ae348-214a-11e7-93ae-92361f002671");
663 assertTrue(workflows != null);
664 assertTrue(workflows.size() != 0);
666 assertEquals("testingWorkflow", workflows.get(0).getArtifactName());
670 public void getWorkflowByModelUUID_invalidUuid_nullOutput() {
671 Workflow workflow = client.findWorkflowByArtifactUUID(UUID.randomUUID().toString());
672 Assert.assertNull(workflow);