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