2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 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.bpmn.servicedecomposition.tasks;
23 import static com.shazam.shazamcrest.MatcherAssert.assertThat;
24 import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs;
25 import static org.hamcrest.CoreMatchers.equalTo;
26 import static org.junit.Assert.assertFalse;
27 import static org.junit.Assert.assertTrue;
30 import java.io.IOException;
31 import java.util.ArrayList;
32 import java.util.Arrays;
33 import java.util.HashMap;
34 import java.util.List;
37 import org.junit.Test;
38 import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion;
39 import org.onap.so.bpmn.servicedecomposition.bbobjects.Collection;
40 import org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration;
41 import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer;
42 import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf;
43 import org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network;
44 import org.onap.so.bpmn.servicedecomposition.bbobjects.LineOfBusiness;
45 import org.onap.so.bpmn.servicedecomposition.bbobjects.NetworkPolicy;
46 import org.onap.so.bpmn.servicedecomposition.bbobjects.OwningEntity;
47 import org.onap.so.bpmn.servicedecomposition.bbobjects.Platform;
48 import org.onap.so.bpmn.servicedecomposition.bbobjects.Project;
49 import org.onap.so.bpmn.servicedecomposition.bbobjects.RouteTableReference;
50 import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance;
51 import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceSubscription;
52 import org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup;
53 import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey;
54 import org.onap.so.bpmn.servicedecomposition.generalobjects.OrchestrationContext;
55 import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext;
56 import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoCollection;
57 import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoConfiguration;
58 import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoGenericVnf;
59 import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoInstanceGroup;
60 import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoNetwork;
61 import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoServiceInstance;
62 import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoVfModule;
63 import org.onap.so.db.catalog.beans.CollectionNetworkResourceCustomization;
64 import org.onap.so.db.catalog.beans.CollectionResource;
65 import org.onap.so.db.catalog.beans.CollectionResourceCustomization;
66 import org.onap.so.db.catalog.beans.CollectionResourceInstanceGroupCustomization;
67 import org.onap.so.db.catalog.beans.ConfigurationResource;
68 import org.onap.so.db.catalog.beans.ConfigurationResourceCustomization;
69 import org.onap.so.db.catalog.beans.CvnfcCustomization;
70 import org.onap.so.db.catalog.beans.InstanceGroup;
71 import org.onap.so.db.catalog.beans.NetworkResourceCustomization;
72 import org.onap.so.db.catalog.beans.OrchestrationStatus;
73 import org.onap.so.db.catalog.beans.Service;
74 import org.onap.so.db.catalog.beans.VfModuleCustomization;
75 import org.onap.so.db.catalog.beans.VnfResourceCustomization;
76 import org.onap.so.db.catalog.beans.VnfVfmoduleCvnfcConfigurationCustomization;
77 import org.onap.so.db.catalog.beans.VnfcCustomization;
78 import org.onap.so.serviceinstancebeans.CloudConfiguration;
79 import org.onap.so.serviceinstancebeans.RequestDetails;
81 import com.fasterxml.jackson.core.JsonParseException;
82 import com.fasterxml.jackson.databind.JsonMappingException;
83 import com.fasterxml.jackson.databind.ObjectMapper;
85 public class BBInputSetupMapperLayerTest {
87 BBInputSetupMapperLayer bbInputSetupMapperLayer = new BBInputSetupMapperLayer();
89 ObjectMapper mapper = new ObjectMapper();
91 private static final String RESOURCE_PATH = "src/test/resources/__files/ExecuteBuildingBlock/";
94 public void testMapOrchestrationStatusFromAAI() {
95 OrchestrationStatus expected = OrchestrationStatus.INVENTORIED;
96 String orchStatusInput = "Inventoried";
97 OrchestrationStatus actual = bbInputSetupMapperLayer.mapOrchestrationStatusFromAAI(orchStatusInput);
98 assertThat(actual, sameBeanAs(expected));
100 expected = OrchestrationStatus.ASSIGNED;
101 orchStatusInput = "Assigned";
102 actual = bbInputSetupMapperLayer.mapOrchestrationStatusFromAAI(orchStatusInput);
103 assertThat(actual, sameBeanAs(expected));
105 expected = OrchestrationStatus.ACTIVE;
106 orchStatusInput = "Active";
107 actual = bbInputSetupMapperLayer.mapOrchestrationStatusFromAAI(orchStatusInput);
108 assertThat(actual, sameBeanAs(expected));
110 expected = OrchestrationStatus.CREATED;
111 orchStatusInput = "Created";
112 actual = bbInputSetupMapperLayer.mapOrchestrationStatusFromAAI(orchStatusInput);
113 assertThat(actual, sameBeanAs(expected));
115 expected = OrchestrationStatus.PRECREATED;
116 orchStatusInput = "PreCreated";
117 actual = bbInputSetupMapperLayer.mapOrchestrationStatusFromAAI(orchStatusInput);
118 assertThat(actual, sameBeanAs(expected));
120 expected = OrchestrationStatus.PENDING_CREATE;
121 orchStatusInput = "PendingCreate";
122 actual = bbInputSetupMapperLayer.mapOrchestrationStatusFromAAI(orchStatusInput);
123 assertThat(actual, sameBeanAs(expected));
125 expected = OrchestrationStatus.PENDING_DELETE;
126 orchStatusInput = "PendingDelete";
127 actual = bbInputSetupMapperLayer.mapOrchestrationStatusFromAAI(orchStatusInput);
128 assertThat(actual, sameBeanAs(expected));
130 expected = OrchestrationStatus.PENDING;
131 orchStatusInput = "Pending";
132 actual = bbInputSetupMapperLayer.mapOrchestrationStatusFromAAI(orchStatusInput);
133 assertThat(actual, sameBeanAs(expected));
135 expected = OrchestrationStatus.PENDING_ACTIVATION;
136 orchStatusInput = "PendingActivation";
137 actual = bbInputSetupMapperLayer.mapOrchestrationStatusFromAAI(orchStatusInput);
138 assertThat(actual, sameBeanAs(expected));
142 public void testMapOrchestrationFuzzyCases() {
143 List<String> values = Arrays.asList("pending-create", "pending_Create", "pendinggcreate", "PendingCreate");
144 values.forEach(value -> {
145 assertThat(bbInputSetupMapperLayer.mapOrchestrationStatusFromAAI(value), equalTo(OrchestrationStatus.PENDING_CREATE));
150 public void testMapAAICustomer() throws IOException {
151 Customer expected = mapper.readValue(
152 new File(RESOURCE_PATH+"Customer.json"),
155 org.onap.aai.domain.yang.Customer customerAAI = mapper.readValue(
156 new File(RESOURCE_PATH+"Customer_AAI.json"), org.onap.aai.domain.yang.Customer.class);
158 Customer actual = bbInputSetupMapperLayer.mapAAICustomer(customerAAI);
160 assertThat(actual, sameBeanAs(expected));
164 public void testMapAAIServiceSubscription() throws IOException {
165 ServiceSubscription expected = mapper.readValue(
166 new File(RESOURCE_PATH + "ServiceSubscriptionExpected.json"), ServiceSubscription.class);
168 org.onap.aai.domain.yang.ServiceSubscription svcSubscriptionAAI = mapper.readValue(
169 new File(RESOURCE_PATH + "ServiceSubscription_AAI.json"), org.onap.aai.domain.yang.ServiceSubscription.class);
171 ServiceSubscription actual = bbInputSetupMapperLayer.mapAAIServiceSubscription(svcSubscriptionAAI);
173 assertThat(actual, sameBeanAs(expected));
177 public void testMapAAIProject() throws IOException {
178 Project expected = mapper.readValue(new File(RESOURCE_PATH+"Project.json"),Project.class);
180 org.onap.aai.domain.yang.Project projectAAI = new org.onap.aai.domain.yang.Project();
181 projectAAI.setProjectName("projectName");
183 Project actual = bbInputSetupMapperLayer.mapAAIProject(projectAAI);
185 assertThat(actual, sameBeanAs(expected));
189 public void testMapRequestProject() throws IOException {
190 Project expected = mapper.readValue(new File(RESOURCE_PATH+"Project.json"),Project.class);
192 org.onap.so.serviceinstancebeans.Project requestProject = new org.onap.so.serviceinstancebeans.Project();
193 requestProject.setProjectName("projectName");
195 Project actual = bbInputSetupMapperLayer.mapRequestProject(requestProject);
197 assertThat(actual, sameBeanAs(expected));
201 public void testMapAAIOwningEntity() throws IOException {
202 OwningEntity expected = mapper.readValue(new File(RESOURCE_PATH+"OwningEntity.json"),OwningEntity.class);
204 org.onap.aai.domain.yang.OwningEntity entityAAI = new org.onap.aai.domain.yang.OwningEntity();
205 entityAAI.setOwningEntityId("owningEntityId");
206 entityAAI.setOwningEntityName("owningEntityName");
208 OwningEntity actual = bbInputSetupMapperLayer.mapAAIOwningEntity(entityAAI);
210 assertThat(actual, sameBeanAs(expected));
214 public void testMapRequestOwningEntity() throws IOException {
215 OwningEntity expected = mapper.readValue(new File(RESOURCE_PATH+"OwningEntity.json"),OwningEntity.class);
217 org.onap.so.serviceinstancebeans.OwningEntity requestOwningEntity = new org.onap.so.serviceinstancebeans.OwningEntity();
218 requestOwningEntity.setOwningEntityId("owningEntityId");
219 requestOwningEntity.setOwningEntityName("owningEntityName");
221 OwningEntity actual = bbInputSetupMapperLayer.mapRequestOwningEntity(requestOwningEntity);
223 assertThat(actual, sameBeanAs(expected));
227 public void testMapAAIPlatform() throws IOException {
228 Platform expected = mapper.readValue(new File(RESOURCE_PATH+"Platform.json"),Platform.class);
230 org.onap.aai.domain.yang.Platform platformAAI = new org.onap.aai.domain.yang.Platform();
231 platformAAI.setPlatformName("platformName");
233 Platform actual = bbInputSetupMapperLayer.mapAAIPlatform(platformAAI);
235 assertThat(actual, sameBeanAs(expected));
239 public void testMapAAILineOfBusiness() throws IOException {
240 LineOfBusiness expected = mapper.readValue(new File(RESOURCE_PATH+"LineOfBusiness.json"),LineOfBusiness.class);
242 org.onap.aai.domain.yang.LineOfBusiness lobAAI = new org.onap.aai.domain.yang.LineOfBusiness();
243 lobAAI.setLineOfBusinessName("lineOfBusinessName");
245 LineOfBusiness actual = bbInputSetupMapperLayer.mapAAILineOfBusiness(lobAAI);
247 assertThat(actual, sameBeanAs(expected));
251 public void testMapAAINetworkPolicy() throws JsonParseException, JsonMappingException, IOException {
252 NetworkPolicy expectedNetworkPolicy = mapper.readValue(new File(RESOURCE_PATH + "NetworkPolicy.json"), NetworkPolicy.class);
254 org.onap.aai.domain.yang.NetworkPolicy aaiNetworkPolicy = new org.onap.aai.domain.yang.NetworkPolicy();
255 aaiNetworkPolicy.setNetworkPolicyId("networkPolicyId");
256 aaiNetworkPolicy.setNetworkPolicyFqdn("networkPolicyFqdn");
257 aaiNetworkPolicy.setHeatStackId("heatStackId");
258 aaiNetworkPolicy.setResourceVersion("resourceVersion");
260 NetworkPolicy actualNetworkPolicy = bbInputSetupMapperLayer.mapAAINetworkPolicy(aaiNetworkPolicy);
262 assertThat(actualNetworkPolicy, sameBeanAs(expectedNetworkPolicy));
266 public void testMapAAIVolumeGroup() throws JsonParseException, JsonMappingException, IOException {
267 VolumeGroup expectedVolumeGroup = mapper.readValue(new File(RESOURCE_PATH + "VolumeGroup.json"), VolumeGroup.class);
269 org.onap.aai.domain.yang.VolumeGroup aaiVolumeGroup = mapper.readValue(
270 new File(RESOURCE_PATH + "VolumeGroup_AAI.json"), org.onap.aai.domain.yang.VolumeGroup.class);
272 VolumeGroup actualVolumeGroup = bbInputSetupMapperLayer.mapAAIVolumeGroup(aaiVolumeGroup);
274 assertThat(actualVolumeGroup, sameBeanAs(expectedVolumeGroup));
278 public void testMapCatalogServiceIntoServiceInstance() throws IOException {
279 ModelInfoServiceInstance expected = mapper.readValue(
280 new File(RESOURCE_PATH + "ModelInfoServiceInstance.json"),
281 ModelInfoServiceInstance.class);
283 Service catalogService = mapper.readValue(
284 new File(RESOURCE_PATH + "CatalogServiceInput.json"), Service.class);
286 ModelInfoServiceInstance actual = bbInputSetupMapperLayer.mapCatalogServiceIntoServiceInstance(catalogService);
288 assertThat(actual, sameBeanAs(expected));
292 public void testMapCatalogInstanceGroupToInstanceGroup() throws IOException {
293 ModelInfoInstanceGroup expected = mapper.readValue(
294 new File(RESOURCE_PATH + "ModelInfoInstanceGroup.json"),
295 ModelInfoInstanceGroup.class);
297 InstanceGroup instanceGroup = mapper.readValue(
298 new File(RESOURCE_PATH + "InstanceGroup.json"), InstanceGroup.class);
299 instanceGroup.setCollectionInstanceGroupCustomizations(new ArrayList<>());
300 CollectionResourceInstanceGroupCustomization collectionInstanceGroupCust = new CollectionResourceInstanceGroupCustomization();
301 collectionInstanceGroupCust.setModelCustomizationUUID("modelCustomizationUUID");
302 collectionInstanceGroupCust.setFunction("function");
303 collectionInstanceGroupCust.setDescription("description");
304 instanceGroup.getCollectionInstanceGroupCustomizations().add(collectionInstanceGroupCust);
305 CollectionResourceCustomization collectionResourceCust = new CollectionResourceCustomization();
306 collectionResourceCust.setModelCustomizationUUID("modelCustomizationUUID");
307 ModelInfoInstanceGroup actual = bbInputSetupMapperLayer.mapCatalogInstanceGroupToInstanceGroup(collectionResourceCust, instanceGroup);
309 assertThat(actual, sameBeanAs(expected));
313 public void testMapCollectionNetworkResourceCustToNetworkResourceCust() {
314 String modelCustomizationUUID = "modelCustomizationUUID";
315 String modelInstanceName = "modelInstanceName";
316 String networkRole = "networkRole";
317 String networkScope = "networkScope";
318 String networkTechnology = "networkTechnology";
319 String networkType = "networkType";
321 NetworkResourceCustomization expected = new NetworkResourceCustomization();
322 expected.setModelCustomizationUUID(modelCustomizationUUID);
323 expected.setModelInstanceName(modelInstanceName);
324 expected.setNetworkRole(networkRole);
325 expected.setNetworkScope(networkScope);
326 expected.setNetworkTechnology(networkTechnology);
327 expected.setNetworkType(networkType);
328 CollectionNetworkResourceCustomization collectionNetworkResourceCust = new CollectionNetworkResourceCustomization();
329 collectionNetworkResourceCust.setModelCustomizationUUID(modelCustomizationUUID);
330 collectionNetworkResourceCust.setModelInstanceName(modelInstanceName);
331 collectionNetworkResourceCust.setNetworkRole(networkRole);
332 collectionNetworkResourceCust.setNetworkScope(networkScope);
333 collectionNetworkResourceCust.setNetworkTechnology(networkTechnology);
334 collectionNetworkResourceCust.setNetworkType(networkType);
335 NetworkResourceCustomization actual = bbInputSetupMapperLayer.mapCollectionNetworkResourceCustToNetworkResourceCust(collectionNetworkResourceCust);
337 assertThat(actual, sameBeanAs(expected));
341 public void testMapCatalogCollectionToCollection() throws IOException {
342 ModelInfoCollection expected = mapper.readValue(
343 new File(RESOURCE_PATH + "ModelInfoCollection.json"),
344 ModelInfoCollection.class);
346 CollectionResourceCustomization collectionCust = mapper.readValue(
347 new File(RESOURCE_PATH + "CollectionResourceCustomization.json"),
348 CollectionResourceCustomization.class);
350 CollectionResource collectionResource = mapper.readValue(
351 new File(RESOURCE_PATH + "CollectionResource.json"),
352 CollectionResource.class);
354 ModelInfoCollection actual = bbInputSetupMapperLayer.mapCatalogCollectionToCollection(collectionCust, collectionResource);
356 assertThat(actual, sameBeanAs(expected));
360 public void testMapAAIServiceInstanceIntoServiceInstance() throws IOException {
361 ServiceInstance expected = mapper.readValue(
362 new File(RESOURCE_PATH + "ServiceInstance_aaiServiceInstanceToSI.json"),
363 ServiceInstance.class);
365 org.onap.aai.domain.yang.ServiceInstance serviceInstanceAAI = mapper.readValue(
366 new File(RESOURCE_PATH + "ServiceInstanceAAIInput.json"),
367 org.onap.aai.domain.yang.ServiceInstance.class);
369 ServiceInstance actual = bbInputSetupMapperLayer.mapAAIServiceInstanceIntoServiceInstance(serviceInstanceAAI);
371 assertThat(actual, sameBeanAs(expected));
375 public void testSetPlatformAndLOB() throws IOException {
376 ServiceInstance expected = mapper.readValue(
377 new File(RESOURCE_PATH + "ServiceInstance_aaiPlatformAndLOBToSI.json"),
378 ServiceInstance.class);
380 Map<ResourceKey, String> resourcesToBeOrchestrated = new HashMap<>();
381 resourcesToBeOrchestrated.put(ResourceKey.GENERIC_VNF_ID, "vnfId");
382 Platform platformMSO = new Platform();
383 platformMSO.setPlatformName("platformName");
384 LineOfBusiness lineOfBusinessMSO = new LineOfBusiness();
385 lineOfBusinessMSO.setLineOfBusinessName("lineOfBusinessName");
387 ServiceInstance actual = mapper.readValue(
388 new File(RESOURCE_PATH + "ServiceInstanceAAIPlatformAndLOBInput.json"),
389 ServiceInstance.class);
391 bbInputSetupMapperLayer.setPlatformAndLOBIntoServiceInstance(platformMSO, lineOfBusinessMSO, actual,
392 resourcesToBeOrchestrated);
394 assertThat(actual, sameBeanAs(expected));
398 public void testMapAAIL3NetworkIntoL3Network() throws IOException {
399 L3Network expected = mapper.readValue(
400 new File(RESOURCE_PATH + "l3NetworkExpected.json"), L3Network.class);
402 org.onap.aai.domain.yang.L3Network aaiL3Network = mapper.readValue(
403 new File(RESOURCE_PATH + "aaiL3NetworkInput.json"),
404 org.onap.aai.domain.yang.L3Network.class);
406 L3Network actual = bbInputSetupMapperLayer.mapAAIL3Network(aaiL3Network);
408 assertThat(actual, sameBeanAs(expected));
412 public void testMapAAIGenericVnfIntoGenericVnf() throws IOException {
413 GenericVnf expected = mapper.readValue(new File(RESOURCE_PATH + "GenericVnfExpected.json"), GenericVnf.class);
414 org.onap.aai.domain.yang.GenericVnf aaiGenericVnf = mapper.readValue(
415 new File(RESOURCE_PATH + "aaiGenericVnfInput.json"), org.onap.aai.domain.yang.GenericVnf.class);
417 GenericVnf actual = bbInputSetupMapperLayer.mapAAIGenericVnfIntoGenericVnf(aaiGenericVnf);
419 assertThat(actual, sameBeanAs(expected));
423 public void testMapAAICollectionIntoCollection() throws JsonParseException, JsonMappingException, IOException {
424 org.onap.aai.domain.yang.Collection aaiCollection = mapper.readValue(
425 new File(RESOURCE_PATH + "CollectionInput.json"), org.onap.aai.domain.yang.Collection.class);
427 Collection expectedCollection = mapper.readValue(new File(RESOURCE_PATH + "CollectionExpected.json"), Collection.class);
429 Collection actualCollection = bbInputSetupMapperLayer.mapAAICollectionIntoCollection(aaiCollection);
431 assertThat(actualCollection, sameBeanAs(expectedCollection));
435 public void testMapAAIInstanceGroupIntoInstanceGroup() throws JsonParseException, JsonMappingException, IOException {
436 org.onap.aai.domain.yang.InstanceGroup aaiInstanceGroup = mapper.readValue(
437 new File(RESOURCE_PATH + "InstanceGroupInput.json"), org.onap.aai.domain.yang.InstanceGroup.class);
439 org.onap.so.bpmn.servicedecomposition.bbobjects.InstanceGroup expectedInstanceGroup = mapper.readValue(
440 new File(RESOURCE_PATH + "InstanceGroupExpected.json"), org.onap.so.bpmn.servicedecomposition.bbobjects.InstanceGroup.class);
442 org.onap.so.bpmn.servicedecomposition.bbobjects.InstanceGroup actualInstanceGroup =
443 bbInputSetupMapperLayer.mapAAIInstanceGroupIntoInstanceGroup(aaiInstanceGroup);
445 assertThat(actualInstanceGroup, sameBeanAs(expectedInstanceGroup));
449 public void testMapAAIRouteTableReferenceIntoRouteTableReference() throws JsonParseException, JsonMappingException, IOException {
450 org.onap.aai.domain.yang.RouteTableReference aaiRouteTableReference = mapper.readValue(
451 new File(RESOURCE_PATH + "RouteTableReferenceInput.json"), org.onap.aai.domain.yang.RouteTableReference.class);
453 RouteTableReference expectedRouteTableReference = mapper.readValue(
454 new File(RESOURCE_PATH + "RouteTableReferenceExpected.json"), RouteTableReference.class);
456 RouteTableReference actualRouteTableReference = bbInputSetupMapperLayer.mapAAIRouteTableReferenceIntoRouteTableReference(aaiRouteTableReference);
458 assertThat(actualRouteTableReference, sameBeanAs(expectedRouteTableReference));
462 public void testMapCatalogNetworkToNetwork() throws JsonParseException, JsonMappingException, IOException {
463 NetworkResourceCustomization networkResourceCustomization = mapper.readValue(
464 new File(RESOURCE_PATH + "NetworkResourceCustomizationInput.json"), NetworkResourceCustomization.class);
466 ModelInfoNetwork expectedModelInfoNetwork = mapper.readValue(
467 new File(RESOURCE_PATH + "ModelInfoNetworkExpected.json"), ModelInfoNetwork.class);
469 ModelInfoNetwork actualModelInfoNetwork = bbInputSetupMapperLayer.mapCatalogNetworkToNetwork(networkResourceCustomization);
471 assertThat(actualModelInfoNetwork, sameBeanAs(expectedModelInfoNetwork));
475 public void testMapCatalogVnfToVnf() throws IOException {
476 VnfResourceCustomization vnfResourceCustomization = mapper.readValue(
477 new File(RESOURCE_PATH + "VnfResourceCustomizationInput.json"), VnfResourceCustomization.class);
479 ModelInfoGenericVnf expectedModelInfoGenericVnf = mapper.readValue(
480 new File(RESOURCE_PATH + "ModelInfoGenericVnfExpected.json"), ModelInfoGenericVnf.class);
482 ModelInfoGenericVnf actualModelInfoGenericVnf = bbInputSetupMapperLayer.mapCatalogVnfToVnf(vnfResourceCustomization);
484 assertThat(actualModelInfoGenericVnf, sameBeanAs(expectedModelInfoGenericVnf));
488 public void testMapCatalogVfModuleToVfModule() throws JsonParseException, JsonMappingException, IOException {
489 VfModuleCustomization vfResourceCustomization = mapper.readValue(
490 new File(RESOURCE_PATH + "VfModuleCustomizationInput.json"), VfModuleCustomization.class);
492 ModelInfoVfModule expectedModelInfoVfModule = mapper.readValue(new File(RESOURCE_PATH + "ModelInfoVfModuleExpected.json"), ModelInfoVfModule.class);
494 ModelInfoVfModule actualModelInfoVfModule = bbInputSetupMapperLayer.mapCatalogVfModuleToVfModule(vfResourceCustomization);
496 assertThat(actualModelInfoVfModule, sameBeanAs(expectedModelInfoVfModule));
500 public void testMapRequestPlatform() throws JsonParseException, JsonMappingException, IOException {
501 org.onap.so.serviceinstancebeans.Platform platform = mapper.readValue(
502 new File(RESOURCE_PATH + "RequestPlatformInput.json"), org.onap.so.serviceinstancebeans.Platform.class);
504 Platform expectedPlatform = mapper.readValue(new File(RESOURCE_PATH + "PlatformExpected.json"), Platform.class);
506 Platform actualPlatform = bbInputSetupMapperLayer.mapRequestPlatform(platform);
508 assertThat(actualPlatform, sameBeanAs(expectedPlatform));
512 public void testMapRequestLineOfBusiness() throws JsonParseException, JsonMappingException, IOException {
513 org.onap.so.serviceinstancebeans.LineOfBusiness lineOfBusiness = mapper.readValue(
514 new File(RESOURCE_PATH + "RequestLineOfBusinessInput.json"), org.onap.so.serviceinstancebeans.LineOfBusiness.class);
516 LineOfBusiness expectedLineOfBusiness = mapper.readValue(new File(RESOURCE_PATH + "LineOfBusinessExpected.json"), LineOfBusiness.class);
518 LineOfBusiness actualLineOfBusiness = bbInputSetupMapperLayer.mapRequestLineOfBusiness(lineOfBusiness);
520 assertThat(actualLineOfBusiness, sameBeanAs(expectedLineOfBusiness));
524 public void testMapAAIConfiguration() throws JsonParseException, JsonMappingException, IOException {
525 org.onap.aai.domain.yang.Configuration configurationAAI = mapper.readValue(
526 new File(RESOURCE_PATH + "ConfigurationInput.json"), org.onap.aai.domain.yang.Configuration.class);
528 Configuration expectedConfiguration = mapper.readValue(
529 new File(RESOURCE_PATH + "ConfigurationExpected.json"), Configuration.class);
531 Configuration actualConfiguration = bbInputSetupMapperLayer.mapAAIConfiguration(configurationAAI);
533 assertThat(actualConfiguration, sameBeanAs(expectedConfiguration));
537 public void testMapRequestContext() throws IOException {
538 RequestContext expected = mapper.readValue(
539 new File(RESOURCE_PATH + "RequestContextExpected.json"),
540 RequestContext.class);
542 RequestDetails requestDetails = mapper.readValue(
543 new File(RESOURCE_PATH + "RequestDetailsInput_mapReqContext.json"),
544 RequestDetails.class);
545 RequestContext actual = bbInputSetupMapperLayer.mapRequestContext(requestDetails);
547 assertThat(actual, sameBeanAs(expected));
551 public void testMapOrchestrationContext() throws IOException {
552 OrchestrationContext expected = new OrchestrationContext();
553 expected.setIsRollbackEnabled(true);
555 RequestDetails requestDetails = mapper.readValue(new File(RESOURCE_PATH + "RequestDetailsInput_mapReqContext.json"), RequestDetails.class);
557 OrchestrationContext actual = bbInputSetupMapperLayer.mapOrchestrationContext(requestDetails);
559 assertThat(actual, sameBeanAs(expected));
563 public void testMapLocationContext() {
564 CloudRegion expected = new CloudRegion();
565 expected.setCloudOwner("test-owner-name");
566 expected.setLcpCloudRegionId("cloudRegionId");
567 expected.setComplex("complexName");
568 expected.setTenantId("tenantId");
569 CloudConfiguration cloudConfig = new CloudConfiguration();
570 cloudConfig.setTenantId("tenantId");
571 cloudConfig.setLcpCloudRegionId("cloudRegionId");
572 cloudConfig.setAicNodeClli("aicNodeClli");
573 org.onap.aai.domain.yang.CloudRegion cloudRegion = new org.onap.aai.domain.yang.CloudRegion();
574 cloudRegion.setCloudOwner("test-owner-name");
575 cloudRegion.setCloudRegionId("cloudRegionId");
576 cloudRegion.setComplexName("complexName");
578 CloudRegion actual = bbInputSetupMapperLayer.mapCloudRegion(cloudConfig, cloudRegion);
580 assertThat(actual, sameBeanAs(expected));
584 public void testMapCloudRegion() {
585 CloudRegion expected = new CloudRegion();
586 expected.setCloudOwner("test-owner-name");
587 expected.setLcpCloudRegionId("cloudRegionId");
588 expected.setTenantId("tenantId");
589 expected.setCloudRegionVersion("cloudRegionVersion");
591 CloudConfiguration cloudConfig = new CloudConfiguration();
592 cloudConfig.setTenantId("tenantId");
593 cloudConfig.setLcpCloudRegionId("cloudRegionId");
594 cloudConfig.setAicNodeClli("aicNodeClli");
596 org.onap.aai.domain.yang.CloudRegion cloudRegion = new org.onap.aai.domain.yang.CloudRegion();
597 cloudRegion.setCloudOwner("test-owner-name");
598 cloudRegion.setCloudRegionId("cloudRegionId");
599 cloudRegion.setCloudRegionVersion("cloudRegionVersion");
601 CloudRegion actual = bbInputSetupMapperLayer.mapCloudRegion(cloudConfig, cloudRegion);
603 assertThat(actual, sameBeanAs(expected));
607 public void testMapCloudRegionWithNullCheck() {
608 CloudRegion expected = new CloudRegion();
610 CloudRegion actual = bbInputSetupMapperLayer.mapCloudRegion(null, null);
612 assertThat(actual, sameBeanAs(expected));
616 public void testmapCatalogConfigurationToConfiguration() {
617 String modelCustUUID = "modelCustomizationUUID";
618 String modelInvariantUUID = "modelInvariantUUID";
619 String modelVersionUUID = "modelUUID";
620 String policyName = "policyName";
621 ModelInfoConfiguration expected = new ModelInfoConfiguration();
622 expected.setModelCustomizationId(modelCustUUID);
623 expected.setModelInvariantId(modelInvariantUUID);
624 expected.setModelVersionId(modelVersionUUID);
625 expected.setPolicyName(policyName);
626 ConfigurationResourceCustomization configurationResourceCustomization = new ConfigurationResourceCustomization();
627 configurationResourceCustomization.setModelCustomizationUUID(modelCustUUID);
628 configurationResourceCustomization.setConfigurationResource(new ConfigurationResource());
629 configurationResourceCustomization.getConfigurationResource().setModelInvariantUUID(modelInvariantUUID);
630 configurationResourceCustomization.getConfigurationResource().setModelUUID(modelVersionUUID);
631 VnfVfmoduleCvnfcConfigurationCustomization policyNameTable = new VnfVfmoduleCvnfcConfigurationCustomization();
632 policyNameTable.setCvnfcCustomization(new CvnfcCustomization());
633 policyNameTable.getCvnfcCustomization().setVnfcCustomization(new VnfcCustomization());
634 policyNameTable.setPolicyName(policyName);
636 ModelInfoConfiguration actual = bbInputSetupMapperLayer.mapCatalogConfigurationToConfiguration(configurationResourceCustomization, policyNameTable);
638 assertThat(actual, sameBeanAs(expected));
642 public void testMapNameValueUserParams() throws IOException {
643 RequestDetails requestDetails = mapper.readValue(new File(RESOURCE_PATH + "RequestDetailsInput_mapReqContext.json"), RequestDetails.class);
644 HashMap<String,String> actual = bbInputSetupMapperLayer.mapNameValueUserParams(requestDetails.getRequestParameters());
646 assertTrue(actual.containsKey("name1"));
647 assertTrue(actual.containsValue("value1"));
648 assertTrue(actual.get("name1").equals("value1"));
649 assertTrue(actual.containsKey("name2"));
650 assertTrue(actual.containsValue("value2"));
651 assertTrue(actual.get("name2").equals("value2"));
652 assertFalse(actual.containsKey("ignore"));
653 assertFalse(actual.containsValue("ignore"));