use of org.onap.so.bpmn.servicedecomposition.bbobjects.Vnfc in project so by onap.
the class BBInputSetupTest method testPopulateConfigurationReplace.
@Test
public void testPopulateConfigurationReplace() 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");
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);
ConfigurationResourceCustomization configurationCust = new ConfigurationResourceCustomization();
configurationCust.setModelCustomizationUUID("72d9d1cd-f46d-447a-abdb-451d6fb05fa9");
service.getConfigurationCustomizations().add(configurationCust);
Map<ResourceKey, String> lookupKeyMap = new HashMap<>();
lookupKeyMap.put(ResourceKey.CONFIGURATION_ID, "configurationId");
String bbName = AssignFlows.FABRIC_CONFIGURATION.toString();
ServiceModel serviceModel = new ServiceModel();
serviceModel.setNewService(service);
ConfigurationResourceKeys configResourceKeys = prepareConfigurationResourceKeys();
configResourceKeys.setVnfcName(vnfcName);
Vnfc vnfc = new Vnfc();
vnfc.setVnfcName(vnfcName);
RequestDetails requestDetails = mapper.readValue(new File(RESOURCE_PATH + "RequestDetailsInput_withRelatedInstanceList.json"), RequestDetails.class);
doNothing().when(SPY_bbInputSetup).mapCatalogConfiguration(configuration, modelInfo, service, configResourceKeys);
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).setIsReplace(true).build();
SPY_bbInputSetup.populateConfiguration(parameter);
configResourceKeys.setVnfResourceCustomizationUUID("my-test-uuid");
verify(SPY_bbInputSetup, times(1)).mapCatalogConfiguration(configuration, modelInfo, service, configResourceKeys);
}
use of org.onap.so.bpmn.servicedecomposition.bbobjects.Vnfc 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.bbobjects.Vnfc in project so by onap.
the class BBInputSetup method populateConfiguration.
protected void populateConfiguration(BBInputSetupParameter parameter) {
Configuration configuration = null;
String replaceVnfModelCustomizationUUID = "";
if (parameter.getRelatedInstanceList() != null) {
for (RelatedInstanceList relatedInstList : parameter.getRelatedInstanceList()) {
RelatedInstance relatedInstance = relatedInstList.getRelatedInstance();
if (relatedInstance.getModelInfo().getModelType().equals(ModelType.vnf)) {
if (parameter.getIsReplace()) {
replaceVnfModelCustomizationUUID = relatedInstance.getModelInfo().getModelCustomizationId();
}
}
}
}
for (Configuration configurationTemp : parameter.getServiceInstance().getConfigurations()) {
if (parameter.getLookupKeyMap().get(ResourceKey.CONFIGURATION_ID) != null && configurationTemp.getConfigurationId().equalsIgnoreCase(parameter.getLookupKeyMap().get(ResourceKey.CONFIGURATION_ID))) {
configuration = configurationTemp;
org.onap.aai.domain.yang.Configuration aaiConfiguration = bbInputSetupUtils.getAAIConfiguration(configuration.getConfigurationId());
if (aaiConfiguration != null) {
parameter.getModelInfo().setModelCustomizationUuid(aaiConfiguration.getModelCustomizationId());
}
}
}
if (configuration == null && (parameter.getBbName().equalsIgnoreCase(AssignFlows.FABRIC_CONFIGURATION.toString()) || parameter.getBbName().equalsIgnoreCase(AssignFlows.VRF_CONFIGURATION.toString()))) {
configuration = this.createConfiguration(parameter.getLookupKeyMap(), parameter.getInstanceName(), parameter.getResourceId());
parameter.getServiceInstance().getConfigurations().add(configuration);
}
if (configuration != null && parameter.getBbName().contains("Fabric")) {
Vnfc vnfc = getVnfcToConfiguration(parameter.getConfigurationResourceKeys().getVnfcName());
configuration.setVnfc(vnfc);
if (!parameter.getBbName().contains("Delete")) {
if (parameter.getIsReplace()) {
parameter.getConfigurationResourceKeys().setVnfResourceCustomizationUUID(replaceVnfModelCustomizationUUID);
mapCatalogConfiguration(configuration, parameter.getModelInfo(), parameter.getServiceModel().getNewService(), parameter.getConfigurationResourceKeys());
} else {
mapCatalogConfiguration(configuration, parameter.getModelInfo(), parameter.getServiceModel().getCurrentService(), parameter.getConfigurationResourceKeys());
}
}
} else if (configuration != null && parameter.getBbName().contains("Vrf")) {
configuration.setModelInfoConfiguration(mapperLayer.mapCatalogConfigurationToConfiguration(findConfigurationResourceCustomization(parameter.getModelInfo(), parameter.getService()), null));
configuration.setConfigurationType(configuration.getModelInfoConfiguration().getConfigurationType());
configuration.setConfigurationSubType(configuration.getModelInfoConfiguration().getConfigurationRole());
}
}
use of org.onap.so.bpmn.servicedecomposition.bbobjects.Vnfc in project so by onap.
the class BBInputSetup method getVnfcToConfiguration.
protected Vnfc getVnfcToConfiguration(String vnfcName) {
AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().vnfc(vnfcName));
Optional<org.onap.aai.domain.yang.Vnfc> vnfcOp = bbInputSetupUtils.getAAIResourceDepthOne(uri).asBean(org.onap.aai.domain.yang.Vnfc.class);
if (vnfcOp.isPresent()) {
org.onap.aai.domain.yang.Vnfc vnfcAAI = vnfcOp.get();
return this.mapperLayer.mapAAIVnfc(vnfcAAI);
} else {
return null;
}
}
use of org.onap.so.bpmn.servicedecomposition.bbobjects.Vnfc in project so by onap.
the class BBInputSetupTest method testPopulateConfiguration.
@Test
public void testPopulateConfiguration() 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");
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);
ConfigurationResourceCustomization configurationCust = new ConfigurationResourceCustomization();
configurationCust.setModelCustomizationUUID("72d9d1cd-f46d-447a-abdb-451d6fb05fa9");
service.getConfigurationCustomizations().add(configurationCust);
Map<ResourceKey, String> lookupKeyMap = new HashMap<>();
lookupKeyMap.put(ResourceKey.CONFIGURATION_ID, "configurationId");
String bbName = AssignFlows.FABRIC_CONFIGURATION.toString();
ServiceModel serviceModel = new ServiceModel();
serviceModel.setCurrentService(service);
ConfigurationResourceKeys configResourceKeys = prepareConfigurationResourceKeys();
configResourceKeys.setVnfcName(vnfcName);
Vnfc vnfc = new Vnfc();
vnfc.setVnfcName(vnfcName);
RequestDetails requestDetails = new RequestDetails();
doNothing().when(SPY_bbInputSetup).mapCatalogConfiguration(configuration, modelInfo, service, configResourceKeys);
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);
lookupKeyMap.put(ResourceKey.CONFIGURATION_ID, null);
SPY_bbInputSetup.populateConfiguration(parameter);
verify(SPY_bbInputSetup, times(2)).mapCatalogConfiguration(configuration, modelInfo, service, configResourceKeys);
instanceName = "configurationName2";
resourceId = "resourceId2";
lookupKeyMap.put(ResourceKey.CONFIGURATION_ID, "configurationId2");
parameter.setInstanceName(instanceName);
parameter.setResourceId(resourceId);
Configuration configuration2 = SPY_bbInputSetup.createConfiguration(lookupKeyMap, instanceName, resourceId);
doReturn(configuration2).when(SPY_bbInputSetup).createConfiguration(lookupKeyMap, instanceName, resourceId);
doNothing().when(SPY_bbInputSetup).mapCatalogConfiguration(configuration2, modelInfo, service, configResourceKeys);
SPY_bbInputSetup.populateConfiguration(parameter);
verify(SPY_bbInputSetup, times(1)).mapCatalogConfiguration(configuration2, modelInfo, service, configResourceKeys);
}
Aggregations