use of org.onap.so.bpmn.servicedecomposition.entities.ConfigurationResourceKeys in project so by onap.
the class ExecuteBuildingBlockBuilder method getConfigurationResourceKeys.
protected ConfigurationResourceKeys getConfigurationResourceKeys(Resource resource, String vnfcName) {
ConfigurationResourceKeys configurationResourceKeys = new ConfigurationResourceKeys();
Optional.ofNullable(vnfcName).ifPresent(configurationResourceKeys::setVnfcName);
configurationResourceKeys.setCvnfcCustomizationUUID(resource.getCvnfModuleCustomizationId());
configurationResourceKeys.setVfModuleCustomizationUUID(resource.getVfModuleCustomizationId());
configurationResourceKeys.setVnfResourceCustomizationUUID(resource.getVnfCustomizationId());
return configurationResourceKeys;
}
use of org.onap.so.bpmn.servicedecomposition.entities.ConfigurationResourceKeys 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.ConfigurationResourceKeys in project so by onap.
the class BBInputSetupTest method test_getGBBMacroNoUserParamsExistingService_forCatalogNetwork.
@Test
public void test_getGBBMacroNoUserParamsExistingService_forCatalogNetwork() throws Exception {
// given
String requestAction = "unassignInstance";
GeneralBuildingBlock gBB = mapper.readValue(new File(RESOURCE_PATH + "GeneralBuildingBlockExpected.json"), GeneralBuildingBlock.class);
L3Network network = new L3Network();
network.setNetworkId("networkId");
gBB.getServiceInstance().getNetworks().add(network);
ServiceInstance serviceInstance = gBB.getServiceInstance();
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);
Map<ResourceKey, String> lookupKeyMap = prepareLookupKeyMap();
Service service = Mockito.mock(Service.class);
CloudConfiguration cloudConfiguration = new CloudConfiguration();
cloudConfiguration.setLcpCloudRegionId("cloudRegionId");
org.onap.aai.domain.yang.ServiceInstance aaiServiceInstance = new org.onap.aai.domain.yang.ServiceInstance();
org.onap.aai.domain.yang.L3Network aaiNetwork = new org.onap.aai.domain.yang.L3Network();
aaiNetwork.setModelCustomizationId("modelCustId");
ConfigurationResourceKeys configResourceKeys = prepareConfigurationResourceKeys();
executeBB.setConfigurationResourceKeys(configResourceKeys).setRequestDetails(requestDetails);
BuildingBlock buildingBlock = executeBB.getBuildingBlock();
buildingBlock.setBpmnFlowName("DeleteNetworkBB").setKey("ab153b6e-c364-44c0-bef6-1f2982117f04");
aaiServiceInstance.setModelVersionId("modelVersionId");
doReturn(service).when(SPY_bbInputSetupUtils).getCatalogServiceByModelUUID(aaiServiceInstance.getModelVersionId());
doReturn(aaiServiceInstance).when(SPY_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(aaiNetwork).when(SPY_bbInputSetupUtils).getAAIL3Network(network.getNetworkId());
doNothing().when(SPY_bbInputSetup).mapCatalogNetwork(any(L3Network.class), any(ModelInfo.class), any(Service.class));
// when
SPY_bbInputSetup.getGBBMacroExistingService(executeBB, lookupKeyMap, executeBB.getBuildingBlock().getBpmnFlowName(), requestAction, null);
// then
verify(SPY_bbInputSetup, times(1)).mapCatalogNetwork(any(L3Network.class), any(ModelInfo.class), any(Service.class));
}
use of org.onap.so.bpmn.servicedecomposition.entities.ConfigurationResourceKeys in project so by onap.
the class BBInputSetupTest method test_getGBBMacroNoUserParamsExistingService_forUnassignVolumeGroupBB.
@Test
public void test_getGBBMacroNoUserParamsExistingService_forUnassignVolumeGroupBB() throws Exception {
// given
String requestAction = "unassignInstance";
GeneralBuildingBlock gBB = mapper.readValue(new File(RESOURCE_PATH + "GeneralBuildingBlockExpected.json"), GeneralBuildingBlock.class);
L3Network network = new L3Network();
network.setNetworkId("networkId");
gBB.getServiceInstance().getNetworks().add(network);
ServiceInstance serviceInstance = gBB.getServiceInstance();
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);
Map<ResourceKey, String> lookupKeyMap = prepareLookupKeyMap();
Service service = Mockito.mock(Service.class);
org.onap.aai.domain.yang.ServiceInstance aaiServiceInstance = new org.onap.aai.domain.yang.ServiceInstance();
GenericVnf vnf = new GenericVnf();
vnf.setVnfId("vnfId");
gBB.getServiceInstance().getVnfs().add(vnf);
org.onap.aai.domain.yang.GenericVnf aaiVnf = new org.onap.aai.domain.yang.GenericVnf();
aaiVnf.setModelCustomizationId("modelCustId");
VfModule vfModule = new VfModule();
vfModule.setVfModuleId("vfModuleId");
gBB.getServiceInstance().getVnfs().get(0).getVfModules().add(vfModule);
CloudRegion cloudRegion = new CloudRegion();
cloudRegion.setLcpCloudRegionId("cloudRegionId");
cloudRegion.setCloudOwner("CloudOwner");
VolumeGroup volumeGroup = new VolumeGroup();
volumeGroup.setVolumeGroupId("volumeGroupId");
gBB.getServiceInstance().getVnfs().get(0).getVolumeGroups().add(volumeGroup);
org.onap.aai.domain.yang.VolumeGroup aaiVolumeGroup = new org.onap.aai.domain.yang.VolumeGroup();
aaiVolumeGroup.setModelCustomizationId("modelCustId");
ConfigurationResourceKeys configResourceKeys = prepareConfigurationResourceKeys();
executeBB.setConfigurationResourceKeys(configResourceKeys).setRequestDetails(requestDetails);
BuildingBlock buildingBlock = executeBB.getBuildingBlock();
buildingBlock.setBpmnFlowName("UnassignVolumeGroupBB").setKey("72d9d1cd-f46d-447a-abdb-451d6fb05fa8");
aaiServiceInstance.setModelVersionId("modelVersionId");
doReturn(service).when(SPY_bbInputSetupUtils).getCatalogServiceByModelUUID(aaiServiceInstance.getModelVersionId());
doReturn(aaiServiceInstance).when(SPY_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(aaiVnf).when(SPY_bbInputSetupUtils).getAAIGenericVnf(vnf.getVnfId());
doNothing().when(SPY_bbInputSetup).mapCatalogVnf(any(GenericVnf.class), any(ModelInfo.class), any(Service.class));
doReturn(aaiVolumeGroup).when(SPY_bbInputSetupUtils).getAAIVolumeGroup(cloudRegion.getCloudOwner(), cloudRegion.getLcpCloudRegionId(), volumeGroup.getVolumeGroupId());
doReturn(Optional.of(cloudRegion)).when(SPY_cloudInfoFromAAI).getCloudInfoFromAAI(gBB.getServiceInstance());
// when
SPY_bbInputSetup.getGBBMacroExistingService(executeBB, lookupKeyMap, executeBB.getBuildingBlock().getBpmnFlowName(), requestAction, null);
// then
verify(SPY_bbInputSetup, times(1)).mapCatalogVnf(any(GenericVnf.class), any(ModelInfo.class), any(Service.class));
verify(SPY_bbInputSetup, times(1)).mapCatalogVolumeGroup(isA(VolumeGroup.class), isA(ModelInfo.class), isA(Service.class), isA(String.class));
}
use of org.onap.so.bpmn.servicedecomposition.entities.ConfigurationResourceKeys in project so by onap.
the class BBInputSetupTest method test_getGBBMacroNoUserParamsExistingService_forControllerExecutionBB_VFModule.
@Test
public void test_getGBBMacroNoUserParamsExistingService_forControllerExecutionBB_VFModule() throws Exception {
// given
String requestAction = "unassignInstance";
GeneralBuildingBlock gBB = mapper.readValue(new File(RESOURCE_PATH + "GeneralBuildingBlockExpected.json"), GeneralBuildingBlock.class);
L3Network network = new L3Network();
network.setNetworkId("networkId");
gBB.getServiceInstance().getNetworks().add(network);
ServiceInstance serviceInstance = gBB.getServiceInstance();
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);
Map<ResourceKey, String> lookupKeyMap = prepareLookupKeyMap();
Service service = Mockito.mock(Service.class);
CloudConfiguration cloudConfiguration = new CloudConfiguration();
cloudConfiguration.setLcpCloudRegionId("cloudRegionId");
org.onap.aai.domain.yang.ServiceInstance aaiServiceInstance = new org.onap.aai.domain.yang.ServiceInstance();
org.onap.aai.domain.yang.L3Network aaiNetwork = new org.onap.aai.domain.yang.L3Network();
aaiNetwork.setModelCustomizationId("modelCustId");
GenericVnf vnf = new GenericVnf();
vnf.setVnfId("vnfId");
gBB.getServiceInstance().getVnfs().add(vnf);
org.onap.aai.domain.yang.GenericVnf aaiVnf = new org.onap.aai.domain.yang.GenericVnf();
aaiVnf.setModelCustomizationId("modelCustId");
VfModule vfModule = new VfModule();
vfModule.setVfModuleId("vfModuleId");
gBB.getServiceInstance().getVnfs().get(0).getVfModules().add(vfModule);
org.onap.aai.domain.yang.VfModule aaiVfModule = new org.onap.aai.domain.yang.VfModule();
aaiVfModule.setModelCustomizationId("modelCustId");
ConfigurationResourceKeys configResourceKeys = prepareConfigurationResourceKeys();
executeBB.setConfigurationResourceKeys(configResourceKeys).setRequestDetails(requestDetails);
BuildingBlock buildingBlock = executeBB.getBuildingBlock();
buildingBlock.setBpmnFlowName("ControllerExecutionBB").setKey("a25e8e8c-58b8-4eec-810c-97dcc1f5cb7f");
buildingBlock.setBpmnScope("VfModule");
aaiServiceInstance.setModelVersionId("modelVersionId");
doReturn(service).when(SPY_bbInputSetupUtils).getCatalogServiceByModelUUID(aaiServiceInstance.getModelVersionId());
doReturn(aaiServiceInstance).when(SPY_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(aaiVnf).when(SPY_bbInputSetupUtils).getAAIGenericVnf(vnf.getVnfId());
doNothing().when(SPY_bbInputSetup).mapCatalogVnf(any(GenericVnf.class), any(ModelInfo.class), any(Service.class));
doReturn(aaiVfModule).when(SPY_bbInputSetupUtils).getAAIVfModule(vnf.getVnfId(), vfModule.getVfModuleId());
// when
SPY_bbInputSetup.getGBBMacroExistingService(executeBB, lookupKeyMap, executeBB.getBuildingBlock().getBpmnFlowName(), requestAction, cloudConfiguration);
// then
verify(SPY_bbInputSetup, times(1)).mapCatalogVnf(any(GenericVnf.class), any(ModelInfo.class), any(Service.class));
verify(SPY_bbInputSetup, times(1)).mapCatalogVfModule(any(VfModule.class), any(ModelInfo.class), any(Service.class), any(String.class));
}
Aggregations