Merge remote-tracking branch 'origin/dublin' into 'origin/master'
[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.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;
85
86 public class BBInputSetupMapperLayerTest {
87
88     BBInputSetupMapperLayer bbInputSetupMapperLayer = new BBInputSetupMapperLayer();
89
90     ObjectMapper mapper = new ObjectMapper();
91
92     private static final String RESOURCE_PATH = "src/test/resources/__files/ExecuteBuildingBlock/";
93
94     @Test
95     public void testMapOrchestrationStatusFromAAI() {
96         OrchestrationStatus expected = OrchestrationStatus.INVENTORIED;
97         String orchStatusInput = "Inventoried";
98         OrchestrationStatus actual = bbInputSetupMapperLayer.mapOrchestrationStatusFromAAI(orchStatusInput);
99         assertThat(actual, sameBeanAs(expected));
100
101         expected = OrchestrationStatus.ASSIGNED;
102         orchStatusInput = "Assigned";
103         actual = bbInputSetupMapperLayer.mapOrchestrationStatusFromAAI(orchStatusInput);
104         assertThat(actual, sameBeanAs(expected));
105
106         expected = OrchestrationStatus.ACTIVE;
107         orchStatusInput = "Active";
108         actual = bbInputSetupMapperLayer.mapOrchestrationStatusFromAAI(orchStatusInput);
109         assertThat(actual, sameBeanAs(expected));
110
111         expected = OrchestrationStatus.CREATED;
112         orchStatusInput = "Created";
113         actual = bbInputSetupMapperLayer.mapOrchestrationStatusFromAAI(orchStatusInput);
114         assertThat(actual, sameBeanAs(expected));
115
116         expected = OrchestrationStatus.PRECREATED;
117         orchStatusInput = "PreCreated";
118         actual = bbInputSetupMapperLayer.mapOrchestrationStatusFromAAI(orchStatusInput);
119         assertThat(actual, sameBeanAs(expected));
120
121         expected = OrchestrationStatus.PENDING_CREATE;
122         orchStatusInput = "PendingCreate";
123         actual = bbInputSetupMapperLayer.mapOrchestrationStatusFromAAI(orchStatusInput);
124         assertThat(actual, sameBeanAs(expected));
125
126         expected = OrchestrationStatus.PENDING_DELETE;
127         orchStatusInput = "PendingDelete";
128         actual = bbInputSetupMapperLayer.mapOrchestrationStatusFromAAI(orchStatusInput);
129         assertThat(actual, sameBeanAs(expected));
130
131         expected = OrchestrationStatus.PENDING;
132         orchStatusInput = "Pending";
133         actual = bbInputSetupMapperLayer.mapOrchestrationStatusFromAAI(orchStatusInput);
134         assertThat(actual, sameBeanAs(expected));
135
136         expected = OrchestrationStatus.PENDING_ACTIVATION;
137         orchStatusInput = "PendingActivation";
138         actual = bbInputSetupMapperLayer.mapOrchestrationStatusFromAAI(orchStatusInput);
139         assertThat(actual, sameBeanAs(expected));
140     }
141
142     @Test
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));
148         });
149     }
150
151     @Test
152     public void testMapAAICustomer() throws IOException {
153         Customer expected = mapper.readValue(new File(RESOURCE_PATH + "Customer.json"), Customer.class);
154
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);
157
158         Customer actual = bbInputSetupMapperLayer.mapAAICustomer(customerAAI);
159
160         assertThat(actual, sameBeanAs(expected));
161     }
162
163     @Test
164     public void testMapAAIServiceSubscription() throws IOException {
165         ServiceSubscription expected = mapper.readValue(new File(RESOURCE_PATH + "ServiceSubscriptionExpected.json"),
166                 ServiceSubscription.class);
167
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);
171
172         ServiceSubscription actual = bbInputSetupMapperLayer.mapAAIServiceSubscription(svcSubscriptionAAI);
173
174         assertThat(actual, sameBeanAs(expected));
175     }
176
177     @Test
178     public void testMapAAIProject() throws IOException {
179         Project expected = mapper.readValue(new File(RESOURCE_PATH + "Project.json"), Project.class);
180
181         org.onap.aai.domain.yang.Project projectAAI = new org.onap.aai.domain.yang.Project();
182         projectAAI.setProjectName("projectName");
183
184         Project actual = bbInputSetupMapperLayer.mapAAIProject(projectAAI);
185
186         assertThat(actual, sameBeanAs(expected));
187     }
188
189     @Test
190     public void testMapRequestProject() throws IOException {
191         Project expected = mapper.readValue(new File(RESOURCE_PATH + "Project.json"), Project.class);
192
193         org.onap.so.serviceinstancebeans.Project requestProject = new org.onap.so.serviceinstancebeans.Project();
194         requestProject.setProjectName("projectName");
195
196         Project actual = bbInputSetupMapperLayer.mapRequestProject(requestProject);
197
198         assertThat(actual, sameBeanAs(expected));
199     }
200
201     @Test
202     public void testMapAAIOwningEntity() throws IOException {
203         OwningEntity expected = mapper.readValue(new File(RESOURCE_PATH + "OwningEntity.json"), OwningEntity.class);
204
205         org.onap.aai.domain.yang.OwningEntity entityAAI = new org.onap.aai.domain.yang.OwningEntity();
206         entityAAI.setOwningEntityId("owningEntityId");
207         entityAAI.setOwningEntityName("owningEntityName");
208
209         OwningEntity actual = bbInputSetupMapperLayer.mapAAIOwningEntity(entityAAI);
210
211         assertThat(actual, sameBeanAs(expected));
212     }
213
214     @Test
215     public void testMapRequestOwningEntity() throws IOException {
216         OwningEntity expected = mapper.readValue(new File(RESOURCE_PATH + "OwningEntity.json"), OwningEntity.class);
217
218         org.onap.so.serviceinstancebeans.OwningEntity requestOwningEntity =
219                 new org.onap.so.serviceinstancebeans.OwningEntity();
220         requestOwningEntity.setOwningEntityId("owningEntityId");
221         requestOwningEntity.setOwningEntityName("owningEntityName");
222
223         OwningEntity actual = bbInputSetupMapperLayer.mapRequestOwningEntity(requestOwningEntity);
224
225         assertThat(actual, sameBeanAs(expected));
226     }
227
228     @Test
229     public void testMapAAIPlatform() throws IOException {
230         Platform expected = mapper.readValue(new File(RESOURCE_PATH + "Platform.json"), Platform.class);
231
232         org.onap.aai.domain.yang.Platform platformAAI = new org.onap.aai.domain.yang.Platform();
233         platformAAI.setPlatformName("platformName");
234
235         Platform actual = bbInputSetupMapperLayer.mapAAIPlatform(platformAAI);
236
237         assertThat(actual, sameBeanAs(expected));
238     }
239
240     @Test
241     public void testMapAAILineOfBusiness() throws IOException {
242         LineOfBusiness expected =
243                 mapper.readValue(new File(RESOURCE_PATH + "LineOfBusiness.json"), LineOfBusiness.class);
244
245         org.onap.aai.domain.yang.LineOfBusiness lobAAI = new org.onap.aai.domain.yang.LineOfBusiness();
246         lobAAI.setLineOfBusinessName("lineOfBusinessName");
247
248         LineOfBusiness actual = bbInputSetupMapperLayer.mapAAILineOfBusiness(lobAAI);
249
250         assertThat(actual, sameBeanAs(expected));
251     }
252
253     @Test
254     public void testMapAAINetworkPolicy() throws JsonParseException, JsonMappingException, IOException {
255         NetworkPolicy expectedNetworkPolicy =
256                 mapper.readValue(new File(RESOURCE_PATH + "NetworkPolicy.json"), NetworkPolicy.class);
257
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");
263
264         NetworkPolicy actualNetworkPolicy = bbInputSetupMapperLayer.mapAAINetworkPolicy(aaiNetworkPolicy);
265
266         assertThat(actualNetworkPolicy, sameBeanAs(expectedNetworkPolicy));
267     }
268
269     @Test
270     public void testMapAAIVolumeGroup() throws JsonParseException, JsonMappingException, IOException {
271         VolumeGroup expectedVolumeGroup =
272                 mapper.readValue(new File(RESOURCE_PATH + "VolumeGroup.json"), VolumeGroup.class);
273
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);
276
277         VolumeGroup actualVolumeGroup = bbInputSetupMapperLayer.mapAAIVolumeGroup(aaiVolumeGroup);
278
279         assertThat(actualVolumeGroup, sameBeanAs(expectedVolumeGroup));
280     }
281
282     @Test
283     public void testMapCatalogServiceIntoServiceInstance() throws IOException {
284         ModelInfoServiceInstance expected = mapper.readValue(new File(RESOURCE_PATH + "ModelInfoServiceInstance.json"),
285                 ModelInfoServiceInstance.class);
286
287         Service catalogService = mapper.readValue(new File(RESOURCE_PATH + "CatalogServiceInput.json"), Service.class);
288
289         ModelInfoServiceInstance actual = bbInputSetupMapperLayer.mapCatalogServiceIntoServiceInstance(catalogService);
290
291         assertThat(actual, sameBeanAs(expected));
292     }
293
294     @Test
295     public void testMapCatalogInstanceGroupToInstanceGroup() throws IOException {
296         ModelInfoInstanceGroup expected =
297                 mapper.readValue(new File(RESOURCE_PATH + "ModelInfoInstanceGroup.json"), ModelInfoInstanceGroup.class);
298
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);
312
313         assertThat(actual, sameBeanAs(expected));
314     }
315
316     @Test
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";
324
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);
342
343         assertThat(actual, sameBeanAs(expected));
344     }
345
346     @Test
347     public void testMapCatalogCollectionToCollection() throws IOException {
348         ModelInfoCollection expected =
349                 mapper.readValue(new File(RESOURCE_PATH + "ModelInfoCollection.json"), ModelInfoCollection.class);
350
351         CollectionResourceCustomization collectionCust =
352                 mapper.readValue(new File(RESOURCE_PATH + "CollectionResourceCustomization.json"),
353                         CollectionResourceCustomization.class);
354
355         CollectionResource collectionResource =
356                 mapper.readValue(new File(RESOURCE_PATH + "CollectionResource.json"), CollectionResource.class);
357
358         ModelInfoCollection actual =
359                 bbInputSetupMapperLayer.mapCatalogCollectionToCollection(collectionCust, collectionResource);
360
361         assertThat(actual, sameBeanAs(expected));
362     }
363
364     @Test
365     public void testMapAAIServiceInstanceIntoServiceInstance() throws IOException {
366         ServiceInstance expected = mapper.readValue(
367                 new File(RESOURCE_PATH + "ServiceInstance_aaiServiceInstanceToSI.json"), ServiceInstance.class);
368
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);
372
373         ServiceInstance actual = bbInputSetupMapperLayer.mapAAIServiceInstanceIntoServiceInstance(serviceInstanceAAI);
374
375         assertThat(actual, sameBeanAs(expected));
376     }
377
378     @Test
379     public void testSetPlatformAndLOB() throws IOException {
380         ServiceInstance expected = mapper.readValue(
381                 new File(RESOURCE_PATH + "ServiceInstance_aaiPlatformAndLOBToSI.json"), ServiceInstance.class);
382
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");
389
390         ServiceInstance actual = mapper.readValue(
391                 new File(RESOURCE_PATH + "ServiceInstanceAAIPlatformAndLOBInput.json"), ServiceInstance.class);
392
393         bbInputSetupMapperLayer.setPlatformAndLOBIntoServiceInstance(platformMSO, lineOfBusinessMSO, actual,
394                 resourcesToBeOrchestrated);
395
396         assertThat(actual, sameBeanAs(expected));
397     }
398
399     @Test
400     public void testMapAAIL3NetworkIntoL3Network() throws IOException {
401         L3Network expected =
402                 mapper.readValue(new File(RESOURCE_PATH + "l3NetworkExpectedWithSubnet.json"), L3Network.class);
403
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);
407
408         L3Network actual = bbInputSetupMapperLayer.mapAAIL3Network(aaiL3Network);
409
410         assertThat(actual, sameBeanAs(expected));
411     }
412
413     @Test
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);
418
419         GenericVnf actual = bbInputSetupMapperLayer.mapAAIGenericVnfIntoGenericVnf(aaiGenericVnf);
420
421         assertThat(actual, sameBeanAs(expected));
422     }
423
424     @Test
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);
428
429         Collection expectedCollection =
430                 mapper.readValue(new File(RESOURCE_PATH + "CollectionExpected.json"), Collection.class);
431
432         Collection actualCollection = bbInputSetupMapperLayer.mapAAICollectionIntoCollection(aaiCollection);
433
434         assertThat(actualCollection, sameBeanAs(expectedCollection));
435     }
436
437     @Test
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);
442
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);
446
447         org.onap.so.bpmn.servicedecomposition.bbobjects.InstanceGroup actualInstanceGroup =
448                 bbInputSetupMapperLayer.mapAAIInstanceGroupIntoInstanceGroup(aaiInstanceGroup);
449
450         assertThat(actualInstanceGroup, sameBeanAs(expectedInstanceGroup));
451     }
452
453     @Test
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);
459
460         RouteTableReference expectedRouteTableReference = mapper
461                 .readValue(new File(RESOURCE_PATH + "RouteTableReferenceExpected.json"), RouteTableReference.class);
462
463         RouteTableReference actualRouteTableReference =
464                 bbInputSetupMapperLayer.mapAAIRouteTableReferenceIntoRouteTableReference(aaiRouteTableReference);
465
466         assertThat(actualRouteTableReference, sameBeanAs(expectedRouteTableReference));
467     }
468
469     @Test
470     public void testMapCatalogNetworkToNetwork() throws JsonParseException, JsonMappingException, IOException {
471         NetworkResourceCustomization networkResourceCustomization = mapper.readValue(
472                 new File(RESOURCE_PATH + "NetworkResourceCustomizationInput.json"), NetworkResourceCustomization.class);
473
474         ModelInfoNetwork expectedModelInfoNetwork =
475                 mapper.readValue(new File(RESOURCE_PATH + "ModelInfoNetworkExpected.json"), ModelInfoNetwork.class);
476
477         ModelInfoNetwork actualModelInfoNetwork =
478                 bbInputSetupMapperLayer.mapCatalogNetworkToNetwork(networkResourceCustomization);
479
480         assertThat(actualModelInfoNetwork, sameBeanAs(expectedModelInfoNetwork));
481     }
482
483     @Test
484     public void testMapCatalogVnfToVnf() throws IOException {
485         VnfResourceCustomization vnfResourceCustomization = mapper.readValue(
486                 new File(RESOURCE_PATH + "VnfResourceCustomizationInput.json"), VnfResourceCustomization.class);
487
488         ModelInfoGenericVnf expectedModelInfoGenericVnf = mapper
489                 .readValue(new File(RESOURCE_PATH + "ModelInfoGenericVnfExpected.json"), ModelInfoGenericVnf.class);
490
491         ModelInfoGenericVnf actualModelInfoGenericVnf =
492                 bbInputSetupMapperLayer.mapCatalogVnfToVnf(vnfResourceCustomization);
493
494         assertThat(actualModelInfoGenericVnf, sameBeanAs(expectedModelInfoGenericVnf));
495     }
496
497     @Test
498     public void testMapCatalogVfModuleToVfModule() throws JsonParseException, JsonMappingException, IOException {
499         VfModuleCustomization vfResourceCustomization = mapper
500                 .readValue(new File(RESOURCE_PATH + "VfModuleCustomizationInput.json"), VfModuleCustomization.class);
501
502         ModelInfoVfModule expectedModelInfoVfModule =
503                 mapper.readValue(new File(RESOURCE_PATH + "ModelInfoVfModuleExpected.json"), ModelInfoVfModule.class);
504
505         ModelInfoVfModule actualModelInfoVfModule =
506                 bbInputSetupMapperLayer.mapCatalogVfModuleToVfModule(vfResourceCustomization);
507
508         assertThat(actualModelInfoVfModule, sameBeanAs(expectedModelInfoVfModule));
509     }
510
511     @Test
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);
515
516         Platform expectedPlatform = mapper.readValue(new File(RESOURCE_PATH + "PlatformExpected.json"), Platform.class);
517
518         Platform actualPlatform = bbInputSetupMapperLayer.mapRequestPlatform(platform);
519
520         assertThat(actualPlatform, sameBeanAs(expectedPlatform));
521     }
522
523     @Test
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);
528
529         LineOfBusiness expectedLineOfBusiness =
530                 mapper.readValue(new File(RESOURCE_PATH + "LineOfBusinessExpected.json"), LineOfBusiness.class);
531
532         LineOfBusiness actualLineOfBusiness = bbInputSetupMapperLayer.mapRequestLineOfBusiness(lineOfBusiness);
533
534         assertThat(actualLineOfBusiness, sameBeanAs(expectedLineOfBusiness));
535     }
536
537     @Test
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);
541
542         Configuration expectedConfiguration =
543                 mapper.readValue(new File(RESOURCE_PATH + "ConfigurationExpected.json"), Configuration.class);
544
545         Configuration actualConfiguration = bbInputSetupMapperLayer.mapAAIConfiguration(configurationAAI);
546
547         assertThat(actualConfiguration, sameBeanAs(expectedConfiguration));
548     }
549
550     @Test
551     public void testMapRequestContext() throws IOException {
552         RequestContext expected =
553                 mapper.readValue(new File(RESOURCE_PATH + "RequestContextExpected.json"), RequestContext.class);
554
555         RequestDetails requestDetails = mapper
556                 .readValue(new File(RESOURCE_PATH + "RequestDetailsInput_mapReqContext.json"), RequestDetails.class);
557         RequestContext actual = bbInputSetupMapperLayer.mapRequestContext(requestDetails);
558
559         assertThat(actual, sameBeanAs(expected));
560     }
561
562     @Test
563     public void testMapOrchestrationContext() throws IOException {
564         OrchestrationContext expected = new OrchestrationContext();
565         expected.setIsRollbackEnabled(true);
566
567         RequestDetails requestDetails = mapper
568                 .readValue(new File(RESOURCE_PATH + "RequestDetailsInput_mapReqContext.json"), RequestDetails.class);
569
570         OrchestrationContext actual = bbInputSetupMapperLayer.mapOrchestrationContext(requestDetails);
571
572         assertThat(actual, sameBeanAs(expected));
573     }
574
575     @Test
576     public void testMapOrchestrationContextNoRequestInfo() throws IOException {
577         OrchestrationContext expected = new OrchestrationContext();
578         expected.setIsRollbackEnabled(false);
579
580         RequestDetails requestDetails = mapper.readValue(
581                 new File(RESOURCE_PATH + "RequestDetailsInput_mapReqContextNoRequestInfo.json"), RequestDetails.class);
582
583         OrchestrationContext actual = bbInputSetupMapperLayer.mapOrchestrationContext(requestDetails);
584
585         assertThat(actual, sameBeanAs(expected));
586     }
587
588     @Test
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");
603
604         CloudRegion actual = bbInputSetupMapperLayer.mapCloudRegion(cloudConfig, cloudRegion);
605
606         assertThat(actual, sameBeanAs(expected));
607     }
608
609     @Test
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");
616
617         CloudConfiguration cloudConfig = new CloudConfiguration();
618         cloudConfig.setTenantId("tenantId");
619         cloudConfig.setLcpCloudRegionId("cloudRegionId");
620         cloudConfig.setAicNodeClli("aicNodeClli");
621
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");
626
627         CloudRegion actual = bbInputSetupMapperLayer.mapCloudRegion(cloudConfig, cloudRegion);
628
629         assertThat(actual, sameBeanAs(expected));
630     }
631
632     @Test
633     public void testMapTenant() {
634         Tenant expected = new Tenant();
635         expected.setTenantId("tenantId");
636         expected.setTenantName("tenantName");
637         expected.setTenantContext("tenantContext");
638
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");
643
644         Tenant actual = bbInputSetupMapperLayer.mapTenant(aaiTenant);
645
646         assertThat(actual, sameBeanAs(expected));
647     }
648
649     @Test
650     public void testMapCloudRegionWithNullCheck() {
651         CloudRegion expected = new CloudRegion();
652
653         CloudRegion actual = bbInputSetupMapperLayer.mapCloudRegion(null, null);
654
655         assertThat(actual, sameBeanAs(expected));
656     }
657
658     @Test
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);
679
680         ModelInfoConfiguration actual = bbInputSetupMapperLayer
681                 .mapCatalogConfigurationToConfiguration(configurationResourceCustomization, policyNameTable);
682
683         assertThat(actual, sameBeanAs(expected));
684     }
685
686     @Test
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);
697
698         CvnfcConfigurationCustomization fabricCustomization = new CvnfcConfigurationCustomization();
699         fabricCustomization.setCvnfcCustomization(new CvnfcCustomization());
700         fabricCustomization.getCvnfcCustomization().setVnfcCustomization(new VnfcCustomization());
701         fabricCustomization.setPolicyName(policyName);
702         fabricCustomization.setModelCustomizationUUID(modelCustUUID);
703
704         ConfigurationResource configurationResource = new ConfigurationResource();
705         configurationResource.setModelUUID(modelVersionUUID);
706         configurationResource.setModelInvariantUUID(modelInvariantUUID);
707         fabricCustomization.setConfigurationResource(configurationResource);
708
709         ModelInfoConfiguration actual =
710                 bbInputSetupMapperLayer.mapCatalogConfigurationToConfiguration(fabricCustomization);
711
712         assertThat(actual, sameBeanAs(expected));
713     }
714
715     @Test
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());
721
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"));
730
731         assertFalse(actual.containsKey("ignore"));
732         assertFalse(actual.containsValue("ignore"));
733     }
734
735     @Test
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());
740
741         assertEquals(actual.getUsePreload(), requestDetails.getRequestParameters().getUsePreload());
742         assertEquals(actual.getSubscriptionServiceType(),
743                 requestDetails.getRequestParameters().getSubscriptionServiceType());
744         assertEquals(actual.getPayload(), requestDetails.getRequestParameters().getPayload());
745     }
746
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;
756     }
757
758 }