Search in sources :

Example 71 with VfModule

use of org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule 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 72 with VfModule

use of org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule in project so by onap.

the class BBInputSetupTest method testMapCatalogVfModuleIfNoVfUnderVnf.

@Test
public void testMapCatalogVfModuleIfNoVfUnderVnf() {
    String vnfModelCustomizationUUID = "vnfResourceCustUUID";
    String vfModuleCustomizationUUID = "vfModelCustomizationUUID";
    VfModule vfModule = new VfModule();
    ModelInfo modelInfo = new ModelInfo();
    modelInfo.setModelCustomizationUuid(vfModuleCustomizationUUID);
    Service service = new Service();
    VnfResourceCustomization vnfResourceCust = new VnfResourceCustomization();
    vnfResourceCust.setModelCustomizationUUID(vnfModelCustomizationUUID);
    VfModuleCustomization vfModuleCust = new VfModuleCustomization();
    vfModuleCust.setModelCustomizationUUID(vfModuleCustomizationUUID);
    ModelInfoVfModule modelInfoVfModule = new ModelInfoVfModule();
    doReturn(vfModuleCust).when(SPY_bbInputSetupUtils).getVfModuleCustomizationByModelCuztomizationUUID(vfModuleCustomizationUUID);
    doReturn(modelInfoVfModule).when(bbInputSetupMapperLayer).mapCatalogVfModuleToVfModule(vfModuleCust);
    SPY_bbInputSetup.mapCatalogVfModule(vfModule, modelInfo, service, vnfModelCustomizationUUID);
    assertThat(vfModule.getModelInfoVfModule(), sameBeanAs(modelInfoVfModule));
    verify(SPY_bbInputSetupUtils, times(1)).getVfModuleCustomizationByModelCuztomizationUUID(modelInfo.getModelCustomizationId());
}
Also used : ModelInfo(org.onap.so.serviceinstancebeans.ModelInfo) ModelInfoVfModule(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoVfModule) Service(org.onap.so.db.catalog.beans.Service) VfModule(org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule) ModelInfoVfModule(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoVfModule) VfModuleCustomization(org.onap.so.db.catalog.beans.VfModuleCustomization) VnfResourceCustomization(org.onap.so.db.catalog.beans.VnfResourceCustomization) Test(org.junit.Test)

Example 73 with VfModule

use of org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule in project so by onap.

the class AppcOrchestratorPreProcessorTest method buildAppcTaskRequestConfigModifyTest.

@Test
public void buildAppcTaskRequestConfigModifyTest() throws Exception {
    final String expectedRequestJson = new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "appcTaskRequestConfigModify.json")));
    ApplicationControllerTaskRequest expectedTaskRequest = mapper.readValue(expectedRequestJson, ApplicationControllerTaskRequest.class);
    execution.getLookupMap().put(ResourceKey.GENERIC_VNF_ID, "-TEST");
    fillRequiredAppcExecutionFieldsConfigModify();
    GenericVnf genericVnf = getTestGenericVnf();
    when(extractPojosForBB.extractByKey(eq(execution), eq(ResourceKey.GENERIC_VNF_ID))).thenReturn(genericVnf);
    mockReferenceResponseForConfigModify();
    execution.getLookupMap().put(ResourceKey.VF_MODULE_ID, "VF-MODULE-ID-TEST");
    VfModule vfModule = new VfModule();
    vfModule.setVfModuleId("VF-MODULE-ID");
    when(extractPojosForBB.extractByKey(eq(execution), eq(ResourceKey.VF_MODULE_ID))).thenReturn(vfModule);
    appcOrchestratorPreProcessor.buildAppcTaskRequest(execution, "ConfigModify");
    ApplicationControllerTaskRequest actualTaskRequest = execution.getVariable("appcOrchestratorRequest");
    assertThat(actualTaskRequest, sameBeanAs(expectedTaskRequest));
}
Also used : ApplicationControllerTaskRequest(org.onap.so.appc.orchestrator.service.beans.ApplicationControllerTaskRequest) GenericVnf(org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf) VfModule(org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule) Test(org.junit.Test)

Example 74 with VfModule

use of org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule in project so by onap.

the class AAICreateTasksTest method createVfModuleGetLowestIndexTest.

@Test
public void createVfModuleGetLowestIndexTest() {
    GenericVnf vnf = new GenericVnf();
    ModelInfoGenericVnf vnfInfo = new ModelInfoGenericVnf();
    vnf.setModelInfoGenericVnf(vnfInfo);
    vnfInfo.setModelInvariantUuid("my-uuid");
    ModelInfoVfModule infoA = new ModelInfoVfModule();
    infoA.setIsBaseBoolean(false);
    infoA.setModelInvariantUUID("A");
    ModelInfoVfModule infoB = new ModelInfoVfModule();
    infoB.setIsBaseBoolean(false);
    infoB.setModelInvariantUUID("B");
    ModelInfoVfModule infoC = new ModelInfoVfModule();
    infoC.setIsBaseBoolean(false);
    infoC.setModelInvariantUUID("C");
    VfModule newVfModuleA = new VfModule();
    newVfModuleA.setVfModuleId("a");
    VfModule newVfModuleB = new VfModule();
    newVfModuleB.setVfModuleId("b");
    VfModule newVfModuleC = new VfModule();
    newVfModuleC.setVfModuleId("c");
    VfModule vfModule = new VfModule();
    vnf.getVfModules().add(vfModule);
    vfModule.setVfModuleId("1");
    VfModule vfModule2 = new VfModule();
    vnf.getVfModules().add(vfModule2);
    vfModule2.setVfModuleId("2");
    VfModule vfModule3 = new VfModule();
    vnf.getVfModules().add(vfModule3);
    vfModule3.setVfModuleId("3");
    VfModule vfModule4 = new VfModule();
    vnf.getVfModules().add(vfModule4);
    vfModule4.setVfModuleId("4");
    VfModule vfModule5 = new VfModule();
    vnf.getVfModules().add(vfModule5);
    vfModule5.setVfModuleId("5");
    // modules are included in the vnf already
    vnf.getVfModules().add(newVfModuleA);
    vnf.getVfModules().add(newVfModuleB);
    vnf.getVfModules().add(newVfModuleC);
    // A
    newVfModuleA.setModelInfoVfModule(infoA);
    vfModule.setModelInfoVfModule(infoA);
    vfModule2.setModelInfoVfModule(infoA);
    vfModule3.setModelInfoVfModule(infoA);
    // B
    newVfModuleB.setModelInfoVfModule(infoB);
    vfModule4.setModelInfoVfModule(infoB);
    vfModule5.setModelInfoVfModule(infoB);
    // C
    newVfModuleC.setModelInfoVfModule(infoC);
    // A
    vfModule.setModuleIndex(2);
    vfModule2.setModuleIndex(0);
    vfModule3.setModuleIndex(3);
    // B
    vfModule4.setModuleIndex(null);
    vfModule5.setModuleIndex(1);
    assertEquals(1, aaiCreateTasks.getLowestUnusedVfModuleIndexFromAAIVnfResponse(vnf, newVfModuleA));
    assertEquals(2, aaiCreateTasks.getLowestUnusedVfModuleIndexFromAAIVnfResponse(vnf, newVfModuleB));
    assertEquals(0, aaiCreateTasks.getLowestUnusedVfModuleIndexFromAAIVnfResponse(vnf, newVfModuleC));
}
Also used : ModelInfoVfModule(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoVfModule) ModelInfoGenericVnf(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoGenericVnf) GenericVnf(org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf) ModelInfoGenericVnf(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoGenericVnf) VfModule(org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule) ModelInfoVfModule(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoVfModule) Test(org.junit.Test)

Example 75 with VfModule

use of org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule in project so by onap.

the class TestDataSetup method setVfModule.

public VfModule setVfModule(boolean addToGenericVnf) {
    VfModule vfModule = buildVfModule();
    GenericVnf genericVnf = null;
    try {
        genericVnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
    } catch (BBObjectNotFoundException e) {
        genericVnf = setGenericVnf();
    }
    if (addToGenericVnf) {
        genericVnf.getVfModules().add(vfModule);
    }
    lookupKeyMap.put(ResourceKey.VF_MODULE_ID, vfModule.getVfModuleId());
    return vfModule;
}
Also used : BBObjectNotFoundException(org.onap.so.client.exception.BBObjectNotFoundException) ModelInfoGenericVnf(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoGenericVnf) GenericVnf(org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf) VfModule(org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule) ModelInfoVfModule(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoVfModule)

Aggregations

VfModule (org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule)97 GenericVnf (org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf)74 ServiceInstance (org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance)53 Test (org.junit.Test)46 ModelInfoVfModule (org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoVfModule)45 RequestContext (org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext)37 CloudRegion (org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion)35 ModelInfoServiceInstance (org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoServiceInstance)30 GeneralBuildingBlock (org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock)27 ModelInfoGenericVnf (org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoGenericVnf)27 HashMap (java.util.HashMap)22 VolumeGroup (org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup)20 OrchestrationContext (org.onap.so.bpmn.servicedecomposition.generalobjects.OrchestrationContext)18 CreateVfModuleRequest (org.onap.so.adapters.vnfrest.CreateVfModuleRequest)14 ModelInfo (org.onap.so.serviceinstancebeans.ModelInfo)14 BBObjectNotFoundException (org.onap.so.client.exception.BBObjectNotFoundException)13 ResourceKey (org.onap.so.bpmn.servicedecomposition.entities.ResourceKey)12 Service (org.onap.so.db.catalog.beans.Service)12 Map (java.util.Map)11 Customer (org.onap.so.bpmn.servicedecomposition.bbobjects.Customer)11