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.Pnf;
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.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.ModelInfoVfModule;
65 import org.onap.so.db.catalog.beans.CollectionNetworkResourceCustomization;
66 import org.onap.so.db.catalog.beans.CollectionResource;
67 import org.onap.so.db.catalog.beans.CollectionResourceCustomization;
68 import org.onap.so.db.catalog.beans.CollectionResourceInstanceGroupCustomization;
69 import org.onap.so.db.catalog.beans.ConfigurationResource;
70 import org.onap.so.db.catalog.beans.ConfigurationResourceCustomization;
71 import org.onap.so.db.catalog.beans.CvnfcConfigurationCustomization;
72 import org.onap.so.db.catalog.beans.CvnfcCustomization;
73 import org.onap.so.db.catalog.beans.InstanceGroup;
74 import org.onap.so.db.catalog.beans.NetworkResourceCustomization;
75 import org.onap.so.db.catalog.beans.OrchestrationStatus;
76 import org.onap.so.db.catalog.beans.Service;
77 import org.onap.so.db.catalog.beans.VfModuleCustomization;
78 import org.onap.so.db.catalog.beans.VnfResourceCustomization;
79 import org.onap.so.db.catalog.beans.VnfcCustomization;
80 import org.onap.so.serviceinstancebeans.CloudConfiguration;
81 import org.onap.so.serviceinstancebeans.RequestDetails;
82 import com.fasterxml.jackson.core.JsonParseException;
83 import com.fasterxml.jackson.databind.JsonMappingException;
84 import com.fasterxml.jackson.databind.ObjectMapper;
86 public class BBInputSetupMapperLayerTest {
88 BBInputSetupMapperLayer bbInputSetupMapperLayer = new BBInputSetupMapperLayer();
90 ObjectMapper mapper = new ObjectMapper();
92 private static final String RESOURCE_PATH = "src/test/resources/__files/ExecuteBuildingBlock/";
95 public void testMapOrchestrationStatusFromAAI() {
96 OrchestrationStatus expected = OrchestrationStatus.INVENTORIED;
97 String orchStatusInput = "Inventoried";
98 OrchestrationStatus actual = bbInputSetupMapperLayer.mapOrchestrationStatusFromAAI(orchStatusInput);
99 assertThat(actual, sameBeanAs(expected));
101 expected = OrchestrationStatus.ASSIGNED;
102 orchStatusInput = "Assigned";
103 actual = bbInputSetupMapperLayer.mapOrchestrationStatusFromAAI(orchStatusInput);
104 assertThat(actual, sameBeanAs(expected));
106 expected = OrchestrationStatus.ACTIVE;
107 orchStatusInput = "Active";
108 actual = bbInputSetupMapperLayer.mapOrchestrationStatusFromAAI(orchStatusInput);
109 assertThat(actual, sameBeanAs(expected));
111 expected = OrchestrationStatus.CREATED;
112 orchStatusInput = "Created";
113 actual = bbInputSetupMapperLayer.mapOrchestrationStatusFromAAI(orchStatusInput);
114 assertThat(actual, sameBeanAs(expected));
116 expected = OrchestrationStatus.PRECREATED;
117 orchStatusInput = "PreCreated";
118 actual = bbInputSetupMapperLayer.mapOrchestrationStatusFromAAI(orchStatusInput);
119 assertThat(actual, sameBeanAs(expected));
121 expected = OrchestrationStatus.PENDING_CREATE;
122 orchStatusInput = "PendingCreate";
123 actual = bbInputSetupMapperLayer.mapOrchestrationStatusFromAAI(orchStatusInput);
124 assertThat(actual, sameBeanAs(expected));
126 expected = OrchestrationStatus.PENDING_DELETE;
127 orchStatusInput = "PendingDelete";
128 actual = bbInputSetupMapperLayer.mapOrchestrationStatusFromAAI(orchStatusInput);
129 assertThat(actual, sameBeanAs(expected));
131 expected = OrchestrationStatus.PENDING;
132 orchStatusInput = "Pending";
133 actual = bbInputSetupMapperLayer.mapOrchestrationStatusFromAAI(orchStatusInput);
134 assertThat(actual, sameBeanAs(expected));
136 expected = OrchestrationStatus.PENDING_ACTIVATION;
137 orchStatusInput = "PendingActivation";
138 actual = bbInputSetupMapperLayer.mapOrchestrationStatusFromAAI(orchStatusInput);
139 assertThat(actual, sameBeanAs(expected));
143 public void testMapOrchestrationFuzzyCases() {
144 List<String> values = Arrays.asList("pending-create", "pending_Create", "pendinggcreate", "PendingCreate");
145 values.forEach(value -> {
146 assertThat(bbInputSetupMapperLayer.mapOrchestrationStatusFromAAI(value),
147 equalTo(OrchestrationStatus.PENDING_CREATE));
152 public void testMapAAICustomer() throws IOException {
153 Customer expected = mapper.readValue(new File(RESOURCE_PATH + "Customer.json"), Customer.class);
155 org.onap.aai.domain.yang.Customer customerAAI = mapper.readValue(new File(RESOURCE_PATH + "Customer_AAI.json"),
156 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(new File(RESOURCE_PATH + "ServiceSubscriptionExpected.json"),
166 ServiceSubscription.class);
168 org.onap.aai.domain.yang.ServiceSubscription svcSubscriptionAAI =
169 mapper.readValue(new File(RESOURCE_PATH + "ServiceSubscription_AAI.json"),
170 org.onap.aai.domain.yang.ServiceSubscription.class);
172 ServiceSubscription actual = bbInputSetupMapperLayer.mapAAIServiceSubscription(svcSubscriptionAAI);
174 assertThat(actual, sameBeanAs(expected));
178 public void testMapAAIProject() throws IOException {
179 Project expected = mapper.readValue(new File(RESOURCE_PATH + "Project.json"), Project.class);
181 org.onap.aai.domain.yang.Project projectAAI = new org.onap.aai.domain.yang.Project();
182 projectAAI.setProjectName("projectName");
184 Project actual = bbInputSetupMapperLayer.mapAAIProject(projectAAI);
186 assertThat(actual, sameBeanAs(expected));
190 public void testMapRequestProject() throws IOException {
191 Project expected = mapper.readValue(new File(RESOURCE_PATH + "Project.json"), Project.class);
193 org.onap.so.serviceinstancebeans.Project requestProject = new org.onap.so.serviceinstancebeans.Project();
194 requestProject.setProjectName("projectName");
196 Project actual = bbInputSetupMapperLayer.mapRequestProject(requestProject);
198 assertThat(actual, sameBeanAs(expected));
202 public void testMapAAIOwningEntity() throws IOException {
203 OwningEntity expected = mapper.readValue(new File(RESOURCE_PATH + "OwningEntity.json"), OwningEntity.class);
205 org.onap.aai.domain.yang.OwningEntity entityAAI = new org.onap.aai.domain.yang.OwningEntity();
206 entityAAI.setOwningEntityId("owningEntityId");
207 entityAAI.setOwningEntityName("owningEntityName");
209 OwningEntity actual = bbInputSetupMapperLayer.mapAAIOwningEntity(entityAAI);
211 assertThat(actual, sameBeanAs(expected));
215 public void testMapRequestOwningEntity() throws IOException {
216 OwningEntity expected = mapper.readValue(new File(RESOURCE_PATH + "OwningEntity.json"), OwningEntity.class);
218 org.onap.so.serviceinstancebeans.OwningEntity requestOwningEntity =
219 new org.onap.so.serviceinstancebeans.OwningEntity();
220 requestOwningEntity.setOwningEntityId("owningEntityId");
221 requestOwningEntity.setOwningEntityName("owningEntityName");
223 OwningEntity actual = bbInputSetupMapperLayer.mapRequestOwningEntity(requestOwningEntity);
225 assertThat(actual, sameBeanAs(expected));
229 public void testMapAAIPlatform() throws IOException {
230 Platform expected = mapper.readValue(new File(RESOURCE_PATH + "Platform.json"), Platform.class);
232 org.onap.aai.domain.yang.Platform platformAAI = new org.onap.aai.domain.yang.Platform();
233 platformAAI.setPlatformName("platformName");
235 Platform actual = bbInputSetupMapperLayer.mapAAIPlatform(platformAAI);
237 assertThat(actual, sameBeanAs(expected));
241 public void testMapAAILineOfBusiness() throws IOException {
242 LineOfBusiness expected =
243 mapper.readValue(new File(RESOURCE_PATH + "LineOfBusiness.json"), LineOfBusiness.class);
245 org.onap.aai.domain.yang.LineOfBusiness lobAAI = new org.onap.aai.domain.yang.LineOfBusiness();
246 lobAAI.setLineOfBusinessName("lineOfBusinessName");
248 LineOfBusiness actual = bbInputSetupMapperLayer.mapAAILineOfBusiness(lobAAI);
250 assertThat(actual, sameBeanAs(expected));
254 public void testMapAAINetworkPolicy() throws JsonParseException, JsonMappingException, IOException {
255 NetworkPolicy expectedNetworkPolicy =
256 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 =
272 mapper.readValue(new File(RESOURCE_PATH + "VolumeGroup.json"), VolumeGroup.class);
274 org.onap.aai.domain.yang.VolumeGroup aaiVolumeGroup = mapper.readValue(
275 new File(RESOURCE_PATH + "VolumeGroup_AAI.json"), org.onap.aai.domain.yang.VolumeGroup.class);
277 VolumeGroup actualVolumeGroup = bbInputSetupMapperLayer.mapAAIVolumeGroup(aaiVolumeGroup);
279 assertThat(actualVolumeGroup, sameBeanAs(expectedVolumeGroup));
283 public void testMapCatalogServiceIntoServiceInstance() throws IOException {
284 ModelInfoServiceInstance expected = mapper.readValue(new File(RESOURCE_PATH + "ModelInfoServiceInstance.json"),
285 ModelInfoServiceInstance.class);
287 Service catalogService = mapper.readValue(new File(RESOURCE_PATH + "CatalogServiceInput.json"), Service.class);
289 ModelInfoServiceInstance actual = bbInputSetupMapperLayer.mapCatalogServiceIntoServiceInstance(catalogService);
291 assertThat(actual, sameBeanAs(expected));
295 public void testMapCatalogInstanceGroupToInstanceGroup() throws IOException {
296 ModelInfoInstanceGroup expected =
297 mapper.readValue(new File(RESOURCE_PATH + "ModelInfoInstanceGroup.json"), ModelInfoInstanceGroup.class);
299 InstanceGroup instanceGroup =
300 mapper.readValue(new File(RESOURCE_PATH + "InstanceGroup.json"), InstanceGroup.class);
301 instanceGroup.setCollectionInstanceGroupCustomizations(new ArrayList<>());
302 CollectionResourceInstanceGroupCustomization collectionInstanceGroupCust =
303 new CollectionResourceInstanceGroupCustomization();
304 collectionInstanceGroupCust.setModelCustomizationUUID("modelCustomizationUUID");
305 collectionInstanceGroupCust.setFunction("function");
306 collectionInstanceGroupCust.setDescription("description");
307 instanceGroup.getCollectionInstanceGroupCustomizations().add(collectionInstanceGroupCust);
308 CollectionResourceCustomization collectionResourceCust = new CollectionResourceCustomization();
309 collectionResourceCust.setModelCustomizationUUID("modelCustomizationUUID");
310 ModelInfoInstanceGroup actual =
311 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 =
333 new CollectionNetworkResourceCustomization();
334 collectionNetworkResourceCust.setModelCustomizationUUID(modelCustomizationUUID);
335 collectionNetworkResourceCust.setModelInstanceName(modelInstanceName);
336 collectionNetworkResourceCust.setNetworkRole(networkRole);
337 collectionNetworkResourceCust.setNetworkScope(networkScope);
338 collectionNetworkResourceCust.setNetworkTechnology(networkTechnology);
339 collectionNetworkResourceCust.setNetworkType(networkType);
340 NetworkResourceCustomization actual = bbInputSetupMapperLayer
341 .mapCollectionNetworkResourceCustToNetworkResourceCust(collectionNetworkResourceCust);
343 assertThat(actual, sameBeanAs(expected));
347 public void testMapCatalogCollectionToCollection() throws IOException {
348 ModelInfoCollection expected =
349 mapper.readValue(new File(RESOURCE_PATH + "ModelInfoCollection.json"), ModelInfoCollection.class);
351 CollectionResourceCustomization collectionCust =
352 mapper.readValue(new File(RESOURCE_PATH + "CollectionResourceCustomization.json"),
353 CollectionResourceCustomization.class);
355 CollectionResource collectionResource =
356 mapper.readValue(new File(RESOURCE_PATH + "CollectionResource.json"), CollectionResource.class);
358 ModelInfoCollection actual =
359 bbInputSetupMapperLayer.mapCatalogCollectionToCollection(collectionCust, collectionResource);
361 assertThat(actual, sameBeanAs(expected));
365 public void testMapAAIServiceInstanceIntoServiceInstance() throws IOException {
366 ServiceInstance expected = mapper.readValue(
367 new File(RESOURCE_PATH + "ServiceInstance_aaiServiceInstanceToSI.json"), ServiceInstance.class);
369 org.onap.aai.domain.yang.ServiceInstance serviceInstanceAAI =
370 mapper.readValue(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"), ServiceInstance.class);
383 Map<ResourceKey, String> resourcesToBeOrchestrated = new HashMap<>();
384 resourcesToBeOrchestrated.put(ResourceKey.GENERIC_VNF_ID, "vnfId");
385 Platform platformMSO = new Platform();
386 platformMSO.setPlatformName("platformName");
387 LineOfBusiness lineOfBusinessMSO = new LineOfBusiness();
388 lineOfBusinessMSO.setLineOfBusinessName("lineOfBusinessName");
390 ServiceInstance actual = mapper.readValue(
391 new File(RESOURCE_PATH + "ServiceInstanceAAIPlatformAndLOBInput.json"), ServiceInstance.class);
393 bbInputSetupMapperLayer.setPlatformAndLOBIntoServiceInstance(platformMSO, lineOfBusinessMSO, actual,
394 resourcesToBeOrchestrated);
396 assertThat(actual, sameBeanAs(expected));
400 public void testMapAAIL3NetworkIntoL3Network() throws IOException {
402 mapper.readValue(new File(RESOURCE_PATH + "l3NetworkExpectedWithSubnet.json"), L3Network.class);
404 org.onap.aai.domain.yang.L3Network aaiL3Network =
405 mapper.readValue(new File(RESOURCE_PATH + "aaiL3NetworkInputWithSubnets.json"),
406 org.onap.aai.domain.yang.L3Network.class);
408 L3Network actual = bbInputSetupMapperLayer.mapAAIL3Network(aaiL3Network);
410 assertThat(actual, sameBeanAs(expected));
414 public void testMapAAIGenericVnfIntoGenericVnf() throws IOException {
415 GenericVnf expected = mapper.readValue(new File(RESOURCE_PATH + "GenericVnfExpected.json"), GenericVnf.class);
416 org.onap.aai.domain.yang.GenericVnf aaiGenericVnf = mapper.readValue(
417 new File(RESOURCE_PATH + "aaiGenericVnfInput.json"), org.onap.aai.domain.yang.GenericVnf.class);
419 GenericVnf actual = bbInputSetupMapperLayer.mapAAIGenericVnfIntoGenericVnf(aaiGenericVnf);
421 assertThat(actual, sameBeanAs(expected));
425 public void testMapAAIPnfIntoPnf() throws IOException {
426 Pnf expected = mapper.readValue(new File(RESOURCE_PATH + "PnfExpected.json"), Pnf.class);
427 org.onap.aai.domain.yang.Pnf aaiPnf =
428 mapper.readValue(new File(RESOURCE_PATH + "aaiPnfInput.json"), org.onap.aai.domain.yang.Pnf.class);
430 Pnf actual = bbInputSetupMapperLayer.mapAAIPnfIntoPnf(aaiPnf);
432 assertThat(actual, sameBeanAs(expected));
436 public void testMapAAICollectionIntoCollection() throws JsonParseException, JsonMappingException, IOException {
437 org.onap.aai.domain.yang.Collection aaiCollection = mapper
438 .readValue(new File(RESOURCE_PATH + "CollectionInput.json"), org.onap.aai.domain.yang.Collection.class);
440 Collection expectedCollection =
441 mapper.readValue(new File(RESOURCE_PATH + "CollectionExpected.json"), Collection.class);
443 Collection actualCollection = bbInputSetupMapperLayer.mapAAICollectionIntoCollection(aaiCollection);
445 assertThat(actualCollection, sameBeanAs(expectedCollection));
449 public void testMapAAIInstanceGroupIntoInstanceGroup()
450 throws JsonParseException, JsonMappingException, IOException {
451 org.onap.aai.domain.yang.InstanceGroup aaiInstanceGroup = mapper.readValue(
452 new File(RESOURCE_PATH + "InstanceGroupInput.json"), org.onap.aai.domain.yang.InstanceGroup.class);
454 org.onap.so.bpmn.servicedecomposition.bbobjects.InstanceGroup expectedInstanceGroup =
455 mapper.readValue(new File(RESOURCE_PATH + "InstanceGroupExpected.json"),
456 org.onap.so.bpmn.servicedecomposition.bbobjects.InstanceGroup.class);
458 org.onap.so.bpmn.servicedecomposition.bbobjects.InstanceGroup actualInstanceGroup =
459 bbInputSetupMapperLayer.mapAAIInstanceGroupIntoInstanceGroup(aaiInstanceGroup);
461 assertThat(actualInstanceGroup, sameBeanAs(expectedInstanceGroup));
465 public void testMapAAIRouteTableReferenceIntoRouteTableReference()
466 throws JsonParseException, JsonMappingException, IOException {
467 org.onap.aai.domain.yang.RouteTableReference aaiRouteTableReference =
468 mapper.readValue(new File(RESOURCE_PATH + "RouteTableReferenceInput.json"),
469 org.onap.aai.domain.yang.RouteTableReference.class);
471 RouteTableReference expectedRouteTableReference = mapper
472 .readValue(new File(RESOURCE_PATH + "RouteTableReferenceExpected.json"), RouteTableReference.class);
474 RouteTableReference actualRouteTableReference =
475 bbInputSetupMapperLayer.mapAAIRouteTableReferenceIntoRouteTableReference(aaiRouteTableReference);
477 assertThat(actualRouteTableReference, sameBeanAs(expectedRouteTableReference));
481 public void testMapCatalogNetworkToNetwork() throws JsonParseException, JsonMappingException, IOException {
482 NetworkResourceCustomization networkResourceCustomization = mapper.readValue(
483 new File(RESOURCE_PATH + "NetworkResourceCustomizationInput.json"), NetworkResourceCustomization.class);
485 ModelInfoNetwork expectedModelInfoNetwork =
486 mapper.readValue(new File(RESOURCE_PATH + "ModelInfoNetworkExpected.json"), ModelInfoNetwork.class);
488 ModelInfoNetwork actualModelInfoNetwork =
489 bbInputSetupMapperLayer.mapCatalogNetworkToNetwork(networkResourceCustomization);
491 assertThat(actualModelInfoNetwork, sameBeanAs(expectedModelInfoNetwork));
495 public void testMapCatalogVnfToVnf() throws IOException {
496 VnfResourceCustomization vnfResourceCustomization = mapper.readValue(
497 new File(RESOURCE_PATH + "VnfResourceCustomizationInput.json"), VnfResourceCustomization.class);
499 ModelInfoGenericVnf expectedModelInfoGenericVnf = mapper
500 .readValue(new File(RESOURCE_PATH + "ModelInfoGenericVnfExpected.json"), ModelInfoGenericVnf.class);
502 ModelInfoGenericVnf actualModelInfoGenericVnf =
503 bbInputSetupMapperLayer.mapCatalogVnfToVnf(vnfResourceCustomization);
505 assertThat(actualModelInfoGenericVnf, sameBeanAs(expectedModelInfoGenericVnf));
509 public void testMapCatalogVfModuleToVfModule() throws JsonParseException, JsonMappingException, IOException {
510 VfModuleCustomization vfResourceCustomization = mapper
511 .readValue(new File(RESOURCE_PATH + "VfModuleCustomizationInput.json"), VfModuleCustomization.class);
513 ModelInfoVfModule expectedModelInfoVfModule =
514 mapper.readValue(new File(RESOURCE_PATH + "ModelInfoVfModuleExpected.json"), ModelInfoVfModule.class);
516 ModelInfoVfModule actualModelInfoVfModule =
517 bbInputSetupMapperLayer.mapCatalogVfModuleToVfModule(vfResourceCustomization);
519 assertThat(actualModelInfoVfModule, sameBeanAs(expectedModelInfoVfModule));
523 public void testMapRequestPlatform() throws JsonParseException, JsonMappingException, IOException {
524 org.onap.so.serviceinstancebeans.Platform platform = mapper.readValue(
525 new File(RESOURCE_PATH + "RequestPlatformInput.json"), org.onap.so.serviceinstancebeans.Platform.class);
527 Platform expectedPlatform = mapper.readValue(new File(RESOURCE_PATH + "PlatformExpected.json"), Platform.class);
529 Platform actualPlatform = bbInputSetupMapperLayer.mapRequestPlatform(platform);
531 assertThat(actualPlatform, sameBeanAs(expectedPlatform));
535 public void testMapRequestLineOfBusiness() throws JsonParseException, JsonMappingException, IOException {
536 org.onap.so.serviceinstancebeans.LineOfBusiness lineOfBusiness =
537 mapper.readValue(new File(RESOURCE_PATH + "RequestLineOfBusinessInput.json"),
538 org.onap.so.serviceinstancebeans.LineOfBusiness.class);
540 LineOfBusiness expectedLineOfBusiness =
541 mapper.readValue(new File(RESOURCE_PATH + "LineOfBusinessExpected.json"), LineOfBusiness.class);
543 LineOfBusiness actualLineOfBusiness = bbInputSetupMapperLayer.mapRequestLineOfBusiness(lineOfBusiness);
545 assertThat(actualLineOfBusiness, sameBeanAs(expectedLineOfBusiness));
549 public void testMapAAIConfiguration() throws JsonParseException, JsonMappingException, IOException {
550 org.onap.aai.domain.yang.Configuration configurationAAI = mapper.readValue(
551 new File(RESOURCE_PATH + "ConfigurationInput.json"), org.onap.aai.domain.yang.Configuration.class);
553 Configuration expectedConfiguration =
554 mapper.readValue(new File(RESOURCE_PATH + "ConfigurationExpected.json"), Configuration.class);
556 Configuration actualConfiguration = bbInputSetupMapperLayer.mapAAIConfiguration(configurationAAI);
558 assertThat(actualConfiguration, sameBeanAs(expectedConfiguration));
562 public void testMapRequestContext() throws IOException {
563 RequestContext expected =
564 mapper.readValue(new File(RESOURCE_PATH + "RequestContextExpected.json"), RequestContext.class);
566 RequestDetails requestDetails = mapper
567 .readValue(new File(RESOURCE_PATH + "RequestDetailsInput_mapReqContext.json"), RequestDetails.class);
568 RequestContext actual = bbInputSetupMapperLayer.mapRequestContext(requestDetails);
570 assertThat(actual, sameBeanAs(expected));
574 public void testMapOrchestrationContext() throws IOException {
575 OrchestrationContext expected = new OrchestrationContext();
576 expected.setIsRollbackEnabled(true);
578 RequestDetails requestDetails = mapper
579 .readValue(new File(RESOURCE_PATH + "RequestDetailsInput_mapReqContext.json"), RequestDetails.class);
581 OrchestrationContext actual = bbInputSetupMapperLayer.mapOrchestrationContext(requestDetails);
583 assertThat(actual, sameBeanAs(expected));
587 public void testMapOrchestrationContextNoRequestInfo() throws IOException {
588 OrchestrationContext expected = new OrchestrationContext();
589 expected.setIsRollbackEnabled(false);
591 RequestDetails requestDetails = mapper.readValue(
592 new File(RESOURCE_PATH + "RequestDetailsInput_mapReqContextNoRequestInfo.json"), RequestDetails.class);
594 OrchestrationContext actual = bbInputSetupMapperLayer.mapOrchestrationContext(requestDetails);
596 assertThat(actual, sameBeanAs(expected));
600 public void testMapLocationContext() {
601 CloudRegion expected = new CloudRegion();
602 expected.setCloudOwner("test-owner-name");
603 expected.setLcpCloudRegionId("cloudRegionId");
604 expected.setComplex("complexName");
605 expected.setTenantId("tenantId");
606 CloudConfiguration cloudConfig = new CloudConfiguration();
607 cloudConfig.setTenantId("tenantId");
608 cloudConfig.setLcpCloudRegionId("cloudRegionId");
609 cloudConfig.setAicNodeClli("aicNodeClli");
610 org.onap.aai.domain.yang.CloudRegion cloudRegion = new org.onap.aai.domain.yang.CloudRegion();
611 cloudRegion.setCloudOwner("test-owner-name");
612 cloudRegion.setCloudRegionId("cloudRegionId");
613 cloudRegion.setComplexName("complexName");
615 CloudRegion actual = bbInputSetupMapperLayer.mapCloudRegion(cloudConfig, cloudRegion);
617 assertThat(actual, sameBeanAs(expected));
621 public void testMapCloudRegion() {
622 CloudRegion expected = new CloudRegion();
623 expected.setCloudOwner("test-owner-name");
624 expected.setLcpCloudRegionId("cloudRegionId");
625 expected.setTenantId("tenantId");
626 expected.setCloudRegionVersion("cloudRegionVersion");
628 CloudConfiguration cloudConfig = new CloudConfiguration();
629 cloudConfig.setTenantId("tenantId");
630 cloudConfig.setLcpCloudRegionId("cloudRegionId");
631 cloudConfig.setAicNodeClli("aicNodeClli");
633 org.onap.aai.domain.yang.CloudRegion cloudRegion = new org.onap.aai.domain.yang.CloudRegion();
634 cloudRegion.setCloudOwner("test-owner-name");
635 cloudRegion.setCloudRegionId("cloudRegionId");
636 cloudRegion.setCloudRegionVersion("cloudRegionVersion");
638 CloudRegion actual = bbInputSetupMapperLayer.mapCloudRegion(cloudConfig, cloudRegion);
640 assertThat(actual, sameBeanAs(expected));
644 public void testMapTenant() {
645 Tenant expected = new Tenant();
646 expected.setTenantId("tenantId");
647 expected.setTenantName("tenantName");
648 expected.setTenantContext("tenantContext");
650 org.onap.aai.domain.yang.Tenant aaiTenant = new org.onap.aai.domain.yang.Tenant();
651 aaiTenant.setTenantId("tenantId");
652 aaiTenant.setTenantName("tenantName");
653 aaiTenant.setTenantContext("tenantContext");
655 Tenant actual = bbInputSetupMapperLayer.mapTenant(aaiTenant);
657 assertThat(actual, sameBeanAs(expected));
661 public void testMapCloudRegionWithNullCheck() {
662 CloudRegion expected = new CloudRegion();
664 CloudRegion actual = bbInputSetupMapperLayer.mapCloudRegion(null, null);
666 assertThat(actual, sameBeanAs(expected));
670 public void testmapCatalogConfigurationToConfiguration() {
671 String modelCustUUID = "modelCustomizationUUID";
672 String modelInvariantUUID = "modelInvariantUUID";
673 String modelVersionUUID = "modelUUID";
674 String policyName = "policyName";
675 ModelInfoConfiguration expected = new ModelInfoConfiguration();
676 expected.setModelCustomizationId(modelCustUUID);
677 expected.setModelInvariantId(modelInvariantUUID);
678 expected.setModelVersionId(modelVersionUUID);
679 expected.setPolicyName(policyName);
680 ConfigurationResourceCustomization configurationResourceCustomization =
681 new ConfigurationResourceCustomization();
682 configurationResourceCustomization.setModelCustomizationUUID(modelCustUUID);
683 configurationResourceCustomization.setConfigurationResource(new ConfigurationResource());
684 configurationResourceCustomization.getConfigurationResource().setModelInvariantUUID(modelInvariantUUID);
685 configurationResourceCustomization.getConfigurationResource().setModelUUID(modelVersionUUID);
686 CvnfcConfigurationCustomization policyNameTable = new CvnfcConfigurationCustomization();
687 policyNameTable.setCvnfcCustomization(new CvnfcCustomization());
688 policyNameTable.getCvnfcCustomization().setVnfcCustomization(new VnfcCustomization());
689 policyNameTable.setPolicyName(policyName);
691 ModelInfoConfiguration actual = bbInputSetupMapperLayer
692 .mapCatalogConfigurationToConfiguration(configurationResourceCustomization, policyNameTable);
694 assertThat(actual, sameBeanAs(expected));
698 public void testmapCatalogConfigurationToFabricConfiguration() {
699 String modelCustUUID = "modelCustomizationUUID";
700 String modelInvariantUUID = "modelInvariantUUID";
701 String modelVersionUUID = "modelUUID";
702 String policyName = "policyName";
703 ModelInfoConfiguration expected = new ModelInfoConfiguration();
704 expected.setModelCustomizationId(modelCustUUID);
705 expected.setModelInvariantId(modelInvariantUUID);
706 expected.setModelVersionId(modelVersionUUID);
707 expected.setPolicyName(policyName);
709 CvnfcConfigurationCustomization fabricCustomization = new CvnfcConfigurationCustomization();
710 fabricCustomization.setCvnfcCustomization(new CvnfcCustomization());
711 fabricCustomization.getCvnfcCustomization().setVnfcCustomization(new VnfcCustomization());
712 fabricCustomization.setPolicyName(policyName);
713 fabricCustomization.setModelCustomizationUUID(modelCustUUID);
715 ConfigurationResource configurationResource = new ConfigurationResource();
716 configurationResource.setModelUUID(modelVersionUUID);
717 configurationResource.setModelInvariantUUID(modelInvariantUUID);
718 fabricCustomization.setConfigurationResource(configurationResource);
720 ModelInfoConfiguration actual =
721 bbInputSetupMapperLayer.mapCatalogConfigurationToConfiguration(fabricCustomization);
723 assertThat(actual, sameBeanAs(expected));
727 public void testMapNameValueUserParams() throws IOException {
728 RequestDetails requestDetails = mapper
729 .readValue(new File(RESOURCE_PATH + "RequestDetailsInput_mapReqContext.json"), RequestDetails.class);
730 Map<String, Object> actual =
731 bbInputSetupMapperLayer.mapNameValueUserParams(requestDetails.getRequestParameters());
733 assertTrue(actual.containsKey("mns_vfw_protected_route_prefixes"));
734 assertTrue(actual.get("mns_vfw_protected_route_prefixes").toString()
735 .contains("interface_route_table_routes_route"));
736 assertTrue(actual.get("mns_vfw_protected_route_prefixes").toString().contains("1.1.1.1/32"));
737 assertTrue(actual.get("mns_vfw_protected_route_prefixes").toString().contains("0::1/128"));
738 assertTrue(actual.containsKey("name1"));
739 assertTrue(actual.containsValue("value1"));
740 assertTrue(actual.get("name1").equals("value1"));
742 assertFalse(actual.containsKey("ignore"));
743 assertFalse(actual.containsValue("ignore"));
747 public void testMapRequestParameters() throws IOException {
748 RequestDetails requestDetails = mapper
749 .readValue(new File(RESOURCE_PATH + "RequestDetailsInput_mapReqContext.json"), RequestDetails.class);
750 RequestParameters actual = bbInputSetupMapperLayer.mapRequestParameters(requestDetails.getRequestParameters());
752 assertEquals(actual.getUsePreload(), requestDetails.getRequestParameters().getUsePreload());
753 assertEquals(actual.getSubscriptionServiceType(),
754 requestDetails.getRequestParameters().getSubscriptionServiceType());
755 assertEquals(actual.getPayload(), requestDetails.getRequestParameters().getPayload());
758 protected RequestParameters mapRequestParameters(
759 org.onap.so.serviceinstancebeans.RequestParameters requestParameters) {
760 RequestParameters requestParams = new RequestParameters();
761 requestParams.setaLaCarte(requestParameters.getALaCarte());
762 requestParams.setUsePreload(requestParameters.getUsePreload());
763 requestParams.setSubscriptionServiceType(requestParameters.getSubscriptionServiceType());
764 requestParams.setUserParams(requestParameters.getUserParams());
765 requestParams.setPayload(requestParameters.getPayload());
766 return requestParams;