use of org.onap.so.serviceinstancebeans.CloudConfiguration in project so by onap.
the class ServiceInstancesUnitTest method getCloudConfigurationOnReplaceVfModuleTest.
@Test
public void getCloudConfigurationOnReplaceVfModuleTest() throws ApiException {
CloudConfiguration cloudConfiguration = new CloudConfiguration();
cloudConfiguration.setTenantId("tenantId");
cloudConfiguration.setLcpCloudRegionId("lcpCloudRegionId");
String requestScope = ModelType.vfModule.toString();
HashMap<String, String> instanceIdMap = new HashMap<>();
instanceIdMap.put("vnfInstanceId", "17c10d8e-48f4-4ee6-b162-a801943df6d6");
instanceIdMap.put("vfModuleInstanceId", "17c10d8e-48f4-4ee6-b162-a801943df6d8");
InfraActiveRequests currentActiveRequest = new InfraActiveRequests();
doReturn(cloudConfiguration).when(bpmnRequestBuilder).getCloudConfigurationVfModuleReplace("17c10d8e-48f4-4ee6-b162-a801943df6d6", "17c10d8e-48f4-4ee6-b162-a801943df6d8");
CloudConfiguration result = serviceInstances.getCloudConfigurationOnReplace(requestScope, instanceIdMap, currentActiveRequest);
assertEquals(cloudConfiguration, result);
}
use of org.onap.so.serviceinstancebeans.CloudConfiguration 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.serviceinstancebeans.CloudConfiguration 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.serviceinstancebeans.CloudConfiguration in project so by onap.
the class BBInputSetupTest method testGetGBBMacroExistingServiceServiceModelNotFound.
@Test
public void testGetGBBMacroExistingServiceServiceModelNotFound() throws Exception {
ExecuteBuildingBlock executeBB = mapper.readValue(new File(RESOURCE_PATH + "ExecuteBuildingBlockSimple.json"), ExecuteBuildingBlock.class);
Map<ResourceKey, String> lookupKeyMap = new HashMap<>();
lookupKeyMap.put(ResourceKey.SERVICE_INSTANCE_ID, "si123");
org.onap.aai.domain.yang.ServiceInstance aaiServiceInstance = new org.onap.aai.domain.yang.ServiceInstance();
aaiServiceInstance.setModelVersionId("modelVersionId");
CloudConfiguration cloudConfiguration = new CloudConfiguration();
cloudConfiguration.setLcpCloudRegionId("cloudRegionId");
doReturn(aaiServiceInstance).when(SPY_bbInputSetupUtils).getAAIServiceInstanceById("si123");
doReturn(null).when(SPY_bbInputSetupUtils).getCatalogServiceByModelUUID(aaiServiceInstance.getModelVersionId());
expectedException.expect(ServiceModelNotFoundException.class);
expectedException.expectMessage("Related service instance model not found in MSO CatalogDB: model-version-id=modelVersionId");
SPY_bbInputSetup.getGBBMacroExistingService(executeBB, lookupKeyMap, "AssignVnfBB", "assign", cloudConfiguration);
}
use of org.onap.so.serviceinstancebeans.CloudConfiguration 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