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));
}
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());
}
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));
}
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));
}
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;
}
Aggregations