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