Search in sources :

Example 6 with VolumeGroup

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

the class BBInputSetupTest method testMapVolumeGroups.

@Test
public void testMapVolumeGroups() throws JsonProcessingException {
    org.onap.aai.domain.yang.VolumeGroup expectedAAI = new org.onap.aai.domain.yang.VolumeGroup();
    VolumeGroup expected = new VolumeGroup();
    AAIResultWrapper vnfWrapper = new AAIResultWrapper(new AAICommonObjectMapperProvider().getMapper().writeValueAsString(expectedAAI));
    doReturn(expected).when(bbInputSetupMapperLayer).mapAAIVolumeGroup(isA(org.onap.aai.domain.yang.VolumeGroup.class));
    List<VolumeGroup> volumeGroupsList = SPY_bbInputSetup.mapVolumeGroups(Arrays.asList(new AAIResultWrapper[] { vnfWrapper }));
    assertEquals(expected, volumeGroupsList.get(0));
}
Also used : VolumeGroup(org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup) AAICommonObjectMapperProvider(org.onap.aaiclient.client.aai.AAICommonObjectMapperProvider) AAIResultWrapper(org.onap.aaiclient.client.aai.entities.AAIResultWrapper) Test(org.junit.Test)

Example 7 with VolumeGroup

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

the class BBInputSetupTest method testPopulateVolumeGroup.

@Test
public void testPopulateVolumeGroup() throws Exception {
    RequestDetails requestDetails = new RequestDetails();
    RelatedInstanceList ril = new RelatedInstanceList();
    RelatedInstance ri = new RelatedInstance();
    ModelInfo mi = new ModelInfo();
    mi.setModelType(ModelType.vnf);
    mi.setModelCustomizationUuid("vnfModelCustomizationUUID");
    mi.setModelCustomizationId("vnfModelCustomizationUUID");
    ri.setModelInfo(mi);
    ril.setRelatedInstance(ri);
    requestDetails.setRelatedInstanceList(new RelatedInstanceList[] { ril });
    ModelInfo modelInfo = new ModelInfo();
    modelInfo.setModelCustomizationId("volumeGroupCustId");
    RequestInfo reqInfo = new RequestInfo();
    reqInfo.setInstanceName("volumeGroupName");
    requestDetails.setModelInfo(modelInfo);
    requestDetails.setRequestInfo(reqInfo);
    ServiceInstance serviceInstance = new ServiceInstance();
    GenericVnf vnf = new GenericVnf();
    vnf.setVnfId("genericVnfId");
    VolumeGroup vg = new VolumeGroup();
    vg.setVolumeGroupName("volumeGroupName");
    vg.setVolumeGroupId("volumeGroupId");
    vg.setModelInfoVfModule(new ModelInfoVfModule());
    vg.getModelInfoVfModule().setModelCustomizationUUID("volumeGroupCustId");
    vnf.getVolumeGroups().add(vg);
    serviceInstance.getVnfs().add(vnf);
    Service service = mapper.readValue(new File(RESOURCE_PATH + "CatalogDBService_getServiceInstanceNOAAIInput.json"), Service.class);
    Map<ResourceKey, String> lookupKeyMap = new HashMap<>();
    lookupKeyMap.put(ResourceKey.GENERIC_VNF_ID, "genericVnfId");
    ServiceModel serviceModel = new ServiceModel();
    serviceModel.setCurrentService(service);
    String bbName = AssignFlows.VOLUME_GROUP.toString();
    String resourceId = "123";
    doNothing().when(SPY_bbInputSetup).mapCatalogVolumeGroup(isA(VolumeGroup.class), eq(modelInfo), eq(service), eq("vnfModelCustomizationUUID"));
    org.onap.aai.domain.yang.GenericVnf aaiGenericVnf = new org.onap.aai.domain.yang.GenericVnf();
    aaiGenericVnf.setModelCustomizationId("vnfModelCustomizationUUID");
    doReturn(aaiGenericVnf).when(SPY_bbInputSetupUtils).getAAIGenericVnf(vnf.getVnfId());
    lookupKeyMap.put(ResourceKey.VOLUME_GROUP_ID, "volumeGroupId");
    BBInputSetupParameter parameter = new BBInputSetupParameter.Builder().setRequestId(REQUEST_ID).setModelInfo(modelInfo).setService(service).setBbName(bbName).setServiceInstance(serviceInstance).setLookupKeyMap(lookupKeyMap).setResourceId(resourceId).setRequestDetails(requestDetails).setInstanceName(reqInfo.getInstanceName()).setServiceModel(serviceModel).build();
    SPY_bbInputSetup.populateVolumeGroup(parameter);
    verify(SPY_bbInputSetup, times(1)).mapCatalogVolumeGroup(eq(vg), isA(ModelInfo.class), eq(service), eq("vnfModelCustomizationUUID"));
    vnf.getVolumeGroups().clear();
    SPY_bbInputSetup.populateVolumeGroup(parameter);
    verify(SPY_bbInputSetup, times(1)).mapCatalogVolumeGroup(vnf.getVolumeGroups().get(0), modelInfo, service, "vnfModelCustomizationUUID");
}
Also used : ModelInfo(org.onap.so.serviceinstancebeans.ModelInfo) ModelInfoGenericVnf(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoGenericVnf) GenericVnf(org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf) RelatedInstanceList(org.onap.so.serviceinstancebeans.RelatedInstanceList) RelatedInstance(org.onap.so.serviceinstancebeans.RelatedInstance) 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) RequestInfo(org.onap.so.serviceinstancebeans.RequestInfo) RequestDetails(org.onap.so.serviceinstancebeans.RequestDetails) ResourceKey(org.onap.so.bpmn.servicedecomposition.entities.ResourceKey) ModelInfoVfModule(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoVfModule) ServiceModel(org.onap.so.bpmn.servicedecomposition.entities.ServiceModel) VolumeGroup(org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup) File(java.io.File) Test(org.junit.Test)

Example 8 with VolumeGroup

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

the class BBInputSetupMapperLayerTest method testMapAAIVolumeGroup.

@Test
public void testMapAAIVolumeGroup() throws JsonParseException, JsonMappingException, IOException {
    VolumeGroup expectedVolumeGroup = mapper.readValue(new File(RESOURCE_PATH + "VolumeGroup.json"), VolumeGroup.class);
    org.onap.aai.domain.yang.VolumeGroup aaiVolumeGroup = mapper.readValue(new File(RESOURCE_PATH + "VolumeGroup_AAI.json"), org.onap.aai.domain.yang.VolumeGroup.class);
    VolumeGroup actualVolumeGroup = bbInputSetupMapperLayer.mapAAIVolumeGroup(aaiVolumeGroup);
    assertThat(actualVolumeGroup, sameBeanAs(expectedVolumeGroup));
}
Also used : VolumeGroup(org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup) File(java.io.File) Test(org.junit.Test)

Example 9 with VolumeGroup

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

the class BBInputSetupTest method testPopulateVfModuleIsReplace.

@Test
public void testPopulateVfModuleIsReplace() throws Exception {
    String vnfId = "vnfId";
    String vfModuleId = "vfModuleId";
    String volumeGroupId = "volumeGroupId";
    String vfModuleCustomizationId = "vfModuleCustomizationId";
    ModelInfo modelInfo = new ModelInfo();
    modelInfo.setModelCustomizationId(vfModuleCustomizationId);
    Service currentService = new Service();
    Service newService = new Service();
    ServiceModel serviceModel = new ServiceModel();
    serviceModel.setCurrentService(currentService);
    currentService.setModelUUID("currentUUID");
    serviceModel.setNewService(newService);
    currentService.setModelUUID("newUUID");
    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);
    lookupKeyMap.put(ResourceKey.VF_MODULE_ID, vfModuleId);
    String resourceId = vfModuleId;
    RelatedInstanceList[] relatedInstanceList = new RelatedInstanceList[1];
    RelatedInstanceList relatedInstanceListObj = new RelatedInstanceList();
    RelatedInstance relatedInstance = new RelatedInstance();
    relatedInstance.setInstanceId(vnfId);
    ModelInfo vnfModelInfo = new ModelInfo();
    vnfModelInfo.setModelCustomizationId("vnfCustomizationId");
    vnfModelInfo.setModelType(ModelType.vnf);
    relatedInstance.setModelInfo(vnfModelInfo);
    relatedInstanceListObj.setRelatedInstance(relatedInstance);
    relatedInstanceList[0] = relatedInstanceListObj;
    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));
    BBInputSetupParameter parameter = new BBInputSetupParameter.Builder().setModelInfo(modelInfo).setService(newService).setServiceInstance(serviceInstance).setBbName(bbName).setLookupKeyMap(lookupKeyMap).setResourceId(resourceId).setRelatedInstanceList(relatedInstanceList).setInstanceName(instanceName).setInstanceParams(instanceParams).setCloudConfiguration(cloudConfiguration).setIsReplace(true).setServiceModel(serviceModel).build();
    SPY_bbInputSetup.populateVfModule(parameter);
    verify(SPY_bbInputSetup, times(2)).mapCatalogVfModule(isA(VfModule.class), isA(ModelInfo.class), eq(serviceModel.getCurrentService()), isA(String.class));
    verify(SPY_bbInputSetup, times(1)).mapCatalogVfModule(isA(VfModule.class), isA(ModelInfo.class), eq(serviceModel.getNewService()), 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) 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) RelatedInstance(org.onap.so.serviceinstancebeans.RelatedInstance) 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 10 with VolumeGroup

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

the class VnfAdapterCreateTasksTest method test_createVolumeGroupRequest.

@Test
public void test_createVolumeGroupRequest() throws Exception {
    RequestContext requestContext = setRequestContext();
    ServiceInstance serviceInstance = setServiceInstance();
    GenericVnf genericVnf = setGenericVnf();
    VfModule vfModule = setVfModule();
    vfModule.setSelflink("vfModuleSelfLink");
    VolumeGroup volumeGroup = setVolumeGroup();
    volumeGroup.setOrchestrationStatus(OrchestrationStatus.ASSIGNED);
    CloudRegion cloudRegion = setCloudRegion();
    OrchestrationContext orchestrationContext = setOrchestrationContext();
    orchestrationContext.setIsRollbackEnabled(true);
    String sdncVnfQueryResponse = "SDNCVnfQueryResponse";
    execution.setVariable("SDNCQueryResponse_" + vfModule.getVfModuleId(), sdncVnfQueryResponse);
    CreateVolumeGroupRequest request = new CreateVolumeGroupRequest();
    request.setVolumeGroupId("volumeGroupStackId");
    when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.GENERIC_VNF_ID))).thenReturn(genericVnf);
    when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.VOLUME_GROUP_ID))).thenReturn(volumeGroup);
    when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.VF_MODULE_ID))).thenReturn(vfModule);
    doReturn(request).when(vnfAdapterVolumeGroupResources).createVolumeGroupRequest(requestContext, cloudRegion, orchestrationContext, serviceInstance, genericVnf, volumeGroup, sdncVnfQueryResponse);
    vnfAdapterCreateTasks.createVolumeGroupRequest(execution);
    verify(vnfAdapterVolumeGroupResources, times(1)).createVolumeGroupRequest(requestContext, cloudRegion, orchestrationContext, serviceInstance, genericVnf, volumeGroup, sdncVnfQueryResponse);
    assertEquals(request.toXmlString(), execution.getVariable("VNFREST_Request"));
}
Also used : CloudRegion(org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion) CreateVolumeGroupRequest(org.onap.so.adapters.vnfrest.CreateVolumeGroupRequest) GenericVnf(org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf) VolumeGroup(org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup) ServiceInstance(org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance) RequestContext(org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext) VfModule(org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule) OrchestrationContext(org.onap.so.bpmn.servicedecomposition.generalobjects.OrchestrationContext) Test(org.junit.Test)

Aggregations

VolumeGroup (org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup)44 GenericVnf (org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf)28 Test (org.junit.Test)23 ServiceInstance (org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance)20 VfModule (org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule)17 CloudRegion (org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion)15 HashMap (java.util.HashMap)13 RequestContext (org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext)13 ModelInfoVfModule (org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoVfModule)13 ModelInfoGenericVnf (org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoGenericVnf)11 ModelInfoServiceInstance (org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoServiceInstance)11 ModelInfo (org.onap.so.serviceinstancebeans.ModelInfo)10 GeneralBuildingBlock (org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock)8 ResourceKey (org.onap.so.bpmn.servicedecomposition.entities.ResourceKey)8 Service (org.onap.so.db.catalog.beans.Service)8 OrchestrationContext (org.onap.so.bpmn.servicedecomposition.generalobjects.OrchestrationContext)7 Map (java.util.Map)6 BBObjectNotFoundException (org.onap.so.client.exception.BBObjectNotFoundException)6 CreateVolumeGroupRequest (org.onap.so.adapters.vnfrest.CreateVolumeGroupRequest)5 CloudConfiguration (org.onap.so.serviceinstancebeans.CloudConfiguration)5