Search in sources :

Example 31 with ModelInfoVfModule

use of org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoVfModule 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 32 with ModelInfoVfModule

use of org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoVfModule in project so by onap.

the class VnfEBBLoaderTest method traverseAAIVnf_should_add_vnfs_and_vfmodules.

@Test
public void traverseAAIVnf_should_add_vnfs_and_vfmodules() throws Exception {
    List<Resource> resourceList = new ArrayList<>();
    List<Pair<WorkflowType, String>> aaiResourceIds = new ArrayList<>();
    GenericVnf genericVnf = mock(GenericVnf.class);
    doReturn(vnfId).when(genericVnf).getVnfId();
    org.onap.aai.domain.yang.GenericVnf aaiVnf = mock(org.onap.aai.domain.yang.GenericVnf.class);
    doReturn(aaiVnf).when(bbInputSetupUtils).getAAIGenericVnf(vnfId);
    VfModule vfModule = mock(VfModule.class);
    doReturn(vfModuleId).when(vfModule).getVfModuleId();
    ModelInfoVfModule modelInfoVfModule = new ModelInfoVfModule();
    modelInfoVfModule.setIsBaseBoolean(true);
    doReturn(modelInfoVfModule).when(vfModule).getModelInfoVfModule();
    org.onap.aai.domain.yang.VfModule aaiVfModule = new org.onap.aai.domain.yang.VfModule();
    aaiVfModule.setIsBaseVfModule(true);
    doReturn(aaiVfModule).when(bbInputSetupUtils).getAAIVfModule(vnfId, vfModuleId);
    doReturn(serviceInstanceAAI).when(bbInputSetupUtils).getAAIServiceInstanceById(serviceId);
    doReturn(serviceInstanceMSO).when(bbInputSetup).getExistingServiceInstance(serviceInstanceAAI);
    doReturn(List.of(genericVnf)).when(serviceInstanceMSO).getVnfs();
    doReturn(List.of(vfModule)).when(genericVnf).getVfModules();
    cut = new VnfEBBLoader(bbInputSetupUtils, bbInputSetup, workflowActionUtils, exceptionBuilder);
    cut.traverseAAIVnf(delegateExecution, resourceList, serviceId, vnfId, aaiResourceIds);
    assertEquals(3, resourceList.size());
    assertEquals(WorkflowType.VNF, resourceList.get(1).getResourceType());
    assertEquals(WorkflowType.VFMODULE, resourceList.get(2).getResourceType());
    assertTrue(resourceList.get(2).isBaseVfModule());
}
Also used : GenericVnf(org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf) Resource(org.onap.so.bpmn.infrastructure.workflow.tasks.Resource) ArrayList(java.util.ArrayList) VfModule(org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule) ModelInfoVfModule(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoVfModule) ModelInfoVfModule(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoVfModule) Pair(org.javatuples.Pair) Test(org.junit.Test)

Example 33 with ModelInfoVfModule

use of org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoVfModule in project so by onap.

the class BBInputSetupTest method testMapCatalogVfModule.

@Test
public void testMapCatalogVfModule() {
    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);
    vnfResourceCust.getVfModuleCustomizations().add(vfModuleCust);
    service.getVnfCustomizations().add(vnfResourceCust);
    ModelInfoVfModule modelInfoVfModule = new ModelInfoVfModule();
    doReturn(modelInfoVfModule).when(bbInputSetupMapperLayer).mapCatalogVfModuleToVfModule(vfModuleCust);
    SPY_bbInputSetup.mapCatalogVfModule(vfModule, modelInfo, service, vnfModelCustomizationUUID);
    assertThat(vfModule.getModelInfoVfModule(), sameBeanAs(modelInfoVfModule));
    modelInfo.setModelCustomizationUuid(null);
    modelInfo.setModelCustomizationId(vfModuleCustomizationUUID);
    SPY_bbInputSetup.mapCatalogVfModule(vfModule, modelInfo, service, vnfModelCustomizationUUID);
    assertThat(vfModule.getModelInfoVfModule(), sameBeanAs(modelInfoVfModule));
}
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)

Aggregations

ModelInfoVfModule (org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoVfModule)33 Test (org.junit.Test)27 VfModule (org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule)25 GenericVnf (org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf)20 ServiceInstance (org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance)18 ModelInfoServiceInstance (org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoServiceInstance)18 RequestContext (org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext)17 HashMap (java.util.HashMap)16 CloudRegion (org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion)16 ModelInfoGenericVnf (org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoGenericVnf)16 OrchestrationContext (org.onap.so.bpmn.servicedecomposition.generalobjects.OrchestrationContext)13 CreateVfModuleRequest (org.onap.so.adapters.vnfrest.CreateVfModuleRequest)10 VolumeGroup (org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup)8 RequestParameters (org.onap.so.bpmn.servicedecomposition.generalobjects.RequestParameters)4 Service (org.onap.so.db.catalog.beans.Service)4 VfModuleCustomization (org.onap.so.db.catalog.beans.VfModuleCustomization)4 ModelInfo (org.onap.so.serviceinstancebeans.ModelInfo)4 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)3 URI (java.net.URI)3 ArrayList (java.util.ArrayList)3