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