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