use of org.onap.so.bpmn.servicedecomposition.entities.ServiceModel in project so by onap.
the class BBInputSetupTest method testGetGBBALaCarteNonServiceWithoutRelatedInstances.
@Test
public void testGetGBBALaCarteNonServiceWithoutRelatedInstances() throws Exception {
GeneralBuildingBlock expected = 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_withoutRelatedInstanceList.json"), RequestDetails.class);
Map<ResourceKey, String> lookupKeyMap = new HashMap<>();
String requestAction = "createInstance";
Service service = Mockito.mock(Service.class);
ServiceModel serviceModel = new ServiceModel();
serviceModel.setCurrentService(service);
String resourceId = "123";
ServiceInstance serviceInstance = Mockito.mock(ServiceInstance.class);
org.onap.aai.domain.yang.ServiceInstance aaiServiceInstance = new org.onap.aai.domain.yang.ServiceInstance();
aaiServiceInstance.setModelVersionId("modelVersionId");
org.onap.aai.domain.yang.CloudRegion aaiCloudRegion = Mockito.mock(org.onap.aai.domain.yang.CloudRegion.class);
String vnfType = "vnfType";
lookupKeyMap.put(ResourceKey.SERVICE_INSTANCE_ID, "instanceId");
doReturn(service).when(SPY_bbInputSetupUtils).getCatalogServiceByModelUUID(aaiServiceInstance.getModelVersionId());
doReturn(aaiServiceInstance).when(SPY_bbInputSetupUtils).getAAIServiceInstanceById("instanceId");
doNothing().when(SPY_bbInputSetup).populateObjectsOnAssignAndCreateFlows(any(BBInputSetupParameter.class));
doReturn(serviceInstance).when(SPY_bbInputSetup).getExistingServiceInstance(aaiServiceInstance);
doReturn(expected).when(SPY_bbInputSetup).populateGBBWithSIAndAdditionalInfo(any(BBInputSetupParameter.class));
GeneralBuildingBlock actual = SPY_bbInputSetup.getGBBALaCarteNonService(executeBB, requestDetails, lookupKeyMap, requestAction, resourceId, vnfType);
assertThat(actual, sameBeanAs(expected));
}
use of org.onap.so.bpmn.servicedecomposition.entities.ServiceModel in project so by onap.
the class BBInputSetupTest method testPopulateObjectsOnAssignAndCreateFlows.
@Test
public void testPopulateObjectsOnAssignAndCreateFlows() throws Exception {
String bbName = AssignFlows.SERVICE_INSTANCE.toString();
String instanceName = "instanceName";
String vnfType = "vnfType";
String resourceId = "networkId";
String productFamilyId = "productFamilyId";
String applicationId = "applicationId";
Service service = Mockito.mock(Service.class);
ServiceModel serviceModel = new ServiceModel();
serviceModel.setCurrentService(service);
ServiceInstance serviceInstance = Mockito.mock(ServiceInstance.class);
RequestDetails requestDetails = Mockito.mock(RequestDetails.class);
ModelInfo modelInfo = Mockito.mock(ModelInfo.class);
RequestInfo requestInfo = Mockito.mock(RequestInfo.class);
RelatedInstanceList[] relatedInstanceList = new RelatedInstanceList[] {};
CloudConfiguration cloudConfiguration = new CloudConfiguration();
org.onap.so.serviceinstancebeans.Platform platform = Mockito.mock(org.onap.so.serviceinstancebeans.Platform.class);
org.onap.so.serviceinstancebeans.LineOfBusiness lineOfBusiness = Mockito.mock(org.onap.so.serviceinstancebeans.LineOfBusiness.class);
Map<ResourceKey, String> lookupKeyMap = new HashMap<>();
doReturn(modelInfo).when(requestDetails).getModelInfo();
doReturn(productFamilyId).when(requestInfo).getProductFamilyId();
doReturn(requestInfo).when(requestDetails).getRequestInfo();
doReturn(instanceName).when(requestInfo).getInstanceName();
doReturn(platform).when(requestDetails).getPlatform();
doReturn(lineOfBusiness).when(requestDetails).getLineOfBusiness();
doReturn(relatedInstanceList).when(requestDetails).getRelatedInstanceList();
doReturn(cloudConfiguration).when(requestDetails).getCloudConfiguration();
doReturn(applicationId).when(requestInfo).getApplicationId();
doReturn(ModelType.network).when(modelInfo).getModelType();
BBInputSetupParameter parameter = new BBInputSetupParameter.Builder().setRequestId(REQUEST_ID).setRequestDetails(requestDetails).setService(service).setBbName(bbName).setServiceInstance(serviceInstance).setLookupKeyMap(lookupKeyMap).setResourceId(resourceId).setVnfType(vnfType).setIsReplace(false).setApplicationId(applicationId).build();
doNothing().when(SPY_bbInputSetup).populateL3Network(parameter);
SPY_bbInputSetup.populateObjectsOnAssignAndCreateFlows(parameter);
parameter.setInstanceName(instanceName);
parameter.setModelInfo(modelInfo);
verify(SPY_bbInputSetup, times(1)).populateL3Network(parameter);
assertEquals("NetworkId populated", true, lookupKeyMap.get(ResourceKey.NETWORK_ID).equalsIgnoreCase(resourceId));
doReturn(ModelType.vnf).when(modelInfo).getModelType();
resourceId = "vnfId";
doNothing().when(SPY_bbInputSetup).populateGenericVnf(parameter);
parameter.setResourceId(resourceId);
SPY_bbInputSetup.populateObjectsOnAssignAndCreateFlows(parameter);
verify(SPY_bbInputSetup, times(1)).populateGenericVnf(parameter);
assertEquals("VnfId populated", true, lookupKeyMap.get(ResourceKey.GENERIC_VNF_ID).equalsIgnoreCase(resourceId));
doReturn(ModelType.volumeGroup).when(modelInfo).getModelType();
resourceId = "volumeGroupId";
parameter.setResourceId(resourceId);
doNothing().when(SPY_bbInputSetup).populateVolumeGroup(parameter);
SPY_bbInputSetup.populateObjectsOnAssignAndCreateFlows(parameter);
verify(SPY_bbInputSetup, times(1)).populateVolumeGroup(parameter);
assertEquals("VolumeGroupId populated", true, lookupKeyMap.get(ResourceKey.VOLUME_GROUP_ID).equalsIgnoreCase(resourceId));
doReturn(ModelType.vfModule).when(modelInfo).getModelType();
resourceId = "vfModuleId";
parameter.setResourceId(resourceId);
doNothing().when(SPY_bbInputSetup).populateVfModule(parameter);
SPY_bbInputSetup.populateObjectsOnAssignAndCreateFlows(parameter);
verify(SPY_bbInputSetup, times(1)).populateVfModule(parameter);
assertEquals("VfModuleId populated", true, lookupKeyMap.get(ResourceKey.VF_MODULE_ID).equalsIgnoreCase(resourceId));
String bbNameAssignVolume = AssignFlows.VOLUME_GROUP.toString();
doReturn(ModelType.vfModule).when(modelInfo).getModelType();
resourceId = "vfModuleId";
parameter.setResourceId(resourceId);
parameter.setBbName(bbNameAssignVolume);
doNothing().when(SPY_bbInputSetup).populateVolumeGroup(parameter);
SPY_bbInputSetup.populateObjectsOnAssignAndCreateFlows(parameter);
verify(SPY_bbInputSetup, times(2)).populateVolumeGroup(parameter);
assertEquals(resourceId, lookupKeyMap.get(ResourceKey.VOLUME_GROUP_ID));
}
use of org.onap.so.bpmn.servicedecomposition.entities.ServiceModel 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.entities.ServiceModel 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.bpmn.servicedecomposition.entities.ServiceModel 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);
}
Aggregations