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;
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;
36 import org.junit.Test;
37 import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion;
38 import org.onap.so.bpmn.servicedecomposition.bbobjects.Collection;
39 import org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration;
40 import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer;
41 import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf;
42 import org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network;
43 import org.onap.so.bpmn.servicedecomposition.bbobjects.LineOfBusiness;
44 import org.onap.so.bpmn.servicedecomposition.bbobjects.NetworkPolicy;
45 import org.onap.so.bpmn.servicedecomposition.bbobjects.OwningEntity;
46 import org.onap.so.bpmn.servicedecomposition.bbobjects.Platform;
47 import org.onap.so.bpmn.servicedecomposition.bbobjects.Pnf;
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.Tenant;
53 import org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup;
54 import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey;
55 import org.onap.so.bpmn.servicedecomposition.generalobjects.OrchestrationContext;
56 import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext;
57 import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestParameters;
58 import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoCollection;
59 import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoConfiguration;
60 import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoGenericVnf;
61 import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoInstanceGroup;
62 import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoNetwork;
63 import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoServiceInstance;
64 import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoPnf;
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.PnfResource;
79 import org.onap.so.db.catalog.beans.PnfResourceCustomization;
80 import org.onap.so.db.catalog.beans.VfModuleCustomization;
81 import org.onap.so.db.catalog.beans.VnfResourceCustomization;
82 import org.onap.so.db.catalog.beans.VnfcCustomization;
83 import org.onap.so.serviceinstancebeans.CloudConfiguration;
84 import org.onap.so.serviceinstancebeans.RequestDetails;
85 import com.fasterxml.jackson.databind.DeserializationFeature;
86 import com.fasterxml.jackson.databind.ObjectMapper;
88 public class BBInputSetupMapperLayerTest {
90 BBInputSetupMapperLayer bbInputSetupMapperLayer = new BBInputSetupMapperLayer();
92 ObjectMapper mapper = new ObjectMapper().configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
94 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),
150 equalTo(OrchestrationStatus.PENDING_CREATE));
155 public void testMapAAICustomer() throws IOException {
156 Customer expected = mapper.readValue(new File(RESOURCE_PATH + "Customer.json"), Customer.class);
158 org.onap.aai.domain.yang.Customer customerAAI = mapper.readValue(new File(RESOURCE_PATH + "Customer_AAI.json"),
159 org.onap.aai.domain.yang.Customer.class);
161 Customer actual = bbInputSetupMapperLayer.mapAAICustomer(customerAAI);
163 assertThat(actual, sameBeanAs(expected));
167 public void testMapAAIServiceSubscription() throws IOException {
168 ServiceSubscription expected = mapper.readValue(new File(RESOURCE_PATH + "ServiceSubscriptionExpected.json"),
169 ServiceSubscription.class);
171 org.onap.aai.domain.yang.ServiceSubscription svcSubscriptionAAI =
172 mapper.readValue(new File(RESOURCE_PATH + "ServiceSubscription_AAI.json"),
173 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 =
222 new org.onap.so.serviceinstancebeans.OwningEntity();
223 requestOwningEntity.setOwningEntityId("owningEntityId");
224 requestOwningEntity.setOwningEntityName("owningEntityName");
226 OwningEntity actual = bbInputSetupMapperLayer.mapRequestOwningEntity(requestOwningEntity);
228 assertThat(actual, sameBeanAs(expected));
232 public void testMapAAIPlatform() throws IOException {
233 Platform expected = mapper.readValue(new File(RESOURCE_PATH + "Platform.json"), Platform.class);
235 org.onap.aai.domain.yang.Platform platformAAI = new org.onap.aai.domain.yang.Platform();
236 platformAAI.setPlatformName("platformName");
238 Platform actual = bbInputSetupMapperLayer.mapAAIPlatform(platformAAI);
240 assertThat(actual, sameBeanAs(expected));
244 public void testMapAAILineOfBusiness() throws IOException {
245 LineOfBusiness expected =
246 mapper.readValue(new File(RESOURCE_PATH + "LineOfBusiness.json"), LineOfBusiness.class);
248 org.onap.aai.domain.yang.LineOfBusiness lobAAI = new org.onap.aai.domain.yang.LineOfBusiness();
249 lobAAI.setLineOfBusinessName("lineOfBusinessName");
251 LineOfBusiness actual = bbInputSetupMapperLayer.mapAAILineOfBusiness(lobAAI);
253 assertThat(actual, sameBeanAs(expected));
257 public void testMapAAINetworkPolicy() throws IOException {
258 NetworkPolicy expectedNetworkPolicy =
259 mapper.readValue(new File(RESOURCE_PATH + "NetworkPolicy.json"), NetworkPolicy.class);
261 org.onap.aai.domain.yang.NetworkPolicy aaiNetworkPolicy = new org.onap.aai.domain.yang.NetworkPolicy();
262 aaiNetworkPolicy.setNetworkPolicyId("networkPolicyId");
263 aaiNetworkPolicy.setNetworkPolicyFqdn("networkPolicyFqdn");
264 aaiNetworkPolicy.setHeatStackId("heatStackId");
265 aaiNetworkPolicy.setResourceVersion("resourceVersion");
267 NetworkPolicy actualNetworkPolicy = bbInputSetupMapperLayer.mapAAINetworkPolicy(aaiNetworkPolicy);
269 assertThat(actualNetworkPolicy, sameBeanAs(expectedNetworkPolicy));
273 public void testMapAAIVolumeGroup() throws IOException {
274 VolumeGroup expectedVolumeGroup =
275 mapper.readValue(new File(RESOURCE_PATH + "VolumeGroup.json"), VolumeGroup.class);
277 org.onap.aai.domain.yang.VolumeGroup aaiVolumeGroup = mapper.readValue(
278 new File(RESOURCE_PATH + "VolumeGroup_AAI.json"), org.onap.aai.domain.yang.VolumeGroup.class);
280 VolumeGroup actualVolumeGroup = bbInputSetupMapperLayer.mapAAIVolumeGroup(aaiVolumeGroup);
282 assertThat(actualVolumeGroup, sameBeanAs(expectedVolumeGroup));
286 public void testMapCatalogServiceIntoServiceInstance() throws IOException {
287 ModelInfoServiceInstance expected = mapper.readValue(new File(RESOURCE_PATH + "ModelInfoServiceInstance.json"),
288 ModelInfoServiceInstance.class);
290 Service catalogService = mapper.readValue(new File(RESOURCE_PATH + "CatalogServiceInput.json"), Service.class);
292 ModelInfoServiceInstance actual = bbInputSetupMapperLayer.mapCatalogServiceIntoServiceInstance(catalogService);
294 assertThat(actual, sameBeanAs(expected));
298 public void testMapCatalogInstanceGroupToInstanceGroup() throws IOException {
299 ModelInfoInstanceGroup expected =
300 mapper.readValue(new File(RESOURCE_PATH + "ModelInfoInstanceGroup.json"), ModelInfoInstanceGroup.class);
302 InstanceGroup instanceGroup =
303 mapper.readValue(new File(RESOURCE_PATH + "InstanceGroup.json"), InstanceGroup.class);
304 instanceGroup.setCollectionInstanceGroupCustomizations(new ArrayList<>());
305 CollectionResourceInstanceGroupCustomization collectionInstanceGroupCust =
306 new CollectionResourceInstanceGroupCustomization();
307 collectionInstanceGroupCust.setModelCustomizationUUID("modelCustomizationUUID");
308 collectionInstanceGroupCust.setFunction("function");
309 collectionInstanceGroupCust.setDescription("description");
310 instanceGroup.getCollectionInstanceGroupCustomizations().add(collectionInstanceGroupCust);
311 CollectionResourceCustomization collectionResourceCust = new CollectionResourceCustomization();
312 collectionResourceCust.setModelCustomizationUUID("modelCustomizationUUID");
313 ModelInfoInstanceGroup actual =
314 bbInputSetupMapperLayer.mapCatalogInstanceGroupToInstanceGroup(collectionResourceCust, instanceGroup);
316 assertThat(actual, sameBeanAs(expected));
320 public void testMapCollectionNetworkResourceCustToNetworkResourceCust() {
321 String modelCustomizationUUID = "modelCustomizationUUID";
322 String modelInstanceName = "modelInstanceName";
323 String networkRole = "networkRole";
324 String networkScope = "networkScope";
325 String networkTechnology = "networkTechnology";
326 String networkType = "networkType";
328 NetworkResourceCustomization expected = new NetworkResourceCustomization();
329 expected.setModelCustomizationUUID(modelCustomizationUUID);
330 expected.setModelInstanceName(modelInstanceName);
331 expected.setNetworkRole(networkRole);
332 expected.setNetworkScope(networkScope);
333 expected.setNetworkTechnology(networkTechnology);
334 expected.setNetworkType(networkType);
335 CollectionNetworkResourceCustomization collectionNetworkResourceCust =
336 new CollectionNetworkResourceCustomization();
337 collectionNetworkResourceCust.setModelCustomizationUUID(modelCustomizationUUID);
338 collectionNetworkResourceCust.setModelInstanceName(modelInstanceName);
339 collectionNetworkResourceCust.setNetworkRole(networkRole);
340 collectionNetworkResourceCust.setNetworkScope(networkScope);
341 collectionNetworkResourceCust.setNetworkTechnology(networkTechnology);
342 collectionNetworkResourceCust.setNetworkType(networkType);
343 NetworkResourceCustomization actual = bbInputSetupMapperLayer
344 .mapCollectionNetworkResourceCustToNetworkResourceCust(collectionNetworkResourceCust);
346 assertThat(actual, sameBeanAs(expected));
350 public void testMapCatalogCollectionToCollection() throws IOException {
351 ModelInfoCollection expected =
352 mapper.readValue(new File(RESOURCE_PATH + "ModelInfoCollection.json"), ModelInfoCollection.class);
354 CollectionResourceCustomization collectionCust =
355 mapper.readValue(new File(RESOURCE_PATH + "CollectionResourceCustomization.json"),
356 CollectionResourceCustomization.class);
358 CollectionResource collectionResource =
359 mapper.readValue(new File(RESOURCE_PATH + "CollectionResource.json"), CollectionResource.class);
361 ModelInfoCollection actual =
362 bbInputSetupMapperLayer.mapCatalogCollectionToCollection(collectionCust, collectionResource);
364 assertThat(actual, sameBeanAs(expected));
368 public void testMapAAIServiceInstanceIntoServiceInstance() throws IOException {
369 ServiceInstance expected = mapper.readValue(
370 new File(RESOURCE_PATH + "ServiceInstance_aaiServiceInstanceToSI.json"), ServiceInstance.class);
372 org.onap.aai.domain.yang.ServiceInstance serviceInstanceAAI =
373 mapper.readValue(new File(RESOURCE_PATH + "ServiceInstanceAAIInput.json"),
374 org.onap.aai.domain.yang.ServiceInstance.class);
376 ServiceInstance actual = bbInputSetupMapperLayer.mapAAIServiceInstanceIntoServiceInstance(serviceInstanceAAI);
378 assertThat(actual, sameBeanAs(expected));
382 public void testSetPlatformAndLOB() throws IOException {
383 ServiceInstance expected = mapper.readValue(
384 new File(RESOURCE_PATH + "ServiceInstance_aaiPlatformAndLOBToSI.json"), ServiceInstance.class);
386 Map<ResourceKey, String> resourcesToBeOrchestrated = new HashMap<>();
387 resourcesToBeOrchestrated.put(ResourceKey.GENERIC_VNF_ID, "vnfId");
388 Platform platformMSO = new Platform();
389 platformMSO.setPlatformName("platformName");
390 LineOfBusiness lineOfBusinessMSO = new LineOfBusiness();
391 lineOfBusinessMSO.setLineOfBusinessName("lineOfBusinessName");
393 ServiceInstance actual = mapper.readValue(
394 new File(RESOURCE_PATH + "ServiceInstanceAAIPlatformAndLOBInput.json"), ServiceInstance.class);
396 bbInputSetupMapperLayer.setPlatformAndLOBIntoServiceInstance(platformMSO, lineOfBusinessMSO, actual,
397 resourcesToBeOrchestrated);
399 assertThat(actual, sameBeanAs(expected));
403 public void testMapAAIL3NetworkIntoL3Network() throws IOException {
405 mapper.readValue(new File(RESOURCE_PATH + "l3NetworkExpectedWithSubnet.json"), L3Network.class);
407 org.onap.aai.domain.yang.L3Network aaiL3Network =
408 mapper.readValue(new File(RESOURCE_PATH + "aaiL3NetworkInputWithSubnets.json"),
409 org.onap.aai.domain.yang.L3Network.class);
411 L3Network actual = bbInputSetupMapperLayer.mapAAIL3Network(aaiL3Network);
413 assertThat(actual, sameBeanAs(expected));
417 public void testMapAAIGenericVnfIntoGenericVnf() throws IOException {
418 GenericVnf expected = mapper.readValue(new File(RESOURCE_PATH + "GenericVnfExpected.json"), GenericVnf.class);
419 org.onap.aai.domain.yang.GenericVnf aaiGenericVnf = mapper.readValue(
420 new File(RESOURCE_PATH + "aaiGenericVnfInput.json"), org.onap.aai.domain.yang.GenericVnf.class);
422 GenericVnf actual = bbInputSetupMapperLayer.mapAAIGenericVnfIntoGenericVnf(aaiGenericVnf);
424 assertThat(actual, sameBeanAs(expected));
428 public void testMapAAIPnfIntoPnf() throws IOException {
429 Pnf expected = mapper.readValue(new File(RESOURCE_PATH + "PnfExpected.json"), Pnf.class);
430 org.onap.aai.domain.yang.Pnf aaiPnf =
431 mapper.readValue(new File(RESOURCE_PATH + "aaiPnfInput.json"), org.onap.aai.domain.yang.Pnf.class);
433 Pnf actual = bbInputSetupMapperLayer.mapAAIPnfIntoPnf(aaiPnf);
435 assertThat(actual, sameBeanAs(expected));
439 public void testMapAAICollectionIntoCollection() throws IOException {
440 org.onap.aai.domain.yang.Collection aaiCollection = mapper
441 .readValue(new File(RESOURCE_PATH + "CollectionInput.json"), org.onap.aai.domain.yang.Collection.class);
443 Collection expectedCollection =
444 mapper.readValue(new File(RESOURCE_PATH + "CollectionExpected.json"), Collection.class);
446 Collection actualCollection = bbInputSetupMapperLayer.mapAAICollectionIntoCollection(aaiCollection);
448 assertThat(actualCollection, sameBeanAs(expectedCollection));
452 public void testMapAAIInstanceGroupIntoInstanceGroup() throws IOException {
453 org.onap.aai.domain.yang.InstanceGroup aaiInstanceGroup = mapper.readValue(
454 new File(RESOURCE_PATH + "InstanceGroupInput.json"), org.onap.aai.domain.yang.InstanceGroup.class);
456 org.onap.so.bpmn.servicedecomposition.bbobjects.InstanceGroup expectedInstanceGroup =
457 mapper.readValue(new File(RESOURCE_PATH + "InstanceGroupExpected.json"),
458 org.onap.so.bpmn.servicedecomposition.bbobjects.InstanceGroup.class);
460 org.onap.so.bpmn.servicedecomposition.bbobjects.InstanceGroup actualInstanceGroup =
461 bbInputSetupMapperLayer.mapAAIInstanceGroupIntoInstanceGroup(aaiInstanceGroup);
463 assertThat(actualInstanceGroup, sameBeanAs(expectedInstanceGroup));
467 public void testMapAAIRouteTableReferenceIntoRouteTableReference() throws IOException {
468 org.onap.aai.domain.yang.RouteTableReference aaiRouteTableReference =
469 mapper.readValue(new File(RESOURCE_PATH + "RouteTableReferenceInput.json"),
470 org.onap.aai.domain.yang.RouteTableReference.class);
472 RouteTableReference expectedRouteTableReference = mapper
473 .readValue(new File(RESOURCE_PATH + "RouteTableReferenceExpected.json"), RouteTableReference.class);
475 RouteTableReference actualRouteTableReference =
476 bbInputSetupMapperLayer.mapAAIRouteTableReferenceIntoRouteTableReference(aaiRouteTableReference);
478 assertThat(actualRouteTableReference, sameBeanAs(expectedRouteTableReference));
482 public void testMapCatalogNetworkToNetwork() throws IOException {
483 NetworkResourceCustomization networkResourceCustomization = mapper.readValue(
484 new File(RESOURCE_PATH + "NetworkResourceCustomizationInput.json"), NetworkResourceCustomization.class);
486 ModelInfoNetwork expectedModelInfoNetwork =
487 mapper.readValue(new File(RESOURCE_PATH + "ModelInfoNetworkExpected.json"), ModelInfoNetwork.class);
489 ModelInfoNetwork actualModelInfoNetwork =
490 bbInputSetupMapperLayer.mapCatalogNetworkToNetwork(networkResourceCustomization);
492 assertThat(actualModelInfoNetwork, sameBeanAs(expectedModelInfoNetwork));
496 public void testMapCatalogVnfToVnf() throws IOException {
497 VnfResourceCustomization vnfResourceCustomization = mapper.readValue(
498 new File(RESOURCE_PATH + "VnfResourceCustomizationInput.json"), VnfResourceCustomization.class);
500 ModelInfoGenericVnf expectedModelInfoGenericVnf = mapper
501 .readValue(new File(RESOURCE_PATH + "ModelInfoGenericVnfExpected.json"), ModelInfoGenericVnf.class);
503 ModelInfoGenericVnf actualModelInfoGenericVnf =
504 bbInputSetupMapperLayer.mapCatalogVnfToVnf(vnfResourceCustomization);
506 assertThat(actualModelInfoGenericVnf, sameBeanAs(expectedModelInfoGenericVnf));
510 public void testMapCatalogPnfToPnf() throws IOException {
511 PnfResourceCustomization pnfResourceCustomization = mapper.readValue(
512 new File(RESOURCE_PATH + "PnfResourceCustomizationInput.json"), PnfResourceCustomization.class);
514 PnfResource pnfResource = new PnfResource();
515 pnfResource.setModelUUID("modelUuid");
516 pnfResource.setModelInvariantUUID("modelInvariantUuid");
517 pnfResource.setModelVersion("modelVersion");
519 pnfResourceCustomization.setPnfResources(pnfResource);
521 ModelInfoPnf expectedModelInfoPnf =
522 mapper.readValue(new File(RESOURCE_PATH + "ModelInfoPnfExpected.json"), ModelInfoPnf.class);
524 ModelInfoPnf actualModelInfoPnf = bbInputSetupMapperLayer.mapCatalogPnfToPnf(pnfResourceCustomization);
526 assertThat(actualModelInfoPnf, sameBeanAs(expectedModelInfoPnf));
530 public void testMapCatalogVfModuleToVfModule() throws IOException {
531 VfModuleCustomization vfResourceCustomization = mapper
532 .readValue(new File(RESOURCE_PATH + "VfModuleCustomizationInput.json"), VfModuleCustomization.class);
534 ModelInfoVfModule expectedModelInfoVfModule =
535 mapper.readValue(new File(RESOURCE_PATH + "ModelInfoVfModuleExpected.json"), ModelInfoVfModule.class);
537 ModelInfoVfModule actualModelInfoVfModule =
538 bbInputSetupMapperLayer.mapCatalogVfModuleToVfModule(vfResourceCustomization);
540 assertThat(actualModelInfoVfModule, sameBeanAs(expectedModelInfoVfModule));
544 public void testMapRequestPlatform() throws IOException {
545 org.onap.so.serviceinstancebeans.Platform platform = mapper.readValue(
546 new File(RESOURCE_PATH + "RequestPlatformInput.json"), org.onap.so.serviceinstancebeans.Platform.class);
548 Platform expectedPlatform = mapper.readValue(new File(RESOURCE_PATH + "PlatformExpected.json"), Platform.class);
550 Platform actualPlatform = bbInputSetupMapperLayer.mapRequestPlatform(platform);
552 assertThat(actualPlatform, sameBeanAs(expectedPlatform));
556 public void testMapRequestLineOfBusiness() throws IOException {
557 org.onap.so.serviceinstancebeans.LineOfBusiness lineOfBusiness =
558 mapper.readValue(new File(RESOURCE_PATH + "RequestLineOfBusinessInput.json"),
559 org.onap.so.serviceinstancebeans.LineOfBusiness.class);
561 LineOfBusiness expectedLineOfBusiness =
562 mapper.readValue(new File(RESOURCE_PATH + "LineOfBusinessExpected.json"), LineOfBusiness.class);
564 LineOfBusiness actualLineOfBusiness = bbInputSetupMapperLayer.mapRequestLineOfBusiness(lineOfBusiness);
566 assertThat(actualLineOfBusiness, sameBeanAs(expectedLineOfBusiness));
570 public void testMapAAIConfiguration() throws IOException {
571 org.onap.aai.domain.yang.Configuration configurationAAI = mapper.readValue(
572 new File(RESOURCE_PATH + "ConfigurationInput.json"), org.onap.aai.domain.yang.Configuration.class);
574 Configuration expectedConfiguration =
575 mapper.readValue(new File(RESOURCE_PATH + "ConfigurationExpected.json"), Configuration.class);
577 Configuration actualConfiguration = bbInputSetupMapperLayer.mapAAIConfiguration(configurationAAI);
579 assertThat(actualConfiguration, sameBeanAs(expectedConfiguration));
583 public void testMapRequestContext() throws IOException {
584 RequestContext expected =
585 mapper.readValue(new File(RESOURCE_PATH + "RequestContextExpected.json"), RequestContext.class);
587 RequestDetails requestDetails = mapper
588 .readValue(new File(RESOURCE_PATH + "RequestDetailsInput_mapReqContext.json"), RequestDetails.class);
589 RequestContext actual = bbInputSetupMapperLayer.mapRequestContext(requestDetails);
591 assertThat(actual, sameBeanAs(expected));
595 public void testMapOrchestrationContext() throws IOException {
596 OrchestrationContext expected = new OrchestrationContext();
597 expected.setIsRollbackEnabled(true);
599 RequestDetails requestDetails = mapper
600 .readValue(new File(RESOURCE_PATH + "RequestDetailsInput_mapReqContext.json"), RequestDetails.class);
602 OrchestrationContext actual = bbInputSetupMapperLayer.mapOrchestrationContext(requestDetails);
604 assertThat(actual, sameBeanAs(expected));
608 public void testMapOrchestrationContextNoRequestInfo() throws IOException {
609 OrchestrationContext expected = new OrchestrationContext();
610 expected.setIsRollbackEnabled(false);
612 RequestDetails requestDetails = mapper.readValue(
613 new File(RESOURCE_PATH + "RequestDetailsInput_mapReqContextNoRequestInfo.json"), RequestDetails.class);
615 OrchestrationContext actual = bbInputSetupMapperLayer.mapOrchestrationContext(requestDetails);
617 assertThat(actual, sameBeanAs(expected));
621 public void testMapLocationContext() {
622 CloudRegion expected = new CloudRegion();
623 expected.setCloudOwner("test-owner-name");
624 expected.setLcpCloudRegionId("cloudRegionId");
625 expected.setComplex("complexName");
626 expected.setTenantId("tenantId");
627 CloudConfiguration cloudConfig = new CloudConfiguration();
628 cloudConfig.setTenantId("tenantId");
629 cloudConfig.setLcpCloudRegionId("cloudRegionId");
630 cloudConfig.setAicNodeClli("aicNodeClli");
631 org.onap.aai.domain.yang.CloudRegion cloudRegion = new org.onap.aai.domain.yang.CloudRegion();
632 cloudRegion.setCloudOwner("test-owner-name");
633 cloudRegion.setCloudRegionId("cloudRegionId");
634 cloudRegion.setComplexName("complexName");
636 CloudRegion actual = bbInputSetupMapperLayer.mapCloudRegion(cloudConfig, cloudRegion);
638 assertThat(actual, sameBeanAs(expected));
642 public void testMapCloudRegion() {
643 CloudRegion expected = new CloudRegion();
644 expected.setCloudOwner("test-owner-name");
645 expected.setLcpCloudRegionId("cloudRegionId");
646 expected.setTenantId("tenantId");
647 expected.setCloudRegionVersion("cloudRegionVersion");
649 CloudConfiguration cloudConfig = new CloudConfiguration();
650 cloudConfig.setTenantId("tenantId");
651 cloudConfig.setLcpCloudRegionId("cloudRegionId");
652 cloudConfig.setAicNodeClli("aicNodeClli");
654 org.onap.aai.domain.yang.CloudRegion cloudRegion = new org.onap.aai.domain.yang.CloudRegion();
655 cloudRegion.setCloudOwner("test-owner-name");
656 cloudRegion.setCloudRegionId("cloudRegionId");
657 cloudRegion.setCloudRegionVersion("cloudRegionVersion");
659 CloudRegion actual = bbInputSetupMapperLayer.mapCloudRegion(cloudConfig, cloudRegion);
661 assertThat(actual, sameBeanAs(expected));
665 public void testMapTenant() {
666 Tenant expected = new Tenant();
667 expected.setTenantId("tenantId");
668 expected.setTenantName("tenantName");
669 expected.setTenantContext("tenantContext");
671 org.onap.aai.domain.yang.Tenant aaiTenant = new org.onap.aai.domain.yang.Tenant();
672 aaiTenant.setTenantId("tenantId");
673 aaiTenant.setTenantName("tenantName");
674 aaiTenant.setTenantContext("tenantContext");
676 Tenant actual = bbInputSetupMapperLayer.mapTenant(aaiTenant);
678 assertThat(actual, sameBeanAs(expected));
682 public void testMapCloudRegionWithNullCheck() {
683 CloudRegion expected = new CloudRegion();
685 CloudRegion actual = bbInputSetupMapperLayer.mapCloudRegion(null, null);
687 assertThat(actual, sameBeanAs(expected));
691 public void testmapCatalogConfigurationToConfiguration() {
692 String modelCustUUID = "modelCustomizationUUID";
693 String modelInvariantUUID = "modelInvariantUUID";
694 String modelVersionUUID = "modelUUID";
695 String policyName = "policyName";
696 ModelInfoConfiguration expected = new ModelInfoConfiguration();
697 expected.setModelCustomizationId(modelCustUUID);
698 expected.setModelInvariantId(modelInvariantUUID);
699 expected.setModelVersionId(modelVersionUUID);
700 expected.setPolicyName(policyName);
701 ConfigurationResourceCustomization configurationResourceCustomization =
702 new ConfigurationResourceCustomization();
703 configurationResourceCustomization.setModelCustomizationUUID(modelCustUUID);
704 configurationResourceCustomization.setConfigurationResource(new ConfigurationResource());
705 configurationResourceCustomization.getConfigurationResource().setModelInvariantUUID(modelInvariantUUID);
706 configurationResourceCustomization.getConfigurationResource().setModelUUID(modelVersionUUID);
707 CvnfcConfigurationCustomization policyNameTable = new CvnfcConfigurationCustomization();
708 policyNameTable.setCvnfcCustomization(new CvnfcCustomization());
709 policyNameTable.getCvnfcCustomization().setVnfcCustomization(new VnfcCustomization());
710 policyNameTable.setPolicyName(policyName);
712 ModelInfoConfiguration actual = bbInputSetupMapperLayer
713 .mapCatalogConfigurationToConfiguration(configurationResourceCustomization, policyNameTable);
715 assertThat(actual, sameBeanAs(expected));
719 public void testmapCatalogConfigurationToFabricConfiguration() {
720 String modelCustUUID = "modelCustomizationUUID";
721 String modelInvariantUUID = "modelInvariantUUID";
722 String modelVersionUUID = "modelUUID";
723 String policyName = "policyName";
724 ModelInfoConfiguration expected = new ModelInfoConfiguration();
725 expected.setModelCustomizationId(modelCustUUID);
726 expected.setModelInvariantId(modelInvariantUUID);
727 expected.setModelVersionId(modelVersionUUID);
728 expected.setPolicyName(policyName);
730 CvnfcConfigurationCustomization fabricCustomization = new CvnfcConfigurationCustomization();
731 fabricCustomization.setCvnfcCustomization(new CvnfcCustomization());
732 fabricCustomization.getCvnfcCustomization().setVnfcCustomization(new VnfcCustomization());
733 fabricCustomization.setPolicyName(policyName);
734 fabricCustomization.setModelCustomizationUUID(modelCustUUID);
736 ConfigurationResource configurationResource = new ConfigurationResource();
737 configurationResource.setModelUUID(modelVersionUUID);
738 configurationResource.setModelInvariantUUID(modelInvariantUUID);
739 fabricCustomization.setConfigurationResource(configurationResource);
741 ModelInfoConfiguration actual =
742 bbInputSetupMapperLayer.mapCatalogConfigurationToConfiguration(fabricCustomization);
744 assertThat(actual, sameBeanAs(expected));
748 public void testMapNameValueUserParams() throws IOException {
749 RequestDetails requestDetails = mapper
750 .readValue(new File(RESOURCE_PATH + "RequestDetailsInput_mapReqContext.json"), RequestDetails.class);
751 Map<String, Object> actual =
752 bbInputSetupMapperLayer.mapNameValueUserParams(requestDetails.getRequestParameters());
754 assertTrue(actual.containsKey("mns_vfw_protected_route_prefixes"));
755 assertTrue(actual.get("mns_vfw_protected_route_prefixes").toString()
756 .contains("interface_route_table_routes_route"));
757 assertTrue(actual.get("mns_vfw_protected_route_prefixes").toString().contains("1.1.1.1/32"));
758 assertTrue(actual.get("mns_vfw_protected_route_prefixes").toString().contains("0::1/128"));
759 assertTrue(actual.containsKey("name1"));
760 assertTrue(actual.containsValue("value1"));
761 assertTrue(actual.get("name1").equals("value1"));
763 assertFalse(actual.containsKey("ignore"));
764 assertFalse(actual.containsValue("ignore"));
768 public void testMapRequestParameters() throws IOException {
769 RequestDetails requestDetails = mapper
770 .readValue(new File(RESOURCE_PATH + "RequestDetailsInput_mapReqContext.json"), RequestDetails.class);
771 RequestParameters actual = bbInputSetupMapperLayer.mapRequestParameters(requestDetails.getRequestParameters());
773 assertEquals(actual.getUsePreload(), requestDetails.getRequestParameters().getUsePreload());
774 assertEquals(actual.getSubscriptionServiceType(),
775 requestDetails.getRequestParameters().getSubscriptionServiceType());
776 assertEquals(actual.getPayload(), requestDetails.getRequestParameters().getPayload());
779 protected RequestParameters mapRequestParameters(
780 org.onap.so.serviceinstancebeans.RequestParameters requestParameters) {
781 RequestParameters requestParams = new RequestParameters();
782 requestParams.setaLaCarte(requestParameters.getALaCarte());
783 requestParams.setUsePreload(requestParameters.getUsePreload());
784 requestParams.setSubscriptionServiceType(requestParameters.getSubscriptionServiceType());
785 requestParams.setUserParams(requestParameters.getUserParams());
786 requestParams.setPayload(requestParameters.getPayload());
787 return requestParams;