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