Check for null requestInfo
[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 = mapper.readValue(new File(RESOURCE_PATH + "l3NetworkExpected.json"), L3Network.class);
402
403         org.onap.aai.domain.yang.L3Network aaiL3Network = mapper.readValue(
404                 new File(RESOURCE_PATH + "aaiL3NetworkInput.json"), org.onap.aai.domain.yang.L3Network.class);
405
406         L3Network actual = bbInputSetupMapperLayer.mapAAIL3Network(aaiL3Network);
407
408         assertThat(actual, sameBeanAs(expected));
409     }
410
411     @Test
412     public void testMapAAIGenericVnfIntoGenericVnf() throws IOException {
413         GenericVnf expected = mapper.readValue(new File(RESOURCE_PATH + "GenericVnfExpected.json"), GenericVnf.class);
414         org.onap.aai.domain.yang.GenericVnf aaiGenericVnf = mapper.readValue(
415                 new File(RESOURCE_PATH + "aaiGenericVnfInput.json"), org.onap.aai.domain.yang.GenericVnf.class);
416
417         GenericVnf actual = bbInputSetupMapperLayer.mapAAIGenericVnfIntoGenericVnf(aaiGenericVnf);
418
419         assertThat(actual, sameBeanAs(expected));
420     }
421
422     @Test
423     public void testMapAAICollectionIntoCollection() throws JsonParseException, JsonMappingException, IOException {
424         org.onap.aai.domain.yang.Collection aaiCollection = mapper
425                 .readValue(new File(RESOURCE_PATH + "CollectionInput.json"), org.onap.aai.domain.yang.Collection.class);
426
427         Collection expectedCollection =
428                 mapper.readValue(new File(RESOURCE_PATH + "CollectionExpected.json"), Collection.class);
429
430         Collection actualCollection = bbInputSetupMapperLayer.mapAAICollectionIntoCollection(aaiCollection);
431
432         assertThat(actualCollection, sameBeanAs(expectedCollection));
433     }
434
435     @Test
436     public void testMapAAIInstanceGroupIntoInstanceGroup()
437             throws JsonParseException, JsonMappingException, IOException {
438         org.onap.aai.domain.yang.InstanceGroup aaiInstanceGroup = mapper.readValue(
439                 new File(RESOURCE_PATH + "InstanceGroupInput.json"), org.onap.aai.domain.yang.InstanceGroup.class);
440
441         org.onap.so.bpmn.servicedecomposition.bbobjects.InstanceGroup expectedInstanceGroup =
442                 mapper.readValue(new File(RESOURCE_PATH + "InstanceGroupExpected.json"),
443                         org.onap.so.bpmn.servicedecomposition.bbobjects.InstanceGroup.class);
444
445         org.onap.so.bpmn.servicedecomposition.bbobjects.InstanceGroup actualInstanceGroup =
446                 bbInputSetupMapperLayer.mapAAIInstanceGroupIntoInstanceGroup(aaiInstanceGroup);
447
448         assertThat(actualInstanceGroup, sameBeanAs(expectedInstanceGroup));
449     }
450
451     @Test
452     public void testMapAAIRouteTableReferenceIntoRouteTableReference()
453             throws JsonParseException, JsonMappingException, IOException {
454         org.onap.aai.domain.yang.RouteTableReference aaiRouteTableReference =
455                 mapper.readValue(new File(RESOURCE_PATH + "RouteTableReferenceInput.json"),
456                         org.onap.aai.domain.yang.RouteTableReference.class);
457
458         RouteTableReference expectedRouteTableReference = mapper
459                 .readValue(new File(RESOURCE_PATH + "RouteTableReferenceExpected.json"), RouteTableReference.class);
460
461         RouteTableReference actualRouteTableReference =
462                 bbInputSetupMapperLayer.mapAAIRouteTableReferenceIntoRouteTableReference(aaiRouteTableReference);
463
464         assertThat(actualRouteTableReference, sameBeanAs(expectedRouteTableReference));
465     }
466
467     @Test
468     public void testMapCatalogNetworkToNetwork() throws JsonParseException, JsonMappingException, IOException {
469         NetworkResourceCustomization networkResourceCustomization = mapper.readValue(
470                 new File(RESOURCE_PATH + "NetworkResourceCustomizationInput.json"), NetworkResourceCustomization.class);
471
472         ModelInfoNetwork expectedModelInfoNetwork =
473                 mapper.readValue(new File(RESOURCE_PATH + "ModelInfoNetworkExpected.json"), ModelInfoNetwork.class);
474
475         ModelInfoNetwork actualModelInfoNetwork =
476                 bbInputSetupMapperLayer.mapCatalogNetworkToNetwork(networkResourceCustomization);
477
478         assertThat(actualModelInfoNetwork, sameBeanAs(expectedModelInfoNetwork));
479     }
480
481     @Test
482     public void testMapCatalogVnfToVnf() throws IOException {
483         VnfResourceCustomization vnfResourceCustomization = mapper.readValue(
484                 new File(RESOURCE_PATH + "VnfResourceCustomizationInput.json"), VnfResourceCustomization.class);
485
486         ModelInfoGenericVnf expectedModelInfoGenericVnf = mapper
487                 .readValue(new File(RESOURCE_PATH + "ModelInfoGenericVnfExpected.json"), ModelInfoGenericVnf.class);
488
489         ModelInfoGenericVnf actualModelInfoGenericVnf =
490                 bbInputSetupMapperLayer.mapCatalogVnfToVnf(vnfResourceCustomization);
491
492         assertThat(actualModelInfoGenericVnf, sameBeanAs(expectedModelInfoGenericVnf));
493     }
494
495     @Test
496     public void testMapCatalogVfModuleToVfModule() throws JsonParseException, JsonMappingException, IOException {
497         VfModuleCustomization vfResourceCustomization = mapper
498                 .readValue(new File(RESOURCE_PATH + "VfModuleCustomizationInput.json"), VfModuleCustomization.class);
499
500         ModelInfoVfModule expectedModelInfoVfModule =
501                 mapper.readValue(new File(RESOURCE_PATH + "ModelInfoVfModuleExpected.json"), ModelInfoVfModule.class);
502
503         ModelInfoVfModule actualModelInfoVfModule =
504                 bbInputSetupMapperLayer.mapCatalogVfModuleToVfModule(vfResourceCustomization);
505
506         assertThat(actualModelInfoVfModule, sameBeanAs(expectedModelInfoVfModule));
507     }
508
509     @Test
510     public void testMapRequestPlatform() throws JsonParseException, JsonMappingException, IOException {
511         org.onap.so.serviceinstancebeans.Platform platform = mapper.readValue(
512                 new File(RESOURCE_PATH + "RequestPlatformInput.json"), org.onap.so.serviceinstancebeans.Platform.class);
513
514         Platform expectedPlatform = mapper.readValue(new File(RESOURCE_PATH + "PlatformExpected.json"), Platform.class);
515
516         Platform actualPlatform = bbInputSetupMapperLayer.mapRequestPlatform(platform);
517
518         assertThat(actualPlatform, sameBeanAs(expectedPlatform));
519     }
520
521     @Test
522     public void testMapRequestLineOfBusiness() throws JsonParseException, JsonMappingException, IOException {
523         org.onap.so.serviceinstancebeans.LineOfBusiness lineOfBusiness =
524                 mapper.readValue(new File(RESOURCE_PATH + "RequestLineOfBusinessInput.json"),
525                         org.onap.so.serviceinstancebeans.LineOfBusiness.class);
526
527         LineOfBusiness expectedLineOfBusiness =
528                 mapper.readValue(new File(RESOURCE_PATH + "LineOfBusinessExpected.json"), LineOfBusiness.class);
529
530         LineOfBusiness actualLineOfBusiness = bbInputSetupMapperLayer.mapRequestLineOfBusiness(lineOfBusiness);
531
532         assertThat(actualLineOfBusiness, sameBeanAs(expectedLineOfBusiness));
533     }
534
535     @Test
536     public void testMapAAIConfiguration() throws JsonParseException, JsonMappingException, IOException {
537         org.onap.aai.domain.yang.Configuration configurationAAI = mapper.readValue(
538                 new File(RESOURCE_PATH + "ConfigurationInput.json"), org.onap.aai.domain.yang.Configuration.class);
539
540         Configuration expectedConfiguration =
541                 mapper.readValue(new File(RESOURCE_PATH + "ConfigurationExpected.json"), Configuration.class);
542
543         Configuration actualConfiguration = bbInputSetupMapperLayer.mapAAIConfiguration(configurationAAI);
544
545         assertThat(actualConfiguration, sameBeanAs(expectedConfiguration));
546     }
547
548     @Test
549     public void testMapRequestContext() throws IOException {
550         RequestContext expected =
551                 mapper.readValue(new File(RESOURCE_PATH + "RequestContextExpected.json"), RequestContext.class);
552
553         RequestDetails requestDetails = mapper
554                 .readValue(new File(RESOURCE_PATH + "RequestDetailsInput_mapReqContext.json"), RequestDetails.class);
555         RequestContext actual = bbInputSetupMapperLayer.mapRequestContext(requestDetails);
556
557         assertThat(actual, sameBeanAs(expected));
558     }
559
560     @Test
561     public void testMapOrchestrationContext() throws IOException {
562         OrchestrationContext expected = new OrchestrationContext();
563         expected.setIsRollbackEnabled(true);
564
565         RequestDetails requestDetails = mapper
566                 .readValue(new File(RESOURCE_PATH + "RequestDetailsInput_mapReqContext.json"), RequestDetails.class);
567
568         OrchestrationContext actual = bbInputSetupMapperLayer.mapOrchestrationContext(requestDetails);
569
570         assertThat(actual, sameBeanAs(expected));
571     }
572
573     @Test
574     public void testMapOrchestrationContextNoRequestInfo() throws IOException {
575         OrchestrationContext expected = new OrchestrationContext();
576         expected.setIsRollbackEnabled(false);
577
578         RequestDetails requestDetails = mapper.readValue(
579                 new File(RESOURCE_PATH + "RequestDetailsInput_mapReqContextNoRequestInfo.json"), RequestDetails.class);
580
581         OrchestrationContext actual = bbInputSetupMapperLayer.mapOrchestrationContext(requestDetails);
582
583         assertThat(actual, sameBeanAs(expected));
584     }
585
586     @Test
587     public void testMapLocationContext() {
588         CloudRegion expected = new CloudRegion();
589         expected.setCloudOwner("test-owner-name");
590         expected.setLcpCloudRegionId("cloudRegionId");
591         expected.setComplex("complexName");
592         expected.setTenantId("tenantId");
593         CloudConfiguration cloudConfig = new CloudConfiguration();
594         cloudConfig.setTenantId("tenantId");
595         cloudConfig.setLcpCloudRegionId("cloudRegionId");
596         cloudConfig.setAicNodeClli("aicNodeClli");
597         org.onap.aai.domain.yang.CloudRegion cloudRegion = new org.onap.aai.domain.yang.CloudRegion();
598         cloudRegion.setCloudOwner("test-owner-name");
599         cloudRegion.setCloudRegionId("cloudRegionId");
600         cloudRegion.setComplexName("complexName");
601
602         CloudRegion actual = bbInputSetupMapperLayer.mapCloudRegion(cloudConfig, cloudRegion);
603
604         assertThat(actual, sameBeanAs(expected));
605     }
606
607     @Test
608     public void testMapCloudRegion() {
609         CloudRegion expected = new CloudRegion();
610         expected.setCloudOwner("test-owner-name");
611         expected.setLcpCloudRegionId("cloudRegionId");
612         expected.setTenantId("tenantId");
613         expected.setCloudRegionVersion("cloudRegionVersion");
614
615         CloudConfiguration cloudConfig = new CloudConfiguration();
616         cloudConfig.setTenantId("tenantId");
617         cloudConfig.setLcpCloudRegionId("cloudRegionId");
618         cloudConfig.setAicNodeClli("aicNodeClli");
619
620         org.onap.aai.domain.yang.CloudRegion cloudRegion = new org.onap.aai.domain.yang.CloudRegion();
621         cloudRegion.setCloudOwner("test-owner-name");
622         cloudRegion.setCloudRegionId("cloudRegionId");
623         cloudRegion.setCloudRegionVersion("cloudRegionVersion");
624
625         CloudRegion actual = bbInputSetupMapperLayer.mapCloudRegion(cloudConfig, cloudRegion);
626
627         assertThat(actual, sameBeanAs(expected));
628     }
629
630     @Test
631     public void testMapTenant() {
632         Tenant expected = new Tenant();
633         expected.setTenantId("tenantId");
634         expected.setTenantName("tenantName");
635         expected.setTenantContext("tenantContext");
636
637         org.onap.aai.domain.yang.Tenant aaiTenant = new org.onap.aai.domain.yang.Tenant();
638         aaiTenant.setTenantId("tenantId");
639         aaiTenant.setTenantName("tenantName");
640         aaiTenant.setTenantContext("tenantContext");
641
642         Tenant actual = bbInputSetupMapperLayer.mapTenant(aaiTenant);
643
644         assertThat(actual, sameBeanAs(expected));
645     }
646
647     @Test
648     public void testMapCloudRegionWithNullCheck() {
649         CloudRegion expected = new CloudRegion();
650
651         CloudRegion actual = bbInputSetupMapperLayer.mapCloudRegion(null, null);
652
653         assertThat(actual, sameBeanAs(expected));
654     }
655
656     @Test
657     public void testmapCatalogConfigurationToConfiguration() {
658         String modelCustUUID = "modelCustomizationUUID";
659         String modelInvariantUUID = "modelInvariantUUID";
660         String modelVersionUUID = "modelUUID";
661         String policyName = "policyName";
662         ModelInfoConfiguration expected = new ModelInfoConfiguration();
663         expected.setModelCustomizationId(modelCustUUID);
664         expected.setModelInvariantId(modelInvariantUUID);
665         expected.setModelVersionId(modelVersionUUID);
666         expected.setPolicyName(policyName);
667         ConfigurationResourceCustomization configurationResourceCustomization =
668                 new ConfigurationResourceCustomization();
669         configurationResourceCustomization.setModelCustomizationUUID(modelCustUUID);
670         configurationResourceCustomization.setConfigurationResource(new ConfigurationResource());
671         configurationResourceCustomization.getConfigurationResource().setModelInvariantUUID(modelInvariantUUID);
672         configurationResourceCustomization.getConfigurationResource().setModelUUID(modelVersionUUID);
673         CvnfcConfigurationCustomization policyNameTable = new CvnfcConfigurationCustomization();
674         policyNameTable.setCvnfcCustomization(new CvnfcCustomization());
675         policyNameTable.getCvnfcCustomization().setVnfcCustomization(new VnfcCustomization());
676         policyNameTable.setPolicyName(policyName);
677
678         ModelInfoConfiguration actual = bbInputSetupMapperLayer
679                 .mapCatalogConfigurationToConfiguration(configurationResourceCustomization, policyNameTable);
680
681         assertThat(actual, sameBeanAs(expected));
682     }
683
684     @Test
685     public void testmapCatalogConfigurationToFabricConfiguration() {
686         String modelCustUUID = "modelCustomizationUUID";
687         String modelInvariantUUID = "modelInvariantUUID";
688         String modelVersionUUID = "modelUUID";
689         String policyName = "policyName";
690         ModelInfoConfiguration expected = new ModelInfoConfiguration();
691         expected.setModelCustomizationId(modelCustUUID);
692         expected.setModelInvariantId(modelInvariantUUID);
693         expected.setModelVersionId(modelVersionUUID);
694         expected.setPolicyName(policyName);
695
696         CvnfcConfigurationCustomization fabricCustomization = new CvnfcConfigurationCustomization();
697         fabricCustomization.setCvnfcCustomization(new CvnfcCustomization());
698         fabricCustomization.getCvnfcCustomization().setVnfcCustomization(new VnfcCustomization());
699         fabricCustomization.setPolicyName(policyName);
700         fabricCustomization.setModelCustomizationUUID(modelCustUUID);
701
702         ConfigurationResource configurationResource = new ConfigurationResource();
703         configurationResource.setModelUUID(modelVersionUUID);
704         configurationResource.setModelInvariantUUID(modelInvariantUUID);
705         fabricCustomization.setConfigurationResource(configurationResource);
706
707         ModelInfoConfiguration actual =
708                 bbInputSetupMapperLayer.mapCatalogConfigurationToConfiguration(fabricCustomization);
709
710         assertThat(actual, sameBeanAs(expected));
711     }
712
713     @Test
714     public void testMapNameValueUserParams() throws IOException {
715         RequestDetails requestDetails = mapper
716                 .readValue(new File(RESOURCE_PATH + "RequestDetailsInput_mapReqContext.json"), RequestDetails.class);
717         Map<String, Object> actual =
718                 bbInputSetupMapperLayer.mapNameValueUserParams(requestDetails.getRequestParameters());
719
720         assertTrue(actual.containsKey("mns_vfw_protected_route_prefixes"));
721         assertTrue(actual.get("mns_vfw_protected_route_prefixes").toString()
722                 .contains("interface_route_table_routes_route"));
723         assertTrue(actual.get("mns_vfw_protected_route_prefixes").toString().contains("1.1.1.1/32"));
724         assertTrue(actual.get("mns_vfw_protected_route_prefixes").toString().contains("0::1/128"));
725         assertTrue(actual.containsKey("name1"));
726         assertTrue(actual.containsValue("value1"));
727         assertTrue(actual.get("name1").equals("value1"));
728
729         assertFalse(actual.containsKey("ignore"));
730         assertFalse(actual.containsValue("ignore"));
731     }
732
733     @Test
734     public void testMapRequestParameters() throws IOException {
735         RequestDetails requestDetails = mapper
736                 .readValue(new File(RESOURCE_PATH + "RequestDetailsInput_mapReqContext.json"), RequestDetails.class);
737         RequestParameters actual = bbInputSetupMapperLayer.mapRequestParameters(requestDetails.getRequestParameters());
738
739         assertEquals(actual.getUsePreload(), requestDetails.getRequestParameters().getUsePreload());
740         assertEquals(actual.getSubscriptionServiceType(),
741                 requestDetails.getRequestParameters().getSubscriptionServiceType());
742         assertEquals(actual.getPayload(), requestDetails.getRequestParameters().getPayload());
743     }
744
745     protected RequestParameters mapRequestParameters(
746             org.onap.so.serviceinstancebeans.RequestParameters requestParameters) {
747         RequestParameters requestParams = new RequestParameters();
748         requestParams.setaLaCarte(requestParameters.getALaCarte());
749         requestParams.setUsePreload(requestParameters.getUsePreload());
750         requestParams.setSubscriptionServiceType(requestParameters.getSubscriptionServiceType());
751         requestParams.setUserParams(requestParameters.getUserParams());
752         requestParams.setPayload(requestParameters.getPayload());
753         return requestParams;
754     }
755
756 }