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;
28 import java.io.IOException;
29 import java.util.ArrayList;
30 import java.util.Arrays;
31 import java.util.HashMap;
32 import java.util.List;
35 import org.junit.Test;
36 import org.mockito.InjectMocks;
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.Project;
48 import org.onap.so.bpmn.servicedecomposition.bbobjects.RouteTableReference;
49 import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance;
50 import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceSubscription;
51 import org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup;
52 import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey;
53 import org.onap.so.bpmn.servicedecomposition.generalobjects.OrchestrationContext;
54 import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext;
55 import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoCollection;
56 import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoConfiguration;
57 import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoGenericVnf;
58 import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoInstanceGroup;
59 import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoNetwork;
60 import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoServiceInstance;
61 import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoVfModule;
62 import org.onap.so.db.catalog.beans.CollectionNetworkResourceCustomization;
63 import org.onap.so.db.catalog.beans.CollectionResource;
64 import org.onap.so.db.catalog.beans.CollectionResourceCustomization;
65 import org.onap.so.db.catalog.beans.CollectionResourceInstanceGroupCustomization;
66 import org.onap.so.db.catalog.beans.ConfigurationResource;
67 import org.onap.so.db.catalog.beans.ConfigurationResourceCustomization;
68 import org.onap.so.db.catalog.beans.CvnfcCustomization;
69 import org.onap.so.db.catalog.beans.InstanceGroup;
70 import org.onap.so.db.catalog.beans.NetworkResourceCustomization;
71 import org.onap.so.db.catalog.beans.OrchestrationStatus;
72 import org.onap.so.db.catalog.beans.Service;
73 import org.onap.so.db.catalog.beans.VfModuleCustomization;
74 import org.onap.so.db.catalog.beans.VnfResourceCustomization;
75 import org.onap.so.db.catalog.beans.VnfVfmoduleCvnfcConfigurationCustomization;
76 import org.onap.so.db.catalog.beans.VnfcCustomization;
77 import org.onap.so.serviceinstancebeans.CloudConfiguration;
78 import org.onap.so.serviceinstancebeans.RequestDetails;
80 import com.fasterxml.jackson.core.JsonParseException;
81 import com.fasterxml.jackson.databind.JsonMappingException;
82 import com.fasterxml.jackson.databind.ObjectMapper;
84 public class BBInputSetupMapperLayerTest {
86 BBInputSetupMapperLayer bbInputSetupMapperLayer = new BBInputSetupMapperLayer();
88 ObjectMapper mapper = new ObjectMapper();
90 private static final String RESOURCE_PATH = "src/test/resources/__files/ExecuteBuildingBlock/";
93 public void testMapOrchestrationStatusFromAAI() {
94 OrchestrationStatus expected = OrchestrationStatus.INVENTORIED;
95 String orchStatusInput = "Inventoried";
96 OrchestrationStatus actual = bbInputSetupMapperLayer.mapOrchestrationStatusFromAAI(orchStatusInput);
97 assertThat(actual, sameBeanAs(expected));
99 expected = OrchestrationStatus.ASSIGNED;
100 orchStatusInput = "Assigned";
101 actual = bbInputSetupMapperLayer.mapOrchestrationStatusFromAAI(orchStatusInput);
102 assertThat(actual, sameBeanAs(expected));
104 expected = OrchestrationStatus.ACTIVE;
105 orchStatusInput = "Active";
106 actual = bbInputSetupMapperLayer.mapOrchestrationStatusFromAAI(orchStatusInput);
107 assertThat(actual, sameBeanAs(expected));
109 expected = OrchestrationStatus.CREATED;
110 orchStatusInput = "Created";
111 actual = bbInputSetupMapperLayer.mapOrchestrationStatusFromAAI(orchStatusInput);
112 assertThat(actual, sameBeanAs(expected));
114 expected = OrchestrationStatus.PRECREATED;
115 orchStatusInput = "PreCreated";
116 actual = bbInputSetupMapperLayer.mapOrchestrationStatusFromAAI(orchStatusInput);
117 assertThat(actual, sameBeanAs(expected));
119 expected = OrchestrationStatus.PENDING_CREATE;
120 orchStatusInput = "PendingCreate";
121 actual = bbInputSetupMapperLayer.mapOrchestrationStatusFromAAI(orchStatusInput);
122 assertThat(actual, sameBeanAs(expected));
124 expected = OrchestrationStatus.PENDING_DELETE;
125 orchStatusInput = "PendingDelete";
126 actual = bbInputSetupMapperLayer.mapOrchestrationStatusFromAAI(orchStatusInput);
127 assertThat(actual, sameBeanAs(expected));
129 expected = OrchestrationStatus.PENDING;
130 orchStatusInput = "Pending";
131 actual = bbInputSetupMapperLayer.mapOrchestrationStatusFromAAI(orchStatusInput);
132 assertThat(actual, sameBeanAs(expected));
134 expected = OrchestrationStatus.PENDING_ACTIVATION;
135 orchStatusInput = "PendingActivation";
136 actual = bbInputSetupMapperLayer.mapOrchestrationStatusFromAAI(orchStatusInput);
137 assertThat(actual, sameBeanAs(expected));
141 public void testMapOrchestrationFuzzyCases() {
142 List<String> values = Arrays.asList("pending-create", "pending_Create", "pendinggcreate", "PendingCreate");
143 values.forEach(value -> {
144 assertThat(bbInputSetupMapperLayer.mapOrchestrationStatusFromAAI(value), equalTo(OrchestrationStatus.PENDING_CREATE));
149 public void testMapAAICustomer() throws IOException {
150 Customer expected = mapper.readValue(
151 new File(RESOURCE_PATH+"Customer.json"),
154 org.onap.aai.domain.yang.Customer customerAAI = mapper.readValue(
155 new File(RESOURCE_PATH+"Customer_AAI.json"), org.onap.aai.domain.yang.Customer.class);
157 Customer actual = bbInputSetupMapperLayer.mapAAICustomer(customerAAI);
159 assertThat(actual, sameBeanAs(expected));
163 public void testMapAAIServiceSubscription() throws IOException {
164 ServiceSubscription expected = mapper.readValue(
165 new File(RESOURCE_PATH + "ServiceSubscriptionExpected.json"), ServiceSubscription.class);
167 org.onap.aai.domain.yang.ServiceSubscription svcSubscriptionAAI = mapper.readValue(
168 new File(RESOURCE_PATH + "ServiceSubscription_AAI.json"), org.onap.aai.domain.yang.ServiceSubscription.class);
170 ServiceSubscription actual = bbInputSetupMapperLayer.mapAAIServiceSubscription(svcSubscriptionAAI);
172 assertThat(actual, sameBeanAs(expected));
176 public void testMapAAIProject() throws IOException {
177 Project expected = mapper.readValue(new File(RESOURCE_PATH+"Project.json"),Project.class);
179 org.onap.aai.domain.yang.Project projectAAI = new org.onap.aai.domain.yang.Project();
180 projectAAI.setProjectName("projectName");
182 Project actual = bbInputSetupMapperLayer.mapAAIProject(projectAAI);
184 assertThat(actual, sameBeanAs(expected));
188 public void testMapRequestProject() throws IOException {
189 Project expected = mapper.readValue(new File(RESOURCE_PATH+"Project.json"),Project.class);
191 org.onap.so.serviceinstancebeans.Project requestProject = new org.onap.so.serviceinstancebeans.Project();
192 requestProject.setProjectName("projectName");
194 Project actual = bbInputSetupMapperLayer.mapRequestProject(requestProject);
196 assertThat(actual, sameBeanAs(expected));
200 public void testMapAAIOwningEntity() throws IOException {
201 OwningEntity expected = mapper.readValue(new File(RESOURCE_PATH+"OwningEntity.json"),OwningEntity.class);
203 org.onap.aai.domain.yang.OwningEntity entityAAI = new org.onap.aai.domain.yang.OwningEntity();
204 entityAAI.setOwningEntityId("owningEntityId");
205 entityAAI.setOwningEntityName("owningEntityName");
207 OwningEntity actual = bbInputSetupMapperLayer.mapAAIOwningEntity(entityAAI);
209 assertThat(actual, sameBeanAs(expected));
213 public void testMapRequestOwningEntity() throws IOException {
214 OwningEntity expected = mapper.readValue(new File(RESOURCE_PATH+"OwningEntity.json"),OwningEntity.class);
216 org.onap.so.serviceinstancebeans.OwningEntity requestOwningEntity = new org.onap.so.serviceinstancebeans.OwningEntity();
217 requestOwningEntity.setOwningEntityId("owningEntityId");
218 requestOwningEntity.setOwningEntityName("owningEntityName");
220 OwningEntity actual = bbInputSetupMapperLayer.mapRequestOwningEntity(requestOwningEntity);
222 assertThat(actual, sameBeanAs(expected));
226 public void testMapAAIPlatform() throws IOException {
227 Platform expected = mapper.readValue(new File(RESOURCE_PATH+"Platform.json"),Platform.class);
229 org.onap.aai.domain.yang.Platform platformAAI = new org.onap.aai.domain.yang.Platform();
230 platformAAI.setPlatformName("platformName");
232 Platform actual = bbInputSetupMapperLayer.mapAAIPlatform(platformAAI);
234 assertThat(actual, sameBeanAs(expected));
238 public void testMapAAILineOfBusiness() throws IOException {
239 LineOfBusiness expected = mapper.readValue(new File(RESOURCE_PATH+"LineOfBusiness.json"),LineOfBusiness.class);
241 org.onap.aai.domain.yang.LineOfBusiness lobAAI = new org.onap.aai.domain.yang.LineOfBusiness();
242 lobAAI.setLineOfBusinessName("lineOfBusinessName");
244 LineOfBusiness actual = bbInputSetupMapperLayer.mapAAILineOfBusiness(lobAAI);
246 assertThat(actual, sameBeanAs(expected));
250 public void testMapAAINetworkPolicy() throws JsonParseException, JsonMappingException, IOException {
251 NetworkPolicy expectedNetworkPolicy = mapper.readValue(new File(RESOURCE_PATH + "NetworkPolicy.json"), NetworkPolicy.class);
253 org.onap.aai.domain.yang.NetworkPolicy aaiNetworkPolicy = new org.onap.aai.domain.yang.NetworkPolicy();
254 aaiNetworkPolicy.setNetworkPolicyId("networkPolicyId");
255 aaiNetworkPolicy.setNetworkPolicyFqdn("networkPolicyFqdn");
256 aaiNetworkPolicy.setHeatStackId("heatStackId");
257 aaiNetworkPolicy.setResourceVersion("resourceVersion");
259 NetworkPolicy actualNetworkPolicy = bbInputSetupMapperLayer.mapAAINetworkPolicy(aaiNetworkPolicy);
261 assertThat(actualNetworkPolicy, sameBeanAs(expectedNetworkPolicy));
265 public void testMapAAIVolumeGroup() throws JsonParseException, JsonMappingException, IOException {
266 VolumeGroup expectedVolumeGroup = mapper.readValue(new File(RESOURCE_PATH + "VolumeGroup.json"), VolumeGroup.class);
268 org.onap.aai.domain.yang.VolumeGroup aaiVolumeGroup = mapper.readValue(
269 new File(RESOURCE_PATH + "VolumeGroup_AAI.json"), org.onap.aai.domain.yang.VolumeGroup.class);
271 VolumeGroup actualVolumeGroup = bbInputSetupMapperLayer.mapAAIVolumeGroup(aaiVolumeGroup);
273 assertThat(actualVolumeGroup, sameBeanAs(expectedVolumeGroup));
277 public void testMapCatalogServiceIntoServiceInstance() throws IOException {
278 ModelInfoServiceInstance expected = mapper.readValue(
279 new File(RESOURCE_PATH + "ModelInfoServiceInstance.json"),
280 ModelInfoServiceInstance.class);
282 Service catalogService = mapper.readValue(
283 new File(RESOURCE_PATH + "CatalogServiceInput.json"), Service.class);
285 ModelInfoServiceInstance actual = bbInputSetupMapperLayer.mapCatalogServiceIntoServiceInstance(catalogService);
287 assertThat(actual, sameBeanAs(expected));
291 public void testMapCatalogInstanceGroupToInstanceGroup() throws IOException {
292 ModelInfoInstanceGroup expected = mapper.readValue(
293 new File(RESOURCE_PATH + "ModelInfoInstanceGroup.json"),
294 ModelInfoInstanceGroup.class);
296 InstanceGroup instanceGroup = mapper.readValue(
297 new File(RESOURCE_PATH + "InstanceGroup.json"), InstanceGroup.class);
298 instanceGroup.setCollectionInstanceGroupCustomizations(new ArrayList<>());
299 CollectionResourceInstanceGroupCustomization collectionInstanceGroupCust = new CollectionResourceInstanceGroupCustomization();
300 collectionInstanceGroupCust.setModelCustomizationUUID("modelCustomizationUUID");
301 collectionInstanceGroupCust.setFunction("function");
302 collectionInstanceGroupCust.setDescription("description");
303 instanceGroup.getCollectionInstanceGroupCustomizations().add(collectionInstanceGroupCust);
304 CollectionResourceCustomization collectionResourceCust = new CollectionResourceCustomization();
305 collectionResourceCust.setModelCustomizationUUID("modelCustomizationUUID");
306 ModelInfoInstanceGroup actual = bbInputSetupMapperLayer.mapCatalogInstanceGroupToInstanceGroup(collectionResourceCust, instanceGroup);
308 assertThat(actual, sameBeanAs(expected));
312 public void testMapCollectionNetworkResourceCustToNetworkResourceCust() {
313 String modelCustomizationUUID = "modelCustomizationUUID";
314 String modelInstanceName = "modelInstanceName";
315 String networkRole = "networkRole";
316 String networkScope = "networkScope";
317 String networkTechnology = "networkTechnology";
318 String networkType = "networkType";
320 NetworkResourceCustomization expected = new NetworkResourceCustomization();
321 expected.setModelCustomizationUUID(modelCustomizationUUID);
322 expected.setModelInstanceName(modelInstanceName);
323 expected.setNetworkRole(networkRole);
324 expected.setNetworkScope(networkScope);
325 expected.setNetworkTechnology(networkTechnology);
326 expected.setNetworkType(networkType);
327 CollectionNetworkResourceCustomization collectionNetworkResourceCust = new CollectionNetworkResourceCustomization();
328 collectionNetworkResourceCust.setModelCustomizationUUID(modelCustomizationUUID);
329 collectionNetworkResourceCust.setModelInstanceName(modelInstanceName);
330 collectionNetworkResourceCust.setNetworkRole(networkRole);
331 collectionNetworkResourceCust.setNetworkScope(networkScope);
332 collectionNetworkResourceCust.setNetworkTechnology(networkTechnology);
333 collectionNetworkResourceCust.setNetworkType(networkType);
334 NetworkResourceCustomization actual = bbInputSetupMapperLayer.mapCollectionNetworkResourceCustToNetworkResourceCust(collectionNetworkResourceCust);
336 assertThat(actual, sameBeanAs(expected));
340 public void testMapCatalogCollectionToCollection() throws IOException {
341 ModelInfoCollection expected = mapper.readValue(
342 new File(RESOURCE_PATH + "ModelInfoCollection.json"),
343 ModelInfoCollection.class);
345 CollectionResourceCustomization collectionCust = mapper.readValue(
346 new File(RESOURCE_PATH + "CollectionResourceCustomization.json"),
347 CollectionResourceCustomization.class);
349 CollectionResource collectionResource = mapper.readValue(
350 new File(RESOURCE_PATH + "CollectionResource.json"),
351 CollectionResource.class);
353 ModelInfoCollection actual = bbInputSetupMapperLayer.mapCatalogCollectionToCollection(collectionCust, collectionResource);
355 assertThat(actual, sameBeanAs(expected));
359 public void testMapAAIServiceInstanceIntoServiceInstance() throws IOException {
360 ServiceInstance expected = mapper.readValue(
361 new File(RESOURCE_PATH + "ServiceInstance_aaiServiceInstanceToSI.json"),
362 ServiceInstance.class);
364 org.onap.aai.domain.yang.ServiceInstance serviceInstanceAAI = mapper.readValue(
365 new File(RESOURCE_PATH + "ServiceInstanceAAIInput.json"),
366 org.onap.aai.domain.yang.ServiceInstance.class);
368 ServiceInstance actual = bbInputSetupMapperLayer.mapAAIServiceInstanceIntoServiceInstance(serviceInstanceAAI);
370 assertThat(actual, sameBeanAs(expected));
374 public void testSetPlatformAndLOB() throws IOException {
375 ServiceInstance expected = mapper.readValue(
376 new File(RESOURCE_PATH + "ServiceInstance_aaiPlatformAndLOBToSI.json"),
377 ServiceInstance.class);
379 Map<ResourceKey, String> resourcesToBeOrchestrated = new HashMap<>();
380 resourcesToBeOrchestrated.put(ResourceKey.GENERIC_VNF_ID, "vnfId");
381 Platform platformMSO = new Platform();
382 platformMSO.setPlatformName("platformName");
383 LineOfBusiness lineOfBusinessMSO = new LineOfBusiness();
384 lineOfBusinessMSO.setLineOfBusinessName("lineOfBusinessName");
386 ServiceInstance actual = mapper.readValue(
387 new File(RESOURCE_PATH + "ServiceInstanceAAIPlatformAndLOBInput.json"),
388 ServiceInstance.class);
390 bbInputSetupMapperLayer.setPlatformAndLOBIntoServiceInstance(platformMSO, lineOfBusinessMSO, actual,
391 resourcesToBeOrchestrated);
393 assertThat(actual, sameBeanAs(expected));
397 public void testMapAAIL3NetworkIntoL3Network() throws IOException {
398 L3Network expected = mapper.readValue(
399 new File(RESOURCE_PATH + "l3NetworkExpected.json"), L3Network.class);
401 org.onap.aai.domain.yang.L3Network aaiL3Network = mapper.readValue(
402 new File(RESOURCE_PATH + "aaiL3NetworkInput.json"),
403 org.onap.aai.domain.yang.L3Network.class);
405 L3Network actual = bbInputSetupMapperLayer.mapAAIL3Network(aaiL3Network);
407 assertThat(actual, sameBeanAs(expected));
411 public void testMapAAIGenericVnfIntoGenericVnf() throws IOException {
412 GenericVnf expected = mapper.readValue(new File(RESOURCE_PATH + "GenericVnfExpected.json"), GenericVnf.class);
413 org.onap.aai.domain.yang.GenericVnf aaiGenericVnf = mapper.readValue(
414 new File(RESOURCE_PATH + "aaiGenericVnfInput.json"), org.onap.aai.domain.yang.GenericVnf.class);
416 GenericVnf actual = bbInputSetupMapperLayer.mapAAIGenericVnfIntoGenericVnf(aaiGenericVnf);
418 assertThat(actual, sameBeanAs(expected));
422 public void testMapAAICollectionIntoCollection() throws JsonParseException, JsonMappingException, IOException {
423 org.onap.aai.domain.yang.Collection aaiCollection = mapper.readValue(
424 new File(RESOURCE_PATH + "CollectionInput.json"), org.onap.aai.domain.yang.Collection.class);
426 Collection expectedCollection = mapper.readValue(new File(RESOURCE_PATH + "CollectionExpected.json"), Collection.class);
428 Collection actualCollection = bbInputSetupMapperLayer.mapAAICollectionIntoCollection(aaiCollection);
430 assertThat(actualCollection, sameBeanAs(expectedCollection));
434 public void testMapAAIInstanceGroupIntoInstanceGroup() throws JsonParseException, JsonMappingException, IOException {
435 org.onap.aai.domain.yang.InstanceGroup aaiInstanceGroup = mapper.readValue(
436 new File(RESOURCE_PATH + "InstanceGroupInput.json"), org.onap.aai.domain.yang.InstanceGroup.class);
438 org.onap.so.bpmn.servicedecomposition.bbobjects.InstanceGroup expectedInstanceGroup = mapper.readValue(
439 new File(RESOURCE_PATH + "InstanceGroupExpected.json"), org.onap.so.bpmn.servicedecomposition.bbobjects.InstanceGroup.class);
441 org.onap.so.bpmn.servicedecomposition.bbobjects.InstanceGroup actualInstanceGroup =
442 bbInputSetupMapperLayer.mapAAIInstanceGroupIntoInstanceGroup(aaiInstanceGroup);
444 assertThat(actualInstanceGroup, sameBeanAs(expectedInstanceGroup));
448 public void testMapAAIRouteTableReferenceIntoRouteTableReference() throws JsonParseException, JsonMappingException, IOException {
449 org.onap.aai.domain.yang.RouteTableReference aaiRouteTableReference = mapper.readValue(
450 new File(RESOURCE_PATH + "RouteTableReferenceInput.json"), org.onap.aai.domain.yang.RouteTableReference.class);
452 RouteTableReference expectedRouteTableReference = mapper.readValue(
453 new File(RESOURCE_PATH + "RouteTableReferenceExpected.json"), RouteTableReference.class);
455 RouteTableReference actualRouteTableReference = bbInputSetupMapperLayer.mapAAIRouteTableReferenceIntoRouteTableReference(aaiRouteTableReference);
457 assertThat(actualRouteTableReference, sameBeanAs(expectedRouteTableReference));
461 public void testMapCatalogNetworkToNetwork() throws JsonParseException, JsonMappingException, IOException {
462 NetworkResourceCustomization networkResourceCustomization = mapper.readValue(
463 new File(RESOURCE_PATH + "NetworkResourceCustomizationInput.json"), NetworkResourceCustomization.class);
465 ModelInfoNetwork expectedModelInfoNetwork = mapper.readValue(
466 new File(RESOURCE_PATH + "ModelInfoNetworkExpected.json"), ModelInfoNetwork.class);
468 ModelInfoNetwork actualModelInfoNetwork = bbInputSetupMapperLayer.mapCatalogNetworkToNetwork(networkResourceCustomization);
470 assertThat(actualModelInfoNetwork, sameBeanAs(expectedModelInfoNetwork));
474 public void testMapCatalogVnfToVnf() throws IOException {
475 VnfResourceCustomization vnfResourceCustomization = mapper.readValue(
476 new File(RESOURCE_PATH + "VnfResourceCustomizationInput.json"), VnfResourceCustomization.class);
478 ModelInfoGenericVnf expectedModelInfoGenericVnf = mapper.readValue(
479 new File(RESOURCE_PATH + "ModelInfoGenericVnfExpected.json"), ModelInfoGenericVnf.class);
481 ModelInfoGenericVnf actualModelInfoGenericVnf = bbInputSetupMapperLayer.mapCatalogVnfToVnf(vnfResourceCustomization);
483 assertThat(actualModelInfoGenericVnf, sameBeanAs(expectedModelInfoGenericVnf));
487 public void testMapCatalogVfModuleToVfModule() throws JsonParseException, JsonMappingException, IOException {
488 VfModuleCustomization vfResourceCustomization = mapper.readValue(
489 new File(RESOURCE_PATH + "VfModuleCustomizationInput.json"), VfModuleCustomization.class);
491 ModelInfoVfModule expectedModelInfoVfModule = mapper.readValue(new File(RESOURCE_PATH + "ModelInfoVfModuleExpected.json"), ModelInfoVfModule.class);
493 ModelInfoVfModule actualModelInfoVfModule = bbInputSetupMapperLayer.mapCatalogVfModuleToVfModule(vfResourceCustomization);
495 assertThat(actualModelInfoVfModule, sameBeanAs(expectedModelInfoVfModule));
499 public void testMapRequestPlatform() throws JsonParseException, JsonMappingException, IOException {
500 org.onap.so.serviceinstancebeans.Platform platform = mapper.readValue(
501 new File(RESOURCE_PATH + "RequestPlatformInput.json"), org.onap.so.serviceinstancebeans.Platform.class);
503 Platform expectedPlatform = mapper.readValue(new File(RESOURCE_PATH + "PlatformExpected.json"), Platform.class);
505 Platform actualPlatform = bbInputSetupMapperLayer.mapRequestPlatform(platform);
507 assertThat(actualPlatform, sameBeanAs(expectedPlatform));
511 public void testMapRequestLineOfBusiness() throws JsonParseException, JsonMappingException, IOException {
512 org.onap.so.serviceinstancebeans.LineOfBusiness lineOfBusiness = mapper.readValue(
513 new File(RESOURCE_PATH + "RequestLineOfBusinessInput.json"), org.onap.so.serviceinstancebeans.LineOfBusiness.class);
515 LineOfBusiness expectedLineOfBusiness = mapper.readValue(new File(RESOURCE_PATH + "LineOfBusinessExpected.json"), LineOfBusiness.class);
517 LineOfBusiness actualLineOfBusiness = bbInputSetupMapperLayer.mapRequestLineOfBusiness(lineOfBusiness);
519 assertThat(actualLineOfBusiness, sameBeanAs(expectedLineOfBusiness));
523 public void testMapAAIConfiguration() throws JsonParseException, JsonMappingException, IOException {
524 org.onap.aai.domain.yang.Configuration configurationAAI = mapper.readValue(
525 new File(RESOURCE_PATH + "ConfigurationInput.json"), org.onap.aai.domain.yang.Configuration.class);
527 Configuration expectedConfiguration = mapper.readValue(
528 new File(RESOURCE_PATH + "ConfigurationExpected.json"), Configuration.class);
530 Configuration actualConfiguration = bbInputSetupMapperLayer.mapAAIConfiguration(configurationAAI);
532 assertThat(actualConfiguration, sameBeanAs(expectedConfiguration));
536 public void testMapRequestContext() throws IOException {
537 RequestContext expected = mapper.readValue(
538 new File(RESOURCE_PATH + "RequestContextExpected.json"),
539 RequestContext.class);
541 RequestDetails requestDetails = mapper.readValue(
542 new File(RESOURCE_PATH + "RequestDetailsInput_mapReqContext.json"),
543 RequestDetails.class);
544 RequestContext actual = bbInputSetupMapperLayer.mapRequestContext(requestDetails);
546 assertThat(actual, sameBeanAs(expected));
550 public void testMapOrchestrationContext() throws IOException {
551 OrchestrationContext expected = new OrchestrationContext();
552 expected.setIsRollbackEnabled(false);
554 RequestDetails requestDetails = mapper.readValue(new File(RESOURCE_PATH + "RequestDetailsInput_mapReqContext.json"), RequestDetails.class);
556 OrchestrationContext actual = bbInputSetupMapperLayer.mapOrchestrationContext(requestDetails);
558 assertThat(actual, sameBeanAs(expected));
562 public void testMapLocationContext() {
563 CloudRegion expected = new CloudRegion();
564 expected.setCloudOwner("att-aic");
565 expected.setLcpCloudRegionId("cloudRegionId");
566 expected.setComplex("complexName");
567 expected.setTenantId("tenantId");
568 CloudConfiguration cloudConfig = new CloudConfiguration();
569 cloudConfig.setTenantId("tenantId");
570 cloudConfig.setLcpCloudRegionId("cloudRegionId");
571 cloudConfig.setAicNodeClli("aicNodeClli");
572 org.onap.aai.domain.yang.CloudRegion cloudRegion = new org.onap.aai.domain.yang.CloudRegion();
573 cloudRegion.setCloudOwner("att-aic");
574 cloudRegion.setCloudRegionId("cloudRegionId");
575 cloudRegion.setComplexName("complexName");
577 CloudRegion actual = bbInputSetupMapperLayer.mapCloudRegion(cloudConfig, cloudRegion, "att-aic");
579 assertThat(actual, sameBeanAs(expected));
583 public void testMapCloudRegion() {
584 CloudRegion expected = new CloudRegion();
585 expected.setCloudOwner("att-aic");
586 expected.setLcpCloudRegionId("cloudRegionId");
587 expected.setTenantId("tenantId");
588 expected.setCloudRegionVersion("cloudRegionVersion");
590 CloudConfiguration cloudConfig = new CloudConfiguration();
591 cloudConfig.setTenantId("tenantId");
592 cloudConfig.setLcpCloudRegionId("cloudRegionId");
593 cloudConfig.setAicNodeClli("aicNodeClli");
595 org.onap.aai.domain.yang.CloudRegion cloudRegion = new org.onap.aai.domain.yang.CloudRegion();
596 cloudRegion.setCloudOwner("att-aic");
597 cloudRegion.setCloudRegionId("cloudRegionId");
598 cloudRegion.setCloudRegionVersion("cloudRegionVersion");
600 CloudRegion actual = bbInputSetupMapperLayer.mapCloudRegion(cloudConfig, cloudRegion, "att-aic");
602 assertThat(actual, sameBeanAs(expected));
606 public void testMapCloudRegionWithNullCheck() {
607 CloudRegion expected = new CloudRegion();
609 CloudRegion actual = bbInputSetupMapperLayer.mapCloudRegion(null, null, null);
611 assertThat(actual, sameBeanAs(expected));
615 public void testmapCatalogConfigurationToConfiguration() {
616 String modelCustUUID = "modelCustomizationUUID";
617 String modelInvariantUUID = "modelInvariantUUID";
618 String modelVersionUUID = "modelUUID";
619 String policyName = "policyName";
620 ModelInfoConfiguration expected = new ModelInfoConfiguration();
621 expected.setModelCustomizationId(modelCustUUID);
622 expected.setModelInvariantId(modelInvariantUUID);
623 expected.setModelVersionId(modelVersionUUID);
624 expected.setPolicyName(policyName);
625 ConfigurationResourceCustomization configurationResourceCustomization = new ConfigurationResourceCustomization();
626 configurationResourceCustomization.setModelCustomizationUUID(modelCustUUID);
627 configurationResourceCustomization.setConfigurationResource(new ConfigurationResource());
628 configurationResourceCustomization.getConfigurationResource().setModelInvariantUUID(modelInvariantUUID);
629 configurationResourceCustomization.getConfigurationResource().setModelUUID(modelVersionUUID);
630 VnfVfmoduleCvnfcConfigurationCustomization policyNameTable = new VnfVfmoduleCvnfcConfigurationCustomization();
631 policyNameTable.setCvnfcCustomization(new CvnfcCustomization());
632 policyNameTable.getCvnfcCustomization().setVnfcCustomization(new VnfcCustomization());
633 policyNameTable.setPolicyName(policyName);
635 ModelInfoConfiguration actual = bbInputSetupMapperLayer.mapCatalogConfigurationToConfiguration(configurationResourceCustomization, policyNameTable);
637 assertThat(actual, sameBeanAs(expected));