fix catalogdb cvfnc customization
[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.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.VfModuleCustomization;
79 import org.onap.so.db.catalog.beans.VnfResourceCustomization;
80 import org.onap.so.db.catalog.beans.CvnfcConfigurationCustomization;
81 import org.onap.so.db.catalog.beans.VnfcCustomization;
82 import org.onap.so.serviceinstancebeans.CloudConfiguration;
83 import org.onap.so.serviceinstancebeans.RequestDetails;
84
85 import com.fasterxml.jackson.core.JsonParseException;
86 import com.fasterxml.jackson.databind.JsonMappingException;
87 import com.fasterxml.jackson.databind.ObjectMapper;
88
89 public class BBInputSetupMapperLayerTest {
90         
91         BBInputSetupMapperLayer bbInputSetupMapperLayer = new BBInputSetupMapperLayer();
92
93         ObjectMapper mapper = new ObjectMapper();
94
95         private static final String RESOURCE_PATH = "src/test/resources/__files/ExecuteBuildingBlock/";
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), equalTo(OrchestrationStatus.PENDING_CREATE));
150                 });
151         }
152         
153         @Test
154         public void testMapAAICustomer() throws IOException {
155                 Customer expected = mapper.readValue(
156                                 new File(RESOURCE_PATH+"Customer.json"),
157                                 Customer.class);
158
159                 org.onap.aai.domain.yang.Customer customerAAI = mapper.readValue(
160                                 new File(RESOURCE_PATH+"Customer_AAI.json"), org.onap.aai.domain.yang.Customer.class);
161                 
162                 Customer actual = bbInputSetupMapperLayer.mapAAICustomer(customerAAI);
163                 
164                 assertThat(actual, sameBeanAs(expected));
165         }
166
167         @Test
168         public void testMapAAIServiceSubscription() throws IOException {
169                 ServiceSubscription expected = mapper.readValue(
170                                 new File(RESOURCE_PATH + "ServiceSubscriptionExpected.json"), ServiceSubscription.class);
171
172                 org.onap.aai.domain.yang.ServiceSubscription svcSubscriptionAAI = mapper.readValue(
173                                 new File(RESOURCE_PATH + "ServiceSubscription_AAI.json"), 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 = new org.onap.so.serviceinstancebeans.OwningEntity();
222                 requestOwningEntity.setOwningEntityId("owningEntityId");
223                 requestOwningEntity.setOwningEntityName("owningEntityName");
224
225                 OwningEntity actual = bbInputSetupMapperLayer.mapRequestOwningEntity(requestOwningEntity);
226
227                 assertThat(actual, sameBeanAs(expected));
228         }
229
230         @Test
231         public void testMapAAIPlatform() throws IOException {
232                 Platform expected = mapper.readValue(new File(RESOURCE_PATH+"Platform.json"),Platform.class);
233
234                 org.onap.aai.domain.yang.Platform platformAAI = new org.onap.aai.domain.yang.Platform();
235                 platformAAI.setPlatformName("platformName");
236
237                 Platform actual = bbInputSetupMapperLayer.mapAAIPlatform(platformAAI);
238
239                 assertThat(actual, sameBeanAs(expected));
240         }
241
242         @Test
243         public void testMapAAILineOfBusiness() throws IOException {
244                 LineOfBusiness expected = mapper.readValue(new File(RESOURCE_PATH+"LineOfBusiness.json"),LineOfBusiness.class);
245
246                 org.onap.aai.domain.yang.LineOfBusiness lobAAI = new org.onap.aai.domain.yang.LineOfBusiness();
247                 lobAAI.setLineOfBusinessName("lineOfBusinessName");
248
249                 LineOfBusiness actual = bbInputSetupMapperLayer.mapAAILineOfBusiness(lobAAI);
250
251                 assertThat(actual, sameBeanAs(expected));
252         }
253         
254         @Test
255         public void testMapAAINetworkPolicy() throws JsonParseException, JsonMappingException, IOException {
256                 NetworkPolicy expectedNetworkPolicy = mapper.readValue(new File(RESOURCE_PATH + "NetworkPolicy.json"), NetworkPolicy.class);
257                 
258                 org.onap.aai.domain.yang.NetworkPolicy aaiNetworkPolicy = new org.onap.aai.domain.yang.NetworkPolicy();
259                 aaiNetworkPolicy.setNetworkPolicyId("networkPolicyId");
260                 aaiNetworkPolicy.setNetworkPolicyFqdn("networkPolicyFqdn");
261                 aaiNetworkPolicy.setHeatStackId("heatStackId");
262                 aaiNetworkPolicy.setResourceVersion("resourceVersion");
263                 
264                 NetworkPolicy actualNetworkPolicy = bbInputSetupMapperLayer.mapAAINetworkPolicy(aaiNetworkPolicy);
265                 
266                 assertThat(actualNetworkPolicy, sameBeanAs(expectedNetworkPolicy));
267         }
268         
269         @Test
270         public void testMapAAIVolumeGroup() throws JsonParseException, JsonMappingException, IOException {
271                 VolumeGroup expectedVolumeGroup = mapper.readValue(new File(RESOURCE_PATH + "VolumeGroup.json"), VolumeGroup.class);
272                 
273                 org.onap.aai.domain.yang.VolumeGroup aaiVolumeGroup = mapper.readValue(
274                                 new File(RESOURCE_PATH + "VolumeGroup_AAI.json"), org.onap.aai.domain.yang.VolumeGroup.class);
275                 
276                 VolumeGroup actualVolumeGroup = bbInputSetupMapperLayer.mapAAIVolumeGroup(aaiVolumeGroup);
277                 
278                 assertThat(actualVolumeGroup, sameBeanAs(expectedVolumeGroup));
279         }
280
281         @Test
282         public void testMapCatalogServiceIntoServiceInstance() throws IOException {
283                 ModelInfoServiceInstance expected = mapper.readValue(
284                                 new File(RESOURCE_PATH + "ModelInfoServiceInstance.json"),
285                                 ModelInfoServiceInstance.class);
286
287                 Service catalogService = mapper.readValue(
288                                 new File(RESOURCE_PATH + "CatalogServiceInput.json"), Service.class);
289
290                 ModelInfoServiceInstance actual = bbInputSetupMapperLayer.mapCatalogServiceIntoServiceInstance(catalogService);
291
292                 assertThat(actual, sameBeanAs(expected));
293         }
294
295         @Test
296         public void testMapCatalogInstanceGroupToInstanceGroup() throws IOException {
297                 ModelInfoInstanceGroup expected = mapper.readValue(
298                                 new File(RESOURCE_PATH + "ModelInfoInstanceGroup.json"),
299                                 ModelInfoInstanceGroup.class);
300
301                 InstanceGroup instanceGroup = mapper.readValue(
302                                 new File(RESOURCE_PATH + "InstanceGroup.json"), InstanceGroup.class);
303                 instanceGroup.setCollectionInstanceGroupCustomizations(new ArrayList<>());
304                 CollectionResourceInstanceGroupCustomization collectionInstanceGroupCust = new CollectionResourceInstanceGroupCustomization();
305                 collectionInstanceGroupCust.setModelCustomizationUUID("modelCustomizationUUID");
306                 collectionInstanceGroupCust.setFunction("function");
307                 collectionInstanceGroupCust.setDescription("description");
308                 instanceGroup.getCollectionInstanceGroupCustomizations().add(collectionInstanceGroupCust);
309                 CollectionResourceCustomization collectionResourceCust = new CollectionResourceCustomization();
310                 collectionResourceCust.setModelCustomizationUUID("modelCustomizationUUID");
311                 ModelInfoInstanceGroup actual = bbInputSetupMapperLayer.mapCatalogInstanceGroupToInstanceGroup(collectionResourceCust, instanceGroup);
312
313                 assertThat(actual, sameBeanAs(expected));
314         }
315         
316         @Test
317         public void testMapCollectionNetworkResourceCustToNetworkResourceCust() {
318                 String modelCustomizationUUID = "modelCustomizationUUID";
319                 String modelInstanceName = "modelInstanceName";
320                 String networkRole = "networkRole";
321                 String networkScope = "networkScope";
322                 String networkTechnology = "networkTechnology";
323                 String networkType = "networkType";
324                 
325                 NetworkResourceCustomization expected = new NetworkResourceCustomization();
326                 expected.setModelCustomizationUUID(modelCustomizationUUID);
327                 expected.setModelInstanceName(modelInstanceName);
328                 expected.setNetworkRole(networkRole);
329                 expected.setNetworkScope(networkScope);
330                 expected.setNetworkTechnology(networkTechnology);
331                 expected.setNetworkType(networkType);
332                 CollectionNetworkResourceCustomization collectionNetworkResourceCust = new CollectionNetworkResourceCustomization();
333                 collectionNetworkResourceCust.setModelCustomizationUUID(modelCustomizationUUID);
334                 collectionNetworkResourceCust.setModelInstanceName(modelInstanceName);
335                 collectionNetworkResourceCust.setNetworkRole(networkRole);
336                 collectionNetworkResourceCust.setNetworkScope(networkScope);
337                 collectionNetworkResourceCust.setNetworkTechnology(networkTechnology);
338                 collectionNetworkResourceCust.setNetworkType(networkType);
339                 NetworkResourceCustomization actual = bbInputSetupMapperLayer.mapCollectionNetworkResourceCustToNetworkResourceCust(collectionNetworkResourceCust);
340                 
341                 assertThat(actual, sameBeanAs(expected));
342         }
343
344         @Test
345         public void testMapCatalogCollectionToCollection() throws IOException {
346                 ModelInfoCollection expected = mapper.readValue(
347                                 new File(RESOURCE_PATH + "ModelInfoCollection.json"),
348                                 ModelInfoCollection.class);
349
350                 CollectionResourceCustomization collectionCust = mapper.readValue(
351                                 new File(RESOURCE_PATH + "CollectionResourceCustomization.json"),
352                                 CollectionResourceCustomization.class);
353
354                 CollectionResource collectionResource = mapper.readValue(
355                                 new File(RESOURCE_PATH + "CollectionResource.json"),
356                                 CollectionResource.class);
357
358                 ModelInfoCollection actual = bbInputSetupMapperLayer.mapCatalogCollectionToCollection(collectionCust, collectionResource);
359
360                 assertThat(actual, sameBeanAs(expected));
361         }
362
363         @Test
364         public void testMapAAIServiceInstanceIntoServiceInstance() throws IOException {
365                 ServiceInstance expected = mapper.readValue(
366                                 new File(RESOURCE_PATH + "ServiceInstance_aaiServiceInstanceToSI.json"),
367                                 ServiceInstance.class);
368
369                 org.onap.aai.domain.yang.ServiceInstance serviceInstanceAAI = mapper.readValue(
370                                 new File(RESOURCE_PATH + "ServiceInstanceAAIInput.json"),
371                                 org.onap.aai.domain.yang.ServiceInstance.class);
372
373                 ServiceInstance actual = bbInputSetupMapperLayer.mapAAIServiceInstanceIntoServiceInstance(serviceInstanceAAI);
374
375                 assertThat(actual, sameBeanAs(expected));
376         }
377
378         @Test
379         public void testSetPlatformAndLOB() throws IOException {
380                 ServiceInstance expected = mapper.readValue(
381                                 new File(RESOURCE_PATH + "ServiceInstance_aaiPlatformAndLOBToSI.json"),
382                                 ServiceInstance.class);
383
384                 Map<ResourceKey, String> resourcesToBeOrchestrated = new HashMap<>();
385                 resourcesToBeOrchestrated.put(ResourceKey.GENERIC_VNF_ID, "vnfId");
386                 Platform platformMSO = new Platform();
387                 platformMSO.setPlatformName("platformName");
388                 LineOfBusiness lineOfBusinessMSO = new LineOfBusiness();
389                 lineOfBusinessMSO.setLineOfBusinessName("lineOfBusinessName");
390
391                 ServiceInstance actual = mapper.readValue(
392                                 new File(RESOURCE_PATH + "ServiceInstanceAAIPlatformAndLOBInput.json"),
393                                 ServiceInstance.class);
394
395                 bbInputSetupMapperLayer.setPlatformAndLOBIntoServiceInstance(platformMSO, lineOfBusinessMSO, actual,
396                                 resourcesToBeOrchestrated);
397
398                 assertThat(actual, sameBeanAs(expected));
399         }
400
401         @Test
402         public void testMapAAIL3NetworkIntoL3Network() throws IOException {
403                 L3Network expected = mapper.readValue(
404                                 new File(RESOURCE_PATH + "l3NetworkExpected.json"), L3Network.class);
405
406                 org.onap.aai.domain.yang.L3Network aaiL3Network = mapper.readValue(
407                                 new File(RESOURCE_PATH + "aaiL3NetworkInput.json"),
408                                 org.onap.aai.domain.yang.L3Network.class);
409
410                 L3Network actual = bbInputSetupMapperLayer.mapAAIL3Network(aaiL3Network);
411
412                 assertThat(actual, sameBeanAs(expected));
413         }
414
415         @Test
416         public void testMapAAIGenericVnfIntoGenericVnf() throws IOException {
417                 GenericVnf expected = mapper.readValue(new File(RESOURCE_PATH + "GenericVnfExpected.json"), GenericVnf.class);
418                 org.onap.aai.domain.yang.GenericVnf aaiGenericVnf = mapper.readValue(
419                                 new File(RESOURCE_PATH + "aaiGenericVnfInput.json"), org.onap.aai.domain.yang.GenericVnf.class);
420                 
421                 GenericVnf actual = bbInputSetupMapperLayer.mapAAIGenericVnfIntoGenericVnf(aaiGenericVnf);
422
423                 assertThat(actual, sameBeanAs(expected));
424         }
425         
426         @Test
427         public void testMapAAICollectionIntoCollection() throws JsonParseException, JsonMappingException, IOException {
428                 org.onap.aai.domain.yang.Collection aaiCollection = mapper.readValue(
429                                 new File(RESOURCE_PATH + "CollectionInput.json"), org.onap.aai.domain.yang.Collection.class);
430                 
431                 Collection expectedCollection = mapper.readValue(new File(RESOURCE_PATH + "CollectionExpected.json"), Collection.class);
432                 
433                 Collection actualCollection = bbInputSetupMapperLayer.mapAAICollectionIntoCollection(aaiCollection);
434                 
435                 assertThat(actualCollection, sameBeanAs(expectedCollection));
436         }
437         
438         @Test
439         public void testMapAAIInstanceGroupIntoInstanceGroup() throws JsonParseException, JsonMappingException, IOException {
440                 org.onap.aai.domain.yang.InstanceGroup aaiInstanceGroup = mapper.readValue(
441                                 new File(RESOURCE_PATH + "InstanceGroupInput.json"), org.onap.aai.domain.yang.InstanceGroup.class);
442                 
443                 org.onap.so.bpmn.servicedecomposition.bbobjects.InstanceGroup expectedInstanceGroup = mapper.readValue(
444                                 new File(RESOURCE_PATH + "InstanceGroupExpected.json"), org.onap.so.bpmn.servicedecomposition.bbobjects.InstanceGroup.class);
445                 
446                 org.onap.so.bpmn.servicedecomposition.bbobjects.InstanceGroup actualInstanceGroup = 
447                                 bbInputSetupMapperLayer.mapAAIInstanceGroupIntoInstanceGroup(aaiInstanceGroup);
448                 
449                 assertThat(actualInstanceGroup, sameBeanAs(expectedInstanceGroup));
450         }
451         
452         @Test
453         public void testMapAAIRouteTableReferenceIntoRouteTableReference() throws JsonParseException, JsonMappingException, IOException {
454                 org.onap.aai.domain.yang.RouteTableReference aaiRouteTableReference = mapper.readValue(
455                                 new File(RESOURCE_PATH + "RouteTableReferenceInput.json"), org.onap.aai.domain.yang.RouteTableReference.class);
456                 
457                 RouteTableReference expectedRouteTableReference = mapper.readValue(
458                                 new File(RESOURCE_PATH + "RouteTableReferenceExpected.json"), RouteTableReference.class);
459                 
460                 RouteTableReference actualRouteTableReference = bbInputSetupMapperLayer.mapAAIRouteTableReferenceIntoRouteTableReference(aaiRouteTableReference);
461                 
462                 assertThat(actualRouteTableReference, sameBeanAs(expectedRouteTableReference));
463         }
464         
465         @Test
466         public void testMapCatalogNetworkToNetwork() throws JsonParseException, JsonMappingException, IOException {
467                 NetworkResourceCustomization networkResourceCustomization = mapper.readValue(
468                                 new File(RESOURCE_PATH + "NetworkResourceCustomizationInput.json"), NetworkResourceCustomization.class);
469                 
470                 ModelInfoNetwork expectedModelInfoNetwork = mapper.readValue(
471                                 new File(RESOURCE_PATH + "ModelInfoNetworkExpected.json"), ModelInfoNetwork.class);
472                 
473                 ModelInfoNetwork actualModelInfoNetwork = bbInputSetupMapperLayer.mapCatalogNetworkToNetwork(networkResourceCustomization);
474                 
475                 assertThat(actualModelInfoNetwork, sameBeanAs(expectedModelInfoNetwork));
476         }
477
478         @Test
479         public void testMapCatalogVnfToVnf() throws IOException {
480                 VnfResourceCustomization vnfResourceCustomization = mapper.readValue(
481                                 new File(RESOURCE_PATH + "VnfResourceCustomizationInput.json"), VnfResourceCustomization.class);
482                 
483                 ModelInfoGenericVnf expectedModelInfoGenericVnf = mapper.readValue(
484                                 new File(RESOURCE_PATH + "ModelInfoGenericVnfExpected.json"), ModelInfoGenericVnf.class);
485                 
486                 ModelInfoGenericVnf actualModelInfoGenericVnf = bbInputSetupMapperLayer.mapCatalogVnfToVnf(vnfResourceCustomization);
487                 
488                 assertThat(actualModelInfoGenericVnf, sameBeanAs(expectedModelInfoGenericVnf));
489         }
490         
491         @Test
492         public void testMapCatalogVfModuleToVfModule() throws JsonParseException, JsonMappingException, IOException {
493                 VfModuleCustomization vfResourceCustomization = mapper.readValue(
494                                 new File(RESOURCE_PATH + "VfModuleCustomizationInput.json"), VfModuleCustomization.class);
495                 
496                 ModelInfoVfModule expectedModelInfoVfModule = mapper.readValue(new File(RESOURCE_PATH + "ModelInfoVfModuleExpected.json"), ModelInfoVfModule.class);
497                 
498                 ModelInfoVfModule actualModelInfoVfModule = bbInputSetupMapperLayer.mapCatalogVfModuleToVfModule(vfResourceCustomization);
499                 
500                 assertThat(actualModelInfoVfModule, sameBeanAs(expectedModelInfoVfModule));
501         }
502         
503         @Test
504         public void testMapRequestPlatform() throws JsonParseException, JsonMappingException, IOException {
505                 org.onap.so.serviceinstancebeans.Platform platform = mapper.readValue(
506                                 new File(RESOURCE_PATH + "RequestPlatformInput.json"), org.onap.so.serviceinstancebeans.Platform.class);
507                 
508                 Platform expectedPlatform = mapper.readValue(new File(RESOURCE_PATH + "PlatformExpected.json"), Platform.class);
509                 
510                 Platform actualPlatform = bbInputSetupMapperLayer.mapRequestPlatform(platform);
511                 
512                 assertThat(actualPlatform, sameBeanAs(expectedPlatform));
513         }
514         
515         @Test
516         public void testMapRequestLineOfBusiness() throws JsonParseException, JsonMappingException, IOException {
517                 org.onap.so.serviceinstancebeans.LineOfBusiness lineOfBusiness = mapper.readValue(
518                                 new File(RESOURCE_PATH + "RequestLineOfBusinessInput.json"), org.onap.so.serviceinstancebeans.LineOfBusiness.class);
519                 
520                 LineOfBusiness expectedLineOfBusiness = mapper.readValue(new File(RESOURCE_PATH + "LineOfBusinessExpected.json"), LineOfBusiness.class);
521                 
522                 LineOfBusiness actualLineOfBusiness = bbInputSetupMapperLayer.mapRequestLineOfBusiness(lineOfBusiness);
523                 
524                 assertThat(actualLineOfBusiness, sameBeanAs(expectedLineOfBusiness));
525         }
526         
527         @Test
528         public void testMapAAIConfiguration() throws JsonParseException, JsonMappingException, IOException {
529                 org.onap.aai.domain.yang.Configuration configurationAAI = mapper.readValue(
530                                 new File(RESOURCE_PATH + "ConfigurationInput.json"), org.onap.aai.domain.yang.Configuration.class);
531                 
532                 Configuration expectedConfiguration = mapper.readValue(
533                                 new File(RESOURCE_PATH + "ConfigurationExpected.json"), Configuration.class);
534                 
535                 Configuration actualConfiguration = bbInputSetupMapperLayer.mapAAIConfiguration(configurationAAI);
536                 
537                 assertThat(actualConfiguration, sameBeanAs(expectedConfiguration));
538         }
539
540         @Test
541         public void testMapRequestContext() throws IOException {
542                 RequestContext expected = mapper.readValue(
543                                 new File(RESOURCE_PATH + "RequestContextExpected.json"),
544                                 RequestContext.class);
545
546                 RequestDetails requestDetails = mapper.readValue(
547                                 new File(RESOURCE_PATH + "RequestDetailsInput_mapReqContext.json"),
548                                 RequestDetails.class);
549                 RequestContext actual = bbInputSetupMapperLayer.mapRequestContext(requestDetails);
550
551                 assertThat(actual, sameBeanAs(expected));
552         }
553
554         @Test
555         public void testMapOrchestrationContext() throws IOException {
556                 OrchestrationContext expected = new OrchestrationContext();
557                 expected.setIsRollbackEnabled(true);
558
559                 RequestDetails requestDetails = mapper.readValue(new File(RESOURCE_PATH + "RequestDetailsInput_mapReqContext.json"), RequestDetails.class);
560
561                 OrchestrationContext actual = bbInputSetupMapperLayer.mapOrchestrationContext(requestDetails);
562
563                 assertThat(actual, sameBeanAs(expected));
564         }
565
566         @Test
567         public void testMapLocationContext() {
568                 CloudRegion expected = new CloudRegion();
569                 expected.setCloudOwner("test-owner-name");
570                 expected.setLcpCloudRegionId("cloudRegionId");
571                 expected.setComplex("complexName");
572                 expected.setTenantId("tenantId");
573                 CloudConfiguration cloudConfig = new CloudConfiguration();
574                 cloudConfig.setTenantId("tenantId");
575                 cloudConfig.setLcpCloudRegionId("cloudRegionId");
576                 cloudConfig.setAicNodeClli("aicNodeClli");
577                 org.onap.aai.domain.yang.CloudRegion cloudRegion = new org.onap.aai.domain.yang.CloudRegion();
578                 cloudRegion.setCloudOwner("test-owner-name");
579                 cloudRegion.setCloudRegionId("cloudRegionId");
580                 cloudRegion.setComplexName("complexName");
581
582                 CloudRegion actual = bbInputSetupMapperLayer.mapCloudRegion(cloudConfig, cloudRegion);
583
584                 assertThat(actual, sameBeanAs(expected));
585         }
586
587         @Test
588         public void testMapCloudRegion() {
589                 CloudRegion expected = new CloudRegion();
590                 expected.setCloudOwner("test-owner-name");
591                 expected.setLcpCloudRegionId("cloudRegionId");
592                 expected.setTenantId("tenantId");
593                 expected.setCloudRegionVersion("cloudRegionVersion");
594
595                 CloudConfiguration cloudConfig = new CloudConfiguration();
596                 cloudConfig.setTenantId("tenantId");
597                 cloudConfig.setLcpCloudRegionId("cloudRegionId");
598                 cloudConfig.setAicNodeClli("aicNodeClli");
599
600                 org.onap.aai.domain.yang.CloudRegion cloudRegion = new org.onap.aai.domain.yang.CloudRegion();
601                 cloudRegion.setCloudOwner("test-owner-name");
602                 cloudRegion.setCloudRegionId("cloudRegionId");
603                 cloudRegion.setCloudRegionVersion("cloudRegionVersion");
604
605                 CloudRegion actual = bbInputSetupMapperLayer.mapCloudRegion(cloudConfig, cloudRegion);
606
607                 assertThat(actual, sameBeanAs(expected));
608         }
609         
610         @Test
611         public void testMapTenant() {
612                 Tenant expected = new Tenant();
613                 expected.setTenantId("tenantId");
614                 expected.setTenantName("tenantName");
615                 expected.setTenantContext("tenantContext");
616
617                 org.onap.aai.domain.yang.Tenant aaiTenant = new org.onap.aai.domain.yang.Tenant();
618                 aaiTenant.setTenantId("tenantId");
619                 aaiTenant.setTenantName("tenantName");
620                 aaiTenant.setTenantContext("tenantContext");
621
622                 Tenant actual = bbInputSetupMapperLayer.mapTenant(aaiTenant);
623
624                 assertThat(actual, sameBeanAs(expected));
625         }
626
627         @Test
628         public void testMapCloudRegionWithNullCheck() {
629                 CloudRegion expected = new CloudRegion();
630
631                 CloudRegion actual = bbInputSetupMapperLayer.mapCloudRegion(null, null);
632
633                 assertThat(actual, sameBeanAs(expected));
634         }
635         
636         @Test
637         public void testmapCatalogConfigurationToConfiguration() {
638                 String modelCustUUID = "modelCustomizationUUID";
639                 String modelInvariantUUID = "modelInvariantUUID";
640                 String modelVersionUUID = "modelUUID";
641                 String policyName = "policyName";
642                 ModelInfoConfiguration expected = new ModelInfoConfiguration();
643                 expected.setModelCustomizationId(modelCustUUID);
644                 expected.setModelInvariantId(modelInvariantUUID);
645                 expected.setModelVersionId(modelVersionUUID);
646                 expected.setPolicyName(policyName);
647                 ConfigurationResourceCustomization configurationResourceCustomization = new ConfigurationResourceCustomization();
648                 configurationResourceCustomization.setModelCustomizationUUID(modelCustUUID);
649                 configurationResourceCustomization.setConfigurationResource(new ConfigurationResource());
650                 configurationResourceCustomization.getConfigurationResource().setModelInvariantUUID(modelInvariantUUID);
651                 configurationResourceCustomization.getConfigurationResource().setModelUUID(modelVersionUUID);
652                 CvnfcConfigurationCustomization policyNameTable = new CvnfcConfigurationCustomization();
653                 policyNameTable.setCvnfcCustomization(new CvnfcCustomization());
654                 policyNameTable.getCvnfcCustomization().setVnfcCustomization(new VnfcCustomization());
655                 policyNameTable.setPolicyName(policyName);
656                 
657                 ModelInfoConfiguration actual = bbInputSetupMapperLayer.mapCatalogConfigurationToConfiguration(configurationResourceCustomization, policyNameTable);
658
659                 assertThat(actual, sameBeanAs(expected));
660         }
661         
662         @Test
663         public void testmapCatalogConfigurationToFabricConfiguration() {
664                 String modelCustUUID = "modelCustomizationUUID";
665                 String modelInvariantUUID = "modelInvariantUUID";
666                 String modelVersionUUID = "modelUUID";
667                 String policyName = "policyName";
668                 ModelInfoConfiguration expected = new ModelInfoConfiguration();
669                 expected.setModelCustomizationId(modelCustUUID);
670                 expected.setModelInvariantId(modelInvariantUUID);
671                 expected.setModelVersionId(modelVersionUUID);
672                 expected.setPolicyName(policyName);
673
674                 CvnfcConfigurationCustomization fabricCustomization = new CvnfcConfigurationCustomization();
675                 fabricCustomization.setCvnfcCustomization(new CvnfcCustomization());
676                 fabricCustomization.getCvnfcCustomization().setVnfcCustomization(new VnfcCustomization());
677                 fabricCustomization.setPolicyName(policyName);
678                 fabricCustomization.setModelCustomizationUUID(modelCustUUID);
679
680                 ConfigurationResource configurationResource = new ConfigurationResource();
681                 configurationResource.setModelUUID(modelVersionUUID);
682                 configurationResource.setModelInvariantUUID(modelInvariantUUID);
683                 fabricCustomization.setConfigurationResource(configurationResource);
684                 
685                 ModelInfoConfiguration actual = bbInputSetupMapperLayer.mapCatalogConfigurationToConfiguration(fabricCustomization);
686
687                 assertThat(actual, sameBeanAs(expected));
688         }
689         
690         @Test
691         public void testMapNameValueUserParams() throws IOException {           
692                 RequestDetails requestDetails = mapper.readValue(new File(RESOURCE_PATH + "RequestDetailsInput_mapReqContext.json"), RequestDetails.class);
693                 Map<String,Object> actual = bbInputSetupMapperLayer.mapNameValueUserParams(requestDetails.getRequestParameters());              
694
695                 assertTrue(actual.containsKey("mns_vfw_protected_route_prefixes"));
696                 assertTrue(actual.get("mns_vfw_protected_route_prefixes").toString().contains("interface_route_table_routes_route"));
697                 assertTrue(actual.get("mns_vfw_protected_route_prefixes").toString().contains("1.1.1.1/32"));
698                 assertTrue(actual.get("mns_vfw_protected_route_prefixes").toString().contains("0::1/128"));
699                 assertTrue(actual.containsKey("name1"));
700                 assertTrue(actual.containsValue("value1"));
701                 assertTrue(actual.get("name1").equals("value1"));
702                                 
703                 assertFalse(actual.containsKey("ignore"));
704                 assertFalse(actual.containsValue("ignore"));            
705         }
706         
707         @Test
708         public void testMapRequestParameters() throws IOException {             
709                 RequestDetails requestDetails = mapper.readValue(new File(RESOURCE_PATH + "RequestDetailsInput_mapReqContext.json"), RequestDetails.class);
710                 RequestParameters actual = bbInputSetupMapperLayer.mapRequestParameters(requestDetails.getRequestParameters());
711                 
712                 assertEquals(actual.getUsePreload(), requestDetails.getRequestParameters().getUsePreload());
713                 assertEquals(actual.getSubscriptionServiceType(), requestDetails.getRequestParameters().getSubscriptionServiceType());
714                 assertEquals(actual.getPayload(), requestDetails.getRequestParameters().getPayload());                          
715         }
716         
717         protected RequestParameters mapRequestParameters(org.onap.so.serviceinstancebeans.RequestParameters requestParameters) {
718                 RequestParameters requestParams = new RequestParameters();
719                 requestParams.setaLaCarte(requestParameters.getALaCarte());
720                 requestParams.setUsePreload(requestParameters.getUsePreload());
721                 requestParams.setSubscriptionServiceType(requestParameters.getSubscriptionServiceType());
722                 requestParams.setUserParams(requestParameters.getUserParams());
723                 requestParams.setPayload(requestParameters.getPayload());
724                 return requestParams;
725         }
726         
727 }