Search in sources :

Example 6 with CloudConfiguration

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);
}
Also used : CloudConfiguration(org.onap.so.serviceinstancebeans.CloudConfiguration) HashMap(java.util.HashMap) InfraActiveRequests(org.onap.so.db.request.beans.InfraActiveRequests) Test(org.junit.Test)

Example 7 with CloudConfiguration

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));
}
Also used : ModelInfo(org.onap.so.serviceinstancebeans.ModelInfo) RelatedInstanceList(org.onap.so.serviceinstancebeans.RelatedInstanceList) HashMap(java.util.HashMap) Service(org.onap.so.db.catalog.beans.Service) ServiceInstance(org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance) ModelInfoServiceInstance(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoServiceInstance) RequestInfo(org.onap.so.serviceinstancebeans.RequestInfo) RequestDetails(org.onap.so.serviceinstancebeans.RequestDetails) ResourceKey(org.onap.so.bpmn.servicedecomposition.entities.ResourceKey) ServiceModel(org.onap.so.bpmn.servicedecomposition.entities.ServiceModel) CloudConfiguration(org.onap.so.serviceinstancebeans.CloudConfiguration) Test(org.junit.Test)

Example 8 with CloudConfiguration

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));
}
Also used : L3Network(org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network) ModelInfo(org.onap.so.serviceinstancebeans.ModelInfo) GeneralBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock) ExecuteBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock) GeneralBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock) BuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.BuildingBlock) ServiceInstance(org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance) ModelInfoServiceInstance(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoServiceInstance) Service(org.onap.so.db.catalog.beans.Service) RequestDetails(org.onap.so.serviceinstancebeans.RequestDetails) ResourceKey(org.onap.so.bpmn.servicedecomposition.entities.ResourceKey) ExecuteBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock) CloudConfiguration(org.onap.so.serviceinstancebeans.CloudConfiguration) ConfigurationResourceKeys(org.onap.so.bpmn.servicedecomposition.entities.ConfigurationResourceKeys) BaseBBInputSetupTestHelper.prepareConfigurationResourceKeys(org.onap.so.bpmn.servicedecomposition.tasks.BaseBBInputSetupTestHelper.prepareConfigurationResourceKeys) File(java.io.File) Test(org.junit.Test)

Example 9 with CloudConfiguration

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);
}
Also used : HashMap(java.util.HashMap) ServiceInstance(org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance) ModelInfoServiceInstance(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoServiceInstance) ResourceKey(org.onap.so.bpmn.servicedecomposition.entities.ResourceKey) ExecuteBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock) CloudConfiguration(org.onap.so.serviceinstancebeans.CloudConfiguration) File(java.io.File) Test(org.junit.Test)

Example 10 with 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));
}
Also used : L3Network(org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network) ModelInfo(org.onap.so.serviceinstancebeans.ModelInfo) GeneralBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock) ModelInfoGenericVnf(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoGenericVnf) GenericVnf(org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf) ExecuteBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock) GeneralBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock) BuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.BuildingBlock) ServiceInstance(org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance) ModelInfoServiceInstance(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoServiceInstance) VfModule(org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule) ModelInfoVfModule(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoVfModule) ExecuteBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock) Service(org.onap.so.db.catalog.beans.Service) RequestDetails(org.onap.so.serviceinstancebeans.RequestDetails) ResourceKey(org.onap.so.bpmn.servicedecomposition.entities.ResourceKey) CloudConfiguration(org.onap.so.serviceinstancebeans.CloudConfiguration) ConfigurationResourceKeys(org.onap.so.bpmn.servicedecomposition.entities.ConfigurationResourceKeys) BaseBBInputSetupTestHelper.prepareConfigurationResourceKeys(org.onap.so.bpmn.servicedecomposition.tasks.BaseBBInputSetupTestHelper.prepareConfigurationResourceKeys) File(java.io.File) Test(org.junit.Test)

Aggregations

CloudConfiguration (org.onap.so.serviceinstancebeans.CloudConfiguration)42 Test (org.junit.Test)28 ServiceInstance (org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance)15 ResourceKey (org.onap.so.bpmn.servicedecomposition.entities.ResourceKey)15 RequestDetails (org.onap.so.serviceinstancebeans.RequestDetails)15 HashMap (java.util.HashMap)13 Service (org.onap.so.db.catalog.beans.Service)13 ModelInfo (org.onap.so.serviceinstancebeans.ModelInfo)13 File (java.io.File)12 ExecuteBuildingBlock (org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock)12 ModelInfoServiceInstance (org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoServiceInstance)12 GenericVnf (org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf)11 GeneralBuildingBlock (org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock)11 ServiceInstancesRequest (org.onap.so.serviceinstancebeans.ServiceInstancesRequest)10 ModelInfoGenericVnf (org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoGenericVnf)9 L3Network (org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network)8 VfModule (org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule)8 BuildingBlock (org.onap.so.bpmn.servicedecomposition.entities.BuildingBlock)7 ConfigurationResourceKeys (org.onap.so.bpmn.servicedecomposition.entities.ConfigurationResourceKeys)7 CloudConfigurationNotFoundException (org.onap.so.apihandlerinfra.infra.rest.exception.CloudConfigurationNotFoundException)6