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.InstanceGroup;
69 import org.onap.so.db.catalog.beans.NetworkResourceCustomization;
70 import org.onap.so.db.catalog.beans.OrchestrationStatus;
71 import org.onap.so.db.catalog.beans.Service;
72 import org.onap.so.db.catalog.beans.VfModuleCustomization;
73 import org.onap.so.db.catalog.beans.VnfResourceCustomization;
74 import org.onap.so.serviceinstancebeans.CloudConfiguration;
75 import org.onap.so.serviceinstancebeans.RequestDetails;
77 import com.fasterxml.jackson.core.JsonParseException;
78 import com.fasterxml.jackson.databind.JsonMappingException;
79 import com.fasterxml.jackson.databind.ObjectMapper;
81 public class BBInputSetupMapperLayerTest {
83 BBInputSetupMapperLayer bbInputSetupMapperLayer = new BBInputSetupMapperLayer();
85 ObjectMapper mapper = new ObjectMapper();
87 private static final String RESOURCE_PATH = "src/test/resources/__files/ExecuteBuildingBlock/";
90 public void testMapOrchestrationStatusFromAAI() {
91 OrchestrationStatus expected = OrchestrationStatus.INVENTORIED;
92 String orchStatusInput = "Inventoried";
93 OrchestrationStatus actual = bbInputSetupMapperLayer.mapOrchestrationStatusFromAAI(orchStatusInput);
94 assertThat(actual, sameBeanAs(expected));
96 expected = OrchestrationStatus.ASSIGNED;
97 orchStatusInput = "Assigned";
98 actual = bbInputSetupMapperLayer.mapOrchestrationStatusFromAAI(orchStatusInput);
99 assertThat(actual, sameBeanAs(expected));
101 expected = OrchestrationStatus.ACTIVE;
102 orchStatusInput = "Active";
103 actual = bbInputSetupMapperLayer.mapOrchestrationStatusFromAAI(orchStatusInput);
104 assertThat(actual, sameBeanAs(expected));
106 expected = OrchestrationStatus.CREATED;
107 orchStatusInput = "Created";
108 actual = bbInputSetupMapperLayer.mapOrchestrationStatusFromAAI(orchStatusInput);
109 assertThat(actual, sameBeanAs(expected));
111 expected = OrchestrationStatus.PRECREATED;
112 orchStatusInput = "PreCreated";
113 actual = bbInputSetupMapperLayer.mapOrchestrationStatusFromAAI(orchStatusInput);
114 assertThat(actual, sameBeanAs(expected));
116 expected = OrchestrationStatus.PENDING_CREATE;
117 orchStatusInput = "PendingCreate";
118 actual = bbInputSetupMapperLayer.mapOrchestrationStatusFromAAI(orchStatusInput);
119 assertThat(actual, sameBeanAs(expected));
121 expected = OrchestrationStatus.PENDING_DELETE;
122 orchStatusInput = "PendingDelete";
123 actual = bbInputSetupMapperLayer.mapOrchestrationStatusFromAAI(orchStatusInput);
124 assertThat(actual, sameBeanAs(expected));
126 expected = OrchestrationStatus.PENDING;
127 orchStatusInput = "Pending";
128 actual = bbInputSetupMapperLayer.mapOrchestrationStatusFromAAI(orchStatusInput);
129 assertThat(actual, sameBeanAs(expected));
131 expected = OrchestrationStatus.PENDING_ACTIVATION;
132 orchStatusInput = "PendingActivation";
133 actual = bbInputSetupMapperLayer.mapOrchestrationStatusFromAAI(orchStatusInput);
134 assertThat(actual, sameBeanAs(expected));
138 public void testMapOrchestrationFuzzyCases() {
139 List<String> values = Arrays.asList("pending-create", "pending_Create", "pendinggcreate", "PendingCreate");
140 values.forEach(value -> {
141 assertThat(bbInputSetupMapperLayer.mapOrchestrationStatusFromAAI(value), equalTo(OrchestrationStatus.PENDING_CREATE));
146 public void testMapAAICustomer() throws IOException {
147 Customer expected = mapper.readValue(
148 new File(RESOURCE_PATH+"Customer.json"),
151 org.onap.aai.domain.yang.Customer customerAAI = mapper.readValue(
152 new File(RESOURCE_PATH+"Customer_AAI.json"), org.onap.aai.domain.yang.Customer.class);
154 Customer actual = bbInputSetupMapperLayer.mapAAICustomer(customerAAI);
156 assertThat(actual, sameBeanAs(expected));
160 public void testMapAAIServiceSubscription() throws IOException {
161 ServiceSubscription expected = mapper.readValue(
162 new File(RESOURCE_PATH + "ServiceSubscriptionExpected.json"), ServiceSubscription.class);
164 org.onap.aai.domain.yang.ServiceSubscription svcSubscriptionAAI = mapper.readValue(
165 new File(RESOURCE_PATH + "ServiceSubscription_AAI.json"), org.onap.aai.domain.yang.ServiceSubscription.class);
167 ServiceSubscription actual = bbInputSetupMapperLayer.mapAAIServiceSubscription(svcSubscriptionAAI);
169 assertThat(actual, sameBeanAs(expected));
173 public void testMapAAIProject() throws IOException {
174 Project expected = mapper.readValue(new File(RESOURCE_PATH+"Project.json"),Project.class);
176 org.onap.aai.domain.yang.Project projectAAI = new org.onap.aai.domain.yang.Project();
177 projectAAI.setProjectName("projectName");
179 Project actual = bbInputSetupMapperLayer.mapAAIProject(projectAAI);
181 assertThat(actual, sameBeanAs(expected));
185 public void testMapRequestProject() throws IOException {
186 Project expected = mapper.readValue(new File(RESOURCE_PATH+"Project.json"),Project.class);
188 org.onap.so.serviceinstancebeans.Project requestProject = new org.onap.so.serviceinstancebeans.Project();
189 requestProject.setProjectName("projectName");
191 Project actual = bbInputSetupMapperLayer.mapRequestProject(requestProject);
193 assertThat(actual, sameBeanAs(expected));
197 public void testMapAAIOwningEntity() throws IOException {
198 OwningEntity expected = mapper.readValue(new File(RESOURCE_PATH+"OwningEntity.json"),OwningEntity.class);
200 org.onap.aai.domain.yang.OwningEntity entityAAI = new org.onap.aai.domain.yang.OwningEntity();
201 entityAAI.setOwningEntityId("owningEntityId");
202 entityAAI.setOwningEntityName("owningEntityName");
204 OwningEntity actual = bbInputSetupMapperLayer.mapAAIOwningEntity(entityAAI);
206 assertThat(actual, sameBeanAs(expected));
210 public void testMapRequestOwningEntity() throws IOException {
211 OwningEntity expected = mapper.readValue(new File(RESOURCE_PATH+"OwningEntity.json"),OwningEntity.class);
213 org.onap.so.serviceinstancebeans.OwningEntity requestOwningEntity = new org.onap.so.serviceinstancebeans.OwningEntity();
214 requestOwningEntity.setOwningEntityId("owningEntityId");
215 requestOwningEntity.setOwningEntityName("owningEntityName");
217 OwningEntity actual = bbInputSetupMapperLayer.mapRequestOwningEntity(requestOwningEntity);
219 assertThat(actual, sameBeanAs(expected));
223 public void testMapAAIPlatform() throws IOException {
224 Platform expected = mapper.readValue(new File(RESOURCE_PATH+"Platform.json"),Platform.class);
226 org.onap.aai.domain.yang.Platform platformAAI = new org.onap.aai.domain.yang.Platform();
227 platformAAI.setPlatformName("platformName");
229 Platform actual = bbInputSetupMapperLayer.mapAAIPlatform(platformAAI);
231 assertThat(actual, sameBeanAs(expected));
235 public void testMapAAILineOfBusiness() throws IOException {
236 LineOfBusiness expected = mapper.readValue(new File(RESOURCE_PATH+"LineOfBusiness.json"),LineOfBusiness.class);
238 org.onap.aai.domain.yang.LineOfBusiness lobAAI = new org.onap.aai.domain.yang.LineOfBusiness();
239 lobAAI.setLineOfBusinessName("lineOfBusinessName");
241 LineOfBusiness actual = bbInputSetupMapperLayer.mapAAILineOfBusiness(lobAAI);
243 assertThat(actual, sameBeanAs(expected));
247 public void testMapAAINetworkPolicy() throws JsonParseException, JsonMappingException, IOException {
248 NetworkPolicy expectedNetworkPolicy = mapper.readValue(new File(RESOURCE_PATH + "NetworkPolicy.json"), NetworkPolicy.class);
250 org.onap.aai.domain.yang.NetworkPolicy aaiNetworkPolicy = new org.onap.aai.domain.yang.NetworkPolicy();
251 aaiNetworkPolicy.setNetworkPolicyId("networkPolicyId");
252 aaiNetworkPolicy.setNetworkPolicyFqdn("networkPolicyFqdn");
253 aaiNetworkPolicy.setHeatStackId("heatStackId");
254 aaiNetworkPolicy.setResourceVersion("resourceVersion");
256 NetworkPolicy actualNetworkPolicy = bbInputSetupMapperLayer.mapAAINetworkPolicy(aaiNetworkPolicy);
258 assertThat(actualNetworkPolicy, sameBeanAs(expectedNetworkPolicy));
262 public void testMapAAIVolumeGroup() throws JsonParseException, JsonMappingException, IOException {
263 VolumeGroup expectedVolumeGroup = mapper.readValue(new File(RESOURCE_PATH + "VolumeGroup.json"), VolumeGroup.class);
265 org.onap.aai.domain.yang.VolumeGroup aaiVolumeGroup = mapper.readValue(
266 new File(RESOURCE_PATH + "VolumeGroup_AAI.json"), org.onap.aai.domain.yang.VolumeGroup.class);
268 VolumeGroup actualVolumeGroup = bbInputSetupMapperLayer.mapAAIVolumeGroup(aaiVolumeGroup);
270 assertThat(actualVolumeGroup, sameBeanAs(expectedVolumeGroup));
274 public void testMapCatalogServiceIntoServiceInstance() throws IOException {
275 ModelInfoServiceInstance expected = mapper.readValue(
276 new File(RESOURCE_PATH + "ModelInfoServiceInstance.json"),
277 ModelInfoServiceInstance.class);
279 Service catalogService = mapper.readValue(
280 new File(RESOURCE_PATH + "CatalogServiceInput.json"), Service.class);
282 ModelInfoServiceInstance actual = bbInputSetupMapperLayer.mapCatalogServiceIntoServiceInstance(catalogService);
284 assertThat(actual, sameBeanAs(expected));
288 public void testMapCatalogInstanceGroupToInstanceGroup() throws IOException {
289 ModelInfoInstanceGroup expected = mapper.readValue(
290 new File(RESOURCE_PATH + "ModelInfoInstanceGroup.json"),
291 ModelInfoInstanceGroup.class);
293 InstanceGroup instanceGroup = mapper.readValue(
294 new File(RESOURCE_PATH + "InstanceGroup.json"), InstanceGroup.class);
295 instanceGroup.setCollectionInstanceGroupCustomizations(new ArrayList<>());
296 CollectionResourceInstanceGroupCustomization collectionInstanceGroupCust = new CollectionResourceInstanceGroupCustomization();
297 collectionInstanceGroupCust.setModelCustomizationUUID("modelCustomizationUUID");
298 collectionInstanceGroupCust.setFunction("function");
299 collectionInstanceGroupCust.setDescription("description");
300 instanceGroup.getCollectionInstanceGroupCustomizations().add(collectionInstanceGroupCust);
301 CollectionResourceCustomization collectionResourceCust = new CollectionResourceCustomization();
302 collectionResourceCust.setModelCustomizationUUID("modelCustomizationUUID");
303 ModelInfoInstanceGroup actual = bbInputSetupMapperLayer.mapCatalogInstanceGroupToInstanceGroup(collectionResourceCust, instanceGroup);
305 assertThat(actual, sameBeanAs(expected));
309 public void testMapCollectionNetworkResourceCustToNetworkResourceCust() {
310 String modelCustomizationUUID = "modelCustomizationUUID";
311 String modelInstanceName = "modelInstanceName";
312 String networkRole = "networkRole";
313 String networkScope = "networkScope";
314 String networkTechnology = "networkTechnology";
315 String networkType = "networkType";
317 NetworkResourceCustomization expected = new NetworkResourceCustomization();
318 expected.setModelCustomizationUUID(modelCustomizationUUID);
319 expected.setModelInstanceName(modelInstanceName);
320 expected.setNetworkRole(networkRole);
321 expected.setNetworkScope(networkScope);
322 expected.setNetworkTechnology(networkTechnology);
323 expected.setNetworkType(networkType);
324 CollectionNetworkResourceCustomization collectionNetworkResourceCust = new CollectionNetworkResourceCustomization();
325 collectionNetworkResourceCust.setModelCustomizationUUID(modelCustomizationUUID);
326 collectionNetworkResourceCust.setModelInstanceName(modelInstanceName);
327 collectionNetworkResourceCust.setNetworkRole(networkRole);
328 collectionNetworkResourceCust.setNetworkScope(networkScope);
329 collectionNetworkResourceCust.setNetworkTechnology(networkTechnology);
330 collectionNetworkResourceCust.setNetworkType(networkType);
331 NetworkResourceCustomization actual = bbInputSetupMapperLayer.mapCollectionNetworkResourceCustToNetworkResourceCust(collectionNetworkResourceCust);
333 assertThat(actual, sameBeanAs(expected));
337 public void testMapCatalogCollectionToCollection() throws IOException {
338 ModelInfoCollection expected = mapper.readValue(
339 new File(RESOURCE_PATH + "ModelInfoCollection.json"),
340 ModelInfoCollection.class);
342 CollectionResourceCustomization collectionCust = mapper.readValue(
343 new File(RESOURCE_PATH + "CollectionResourceCustomization.json"),
344 CollectionResourceCustomization.class);
346 CollectionResource collectionResource = mapper.readValue(
347 new File(RESOURCE_PATH + "CollectionResource.json"),
348 CollectionResource.class);
350 ModelInfoCollection actual = bbInputSetupMapperLayer.mapCatalogCollectionToCollection(collectionCust, collectionResource);
352 assertThat(actual, sameBeanAs(expected));
356 public void testMapAAIServiceInstanceIntoServiceInstance() throws IOException {
357 ServiceInstance expected = mapper.readValue(
358 new File(RESOURCE_PATH + "ServiceInstance_aaiServiceInstanceToSI.json"),
359 ServiceInstance.class);
361 org.onap.aai.domain.yang.ServiceInstance serviceInstanceAAI = mapper.readValue(
362 new File(RESOURCE_PATH + "ServiceInstanceAAIInput.json"),
363 org.onap.aai.domain.yang.ServiceInstance.class);
365 ServiceInstance actual = bbInputSetupMapperLayer.mapAAIServiceInstanceIntoServiceInstance(serviceInstanceAAI);
367 assertThat(actual, sameBeanAs(expected));
371 public void testSetPlatformAndLOB() throws IOException {
372 ServiceInstance expected = mapper.readValue(
373 new File(RESOURCE_PATH + "ServiceInstance_aaiPlatformAndLOBToSI.json"),
374 ServiceInstance.class);
376 Map<ResourceKey, String> resourcesToBeOrchestrated = new HashMap<>();
377 resourcesToBeOrchestrated.put(ResourceKey.GENERIC_VNF_ID, "vnfId");
378 Platform platformMSO = new Platform();
379 platformMSO.setPlatformName("platformName");
380 LineOfBusiness lineOfBusinessMSO = new LineOfBusiness();
381 lineOfBusinessMSO.setLineOfBusinessName("lineOfBusinessName");
383 ServiceInstance actual = mapper.readValue(
384 new File(RESOURCE_PATH + "ServiceInstanceAAIPlatformAndLOBInput.json"),
385 ServiceInstance.class);
387 bbInputSetupMapperLayer.setPlatformAndLOBIntoServiceInstance(platformMSO, lineOfBusinessMSO, actual,
388 resourcesToBeOrchestrated);
390 assertThat(actual, sameBeanAs(expected));
394 public void testMapAAIL3NetworkIntoL3Network() throws IOException {
395 L3Network expected = mapper.readValue(
396 new File(RESOURCE_PATH + "l3NetworkExpected.json"), L3Network.class);
398 org.onap.aai.domain.yang.L3Network aaiL3Network = mapper.readValue(
399 new File(RESOURCE_PATH + "aaiL3NetworkInput.json"),
400 org.onap.aai.domain.yang.L3Network.class);
402 L3Network actual = bbInputSetupMapperLayer.mapAAIL3Network(aaiL3Network);
404 assertThat(actual, sameBeanAs(expected));
408 public void testMapAAIGenericVnfIntoGenericVnf() throws IOException {
409 GenericVnf expected = mapper.readValue(new File(RESOURCE_PATH + "GenericVnfExpected.json"), GenericVnf.class);
410 org.onap.aai.domain.yang.GenericVnf aaiGenericVnf = mapper.readValue(
411 new File(RESOURCE_PATH + "aaiGenericVnfInput.json"), org.onap.aai.domain.yang.GenericVnf.class);
413 GenericVnf actual = bbInputSetupMapperLayer.mapAAIGenericVnfIntoGenericVnf(aaiGenericVnf);
415 assertThat(actual, sameBeanAs(expected));
419 public void testMapAAICollectionIntoCollection() throws JsonParseException, JsonMappingException, IOException {
420 org.onap.aai.domain.yang.Collection aaiCollection = mapper.readValue(
421 new File(RESOURCE_PATH + "CollectionInput.json"), org.onap.aai.domain.yang.Collection.class);
423 Collection expectedCollection = mapper.readValue(new File(RESOURCE_PATH + "CollectionExpected.json"), Collection.class);
425 Collection actualCollection = bbInputSetupMapperLayer.mapAAICollectionIntoCollection(aaiCollection);
427 assertThat(actualCollection, sameBeanAs(expectedCollection));
431 public void testMapAAIInstanceGroupIntoInstanceGroup() throws JsonParseException, JsonMappingException, IOException {
432 org.onap.aai.domain.yang.InstanceGroup aaiInstanceGroup = mapper.readValue(
433 new File(RESOURCE_PATH + "InstanceGroupInput.json"), org.onap.aai.domain.yang.InstanceGroup.class);
435 org.onap.so.bpmn.servicedecomposition.bbobjects.InstanceGroup expectedInstanceGroup = mapper.readValue(
436 new File(RESOURCE_PATH + "InstanceGroupExpected.json"), org.onap.so.bpmn.servicedecomposition.bbobjects.InstanceGroup.class);
438 org.onap.so.bpmn.servicedecomposition.bbobjects.InstanceGroup actualInstanceGroup =
439 bbInputSetupMapperLayer.mapAAIInstanceGroupIntoInstanceGroup(aaiInstanceGroup);
441 assertThat(actualInstanceGroup, sameBeanAs(expectedInstanceGroup));
445 public void testMapAAIRouteTableReferenceIntoRouteTableReference() throws JsonParseException, JsonMappingException, IOException {
446 org.onap.aai.domain.yang.RouteTableReference aaiRouteTableReference = mapper.readValue(
447 new File(RESOURCE_PATH + "RouteTableReferenceInput.json"), org.onap.aai.domain.yang.RouteTableReference.class);
449 RouteTableReference expectedRouteTableReference = mapper.readValue(
450 new File(RESOURCE_PATH + "RouteTableReferenceExpected.json"), RouteTableReference.class);
452 RouteTableReference actualRouteTableReference = bbInputSetupMapperLayer.mapAAIRouteTableReferenceIntoRouteTableReference(aaiRouteTableReference);
454 assertThat(actualRouteTableReference, sameBeanAs(expectedRouteTableReference));
458 public void testMapCatalogNetworkToNetwork() throws JsonParseException, JsonMappingException, IOException {
459 NetworkResourceCustomization networkResourceCustomization = mapper.readValue(
460 new File(RESOURCE_PATH + "NetworkResourceCustomizationInput.json"), NetworkResourceCustomization.class);
462 ModelInfoNetwork expectedModelInfoNetwork = mapper.readValue(
463 new File(RESOURCE_PATH + "ModelInfoNetworkExpected.json"), ModelInfoNetwork.class);
465 ModelInfoNetwork actualModelInfoNetwork = bbInputSetupMapperLayer.mapCatalogNetworkToNetwork(networkResourceCustomization);
467 assertThat(actualModelInfoNetwork, sameBeanAs(expectedModelInfoNetwork));
471 public void testMapCatalogVnfToVnf() throws IOException {
472 VnfResourceCustomization vnfResourceCustomization = mapper.readValue(
473 new File(RESOURCE_PATH + "VnfResourceCustomizationInput.json"), VnfResourceCustomization.class);
475 ModelInfoGenericVnf expectedModelInfoGenericVnf = mapper.readValue(
476 new File(RESOURCE_PATH + "ModelInfoGenericVnfExpected.json"), ModelInfoGenericVnf.class);
478 ModelInfoGenericVnf actualModelInfoGenericVnf = bbInputSetupMapperLayer.mapCatalogVnfToVnf(vnfResourceCustomization);
480 assertThat(actualModelInfoGenericVnf, sameBeanAs(expectedModelInfoGenericVnf));
484 public void testMapCatalogVfModuleToVfModule() throws JsonParseException, JsonMappingException, IOException {
485 VfModuleCustomization vfResourceCustomization = mapper.readValue(
486 new File(RESOURCE_PATH + "VfModuleCustomizationInput.json"), VfModuleCustomization.class);
488 ModelInfoVfModule expectedModelInfoVfModule = mapper.readValue(new File(RESOURCE_PATH + "ModelInfoVfModuleExpected.json"), ModelInfoVfModule.class);
490 ModelInfoVfModule actualModelInfoVfModule = bbInputSetupMapperLayer.mapCatalogVfModuleToVfModule(vfResourceCustomization);
492 assertThat(actualModelInfoVfModule, sameBeanAs(expectedModelInfoVfModule));
496 public void testMapRequestPlatform() throws JsonParseException, JsonMappingException, IOException {
497 org.onap.so.serviceinstancebeans.Platform platform = mapper.readValue(
498 new File(RESOURCE_PATH + "RequestPlatformInput.json"), org.onap.so.serviceinstancebeans.Platform.class);
500 Platform expectedPlatform = mapper.readValue(new File(RESOURCE_PATH + "PlatformExpected.json"), Platform.class);
502 Platform actualPlatform = bbInputSetupMapperLayer.mapRequestPlatform(platform);
504 assertThat(actualPlatform, sameBeanAs(expectedPlatform));
508 public void testMapRequestLineOfBusiness() throws JsonParseException, JsonMappingException, IOException {
509 org.onap.so.serviceinstancebeans.LineOfBusiness lineOfBusiness = mapper.readValue(
510 new File(RESOURCE_PATH + "RequestLineOfBusinessInput.json"), org.onap.so.serviceinstancebeans.LineOfBusiness.class);
512 LineOfBusiness expectedLineOfBusiness = mapper.readValue(new File(RESOURCE_PATH + "LineOfBusinessExpected.json"), LineOfBusiness.class);
514 LineOfBusiness actualLineOfBusiness = bbInputSetupMapperLayer.mapRequestLineOfBusiness(lineOfBusiness);
516 assertThat(actualLineOfBusiness, sameBeanAs(expectedLineOfBusiness));
520 public void testMapAAIConfiguration() throws JsonParseException, JsonMappingException, IOException {
521 org.onap.aai.domain.yang.Configuration configurationAAI = mapper.readValue(
522 new File(RESOURCE_PATH + "ConfigurationInput.json"), org.onap.aai.domain.yang.Configuration.class);
524 Configuration expectedConfiguration = mapper.readValue(
525 new File(RESOURCE_PATH + "ConfigurationExpected.json"), Configuration.class);
527 Configuration actualConfiguration = bbInputSetupMapperLayer.mapAAIConfiguration(configurationAAI);
529 assertThat(actualConfiguration, sameBeanAs(expectedConfiguration));
533 public void testMapRequestContext() throws IOException {
534 RequestContext expected = mapper.readValue(
535 new File(RESOURCE_PATH + "RequestContextExpected.json"),
536 RequestContext.class);
538 RequestDetails requestDetails = mapper.readValue(
539 new File(RESOURCE_PATH + "RequestDetailsInput_mapReqContext.json"),
540 RequestDetails.class);
541 RequestContext actual = bbInputSetupMapperLayer.mapRequestContext(requestDetails);
543 assertThat(actual, sameBeanAs(expected));
547 public void testMapOrchestrationContext() throws IOException {
548 OrchestrationContext expected = new OrchestrationContext();
549 expected.setIsRollbackEnabled(false);
551 RequestDetails requestDetails = mapper.readValue(new File(RESOURCE_PATH + "RequestDetailsInput_mapReqContext.json"), RequestDetails.class);
553 OrchestrationContext actual = bbInputSetupMapperLayer.mapOrchestrationContext(requestDetails);
555 assertThat(actual, sameBeanAs(expected));
559 public void testMapLocationContext() {
560 CloudRegion expected = new CloudRegion();
561 expected.setCloudOwner("att-aic");
562 expected.setLcpCloudRegionId("cloudRegionId");
563 expected.setComplex("complexName");
564 expected.setTenantId("tenantId");
565 CloudConfiguration cloudConfig = new CloudConfiguration();
566 cloudConfig.setTenantId("tenantId");
567 cloudConfig.setLcpCloudRegionId("cloudRegionId");
568 cloudConfig.setAicNodeClli("aicNodeClli");
569 org.onap.aai.domain.yang.CloudRegion cloudRegion = new org.onap.aai.domain.yang.CloudRegion();
570 cloudRegion.setCloudOwner("att-aic");
571 cloudRegion.setCloudRegionId("cloudRegionId");
572 cloudRegion.setComplexName("complexName");
574 CloudRegion actual = bbInputSetupMapperLayer.mapCloudRegion(cloudConfig, cloudRegion, "att-aic");
576 assertThat(actual, sameBeanAs(expected));
580 public void testMapCloudRegion() {
581 CloudRegion expected = new CloudRegion();
582 expected.setCloudOwner("att-aic");
583 expected.setLcpCloudRegionId("cloudRegionId");
584 expected.setTenantId("tenantId");
585 expected.setCloudRegionVersion("cloudRegionVersion");
587 CloudConfiguration cloudConfig = new CloudConfiguration();
588 cloudConfig.setTenantId("tenantId");
589 cloudConfig.setLcpCloudRegionId("cloudRegionId");
590 cloudConfig.setAicNodeClli("aicNodeClli");
592 org.onap.aai.domain.yang.CloudRegion cloudRegion = new org.onap.aai.domain.yang.CloudRegion();
593 cloudRegion.setCloudOwner("att-aic");
594 cloudRegion.setCloudRegionId("cloudRegionId");
595 cloudRegion.setCloudRegionVersion("cloudRegionVersion");
597 CloudRegion actual = bbInputSetupMapperLayer.mapCloudRegion(cloudConfig, cloudRegion, "att-aic");
599 assertThat(actual, sameBeanAs(expected));
603 public void testMapCloudRegionWithNullCheck() {
604 CloudRegion expected = new CloudRegion();
606 CloudRegion actual = bbInputSetupMapperLayer.mapCloudRegion(null, null, null);
608 assertThat(actual, sameBeanAs(expected));
612 public void testmapCatalogConfigurationToConfiguration() {
613 String modelCustUUID = "modelCustomizationUUID";
614 String modelInvariantUUID = "modelInvariantUUID";
615 String modelVersionUUID = "modelUUID";
616 ModelInfoConfiguration expected = new ModelInfoConfiguration();
617 expected.setModelCustomizationId(modelCustUUID);
618 expected.setModelInvariantId(modelInvariantUUID);
619 expected.setModelVersionId(modelVersionUUID);
620 ConfigurationResourceCustomization configurationResourceCustomization = new ConfigurationResourceCustomization();
621 configurationResourceCustomization.setModelCustomizationUUID(modelCustUUID);
622 configurationResourceCustomization.setConfigurationResource(new ConfigurationResource());
623 configurationResourceCustomization.getConfigurationResource().setModelInvariantUUID(modelInvariantUUID);
624 configurationResourceCustomization.getConfigurationResource().setModelUUID(modelVersionUUID);
626 ModelInfoConfiguration actual = bbInputSetupMapperLayer.mapCatalogConfigurationToConfiguration(configurationResourceCustomization );
628 assertThat(actual, sameBeanAs(expected));