use of org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance in project so by onap.
the class BBInputSetupExistingServiceTest method test_getGBBMacro_getGBBMacroExistingService_shouldBeCalled.
@Test
public void test_getGBBMacro_getGBBMacroExistingService_shouldBeCalled() throws Exception {
// given
String resourceId = "123";
String vnfType = "vnfType";
String requestAction = this.requestAction;
Service service = Mockito.mock(Service.class);
GeneralBuildingBlock gBB = mapper.readValue(new File(RESOURCE_PATH + "GeneralBuildingBlockExpected.json"), GeneralBuildingBlock.class);
ServiceInstance serviceInstance = gBB.getServiceInstance();
Map<ResourceKey, String> lookupKeyMap = prepareLookupKeyMap();
org.onap.aai.domain.yang.ServiceInstance aaiServiceInstance = new org.onap.aai.domain.yang.ServiceInstance();
aaiServiceInstance.setModelVersionId("modelVersionId");
CloudConfiguration cloudConfig = new CloudConfiguration();
cloudConfig.setLcpCloudRegionId("lcpCloudRegionId");
CloudRegion aaiCloudRegion = Mockito.mock(CloudRegion.class);
RequestDetails requestDetails = mapper.readValue(new File(RESOURCE_PATH + "RequestDetailsInput_serviceMacro.json"), RequestDetails.class);
requestDetails.getRequestParameters().setUserParams(null);
requestDetails.setCloudConfiguration(cloudConfig);
ExecuteBuildingBlock executeBB = mapper.readValue(new File(RESOURCE_PATH + "ExecuteBuildingBlockSimple.json"), ExecuteBuildingBlock.class);
executeBB.setRequestDetails(requestDetails);
BuildingBlock buildingBlock = executeBB.getBuildingBlock();
buildingBlock.setBpmnFlowName(this.bpmnFlowName).setKey(this.key);
doReturn(service).when(bbInputSetupUtils).getCatalogServiceByModelUUID(aaiServiceInstance.getModelVersionId());
doReturn(aaiServiceInstance).when(bbInputSetupUtils).getAAIServiceInstanceById(lookupKeyMap.get(ResourceKey.SERVICE_INSTANCE_ID));
doReturn(serviceInstance).when(SPY_bbInputSetup).getExistingServiceInstance(aaiServiceInstance);
doReturn(gBB).when(SPY_bbInputSetup).populateGBBWithSIAndAdditionalInfo(any(BBInputSetupParameter.class));
doReturn(aaiCloudRegion).when(bbInputSetupUtils).getCloudRegion(requestDetails.getCloudConfiguration());
// when
SPY_bbInputSetup.getGBBMacro(executeBB, requestDetails, lookupKeyMap, requestAction, resourceId, vnfType);
// then
verify(SPY_bbInputSetup, times(1)).getGBBMacroExistingService(isA(ExecuteBuildingBlock.class), any(), any(String.class), isA(String.class), isA(CloudConfiguration.class));
}
use of org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance 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.ServiceInstance 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.bbobjects.ServiceInstance in project so by onap.
the class BBInputSetupMapperLayerTest method testMapAAIServiceInstanceIntoServiceInstance.
@Test
public void testMapAAIServiceInstanceIntoServiceInstance() throws IOException {
ServiceInstance expected = mapper.readValue(new File(RESOURCE_PATH + "ServiceInstance_aaiServiceInstanceToSI.json"), ServiceInstance.class);
org.onap.aai.domain.yang.ServiceInstance serviceInstanceAAI = mapper.readValue(new File(RESOURCE_PATH + "ServiceInstanceAAIInput.json"), org.onap.aai.domain.yang.ServiceInstance.class);
ServiceInstance actual = bbInputSetupMapperLayer.mapAAIServiceInstanceIntoServiceInstance(serviceInstanceAAI);
assertThat(actual, sameBeanAs(expected));
}
use of org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance 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