9195df09559332d490a0c60ce5f3045fc8cb580b
[so.git] / bpmn / MSOCommonBPMN / src / test / java / org / onap / so / bpmn / servicedecomposition / tasks / BBInputSetupMapperLayerTest.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP - SO
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
10  *
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  *
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=========================================================
19  */
20
21 package org.onap.so.bpmn.servicedecomposition.tasks;
22
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;
29 import java.io.File;
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;
35 import java.util.Map;
36 import org.junit.Test;
37 import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion;
38 import org.onap.so.bpmn.servicedecomposition.bbobjects.Collection;
39 import org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration;
40 import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer;
41 import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf;
42 import org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network;
43 import org.onap.so.bpmn.servicedecomposition.bbobjects.LineOfBusiness;
44 import org.onap.so.bpmn.servicedecomposition.bbobjects.NetworkPolicy;
45 import org.onap.so.bpmn.servicedecomposition.bbobjects.OwningEntity;
46 import org.onap.so.bpmn.servicedecomposition.bbobjects.Platform;
47 import org.onap.so.bpmn.servicedecomposition.bbobjects.Pnf;
48 import org.onap.so.bpmn.servicedecomposition.bbobjects.Project;
49 import org.onap.so.bpmn.servicedecomposition.bbobjects.RouteTableReference;
50 import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance;
51 import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceSubscription;
52 import org.onap.so.bpmn.servicedecomposition.bbobjects.Tenant;
53 import org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup;
54 import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey;
55 import org.onap.so.bpmn.servicedecomposition.generalobjects.OrchestrationContext;
56 import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext;
57 import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestParameters;
58 import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoCollection;
59 import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoConfiguration;
60 import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoGenericVnf;
61 import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoInstanceGroup;
62 import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoNetwork;
63 import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoServiceInstance;
64 import org.onap.so.bpmn.servicedecomposition.modelinfo.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.DeserializationFeature;
84 import com.fasterxml.jackson.databind.JsonMappingException;
85 import com.fasterxml.jackson.databind.ObjectMapper;
86
87 public class BBInputSetupMapperLayerTest {
88
89     BBInputSetupMapperLayer bbInputSetupMapperLayer = new BBInputSetupMapperLayer();
90
91     ObjectMapper mapper = new ObjectMapper().configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
92
93     private static final String RESOURCE_PATH = "src/test/resources/__files/ExecuteBuildingBlock/";
94
95
96     @Test
97     public void testMapOrchestrationStatusFromAAI() {
98         OrchestrationStatus expected = OrchestrationStatus.INVENTORIED;
99         String orchStatusInput = "Inventoried";
100         OrchestrationStatus actual = bbInputSetupMapperLayer.mapOrchestrationStatusFromAAI(orchStatusInput);
101         assertThat(actual, sameBeanAs(expected));
102
103         expected = OrchestrationStatus.ASSIGNED;
104         orchStatusInput = "Assigned";
105         actual = bbInputSetupMapperLayer.mapOrchestrationStatusFromAAI(orchStatusInput);
106         assertThat(actual, sameBeanAs(expected));
107
108         expected = OrchestrationStatus.ACTIVE;
109         orchStatusInput = "Active";
110         actual = bbInputSetupMapperLayer.mapOrchestrationStatusFromAAI(orchStatusInput);
111         assertThat(actual, sameBeanAs(expected));
112
113         expected = OrchestrationStatus.CREATED;
114         orchStatusInput = "Created";
115         actual = bbInputSetupMapperLayer.mapOrchestrationStatusFromAAI(orchStatusInput);
116         assertThat(actual, sameBeanAs(expected));
117
118         expected = OrchestrationStatus.PRECREATED;
119         orchStatusInput = "PreCreated";
120         actual = bbInputSetupMapperLayer.mapOrchestrationStatusFromAAI(orchStatusInput);
121         assertThat(actual, sameBeanAs(expected));
122
123         expected = OrchestrationStatus.PENDING_CREATE;
124         orchStatusInput = "PendingCreate";
125         actual = bbInputSetupMapperLayer.mapOrchestrationStatusFromAAI(orchStatusInput);
126         assertThat(actual, sameBeanAs(expected));
127
128         expected = OrchestrationStatus.PENDING_DELETE;
129         orchStatusInput = "PendingDelete";
130         actual = bbInputSetupMapperLayer.mapOrchestrationStatusFromAAI(orchStatusInput);
131         assertThat(actual, sameBeanAs(expected));
132
133         expected = OrchestrationStatus.PENDING;
134         orchStatusInput = "Pending";
135         actual = bbInputSetupMapperLayer.mapOrchestrationStatusFromAAI(orchStatusInput);
136         assertThat(actual, sameBeanAs(expected));
137
138         expected = OrchestrationStatus.PENDING_ACTIVATION;
139         orchStatusInput = "PendingActivation";
140         actual = bbInputSetupMapperLayer.mapOrchestrationStatusFromAAI(orchStatusInput);
141         assertThat(actual, sameBeanAs(expected));
142     }
143
144     @Test
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),
149                     equalTo(OrchestrationStatus.PENDING_CREATE));
150         });
151     }
152
153     @Test
154     public void testMapAAICustomer() throws IOException {
155         Customer expected = mapper.readValue(new File(RESOURCE_PATH + "Customer.json"), Customer.class);
156
157         org.onap.aai.domain.yang.Customer customerAAI = mapper.readValue(new File(RESOURCE_PATH + "Customer_AAI.json"),
158                 org.onap.aai.domain.yang.Customer.class);
159
160         Customer actual = bbInputSetupMapperLayer.mapAAICustomer(customerAAI);
161
162         assertThat(actual, sameBeanAs(expected));
163     }
164
165     @Test
166     public void testMapAAIServiceSubscription() throws IOException {
167         ServiceSubscription expected = mapper.readValue(new File(RESOURCE_PATH + "ServiceSubscriptionExpected.json"),
168                 ServiceSubscription.class);
169
170         org.onap.aai.domain.yang.ServiceSubscription svcSubscriptionAAI =
171                 mapper.readValue(new File(RESOURCE_PATH + "ServiceSubscription_AAI.json"),
172                         org.onap.aai.domain.yang.ServiceSubscription.class);
173
174         ServiceSubscription actual = bbInputSetupMapperLayer.mapAAIServiceSubscription(svcSubscriptionAAI);
175
176         assertThat(actual, sameBeanAs(expected));
177     }
178
179     @Test
180     public void testMapAAIProject() throws IOException {
181         Project expected = mapper.readValue(new File(RESOURCE_PATH + "Project.json"), Project.class);
182
183         org.onap.aai.domain.yang.Project projectAAI = new org.onap.aai.domain.yang.Project();
184         projectAAI.setProjectName("projectName");
185
186         Project actual = bbInputSetupMapperLayer.mapAAIProject(projectAAI);
187
188         assertThat(actual, sameBeanAs(expected));
189     }
190
191     @Test
192     public void testMapRequestProject() throws IOException {
193         Project expected = mapper.readValue(new File(RESOURCE_PATH + "Project.json"), Project.class);
194
195         org.onap.so.serviceinstancebeans.Project requestProject = new org.onap.so.serviceinstancebeans.Project();
196         requestProject.setProjectName("projectName");
197
198         Project actual = bbInputSetupMapperLayer.mapRequestProject(requestProject);
199
200         assertThat(actual, sameBeanAs(expected));
201     }
202
203     @Test
204     public void testMapAAIOwningEntity() throws IOException {
205         OwningEntity expected = mapper.readValue(new File(RESOURCE_PATH + "OwningEntity.json"), OwningEntity.class);
206
207         org.onap.aai.domain.yang.OwningEntity entityAAI = new org.onap.aai.domain.yang.OwningEntity();
208         entityAAI.setOwningEntityId("owningEntityId");
209         entityAAI.setOwningEntityName("owningEntityName");
210
211         OwningEntity actual = bbInputSetupMapperLayer.mapAAIOwningEntity(entityAAI);
212
213         assertThat(actual, sameBeanAs(expected));
214     }
215
216     @Test
217     public void testMapRequestOwningEntity() throws IOException {
218         OwningEntity expected = mapper.readValue(new File(RESOURCE_PATH + "OwningEntity.json"), OwningEntity.class);
219
220         org.onap.so.serviceinstancebeans.OwningEntity requestOwningEntity =
221                 new org.onap.so.serviceinstancebeans.OwningEntity();
222         requestOwningEntity.setOwningEntityId("owningEntityId");
223         requestOwningEntity.setOwningEntityName("owningEntityName");
224
225         OwningEntity actual = bbInputSetupMapperLayer.mapRequestOwningEntity(requestOwningEntity);
226
227         assertThat(actual, sameBeanAs(expected));
228     }
229
230     @Test
231     public void testMapAAIPlatform() throws IOException {
232         Platform expected = mapper.readValue(new File(RESOURCE_PATH + "Platform.json"), Platform.class);
233
234         org.onap.aai.domain.yang.Platform platformAAI = new org.onap.aai.domain.yang.Platform();
235         platformAAI.setPlatformName("platformName");
236
237         Platform actual = bbInputSetupMapperLayer.mapAAIPlatform(platformAAI);
238
239         assertThat(actual, sameBeanAs(expected));
240     }
241
242     @Test
243     public void testMapAAILineOfBusiness() throws IOException {
244         LineOfBusiness expected =
245                 mapper.readValue(new File(RESOURCE_PATH + "LineOfBusiness.json"), LineOfBusiness.class);
246
247         org.onap.aai.domain.yang.LineOfBusiness lobAAI = new org.onap.aai.domain.yang.LineOfBusiness();
248         lobAAI.setLineOfBusinessName("lineOfBusinessName");
249
250         LineOfBusiness actual = bbInputSetupMapperLayer.mapAAILineOfBusiness(lobAAI);
251
252         assertThat(actual, sameBeanAs(expected));
253     }
254
255     @Test
256     public void testMapAAINetworkPolicy() throws JsonParseException, JsonMappingException, IOException {
257         NetworkPolicy expectedNetworkPolicy =
258                 mapper.readValue(new File(RESOURCE_PATH + "NetworkPolicy.json"), NetworkPolicy.class);
259
260         org.onap.aai.domain.yang.NetworkPolicy aaiNetworkPolicy = new org.onap.aai.domain.yang.NetworkPolicy();
261         aaiNetworkPolicy.setNetworkPolicyId("networkPolicyId");
262         aaiNetworkPolicy.setNetworkPolicyFqdn("networkPolicyFqdn");
263         aaiNetworkPolicy.setHeatStackId("heatStackId");
264         aaiNetworkPolicy.setResourceVersion("resourceVersion");
265
266         NetworkPolicy actualNetworkPolicy = bbInputSetupMapperLayer.mapAAINetworkPolicy(aaiNetworkPolicy);
267
268         assertThat(actualNetworkPolicy, sameBeanAs(expectedNetworkPolicy));
269     }
270
271     @Test
272     public void testMapAAIVolumeGroup() throws JsonParseException, JsonMappingException, IOException {
273         VolumeGroup expectedVolumeGroup =
274                 mapper.readValue(new File(RESOURCE_PATH + "VolumeGroup.json"), VolumeGroup.class);
275
276         org.onap.aai.domain.yang.VolumeGroup aaiVolumeGroup = mapper.readValue(
277                 new File(RESOURCE_PATH + "VolumeGroup_AAI.json"), org.onap.aai.domain.yang.VolumeGroup.class);
278
279         VolumeGroup actualVolumeGroup = bbInputSetupMapperLayer.mapAAIVolumeGroup(aaiVolumeGroup);
280
281         assertThat(actualVolumeGroup, sameBeanAs(expectedVolumeGroup));
282     }
283
284     @Test
285     public void testMapCatalogServiceIntoServiceInstance() throws IOException {
286         ModelInfoServiceInstance expected = mapper.readValue(new File(RESOURCE_PATH + "ModelInfoServiceInstance.json"),
287                 ModelInfoServiceInstance.class);
288
289         Service catalogService = mapper.readValue(new File(RESOURCE_PATH + "CatalogServiceInput.json"), Service.class);
290
291         ModelInfoServiceInstance actual = bbInputSetupMapperLayer.mapCatalogServiceIntoServiceInstance(catalogService);
292
293         assertThat(actual, sameBeanAs(expected));
294     }
295
296     @Test
297     public void testMapCatalogInstanceGroupToInstanceGroup() throws IOException {
298         ModelInfoInstanceGroup expected =
299                 mapper.readValue(new File(RESOURCE_PATH + "ModelInfoInstanceGroup.json"), ModelInfoInstanceGroup.class);
300
301         InstanceGroup instanceGroup =
302                 mapper.readValue(new File(RESOURCE_PATH + "InstanceGroup.json"), InstanceGroup.class);
303         instanceGroup.setCollectionInstanceGroupCustomizations(new ArrayList<>());
304         CollectionResourceInstanceGroupCustomization collectionInstanceGroupCust =
305                 new CollectionResourceInstanceGroupCustomization();
306         collectionInstanceGroupCust.setModelCustomizationUUID("modelCustomizationUUID");
307         collectionInstanceGroupCust.setFunction("function");
308         collectionInstanceGroupCust.setDescription("description");
309         instanceGroup.getCollectionInstanceGroupCustomizations().add(collectionInstanceGroupCust);
310         CollectionResourceCustomization collectionResourceCust = new CollectionResourceCustomization();
311         collectionResourceCust.setModelCustomizationUUID("modelCustomizationUUID");
312         ModelInfoInstanceGroup actual =
313                 bbInputSetupMapperLayer.mapCatalogInstanceGroupToInstanceGroup(collectionResourceCust, instanceGroup);
314
315         assertThat(actual, sameBeanAs(expected));
316     }
317
318     @Test
319     public void testMapCollectionNetworkResourceCustToNetworkResourceCust() {
320         String modelCustomizationUUID = "modelCustomizationUUID";
321         String modelInstanceName = "modelInstanceName";
322         String networkRole = "networkRole";
323         String networkScope = "networkScope";
324         String networkTechnology = "networkTechnology";
325         String networkType = "networkType";
326
327         NetworkResourceCustomization expected = new NetworkResourceCustomization();
328         expected.setModelCustomizationUUID(modelCustomizationUUID);
329         expected.setModelInstanceName(modelInstanceName);
330         expected.setNetworkRole(networkRole);
331         expected.setNetworkScope(networkScope);
332         expected.setNetworkTechnology(networkTechnology);
333         expected.setNetworkType(networkType);
334         CollectionNetworkResourceCustomization collectionNetworkResourceCust =
335                 new CollectionNetworkResourceCustomization();
336         collectionNetworkResourceCust.setModelCustomizationUUID(modelCustomizationUUID);
337         collectionNetworkResourceCust.setModelInstanceName(modelInstanceName);
338         collectionNetworkResourceCust.setNetworkRole(networkRole);
339         collectionNetworkResourceCust.setNetworkScope(networkScope);
340         collectionNetworkResourceCust.setNetworkTechnology(networkTechnology);
341         collectionNetworkResourceCust.setNetworkType(networkType);
342         NetworkResourceCustomization actual = bbInputSetupMapperLayer
343                 .mapCollectionNetworkResourceCustToNetworkResourceCust(collectionNetworkResourceCust);
344
345         assertThat(actual, sameBeanAs(expected));
346     }
347
348     @Test
349     public void testMapCatalogCollectionToCollection() throws IOException {
350         ModelInfoCollection expected =
351                 mapper.readValue(new File(RESOURCE_PATH + "ModelInfoCollection.json"), ModelInfoCollection.class);
352
353         CollectionResourceCustomization collectionCust =
354                 mapper.readValue(new File(RESOURCE_PATH + "CollectionResourceCustomization.json"),
355                         CollectionResourceCustomization.class);
356
357         CollectionResource collectionResource =
358                 mapper.readValue(new File(RESOURCE_PATH + "CollectionResource.json"), CollectionResource.class);
359
360         ModelInfoCollection actual =
361                 bbInputSetupMapperLayer.mapCatalogCollectionToCollection(collectionCust, collectionResource);
362
363         assertThat(actual, sameBeanAs(expected));
364     }
365
366     @Test
367     public void testMapAAIServiceInstanceIntoServiceInstance() throws IOException {
368         ServiceInstance expected = mapper.readValue(
369                 new File(RESOURCE_PATH + "ServiceInstance_aaiServiceInstanceToSI.json"), ServiceInstance.class);
370
371         org.onap.aai.domain.yang.ServiceInstance serviceInstanceAAI =
372                 mapper.readValue(new File(RESOURCE_PATH + "ServiceInstanceAAIInput.json"),
373                         org.onap.aai.domain.yang.ServiceInstance.class);
374
375         ServiceInstance actual = bbInputSetupMapperLayer.mapAAIServiceInstanceIntoServiceInstance(serviceInstanceAAI);
376
377         assertThat(actual, sameBeanAs(expected));
378     }
379
380     @Test
381     public void testSetPlatformAndLOB() throws IOException {
382         ServiceInstance expected = mapper.readValue(
383                 new File(RESOURCE_PATH + "ServiceInstance_aaiPlatformAndLOBToSI.json"), ServiceInstance.class);
384
385         Map<ResourceKey, String> resourcesToBeOrchestrated = new HashMap<>();
386         resourcesToBeOrchestrated.put(ResourceKey.GENERIC_VNF_ID, "vnfId");
387         Platform platformMSO = new Platform();
388         platformMSO.setPlatformName("platformName");
389         LineOfBusiness lineOfBusinessMSO = new LineOfBusiness();
390         lineOfBusinessMSO.setLineOfBusinessName("lineOfBusinessName");
391
392         ServiceInstance actual = mapper.readValue(
393                 new File(RESOURCE_PATH + "ServiceInstanceAAIPlatformAndLOBInput.json"), ServiceInstance.class);
394
395         bbInputSetupMapperLayer.setPlatformAndLOBIntoServiceInstance(platformMSO, lineOfBusinessMSO, actual,
396                 resourcesToBeOrchestrated);
397
398         assertThat(actual, sameBeanAs(expected));
399     }
400
401     @Test
402     public void testMapAAIL3NetworkIntoL3Network() throws IOException {
403         L3Network expected =
404                 mapper.readValue(new File(RESOURCE_PATH + "l3NetworkExpectedWithSubnet.json"), L3Network.class);
405
406         org.onap.aai.domain.yang.L3Network aaiL3Network =
407                 mapper.readValue(new File(RESOURCE_PATH + "aaiL3NetworkInputWithSubnets.json"),
408                         org.onap.aai.domain.yang.L3Network.class);
409
410         L3Network actual = bbInputSetupMapperLayer.mapAAIL3Network(aaiL3Network);
411
412         assertThat(actual, sameBeanAs(expected));
413     }
414
415     @Test
416     public void testMapAAIGenericVnfIntoGenericVnf() throws IOException {
417         GenericVnf expected = mapper.readValue(new File(RESOURCE_PATH + "GenericVnfExpected.json"), GenericVnf.class);
418         org.onap.aai.domain.yang.GenericVnf aaiGenericVnf = mapper.readValue(
419                 new File(RESOURCE_PATH + "aaiGenericVnfInput.json"), org.onap.aai.domain.yang.GenericVnf.class);
420
421         GenericVnf actual = bbInputSetupMapperLayer.mapAAIGenericVnfIntoGenericVnf(aaiGenericVnf);
422
423         assertThat(actual, sameBeanAs(expected));
424     }
425
426     @Test
427     public void testMapAAIPnfIntoPnf() throws IOException {
428         Pnf expected = mapper.readValue(new File(RESOURCE_PATH + "PnfExpected.json"), Pnf.class);
429         org.onap.aai.domain.yang.Pnf aaiPnf =
430                 mapper.readValue(new File(RESOURCE_PATH + "aaiPnfInput.json"), org.onap.aai.domain.yang.Pnf.class);
431
432         Pnf actual = bbInputSetupMapperLayer.mapAAIPnfIntoPnf(aaiPnf);
433
434         assertThat(actual, sameBeanAs(expected));
435     }
436
437     @Test
438     public void testMapAAICollectionIntoCollection() throws JsonParseException, JsonMappingException, IOException {
439         org.onap.aai.domain.yang.Collection aaiCollection = mapper
440                 .readValue(new File(RESOURCE_PATH + "CollectionInput.json"), org.onap.aai.domain.yang.Collection.class);
441
442         Collection expectedCollection =
443                 mapper.readValue(new File(RESOURCE_PATH + "CollectionExpected.json"), Collection.class);
444
445         Collection actualCollection = bbInputSetupMapperLayer.mapAAICollectionIntoCollection(aaiCollection);
446
447         assertThat(actualCollection, sameBeanAs(expectedCollection));
448     }
449
450     @Test
451     public void testMapAAIInstanceGroupIntoInstanceGroup()
452             throws JsonParseException, JsonMappingException, IOException {
453         org.onap.aai.domain.yang.InstanceGroup aaiInstanceGroup = mapper.readValue(
454                 new File(RESOURCE_PATH + "InstanceGroupInput.json"), org.onap.aai.domain.yang.InstanceGroup.class);
455
456         org.onap.so.bpmn.servicedecomposition.bbobjects.InstanceGroup expectedInstanceGroup =
457                 mapper.readValue(new File(RESOURCE_PATH + "InstanceGroupExpected.json"),
458                         org.onap.so.bpmn.servicedecomposition.bbobjects.InstanceGroup.class);
459
460         org.onap.so.bpmn.servicedecomposition.bbobjects.InstanceGroup actualInstanceGroup =
461                 bbInputSetupMapperLayer.mapAAIInstanceGroupIntoInstanceGroup(aaiInstanceGroup);
462
463         assertThat(actualInstanceGroup, sameBeanAs(expectedInstanceGroup));
464     }
465
466     @Test
467     public void testMapAAIRouteTableReferenceIntoRouteTableReference()
468             throws JsonParseException, JsonMappingException, IOException {
469         org.onap.aai.domain.yang.RouteTableReference aaiRouteTableReference =
470                 mapper.readValue(new File(RESOURCE_PATH + "RouteTableReferenceInput.json"),
471                         org.onap.aai.domain.yang.RouteTableReference.class);
472
473         RouteTableReference expectedRouteTableReference = mapper
474                 .readValue(new File(RESOURCE_PATH + "RouteTableReferenceExpected.json"), RouteTableReference.class);
475
476         RouteTableReference actualRouteTableReference =
477                 bbInputSetupMapperLayer.mapAAIRouteTableReferenceIntoRouteTableReference(aaiRouteTableReference);
478
479         assertThat(actualRouteTableReference, sameBeanAs(expectedRouteTableReference));
480     }
481
482     @Test
483     public void testMapCatalogNetworkToNetwork() throws JsonParseException, JsonMappingException, IOException {
484         NetworkResourceCustomization networkResourceCustomization = mapper.readValue(
485                 new File(RESOURCE_PATH + "NetworkResourceCustomizationInput.json"), NetworkResourceCustomization.class);
486
487         ModelInfoNetwork expectedModelInfoNetwork =
488                 mapper.readValue(new File(RESOURCE_PATH + "ModelInfoNetworkExpected.json"), ModelInfoNetwork.class);
489
490         ModelInfoNetwork actualModelInfoNetwork =
491                 bbInputSetupMapperLayer.mapCatalogNetworkToNetwork(networkResourceCustomization);
492
493         assertThat(actualModelInfoNetwork, sameBeanAs(expectedModelInfoNetwork));
494     }
495
496     @Test
497     public void testMapCatalogVnfToVnf() throws IOException {
498         VnfResourceCustomization vnfResourceCustomization = mapper.readValue(
499                 new File(RESOURCE_PATH + "VnfResourceCustomizationInput.json"), VnfResourceCustomization.class);
500
501         ModelInfoGenericVnf expectedModelInfoGenericVnf = mapper
502                 .readValue(new File(RESOURCE_PATH + "ModelInfoGenericVnfExpected.json"), ModelInfoGenericVnf.class);
503
504         ModelInfoGenericVnf actualModelInfoGenericVnf =
505                 bbInputSetupMapperLayer.mapCatalogVnfToVnf(vnfResourceCustomization);
506
507         assertThat(actualModelInfoGenericVnf, sameBeanAs(expectedModelInfoGenericVnf));
508     }
509
510     @Test
511     public void testMapCatalogVfModuleToVfModule() throws JsonParseException, JsonMappingException, IOException {
512         VfModuleCustomization vfResourceCustomization = mapper
513                 .readValue(new File(RESOURCE_PATH + "VfModuleCustomizationInput.json"), VfModuleCustomization.class);
514
515         ModelInfoVfModule expectedModelInfoVfModule =
516                 mapper.readValue(new File(RESOURCE_PATH + "ModelInfoVfModuleExpected.json"), ModelInfoVfModule.class);
517
518         ModelInfoVfModule actualModelInfoVfModule =
519                 bbInputSetupMapperLayer.mapCatalogVfModuleToVfModule(vfResourceCustomization);
520
521         assertThat(actualModelInfoVfModule, sameBeanAs(expectedModelInfoVfModule));
522     }
523
524     @Test
525     public void testMapRequestPlatform() throws JsonParseException, JsonMappingException, IOException {
526         org.onap.so.serviceinstancebeans.Platform platform = mapper.readValue(
527                 new File(RESOURCE_PATH + "RequestPlatformInput.json"), org.onap.so.serviceinstancebeans.Platform.class);
528
529         Platform expectedPlatform = mapper.readValue(new File(RESOURCE_PATH + "PlatformExpected.json"), Platform.class);
530
531         Platform actualPlatform = bbInputSetupMapperLayer.mapRequestPlatform(platform);
532
533         assertThat(actualPlatform, sameBeanAs(expectedPlatform));
534     }
535
536     @Test
537     public void testMapRequestLineOfBusiness() throws JsonParseException, JsonMappingException, IOException {
538         org.onap.so.serviceinstancebeans.LineOfBusiness lineOfBusiness =
539                 mapper.readValue(new File(RESOURCE_PATH + "RequestLineOfBusinessInput.json"),
540                         org.onap.so.serviceinstancebeans.LineOfBusiness.class);
541
542         LineOfBusiness expectedLineOfBusiness =
543                 mapper.readValue(new File(RESOURCE_PATH + "LineOfBusinessExpected.json"), LineOfBusiness.class);
544
545         LineOfBusiness actualLineOfBusiness = bbInputSetupMapperLayer.mapRequestLineOfBusiness(lineOfBusiness);
546
547         assertThat(actualLineOfBusiness, sameBeanAs(expectedLineOfBusiness));
548     }
549
550     @Test
551     public void testMapAAIConfiguration() throws JsonParseException, JsonMappingException, IOException {
552         org.onap.aai.domain.yang.Configuration configurationAAI = mapper.readValue(
553                 new File(RESOURCE_PATH + "ConfigurationInput.json"), org.onap.aai.domain.yang.Configuration.class);
554
555         Configuration expectedConfiguration =
556                 mapper.readValue(new File(RESOURCE_PATH + "ConfigurationExpected.json"), Configuration.class);
557
558         Configuration actualConfiguration = bbInputSetupMapperLayer.mapAAIConfiguration(configurationAAI);
559
560         assertThat(actualConfiguration, sameBeanAs(expectedConfiguration));
561     }
562
563     @Test
564     public void testMapRequestContext() throws IOException {
565         RequestContext expected =
566                 mapper.readValue(new File(RESOURCE_PATH + "RequestContextExpected.json"), RequestContext.class);
567
568         RequestDetails requestDetails = mapper
569                 .readValue(new File(RESOURCE_PATH + "RequestDetailsInput_mapReqContext.json"), RequestDetails.class);
570         RequestContext actual = bbInputSetupMapperLayer.mapRequestContext(requestDetails);
571
572         assertThat(actual, sameBeanAs(expected));
573     }
574
575     @Test
576     public void testMapOrchestrationContext() throws IOException {
577         OrchestrationContext expected = new OrchestrationContext();
578         expected.setIsRollbackEnabled(true);
579
580         RequestDetails requestDetails = mapper
581                 .readValue(new File(RESOURCE_PATH + "RequestDetailsInput_mapReqContext.json"), RequestDetails.class);
582
583         OrchestrationContext actual = bbInputSetupMapperLayer.mapOrchestrationContext(requestDetails);
584
585         assertThat(actual, sameBeanAs(expected));
586     }
587
588     @Test
589     public void testMapOrchestrationContextNoRequestInfo() throws IOException {
590         OrchestrationContext expected = new OrchestrationContext();
591         expected.setIsRollbackEnabled(false);
592
593         RequestDetails requestDetails = mapper.readValue(
594                 new File(RESOURCE_PATH + "RequestDetailsInput_mapReqContextNoRequestInfo.json"), RequestDetails.class);
595
596         OrchestrationContext actual = bbInputSetupMapperLayer.mapOrchestrationContext(requestDetails);
597
598         assertThat(actual, sameBeanAs(expected));
599     }
600
601     @Test
602     public void testMapLocationContext() {
603         CloudRegion expected = new CloudRegion();
604         expected.setCloudOwner("test-owner-name");
605         expected.setLcpCloudRegionId("cloudRegionId");
606         expected.setComplex("complexName");
607         expected.setTenantId("tenantId");
608         CloudConfiguration cloudConfig = new CloudConfiguration();
609         cloudConfig.setTenantId("tenantId");
610         cloudConfig.setLcpCloudRegionId("cloudRegionId");
611         cloudConfig.setAicNodeClli("aicNodeClli");
612         org.onap.aai.domain.yang.CloudRegion cloudRegion = new org.onap.aai.domain.yang.CloudRegion();
613         cloudRegion.setCloudOwner("test-owner-name");
614         cloudRegion.setCloudRegionId("cloudRegionId");
615         cloudRegion.setComplexName("complexName");
616
617         CloudRegion actual = bbInputSetupMapperLayer.mapCloudRegion(cloudConfig, cloudRegion);
618
619         assertThat(actual, sameBeanAs(expected));
620     }
621
622     @Test
623     public void testMapCloudRegion() {
624         CloudRegion expected = new CloudRegion();
625         expected.setCloudOwner("test-owner-name");
626         expected.setLcpCloudRegionId("cloudRegionId");
627         expected.setTenantId("tenantId");
628         expected.setCloudRegionVersion("cloudRegionVersion");
629
630         CloudConfiguration cloudConfig = new CloudConfiguration();
631         cloudConfig.setTenantId("tenantId");
632         cloudConfig.setLcpCloudRegionId("cloudRegionId");
633         cloudConfig.setAicNodeClli("aicNodeClli");
634
635         org.onap.aai.domain.yang.CloudRegion cloudRegion = new org.onap.aai.domain.yang.CloudRegion();
636         cloudRegion.setCloudOwner("test-owner-name");
637         cloudRegion.setCloudRegionId("cloudRegionId");
638         cloudRegion.setCloudRegionVersion("cloudRegionVersion");
639
640         CloudRegion actual = bbInputSetupMapperLayer.mapCloudRegion(cloudConfig, cloudRegion);
641
642         assertThat(actual, sameBeanAs(expected));
643     }
644
645     @Test
646     public void testMapTenant() {
647         Tenant expected = new Tenant();
648         expected.setTenantId("tenantId");
649         expected.setTenantName("tenantName");
650         expected.setTenantContext("tenantContext");
651
652         org.onap.aai.domain.yang.Tenant aaiTenant = new org.onap.aai.domain.yang.Tenant();
653         aaiTenant.setTenantId("tenantId");
654         aaiTenant.setTenantName("tenantName");
655         aaiTenant.setTenantContext("tenantContext");
656
657         Tenant actual = bbInputSetupMapperLayer.mapTenant(aaiTenant);
658
659         assertThat(actual, sameBeanAs(expected));
660     }
661
662     @Test
663     public void testMapCloudRegionWithNullCheck() {
664         CloudRegion expected = new CloudRegion();
665
666         CloudRegion actual = bbInputSetupMapperLayer.mapCloudRegion(null, null);
667
668         assertThat(actual, sameBeanAs(expected));
669     }
670
671     @Test
672     public void testmapCatalogConfigurationToConfiguration() {
673         String modelCustUUID = "modelCustomizationUUID";
674         String modelInvariantUUID = "modelInvariantUUID";
675         String modelVersionUUID = "modelUUID";
676         String policyName = "policyName";
677         ModelInfoConfiguration expected = new ModelInfoConfiguration();
678         expected.setModelCustomizationId(modelCustUUID);
679         expected.setModelInvariantId(modelInvariantUUID);
680         expected.setModelVersionId(modelVersionUUID);
681         expected.setPolicyName(policyName);
682         ConfigurationResourceCustomization configurationResourceCustomization =
683                 new ConfigurationResourceCustomization();
684         configurationResourceCustomization.setModelCustomizationUUID(modelCustUUID);
685         configurationResourceCustomization.setConfigurationResource(new ConfigurationResource());
686         configurationResourceCustomization.getConfigurationResource().setModelInvariantUUID(modelInvariantUUID);
687         configurationResourceCustomization.getConfigurationResource().setModelUUID(modelVersionUUID);
688         CvnfcConfigurationCustomization policyNameTable = new CvnfcConfigurationCustomization();
689         policyNameTable.setCvnfcCustomization(new CvnfcCustomization());
690         policyNameTable.getCvnfcCustomization().setVnfcCustomization(new VnfcCustomization());
691         policyNameTable.setPolicyName(policyName);
692
693         ModelInfoConfiguration actual = bbInputSetupMapperLayer
694                 .mapCatalogConfigurationToConfiguration(configurationResourceCustomization, policyNameTable);
695
696         assertThat(actual, sameBeanAs(expected));
697     }
698
699     @Test
700     public void testmapCatalogConfigurationToFabricConfiguration() {
701         String modelCustUUID = "modelCustomizationUUID";
702         String modelInvariantUUID = "modelInvariantUUID";
703         String modelVersionUUID = "modelUUID";
704         String policyName = "policyName";
705         ModelInfoConfiguration expected = new ModelInfoConfiguration();
706         expected.setModelCustomizationId(modelCustUUID);
707         expected.setModelInvariantId(modelInvariantUUID);
708         expected.setModelVersionId(modelVersionUUID);
709         expected.setPolicyName(policyName);
710
711         CvnfcConfigurationCustomization fabricCustomization = new CvnfcConfigurationCustomization();
712         fabricCustomization.setCvnfcCustomization(new CvnfcCustomization());
713         fabricCustomization.getCvnfcCustomization().setVnfcCustomization(new VnfcCustomization());
714         fabricCustomization.setPolicyName(policyName);
715         fabricCustomization.setModelCustomizationUUID(modelCustUUID);
716
717         ConfigurationResource configurationResource = new ConfigurationResource();
718         configurationResource.setModelUUID(modelVersionUUID);
719         configurationResource.setModelInvariantUUID(modelInvariantUUID);
720         fabricCustomization.setConfigurationResource(configurationResource);
721
722         ModelInfoConfiguration actual =
723                 bbInputSetupMapperLayer.mapCatalogConfigurationToConfiguration(fabricCustomization);
724
725         assertThat(actual, sameBeanAs(expected));
726     }
727
728     @Test
729     public void testMapNameValueUserParams() throws IOException {
730         RequestDetails requestDetails = mapper
731                 .readValue(new File(RESOURCE_PATH + "RequestDetailsInput_mapReqContext.json"), RequestDetails.class);
732         Map<String, Object> actual =
733                 bbInputSetupMapperLayer.mapNameValueUserParams(requestDetails.getRequestParameters());
734
735         assertTrue(actual.containsKey("mns_vfw_protected_route_prefixes"));
736         assertTrue(actual.get("mns_vfw_protected_route_prefixes").toString()
737                 .contains("interface_route_table_routes_route"));
738         assertTrue(actual.get("mns_vfw_protected_route_prefixes").toString().contains("1.1.1.1/32"));
739         assertTrue(actual.get("mns_vfw_protected_route_prefixes").toString().contains("0::1/128"));
740         assertTrue(actual.containsKey("name1"));
741         assertTrue(actual.containsValue("value1"));
742         assertTrue(actual.get("name1").equals("value1"));
743
744         assertFalse(actual.containsKey("ignore"));
745         assertFalse(actual.containsValue("ignore"));
746     }
747
748     @Test
749     public void testMapRequestParameters() throws IOException {
750         RequestDetails requestDetails = mapper
751                 .readValue(new File(RESOURCE_PATH + "RequestDetailsInput_mapReqContext.json"), RequestDetails.class);
752         RequestParameters actual = bbInputSetupMapperLayer.mapRequestParameters(requestDetails.getRequestParameters());
753
754         assertEquals(actual.getUsePreload(), requestDetails.getRequestParameters().getUsePreload());
755         assertEquals(actual.getSubscriptionServiceType(),
756                 requestDetails.getRequestParameters().getSubscriptionServiceType());
757         assertEquals(actual.getPayload(), requestDetails.getRequestParameters().getPayload());
758     }
759
760     protected RequestParameters mapRequestParameters(
761             org.onap.so.serviceinstancebeans.RequestParameters requestParameters) {
762         RequestParameters requestParams = new RequestParameters();
763         requestParams.setaLaCarte(requestParameters.getALaCarte());
764         requestParams.setUsePreload(requestParameters.getUsePreload());
765         requestParams.setSubscriptionServiceType(requestParameters.getSubscriptionServiceType());
766         requestParams.setUserParams(requestParameters.getUserParams());
767         requestParams.setPayload(requestParameters.getPayload());
768         return requestParams;
769     }
770
771 }