use of org.onap.so.bpmn.servicedecomposition.entities.ResourceKey in project so by onap.
the class BBInputSetupTest method testPopulateFabricConfiguration.
@Test
public void testPopulateFabricConfiguration() throws JsonParseException, JsonMappingException, IOException {
String instanceName = "configurationName";
ModelInfo modelInfo = new ModelInfo();
modelInfo.setModelCustomizationUuid("72d9d1cd-f46d-447a-abdb-451d6fb05fa9");
ServiceInstance serviceInstance = new ServiceInstance();
Configuration configuration = new Configuration();
configuration.setConfigurationId("configurationId");
configuration.setConfigurationName("configurationName");
configuration.setConfigurationSubType("Fabric Config");
serviceInstance.getConfigurations().add(configuration);
String resourceId = "configurationId";
String vnfcName = "vnfcName";
// Mock service
Service service = mapper.readValue(new File(RESOURCE_PATH + "CatalogDBService_getServiceInstanceNOAAIInput.json"), Service.class);
Map<ResourceKey, String> lookupKeyMap = new HashMap<>();
lookupKeyMap.put(ResourceKey.CONFIGURATION_ID, "configurationId");
String bbName = AssignFlows.FABRIC_CONFIGURATION.toString();
ConfigurationResourceKeys configResourceKeys = prepareConfigurationResourceKeys();
configResourceKeys.setVnfcName(vnfcName);
Vnfc vnfc = new Vnfc();
vnfc.setVnfcName(vnfcName);
RequestDetails requestDetails = new RequestDetails();
ServiceModel serviceModel = new ServiceModel();
serviceModel.setCurrentService(service);
CvnfcConfigurationCustomization vnfVfmoduleCvnfcConfigurationCustomization = new CvnfcConfigurationCustomization();
ConfigurationResource configurationResource = new ConfigurationResource();
configurationResource.setModelUUID("modelUUID");
configurationResource.setModelInvariantUUID("modelInvariantUUID");
vnfVfmoduleCvnfcConfigurationCustomization.setConfigurationResource(configurationResource);
doReturn(null).when(SPY_bbInputSetup).findConfigurationResourceCustomization(modelInfo, service);
doReturn(vnfc).when(SPY_bbInputSetup).getVnfcToConfiguration(vnfcName);
BBInputSetupParameter parameter = new BBInputSetupParameter.Builder().setRequestId(REQUEST_ID).setModelInfo(modelInfo).setService(service).setBbName(bbName).setServiceInstance(serviceInstance).setLookupKeyMap(lookupKeyMap).setResourceId(resourceId).setInstanceName(instanceName).setConfigurationResourceKeys(configResourceKeys).setRequestDetails(requestDetails).setServiceModel(serviceModel).build();
SPY_bbInputSetup.populateConfiguration(parameter);
verify(SPY_bbInputSetup, times(1)).mapCatalogConfiguration(configuration, modelInfo, service, configResourceKeys);
}
use of org.onap.so.bpmn.servicedecomposition.entities.ResourceKey in project so by onap.
the class BBInputSetupTest method testgetGBBMacroNoUserParamsOtherException.
@Test(expected = IllegalArgumentException.class)
public void testgetGBBMacroNoUserParamsOtherException() throws Exception {
GeneralBuildingBlock gBB = mapper.readValue(new File(RESOURCE_PATH + "GeneralBuildingBlockExpected.json"), GeneralBuildingBlock.class);
ExecuteBuildingBlock executeBB = mapper.readValue(new File(RESOURCE_PATH + "ExecuteBuildingBlockSimple.json"), ExecuteBuildingBlock.class);
RequestDetails requestDetails = mapper.readValue(new File(RESOURCE_PATH + "RequestDetailsInput_serviceMacro.json"), RequestDetails.class);
requestDetails.getRequestParameters().setUserParams(null);
org.onap.aai.domain.yang.GenericVnf aaiVnf = new org.onap.aai.domain.yang.GenericVnf();
aaiVnf.setModelCustomizationId("modelCustId");
Map<ResourceKey, String> lookupKeyMap = new HashMap<>();
lookupKeyMap.put(ResourceKey.NETWORK_ID, "networkId");
lookupKeyMap.put(ResourceKey.GENERIC_VNF_ID, "vnfId");
lookupKeyMap.put(ResourceKey.VF_MODULE_ID, "vfModuleId");
lookupKeyMap.put(ResourceKey.VOLUME_GROUP_ID, "volumeGroupId");
lookupKeyMap.put(ResourceKey.SERVICE_INSTANCE_ID, "serviceInstanceId");
String resourceId = "123";
String vnfType = "vnfType";
Service service = Mockito.mock(Service.class);
String requestAction = "assignInstance";
doReturn(gBB).when(SPY_bbInputSetup).getGBBALaCarteService(executeBB, requestDetails, lookupKeyMap, requestAction, lookupKeyMap.get(ResourceKey.SERVICE_INSTANCE_ID));
doReturn(service).when(SPY_bbInputSetupUtils).getCatalogServiceByModelUUID(gBB.getServiceInstance().getModelInfoServiceInstance().getModelUuid());
String generatedId = "12131";
SPY_bbInputSetup.getGBBMacro(executeBB, requestDetails, lookupKeyMap, requestAction, resourceId, vnfType);
}
use of org.onap.so.bpmn.servicedecomposition.entities.ResourceKey in project so by onap.
the class BBInputSetupMapperLayerTest method testSetPlatformAndLOB.
@Test
public void testSetPlatformAndLOB() throws IOException {
ServiceInstance expected = mapper.readValue(new File(RESOURCE_PATH + "ServiceInstance_aaiPlatformAndLOBToSI.json"), ServiceInstance.class);
Map<ResourceKey, String> resourcesToBeOrchestrated = new HashMap<>();
resourcesToBeOrchestrated.put(ResourceKey.GENERIC_VNF_ID, "vnfId");
Platform platformMSO = new Platform();
platformMSO.setPlatformName("platformName");
LineOfBusiness lineOfBusinessMSO = new LineOfBusiness();
lineOfBusinessMSO.setLineOfBusinessName("lineOfBusinessName");
ServiceInstance actual = mapper.readValue(new File(RESOURCE_PATH + "ServiceInstanceAAIPlatformAndLOBInput.json"), ServiceInstance.class);
bbInputSetupMapperLayer.setPlatformAndLOBIntoServiceInstance(platformMSO, lineOfBusinessMSO, actual, resourcesToBeOrchestrated);
assertThat(actual, sameBeanAs(expected));
}
use of org.onap.so.bpmn.servicedecomposition.entities.ResourceKey in project so by onap.
the class BBInputSetupTest method testSetHomingFlag.
@Test
public void testSetHomingFlag() throws IOException {
GeneralBuildingBlock expected = mapper.readValue(new File(RESOURCE_PATH + "GeneralBuildingBlockExpected.json"), GeneralBuildingBlock.class);
Map<ResourceKey, String> lookupKeyMap = new HashMap<>();
lookupKeyMap.put(ResourceKey.GENERIC_VNF_ID, "vnfId");
GenericVnf genericVnfExpected = new GenericVnf();
genericVnfExpected.setVnfId("vnfId");
genericVnfExpected.setCallHoming(true);
expected.getCustomer().getServiceSubscription().getServiceInstances().get(0).getVnfs().add(genericVnfExpected);
boolean homing = true;
GenericVnf genericVnfActual = new GenericVnf();
genericVnfActual.setVnfId("vnfId");
genericVnfActual.setCallHoming(false);
GeneralBuildingBlock actual = mapper.readValue(new File(RESOURCE_PATH + "GeneralBuildingBlockExpected.json"), GeneralBuildingBlock.class);
actual.getCustomer().getServiceSubscription().getServiceInstances().get(0).getVnfs().add(genericVnfActual);
SPY_bbInputSetup.setHomingFlag(actual, homing, lookupKeyMap);
assertThat(actual, sameBeanAs(expected));
}
use of org.onap.so.bpmn.servicedecomposition.entities.ResourceKey in project so by onap.
the class BBInputSetupTest method testPopulateVfModuleIsReplace.
@Test
public void testPopulateVfModuleIsReplace() throws Exception {
String vnfId = "vnfId";
String vfModuleId = "vfModuleId";
String volumeGroupId = "volumeGroupId";
String vfModuleCustomizationId = "vfModuleCustomizationId";
ModelInfo modelInfo = new ModelInfo();
modelInfo.setModelCustomizationId(vfModuleCustomizationId);
Service currentService = new Service();
Service newService = new Service();
ServiceModel serviceModel = new ServiceModel();
serviceModel.setCurrentService(currentService);
currentService.setModelUUID("currentUUID");
serviceModel.setNewService(newService);
currentService.setModelUUID("newUUID");
String bbName = AssignFlows.VF_MODULE.toString();
ServiceInstance serviceInstance = new ServiceInstance();
GenericVnf vnf = new GenericVnf();
vnf.setVnfId(vnfId);
VolumeGroup volumeGroup = new VolumeGroup();
volumeGroup.setVolumeGroupId(volumeGroupId);
vnf.getVolumeGroups().add(volumeGroup);
serviceInstance.getVnfs().add(vnf);
VfModule vfModule1 = new VfModule();
vfModule1.setVfModuleId("vfModuleId1");
VfModule vfModule2 = new VfModule();
vfModule2.setVfModuleId("vfModuleId2");
vnf.getVfModules().add(vfModule1);
vnf.getVfModules().add(vfModule2);
Map<ResourceKey, String> lookupKeyMap = new HashMap<>();
lookupKeyMap.put(ResourceKey.GENERIC_VNF_ID, vnfId);
lookupKeyMap.put(ResourceKey.VF_MODULE_ID, vfModuleId);
String resourceId = vfModuleId;
RelatedInstanceList[] relatedInstanceList = new RelatedInstanceList[1];
RelatedInstanceList relatedInstanceListObj = new RelatedInstanceList();
RelatedInstance relatedInstance = new RelatedInstance();
relatedInstance.setInstanceId(vnfId);
ModelInfo vnfModelInfo = new ModelInfo();
vnfModelInfo.setModelCustomizationId("vnfCustomizationId");
vnfModelInfo.setModelType(ModelType.vnf);
relatedInstance.setModelInfo(vnfModelInfo);
relatedInstanceListObj.setRelatedInstance(relatedInstance);
relatedInstanceList[0] = relatedInstanceListObj;
String instanceName = "vfModuleName";
List<Map<String, String>> instanceParams = null;
CloudConfiguration cloudConfiguration = new CloudConfiguration();
org.onap.aai.domain.yang.GenericVnf vnfAAI = new org.onap.aai.domain.yang.GenericVnf();
vnfAAI.setModelCustomizationId("vnfModelCustId");
org.onap.aai.domain.yang.VolumeGroup volumeGroupAAI = new org.onap.aai.domain.yang.VolumeGroup();
volumeGroupAAI.setModelCustomizationId(vfModuleCustomizationId);
org.onap.aai.domain.yang.VfModule vfModuleAAI = new org.onap.aai.domain.yang.VfModule();
vfModuleAAI.setModelCustomizationId(vfModuleCustomizationId);
doReturn(vnfAAI).when(SPY_bbInputSetupUtils).getAAIGenericVnf(vnf.getVnfId());
doReturn(volumeGroupAAI).when(SPY_bbInputSetupUtils).getAAIVolumeGroup(CLOUD_OWNER, cloudConfiguration.getLcpCloudRegionId(), volumeGroup.getVolumeGroupId());
doReturn(vfModuleAAI).when(SPY_bbInputSetupUtils).getAAIVfModule(isA(String.class), isA(String.class));
doNothing().when(SPY_bbInputSetup).mapCatalogVnf(isA(GenericVnf.class), isA(ModelInfo.class), isA(Service.class));
doNothing().when(SPY_bbInputSetup).mapCatalogVfModule(isA(VfModule.class), isA(ModelInfo.class), isA(Service.class), isA(String.class));
BBInputSetupParameter parameter = new BBInputSetupParameter.Builder().setModelInfo(modelInfo).setService(newService).setServiceInstance(serviceInstance).setBbName(bbName).setLookupKeyMap(lookupKeyMap).setResourceId(resourceId).setRelatedInstanceList(relatedInstanceList).setInstanceName(instanceName).setInstanceParams(instanceParams).setCloudConfiguration(cloudConfiguration).setIsReplace(true).setServiceModel(serviceModel).build();
SPY_bbInputSetup.populateVfModule(parameter);
verify(SPY_bbInputSetup, times(2)).mapCatalogVfModule(isA(VfModule.class), isA(ModelInfo.class), eq(serviceModel.getCurrentService()), isA(String.class));
verify(SPY_bbInputSetup, times(1)).mapCatalogVfModule(isA(VfModule.class), isA(ModelInfo.class), eq(serviceModel.getNewService()), isA(String.class));
assertEquals("Lookup Key Map populated with VfModule Id", vfModuleId, lookupKeyMap.get(ResourceKey.VF_MODULE_ID));
assertEquals("Lookup Key Map populated with VolumeGroup Id", volumeGroupId, lookupKeyMap.get(ResourceKey.VOLUME_GROUP_ID));
}
Aggregations