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.assertEquals;
27 import static org.junit.Assert.assertFalse;
28 import static org.junit.Assert.assertTrue;
31 import java.io.IOException;
32 import java.util.ArrayList;
33 import java.util.Arrays;
34 import java.util.HashMap;
35 import java.util.List;
38 import org.junit.Test;
39 import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion;
40 import org.onap.so.bpmn.servicedecomposition.bbobjects.Collection;
41 import org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration;
42 import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer;
43 import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf;
44 import org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network;
45 import org.onap.so.bpmn.servicedecomposition.bbobjects.LineOfBusiness;
46 import org.onap.so.bpmn.servicedecomposition.bbobjects.NetworkPolicy;
47 import org.onap.so.bpmn.servicedecomposition.bbobjects.OwningEntity;
48 import org.onap.so.bpmn.servicedecomposition.bbobjects.Platform;
49 import org.onap.so.bpmn.servicedecomposition.bbobjects.Project;
50 import org.onap.so.bpmn.servicedecomposition.bbobjects.RouteTableReference;
51 import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance;
52 import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceSubscription;
53 import org.onap.so.bpmn.servicedecomposition.bbobjects.Tenant;
54 import org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup;
55 import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey;
56 import org.onap.so.bpmn.servicedecomposition.generalobjects.OrchestrationContext;
57 import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext;
58 import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestParameters;
59 import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoCollection;
60 import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoConfiguration;
61 import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoGenericVnf;
62 import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoInstanceGroup;
63 import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoNetwork;
64 import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoServiceInstance;
65 import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoVfModule;
66 import org.onap.so.db.catalog.beans.CollectionNetworkResourceCustomization;
67 import org.onap.so.db.catalog.beans.CollectionResource;
68 import org.onap.so.db.catalog.beans.CollectionResourceCustomization;
69 import org.onap.so.db.catalog.beans.CollectionResourceInstanceGroupCustomization;
70 import org.onap.so.db.catalog.beans.ConfigurationResource;
71 import org.onap.so.db.catalog.beans.ConfigurationResourceCustomization;
72 import org.onap.so.db.catalog.beans.CvnfcConfigurationCustomization;
73 import org.onap.so.db.catalog.beans.CvnfcCustomization;
74 import org.onap.so.db.catalog.beans.InstanceGroup;
75 import org.onap.so.db.catalog.beans.NetworkResourceCustomization;
76 import org.onap.so.db.catalog.beans.OrchestrationStatus;
77 import org.onap.so.db.catalog.beans.Service;
78 import org.onap.so.db.catalog.beans.VfModuleCustomization;
79 import org.onap.so.db.catalog.beans.VnfResourceCustomization;
80 import org.onap.so.db.catalog.beans.CvnfcConfigurationCustomization;
81 import org.onap.so.db.catalog.beans.VnfcCustomization;
82 import org.onap.so.serviceinstancebeans.CloudConfiguration;
83 import org.onap.so.serviceinstancebeans.RequestDetails;
85 import com.fasterxml.jackson.core.JsonParseException;
86 import com.fasterxml.jackson.databind.JsonMappingException;
87 import com.fasterxml.jackson.databind.ObjectMapper;
89 public class BBInputSetupMapperLayerTest {
91 BBInputSetupMapperLayer bbInputSetupMapperLayer = new BBInputSetupMapperLayer();
93 ObjectMapper mapper = new ObjectMapper();
95 private static final String RESOURCE_PATH = "src/test/resources/__files/ExecuteBuildingBlock/";
98 public void testMapOrchestrationStatusFromAAI() {
99 OrchestrationStatus expected = OrchestrationStatus.INVENTORIED;
100 String orchStatusInput = "Inventoried";
101 OrchestrationStatus actual = bbInputSetupMapperLayer.mapOrchestrationStatusFromAAI(orchStatusInput);
102 assertThat(actual, sameBeanAs(expected));
104 expected = OrchestrationStatus.ASSIGNED;
105 orchStatusInput = "Assigned";
106 actual = bbInputSetupMapperLayer.mapOrchestrationStatusFromAAI(orchStatusInput);
107 assertThat(actual, sameBeanAs(expected));
109 expected = OrchestrationStatus.ACTIVE;
110 orchStatusInput = "Active";
111 actual = bbInputSetupMapperLayer.mapOrchestrationStatusFromAAI(orchStatusInput);
112 assertThat(actual, sameBeanAs(expected));
114 expected = OrchestrationStatus.CREATED;
115 orchStatusInput = "Created";
116 actual = bbInputSetupMapperLayer.mapOrchestrationStatusFromAAI(orchStatusInput);
117 assertThat(actual, sameBeanAs(expected));
119 expected = OrchestrationStatus.PRECREATED;
120 orchStatusInput = "PreCreated";
121 actual = bbInputSetupMapperLayer.mapOrchestrationStatusFromAAI(orchStatusInput);
122 assertThat(actual, sameBeanAs(expected));
124 expected = OrchestrationStatus.PENDING_CREATE;
125 orchStatusInput = "PendingCreate";
126 actual = bbInputSetupMapperLayer.mapOrchestrationStatusFromAAI(orchStatusInput);
127 assertThat(actual, sameBeanAs(expected));
129 expected = OrchestrationStatus.PENDING_DELETE;
130 orchStatusInput = "PendingDelete";
131 actual = bbInputSetupMapperLayer.mapOrchestrationStatusFromAAI(orchStatusInput);
132 assertThat(actual, sameBeanAs(expected));
134 expected = OrchestrationStatus.PENDING;
135 orchStatusInput = "Pending";
136 actual = bbInputSetupMapperLayer.mapOrchestrationStatusFromAAI(orchStatusInput);
137 assertThat(actual, sameBeanAs(expected));
139 expected = OrchestrationStatus.PENDING_ACTIVATION;
140 orchStatusInput = "PendingActivation";
141 actual = bbInputSetupMapperLayer.mapOrchestrationStatusFromAAI(orchStatusInput);
142 assertThat(actual, sameBeanAs(expected));
146 public void testMapOrchestrationFuzzyCases() {
147 List<String> values = Arrays.asList("pending-create", "pending_Create", "pendinggcreate", "PendingCreate");
148 values.forEach(value -> {
149 assertThat(bbInputSetupMapperLayer.mapOrchestrationStatusFromAAI(value), equalTo(OrchestrationStatus.PENDING_CREATE));
154 public void testMapAAICustomer() throws IOException {
155 Customer expected = mapper.readValue(
156 new File(RESOURCE_PATH+"Customer.json"),
159 org.onap.aai.domain.yang.Customer customerAAI = mapper.readValue(
160 new File(RESOURCE_PATH+"Customer_AAI.json"), org.onap.aai.domain.yang.Customer.class);
162 Customer actual = bbInputSetupMapperLayer.mapAAICustomer(customerAAI);
164 assertThat(actual, sameBeanAs(expected));
168 public void testMapAAIServiceSubscription() throws IOException {
169 ServiceSubscription expected = mapper.readValue(
170 new File(RESOURCE_PATH + "ServiceSubscriptionExpected.json"), ServiceSubscription.class);
172 org.onap.aai.domain.yang.ServiceSubscription svcSubscriptionAAI = mapper.readValue(
173 new File(RESOURCE_PATH + "ServiceSubscription_AAI.json"), org.onap.aai.domain.yang.ServiceSubscription.class);
175 ServiceSubscription actual = bbInputSetupMapperLayer.mapAAIServiceSubscription(svcSubscriptionAAI);
177 assertThat(actual, sameBeanAs(expected));
181 public void testMapAAIProject() throws IOException {
182 Project expected = mapper.readValue(new File(RESOURCE_PATH+"Project.json"),Project.class);
184 org.onap.aai.domain.yang.Project projectAAI = new org.onap.aai.domain.yang.Project();
185 projectAAI.setProjectName("projectName");
187 Project actual = bbInputSetupMapperLayer.mapAAIProject(projectAAI);
189 assertThat(actual, sameBeanAs(expected));
193 public void testMapRequestProject() throws IOException {
194 Project expected = mapper.readValue(new File(RESOURCE_PATH+"Project.json"),Project.class);
196 org.onap.so.serviceinstancebeans.Project requestProject = new org.onap.so.serviceinstancebeans.Project();
197 requestProject.setProjectName("projectName");
199 Project actual = bbInputSetupMapperLayer.mapRequestProject(requestProject);
201 assertThat(actual, sameBeanAs(expected));
205 public void testMapAAIOwningEntity() throws IOException {
206 OwningEntity expected = mapper.readValue(new File(RESOURCE_PATH+"OwningEntity.json"),OwningEntity.class);
208 org.onap.aai.domain.yang.OwningEntity entityAAI = new org.onap.aai.domain.yang.OwningEntity();
209 entityAAI.setOwningEntityId("owningEntityId");
210 entityAAI.setOwningEntityName("owningEntityName");
212 OwningEntity actual = bbInputSetupMapperLayer.mapAAIOwningEntity(entityAAI);
214 assertThat(actual, sameBeanAs(expected));
218 public void testMapRequestOwningEntity() throws IOException {
219 OwningEntity expected = mapper.readValue(new File(RESOURCE_PATH+"OwningEntity.json"),OwningEntity.class);
221 org.onap.so.serviceinstancebeans.OwningEntity requestOwningEntity = new org.onap.so.serviceinstancebeans.OwningEntity();
222 requestOwningEntity.setOwningEntityId("owningEntityId");
223 requestOwningEntity.setOwningEntityName("owningEntityName");
225 OwningEntity actual = bbInputSetupMapperLayer.mapRequestOwningEntity(requestOwningEntity);
227 assertThat(actual, sameBeanAs(expected));
231 public void testMapAAIPlatform() throws IOException {
232 Platform expected = mapper.readValue(new File(RESOURCE_PATH+"Platform.json"),Platform.class);
234 org.onap.aai.domain.yang.Platform platformAAI = new org.onap.aai.domain.yang.Platform();
235 platformAAI.setPlatformName("platformName");
237 Platform actual = bbInputSetupMapperLayer.mapAAIPlatform(platformAAI);
239 assertThat(actual, sameBeanAs(expected));
243 public void testMapAAILineOfBusiness() throws IOException {
244 LineOfBusiness expected = mapper.readValue(new File(RESOURCE_PATH+"LineOfBusiness.json"),LineOfBusiness.class);
246 org.onap.aai.domain.yang.LineOfBusiness lobAAI = new org.onap.aai.domain.yang.LineOfBusiness();
247 lobAAI.setLineOfBusinessName("lineOfBusinessName");
249 LineOfBusiness actual = bbInputSetupMapperLayer.mapAAILineOfBusiness(lobAAI);
251 assertThat(actual, sameBeanAs(expected));
255 public void testMapAAINetworkPolicy() throws JsonParseException, JsonMappingException, IOException {
256 NetworkPolicy expectedNetworkPolicy = mapper.readValue(new File(RESOURCE_PATH + "NetworkPolicy.json"), NetworkPolicy.class);
258 org.onap.aai.domain.yang.NetworkPolicy aaiNetworkPolicy = new org.onap.aai.domain.yang.NetworkPolicy();
259 aaiNetworkPolicy.setNetworkPolicyId("networkPolicyId");
260 aaiNetworkPolicy.setNetworkPolicyFqdn("networkPolicyFqdn");
261 aaiNetworkPolicy.setHeatStackId("heatStackId");
262 aaiNetworkPolicy.setResourceVersion("resourceVersion");
264 NetworkPolicy actualNetworkPolicy = bbInputSetupMapperLayer.mapAAINetworkPolicy(aaiNetworkPolicy);
266 assertThat(actualNetworkPolicy, sameBeanAs(expectedNetworkPolicy));
270 public void testMapAAIVolumeGroup() throws JsonParseException, JsonMappingException, IOException {
271 VolumeGroup expectedVolumeGroup = mapper.readValue(new File(RESOURCE_PATH + "VolumeGroup.json"), VolumeGroup.class);
273 org.onap.aai.domain.yang.VolumeGroup aaiVolumeGroup = mapper.readValue(
274 new File(RESOURCE_PATH + "VolumeGroup_AAI.json"), org.onap.aai.domain.yang.VolumeGroup.class);
276 VolumeGroup actualVolumeGroup = bbInputSetupMapperLayer.mapAAIVolumeGroup(aaiVolumeGroup);
278 assertThat(actualVolumeGroup, sameBeanAs(expectedVolumeGroup));
282 public void testMapCatalogServiceIntoServiceInstance() throws IOException {
283 ModelInfoServiceInstance expected = mapper.readValue(
284 new File(RESOURCE_PATH + "ModelInfoServiceInstance.json"),
285 ModelInfoServiceInstance.class);
287 Service catalogService = mapper.readValue(
288 new File(RESOURCE_PATH + "CatalogServiceInput.json"), Service.class);
290 ModelInfoServiceInstance actual = bbInputSetupMapperLayer.mapCatalogServiceIntoServiceInstance(catalogService);
292 assertThat(actual, sameBeanAs(expected));
296 public void testMapCatalogInstanceGroupToInstanceGroup() throws IOException {
297 ModelInfoInstanceGroup expected = mapper.readValue(
298 new File(RESOURCE_PATH + "ModelInfoInstanceGroup.json"),
299 ModelInfoInstanceGroup.class);
301 InstanceGroup instanceGroup = mapper.readValue(
302 new File(RESOURCE_PATH + "InstanceGroup.json"), InstanceGroup.class);
303 instanceGroup.setCollectionInstanceGroupCustomizations(new ArrayList<>());
304 CollectionResourceInstanceGroupCustomization collectionInstanceGroupCust = new CollectionResourceInstanceGroupCustomization();
305 collectionInstanceGroupCust.setModelCustomizationUUID("modelCustomizationUUID");
306 collectionInstanceGroupCust.setFunction("function");
307 collectionInstanceGroupCust.setDescription("description");
308 instanceGroup.getCollectionInstanceGroupCustomizations().add(collectionInstanceGroupCust);
309 CollectionResourceCustomization collectionResourceCust = new CollectionResourceCustomization();
310 collectionResourceCust.setModelCustomizationUUID("modelCustomizationUUID");
311 ModelInfoInstanceGroup actual = bbInputSetupMapperLayer.mapCatalogInstanceGroupToInstanceGroup(collectionResourceCust, instanceGroup);
313 assertThat(actual, sameBeanAs(expected));
317 public void testMapCollectionNetworkResourceCustToNetworkResourceCust() {
318 String modelCustomizationUUID = "modelCustomizationUUID";
319 String modelInstanceName = "modelInstanceName";
320 String networkRole = "networkRole";
321 String networkScope = "networkScope";
322 String networkTechnology = "networkTechnology";
323 String networkType = "networkType";
325 NetworkResourceCustomization expected = new NetworkResourceCustomization();
326 expected.setModelCustomizationUUID(modelCustomizationUUID);
327 expected.setModelInstanceName(modelInstanceName);
328 expected.setNetworkRole(networkRole);
329 expected.setNetworkScope(networkScope);
330 expected.setNetworkTechnology(networkTechnology);
331 expected.setNetworkType(networkType);
332 CollectionNetworkResourceCustomization collectionNetworkResourceCust = new CollectionNetworkResourceCustomization();
333 collectionNetworkResourceCust.setModelCustomizationUUID(modelCustomizationUUID);
334 collectionNetworkResourceCust.setModelInstanceName(modelInstanceName);
335 collectionNetworkResourceCust.setNetworkRole(networkRole);
336 collectionNetworkResourceCust.setNetworkScope(networkScope);
337 collectionNetworkResourceCust.setNetworkTechnology(networkTechnology);
338 collectionNetworkResourceCust.setNetworkType(networkType);
339 NetworkResourceCustomization actual = bbInputSetupMapperLayer.mapCollectionNetworkResourceCustToNetworkResourceCust(collectionNetworkResourceCust);
341 assertThat(actual, sameBeanAs(expected));
345 public void testMapCatalogCollectionToCollection() throws IOException {
346 ModelInfoCollection expected = mapper.readValue(
347 new File(RESOURCE_PATH + "ModelInfoCollection.json"),
348 ModelInfoCollection.class);
350 CollectionResourceCustomization collectionCust = mapper.readValue(
351 new File(RESOURCE_PATH + "CollectionResourceCustomization.json"),
352 CollectionResourceCustomization.class);
354 CollectionResource collectionResource = mapper.readValue(
355 new File(RESOURCE_PATH + "CollectionResource.json"),
356 CollectionResource.class);
358 ModelInfoCollection actual = bbInputSetupMapperLayer.mapCatalogCollectionToCollection(collectionCust, collectionResource);
360 assertThat(actual, sameBeanAs(expected));
364 public void testMapAAIServiceInstanceIntoServiceInstance() throws IOException {
365 ServiceInstance expected = mapper.readValue(
366 new File(RESOURCE_PATH + "ServiceInstance_aaiServiceInstanceToSI.json"),
367 ServiceInstance.class);
369 org.onap.aai.domain.yang.ServiceInstance serviceInstanceAAI = mapper.readValue(
370 new File(RESOURCE_PATH + "ServiceInstanceAAIInput.json"),
371 org.onap.aai.domain.yang.ServiceInstance.class);
373 ServiceInstance actual = bbInputSetupMapperLayer.mapAAIServiceInstanceIntoServiceInstance(serviceInstanceAAI);
375 assertThat(actual, sameBeanAs(expected));
379 public void testSetPlatformAndLOB() throws IOException {
380 ServiceInstance expected = mapper.readValue(
381 new File(RESOURCE_PATH + "ServiceInstance_aaiPlatformAndLOBToSI.json"),
382 ServiceInstance.class);
384 Map<ResourceKey, String> resourcesToBeOrchestrated = new HashMap<>();
385 resourcesToBeOrchestrated.put(ResourceKey.GENERIC_VNF_ID, "vnfId");
386 Platform platformMSO = new Platform();
387 platformMSO.setPlatformName("platformName");
388 LineOfBusiness lineOfBusinessMSO = new LineOfBusiness();
389 lineOfBusinessMSO.setLineOfBusinessName("lineOfBusinessName");
391 ServiceInstance actual = mapper.readValue(
392 new File(RESOURCE_PATH + "ServiceInstanceAAIPlatformAndLOBInput.json"),
393 ServiceInstance.class);
395 bbInputSetupMapperLayer.setPlatformAndLOBIntoServiceInstance(platformMSO, lineOfBusinessMSO, actual,
396 resourcesToBeOrchestrated);
398 assertThat(actual, sameBeanAs(expected));
402 public void testMapAAIL3NetworkIntoL3Network() throws IOException {
403 L3Network expected = mapper.readValue(
404 new File(RESOURCE_PATH + "l3NetworkExpected.json"), L3Network.class);
406 org.onap.aai.domain.yang.L3Network aaiL3Network = mapper.readValue(
407 new File(RESOURCE_PATH + "aaiL3NetworkInput.json"),
408 org.onap.aai.domain.yang.L3Network.class);
410 L3Network actual = bbInputSetupMapperLayer.mapAAIL3Network(aaiL3Network);
412 assertThat(actual, sameBeanAs(expected));
416 public void testMapAAIGenericVnfIntoGenericVnf() throws IOException {
417 GenericVnf expected = mapper.readValue(new File(RESOURCE_PATH + "GenericVnfExpected.json"), GenericVnf.class);
418 org.onap.aai.domain.yang.GenericVnf aaiGenericVnf = mapper.readValue(
419 new File(RESOURCE_PATH + "aaiGenericVnfInput.json"), org.onap.aai.domain.yang.GenericVnf.class);
421 GenericVnf actual = bbInputSetupMapperLayer.mapAAIGenericVnfIntoGenericVnf(aaiGenericVnf);
423 assertThat(actual, sameBeanAs(expected));
427 public void testMapAAICollectionIntoCollection() throws JsonParseException, JsonMappingException, IOException {
428 org.onap.aai.domain.yang.Collection aaiCollection = mapper.readValue(
429 new File(RESOURCE_PATH + "CollectionInput.json"), org.onap.aai.domain.yang.Collection.class);
431 Collection expectedCollection = mapper.readValue(new File(RESOURCE_PATH + "CollectionExpected.json"), Collection.class);
433 Collection actualCollection = bbInputSetupMapperLayer.mapAAICollectionIntoCollection(aaiCollection);
435 assertThat(actualCollection, sameBeanAs(expectedCollection));
439 public void testMapAAIInstanceGroupIntoInstanceGroup() throws JsonParseException, JsonMappingException, IOException {
440 org.onap.aai.domain.yang.InstanceGroup aaiInstanceGroup = mapper.readValue(
441 new File(RESOURCE_PATH + "InstanceGroupInput.json"), org.onap.aai.domain.yang.InstanceGroup.class);
443 org.onap.so.bpmn.servicedecomposition.bbobjects.InstanceGroup expectedInstanceGroup = mapper.readValue(
444 new File(RESOURCE_PATH + "InstanceGroupExpected.json"), org.onap.so.bpmn.servicedecomposition.bbobjects.InstanceGroup.class);
446 org.onap.so.bpmn.servicedecomposition.bbobjects.InstanceGroup actualInstanceGroup =
447 bbInputSetupMapperLayer.mapAAIInstanceGroupIntoInstanceGroup(aaiInstanceGroup);
449 assertThat(actualInstanceGroup, sameBeanAs(expectedInstanceGroup));
453 public void testMapAAIRouteTableReferenceIntoRouteTableReference() throws JsonParseException, JsonMappingException, IOException {
454 org.onap.aai.domain.yang.RouteTableReference aaiRouteTableReference = mapper.readValue(
455 new File(RESOURCE_PATH + "RouteTableReferenceInput.json"), org.onap.aai.domain.yang.RouteTableReference.class);
457 RouteTableReference expectedRouteTableReference = mapper.readValue(
458 new File(RESOURCE_PATH + "RouteTableReferenceExpected.json"), RouteTableReference.class);
460 RouteTableReference actualRouteTableReference = bbInputSetupMapperLayer.mapAAIRouteTableReferenceIntoRouteTableReference(aaiRouteTableReference);
462 assertThat(actualRouteTableReference, sameBeanAs(expectedRouteTableReference));
466 public void testMapCatalogNetworkToNetwork() throws JsonParseException, JsonMappingException, IOException {
467 NetworkResourceCustomization networkResourceCustomization = mapper.readValue(
468 new File(RESOURCE_PATH + "NetworkResourceCustomizationInput.json"), NetworkResourceCustomization.class);
470 ModelInfoNetwork expectedModelInfoNetwork = mapper.readValue(
471 new File(RESOURCE_PATH + "ModelInfoNetworkExpected.json"), ModelInfoNetwork.class);
473 ModelInfoNetwork actualModelInfoNetwork = bbInputSetupMapperLayer.mapCatalogNetworkToNetwork(networkResourceCustomization);
475 assertThat(actualModelInfoNetwork, sameBeanAs(expectedModelInfoNetwork));
479 public void testMapCatalogVnfToVnf() throws IOException {
480 VnfResourceCustomization vnfResourceCustomization = mapper.readValue(
481 new File(RESOURCE_PATH + "VnfResourceCustomizationInput.json"), VnfResourceCustomization.class);
483 ModelInfoGenericVnf expectedModelInfoGenericVnf = mapper.readValue(
484 new File(RESOURCE_PATH + "ModelInfoGenericVnfExpected.json"), ModelInfoGenericVnf.class);
486 ModelInfoGenericVnf actualModelInfoGenericVnf = bbInputSetupMapperLayer.mapCatalogVnfToVnf(vnfResourceCustomization);
488 assertThat(actualModelInfoGenericVnf, sameBeanAs(expectedModelInfoGenericVnf));
492 public void testMapCatalogVfModuleToVfModule() throws JsonParseException, JsonMappingException, IOException {
493 VfModuleCustomization vfResourceCustomization = mapper.readValue(
494 new File(RESOURCE_PATH + "VfModuleCustomizationInput.json"), VfModuleCustomization.class);
496 ModelInfoVfModule expectedModelInfoVfModule = mapper.readValue(new File(RESOURCE_PATH + "ModelInfoVfModuleExpected.json"), ModelInfoVfModule.class);
498 ModelInfoVfModule actualModelInfoVfModule = bbInputSetupMapperLayer.mapCatalogVfModuleToVfModule(vfResourceCustomization);
500 assertThat(actualModelInfoVfModule, sameBeanAs(expectedModelInfoVfModule));
504 public void testMapRequestPlatform() throws JsonParseException, JsonMappingException, IOException {
505 org.onap.so.serviceinstancebeans.Platform platform = mapper.readValue(
506 new File(RESOURCE_PATH + "RequestPlatformInput.json"), org.onap.so.serviceinstancebeans.Platform.class);
508 Platform expectedPlatform = mapper.readValue(new File(RESOURCE_PATH + "PlatformExpected.json"), Platform.class);
510 Platform actualPlatform = bbInputSetupMapperLayer.mapRequestPlatform(platform);
512 assertThat(actualPlatform, sameBeanAs(expectedPlatform));
516 public void testMapRequestLineOfBusiness() throws JsonParseException, JsonMappingException, IOException {
517 org.onap.so.serviceinstancebeans.LineOfBusiness lineOfBusiness = mapper.readValue(
518 new File(RESOURCE_PATH + "RequestLineOfBusinessInput.json"), org.onap.so.serviceinstancebeans.LineOfBusiness.class);
520 LineOfBusiness expectedLineOfBusiness = mapper.readValue(new File(RESOURCE_PATH + "LineOfBusinessExpected.json"), LineOfBusiness.class);
522 LineOfBusiness actualLineOfBusiness = bbInputSetupMapperLayer.mapRequestLineOfBusiness(lineOfBusiness);
524 assertThat(actualLineOfBusiness, sameBeanAs(expectedLineOfBusiness));
528 public void testMapAAIConfiguration() throws JsonParseException, JsonMappingException, IOException {
529 org.onap.aai.domain.yang.Configuration configurationAAI = mapper.readValue(
530 new File(RESOURCE_PATH + "ConfigurationInput.json"), org.onap.aai.domain.yang.Configuration.class);
532 Configuration expectedConfiguration = mapper.readValue(
533 new File(RESOURCE_PATH + "ConfigurationExpected.json"), Configuration.class);
535 Configuration actualConfiguration = bbInputSetupMapperLayer.mapAAIConfiguration(configurationAAI);
537 assertThat(actualConfiguration, sameBeanAs(expectedConfiguration));
541 public void testMapRequestContext() throws IOException {
542 RequestContext expected = mapper.readValue(
543 new File(RESOURCE_PATH + "RequestContextExpected.json"),
544 RequestContext.class);
546 RequestDetails requestDetails = mapper.readValue(
547 new File(RESOURCE_PATH + "RequestDetailsInput_mapReqContext.json"),
548 RequestDetails.class);
549 RequestContext actual = bbInputSetupMapperLayer.mapRequestContext(requestDetails);
551 assertThat(actual, sameBeanAs(expected));
555 public void testMapOrchestrationContext() throws IOException {
556 OrchestrationContext expected = new OrchestrationContext();
557 expected.setIsRollbackEnabled(true);
559 RequestDetails requestDetails = mapper.readValue(new File(RESOURCE_PATH + "RequestDetailsInput_mapReqContext.json"), RequestDetails.class);
561 OrchestrationContext actual = bbInputSetupMapperLayer.mapOrchestrationContext(requestDetails);
563 assertThat(actual, sameBeanAs(expected));
567 public void testMapLocationContext() {
568 CloudRegion expected = new CloudRegion();
569 expected.setCloudOwner("test-owner-name");
570 expected.setLcpCloudRegionId("cloudRegionId");
571 expected.setComplex("complexName");
572 expected.setTenantId("tenantId");
573 CloudConfiguration cloudConfig = new CloudConfiguration();
574 cloudConfig.setTenantId("tenantId");
575 cloudConfig.setLcpCloudRegionId("cloudRegionId");
576 cloudConfig.setAicNodeClli("aicNodeClli");
577 org.onap.aai.domain.yang.CloudRegion cloudRegion = new org.onap.aai.domain.yang.CloudRegion();
578 cloudRegion.setCloudOwner("test-owner-name");
579 cloudRegion.setCloudRegionId("cloudRegionId");
580 cloudRegion.setComplexName("complexName");
582 CloudRegion actual = bbInputSetupMapperLayer.mapCloudRegion(cloudConfig, cloudRegion);
584 assertThat(actual, sameBeanAs(expected));
588 public void testMapCloudRegion() {
589 CloudRegion expected = new CloudRegion();
590 expected.setCloudOwner("test-owner-name");
591 expected.setLcpCloudRegionId("cloudRegionId");
592 expected.setTenantId("tenantId");
593 expected.setCloudRegionVersion("cloudRegionVersion");
595 CloudConfiguration cloudConfig = new CloudConfiguration();
596 cloudConfig.setTenantId("tenantId");
597 cloudConfig.setLcpCloudRegionId("cloudRegionId");
598 cloudConfig.setAicNodeClli("aicNodeClli");
600 org.onap.aai.domain.yang.CloudRegion cloudRegion = new org.onap.aai.domain.yang.CloudRegion();
601 cloudRegion.setCloudOwner("test-owner-name");
602 cloudRegion.setCloudRegionId("cloudRegionId");
603 cloudRegion.setCloudRegionVersion("cloudRegionVersion");
605 CloudRegion actual = bbInputSetupMapperLayer.mapCloudRegion(cloudConfig, cloudRegion);
607 assertThat(actual, sameBeanAs(expected));
611 public void testMapTenant() {
612 Tenant expected = new Tenant();
613 expected.setTenantId("tenantId");
614 expected.setTenantName("tenantName");
615 expected.setTenantContext("tenantContext");
617 org.onap.aai.domain.yang.Tenant aaiTenant = new org.onap.aai.domain.yang.Tenant();
618 aaiTenant.setTenantId("tenantId");
619 aaiTenant.setTenantName("tenantName");
620 aaiTenant.setTenantContext("tenantContext");
622 Tenant actual = bbInputSetupMapperLayer.mapTenant(aaiTenant);
624 assertThat(actual, sameBeanAs(expected));
628 public void testMapCloudRegionWithNullCheck() {
629 CloudRegion expected = new CloudRegion();
631 CloudRegion actual = bbInputSetupMapperLayer.mapCloudRegion(null, null);
633 assertThat(actual, sameBeanAs(expected));
637 public void testmapCatalogConfigurationToConfiguration() {
638 String modelCustUUID = "modelCustomizationUUID";
639 String modelInvariantUUID = "modelInvariantUUID";
640 String modelVersionUUID = "modelUUID";
641 String policyName = "policyName";
642 ModelInfoConfiguration expected = new ModelInfoConfiguration();
643 expected.setModelCustomizationId(modelCustUUID);
644 expected.setModelInvariantId(modelInvariantUUID);
645 expected.setModelVersionId(modelVersionUUID);
646 expected.setPolicyName(policyName);
647 ConfigurationResourceCustomization configurationResourceCustomization = new ConfigurationResourceCustomization();
648 configurationResourceCustomization.setModelCustomizationUUID(modelCustUUID);
649 configurationResourceCustomization.setConfigurationResource(new ConfigurationResource());
650 configurationResourceCustomization.getConfigurationResource().setModelInvariantUUID(modelInvariantUUID);
651 configurationResourceCustomization.getConfigurationResource().setModelUUID(modelVersionUUID);
652 CvnfcConfigurationCustomization policyNameTable = new CvnfcConfigurationCustomization();
653 policyNameTable.setCvnfcCustomization(new CvnfcCustomization());
654 policyNameTable.getCvnfcCustomization().setVnfcCustomization(new VnfcCustomization());
655 policyNameTable.setPolicyName(policyName);
657 ModelInfoConfiguration actual = bbInputSetupMapperLayer.mapCatalogConfigurationToConfiguration(configurationResourceCustomization, policyNameTable);
659 assertThat(actual, sameBeanAs(expected));
663 public void testmapCatalogConfigurationToFabricConfiguration() {
664 String modelCustUUID = "modelCustomizationUUID";
665 String modelInvariantUUID = "modelInvariantUUID";
666 String modelVersionUUID = "modelUUID";
667 String policyName = "policyName";
668 ModelInfoConfiguration expected = new ModelInfoConfiguration();
669 expected.setModelCustomizationId(modelCustUUID);
670 expected.setModelInvariantId(modelInvariantUUID);
671 expected.setModelVersionId(modelVersionUUID);
672 expected.setPolicyName(policyName);
674 CvnfcConfigurationCustomization fabricCustomization = new CvnfcConfigurationCustomization();
675 fabricCustomization.setCvnfcCustomization(new CvnfcCustomization());
676 fabricCustomization.getCvnfcCustomization().setVnfcCustomization(new VnfcCustomization());
677 fabricCustomization.setPolicyName(policyName);
678 fabricCustomization.setModelCustomizationUUID(modelCustUUID);
680 ConfigurationResource configurationResource = new ConfigurationResource();
681 configurationResource.setModelUUID(modelVersionUUID);
682 configurationResource.setModelInvariantUUID(modelInvariantUUID);
683 fabricCustomization.setConfigurationResource(configurationResource);
685 ModelInfoConfiguration actual = bbInputSetupMapperLayer.mapCatalogConfigurationToConfiguration(fabricCustomization);
687 assertThat(actual, sameBeanAs(expected));
691 public void testMapNameValueUserParams() throws IOException {
692 RequestDetails requestDetails = mapper.readValue(new File(RESOURCE_PATH + "RequestDetailsInput_mapReqContext.json"), RequestDetails.class);
693 Map<String,Object> actual = bbInputSetupMapperLayer.mapNameValueUserParams(requestDetails.getRequestParameters());
695 assertTrue(actual.containsKey("mns_vfw_protected_route_prefixes"));
696 assertTrue(actual.get("mns_vfw_protected_route_prefixes").toString().contains("interface_route_table_routes_route"));
697 assertTrue(actual.get("mns_vfw_protected_route_prefixes").toString().contains("1.1.1.1/32"));
698 assertTrue(actual.get("mns_vfw_protected_route_prefixes").toString().contains("0::1/128"));
699 assertTrue(actual.containsKey("name1"));
700 assertTrue(actual.containsValue("value1"));
701 assertTrue(actual.get("name1").equals("value1"));
703 assertFalse(actual.containsKey("ignore"));
704 assertFalse(actual.containsValue("ignore"));
708 public void testMapRequestParameters() throws IOException {
709 RequestDetails requestDetails = mapper.readValue(new File(RESOURCE_PATH + "RequestDetailsInput_mapReqContext.json"), RequestDetails.class);
710 RequestParameters actual = bbInputSetupMapperLayer.mapRequestParameters(requestDetails.getRequestParameters());
712 assertEquals(actual.getUsePreload(), requestDetails.getRequestParameters().getUsePreload());
713 assertEquals(actual.getSubscriptionServiceType(), requestDetails.getRequestParameters().getSubscriptionServiceType());
714 assertEquals(actual.getPayload(), requestDetails.getRequestParameters().getPayload());
717 protected RequestParameters mapRequestParameters(org.onap.so.serviceinstancebeans.RequestParameters requestParameters) {
718 RequestParameters requestParams = new RequestParameters();
719 requestParams.setaLaCarte(requestParameters.getALaCarte());
720 requestParams.setUsePreload(requestParameters.getUsePreload());
721 requestParams.setSubscriptionServiceType(requestParameters.getSubscriptionServiceType());
722 requestParams.setUserParams(requestParameters.getUserParams());
723 requestParams.setPayload(requestParameters.getPayload());
724 return requestParams;