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.Project;
48 import org.onap.so.bpmn.servicedecomposition.bbobjects.RouteTableReference;
49 import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance;
50 import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceSubscription;
51 import org.onap.so.bpmn.servicedecomposition.bbobjects.Tenant;
52 import org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup;
53 import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey;
54 import org.onap.so.bpmn.servicedecomposition.generalobjects.OrchestrationContext;
55 import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext;
56 import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestParameters;
57 import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoCollection;
58 import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoConfiguration;
59 import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoGenericVnf;
60 import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoInstanceGroup;
61 import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoNetwork;
62 import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoServiceInstance;
63 import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoVfModule;
64 import org.onap.so.db.catalog.beans.CollectionNetworkResourceCustomization;
65 import org.onap.so.db.catalog.beans.CollectionResource;
66 import org.onap.so.db.catalog.beans.CollectionResourceCustomization;
67 import org.onap.so.db.catalog.beans.CollectionResourceInstanceGroupCustomization;
68 import org.onap.so.db.catalog.beans.ConfigurationResource;
69 import org.onap.so.db.catalog.beans.ConfigurationResourceCustomization;
70 import org.onap.so.db.catalog.beans.CvnfcConfigurationCustomization;
71 import org.onap.so.db.catalog.beans.CvnfcCustomization;
72 import org.onap.so.db.catalog.beans.InstanceGroup;
73 import org.onap.so.db.catalog.beans.NetworkResourceCustomization;
74 import org.onap.so.db.catalog.beans.OrchestrationStatus;
75 import org.onap.so.db.catalog.beans.Service;
76 import org.onap.so.db.catalog.beans.VfModuleCustomization;
77 import org.onap.so.db.catalog.beans.VnfResourceCustomization;
78 import org.onap.so.db.catalog.beans.CvnfcConfigurationCustomization;
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 testMapAAICollectionIntoCollection() throws JsonParseException, JsonMappingException, IOException {
426 org.onap.aai.domain.yang.Collection aaiCollection = mapper
427 .readValue(new File(RESOURCE_PATH + "CollectionInput.json"), org.onap.aai.domain.yang.Collection.class);
429 Collection expectedCollection =
430 mapper.readValue(new File(RESOURCE_PATH + "CollectionExpected.json"), Collection.class);
432 Collection actualCollection = bbInputSetupMapperLayer.mapAAICollectionIntoCollection(aaiCollection);
434 assertThat(actualCollection, sameBeanAs(expectedCollection));
438 public void testMapAAIInstanceGroupIntoInstanceGroup()
439 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 =
444 mapper.readValue(new File(RESOURCE_PATH + "InstanceGroupExpected.json"),
445 org.onap.so.bpmn.servicedecomposition.bbobjects.InstanceGroup.class);
447 org.onap.so.bpmn.servicedecomposition.bbobjects.InstanceGroup actualInstanceGroup =
448 bbInputSetupMapperLayer.mapAAIInstanceGroupIntoInstanceGroup(aaiInstanceGroup);
450 assertThat(actualInstanceGroup, sameBeanAs(expectedInstanceGroup));
454 public void testMapAAIRouteTableReferenceIntoRouteTableReference()
455 throws JsonParseException, JsonMappingException, IOException {
456 org.onap.aai.domain.yang.RouteTableReference aaiRouteTableReference =
457 mapper.readValue(new File(RESOURCE_PATH + "RouteTableReferenceInput.json"),
458 org.onap.aai.domain.yang.RouteTableReference.class);
460 RouteTableReference expectedRouteTableReference = mapper
461 .readValue(new File(RESOURCE_PATH + "RouteTableReferenceExpected.json"), RouteTableReference.class);
463 RouteTableReference actualRouteTableReference =
464 bbInputSetupMapperLayer.mapAAIRouteTableReferenceIntoRouteTableReference(aaiRouteTableReference);
466 assertThat(actualRouteTableReference, sameBeanAs(expectedRouteTableReference));
470 public void testMapCatalogNetworkToNetwork() throws JsonParseException, JsonMappingException, IOException {
471 NetworkResourceCustomization networkResourceCustomization = mapper.readValue(
472 new File(RESOURCE_PATH + "NetworkResourceCustomizationInput.json"), NetworkResourceCustomization.class);
474 ModelInfoNetwork expectedModelInfoNetwork =
475 mapper.readValue(new File(RESOURCE_PATH + "ModelInfoNetworkExpected.json"), ModelInfoNetwork.class);
477 ModelInfoNetwork actualModelInfoNetwork =
478 bbInputSetupMapperLayer.mapCatalogNetworkToNetwork(networkResourceCustomization);
480 assertThat(actualModelInfoNetwork, sameBeanAs(expectedModelInfoNetwork));
484 public void testMapCatalogVnfToVnf() throws IOException {
485 VnfResourceCustomization vnfResourceCustomization = mapper.readValue(
486 new File(RESOURCE_PATH + "VnfResourceCustomizationInput.json"), VnfResourceCustomization.class);
488 ModelInfoGenericVnf expectedModelInfoGenericVnf = mapper
489 .readValue(new File(RESOURCE_PATH + "ModelInfoGenericVnfExpected.json"), ModelInfoGenericVnf.class);
491 ModelInfoGenericVnf actualModelInfoGenericVnf =
492 bbInputSetupMapperLayer.mapCatalogVnfToVnf(vnfResourceCustomization);
494 assertThat(actualModelInfoGenericVnf, sameBeanAs(expectedModelInfoGenericVnf));
498 public void testMapCatalogVfModuleToVfModule() throws JsonParseException, JsonMappingException, IOException {
499 VfModuleCustomization vfResourceCustomization = mapper
500 .readValue(new File(RESOURCE_PATH + "VfModuleCustomizationInput.json"), VfModuleCustomization.class);
502 ModelInfoVfModule expectedModelInfoVfModule =
503 mapper.readValue(new File(RESOURCE_PATH + "ModelInfoVfModuleExpected.json"), ModelInfoVfModule.class);
505 ModelInfoVfModule actualModelInfoVfModule =
506 bbInputSetupMapperLayer.mapCatalogVfModuleToVfModule(vfResourceCustomization);
508 assertThat(actualModelInfoVfModule, sameBeanAs(expectedModelInfoVfModule));
512 public void testMapRequestPlatform() throws JsonParseException, JsonMappingException, IOException {
513 org.onap.so.serviceinstancebeans.Platform platform = mapper.readValue(
514 new File(RESOURCE_PATH + "RequestPlatformInput.json"), org.onap.so.serviceinstancebeans.Platform.class);
516 Platform expectedPlatform = mapper.readValue(new File(RESOURCE_PATH + "PlatformExpected.json"), Platform.class);
518 Platform actualPlatform = bbInputSetupMapperLayer.mapRequestPlatform(platform);
520 assertThat(actualPlatform, sameBeanAs(expectedPlatform));
524 public void testMapRequestLineOfBusiness() throws JsonParseException, JsonMappingException, IOException {
525 org.onap.so.serviceinstancebeans.LineOfBusiness lineOfBusiness =
526 mapper.readValue(new File(RESOURCE_PATH + "RequestLineOfBusinessInput.json"),
527 org.onap.so.serviceinstancebeans.LineOfBusiness.class);
529 LineOfBusiness expectedLineOfBusiness =
530 mapper.readValue(new File(RESOURCE_PATH + "LineOfBusinessExpected.json"), LineOfBusiness.class);
532 LineOfBusiness actualLineOfBusiness = bbInputSetupMapperLayer.mapRequestLineOfBusiness(lineOfBusiness);
534 assertThat(actualLineOfBusiness, sameBeanAs(expectedLineOfBusiness));
538 public void testMapAAIConfiguration() throws JsonParseException, JsonMappingException, IOException {
539 org.onap.aai.domain.yang.Configuration configurationAAI = mapper.readValue(
540 new File(RESOURCE_PATH + "ConfigurationInput.json"), org.onap.aai.domain.yang.Configuration.class);
542 Configuration expectedConfiguration =
543 mapper.readValue(new File(RESOURCE_PATH + "ConfigurationExpected.json"), Configuration.class);
545 Configuration actualConfiguration = bbInputSetupMapperLayer.mapAAIConfiguration(configurationAAI);
547 assertThat(actualConfiguration, sameBeanAs(expectedConfiguration));
551 public void testMapRequestContext() throws IOException {
552 RequestContext expected =
553 mapper.readValue(new File(RESOURCE_PATH + "RequestContextExpected.json"), RequestContext.class);
555 RequestDetails requestDetails = mapper
556 .readValue(new File(RESOURCE_PATH + "RequestDetailsInput_mapReqContext.json"), RequestDetails.class);
557 RequestContext actual = bbInputSetupMapperLayer.mapRequestContext(requestDetails);
559 assertThat(actual, sameBeanAs(expected));
563 public void testMapOrchestrationContext() throws IOException {
564 OrchestrationContext expected = new OrchestrationContext();
565 expected.setIsRollbackEnabled(true);
567 RequestDetails requestDetails = mapper
568 .readValue(new File(RESOURCE_PATH + "RequestDetailsInput_mapReqContext.json"), RequestDetails.class);
570 OrchestrationContext actual = bbInputSetupMapperLayer.mapOrchestrationContext(requestDetails);
572 assertThat(actual, sameBeanAs(expected));
576 public void testMapOrchestrationContextNoRequestInfo() throws IOException {
577 OrchestrationContext expected = new OrchestrationContext();
578 expected.setIsRollbackEnabled(false);
580 RequestDetails requestDetails = mapper.readValue(
581 new File(RESOURCE_PATH + "RequestDetailsInput_mapReqContextNoRequestInfo.json"), RequestDetails.class);
583 OrchestrationContext actual = bbInputSetupMapperLayer.mapOrchestrationContext(requestDetails);
585 assertThat(actual, sameBeanAs(expected));
589 public void testMapLocationContext() {
590 CloudRegion expected = new CloudRegion();
591 expected.setCloudOwner("test-owner-name");
592 expected.setLcpCloudRegionId("cloudRegionId");
593 expected.setComplex("complexName");
594 expected.setTenantId("tenantId");
595 CloudConfiguration cloudConfig = new CloudConfiguration();
596 cloudConfig.setTenantId("tenantId");
597 cloudConfig.setLcpCloudRegionId("cloudRegionId");
598 cloudConfig.setAicNodeClli("aicNodeClli");
599 org.onap.aai.domain.yang.CloudRegion cloudRegion = new org.onap.aai.domain.yang.CloudRegion();
600 cloudRegion.setCloudOwner("test-owner-name");
601 cloudRegion.setCloudRegionId("cloudRegionId");
602 cloudRegion.setComplexName("complexName");
604 CloudRegion actual = bbInputSetupMapperLayer.mapCloudRegion(cloudConfig, cloudRegion);
606 assertThat(actual, sameBeanAs(expected));
610 public void testMapCloudRegion() {
611 CloudRegion expected = new CloudRegion();
612 expected.setCloudOwner("test-owner-name");
613 expected.setLcpCloudRegionId("cloudRegionId");
614 expected.setTenantId("tenantId");
615 expected.setCloudRegionVersion("cloudRegionVersion");
617 CloudConfiguration cloudConfig = new CloudConfiguration();
618 cloudConfig.setTenantId("tenantId");
619 cloudConfig.setLcpCloudRegionId("cloudRegionId");
620 cloudConfig.setAicNodeClli("aicNodeClli");
622 org.onap.aai.domain.yang.CloudRegion cloudRegion = new org.onap.aai.domain.yang.CloudRegion();
623 cloudRegion.setCloudOwner("test-owner-name");
624 cloudRegion.setCloudRegionId("cloudRegionId");
625 cloudRegion.setCloudRegionVersion("cloudRegionVersion");
627 CloudRegion actual = bbInputSetupMapperLayer.mapCloudRegion(cloudConfig, cloudRegion);
629 assertThat(actual, sameBeanAs(expected));
633 public void testMapTenant() {
634 Tenant expected = new Tenant();
635 expected.setTenantId("tenantId");
636 expected.setTenantName("tenantName");
637 expected.setTenantContext("tenantContext");
639 org.onap.aai.domain.yang.Tenant aaiTenant = new org.onap.aai.domain.yang.Tenant();
640 aaiTenant.setTenantId("tenantId");
641 aaiTenant.setTenantName("tenantName");
642 aaiTenant.setTenantContext("tenantContext");
644 Tenant actual = bbInputSetupMapperLayer.mapTenant(aaiTenant);
646 assertThat(actual, sameBeanAs(expected));
650 public void testMapCloudRegionWithNullCheck() {
651 CloudRegion expected = new CloudRegion();
653 CloudRegion actual = bbInputSetupMapperLayer.mapCloudRegion(null, null);
655 assertThat(actual, sameBeanAs(expected));
659 public void testmapCatalogConfigurationToConfiguration() {
660 String modelCustUUID = "modelCustomizationUUID";
661 String modelInvariantUUID = "modelInvariantUUID";
662 String modelVersionUUID = "modelUUID";
663 String policyName = "policyName";
664 ModelInfoConfiguration expected = new ModelInfoConfiguration();
665 expected.setModelCustomizationId(modelCustUUID);
666 expected.setModelInvariantId(modelInvariantUUID);
667 expected.setModelVersionId(modelVersionUUID);
668 expected.setPolicyName(policyName);
669 ConfigurationResourceCustomization configurationResourceCustomization =
670 new ConfigurationResourceCustomization();
671 configurationResourceCustomization.setModelCustomizationUUID(modelCustUUID);
672 configurationResourceCustomization.setConfigurationResource(new ConfigurationResource());
673 configurationResourceCustomization.getConfigurationResource().setModelInvariantUUID(modelInvariantUUID);
674 configurationResourceCustomization.getConfigurationResource().setModelUUID(modelVersionUUID);
675 CvnfcConfigurationCustomization policyNameTable = new CvnfcConfigurationCustomization();
676 policyNameTable.setCvnfcCustomization(new CvnfcCustomization());
677 policyNameTable.getCvnfcCustomization().setVnfcCustomization(new VnfcCustomization());
678 policyNameTable.setPolicyName(policyName);
680 ModelInfoConfiguration actual = bbInputSetupMapperLayer
681 .mapCatalogConfigurationToConfiguration(configurationResourceCustomization, policyNameTable);
683 assertThat(actual, sameBeanAs(expected));
687 public void testmapCatalogConfigurationToFabricConfiguration() {
688 String modelCustUUID = "modelCustomizationUUID";
689 String modelInvariantUUID = "modelInvariantUUID";
690 String modelVersionUUID = "modelUUID";
691 String policyName = "policyName";
692 ModelInfoConfiguration expected = new ModelInfoConfiguration();
693 expected.setModelCustomizationId(modelCustUUID);
694 expected.setModelInvariantId(modelInvariantUUID);
695 expected.setModelVersionId(modelVersionUUID);
696 expected.setPolicyName(policyName);
698 CvnfcConfigurationCustomization fabricCustomization = new CvnfcConfigurationCustomization();
699 fabricCustomization.setCvnfcCustomization(new CvnfcCustomization());
700 fabricCustomization.getCvnfcCustomization().setVnfcCustomization(new VnfcCustomization());
701 fabricCustomization.setPolicyName(policyName);
702 fabricCustomization.setModelCustomizationUUID(modelCustUUID);
704 ConfigurationResource configurationResource = new ConfigurationResource();
705 configurationResource.setModelUUID(modelVersionUUID);
706 configurationResource.setModelInvariantUUID(modelInvariantUUID);
707 fabricCustomization.setConfigurationResource(configurationResource);
709 ModelInfoConfiguration actual =
710 bbInputSetupMapperLayer.mapCatalogConfigurationToConfiguration(fabricCustomization);
712 assertThat(actual, sameBeanAs(expected));
716 public void testMapNameValueUserParams() throws IOException {
717 RequestDetails requestDetails = mapper
718 .readValue(new File(RESOURCE_PATH + "RequestDetailsInput_mapReqContext.json"), RequestDetails.class);
719 Map<String, Object> actual =
720 bbInputSetupMapperLayer.mapNameValueUserParams(requestDetails.getRequestParameters());
722 assertTrue(actual.containsKey("mns_vfw_protected_route_prefixes"));
723 assertTrue(actual.get("mns_vfw_protected_route_prefixes").toString()
724 .contains("interface_route_table_routes_route"));
725 assertTrue(actual.get("mns_vfw_protected_route_prefixes").toString().contains("1.1.1.1/32"));
726 assertTrue(actual.get("mns_vfw_protected_route_prefixes").toString().contains("0::1/128"));
727 assertTrue(actual.containsKey("name1"));
728 assertTrue(actual.containsValue("value1"));
729 assertTrue(actual.get("name1").equals("value1"));
731 assertFalse(actual.containsKey("ignore"));
732 assertFalse(actual.containsValue("ignore"));
736 public void testMapRequestParameters() throws IOException {
737 RequestDetails requestDetails = mapper
738 .readValue(new File(RESOURCE_PATH + "RequestDetailsInput_mapReqContext.json"), RequestDetails.class);
739 RequestParameters actual = bbInputSetupMapperLayer.mapRequestParameters(requestDetails.getRequestParameters());
741 assertEquals(actual.getUsePreload(), requestDetails.getRequestParameters().getUsePreload());
742 assertEquals(actual.getSubscriptionServiceType(),
743 requestDetails.getRequestParameters().getSubscriptionServiceType());
744 assertEquals(actual.getPayload(), requestDetails.getRequestParameters().getPayload());
747 protected RequestParameters mapRequestParameters(
748 org.onap.so.serviceinstancebeans.RequestParameters requestParameters) {
749 RequestParameters requestParams = new RequestParameters();
750 requestParams.setaLaCarte(requestParameters.getALaCarte());
751 requestParams.setUsePreload(requestParameters.getUsePreload());
752 requestParams.setSubscriptionServiceType(requestParameters.getSubscriptionServiceType());
753 requestParams.setUserParams(requestParameters.getUserParams());
754 requestParams.setPayload(requestParameters.getPayload());
755 return requestParams;