use of org.onap.so.serviceinstancebeans.ModelInfo in project so by onap.
the class BBInputSetupTest method testPopulateGenericVnfWhereVnfTypeIsNull.
@Test
public void testPopulateGenericVnfWhereVnfTypeIsNull() throws JsonParseException, JsonMappingException, IOException {
org.onap.so.serviceinstancebeans.Platform platform = new org.onap.so.serviceinstancebeans.Platform();
org.onap.so.serviceinstancebeans.LineOfBusiness lineOfBusiness = new org.onap.so.serviceinstancebeans.LineOfBusiness();
String instanceName = "vnfName";
ModelInfo modelInfo = new ModelInfo();
modelInfo.setModelType(ModelType.vnf);
ServiceInstance serviceInstance = new ServiceInstance();
GenericVnf vnf = new GenericVnf();
vnf.setVnfId("genericVnfId");
vnf.setVnfName("vnfName");
serviceInstance.getVnfs().add(vnf);
String vnfType = null;
RequestDetails requestDetails = mapper.readValue(new File(RESOURCE_PATH + "RequestDetails_CreateVnf.json"), RequestDetails.class);
Service service = mapper.readValue(new File(RESOURCE_PATH + "CatalogDBService_getServiceInstanceNOAAIInput.json"), Service.class);
Map<ResourceKey, String> lookupKeyMap = new HashMap<>();
lookupKeyMap.put(ResourceKey.GENERIC_VNF_ID, "genericVnfId");
String bbName = AssignFlows.VNF.toString();
Platform expectedPlatform = new Platform();
LineOfBusiness expectedLineOfBusiness = new LineOfBusiness();
String resourceId = "123";
String applicationId = "applicationId";
doReturn(expectedPlatform).when(bbInputSetupMapperLayer).mapRequestPlatform(platform);
doReturn(expectedLineOfBusiness).when(bbInputSetupMapperLayer).mapRequestLineOfBusiness(lineOfBusiness);
org.onap.aai.domain.yang.GenericVnf vnfAAI = new org.onap.aai.domain.yang.GenericVnf();
vnfAAI.setModelCustomizationId("modelCustId");
doReturn(vnfAAI).when(SPY_bbInputSetupUtils).getAAIGenericVnf(vnf.getVnfId());
doNothing().when(SPY_bbInputSetup).mapCatalogVnf(vnf, modelInfo, service);
org.onap.aai.domain.yang.InstanceGroup instanceGroupAAI = new org.onap.aai.domain.yang.InstanceGroup();
doReturn(instanceGroupAAI).when(SPY_bbInputSetupUtils).getAAIInstanceGroup(any());
org.onap.so.db.catalog.beans.InstanceGroup catalogInstanceGroup = new org.onap.so.db.catalog.beans.InstanceGroup();
doReturn(catalogInstanceGroup).when(SPY_bbInputSetupUtils).getCatalogInstanceGroup(any());
BBInputSetupParameter parameter = new BBInputSetupParameter.Builder().setRequestId(REQUEST_ID).setModelInfo(modelInfo).setInstanceName(instanceName).setPlatform(platform).setLineOfBusiness(lineOfBusiness).setService(service).setBbName(bbName).setServiceInstance(serviceInstance).setLookupKeyMap(lookupKeyMap).setRelatedInstanceList(requestDetails.getRelatedInstanceList()).setResourceId(resourceId).setVnfType(vnfType).setProductFamilyId(requestDetails.getRequestInfo().getProductFamilyId()).build();
SPY_bbInputSetup.populateGenericVnf(parameter);
lookupKeyMap.put(ResourceKey.GENERIC_VNF_ID, null);
SPY_bbInputSetup.populateGenericVnf(parameter);
verify(SPY_bbInputSetup, times(1)).mapCatalogVnf(vnf, modelInfo, service);
instanceName = "vnfName2";
GenericVnf vnf2 = SPY_bbInputSetup.createGenericVnf(lookupKeyMap, instanceName, platform, lineOfBusiness, resourceId, vnfType, null, requestDetails.getRequestInfo().getProductFamilyId(), applicationId);
org.onap.aai.domain.yang.GenericVnf vnf2AAI = new org.onap.aai.domain.yang.GenericVnf();
vnfAAI.setModelCustomizationId("modelCustId2");
doReturn(vnf2AAI).when(SPY_bbInputSetupUtils).getAAIGenericVnf(vnf2.getVnfId());
doNothing().when(SPY_bbInputSetup).mapCatalogVnf(vnf2, modelInfo, service);
doNothing().when(SPY_bbInputSetup).mapNetworkCollectionInstanceGroup(vnf2, "{instanceGroupId}");
SPY_bbInputSetup.populateGenericVnf(parameter);
verify(SPY_bbInputSetup, times(2)).mapCatalogVnf(vnf2, modelInfo, service);
verify(SPY_bbInputSetup, times(2)).mapNetworkCollectionInstanceGroup(vnf2, "{instanceGroupId}");
verify(SPY_bbInputSetup, times(1)).mapVnfcCollectionInstanceGroup(vnf2, modelInfo, service);
}
use of org.onap.so.serviceinstancebeans.ModelInfo in project so by onap.
the class BBInputSetupTest method testPopulateVolumeGroup.
@Test
public void testPopulateVolumeGroup() throws Exception {
RequestDetails requestDetails = new RequestDetails();
RelatedInstanceList ril = new RelatedInstanceList();
RelatedInstance ri = new RelatedInstance();
ModelInfo mi = new ModelInfo();
mi.setModelType(ModelType.vnf);
mi.setModelCustomizationUuid("vnfModelCustomizationUUID");
mi.setModelCustomizationId("vnfModelCustomizationUUID");
ri.setModelInfo(mi);
ril.setRelatedInstance(ri);
requestDetails.setRelatedInstanceList(new RelatedInstanceList[] { ril });
ModelInfo modelInfo = new ModelInfo();
modelInfo.setModelCustomizationId("volumeGroupCustId");
RequestInfo reqInfo = new RequestInfo();
reqInfo.setInstanceName("volumeGroupName");
requestDetails.setModelInfo(modelInfo);
requestDetails.setRequestInfo(reqInfo);
ServiceInstance serviceInstance = new ServiceInstance();
GenericVnf vnf = new GenericVnf();
vnf.setVnfId("genericVnfId");
VolumeGroup vg = new VolumeGroup();
vg.setVolumeGroupName("volumeGroupName");
vg.setVolumeGroupId("volumeGroupId");
vg.setModelInfoVfModule(new ModelInfoVfModule());
vg.getModelInfoVfModule().setModelCustomizationUUID("volumeGroupCustId");
vnf.getVolumeGroups().add(vg);
serviceInstance.getVnfs().add(vnf);
Service service = mapper.readValue(new File(RESOURCE_PATH + "CatalogDBService_getServiceInstanceNOAAIInput.json"), Service.class);
Map<ResourceKey, String> lookupKeyMap = new HashMap<>();
lookupKeyMap.put(ResourceKey.GENERIC_VNF_ID, "genericVnfId");
ServiceModel serviceModel = new ServiceModel();
serviceModel.setCurrentService(service);
String bbName = AssignFlows.VOLUME_GROUP.toString();
String resourceId = "123";
doNothing().when(SPY_bbInputSetup).mapCatalogVolumeGroup(isA(VolumeGroup.class), eq(modelInfo), eq(service), eq("vnfModelCustomizationUUID"));
org.onap.aai.domain.yang.GenericVnf aaiGenericVnf = new org.onap.aai.domain.yang.GenericVnf();
aaiGenericVnf.setModelCustomizationId("vnfModelCustomizationUUID");
doReturn(aaiGenericVnf).when(SPY_bbInputSetupUtils).getAAIGenericVnf(vnf.getVnfId());
lookupKeyMap.put(ResourceKey.VOLUME_GROUP_ID, "volumeGroupId");
BBInputSetupParameter parameter = new BBInputSetupParameter.Builder().setRequestId(REQUEST_ID).setModelInfo(modelInfo).setService(service).setBbName(bbName).setServiceInstance(serviceInstance).setLookupKeyMap(lookupKeyMap).setResourceId(resourceId).setRequestDetails(requestDetails).setInstanceName(reqInfo.getInstanceName()).setServiceModel(serviceModel).build();
SPY_bbInputSetup.populateVolumeGroup(parameter);
verify(SPY_bbInputSetup, times(1)).mapCatalogVolumeGroup(eq(vg), isA(ModelInfo.class), eq(service), eq("vnfModelCustomizationUUID"));
vnf.getVolumeGroups().clear();
SPY_bbInputSetup.populateVolumeGroup(parameter);
verify(SPY_bbInputSetup, times(1)).mapCatalogVolumeGroup(vnf.getVolumeGroups().get(0), modelInfo, service, "vnfModelCustomizationUUID");
}
use of org.onap.so.serviceinstancebeans.ModelInfo in project so by onap.
the class BBInputSetupTest method testMapCatalogVnf.
@Test
public void testMapCatalogVnf() {
ModelInfoGenericVnf modelInfoGenericVnf = new ModelInfoGenericVnf();
GenericVnf genericVnf = new GenericVnf();
RequestDetails requestDetails = new RequestDetails();
ModelInfo modelInfo = new ModelInfo();
modelInfo.setModelCustomizationUuid("modelCustomizationUUID");
requestDetails.setModelInfo(modelInfo);
Service service = new Service();
VnfResourceCustomization resourceCust = new VnfResourceCustomization();
resourceCust.setModelCustomizationUUID("vnfModelCustomizationUUID");
service.getVnfCustomizations().add(resourceCust);
resourceCust.setModelCustomizationUUID("modelCustomizationUUID");
doReturn(modelInfoGenericVnf).when(bbInputSetupMapperLayer).mapCatalogVnfToVnf(resourceCust);
SPY_bbInputSetup.mapCatalogVnf(genericVnf, modelInfo, service);
assertEquals(modelInfoGenericVnf, genericVnf.getModelInfoGenericVnf());
}
use of org.onap.so.serviceinstancebeans.ModelInfo 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.serviceinstancebeans.ModelInfo in project so by onap.
the class BBInputSetupTest method testMapVnfcCollectionInstanceGroup.
@Test
public void testMapVnfcCollectionInstanceGroup() {
VnfResourceCustomization vnfResourceCust = Mockito.mock(VnfResourceCustomization.class);
GenericVnf genericVnf = new GenericVnf();
ModelInfo modelInfo = Mockito.mock(ModelInfo.class);
Service service = Mockito.mock(Service.class);
org.onap.so.db.catalog.beans.InstanceGroup instanceGroup = new org.onap.so.db.catalog.beans.InstanceGroup();
instanceGroup.setModelUUID("modelUUID");
List<VnfcInstanceGroupCustomization> vnfcInstanceGroups = new ArrayList<>();
VnfcInstanceGroupCustomization vnfcInstanceGroupCust = new VnfcInstanceGroupCustomization();
vnfcInstanceGroupCust.setInstanceGroup(instanceGroup);
vnfcInstanceGroupCust.setFunction("function");
vnfcInstanceGroupCust.setDescription("description");
vnfcInstanceGroups.add(vnfcInstanceGroupCust);
ModelInfoInstanceGroup modelInfoInstanceGroup = new ModelInfoInstanceGroup();
modelInfoInstanceGroup.setModelUUID("modelUUID");
doReturn(vnfResourceCust).when(SPY_bbInputSetup).getVnfResourceCustomizationFromService(modelInfo, service);
doReturn(vnfcInstanceGroups).when(vnfResourceCust).getVnfcInstanceGroupCustomizations();
doReturn(instanceGroup).when(SPY_bbInputSetupUtils).getCatalogInstanceGroup("modelUUID");
doReturn(modelInfoInstanceGroup).when(bbInputSetupMapperLayer).mapCatalogInstanceGroupToInstanceGroup(null, instanceGroup);
SPY_bbInputSetup.mapVnfcCollectionInstanceGroup(genericVnf, modelInfo, service);
assertEquals("Instance Group was created", true, genericVnf.getInstanceGroups().size() == 1);
}
Aggregations