Search in sources :

Example 91 with Service

use of org.onap.so.db.catalog.beans.Service in project so by onap.

the class BBInputSetupTest method testPopulateVfModule.

@Test
public void testPopulateVfModule() throws Exception {
    String vnfId = "vnfId";
    String vfModuleId = "vfModuleId";
    String volumeGroupId = "volumeGroupId";
    String vfModuleCustomizationId = "vfModuleCustomizationId";
    ModelInfo modelInfo = new ModelInfo();
    modelInfo.setModelCustomizationId(vfModuleCustomizationId);
    Service service = new Service();
    ServiceModel serviceModel = new ServiceModel();
    serviceModel.setCurrentService(service);
    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);
    String resourceId = vfModuleId;
    RelatedInstanceList[] relatedInstanceList = null;
    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));
    SPY_bbInputSetup.populateVfModule(new BBInputSetupParameter.Builder().setRequestId(REQUEST_ID).setModelInfo(modelInfo).setService(service).setBbName(bbName).setServiceInstance(serviceInstance).setLookupKeyMap(lookupKeyMap).setResourceId(resourceId).setRelatedInstanceList(relatedInstanceList).setInstanceName(instanceName).setInstanceParams(instanceParams).setCloudConfiguration(cloudConfiguration).setServiceModel(serviceModel).build());
    verify(SPY_bbInputSetup, times(3)).mapCatalogVfModule(isA(VfModule.class), isA(ModelInfo.class), isA(Service.class), 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));
}
Also used : ModelInfo(org.onap.so.serviceinstancebeans.ModelInfo) ModelInfoGenericVnf(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoGenericVnf) GenericVnf(org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf) HashMap(java.util.HashMap) RelatedInstanceList(org.onap.so.serviceinstancebeans.RelatedInstanceList) AAIFluentTypeBuilder(org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder) 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) ServiceModel(org.onap.so.bpmn.servicedecomposition.entities.ServiceModel) VolumeGroup(org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup) Service(org.onap.so.db.catalog.beans.Service) ResourceKey(org.onap.so.bpmn.servicedecomposition.entities.ResourceKey) CloudConfiguration(org.onap.so.serviceinstancebeans.CloudConfiguration) Map(java.util.Map) BaseBBInputSetupTestHelper.prepareLookupKeyMap(org.onap.so.bpmn.servicedecomposition.tasks.BaseBBInputSetupTestHelper.prepareLookupKeyMap) HashMap(java.util.HashMap) Test(org.junit.Test)

Example 92 with Service

use of org.onap.so.db.catalog.beans.Service in project so by onap.

the class BBInputSetupTest method testGetServiceInstanceHelperCreateScenarioExistingNoNameButWithIdDifferentModel.

@Test
public void testGetServiceInstanceHelperCreateScenarioExistingNoNameButWithIdDifferentModel() throws Exception {
    RequestDetails requestDetails = new RequestDetails();
    RequestInfo requestInfo = new RequestInfo();
    requestDetails.setRequestInfo(requestInfo);
    Customer customer = new Customer();
    String serviceInstanceId = "SharansInstanceId";
    boolean aLaCarte = true;
    Service service = new Service();
    service.setModelUUID("modelUUID");
    ServiceInstance expected = new ServiceInstance();
    org.onap.aai.domain.yang.ServiceInstance serviceInstanceAAI = new org.onap.aai.domain.yang.ServiceInstance();
    serviceInstanceAAI.setModelVersionId("modelUUIDDifferent");
    Map<ResourceKey, String> lookupKeyMap = new HashMap<>();
    String bbName = "ActivateServiceInstanceBB";
    Service differentService = new Service();
    differentService.setModelUUID("modelUUIDDifferent");
    doReturn(serviceInstanceAAI).when(SPY_bbInputSetupUtils).getAAIServiceInstanceById(serviceInstanceId);
    ServiceInstance actual = SPY_bbInputSetup.getServiceInstanceHelper(requestDetails, customer, null, null, lookupKeyMap, serviceInstanceId, aLaCarte, service, bbName);
    assertThat(actual, sameBeanAs(expected));
}
Also used : Customer(org.onap.so.bpmn.servicedecomposition.bbobjects.Customer) 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) Test(org.junit.Test)

Example 93 with Service

use of org.onap.so.db.catalog.beans.Service in project so by onap.

the class BBInputSetupTest method test_getGBBMacroNoUserParamsExistingService_forUnassignVfModuleBB.

@Test
public void test_getGBBMacroNoUserParamsExistingService_forUnassignVfModuleBB() 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("UnassignVfModuleBB").setKey("a25e8e8c-58b8-4eec-810c-97dcc1f5cb7f");
    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)

Example 94 with Service

use of org.onap.so.db.catalog.beans.Service in project so by onap.

the class BBInputSetupTest method testPopulateL3Network.

@Test
public void testPopulateL3Network() throws JsonParseException, JsonMappingException, IOException {
    String instanceName = "networkName";
    ModelInfo modelInfo = new ModelInfo();
    modelInfo.setModelType(ModelType.network);
    ServiceInstance serviceInstance = new ServiceInstance();
    L3Network network = new L3Network();
    network.setNetworkId("networkId");
    network.setNetworkName("networkName");
    serviceInstance.getNetworks().add(network);
    String resourceId = "123";
    // Mock service
    Service service = mapper.readValue(new File(RESOURCE_PATH + "CatalogDBService_getServiceInstanceNOAAIInput.json"), Service.class);
    Map<ResourceKey, String> lookupKeyMap = new HashMap<>();
    lookupKeyMap.put(ResourceKey.NETWORK_ID, "networkId");
    String bbName = AssignFlows.NETWORK_A_LA_CARTE.toString();
    doNothing().when(SPY_bbInputSetup).mapCatalogNetwork(network, modelInfo, service);
    BBInputSetupParameter parameter = new BBInputSetupParameter.Builder().setRequestId(REQUEST_ID).setInstanceName(instanceName).setModelInfo(modelInfo).setService(service).setBbName(bbName).setServiceInstance(serviceInstance).setLookupKeyMap(lookupKeyMap).setResourceId(resourceId).build();
    SPY_bbInputSetup.populateL3Network(parameter);
    lookupKeyMap.put(ResourceKey.NETWORK_ID, null);
    SPY_bbInputSetup.populateL3Network(parameter);
    verify(SPY_bbInputSetup, times(1)).mapCatalogNetwork(network, modelInfo, service);
    instanceName = "networkName2";
    L3Network network2 = SPY_bbInputSetup.createNetwork(lookupKeyMap, instanceName, resourceId, null, parameter);
    SPY_bbInputSetup.populateL3Network(parameter);
    verify(SPY_bbInputSetup, times(2)).mapCatalogNetwork(network2, modelInfo, service);
}
Also used : L3Network(org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network) ModelInfo(org.onap.so.serviceinstancebeans.ModelInfo) HashMap(java.util.HashMap) ServiceInstance(org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance) ModelInfoServiceInstance(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoServiceInstance) Service(org.onap.so.db.catalog.beans.Service) File(java.io.File) ResourceKey(org.onap.so.bpmn.servicedecomposition.entities.ResourceKey) Test(org.junit.Test)

Example 95 with Service

use of org.onap.so.db.catalog.beans.Service in project so by onap.

the class BBInputSetupTest method testgetGBBMacroNoUserParamsDeactivateInstnace.

@Test
public void testgetGBBMacroNoUserParamsDeactivateInstnace() throws Exception {
    String resourceId = "123";
    String vnfType = "vnfType";
    String requestAction = "deactivateInstance";
    Service service = Mockito.mock(Service.class);
    GeneralBuildingBlock gBB = 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_serviceMacro.json"), RequestDetails.class);
    requestDetails.getRequestParameters().setUserParams(null);
    org.onap.aai.domain.yang.GenericVnf aaiVnf = new org.onap.aai.domain.yang.GenericVnf();
    aaiVnf.setModelCustomizationId("modelCustId");
    Map<ResourceKey, String> lookupKeyMap = new HashMap<>();
    lookupKeyMap.put(ResourceKey.NETWORK_ID, "networkId");
    lookupKeyMap.put(ResourceKey.GENERIC_VNF_ID, "vnfId");
    lookupKeyMap.put(ResourceKey.VF_MODULE_ID, "vfModuleId");
    lookupKeyMap.put(ResourceKey.VOLUME_GROUP_ID, "volumeGroupId");
    lookupKeyMap.put(ResourceKey.SERVICE_INSTANCE_ID, "serviceInstanceId");
    BuildingBlock buildingBlock = executeBB.getBuildingBlock();
    buildingBlock.setBpmnFlowName("DeactivateServiceInstanceBB").setKey("3c40d244-808e-42ca-b09a-256d83d19d0a");
    doReturn(gBB).when(SPY_bbInputSetup).getGBBALaCarteService(executeBB, requestDetails, lookupKeyMap, requestAction, lookupKeyMap.get(ResourceKey.SERVICE_INSTANCE_ID));
    doReturn(service).when(SPY_bbInputSetupUtils).getCatalogServiceByModelUUID(gBB.getServiceInstance().getModelInfoServiceInstance().getModelUuid());
    GeneralBuildingBlock actual = SPY_bbInputSetup.getGBBMacro(executeBB, requestDetails, lookupKeyMap, requestAction, resourceId, vnfType);
    assertThat(actual, sameBeanAs(gBB));
}
Also used : 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) HashMap(java.util.HashMap) 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) File(java.io.File) Test(org.junit.Test)

Aggregations

Service (org.onap.so.db.catalog.beans.Service)171 Test (org.junit.Test)135 RequestDetails (org.onap.so.serviceinstancebeans.RequestDetails)57 File (java.io.File)48 ServiceInstance (org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance)47 ResourceKey (org.onap.so.bpmn.servicedecomposition.entities.ResourceKey)46 ModelInfoServiceInstance (org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoServiceInstance)40 ArrayList (java.util.ArrayList)39 HashMap (java.util.HashMap)37 ModelInfo (org.onap.so.serviceinstancebeans.ModelInfo)37 ExecuteBuildingBlock (org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock)36 GeneralBuildingBlock (org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock)29 ServiceRecipe (org.onap.so.db.catalog.beans.ServiceRecipe)24 GenericVnf (org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf)22 ModelInfoGenericVnf (org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoGenericVnf)19 BuildingBlock (org.onap.so.bpmn.servicedecomposition.entities.BuildingBlock)18 ConfigurationResourceKeys (org.onap.so.bpmn.servicedecomposition.entities.ConfigurationResourceKeys)18 NetworkResourceCustomization (org.onap.so.db.catalog.beans.NetworkResourceCustomization)18 VnfResourceCustomization (org.onap.so.db.catalog.beans.VnfResourceCustomization)18 CloudConfiguration (org.onap.so.serviceinstancebeans.CloudConfiguration)18