2 * ============LICENSE_START=======================================================
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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=========================================================
21 package org.onap.so.bpmn.servicedecomposition.tasks;
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;
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;
36 import org.junit.Test;
37 import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion;
38 import org.onap.so.bpmn.servicedecomposition.bbobjects.Collection;
39 import org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration;
40 import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer;
41 import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf;
42 import org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network;
43 import org.onap.so.bpmn.servicedecomposition.bbobjects.LineOfBusiness;
44 import org.onap.so.bpmn.servicedecomposition.bbobjects.NetworkPolicy;
45 import org.onap.so.bpmn.servicedecomposition.bbobjects.OwningEntity;
46 import org.onap.so.bpmn.servicedecomposition.bbobjects.Platform;
47 import org.onap.so.bpmn.servicedecomposition.bbobjects.Pnf;
48 import org.onap.so.bpmn.servicedecomposition.bbobjects.Project;
49 import org.onap.so.bpmn.servicedecomposition.bbobjects.RouteTableReference;
50 import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance;
51 import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceSubscription;
52 import org.onap.so.bpmn.servicedecomposition.bbobjects.Tenant;
53 import org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup;
54 import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey;
55 import org.onap.so.bpmn.servicedecomposition.generalobjects.OrchestrationContext;
56 import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext;
57 import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestParameters;
58 import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoCollection;
59 import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoConfiguration;
60 import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoGenericVnf;
61 import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoInstanceGroup;
62 import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoNetwork;
63 import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoServiceInstance;
64 import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoPnf;
65 import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoVfModule;
66 import org.onap.so.db.catalog.beans.CollectionNetworkResourceCustomization;
67 import org.onap.so.db.catalog.beans.CollectionResource;
68 import org.onap.so.db.catalog.beans.CollectionResourceCustomization;
69 import org.onap.so.db.catalog.beans.CollectionResourceInstanceGroupCustomization;
70 import org.onap.so.db.catalog.beans.ConfigurationResource;
71 import org.onap.so.db.catalog.beans.ConfigurationResourceCustomization;
72 import org.onap.so.db.catalog.beans.CvnfcConfigurationCustomization;
73 import org.onap.so.db.catalog.beans.CvnfcCustomization;
74 import org.onap.so.db.catalog.beans.InstanceGroup;
75 import org.onap.so.db.catalog.beans.NetworkResourceCustomization;
76 import org.onap.so.db.catalog.beans.OrchestrationStatus;
77 import org.onap.so.db.catalog.beans.Service;
78 import org.onap.so.db.catalog.beans.PnfResource;
79 import org.onap.so.db.catalog.beans.PnfResourceCustomization;
80 import org.onap.so.db.catalog.beans.VfModuleCustomization;
81 import org.onap.so.db.catalog.beans.VnfResourceCustomization;
82 import org.onap.so.db.catalog.beans.VnfcCustomization;
83 import org.onap.so.serviceinstancebeans.CloudConfiguration;
84 import org.onap.so.serviceinstancebeans.RequestDetails;
85 import com.fasterxml.jackson.core.JsonParseException;
86 import com.fasterxml.jackson.databind.DeserializationFeature;
87 import com.fasterxml.jackson.databind.JsonMappingException;
88 import com.fasterxml.jackson.databind.ObjectMapper;
90 public class BBInputSetupMapperLayerTest {
92 BBInputSetupMapperLayer bbInputSetupMapperLayer = new BBInputSetupMapperLayer();
94 ObjectMapper mapper = new ObjectMapper().configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
96 private static final String RESOURCE_PATH = "src/test/resources/__files/ExecuteBuildingBlock/";
100 public void testMapOrchestrationStatusFromAAI() {
101 OrchestrationStatus expected = OrchestrationStatus.INVENTORIED;
102 String orchStatusInput = "Inventoried";
103 OrchestrationStatus actual = bbInputSetupMapperLayer.mapOrchestrationStatusFromAAI(orchStatusInput);
104 assertThat(actual, sameBeanAs(expected));
106 expected = OrchestrationStatus.ASSIGNED;
107 orchStatusInput = "Assigned";
108 actual = bbInputSetupMapperLayer.mapOrchestrationStatusFromAAI(orchStatusInput);
109 assertThat(actual, sameBeanAs(expected));
111 expected = OrchestrationStatus.ACTIVE;
112 orchStatusInput = "Active";
113 actual = bbInputSetupMapperLayer.mapOrchestrationStatusFromAAI(orchStatusInput);
114 assertThat(actual, sameBeanAs(expected));
116 expected = OrchestrationStatus.CREATED;
117 orchStatusInput = "Created";
118 actual = bbInputSetupMapperLayer.mapOrchestrationStatusFromAAI(orchStatusInput);
119 assertThat(actual, sameBeanAs(expected));
121 expected = OrchestrationStatus.PRECREATED;
122 orchStatusInput = "PreCreated";
123 actual = bbInputSetupMapperLayer.mapOrchestrationStatusFromAAI(orchStatusInput);
124 assertThat(actual, sameBeanAs(expected));
126 expected = OrchestrationStatus.PENDING_CREATE;
127 orchStatusInput = "PendingCreate";
128 actual = bbInputSetupMapperLayer.mapOrchestrationStatusFromAAI(orchStatusInput);
129 assertThat(actual, sameBeanAs(expected));
131 expected = OrchestrationStatus.PENDING_DELETE;
132 orchStatusInput = "PendingDelete";
133 actual = bbInputSetupMapperLayer.mapOrchestrationStatusFromAAI(orchStatusInput);
134 assertThat(actual, sameBeanAs(expected));
136 expected = OrchestrationStatus.PENDING;
137 orchStatusInput = "Pending";
138 actual = bbInputSetupMapperLayer.mapOrchestrationStatusFromAAI(orchStatusInput);
139 assertThat(actual, sameBeanAs(expected));
141 expected = OrchestrationStatus.PENDING_ACTIVATION;
142 orchStatusInput = "PendingActivation";
143 actual = bbInputSetupMapperLayer.mapOrchestrationStatusFromAAI(orchStatusInput);
144 assertThat(actual, sameBeanAs(expected));
148 public void testMapOrchestrationFuzzyCases() {
149 List<String> values = Arrays.asList("pending-create", "pending_Create", "pendinggcreate", "PendingCreate");
150 values.forEach(value -> {
151 assertThat(bbInputSetupMapperLayer.mapOrchestrationStatusFromAAI(value),
152 equalTo(OrchestrationStatus.PENDING_CREATE));
157 public void testMapAAICustomer() throws IOException {
158 Customer expected = mapper.readValue(new File(RESOURCE_PATH + "Customer.json"), Customer.class);
160 org.onap.aai.domain.yang.Customer customerAAI = mapper.readValue(new File(RESOURCE_PATH + "Customer_AAI.json"),
161 org.onap.aai.domain.yang.Customer.class);
163 Customer actual = bbInputSetupMapperLayer.mapAAICustomer(customerAAI);
165 assertThat(actual, sameBeanAs(expected));
169 public void testMapAAIServiceSubscription() throws IOException {
170 ServiceSubscription expected = mapper.readValue(new File(RESOURCE_PATH + "ServiceSubscriptionExpected.json"),
171 ServiceSubscription.class);
173 org.onap.aai.domain.yang.ServiceSubscription svcSubscriptionAAI =
174 mapper.readValue(new File(RESOURCE_PATH + "ServiceSubscription_AAI.json"),
175 org.onap.aai.domain.yang.ServiceSubscription.class);
177 ServiceSubscription actual = bbInputSetupMapperLayer.mapAAIServiceSubscription(svcSubscriptionAAI);
179 assertThat(actual, sameBeanAs(expected));
183 public void testMapAAIProject() throws IOException {
184 Project expected = mapper.readValue(new File(RESOURCE_PATH + "Project.json"), Project.class);
186 org.onap.aai.domain.yang.Project projectAAI = new org.onap.aai.domain.yang.Project();
187 projectAAI.setProjectName("projectName");
189 Project actual = bbInputSetupMapperLayer.mapAAIProject(projectAAI);
191 assertThat(actual, sameBeanAs(expected));
195 public void testMapRequestProject() throws IOException {
196 Project expected = mapper.readValue(new File(RESOURCE_PATH + "Project.json"), Project.class);
198 org.onap.so.serviceinstancebeans.Project requestProject = new org.onap.so.serviceinstancebeans.Project();
199 requestProject.setProjectName("projectName");
201 Project actual = bbInputSetupMapperLayer.mapRequestProject(requestProject);
203 assertThat(actual, sameBeanAs(expected));
207 public void testMapAAIOwningEntity() throws IOException {
208 OwningEntity expected = mapper.readValue(new File(RESOURCE_PATH + "OwningEntity.json"), OwningEntity.class);
210 org.onap.aai.domain.yang.OwningEntity entityAAI = new org.onap.aai.domain.yang.OwningEntity();
211 entityAAI.setOwningEntityId("owningEntityId");
212 entityAAI.setOwningEntityName("owningEntityName");
214 OwningEntity actual = bbInputSetupMapperLayer.mapAAIOwningEntity(entityAAI);
216 assertThat(actual, sameBeanAs(expected));
220 public void testMapRequestOwningEntity() throws IOException {
221 OwningEntity expected = mapper.readValue(new File(RESOURCE_PATH + "OwningEntity.json"), OwningEntity.class);
223 org.onap.so.serviceinstancebeans.OwningEntity requestOwningEntity =
224 new org.onap.so.serviceinstancebeans.OwningEntity();
225 requestOwningEntity.setOwningEntityId("owningEntityId");
226 requestOwningEntity.setOwningEntityName("owningEntityName");
228 OwningEntity actual = bbInputSetupMapperLayer.mapRequestOwningEntity(requestOwningEntity);
230 assertThat(actual, sameBeanAs(expected));
234 public void testMapAAIPlatform() throws IOException {
235 Platform expected = mapper.readValue(new File(RESOURCE_PATH + "Platform.json"), Platform.class);
237 org.onap.aai.domain.yang.Platform platformAAI = new org.onap.aai.domain.yang.Platform();
238 platformAAI.setPlatformName("platformName");
240 Platform actual = bbInputSetupMapperLayer.mapAAIPlatform(platformAAI);
242 assertThat(actual, sameBeanAs(expected));
246 public void testMapAAILineOfBusiness() throws IOException {
247 LineOfBusiness expected =
248 mapper.readValue(new File(RESOURCE_PATH + "LineOfBusiness.json"), LineOfBusiness.class);
250 org.onap.aai.domain.yang.LineOfBusiness lobAAI = new org.onap.aai.domain.yang.LineOfBusiness();
251 lobAAI.setLineOfBusinessName("lineOfBusinessName");
253 LineOfBusiness actual = bbInputSetupMapperLayer.mapAAILineOfBusiness(lobAAI);
255 assertThat(actual, sameBeanAs(expected));
259 public void testMapAAINetworkPolicy() throws JsonParseException, JsonMappingException, IOException {
260 NetworkPolicy expectedNetworkPolicy =
261 mapper.readValue(new File(RESOURCE_PATH + "NetworkPolicy.json"), NetworkPolicy.class);
263 org.onap.aai.domain.yang.NetworkPolicy aaiNetworkPolicy = new org.onap.aai.domain.yang.NetworkPolicy();
264 aaiNetworkPolicy.setNetworkPolicyId("networkPolicyId");
265 aaiNetworkPolicy.setNetworkPolicyFqdn("networkPolicyFqdn");
266 aaiNetworkPolicy.setHeatStackId("heatStackId");
267 aaiNetworkPolicy.setResourceVersion("resourceVersion");
269 NetworkPolicy actualNetworkPolicy = bbInputSetupMapperLayer.mapAAINetworkPolicy(aaiNetworkPolicy);
271 assertThat(actualNetworkPolicy, sameBeanAs(expectedNetworkPolicy));
275 public void testMapAAIVolumeGroup() throws JsonParseException, JsonMappingException, IOException {
276 VolumeGroup expectedVolumeGroup =
277 mapper.readValue(new File(RESOURCE_PATH + "VolumeGroup.json"), VolumeGroup.class);
279 org.onap.aai.domain.yang.VolumeGroup aaiVolumeGroup = mapper.readValue(
280 new File(RESOURCE_PATH + "VolumeGroup_AAI.json"), org.onap.aai.domain.yang.VolumeGroup.class);
282 VolumeGroup actualVolumeGroup = bbInputSetupMapperLayer.mapAAIVolumeGroup(aaiVolumeGroup);
284 assertThat(actualVolumeGroup, sameBeanAs(expectedVolumeGroup));
288 public void testMapCatalogServiceIntoServiceInstance() throws IOException {
289 ModelInfoServiceInstance expected = mapper.readValue(new File(RESOURCE_PATH + "ModelInfoServiceInstance.json"),
290 ModelInfoServiceInstance.class);
292 Service catalogService = mapper.readValue(new File(RESOURCE_PATH + "CatalogServiceInput.json"), Service.class);
294 ModelInfoServiceInstance actual = bbInputSetupMapperLayer.mapCatalogServiceIntoServiceInstance(catalogService);
296 assertThat(actual, sameBeanAs(expected));
300 public void testMapCatalogInstanceGroupToInstanceGroup() throws IOException {
301 ModelInfoInstanceGroup expected =
302 mapper.readValue(new File(RESOURCE_PATH + "ModelInfoInstanceGroup.json"), ModelInfoInstanceGroup.class);
304 InstanceGroup instanceGroup =
305 mapper.readValue(new File(RESOURCE_PATH + "InstanceGroup.json"), InstanceGroup.class);
306 instanceGroup.setCollectionInstanceGroupCustomizations(new ArrayList<>());
307 CollectionResourceInstanceGroupCustomization collectionInstanceGroupCust =
308 new CollectionResourceInstanceGroupCustomization();
309 collectionInstanceGroupCust.setModelCustomizationUUID("modelCustomizationUUID");
310 collectionInstanceGroupCust.setFunction("function");
311 collectionInstanceGroupCust.setDescription("description");
312 instanceGroup.getCollectionInstanceGroupCustomizations().add(collectionInstanceGroupCust);
313 CollectionResourceCustomization collectionResourceCust = new CollectionResourceCustomization();
314 collectionResourceCust.setModelCustomizationUUID("modelCustomizationUUID");
315 ModelInfoInstanceGroup actual =
316 bbInputSetupMapperLayer.mapCatalogInstanceGroupToInstanceGroup(collectionResourceCust, instanceGroup);
318 assertThat(actual, sameBeanAs(expected));
322 public void testMapCollectionNetworkResourceCustToNetworkResourceCust() {
323 String modelCustomizationUUID = "modelCustomizationUUID";
324 String modelInstanceName = "modelInstanceName";
325 String networkRole = "networkRole";
326 String networkScope = "networkScope";
327 String networkTechnology = "networkTechnology";
328 String networkType = "networkType";
330 NetworkResourceCustomization expected = new NetworkResourceCustomization();
331 expected.setModelCustomizationUUID(modelCustomizationUUID);
332 expected.setModelInstanceName(modelInstanceName);
333 expected.setNetworkRole(networkRole);
334 expected.setNetworkScope(networkScope);
335 expected.setNetworkTechnology(networkTechnology);
336 expected.setNetworkType(networkType);
337 CollectionNetworkResourceCustomization collectionNetworkResourceCust =
338 new CollectionNetworkResourceCustomization();
339 collectionNetworkResourceCust.setModelCustomizationUUID(modelCustomizationUUID);
340 collectionNetworkResourceCust.setModelInstanceName(modelInstanceName);
341 collectionNetworkResourceCust.setNetworkRole(networkRole);
342 collectionNetworkResourceCust.setNetworkScope(networkScope);
343 collectionNetworkResourceCust.setNetworkTechnology(networkTechnology);
344 collectionNetworkResourceCust.setNetworkType(networkType);
345 NetworkResourceCustomization actual = bbInputSetupMapperLayer
346 .mapCollectionNetworkResourceCustToNetworkResourceCust(collectionNetworkResourceCust);
348 assertThat(actual, sameBeanAs(expected));
352 public void testMapCatalogCollectionToCollection() throws IOException {
353 ModelInfoCollection expected =
354 mapper.readValue(new File(RESOURCE_PATH + "ModelInfoCollection.json"), ModelInfoCollection.class);
356 CollectionResourceCustomization collectionCust =
357 mapper.readValue(new File(RESOURCE_PATH + "CollectionResourceCustomization.json"),
358 CollectionResourceCustomization.class);
360 CollectionResource collectionResource =
361 mapper.readValue(new File(RESOURCE_PATH + "CollectionResource.json"), CollectionResource.class);
363 ModelInfoCollection actual =
364 bbInputSetupMapperLayer.mapCatalogCollectionToCollection(collectionCust, collectionResource);
366 assertThat(actual, sameBeanAs(expected));
370 public void testMapAAIServiceInstanceIntoServiceInstance() throws IOException {
371 ServiceInstance expected = mapper.readValue(
372 new File(RESOURCE_PATH + "ServiceInstance_aaiServiceInstanceToSI.json"), ServiceInstance.class);
374 org.onap.aai.domain.yang.ServiceInstance serviceInstanceAAI =
375 mapper.readValue(new File(RESOURCE_PATH + "ServiceInstanceAAIInput.json"),
376 org.onap.aai.domain.yang.ServiceInstance.class);
378 ServiceInstance actual = bbInputSetupMapperLayer.mapAAIServiceInstanceIntoServiceInstance(serviceInstanceAAI);
380 assertThat(actual, sameBeanAs(expected));
384 public void testSetPlatformAndLOB() throws IOException {
385 ServiceInstance expected = mapper.readValue(
386 new File(RESOURCE_PATH + "ServiceInstance_aaiPlatformAndLOBToSI.json"), ServiceInstance.class);
388 Map<ResourceKey, String> resourcesToBeOrchestrated = new HashMap<>();
389 resourcesToBeOrchestrated.put(ResourceKey.GENERIC_VNF_ID, "vnfId");
390 Platform platformMSO = new Platform();
391 platformMSO.setPlatformName("platformName");
392 LineOfBusiness lineOfBusinessMSO = new LineOfBusiness();
393 lineOfBusinessMSO.setLineOfBusinessName("lineOfBusinessName");
395 ServiceInstance actual = mapper.readValue(
396 new File(RESOURCE_PATH + "ServiceInstanceAAIPlatformAndLOBInput.json"), ServiceInstance.class);
398 bbInputSetupMapperLayer.setPlatformAndLOBIntoServiceInstance(platformMSO, lineOfBusinessMSO, actual,
399 resourcesToBeOrchestrated);
401 assertThat(actual, sameBeanAs(expected));
405 public void testMapAAIL3NetworkIntoL3Network() throws IOException {
407 mapper.readValue(new File(RESOURCE_PATH + "l3NetworkExpectedWithSubnet.json"), L3Network.class);
409 org.onap.aai.domain.yang.L3Network aaiL3Network =
410 mapper.readValue(new File(RESOURCE_PATH + "aaiL3NetworkInputWithSubnets.json"),
411 org.onap.aai.domain.yang.L3Network.class);
413 L3Network actual = bbInputSetupMapperLayer.mapAAIL3Network(aaiL3Network);
415 assertThat(actual, sameBeanAs(expected));
419 public void testMapAAIGenericVnfIntoGenericVnf() throws IOException {
420 GenericVnf expected = mapper.readValue(new File(RESOURCE_PATH + "GenericVnfExpected.json"), GenericVnf.class);
421 org.onap.aai.domain.yang.GenericVnf aaiGenericVnf = mapper.readValue(
422 new File(RESOURCE_PATH + "aaiGenericVnfInput.json"), org.onap.aai.domain.yang.GenericVnf.class);
424 GenericVnf actual = bbInputSetupMapperLayer.mapAAIGenericVnfIntoGenericVnf(aaiGenericVnf);
426 assertThat(actual, sameBeanAs(expected));
430 public void testMapAAIPnfIntoPnf() throws IOException {
431 Pnf expected = mapper.readValue(new File(RESOURCE_PATH + "PnfExpected.json"), Pnf.class);
432 org.onap.aai.domain.yang.Pnf aaiPnf =
433 mapper.readValue(new File(RESOURCE_PATH + "aaiPnfInput.json"), org.onap.aai.domain.yang.Pnf.class);
435 Pnf actual = bbInputSetupMapperLayer.mapAAIPnfIntoPnf(aaiPnf);
437 assertThat(actual, sameBeanAs(expected));
441 public void testMapAAICollectionIntoCollection() throws JsonParseException, JsonMappingException, IOException {
442 org.onap.aai.domain.yang.Collection aaiCollection = mapper
443 .readValue(new File(RESOURCE_PATH + "CollectionInput.json"), org.onap.aai.domain.yang.Collection.class);
445 Collection expectedCollection =
446 mapper.readValue(new File(RESOURCE_PATH + "CollectionExpected.json"), Collection.class);
448 Collection actualCollection = bbInputSetupMapperLayer.mapAAICollectionIntoCollection(aaiCollection);
450 assertThat(actualCollection, sameBeanAs(expectedCollection));
454 public void testMapAAIInstanceGroupIntoInstanceGroup()
455 throws JsonParseException, JsonMappingException, IOException {
456 org.onap.aai.domain.yang.InstanceGroup aaiInstanceGroup = mapper.readValue(
457 new File(RESOURCE_PATH + "InstanceGroupInput.json"), org.onap.aai.domain.yang.InstanceGroup.class);
459 org.onap.so.bpmn.servicedecomposition.bbobjects.InstanceGroup expectedInstanceGroup =
460 mapper.readValue(new File(RESOURCE_PATH + "InstanceGroupExpected.json"),
461 org.onap.so.bpmn.servicedecomposition.bbobjects.InstanceGroup.class);
463 org.onap.so.bpmn.servicedecomposition.bbobjects.InstanceGroup actualInstanceGroup =
464 bbInputSetupMapperLayer.mapAAIInstanceGroupIntoInstanceGroup(aaiInstanceGroup);
466 assertThat(actualInstanceGroup, sameBeanAs(expectedInstanceGroup));
470 public void testMapAAIRouteTableReferenceIntoRouteTableReference()
471 throws JsonParseException, JsonMappingException, IOException {
472 org.onap.aai.domain.yang.RouteTableReference aaiRouteTableReference =
473 mapper.readValue(new File(RESOURCE_PATH + "RouteTableReferenceInput.json"),
474 org.onap.aai.domain.yang.RouteTableReference.class);
476 RouteTableReference expectedRouteTableReference = mapper
477 .readValue(new File(RESOURCE_PATH + "RouteTableReferenceExpected.json"), RouteTableReference.class);
479 RouteTableReference actualRouteTableReference =
480 bbInputSetupMapperLayer.mapAAIRouteTableReferenceIntoRouteTableReference(aaiRouteTableReference);
482 assertThat(actualRouteTableReference, sameBeanAs(expectedRouteTableReference));
486 public void testMapCatalogNetworkToNetwork() throws JsonParseException, JsonMappingException, IOException {
487 NetworkResourceCustomization networkResourceCustomization = mapper.readValue(
488 new File(RESOURCE_PATH + "NetworkResourceCustomizationInput.json"), NetworkResourceCustomization.class);
490 ModelInfoNetwork expectedModelInfoNetwork =
491 mapper.readValue(new File(RESOURCE_PATH + "ModelInfoNetworkExpected.json"), ModelInfoNetwork.class);
493 ModelInfoNetwork actualModelInfoNetwork =
494 bbInputSetupMapperLayer.mapCatalogNetworkToNetwork(networkResourceCustomization);
496 assertThat(actualModelInfoNetwork, sameBeanAs(expectedModelInfoNetwork));
500 public void testMapCatalogVnfToVnf() throws IOException {
501 VnfResourceCustomization vnfResourceCustomization = mapper.readValue(
502 new File(RESOURCE_PATH + "VnfResourceCustomizationInput.json"), VnfResourceCustomization.class);
504 ModelInfoGenericVnf expectedModelInfoGenericVnf = mapper
505 .readValue(new File(RESOURCE_PATH + "ModelInfoGenericVnfExpected.json"), ModelInfoGenericVnf.class);
507 ModelInfoGenericVnf actualModelInfoGenericVnf =
508 bbInputSetupMapperLayer.mapCatalogVnfToVnf(vnfResourceCustomization);
510 assertThat(actualModelInfoGenericVnf, sameBeanAs(expectedModelInfoGenericVnf));
514 public void testMapCatalogPnfToPnf() throws IOException {
515 PnfResourceCustomization pnfResourceCustomization = mapper.readValue(
516 new File(RESOURCE_PATH + "PnfResourceCustomizationInput.json"), PnfResourceCustomization.class);
518 PnfResource pnfResource = new PnfResource();
519 pnfResource.setModelUUID("modelUuid");
520 pnfResource.setModelInvariantUUID("modelInvariantUuid");
521 pnfResource.setModelVersion("modelVersion");
523 pnfResourceCustomization.setPnfResources(pnfResource);
525 ModelInfoPnf expectedModelInfoPnf =
526 mapper.readValue(new File(RESOURCE_PATH + "ModelInfoPnfExpected.json"), ModelInfoPnf.class);
528 ModelInfoPnf actualModelInfoPnf = bbInputSetupMapperLayer.mapCatalogPnfToPnf(pnfResourceCustomization);
530 assertThat(actualModelInfoPnf, sameBeanAs(expectedModelInfoPnf));
534 public void testMapCatalogVfModuleToVfModule() throws JsonParseException, JsonMappingException, IOException {
535 VfModuleCustomization vfResourceCustomization = mapper
536 .readValue(new File(RESOURCE_PATH + "VfModuleCustomizationInput.json"), VfModuleCustomization.class);
538 ModelInfoVfModule expectedModelInfoVfModule =
539 mapper.readValue(new File(RESOURCE_PATH + "ModelInfoVfModuleExpected.json"), ModelInfoVfModule.class);
541 ModelInfoVfModule actualModelInfoVfModule =
542 bbInputSetupMapperLayer.mapCatalogVfModuleToVfModule(vfResourceCustomization);
544 assertThat(actualModelInfoVfModule, sameBeanAs(expectedModelInfoVfModule));
548 public void testMapRequestPlatform() throws JsonParseException, JsonMappingException, IOException {
549 org.onap.so.serviceinstancebeans.Platform platform = mapper.readValue(
550 new File(RESOURCE_PATH + "RequestPlatformInput.json"), org.onap.so.serviceinstancebeans.Platform.class);
552 Platform expectedPlatform = mapper.readValue(new File(RESOURCE_PATH + "PlatformExpected.json"), Platform.class);
554 Platform actualPlatform = bbInputSetupMapperLayer.mapRequestPlatform(platform);
556 assertThat(actualPlatform, sameBeanAs(expectedPlatform));
560 public void testMapRequestLineOfBusiness() throws JsonParseException, JsonMappingException, IOException {
561 org.onap.so.serviceinstancebeans.LineOfBusiness lineOfBusiness =
562 mapper.readValue(new File(RESOURCE_PATH + "RequestLineOfBusinessInput.json"),
563 org.onap.so.serviceinstancebeans.LineOfBusiness.class);
565 LineOfBusiness expectedLineOfBusiness =
566 mapper.readValue(new File(RESOURCE_PATH + "LineOfBusinessExpected.json"), LineOfBusiness.class);
568 LineOfBusiness actualLineOfBusiness = bbInputSetupMapperLayer.mapRequestLineOfBusiness(lineOfBusiness);
570 assertThat(actualLineOfBusiness, sameBeanAs(expectedLineOfBusiness));
574 public void testMapAAIConfiguration() throws JsonParseException, JsonMappingException, IOException {
575 org.onap.aai.domain.yang.Configuration configurationAAI = mapper.readValue(
576 new File(RESOURCE_PATH + "ConfigurationInput.json"), org.onap.aai.domain.yang.Configuration.class);
578 Configuration expectedConfiguration =
579 mapper.readValue(new File(RESOURCE_PATH + "ConfigurationExpected.json"), Configuration.class);
581 Configuration actualConfiguration = bbInputSetupMapperLayer.mapAAIConfiguration(configurationAAI);
583 assertThat(actualConfiguration, sameBeanAs(expectedConfiguration));
587 public void testMapRequestContext() throws IOException {
588 RequestContext expected =
589 mapper.readValue(new File(RESOURCE_PATH + "RequestContextExpected.json"), RequestContext.class);
591 RequestDetails requestDetails = mapper
592 .readValue(new File(RESOURCE_PATH + "RequestDetailsInput_mapReqContext.json"), RequestDetails.class);
593 RequestContext actual = bbInputSetupMapperLayer.mapRequestContext(requestDetails);
595 assertThat(actual, sameBeanAs(expected));
599 public void testMapOrchestrationContext() throws IOException {
600 OrchestrationContext expected = new OrchestrationContext();
601 expected.setIsRollbackEnabled(true);
603 RequestDetails requestDetails = mapper
604 .readValue(new File(RESOURCE_PATH + "RequestDetailsInput_mapReqContext.json"), RequestDetails.class);
606 OrchestrationContext actual = bbInputSetupMapperLayer.mapOrchestrationContext(requestDetails);
608 assertThat(actual, sameBeanAs(expected));
612 public void testMapOrchestrationContextNoRequestInfo() throws IOException {
613 OrchestrationContext expected = new OrchestrationContext();
614 expected.setIsRollbackEnabled(false);
616 RequestDetails requestDetails = mapper.readValue(
617 new File(RESOURCE_PATH + "RequestDetailsInput_mapReqContextNoRequestInfo.json"), RequestDetails.class);
619 OrchestrationContext actual = bbInputSetupMapperLayer.mapOrchestrationContext(requestDetails);
621 assertThat(actual, sameBeanAs(expected));
625 public void testMapLocationContext() {
626 CloudRegion expected = new CloudRegion();
627 expected.setCloudOwner("test-owner-name");
628 expected.setLcpCloudRegionId("cloudRegionId");
629 expected.setComplex("complexName");
630 expected.setTenantId("tenantId");
631 CloudConfiguration cloudConfig = new CloudConfiguration();
632 cloudConfig.setTenantId("tenantId");
633 cloudConfig.setLcpCloudRegionId("cloudRegionId");
634 cloudConfig.setAicNodeClli("aicNodeClli");
635 org.onap.aai.domain.yang.CloudRegion cloudRegion = new org.onap.aai.domain.yang.CloudRegion();
636 cloudRegion.setCloudOwner("test-owner-name");
637 cloudRegion.setCloudRegionId("cloudRegionId");
638 cloudRegion.setComplexName("complexName");
640 CloudRegion actual = bbInputSetupMapperLayer.mapCloudRegion(cloudConfig, cloudRegion);
642 assertThat(actual, sameBeanAs(expected));
646 public void testMapCloudRegion() {
647 CloudRegion expected = new CloudRegion();
648 expected.setCloudOwner("test-owner-name");
649 expected.setLcpCloudRegionId("cloudRegionId");
650 expected.setTenantId("tenantId");
651 expected.setCloudRegionVersion("cloudRegionVersion");
653 CloudConfiguration cloudConfig = new CloudConfiguration();
654 cloudConfig.setTenantId("tenantId");
655 cloudConfig.setLcpCloudRegionId("cloudRegionId");
656 cloudConfig.setAicNodeClli("aicNodeClli");
658 org.onap.aai.domain.yang.CloudRegion cloudRegion = new org.onap.aai.domain.yang.CloudRegion();
659 cloudRegion.setCloudOwner("test-owner-name");
660 cloudRegion.setCloudRegionId("cloudRegionId");
661 cloudRegion.setCloudRegionVersion("cloudRegionVersion");
663 CloudRegion actual = bbInputSetupMapperLayer.mapCloudRegion(cloudConfig, cloudRegion);
665 assertThat(actual, sameBeanAs(expected));
669 public void testMapTenant() {
670 Tenant expected = new Tenant();
671 expected.setTenantId("tenantId");
672 expected.setTenantName("tenantName");
673 expected.setTenantContext("tenantContext");
675 org.onap.aai.domain.yang.Tenant aaiTenant = new org.onap.aai.domain.yang.Tenant();
676 aaiTenant.setTenantId("tenantId");
677 aaiTenant.setTenantName("tenantName");
678 aaiTenant.setTenantContext("tenantContext");
680 Tenant actual = bbInputSetupMapperLayer.mapTenant(aaiTenant);
682 assertThat(actual, sameBeanAs(expected));
686 public void testMapCloudRegionWithNullCheck() {
687 CloudRegion expected = new CloudRegion();
689 CloudRegion actual = bbInputSetupMapperLayer.mapCloudRegion(null, null);
691 assertThat(actual, sameBeanAs(expected));
695 public void testmapCatalogConfigurationToConfiguration() {
696 String modelCustUUID = "modelCustomizationUUID";
697 String modelInvariantUUID = "modelInvariantUUID";
698 String modelVersionUUID = "modelUUID";
699 String policyName = "policyName";
700 ModelInfoConfiguration expected = new ModelInfoConfiguration();
701 expected.setModelCustomizationId(modelCustUUID);
702 expected.setModelInvariantId(modelInvariantUUID);
703 expected.setModelVersionId(modelVersionUUID);
704 expected.setPolicyName(policyName);
705 ConfigurationResourceCustomization configurationResourceCustomization =
706 new ConfigurationResourceCustomization();
707 configurationResourceCustomization.setModelCustomizationUUID(modelCustUUID);
708 configurationResourceCustomization.setConfigurationResource(new ConfigurationResource());
709 configurationResourceCustomization.getConfigurationResource().setModelInvariantUUID(modelInvariantUUID);
710 configurationResourceCustomization.getConfigurationResource().setModelUUID(modelVersionUUID);
711 CvnfcConfigurationCustomization policyNameTable = new CvnfcConfigurationCustomization();
712 policyNameTable.setCvnfcCustomization(new CvnfcCustomization());
713 policyNameTable.getCvnfcCustomization().setVnfcCustomization(new VnfcCustomization());
714 policyNameTable.setPolicyName(policyName);
716 ModelInfoConfiguration actual = bbInputSetupMapperLayer
717 .mapCatalogConfigurationToConfiguration(configurationResourceCustomization, policyNameTable);
719 assertThat(actual, sameBeanAs(expected));
723 public void testmapCatalogConfigurationToFabricConfiguration() {
724 String modelCustUUID = "modelCustomizationUUID";
725 String modelInvariantUUID = "modelInvariantUUID";
726 String modelVersionUUID = "modelUUID";
727 String policyName = "policyName";
728 ModelInfoConfiguration expected = new ModelInfoConfiguration();
729 expected.setModelCustomizationId(modelCustUUID);
730 expected.setModelInvariantId(modelInvariantUUID);
731 expected.setModelVersionId(modelVersionUUID);
732 expected.setPolicyName(policyName);
734 CvnfcConfigurationCustomization fabricCustomization = new CvnfcConfigurationCustomization();
735 fabricCustomization.setCvnfcCustomization(new CvnfcCustomization());
736 fabricCustomization.getCvnfcCustomization().setVnfcCustomization(new VnfcCustomization());
737 fabricCustomization.setPolicyName(policyName);
738 fabricCustomization.setModelCustomizationUUID(modelCustUUID);
740 ConfigurationResource configurationResource = new ConfigurationResource();
741 configurationResource.setModelUUID(modelVersionUUID);
742 configurationResource.setModelInvariantUUID(modelInvariantUUID);
743 fabricCustomization.setConfigurationResource(configurationResource);
745 ModelInfoConfiguration actual =
746 bbInputSetupMapperLayer.mapCatalogConfigurationToConfiguration(fabricCustomization);
748 assertThat(actual, sameBeanAs(expected));
752 public void testMapNameValueUserParams() throws IOException {
753 RequestDetails requestDetails = mapper
754 .readValue(new File(RESOURCE_PATH + "RequestDetailsInput_mapReqContext.json"), RequestDetails.class);
755 Map<String, Object> actual =
756 bbInputSetupMapperLayer.mapNameValueUserParams(requestDetails.getRequestParameters());
758 assertTrue(actual.containsKey("mns_vfw_protected_route_prefixes"));
759 assertTrue(actual.get("mns_vfw_protected_route_prefixes").toString()
760 .contains("interface_route_table_routes_route"));
761 assertTrue(actual.get("mns_vfw_protected_route_prefixes").toString().contains("1.1.1.1/32"));
762 assertTrue(actual.get("mns_vfw_protected_route_prefixes").toString().contains("0::1/128"));
763 assertTrue(actual.containsKey("name1"));
764 assertTrue(actual.containsValue("value1"));
765 assertTrue(actual.get("name1").equals("value1"));
767 assertFalse(actual.containsKey("ignore"));
768 assertFalse(actual.containsValue("ignore"));
772 public void testMapRequestParameters() throws IOException {
773 RequestDetails requestDetails = mapper
774 .readValue(new File(RESOURCE_PATH + "RequestDetailsInput_mapReqContext.json"), RequestDetails.class);
775 RequestParameters actual = bbInputSetupMapperLayer.mapRequestParameters(requestDetails.getRequestParameters());
777 assertEquals(actual.getUsePreload(), requestDetails.getRequestParameters().getUsePreload());
778 assertEquals(actual.getSubscriptionServiceType(),
779 requestDetails.getRequestParameters().getSubscriptionServiceType());
780 assertEquals(actual.getPayload(), requestDetails.getRequestParameters().getPayload());
783 protected RequestParameters mapRequestParameters(
784 org.onap.so.serviceinstancebeans.RequestParameters requestParameters) {
785 RequestParameters requestParams = new RequestParameters();
786 requestParams.setaLaCarte(requestParameters.getALaCarte());
787 requestParams.setUsePreload(requestParameters.getUsePreload());
788 requestParams.setSubscriptionServiceType(requestParameters.getSubscriptionServiceType());
789 requestParams.setUserParams(requestParameters.getUserParams());
790 requestParams.setPayload(requestParameters.getPayload());
791 return requestParams;