2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
21 package org.onap.so.bpmn.servicedecomposition.tasks;
23 import static com.shazam.shazamcrest.MatcherAssert.assertThat;
24 import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs;
25 import static org.hamcrest.CoreMatchers.equalTo;
26 import static org.junit.Assert.assertEquals;
27 import static org.junit.Assert.assertFalse;
28 import static org.junit.Assert.assertTrue;
31 import java.io.IOException;
32 import java.util.ArrayList;
33 import java.util.Arrays;
34 import java.util.HashMap;
35 import java.util.List;
38 import org.junit.Test;
39 import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion;
40 import org.onap.so.bpmn.servicedecomposition.bbobjects.Collection;
41 import org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration;
42 import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer;
43 import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf;
44 import org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network;
45 import org.onap.so.bpmn.servicedecomposition.bbobjects.LineOfBusiness;
46 import org.onap.so.bpmn.servicedecomposition.bbobjects.NetworkPolicy;
47 import org.onap.so.bpmn.servicedecomposition.bbobjects.OwningEntity;
48 import org.onap.so.bpmn.servicedecomposition.bbobjects.Platform;
49 import org.onap.so.bpmn.servicedecomposition.bbobjects.Project;
50 import org.onap.so.bpmn.servicedecomposition.bbobjects.RouteTableReference;
51 import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance;
52 import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceSubscription;
53 import org.onap.so.bpmn.servicedecomposition.bbobjects.Tenant;
54 import org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup;
55 import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey;
56 import org.onap.so.bpmn.servicedecomposition.generalobjects.OrchestrationContext;
57 import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext;
58 import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestParameters;
59 import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoCollection;
60 import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoConfiguration;
61 import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoGenericVnf;
62 import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoInstanceGroup;
63 import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoNetwork;
64 import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoServiceInstance;
65 import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoVfModule;
66 import org.onap.so.db.catalog.beans.CollectionNetworkResourceCustomization;
67 import org.onap.so.db.catalog.beans.CollectionResource;
68 import org.onap.so.db.catalog.beans.CollectionResourceCustomization;
69 import org.onap.so.db.catalog.beans.CollectionResourceInstanceGroupCustomization;
70 import org.onap.so.db.catalog.beans.ConfigurationResource;
71 import org.onap.so.db.catalog.beans.ConfigurationResourceCustomization;
72 import org.onap.so.db.catalog.beans.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.VnfVfmoduleCvnfcConfigurationCustomization;
80 import org.onap.so.db.catalog.beans.VnfcCustomization;
81 import org.onap.so.serviceinstancebeans.CloudConfiguration;
82 import org.onap.so.serviceinstancebeans.RequestDetails;
84 import com.fasterxml.jackson.core.JsonParseException;
85 import com.fasterxml.jackson.databind.JsonMappingException;
86 import com.fasterxml.jackson.databind.ObjectMapper;
88 public class BBInputSetupMapperLayerTest {
90 BBInputSetupMapperLayer bbInputSetupMapperLayer = new BBInputSetupMapperLayer();
92 ObjectMapper mapper = new ObjectMapper();
94 private static final String RESOURCE_PATH = "src/test/resources/__files/ExecuteBuildingBlock/";
97 public void testMapOrchestrationStatusFromAAI() {
98 OrchestrationStatus expected = OrchestrationStatus.INVENTORIED;
99 String orchStatusInput = "Inventoried";
100 OrchestrationStatus actual = bbInputSetupMapperLayer.mapOrchestrationStatusFromAAI(orchStatusInput);
101 assertThat(actual, sameBeanAs(expected));
103 expected = OrchestrationStatus.ASSIGNED;
104 orchStatusInput = "Assigned";
105 actual = bbInputSetupMapperLayer.mapOrchestrationStatusFromAAI(orchStatusInput);
106 assertThat(actual, sameBeanAs(expected));
108 expected = OrchestrationStatus.ACTIVE;
109 orchStatusInput = "Active";
110 actual = bbInputSetupMapperLayer.mapOrchestrationStatusFromAAI(orchStatusInput);
111 assertThat(actual, sameBeanAs(expected));
113 expected = OrchestrationStatus.CREATED;
114 orchStatusInput = "Created";
115 actual = bbInputSetupMapperLayer.mapOrchestrationStatusFromAAI(orchStatusInput);
116 assertThat(actual, sameBeanAs(expected));
118 expected = OrchestrationStatus.PRECREATED;
119 orchStatusInput = "PreCreated";
120 actual = bbInputSetupMapperLayer.mapOrchestrationStatusFromAAI(orchStatusInput);
121 assertThat(actual, sameBeanAs(expected));
123 expected = OrchestrationStatus.PENDING_CREATE;
124 orchStatusInput = "PendingCreate";
125 actual = bbInputSetupMapperLayer.mapOrchestrationStatusFromAAI(orchStatusInput);
126 assertThat(actual, sameBeanAs(expected));
128 expected = OrchestrationStatus.PENDING_DELETE;
129 orchStatusInput = "PendingDelete";
130 actual = bbInputSetupMapperLayer.mapOrchestrationStatusFromAAI(orchStatusInput);
131 assertThat(actual, sameBeanAs(expected));
133 expected = OrchestrationStatus.PENDING;
134 orchStatusInput = "Pending";
135 actual = bbInputSetupMapperLayer.mapOrchestrationStatusFromAAI(orchStatusInput);
136 assertThat(actual, sameBeanAs(expected));
138 expected = OrchestrationStatus.PENDING_ACTIVATION;
139 orchStatusInput = "PendingActivation";
140 actual = bbInputSetupMapperLayer.mapOrchestrationStatusFromAAI(orchStatusInput);
141 assertThat(actual, sameBeanAs(expected));
145 public void testMapOrchestrationFuzzyCases() {
146 List<String> values = Arrays.asList("pending-create", "pending_Create", "pendinggcreate", "PendingCreate");
147 values.forEach(value -> {
148 assertThat(bbInputSetupMapperLayer.mapOrchestrationStatusFromAAI(value), equalTo(OrchestrationStatus.PENDING_CREATE));
153 public void testMapAAICustomer() throws IOException {
154 Customer expected = mapper.readValue(
155 new File(RESOURCE_PATH+"Customer.json"),
158 org.onap.aai.domain.yang.Customer customerAAI = mapper.readValue(
159 new File(RESOURCE_PATH+"Customer_AAI.json"), 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(
169 new File(RESOURCE_PATH + "ServiceSubscriptionExpected.json"), ServiceSubscription.class);
171 org.onap.aai.domain.yang.ServiceSubscription svcSubscriptionAAI = mapper.readValue(
172 new File(RESOURCE_PATH + "ServiceSubscription_AAI.json"), org.onap.aai.domain.yang.ServiceSubscription.class);
174 ServiceSubscription actual = bbInputSetupMapperLayer.mapAAIServiceSubscription(svcSubscriptionAAI);
176 assertThat(actual, sameBeanAs(expected));
180 public void testMapAAIProject() throws IOException {
181 Project expected = mapper.readValue(new File(RESOURCE_PATH+"Project.json"),Project.class);
183 org.onap.aai.domain.yang.Project projectAAI = new org.onap.aai.domain.yang.Project();
184 projectAAI.setProjectName("projectName");
186 Project actual = bbInputSetupMapperLayer.mapAAIProject(projectAAI);
188 assertThat(actual, sameBeanAs(expected));
192 public void testMapRequestProject() throws IOException {
193 Project expected = mapper.readValue(new File(RESOURCE_PATH+"Project.json"),Project.class);
195 org.onap.so.serviceinstancebeans.Project requestProject = new org.onap.so.serviceinstancebeans.Project();
196 requestProject.setProjectName("projectName");
198 Project actual = bbInputSetupMapperLayer.mapRequestProject(requestProject);
200 assertThat(actual, sameBeanAs(expected));
204 public void testMapAAIOwningEntity() throws IOException {
205 OwningEntity expected = mapper.readValue(new File(RESOURCE_PATH+"OwningEntity.json"),OwningEntity.class);
207 org.onap.aai.domain.yang.OwningEntity entityAAI = new org.onap.aai.domain.yang.OwningEntity();
208 entityAAI.setOwningEntityId("owningEntityId");
209 entityAAI.setOwningEntityName("owningEntityName");
211 OwningEntity actual = bbInputSetupMapperLayer.mapAAIOwningEntity(entityAAI);
213 assertThat(actual, sameBeanAs(expected));
217 public void testMapRequestOwningEntity() throws IOException {
218 OwningEntity expected = mapper.readValue(new File(RESOURCE_PATH+"OwningEntity.json"),OwningEntity.class);
220 org.onap.so.serviceinstancebeans.OwningEntity requestOwningEntity = new org.onap.so.serviceinstancebeans.OwningEntity();
221 requestOwningEntity.setOwningEntityId("owningEntityId");
222 requestOwningEntity.setOwningEntityName("owningEntityName");
224 OwningEntity actual = bbInputSetupMapperLayer.mapRequestOwningEntity(requestOwningEntity);
226 assertThat(actual, sameBeanAs(expected));
230 public void testMapAAIPlatform() throws IOException {
231 Platform expected = mapper.readValue(new File(RESOURCE_PATH+"Platform.json"),Platform.class);
233 org.onap.aai.domain.yang.Platform platformAAI = new org.onap.aai.domain.yang.Platform();
234 platformAAI.setPlatformName("platformName");
236 Platform actual = bbInputSetupMapperLayer.mapAAIPlatform(platformAAI);
238 assertThat(actual, sameBeanAs(expected));
242 public void testMapAAILineOfBusiness() throws IOException {
243 LineOfBusiness expected = 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 = mapper.readValue(new File(RESOURCE_PATH + "NetworkPolicy.json"), NetworkPolicy.class);
257 org.onap.aai.domain.yang.NetworkPolicy aaiNetworkPolicy = new org.onap.aai.domain.yang.NetworkPolicy();
258 aaiNetworkPolicy.setNetworkPolicyId("networkPolicyId");
259 aaiNetworkPolicy.setNetworkPolicyFqdn("networkPolicyFqdn");
260 aaiNetworkPolicy.setHeatStackId("heatStackId");
261 aaiNetworkPolicy.setResourceVersion("resourceVersion");
263 NetworkPolicy actualNetworkPolicy = bbInputSetupMapperLayer.mapAAINetworkPolicy(aaiNetworkPolicy);
265 assertThat(actualNetworkPolicy, sameBeanAs(expectedNetworkPolicy));
269 public void testMapAAIVolumeGroup() throws JsonParseException, JsonMappingException, IOException {
270 VolumeGroup expectedVolumeGroup = mapper.readValue(new File(RESOURCE_PATH + "VolumeGroup.json"), VolumeGroup.class);
272 org.onap.aai.domain.yang.VolumeGroup aaiVolumeGroup = mapper.readValue(
273 new File(RESOURCE_PATH + "VolumeGroup_AAI.json"), org.onap.aai.domain.yang.VolumeGroup.class);
275 VolumeGroup actualVolumeGroup = bbInputSetupMapperLayer.mapAAIVolumeGroup(aaiVolumeGroup);
277 assertThat(actualVolumeGroup, sameBeanAs(expectedVolumeGroup));
281 public void testMapCatalogServiceIntoServiceInstance() throws IOException {
282 ModelInfoServiceInstance expected = mapper.readValue(
283 new File(RESOURCE_PATH + "ModelInfoServiceInstance.json"),
284 ModelInfoServiceInstance.class);
286 Service catalogService = mapper.readValue(
287 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 = mapper.readValue(
297 new File(RESOURCE_PATH + "ModelInfoInstanceGroup.json"),
298 ModelInfoInstanceGroup.class);
300 InstanceGroup instanceGroup = mapper.readValue(
301 new File(RESOURCE_PATH + "InstanceGroup.json"), InstanceGroup.class);
302 instanceGroup.setCollectionInstanceGroupCustomizations(new ArrayList<>());
303 CollectionResourceInstanceGroupCustomization collectionInstanceGroupCust = 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 = bbInputSetupMapperLayer.mapCatalogInstanceGroupToInstanceGroup(collectionResourceCust, instanceGroup);
312 assertThat(actual, sameBeanAs(expected));
316 public void testMapCollectionNetworkResourceCustToNetworkResourceCust() {
317 String modelCustomizationUUID = "modelCustomizationUUID";
318 String modelInstanceName = "modelInstanceName";
319 String networkRole = "networkRole";
320 String networkScope = "networkScope";
321 String networkTechnology = "networkTechnology";
322 String networkType = "networkType";
324 NetworkResourceCustomization expected = new NetworkResourceCustomization();
325 expected.setModelCustomizationUUID(modelCustomizationUUID);
326 expected.setModelInstanceName(modelInstanceName);
327 expected.setNetworkRole(networkRole);
328 expected.setNetworkScope(networkScope);
329 expected.setNetworkTechnology(networkTechnology);
330 expected.setNetworkType(networkType);
331 CollectionNetworkResourceCustomization collectionNetworkResourceCust = new CollectionNetworkResourceCustomization();
332 collectionNetworkResourceCust.setModelCustomizationUUID(modelCustomizationUUID);
333 collectionNetworkResourceCust.setModelInstanceName(modelInstanceName);
334 collectionNetworkResourceCust.setNetworkRole(networkRole);
335 collectionNetworkResourceCust.setNetworkScope(networkScope);
336 collectionNetworkResourceCust.setNetworkTechnology(networkTechnology);
337 collectionNetworkResourceCust.setNetworkType(networkType);
338 NetworkResourceCustomization actual = bbInputSetupMapperLayer.mapCollectionNetworkResourceCustToNetworkResourceCust(collectionNetworkResourceCust);
340 assertThat(actual, sameBeanAs(expected));
344 public void testMapCatalogCollectionToCollection() throws IOException {
345 ModelInfoCollection expected = mapper.readValue(
346 new File(RESOURCE_PATH + "ModelInfoCollection.json"),
347 ModelInfoCollection.class);
349 CollectionResourceCustomization collectionCust = mapper.readValue(
350 new File(RESOURCE_PATH + "CollectionResourceCustomization.json"),
351 CollectionResourceCustomization.class);
353 CollectionResource collectionResource = mapper.readValue(
354 new File(RESOURCE_PATH + "CollectionResource.json"),
355 CollectionResource.class);
357 ModelInfoCollection actual = bbInputSetupMapperLayer.mapCatalogCollectionToCollection(collectionCust, collectionResource);
359 assertThat(actual, sameBeanAs(expected));
363 public void testMapAAIServiceInstanceIntoServiceInstance() throws IOException {
364 ServiceInstance expected = mapper.readValue(
365 new File(RESOURCE_PATH + "ServiceInstance_aaiServiceInstanceToSI.json"),
366 ServiceInstance.class);
368 org.onap.aai.domain.yang.ServiceInstance serviceInstanceAAI = mapper.readValue(
369 new File(RESOURCE_PATH + "ServiceInstanceAAIInput.json"),
370 org.onap.aai.domain.yang.ServiceInstance.class);
372 ServiceInstance actual = bbInputSetupMapperLayer.mapAAIServiceInstanceIntoServiceInstance(serviceInstanceAAI);
374 assertThat(actual, sameBeanAs(expected));
378 public void testSetPlatformAndLOB() throws IOException {
379 ServiceInstance expected = mapper.readValue(
380 new File(RESOURCE_PATH + "ServiceInstance_aaiPlatformAndLOBToSI.json"),
381 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"),
392 ServiceInstance.class);
394 bbInputSetupMapperLayer.setPlatformAndLOBIntoServiceInstance(platformMSO, lineOfBusinessMSO, actual,
395 resourcesToBeOrchestrated);
397 assertThat(actual, sameBeanAs(expected));
401 public void testMapAAIL3NetworkIntoL3Network() throws IOException {
402 L3Network expected = mapper.readValue(
403 new File(RESOURCE_PATH + "l3NetworkExpected.json"), L3Network.class);
405 org.onap.aai.domain.yang.L3Network aaiL3Network = mapper.readValue(
406 new File(RESOURCE_PATH + "aaiL3NetworkInput.json"),
407 org.onap.aai.domain.yang.L3Network.class);
409 L3Network actual = bbInputSetupMapperLayer.mapAAIL3Network(aaiL3Network);
411 assertThat(actual, sameBeanAs(expected));
415 public void testMapAAIGenericVnfIntoGenericVnf() throws IOException {
416 GenericVnf expected = mapper.readValue(new File(RESOURCE_PATH + "GenericVnfExpected.json"), GenericVnf.class);
417 org.onap.aai.domain.yang.GenericVnf aaiGenericVnf = mapper.readValue(
418 new File(RESOURCE_PATH + "aaiGenericVnfInput.json"), org.onap.aai.domain.yang.GenericVnf.class);
420 GenericVnf actual = bbInputSetupMapperLayer.mapAAIGenericVnfIntoGenericVnf(aaiGenericVnf);
422 assertThat(actual, sameBeanAs(expected));
426 public void testMapAAICollectionIntoCollection() throws JsonParseException, JsonMappingException, IOException {
427 org.onap.aai.domain.yang.Collection aaiCollection = mapper.readValue(
428 new File(RESOURCE_PATH + "CollectionInput.json"), org.onap.aai.domain.yang.Collection.class);
430 Collection expectedCollection = 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() throws JsonParseException, JsonMappingException, IOException {
439 org.onap.aai.domain.yang.InstanceGroup aaiInstanceGroup = mapper.readValue(
440 new File(RESOURCE_PATH + "InstanceGroupInput.json"), org.onap.aai.domain.yang.InstanceGroup.class);
442 org.onap.so.bpmn.servicedecomposition.bbobjects.InstanceGroup expectedInstanceGroup = mapper.readValue(
443 new File(RESOURCE_PATH + "InstanceGroupExpected.json"), org.onap.so.bpmn.servicedecomposition.bbobjects.InstanceGroup.class);
445 org.onap.so.bpmn.servicedecomposition.bbobjects.InstanceGroup actualInstanceGroup =
446 bbInputSetupMapperLayer.mapAAIInstanceGroupIntoInstanceGroup(aaiInstanceGroup);
448 assertThat(actualInstanceGroup, sameBeanAs(expectedInstanceGroup));
452 public void testMapAAIRouteTableReferenceIntoRouteTableReference() throws JsonParseException, JsonMappingException, IOException {
453 org.onap.aai.domain.yang.RouteTableReference aaiRouteTableReference = mapper.readValue(
454 new File(RESOURCE_PATH + "RouteTableReferenceInput.json"), org.onap.aai.domain.yang.RouteTableReference.class);
456 RouteTableReference expectedRouteTableReference = mapper.readValue(
457 new File(RESOURCE_PATH + "RouteTableReferenceExpected.json"), RouteTableReference.class);
459 RouteTableReference actualRouteTableReference = bbInputSetupMapperLayer.mapAAIRouteTableReferenceIntoRouteTableReference(aaiRouteTableReference);
461 assertThat(actualRouteTableReference, sameBeanAs(expectedRouteTableReference));
465 public void testMapCatalogNetworkToNetwork() throws JsonParseException, JsonMappingException, IOException {
466 NetworkResourceCustomization networkResourceCustomization = mapper.readValue(
467 new File(RESOURCE_PATH + "NetworkResourceCustomizationInput.json"), NetworkResourceCustomization.class);
469 ModelInfoNetwork expectedModelInfoNetwork = mapper.readValue(
470 new File(RESOURCE_PATH + "ModelInfoNetworkExpected.json"), ModelInfoNetwork.class);
472 ModelInfoNetwork actualModelInfoNetwork = bbInputSetupMapperLayer.mapCatalogNetworkToNetwork(networkResourceCustomization);
474 assertThat(actualModelInfoNetwork, sameBeanAs(expectedModelInfoNetwork));
478 public void testMapCatalogVnfToVnf() throws IOException {
479 VnfResourceCustomization vnfResourceCustomization = mapper.readValue(
480 new File(RESOURCE_PATH + "VnfResourceCustomizationInput.json"), VnfResourceCustomization.class);
482 ModelInfoGenericVnf expectedModelInfoGenericVnf = mapper.readValue(
483 new File(RESOURCE_PATH + "ModelInfoGenericVnfExpected.json"), ModelInfoGenericVnf.class);
485 ModelInfoGenericVnf actualModelInfoGenericVnf = bbInputSetupMapperLayer.mapCatalogVnfToVnf(vnfResourceCustomization);
487 assertThat(actualModelInfoGenericVnf, sameBeanAs(expectedModelInfoGenericVnf));
491 public void testMapCatalogVfModuleToVfModule() throws JsonParseException, JsonMappingException, IOException {
492 VfModuleCustomization vfResourceCustomization = mapper.readValue(
493 new File(RESOURCE_PATH + "VfModuleCustomizationInput.json"), VfModuleCustomization.class);
495 ModelInfoVfModule expectedModelInfoVfModule = mapper.readValue(new File(RESOURCE_PATH + "ModelInfoVfModuleExpected.json"), ModelInfoVfModule.class);
497 ModelInfoVfModule actualModelInfoVfModule = bbInputSetupMapperLayer.mapCatalogVfModuleToVfModule(vfResourceCustomization);
499 assertThat(actualModelInfoVfModule, sameBeanAs(expectedModelInfoVfModule));
503 public void testMapRequestPlatform() throws JsonParseException, JsonMappingException, IOException {
504 org.onap.so.serviceinstancebeans.Platform platform = mapper.readValue(
505 new File(RESOURCE_PATH + "RequestPlatformInput.json"), org.onap.so.serviceinstancebeans.Platform.class);
507 Platform expectedPlatform = mapper.readValue(new File(RESOURCE_PATH + "PlatformExpected.json"), Platform.class);
509 Platform actualPlatform = bbInputSetupMapperLayer.mapRequestPlatform(platform);
511 assertThat(actualPlatform, sameBeanAs(expectedPlatform));
515 public void testMapRequestLineOfBusiness() throws JsonParseException, JsonMappingException, IOException {
516 org.onap.so.serviceinstancebeans.LineOfBusiness lineOfBusiness = mapper.readValue(
517 new File(RESOURCE_PATH + "RequestLineOfBusinessInput.json"), org.onap.so.serviceinstancebeans.LineOfBusiness.class);
519 LineOfBusiness expectedLineOfBusiness = mapper.readValue(new File(RESOURCE_PATH + "LineOfBusinessExpected.json"), LineOfBusiness.class);
521 LineOfBusiness actualLineOfBusiness = bbInputSetupMapperLayer.mapRequestLineOfBusiness(lineOfBusiness);
523 assertThat(actualLineOfBusiness, sameBeanAs(expectedLineOfBusiness));
527 public void testMapAAIConfiguration() throws JsonParseException, JsonMappingException, IOException {
528 org.onap.aai.domain.yang.Configuration configurationAAI = mapper.readValue(
529 new File(RESOURCE_PATH + "ConfigurationInput.json"), org.onap.aai.domain.yang.Configuration.class);
531 Configuration expectedConfiguration = mapper.readValue(
532 new File(RESOURCE_PATH + "ConfigurationExpected.json"), Configuration.class);
534 Configuration actualConfiguration = bbInputSetupMapperLayer.mapAAIConfiguration(configurationAAI);
536 assertThat(actualConfiguration, sameBeanAs(expectedConfiguration));
540 public void testMapRequestContext() throws IOException {
541 RequestContext expected = mapper.readValue(
542 new File(RESOURCE_PATH + "RequestContextExpected.json"),
543 RequestContext.class);
545 RequestDetails requestDetails = mapper.readValue(
546 new File(RESOURCE_PATH + "RequestDetailsInput_mapReqContext.json"),
547 RequestDetails.class);
548 RequestContext actual = bbInputSetupMapperLayer.mapRequestContext(requestDetails);
550 assertThat(actual, sameBeanAs(expected));
554 public void testMapOrchestrationContext() throws IOException {
555 OrchestrationContext expected = new OrchestrationContext();
556 expected.setIsRollbackEnabled(true);
558 RequestDetails requestDetails = mapper.readValue(new File(RESOURCE_PATH + "RequestDetailsInput_mapReqContext.json"), RequestDetails.class);
560 OrchestrationContext actual = bbInputSetupMapperLayer.mapOrchestrationContext(requestDetails);
562 assertThat(actual, sameBeanAs(expected));
566 public void testMapLocationContext() {
567 CloudRegion expected = new CloudRegion();
568 expected.setCloudOwner("test-owner-name");
569 expected.setLcpCloudRegionId("cloudRegionId");
570 expected.setComplex("complexName");
571 expected.setTenantId("tenantId");
572 CloudConfiguration cloudConfig = new CloudConfiguration();
573 cloudConfig.setTenantId("tenantId");
574 cloudConfig.setLcpCloudRegionId("cloudRegionId");
575 cloudConfig.setAicNodeClli("aicNodeClli");
576 org.onap.aai.domain.yang.CloudRegion cloudRegion = new org.onap.aai.domain.yang.CloudRegion();
577 cloudRegion.setCloudOwner("test-owner-name");
578 cloudRegion.setCloudRegionId("cloudRegionId");
579 cloudRegion.setComplexName("complexName");
581 CloudRegion actual = bbInputSetupMapperLayer.mapCloudRegion(cloudConfig, cloudRegion);
583 assertThat(actual, sameBeanAs(expected));
587 public void testMapCloudRegion() {
588 CloudRegion expected = new CloudRegion();
589 expected.setCloudOwner("test-owner-name");
590 expected.setLcpCloudRegionId("cloudRegionId");
591 expected.setTenantId("tenantId");
592 expected.setCloudRegionVersion("cloudRegionVersion");
594 CloudConfiguration cloudConfig = new CloudConfiguration();
595 cloudConfig.setTenantId("tenantId");
596 cloudConfig.setLcpCloudRegionId("cloudRegionId");
597 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.setCloudRegionVersion("cloudRegionVersion");
604 CloudRegion actual = bbInputSetupMapperLayer.mapCloudRegion(cloudConfig, cloudRegion);
606 assertThat(actual, sameBeanAs(expected));
610 public void testMapTenant() {
611 Tenant expected = new Tenant();
612 expected.setTenantId("tenantId");
613 expected.setTenantName("tenantName");
614 expected.setTenantContext("tenantContext");
616 org.onap.aai.domain.yang.Tenant aaiTenant = new org.onap.aai.domain.yang.Tenant();
617 aaiTenant.setTenantId("tenantId");
618 aaiTenant.setTenantName("tenantName");
619 aaiTenant.setTenantContext("tenantContext");
621 Tenant actual = bbInputSetupMapperLayer.mapTenant(aaiTenant);
623 assertThat(actual, sameBeanAs(expected));
627 public void testMapCloudRegionWithNullCheck() {
628 CloudRegion expected = new CloudRegion();
630 CloudRegion actual = bbInputSetupMapperLayer.mapCloudRegion(null, null);
632 assertThat(actual, sameBeanAs(expected));
636 public void testmapCatalogConfigurationToConfiguration() {
637 String modelCustUUID = "modelCustomizationUUID";
638 String modelInvariantUUID = "modelInvariantUUID";
639 String modelVersionUUID = "modelUUID";
640 String policyName = "policyName";
641 ModelInfoConfiguration expected = new ModelInfoConfiguration();
642 expected.setModelCustomizationId(modelCustUUID);
643 expected.setModelInvariantId(modelInvariantUUID);
644 expected.setModelVersionId(modelVersionUUID);
645 expected.setPolicyName(policyName);
646 ConfigurationResourceCustomization configurationResourceCustomization = new ConfigurationResourceCustomization();
647 configurationResourceCustomization.setModelCustomizationUUID(modelCustUUID);
648 configurationResourceCustomization.setConfigurationResource(new ConfigurationResource());
649 configurationResourceCustomization.getConfigurationResource().setModelInvariantUUID(modelInvariantUUID);
650 configurationResourceCustomization.getConfigurationResource().setModelUUID(modelVersionUUID);
651 VnfVfmoduleCvnfcConfigurationCustomization policyNameTable = new VnfVfmoduleCvnfcConfigurationCustomization();
652 policyNameTable.setCvnfcCustomization(new CvnfcCustomization());
653 policyNameTable.getCvnfcCustomization().setVnfcCustomization(new VnfcCustomization());
654 policyNameTable.setPolicyName(policyName);
656 ModelInfoConfiguration actual = bbInputSetupMapperLayer.mapCatalogConfigurationToConfiguration(configurationResourceCustomization, policyNameTable);
658 assertThat(actual, sameBeanAs(expected));
662 public void testmapCatalogConfigurationToFabricConfiguration() {
663 String modelCustUUID = "modelCustomizationUUID";
664 String modelInvariantUUID = "modelInvariantUUID";
665 String modelVersionUUID = "modelUUID";
666 String policyName = "policyName";
667 ModelInfoConfiguration expected = new ModelInfoConfiguration();
668 expected.setModelCustomizationId(modelCustUUID);
669 expected.setModelInvariantId(modelInvariantUUID);
670 expected.setModelVersionId(modelVersionUUID);
671 expected.setPolicyName(policyName);
673 VnfVfmoduleCvnfcConfigurationCustomization fabricCustomization = new VnfVfmoduleCvnfcConfigurationCustomization();
674 fabricCustomization.setCvnfcCustomization(new CvnfcCustomization());
675 fabricCustomization.getCvnfcCustomization().setVnfcCustomization(new VnfcCustomization());
676 fabricCustomization.setPolicyName(policyName);
677 fabricCustomization.setModelCustomizationUUID(modelCustUUID);
679 ConfigurationResource configurationResource = new ConfigurationResource();
680 configurationResource.setModelUUID(modelVersionUUID);
681 configurationResource.setModelInvariantUUID(modelInvariantUUID);
682 fabricCustomization.setConfigurationResource(configurationResource);
684 ModelInfoConfiguration actual = bbInputSetupMapperLayer.mapCatalogConfigurationToConfiguration(fabricCustomization);
686 assertThat(actual, sameBeanAs(expected));
690 public void testMapNameValueUserParams() throws IOException {
691 RequestDetails requestDetails = mapper.readValue(new File(RESOURCE_PATH + "RequestDetailsInput_mapReqContext.json"), RequestDetails.class);
692 Map<String,Object> actual = bbInputSetupMapperLayer.mapNameValueUserParams(requestDetails.getRequestParameters());
694 assertTrue(actual.containsKey("mns_vfw_protected_route_prefixes"));
695 assertTrue(actual.get("mns_vfw_protected_route_prefixes").toString().contains("interface_route_table_routes_route"));
696 assertTrue(actual.get("mns_vfw_protected_route_prefixes").toString().contains("1.1.1.1/32"));
697 assertTrue(actual.get("mns_vfw_protected_route_prefixes").toString().contains("0::1/128"));
698 assertTrue(actual.containsKey("name1"));
699 assertTrue(actual.containsValue("value1"));
700 assertTrue(actual.get("name1").equals("value1"));
702 assertFalse(actual.containsKey("ignore"));
703 assertFalse(actual.containsValue("ignore"));
707 public void testMapRequestParameters() throws IOException {
708 RequestDetails requestDetails = mapper.readValue(new File(RESOURCE_PATH + "RequestDetailsInput_mapReqContext.json"), RequestDetails.class);
709 RequestParameters actual = bbInputSetupMapperLayer.mapRequestParameters(requestDetails.getRequestParameters());
711 assertEquals(actual.getUsePreload(), requestDetails.getRequestParameters().getUsePreload());
712 assertEquals(actual.getSubscriptionServiceType(), requestDetails.getRequestParameters().getSubscriptionServiceType());
713 assertEquals(actual.getPayload(), requestDetails.getRequestParameters().getPayload());
716 protected RequestParameters mapRequestParameters(org.onap.so.serviceinstancebeans.RequestParameters requestParameters) {
717 RequestParameters requestParams = new RequestParameters();
718 requestParams.setaLaCarte(requestParameters.getALaCarte());
719 requestParams.setUsePreload(requestParameters.getUsePreload());
720 requestParams.setSubscriptionServiceType(requestParameters.getSubscriptionServiceType());
721 requestParams.setUserParams(requestParameters.getUserParams());
722 requestParams.setPayload(requestParameters.getPayload());
723 return requestParams;