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.mockito.Mockito.when;
27 import java.util.List;
28 import java.util.UUID;
30 import javax.ws.rs.core.UriBuilder;
32 import org.junit.Assert;
33 import org.junit.Before;
34 import org.junit.Test;
35 import org.junit.runner.RunWith;
36 import org.onap.so.adapters.catalogdb.CatalogDBApplication;
37 import org.onap.so.db.catalog.beans.AuthenticationType;
38 import org.onap.so.db.catalog.beans.CloudIdentity;
39 import org.onap.so.db.catalog.beans.CloudSite;
40 import org.onap.so.db.catalog.beans.CloudifyManager;
41 import org.onap.so.db.catalog.beans.ExternalServiceToInternalService;
42 import org.onap.so.db.catalog.beans.HomingInstance;
43 import org.onap.so.db.catalog.beans.InstanceGroup;
44 import org.onap.so.db.catalog.beans.NetworkResourceCustomization;
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.ExternalServiceToInternalService;
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.web.server.LocalServerPort;
60 import org.springframework.boot.test.context.SpringBootTest;
61 import org.springframework.boot.test.mock.mockito.MockBean;
62 import org.springframework.test.context.ActiveProfiles;
63 import org.springframework.test.context.junit4.SpringRunner;
65 import com.fasterxml.jackson.databind.ObjectMapper;
67 @RunWith(SpringRunner.class)
68 @SpringBootTest(classes = CatalogDBApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
69 @ActiveProfiles("test")
70 public class CatalogDbClientTest {
71 public static final String MTN13 = "mtn13";
76 @Value("${mso.db.auth}")
77 private String msoAdaptersAuth;
80 CatalogDbClientPortChanger client;
83 public void initialize(){
84 client.wiremockPort= String.valueOf(port);
88 public void testGetRainyDayHandlerStatusByFlowNameAndServiceTypeAndVnfTypeAndErrorCodeAndWorkStep(){
89 RainyDayHandlerStatus rainyDayHandlerStatus = client.getRainyDayHandlerStatusByFlowNameAndServiceTypeAndVnfTypeAndErrorCodeAndWorkStep("AssignServiceInstanceBB", "*", "*", "*", "*");
90 Assert.assertEquals("Rollback", rainyDayHandlerStatus.getPolicy());
94 public void testGetRainyDayHandlerStatusByFlowNameAndServiceTypeAndVnfTypeAndErrorCodeAndWorkStepRecordNotFound(){
95 RainyDayHandlerStatus rainyDayHandlerStatus = client.getRainyDayHandlerStatusByFlowNameAndServiceTypeAndVnfTypeAndErrorCodeAndWorkStep(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.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());
198 public void testGetVnfResourceCustomizationByModelCustomizationUUINotFound() {
199 VnfResourceCustomization vnfResourceCustomization = client.getVnfResourceCustomizationByModelCustomizationUUID(UUID.randomUUID().toString());
200 Assert.assertNull(vnfResourceCustomization);
204 public void testGetInstanceGroupByModelUUID() {
205 InstanceGroup instanceGroup = client.getInstanceGroupByModelUUID("0c8692ef-b9c0-435d-a738-edf31e71f38b");
206 Assert.assertNotNull(instanceGroup);
207 Assert.assertEquals("network_collection_resource_1806..NetworkCollection..0", instanceGroup.getModelName());
208 Assert.assertEquals("org.openecomp.resource.cr.NetworkCollectionResource1806", instanceGroup.getToscaNodeType().toString());
212 public void testGetVfModuleCustomizationByModelCuztomizationUUID() {
213 VfModuleCustomization vfModuleCustomization = client.getVfModuleCustomizationByModelCuztomizationUUID("cb82ffd8-252a-11e7-93ae-92361f002671");
214 Assert.assertNotNull(vfModuleCustomization);
215 Assert.assertNotNull(vfModuleCustomization.getModelCustomizationUUID());
216 Assert.assertEquals("base", vfModuleCustomization.getLabel());
220 public void testGetVfModuleCustomizationByModelCuztomizationUUIDNotFound() {
221 VfModuleCustomization vfModuleCustomization = client.getVfModuleCustomizationByModelCuztomizationUUID(UUID.randomUUID().toString());
222 Assert.assertNull(vfModuleCustomization);
226 public void testGetNetworkResourceCustomizationByModelCustomizationUUID() {
227 NetworkResourceCustomization networkResourceCustomization = client.getNetworkResourceCustomizationByModelCustomizationUUID("3bdbb104-476c-483e-9f8b-c095b3d308ac");
228 Assert.assertNotNull(networkResourceCustomization);
229 Assert.assertNotNull(networkResourceCustomization.getModelCustomizationUUID());
230 Assert.assertEquals("CONTRAIL30_GNDIRECT 9", networkResourceCustomization.getModelInstanceName());
231 Assert.assertNotNull(networkResourceCustomization.getNetworkResource());
235 public void testGetNetworkResourceCustomizationByModelCustomizationUUIDNotFound() {
236 NetworkResourceCustomization networkResourceCustomization = client.getNetworkResourceCustomizationByModelCustomizationUUID(UUID.randomUUID().toString());
237 Assert.assertNull(networkResourceCustomization);
241 public void testGgetVfModuleCustomizationByModelCustomizationUUIDAndVfModuleModelUUID() {
242 VfModuleCustomization vfModuleCustomization = client.getVfModuleCustomizationByModelCustomizationUUIDAndVfModuleModelUUID("cb82ffd8-252a-11e7-93ae-92361f002672", "20c4431c-246d-11e7-93ae-92361f002672");
243 Assert.assertNotNull(vfModuleCustomization);
244 Assert.assertNotNull(vfModuleCustomization.getModelCustomizationUUID());
245 Assert.assertNotNull(vfModuleCustomization.getVfModule());
246 Assert.assertEquals("base", vfModuleCustomization.getLabel());
250 public void testGgetVfModuleCustomizationByModelCustomizationUUIDAndVfModuleModelUUIDNotFound() {
251 VfModuleCustomization vfModuleCustomization = client.getVfModuleCustomizationByModelCustomizationUUIDAndVfModuleModelUUID("cb82ffd8-252a-11e7-93ae-92361f002672", UUID.randomUUID().toString());
252 Assert.assertNull(vfModuleCustomization);
256 public void testGetFirstByServiceModelUUIDAndAction() {
257 ServiceRecipe serviceRecipe = client.getFirstByServiceModelUUIDAndAction("4694a55f-58b3-4f17-92a5-796d6f5ffd0d", "createInstance");
258 Assert.assertNotNull(serviceRecipe);
259 Assert.assertNotNull(serviceRecipe.getServiceModelUUID());
260 Assert.assertNotNull(serviceRecipe.getAction());
261 Assert.assertEquals("/mso/async/services/CreateGenericALaCarteServiceInstance", serviceRecipe.getOrchestrationUri());
262 Assert.assertEquals("MSOTADevInfra aLaCarte", serviceRecipe.getDescription());
266 public void testGetFirstByServiceModelUUIDAndActionNotFound() {
267 ServiceRecipe serviceRecipe = client.getFirstByServiceModelUUIDAndAction("5df8b6de-2083-11e7-93ae-92361f002671", UUID.randomUUID().toString());
268 Assert.assertNull(serviceRecipe);
272 public void testGetFirstVnfResourceByModelInvariantUUIDAndModelVersion() {
273 VnfResource vnfResource = client.getFirstVnfResourceByModelInvariantUUIDAndModelVersion("2fff5b20-214b-11e7-93ae-92361f002671", "2.0");
274 Assert.assertNotNull(vnfResource);
275 Assert.assertNotNull(vnfResource.getModelInvariantId());
276 Assert.assertNotNull(vnfResource.getModelVersion());
277 Assert.assertNotNull(vnfResource.getHeatTemplates());
278 Assert.assertNotNull(vnfResource.getVnfResourceCustomizations());
279 Assert.assertEquals("vSAMP10a", vnfResource.getModelName());
283 public void testGetFirstVnfResourceByModelInvariantUUIDAndModelVersionNotFound() {
284 VnfResource vnfResource = client.getFirstVnfResourceByModelInvariantUUIDAndModelVersion("2fff5b20-214b-11e7-93ae-92361f002671", UUID.randomUUID().toString());
285 Assert.assertNull(vnfResource);
289 public void testGetFirstVnfResourceCustomizationByModelInstanceNameAndVnfResources() {
290 VnfResource vnfr = new VnfResource();
291 vnfr.setModelUUID("ff2ae348-214a-11e7-93ae-92361f002671");
292 VnfResourceCustomization firstVnfResourceCustomizationByModelInstanceNameAndVnfResources = client.getFirstVnfResourceCustomizationByModelInstanceNameAndVnfResources("vSAMP10a 1", vnfr);
293 Assert.assertNotNull(firstVnfResourceCustomizationByModelInstanceNameAndVnfResources);
294 Assert.assertEquals("vSAMP", firstVnfResourceCustomizationByModelInstanceNameAndVnfResources.getNfRole());
295 Assert.assertEquals("vSAMP10a 1", firstVnfResourceCustomizationByModelInstanceNameAndVnfResources.getModelInstanceName());
296 Assert.assertNotNull(firstVnfResourceCustomizationByModelInstanceNameAndVnfResources.getVnfResources());
297 Assert.assertNotNull(firstVnfResourceCustomizationByModelInstanceNameAndVnfResources.getVfModuleCustomizations());
301 public void testGetFirstVnfRecipeByNfRoleAndAction() {
302 VnfRecipe vnfRecipe = client.getFirstVnfRecipeByNfRoleAndAction("GR-API-DEFAULT", "createInstance");
303 Assert.assertNotNull(vnfRecipe);
304 Assert.assertNotNull(vnfRecipe.getNfRole());
305 Assert.assertNotNull(vnfRecipe.getAction());
306 Assert.assertEquals("Gr api recipe to create vnf", vnfRecipe.getDescription());
307 Assert.assertEquals("/mso/async/services/WorkflowActionBB", vnfRecipe.getOrchestrationUri());
311 public void testGetFirstVnfRecipeByNfRoleAndActionNotFound() {
312 VnfRecipe vnfRecipe = client.getFirstVnfRecipeByNfRoleAndAction(UUID.randomUUID().toString(), "createInstance");
313 Assert.assertNull(vnfRecipe);
317 public void testGetFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction() {
318 VnfComponentsRecipe vnfComponentsRecipe = client.getFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction("20c4431c-246d-11e7-93ae-92361f002671", "volumeGroup", "createInstance");
319 Assert.assertNotNull(vnfComponentsRecipe);
320 Assert.assertNotNull(vnfComponentsRecipe.getAction());
321 Assert.assertNotNull(vnfComponentsRecipe.getVfModuleModelUUID());
322 Assert.assertNotNull(vnfComponentsRecipe.getVnfComponentType());
323 Assert.assertEquals("Gr api recipe to create volume-group", vnfComponentsRecipe.getDescription());
324 Assert.assertEquals("/mso/async/services/WorkflowActionBB", vnfComponentsRecipe.getOrchestrationUri());
330 public void testGetFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndActionNotFound() {
331 VnfComponentsRecipe vnfComponentsRecipe = client.getFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction(UUID.randomUUID().toString(), "volumeGroup", "createInstance");
332 Assert.assertNull(vnfComponentsRecipe);
336 public void testGetFirstVnfComponentsRecipeByVnfComponentTypeAndAction() {
337 VnfComponentsRecipe vnfComponentsRecipe = client.getFirstVnfComponentsRecipeByVnfComponentTypeAndAction("volumeGroup", "createInstance");
338 Assert.assertNotNull(vnfComponentsRecipe);
339 Assert.assertNotNull(vnfComponentsRecipe.getAction());
340 Assert.assertNotNull(vnfComponentsRecipe.getVnfComponentType());
341 Assert.assertEquals("VID_DEFAULT recipe t", vnfComponentsRecipe.getDescription());
342 Assert.assertEquals("/mso/async/services/CreateVfModuleVolumeInfraV1", vnfComponentsRecipe.getOrchestrationUri());
346 public void testGetServiceByModelVersionAndModelInvariantUUID() {
347 Service service = client.getServiceByModelVersionAndModelInvariantUUID("2.0", "9647dfc4-2083-11e7-93ae-92361f002671");
348 Assert.assertNotNull(service);
349 Assert.assertNotNull(service.getModelVersion());
350 Assert.assertNotNull(service.getModelInvariantUUID());
351 Assert.assertEquals("MSOTADevInfra_vSAMP10a_Service", service.getModelName());
352 Assert.assertEquals("NA", service.getServiceRole());
356 public void testGetServiceByModelVersionAndModelInvariantUUIDNotFound() {
357 Service service = client.getServiceByModelVersionAndModelInvariantUUID("2.0", UUID.randomUUID().toString());
358 Assert.assertNull(service);
362 public void testGetVfModuleByModelInvariantUUIDAndModelVersion() {
363 VfModule vfModule = client.getVfModuleByModelInvariantUUIDAndModelVersion("78ca26d0-246d-11e7-93ae-92361f002671", "2");
364 Assert.assertNotNull(vfModule);
365 Assert.assertNotNull(vfModule.getModelVersion());
366 Assert.assertNotNull(vfModule.getModelInvariantUUID());
367 Assert.assertEquals("vSAMP10aDEV::base::module-0", vfModule.getModelName());
368 Assert.assertEquals("vSAMP10a DEV Base", vfModule.getDescription());
372 public void testGetVfModuleByModelInvariantUUIDAndModelVersionNotFound() {
373 VfModule vfModule = client.getVfModuleByModelInvariantUUIDAndModelVersion(UUID.randomUUID().toString(), "2");
374 Assert.assertNull(vfModule);
378 public void testGetServiceByModelInvariantUUIDOrderByModelVersionDesc() {
379 List<Service> serviceList = client.getServiceByModelInvariantUUIDOrderByModelVersionDesc("9647dfc4-2083-11e7-93ae-92361f002671");
380 Assert.assertFalse(serviceList.isEmpty());
381 Assert.assertEquals(2, serviceList.size());
382 Service service = serviceList.get(0);
383 Assert.assertEquals("2.0", service.getModelVersion());
387 public void testGetServiceByModelInvariantUUIDOrderByModelVersionDescNotFound() {
388 List<Service> serviceList = client.getServiceByModelInvariantUUIDOrderByModelVersionDesc(UUID.randomUUID().toString());
389 Assert.assertTrue(serviceList.isEmpty());
393 public void testGetVfModuleByModelInvariantUUIDOrderByModelVersionDesc() {
394 List<VfModule> moduleList = client.getVfModuleByModelInvariantUUIDOrderByModelVersionDesc("78ca26d0-246d-11e7-93ae-92361f002671");
395 Assert.assertFalse(moduleList.isEmpty());
396 Assert.assertEquals(2, moduleList.size());
397 VfModule module = moduleList.get(0);
398 Assert.assertEquals("vSAMP10a DEV Base",module.getDescription());
402 public void testPostCloudSite() {
403 CatalogDbClientPortChanger localClient = new CatalogDbClientPortChanger("http://localhost:" + client.wiremockPort, msoAdaptersAuth, client.wiremockPort);
404 CloudSite cloudSite = new CloudSite();
405 cloudSite.setId("MTN6");
406 cloudSite.setClli("TESTCLLI");
407 cloudSite.setRegionId("regionId");
408 cloudSite.setCloudVersion("VERSION");
409 cloudSite.setPlatform("PLATFORM");
411 CloudIdentity cloudIdentity = new CloudIdentity();
412 cloudIdentity.setId("RANDOMID");
413 cloudIdentity.setIdentityUrl("URL");
414 cloudIdentity.setMsoId("MSO_ID");
415 cloudIdentity.setMsoPass("MSO_PASS");
416 cloudIdentity.setAdminTenant("ADMIN_TENANT");
417 cloudIdentity.setMemberRole("ROLE");
418 cloudIdentity.setIdentityServerType(ServerType.KEYSTONE);
419 cloudIdentity.setIdentityAuthenticationType(AuthenticationType.RACKSPACE_APIKEY);
420 cloudSite.setIdentityService(cloudIdentity);
421 localClient.postCloudSite(cloudSite);
422 CloudSite getCloudSite = this.client.getCloudSite("MTN6");
423 Assert.assertNotNull(getCloudSite);
424 Assert.assertNotNull(getCloudSite.getIdentityService());
425 Assert.assertEquals("TESTCLLI", getCloudSite.getClli());
426 Assert.assertEquals("regionId", getCloudSite.getRegionId());
427 Assert.assertEquals("RANDOMID", getCloudSite.getIdentityServiceId());
431 public void testGetHomingInstance() {
432 HomingInstance homingInstance = client.getHomingInstance("5df8b6de-2083-11e7-93ae-92361f232671");
433 Assert.assertNotNull(homingInstance);
434 Assert.assertNotNull(homingInstance.getCloudOwner());
435 Assert.assertNotNull(homingInstance.getCloudRegionId());
436 Assert.assertNotNull(homingInstance.getOofDirectives());
440 public void testPostHomingInstance() {
441 CatalogDbClientPortChanger localClient = new CatalogDbClientPortChanger("http://localhost:" + client.wiremockPort, msoAdaptersAuth, client.wiremockPort);
442 HomingInstance homingInstance = new HomingInstance();
443 homingInstance.setServiceInstanceId("5df8d6be-2083-11e7-93ae-92361f232671");
444 homingInstance.setCloudOwner("CloudOwner-1");
445 homingInstance.setCloudRegionId("CloudRegionOne");
446 homingInstance.setOofDirectives("{\n" +
447 "\"directives\": [\n" +
449 "\"directives\": [\n" +
451 "\"attributes\": [\n" +
453 "\"attribute_value\": \"onap.hpa.flavor31\",\n" +
454 "\"attribute_name\": \"firewall_flavor_name\"\n" +
457 "\"type\": \"flavor_directives\"\n" +
460 "\"type\": \"vnfc\",\n" +
461 "\"id\": \"vfw\"\n" +
464 "\"directives\": [\n" +
466 "\"attributes\": [\n" +
468 "\"attribute_value\": \"onap.hpa.flavor32\",\n" +
469 "\"attribute_name\": \"packetgen_flavor_name\"\n" +
472 "\"type\": \"flavor_directives\"\n" +
475 "\"type\": \"vnfc\",\n" +
476 "\"id\": \"vgenerator\"\n" +
479 "\"directives\": [\n" +
481 "\"attributes\": [\n" +
483 "\"attribute_value\": \"onap.hpa.flavor31\",\n" +
484 "\"attribute_name\": \"sink_flavor_name\"\n" +
487 "\"type\": \"flavor_directives\"\n" +
490 "\"type\": \"vnfc\",\n" +
491 "\"id\": \"vsink\"\n" +
495 localClient.postHomingInstance(homingInstance);
496 HomingInstance getHomingInstance = this.client.getHomingInstance("5df8d6be-2083-11e7-93ae-92361f232671");
497 Assert.assertNotNull(getHomingInstance);
498 Assert.assertNotNull(getHomingInstance.getCloudRegionId());
499 Assert.assertNotNull(getHomingInstance.getCloudOwner());
500 Assert.assertEquals("CloudOwner-1", getHomingInstance.getCloudOwner());
501 Assert.assertEquals("CloudRegionOne", getHomingInstance.getCloudRegionId());
505 public void testGetServiceByModelName() {
506 Service service = client.getServiceByModelName("MSOTADevInfra_Test_Service");
507 Assert.assertNotNull(service);
508 Assert.assertNotNull(service.getModelVersion());
509 Assert.assertNotNull(service.getModelInvariantUUID());
510 Assert.assertEquals("MSOTADevInfra_Test_Service", service.getModelName());
511 Assert.assertEquals("NA", service.getServiceRole());
515 public void testGetServiceByModelNameNotFound() {
516 Service service = client.getServiceByModelName("Not_Found");
517 Assert.assertNull(service);
521 public void testGetServiceByModelUUID() {
522 Service service = client.getServiceByModelUUID("5df8b6de-2083-11e7-93ae-92361f002679");
523 Assert.assertNotNull(service);
524 Assert.assertNotNull(service.getModelVersion());
525 Assert.assertNotNull(service.getModelInvariantUUID());
526 Assert.assertEquals("5df8b6de-2083-11e7-93ae-92361f002679", service.getModelUUID());
527 Assert.assertEquals("NA", service.getServiceRole());
531 public void testGetServiceByModelUUIDNotFound() {
532 Service service = client.getServiceByModelUUID("Not_Found");
533 Assert.assertNull(service);
537 public void testGetNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner(){
538 NorthBoundRequest northBoundRequest = new NorthBoundRequest();
539 northBoundRequest.setAction("createService");
540 northBoundRequest.setRequestScope("service");
541 northBoundRequest.setIsAlacarte(true);
542 northBoundRequest.setCloudOwner("my-custom-cloud-owner");
543 client.getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner("createService", "service", true, "my-custom-cloud-owner");
544 Assert.assertNotNull(northBoundRequest);
545 Assert.assertEquals("createService",northBoundRequest.getAction());
546 Assert.assertEquals("service",northBoundRequest.getRequestScope());
547 Assert.assertEquals(true,northBoundRequest.getIsAlacarte() );
548 Assert.assertEquals("my-custom-cloud-owner", northBoundRequest.getCloudOwner());
552 public void testFindServiceRecipeByActionAndServiceModelUUID() {
553 ServiceRecipe serviceRecipe = client.findServiceRecipeByActionAndServiceModelUUID("createInstance","4694a55f-58b3-4f17-92a5-796d6f5ffd0d" );
554 Assert.assertNotNull(serviceRecipe);
555 Assert.assertNotNull(serviceRecipe.getServiceModelUUID());
556 Assert.assertNotNull(serviceRecipe.getAction());
557 Assert.assertEquals("/mso/async/services/CreateGenericALaCarteServiceInstance", serviceRecipe.getOrchestrationUri());
558 Assert.assertEquals("MSOTADevInfra aLaCarte", serviceRecipe.getDescription());
562 public void testFindServiceRecipeByActionAndServiceModelUUIDNotFound() {
563 ServiceRecipe serviceRecipe = client.findServiceRecipeByActionAndServiceModelUUID("not_found","5df8b6de-2083-11e7-93ae-test" );
564 Assert.assertNull(serviceRecipe);
568 public void testFindExternalToInternalServiceByServiceName() {
569 ExternalServiceToInternalService externalServiceToInternalService = client.findExternalToInternalServiceByServiceName("MySpecialServiceName");
570 Assert.assertNotNull(externalServiceToInternalService);
571 Assert.assertNotNull(externalServiceToInternalService.getServiceName());
572 Assert.assertNotNull(externalServiceToInternalService.getServiceModelUUID());
573 Assert.assertEquals("MySpecialServiceName", externalServiceToInternalService.getServiceName());
577 public void testFindExternalToInternalServiceByServiceNameNotFound() {
578 ExternalServiceToInternalService externalServiceToInternalService = client.findExternalToInternalServiceByServiceName("Not_Found");
579 Assert.assertNull(externalServiceToInternalService);