461fce555f11a53931b5152bac232e99ab43950e
[so.git] /
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP - SO
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
10  *
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  *
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=========================================================
19  */
20
21 package org.onap.so.db.catalog.client;
22
23
24 import static org.junit.Assert.assertEquals;
25 import static org.junit.Assert.assertNotNull;
26
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.macro.NorthBoundRequest;
55 import org.onap.so.db.catalog.beans.macro.RainyDayHandlerStatus;
56 import org.springframework.beans.factory.annotation.Autowired;
57 import org.springframework.beans.factory.annotation.Value;
58 import org.springframework.boot.test.context.SpringBootTest;
59 import org.springframework.boot.web.server.LocalServerPort;
60 import org.springframework.test.context.ActiveProfiles;
61 import org.springframework.test.context.junit4.SpringRunner;
62
63 public class CatalogDbClientTest extends CatalogDbAdapterBaseTest {
64
65     public static final String MTN13 = "mtn13";
66
67     @LocalServerPort
68     private int port;
69
70     @Value("${mso.db.auth}")
71     private String msoAdaptersAuth;
72
73     @Autowired
74     CatalogDbClientPortChanger client;
75
76     @Before
77     public void initialize() {
78         client.wiremockPort = String.valueOf(port);
79     }
80
81     @Test
82     public void testGetRainyDayHandlerStatusByFlowNameAndServiceTypeAndVnfTypeAndErrorCodeAndWorkStep() {
83         RainyDayHandlerStatus rainyDayHandlerStatus = client
84             .getRainyDayHandlerStatusByFlowNameAndServiceTypeAndVnfTypeAndErrorCodeAndWorkStep(
85                 "AssignServiceInstanceBB", "*", "*", "*", "*");
86         Assert.assertEquals("Rollback", rainyDayHandlerStatus.getPolicy());
87     }
88
89     @Test
90     public void testGetRainyDayHandlerStatusByFlowNameAndServiceTypeAndVnfTypeAndErrorCodeAndWorkStepRecordNotFound() {
91         RainyDayHandlerStatus rainyDayHandlerStatus = client
92             .getRainyDayHandlerStatusByFlowNameAndServiceTypeAndVnfTypeAndErrorCodeAndWorkStep(
93                 UUID.randomUUID().toString(), "*", "*", "*", "*");
94         Assert.assertNull(rainyDayHandlerStatus);
95     }
96
97     @Test
98     public void testGetCloudSiteHappyPath() throws Exception {
99         CloudSite cloudSite = client.getCloudSite(MTN13);
100         Assert.assertNotNull(cloudSite);
101         Assert.assertNotNull(cloudSite.getIdentityService());
102         Assert.assertEquals("MDT13", cloudSite.getClli());
103         Assert.assertEquals("mtn13", cloudSite.getRegionId());
104         Assert.assertEquals("MTN13", cloudSite.getIdentityServiceId());
105     }
106
107     @Test
108     public void testGetCloudSiteNotFound() throws Exception {
109         CloudSite cloudSite = client.getCloudSite(UUID.randomUUID().toString());
110         Assert.assertNull(cloudSite);
111     }
112
113     @Test
114     public void testGetCloudifyManagerHappyPath() throws Exception {
115         CloudifyManager cloudifyManager = client.getCloudifyManager("mtn13");
116         Assert.assertNotNull(cloudifyManager);
117         Assert.assertEquals("http://localhost:28090/v2.0", cloudifyManager.getCloudifyUrl());
118
119     }
120
121     @Test
122     public void testGetCloudifyManagerNotFound() throws Exception {
123         CloudifyManager cloudifyManager = client.getCloudifyManager(UUID.randomUUID().toString());
124         Assert.assertNull(cloudifyManager);
125     }
126
127
128     @Test
129     public void testGetCloudSiteByClliAndAicVersionHappyPath() throws Exception {
130         CloudSite cloudSite = client.getCloudSiteByClliAndAicVersion("MDT13", "2.5");
131         Assert.assertNotNull(cloudSite);
132     }
133
134     @Test
135     public void testGetCloudSiteByClliAndAicVersionNotFound() throws Exception {
136         CloudSite cloudSite = client.getCloudSiteByClliAndAicVersion("MDT13", "232496239746328");
137         Assert.assertNull(cloudSite);
138     }
139
140     @Test
141     public void testGetServiceByID() throws Exception {
142         Service serviceByID = client.getServiceByID("5df8b6de-2083-11e7-93ae-92361f002671");
143         Assert.assertNotNull(serviceByID);
144         Assert.assertEquals("MSOTADevInfra_vSAMP10a_Service", serviceByID.getModelName());
145         Assert.assertEquals("NA", serviceByID.getServiceType());
146         Assert.assertEquals("NA", serviceByID.getServiceRole());
147     }
148
149     @Test
150     public void testGetServiceByIDNotFound() throws Exception {
151         Service serviceByID = client.getServiceByID(UUID.randomUUID().toString());
152         Assert.assertNull(serviceByID);
153     }
154
155     @Test
156     public void testGetVfModuleByModelUUID() throws Exception {
157         VfModule vfModule = client.getVfModuleByModelUUID("20c4431c-246d-11e7-93ae-92361f002671");
158         Assert.assertNotNull(vfModule);
159         Assert.assertNotNull(vfModule.getVfModuleCustomization());
160         Assert.assertEquals("78ca26d0-246d-11e7-93ae-92361f002671", vfModule.getModelInvariantUUID());
161         Assert.assertEquals("vSAMP10aDEV::base::module-0", vfModule.getModelName());
162     }
163
164     @Test
165     public void testGetVfModuleByModelUUIDNotFound() throws Exception {
166         VfModule vfModule = client.getVfModuleByModelUUID(UUID.randomUUID().toString());
167         Assert.assertNull(vfModule);
168     }
169
170     @Test
171     public void testGetVnfResourceByModelUUID() throws Exception {
172         VnfResource vnfResource = client.getVnfResourceByModelUUID("ff2ae348-214a-11e7-93ae-92361f002671");
173         Assert.assertNotNull(vnfResource);
174         Assert.assertEquals("vSAMP10a", vnfResource.getModelName());
175     }
176
177     @Test
178     public void testGetVnfResourceByModelUUIDNotFound() throws Exception {
179         VnfResource vnfResource = client.getVnfResourceByModelUUID(UUID.randomUUID().toString());
180         Assert.assertNull(vnfResource);
181     }
182
183     @Test
184     public void testGetVnfResourceCustomizationByModelCustomizationUUID() {
185         VnfResourceCustomization vnfResourceCustomization = client
186             .getVnfResourceCustomizationByModelCustomizationUUID("68dc9a92-214c-11e7-93ae-92361f002671");
187         Assert.assertNotNull(vnfResourceCustomization);
188         Assert.assertEquals("vSAMP", vnfResourceCustomization.getNfRole());
189         Assert.assertNotNull(vnfResourceCustomization.getModelCustomizationUUID());
190         Assert.assertNotNull(vnfResourceCustomization.getVnfResources());
191         Assert.assertNotNull(vnfResourceCustomization.getVfModuleCustomizations());
192         Assert.assertEquals("vSAMP10a", vnfResourceCustomization.getVnfResources().getModelName());
193     }
194
195     @Test
196     public void testGetVnfResourceCustomizationByModelCustomizationUUINotFound() {
197         VnfResourceCustomization vnfResourceCustomization = client
198             .getVnfResourceCustomizationByModelCustomizationUUID(UUID.randomUUID().toString());
199         Assert.assertNull(vnfResourceCustomization);
200     }
201
202     @Test
203     public void testGetInstanceGroupByModelUUID() {
204         InstanceGroup instanceGroup = client.getInstanceGroupByModelUUID("0c8692ef-b9c0-435d-a738-edf31e71f38b");
205         Assert.assertNotNull(instanceGroup);
206         Assert.assertEquals("network_collection_resource_1806..NetworkCollection..0", instanceGroup.getModelName());
207         Assert.assertEquals("org.openecomp.resource.cr.NetworkCollectionResource1806",
208             instanceGroup.getToscaNodeType().toString());
209     }
210
211     @Test
212     public void testGetVfModuleCustomizationByModelCuztomizationUUID() {
213         VfModuleCustomization vfModuleCustomization = client
214             .getVfModuleCustomizationByModelCuztomizationUUID("cb82ffd8-252a-11e7-93ae-92361f002671");
215         Assert.assertNotNull(vfModuleCustomization);
216         Assert.assertNotNull(vfModuleCustomization.getModelCustomizationUUID());
217         Assert.assertEquals("base", vfModuleCustomization.getLabel());
218     }
219
220     @Test
221     public void testGetVfModuleCustomizationByModelCuztomizationUUIDNotFound() {
222         VfModuleCustomization vfModuleCustomization = client
223             .getVfModuleCustomizationByModelCuztomizationUUID(UUID.randomUUID().toString());
224         Assert.assertNull(vfModuleCustomization);
225     }
226
227     @Test
228     public void testGetNetworkResourceCustomizationByModelCustomizationUUID() {
229         NetworkResourceCustomization networkResourceCustomization = client
230             .getNetworkResourceCustomizationByModelCustomizationUUID("3bdbb104-476c-483e-9f8b-c095b3d308ac");
231         Assert.assertNotNull(networkResourceCustomization);
232         Assert.assertNotNull(networkResourceCustomization.getModelCustomizationUUID());
233         Assert.assertEquals("CONTRAIL30_GNDIRECT 9", networkResourceCustomization.getModelInstanceName());
234         Assert.assertNotNull(networkResourceCustomization.getNetworkResource());
235     }
236
237     @Test
238     public void testGetNetworkResourceCustomizationByModelCustomizationUUIDNotFound() {
239         NetworkResourceCustomization networkResourceCustomization = client
240             .getNetworkResourceCustomizationByModelCustomizationUUID(UUID.randomUUID().toString());
241         Assert.assertNull(networkResourceCustomization);
242     }
243
244     @Test
245     public void testGgetVfModuleCustomizationByModelCustomizationUUIDAndVfModuleModelUUID() {
246         VfModuleCustomization vfModuleCustomization = client
247             .getVfModuleCustomizationByModelCustomizationUUIDAndVfModuleModelUUID(
248                 "cb82ffd8-252a-11e7-93ae-92361f002672", "20c4431c-246d-11e7-93ae-92361f002672");
249         Assert.assertNotNull(vfModuleCustomization);
250         Assert.assertNotNull(vfModuleCustomization.getModelCustomizationUUID());
251         Assert.assertNotNull(vfModuleCustomization.getVfModule());
252         Assert.assertEquals("base", vfModuleCustomization.getLabel());
253     }
254
255     @Test
256     public void testGgetVfModuleCustomizationByModelCustomizationUUIDAndVfModuleModelUUIDNotFound() {
257         VfModuleCustomization vfModuleCustomization = client
258             .getVfModuleCustomizationByModelCustomizationUUIDAndVfModuleModelUUID(
259                 "cb82ffd8-252a-11e7-93ae-92361f002672", UUID.randomUUID().toString());
260         Assert.assertNull(vfModuleCustomization);
261     }
262
263     @Test
264     public void testGetFirstByServiceModelUUIDAndAction() {
265         ServiceRecipe serviceRecipe = client
266             .getFirstByServiceModelUUIDAndAction("4694a55f-58b3-4f17-92a5-796d6f5ffd0d", "createInstance");
267         Assert.assertNotNull(serviceRecipe);
268         Assert.assertNotNull(serviceRecipe.getServiceModelUUID());
269         Assert.assertNotNull(serviceRecipe.getAction());
270         Assert.assertEquals("/mso/async/services/CreateGenericALaCarteServiceInstance",
271             serviceRecipe.getOrchestrationUri());
272         Assert.assertEquals("MSOTADevInfra aLaCarte", serviceRecipe.getDescription());
273     }
274
275     @Test
276     public void testGetFirstByServiceModelUUIDAndActionNotFound() {
277         ServiceRecipe serviceRecipe = client
278             .getFirstByServiceModelUUIDAndAction("5df8b6de-2083-11e7-93ae-92361f002671", UUID.randomUUID().toString());
279         Assert.assertNull(serviceRecipe);
280     }
281
282     @Test
283     public void testGetFirstVnfResourceByModelInvariantUUIDAndModelVersion() {
284         VnfResource vnfResource = client
285             .getFirstVnfResourceByModelInvariantUUIDAndModelVersion("2fff5b20-214b-11e7-93ae-92361f002671", "2.0");
286         Assert.assertNotNull(vnfResource);
287         Assert.assertNotNull(vnfResource.getModelInvariantId());
288         Assert.assertNotNull(vnfResource.getModelVersion());
289         Assert.assertNotNull(vnfResource.getHeatTemplates());
290         Assert.assertNotNull(vnfResource.getVnfResourceCustomizations());
291         Assert.assertEquals("vSAMP10a", vnfResource.getModelName());
292     }
293
294     @Test
295     public void testGetFirstVnfResourceByModelInvariantUUIDAndModelVersionNotFound() {
296         VnfResource vnfResource = client
297             .getFirstVnfResourceByModelInvariantUUIDAndModelVersion("2fff5b20-214b-11e7-93ae-92361f002671",
298                 UUID.randomUUID().toString());
299         Assert.assertNull(vnfResource);
300     }
301
302     @Test
303     public void testGetFirstVnfResourceCustomizationByModelInstanceNameAndVnfResources() {
304         VnfResource vnfr = new VnfResource();
305         vnfr.setModelUUID("ff2ae348-214a-11e7-93ae-92361f002671");
306         VnfResourceCustomization firstVnfResourceCustomizationByModelInstanceNameAndVnfResources = client
307             .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
314             .assertNotNull(firstVnfResourceCustomizationByModelInstanceNameAndVnfResources.getVfModuleCustomizations());
315     }
316
317     @Test
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());
325     }
326
327     @Test
328     public void testGetFirstVnfRecipeByNfRoleAndActionNotFound() {
329         VnfRecipe vnfRecipe = client.getFirstVnfRecipeByNfRoleAndAction(UUID.randomUUID().toString(), "createInstance");
330         Assert.assertNull(vnfRecipe);
331     }
332
333     @Test
334     public void testGetFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction() {
335         VnfComponentsRecipe vnfComponentsRecipe = client
336             .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());
344
345     }
346
347
348     @Test
349     public void testGetFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndActionNotFound() {
350         VnfComponentsRecipe vnfComponentsRecipe = client
351             .getFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction(UUID.randomUUID().toString(),
352                 "volumeGroup", "createInstance");
353         Assert.assertNull(vnfComponentsRecipe);
354     }
355
356     @Test
357     public void testGetFirstVnfComponentsRecipeByVnfComponentTypeAndAction() {
358         VnfComponentsRecipe vnfComponentsRecipe = client
359             .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
365             .assertEquals("/mso/async/services/CreateVfModuleVolumeInfraV1", vnfComponentsRecipe.getOrchestrationUri());
366     }
367
368     @Test
369     public void testGetServiceByModelVersionAndModelInvariantUUID() {
370         Service service = client
371             .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());
377     }
378
379     @Test
380     public void testGetServiceByModelVersionAndModelInvariantUUIDNotFound() {
381         Service service = client.getServiceByModelVersionAndModelInvariantUUID("2.0", UUID.randomUUID().toString());
382         Assert.assertNull(service);
383     }
384
385     @Test
386     public void testGetVfModuleByModelInvariantUUIDAndModelVersion() {
387         VfModule vfModule = client
388             .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());
394     }
395
396     @Test
397     public void testGetVfModuleByModelInvariantUUIDAndModelVersionNotFound() {
398         VfModule vfModule = client.getVfModuleByModelInvariantUUIDAndModelVersion(UUID.randomUUID().toString(), "2");
399         Assert.assertNull(vfModule);
400     }
401
402     @Test
403     public void testGetServiceByModelInvariantUUIDOrderByModelVersionDesc() {
404         List<Service> serviceList = client
405             .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());
410     }
411
412     @Test
413     public void testGetServiceByModelInvariantUUIDOrderByModelVersionDescNotFound() {
414         List<Service> serviceList = client
415             .getServiceByModelInvariantUUIDOrderByModelVersionDesc(UUID.randomUUID().toString());
416         Assert.assertTrue(serviceList.isEmpty());
417     }
418
419     @Test
420     public void testGetVfModuleByModelInvariantUUIDOrderByModelVersionDesc() {
421         List<VfModule> moduleList = client
422             .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());
427     }
428
429     @Test
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");
439
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());
457     }
458
459     @Test
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());
466     }
467
468     @Test
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" +
477             "\"directives\": [\n" +
478             "{\n" +
479             "\"directives\": [\n" +
480             "{\n" +
481             "\"attributes\": [\n" +
482             "{\n" +
483             "\"attribute_value\": \"onap.hpa.flavor31\",\n" +
484             "\"attribute_name\": \"firewall_flavor_name\"\n" +
485             "}\n" +
486             "],\n" +
487             "\"type\": \"flavor_directives\"\n" +
488             "}\n" +
489             "],\n" +
490             "\"type\": \"vnfc\",\n" +
491             "\"id\": \"vfw\"\n" +
492             "},\n" +
493             "{\n" +
494             "\"directives\": [\n" +
495             "{\n" +
496             "\"attributes\": [\n" +
497             "{\n" +
498             "\"attribute_value\": \"onap.hpa.flavor32\",\n" +
499             "\"attribute_name\": \"packetgen_flavor_name\"\n" +
500             "}\n" +
501             "],\n" +
502             "\"type\": \"flavor_directives\"\n" +
503             "}\n" +
504             "],\n" +
505             "\"type\": \"vnfc\",\n" +
506             "\"id\": \"vgenerator\"\n" +
507             "},\n" +
508             "{\n" +
509             "\"directives\": [\n" +
510             "{\n" +
511             "\"attributes\": [\n" +
512             "{\n" +
513             "\"attribute_value\": \"onap.hpa.flavor31\",\n" +
514             "\"attribute_name\": \"sink_flavor_name\"\n" +
515             "}\n" +
516             "],\n" +
517             "\"type\": \"flavor_directives\"\n" +
518             "}\n" +
519             "],\n" +
520             "\"type\": \"vnfc\",\n" +
521             "\"id\": \"vsink\"\n" +
522             "}\n" +
523             "]\n" +
524             "}");
525         localClient.postHomingInstance(homingInstance);
526         HomingInstance getHomingInstance = this.client.getHomingInstance("5df8d6be-2083-11e7-93ae-92361f232671");
527         Assert.assertNotNull(getHomingInstance);
528         Assert.assertNotNull(getHomingInstance.getCloudRegionId());
529         Assert.assertNotNull(getHomingInstance.getCloudOwner());
530         Assert.assertEquals("CloudOwner-1", getHomingInstance.getCloudOwner());
531         Assert.assertEquals("CloudRegionOne", getHomingInstance.getCloudRegionId());
532     }
533
534     @Test
535     public void testGetServiceByModelName() {
536         Service service = client.getServiceByModelName("MSOTADevInfra_Test_Service");
537         Assert.assertNotNull(service);
538         Assert.assertNotNull(service.getModelVersion());
539         Assert.assertNotNull(service.getModelInvariantUUID());
540         Assert.assertEquals("MSOTADevInfra_Test_Service", service.getModelName());
541         Assert.assertEquals("NA", service.getServiceRole());
542     }
543
544     @Test
545     public void testGetServiceByModelNameNotFound() {
546         Service service = client.getServiceByModelName("Not_Found");
547         Assert.assertNull(service);
548     }
549
550     @Test
551     public void testGetServiceByModelUUID() {
552         Service service = client.getServiceByModelUUID("5df8b6de-2083-11e7-93ae-92361f002679");
553         Assert.assertNotNull(service);
554         Assert.assertNotNull(service.getModelVersion());
555         Assert.assertNotNull(service.getModelInvariantUUID());
556         Assert.assertEquals("5df8b6de-2083-11e7-93ae-92361f002679", service.getModelUUID());
557         Assert.assertEquals("NA", service.getServiceRole());
558     }
559
560     @Test
561     public void testGetServiceByModelUUIDNotFound() {
562         Service service = client.getServiceByModelUUID("Not_Found");
563         Assert.assertNull(service);
564     }
565
566     @Test
567     public void testGetNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner() {
568         NorthBoundRequest northBoundRequest = new NorthBoundRequest();
569         northBoundRequest.setAction("createService");
570         northBoundRequest.setRequestScope("service");
571         northBoundRequest.setIsAlacarte(true);
572         northBoundRequest.setCloudOwner("my-custom-cloud-owner");
573         client.getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner("createService", "service", true,
574             "my-custom-cloud-owner");
575         Assert.assertNotNull(northBoundRequest);
576         Assert.assertEquals("createService", northBoundRequest.getAction());
577         Assert.assertEquals("service", northBoundRequest.getRequestScope());
578         Assert.assertEquals(true, northBoundRequest.getIsAlacarte());
579         Assert.assertEquals("my-custom-cloud-owner", northBoundRequest.getCloudOwner());
580     }
581
582     @Test
583     public void testFindServiceRecipeByActionAndServiceModelUUID() {
584         ServiceRecipe serviceRecipe = client
585             .findServiceRecipeByActionAndServiceModelUUID("createInstance", "4694a55f-58b3-4f17-92a5-796d6f5ffd0d");
586         Assert.assertNotNull(serviceRecipe);
587         Assert.assertNotNull(serviceRecipe.getServiceModelUUID());
588         Assert.assertNotNull(serviceRecipe.getAction());
589         Assert.assertEquals("/mso/async/services/CreateGenericALaCarteServiceInstance",
590             serviceRecipe.getOrchestrationUri());
591         Assert.assertEquals("MSOTADevInfra aLaCarte", serviceRecipe.getDescription());
592     }
593
594     @Test
595     public void testFindServiceRecipeByActionAndServiceModelUUIDNotFound() {
596         ServiceRecipe serviceRecipe = client
597             .findServiceRecipeByActionAndServiceModelUUID("not_found", "5df8b6de-2083-11e7-93ae-test");
598         Assert.assertNull(serviceRecipe);
599     }
600
601     @Test
602     public void testFindExternalToInternalServiceByServiceName() {
603         ExternalServiceToInternalService externalServiceToInternalService = client
604             .findExternalToInternalServiceByServiceName("MySpecialServiceName");
605         Assert.assertNotNull(externalServiceToInternalService);
606         Assert.assertNotNull(externalServiceToInternalService.getServiceName());
607         Assert.assertNotNull(externalServiceToInternalService.getServiceModelUUID());
608         Assert.assertEquals("MySpecialServiceName", externalServiceToInternalService.getServiceName());
609     }
610
611     @Test
612     public void testFindExternalToInternalServiceByServiceNameNotFound() {
613         ExternalServiceToInternalService externalServiceToInternalService = client
614             .findExternalToInternalServiceByServiceName("Not_Found");
615         Assert.assertNull(externalServiceToInternalService);
616     }
617
618     @Test
619     public void getPnfResourceByModelUUID_validUuid_expectedOutput() {
620         PnfResource pnfResource = client.getPnfResourceByModelUUID("ff2ae348-214a-11e7-93ae-92361f002680");
621         Assert.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());
627     }
628
629     @Test
630     public void getPnfResourceByModelUUID_invalidUuid_NullOutput() {
631         PnfResource pnfResource = client.getPnfResourceByModelUUID(UUID.randomUUID().toString());
632         Assert.assertNull(pnfResource);
633     }
634
635     @Test
636     public void getPnfResourceCustomizationByModelCustomizationUUID_validUuid_expectedOutput() {
637         PnfResourceCustomization pnfResourceCustomization = client
638             .getPnfResourceCustomizationByModelCustomizationUUID("68dc9a92-214c-11e7-93ae-92361f002680");
639         assertEquals("modelInstanceName", "PNF routing", pnfResourceCustomization.getModelInstanceName());
640         assertEquals("blueprintName", "test_configuration_restconf", pnfResourceCustomization.getBlueprintName());
641         assertEquals("blueprintVersion", "1.0.0", pnfResourceCustomization.getBlueprintVersion());
642         PnfResource pnfResource = pnfResourceCustomization.getPnfResources();
643         assertNotNull(pnfResource);
644
645         assertEquals("PNFResource modelUUID", "ff2ae348-214a-11e7-93ae-92361f002680", pnfResource.getModelUUID());
646         assertEquals("PNFResource modelInvariantUUID", "2fff5b20-214b-11e7-93ae-92361f002680",
647             pnfResource.getModelInvariantUUID());
648         assertEquals("PNFResource modelVersion", "1.0", pnfResource.getModelVersion());
649         assertEquals("PNFResource orchestration mode", "", pnfResource.getOrchestrationMode());
650     }
651
652     @Test
653     public void getPnfResourceCustomizationByModelCustomizationUUID_invalidUuid_nullOutput() {
654         PnfResourceCustomization pnfResourceCustomization = client
655             .getPnfResourceCustomizationByModelCustomizationUUID(UUID.randomUUID().toString());
656         Assert.assertNull(pnfResourceCustomization);
657     }
658
659 }