use of org.onap.aai.domain.yang.VfModule in project so by onap.
the class WorkflowActionTest method selectExecutionListALaCarteVfModuleKeepVolumeGroupReplaceRetainAssignmentsTest.
@Test
public void selectExecutionListALaCarteVfModuleKeepVolumeGroupReplaceRetainAssignmentsTest() throws Exception {
String gAction = "replaceInstanceRetainAssignments";
String resource = "VfModule";
String bpmnRequest = readBpmnRequestFromFile(VF_MODULE_CREATE_WITH_FABRIC_JSON);
initExecution(gAction, bpmnRequest, true);
execution.setVariable("requestUri", "v7/serviceInstances/f647e3ef-6d2e-4cd3-bff4-8df4634208de/vnfs/b80b16a5-f80d-4ffa-91c8-bd47c7438a3d/vfModules/1234");
execution.setVariable("vnfId", "b80b16a5-f80d-4ffa-91c8-bd47c7438a3d");
execution.setVariable("vfModuleId", "1234");
VolumeGroup volumeGroup = new VolumeGroup();
volumeGroup.setVolumeGroupId("volumeGroupId");
doReturn(Optional.of(volumeGroup)).when(bbSetupUtils).getRelatedVolumeGroupFromVfModule("b80b16a5-f80d-4ffa-91c8-bd47c7438a3d", "1234");
VfModuleCustomization vfModuleCustomization = new VfModuleCustomization();
vfModuleCustomization.setVolumeHeatEnv(new HeatEnvironment());
org.onap.so.db.catalog.beans.VfModule vfModule = new org.onap.so.db.catalog.beans.VfModule();
vfModule.setVolumeHeatTemplate(new HeatTemplate());
vfModuleCustomization.setVfModule(vfModule);
when(catalogDbClient.getVfModuleCustomizationByModelCuztomizationUUID("9a6d01fd-19a7-490a-9800-460830a12e0b")).thenReturn(vfModuleCustomization);
NorthBoundRequest northBoundRequest = new NorthBoundRequest();
northBoundRequest.setOrchestrationFlowList(replaceRetainAssignmentsVfModuleOrchFlows);
when(catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner(gAction, resource, true, "my-custom-cloud-owner")).thenReturn(northBoundRequest);
workflowAction.selectExecutionList(execution);
List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
assertEqualsBulkFlowName(ebbs, "DeactivateVfModuleBB", "DeleteVfModuleATTBB", "ChangeModelVfModuleBB", "CreateVfModuleBB", "ActivateVfModuleBB", "ChangeModelVnfBB", "ChangeModelServiceInstanceBB");
}
use of org.onap.aai.domain.yang.VfModule in project so by onap.
the class AaiResourceIdValidatorTest method validateResourceIdInAAIVfModuleTest.
@Test
public void validateResourceIdInAAIVfModuleTest() throws Exception {
RequestDetails reqDetails = setupRequestDetails();
WorkflowResourceIds workflowResourceIds = new WorkflowResourceIds();
workflowResourceIds.setVnfId("id123");
GenericVnf vnf = new GenericVnf();
VfModules vfModules = new VfModules();
VfModule vfModule = new VfModule();
vfModule.setVfModuleId("id123");
vfModule.setVfModuleName("name123");
vfModule.setModelCustomizationId("1234567");
vfModules.getVfModule().add(vfModule);
vnf.setVfModules(vfModules);
when(bbInputSetupUtilsMock.getAAIGenericVnf("id123")).thenReturn(vnf);
String id = testedObject.validateResourceIdInAAI("generatedId123", WorkflowType.VFMODULE, "name123", reqDetails, workflowResourceIds);
assertEquals("id123", id);
GenericVnf vnf1 = new GenericVnf();
VfModules vfModules2 = new VfModules();
VfModule vfModule2 = new VfModule();
vfModule2.setVfModuleName("vFModName222");
vfModule2.setModelCustomizationId("222");
vfModules2.getVfModule().add(vfModule2);
vnf1.setVfModules(vfModules2);
workflowResourceIds.setVnfId("id111");
when(bbInputSetupUtilsMock.getAAIGenericVnf("id111")).thenReturn(vnf1);
String id2 = testedObject.validateResourceIdInAAI("generatedId123", WorkflowType.VFMODULE, "111111", reqDetails, workflowResourceIds);
assertEquals("generatedId123", id2);
this.expectedException.expect(DuplicateNameException.class);
this.expectedException.expectMessage(containsString("vfModule with name (vFModName222), same parent and different customization id (1234567) already exists. The name must be unique."));
testedObject.validateResourceIdInAAI("generatedId123", WorkflowType.VFMODULE, "vFModName222", reqDetails, workflowResourceIds);
}
use of org.onap.aai.domain.yang.VfModule in project so by onap.
the class WorkflowActionBBTasksTest method postProcessingExecuteBBActivateVfModuleNotReplaceInstanceTest.
@Test
public void postProcessingExecuteBBActivateVfModuleNotReplaceInstanceTest() throws CloneNotSupportedException {
WorkflowResourceIds workflowResourceIds = new WorkflowResourceIds();
workflowResourceIds.setServiceInstanceId("1");
workflowResourceIds.setVnfId("1");
BuildingBlock bbActivateVfModule = new BuildingBlock().setBpmnFlowName("ActivateVfModuleBB");
ExecuteBuildingBlock ebbActivateVfModule = new ExecuteBuildingBlock().setBuildingBlock(bbActivateVfModule);
ebbActivateVfModule.setWorkflowResourceIds(workflowResourceIds);
ebbActivateVfModule.setResourceId("1");
ServiceInstance service = new ServiceInstance();
service.setServiceInstanceName("name");
service.setModelVersionId("1");
doReturn(service).when(bbSetupUtils).getAAIServiceInstanceById("1");
GenericVnf vnf = new GenericVnf();
vnf.setVnfName("name");
vnf.setModelCustomizationId("1");
doReturn(vnf).when(bbSetupUtils).getAAIGenericVnf("1");
VfModule vfModule = new VfModule();
vfModule.setVfModuleName("name");
vfModule.setModelCustomizationId("1");
doReturn(vfModule).when(bbSetupUtils).getAAIVfModule("1", "1");
List<org.onap.aai.domain.yang.Vnfc> vnfcs = new ArrayList<org.onap.aai.domain.yang.Vnfc>();
org.onap.aai.domain.yang.Vnfc vnfc = new org.onap.aai.domain.yang.Vnfc();
vnfc.setModelInvariantId("1");
vnfc.setVnfcName("name");
vnfc.setModelCustomizationId("2");
vnfcs.add(vnfc);
doReturn(vnfcs).when(workflowAction).getRelatedResourcesInVfModule(any(), any(), any(), any());
CvnfcConfigurationCustomization vfModuleCustomization = new CvnfcConfigurationCustomization();
ConfigurationResource configuration = new ConfigurationResource();
configuration.setToscaNodeType("FabricConfiguration");
configuration.setModelUUID("1");
vfModuleCustomization.setConfigurationResource(configuration);
doReturn(vfModuleCustomization).when(catalogDbClient).getCvnfcCustomization("1", "1", "1", "2");
prepareDelegateExecution();
List<ExecuteBuildingBlock> flowsToExecute = new ArrayList<>();
flowsToExecute.add(ebbActivateVfModule);
execution.setVariable("requestAction", "createInstance");
execution.setVariable("completed", true);
ArgumentCaptor<DelegateExecution> executionCaptor = ArgumentCaptor.forClass(DelegateExecution.class);
ArgumentCaptor<ExecuteBuildingBlock> bbCaptor = ArgumentCaptor.forClass(ExecuteBuildingBlock.class);
ArgumentCaptor<List> listCaptor = ArgumentCaptor.forClass(List.class);
workflowActionBBTasks.postProcessingExecuteBBActivateVfModule(execution, ebbActivateVfModule, flowsToExecute);
verify(workflowActionBBTasks, times(1)).postProcessingExecuteBBActivateVfModule(executionCaptor.capture(), bbCaptor.capture(), listCaptor.capture());
assertEquals(false, executionCaptor.getAllValues().get(0).getVariable("completed"));
assertEquals(2, ((ArrayList) executionCaptor.getAllValues().get(0).getVariable("flowsToExecute")).size());
assertEquals("2", ((ExecuteBuildingBlock) ((ArrayList) executionCaptor.getAllValues().get(0).getVariable("flowsToExecute")).get(1)).getConfigurationResourceKeys().getCvnfcCustomizationUUID());
assertEquals("AddFabricConfigurationBB", ((ExecuteBuildingBlock) ((ArrayList) executionCaptor.getAllValues().get(0).getVariable("flowsToExecute")).get(1)).getBuildingBlock().getBpmnFlowName());
}
use of org.onap.aai.domain.yang.VfModule in project so by onap.
the class WorkflowActionBBTasksTest method postProcessingExecuteBBActivateVfModuleReplaceInstanceHasNoConfigurationTest.
@Test
public void postProcessingExecuteBBActivateVfModuleReplaceInstanceHasNoConfigurationTest() throws CloneNotSupportedException {
WorkflowResourceIds workflowResourceIds = new WorkflowResourceIds();
workflowResourceIds.setServiceInstanceId("1");
workflowResourceIds.setVnfId("1");
BuildingBlock bbActivateVfModule = new BuildingBlock().setBpmnFlowName("ActivateVfModuleBB");
ExecuteBuildingBlock ebbActivateVfModule = new ExecuteBuildingBlock().setBuildingBlock(bbActivateVfModule);
ebbActivateVfModule.setWorkflowResourceIds(workflowResourceIds);
ebbActivateVfModule.setResourceId("1");
ServiceInstance service = new ServiceInstance();
service.setServiceInstanceName("name");
service.setModelVersionId("1");
doReturn(service).when(bbSetupUtils).getAAIServiceInstanceById("1");
GenericVnf vnf = new GenericVnf();
vnf.setVnfName("name");
vnf.setModelCustomizationId("1");
doReturn(vnf).when(bbSetupUtils).getAAIGenericVnf("1");
VfModule vfModule = new VfModule();
vfModule.setVfModuleName("name");
vfModule.setModelCustomizationId("1");
doReturn(vfModule).when(bbSetupUtils).getAAIVfModule("1", "1");
List<org.onap.aai.domain.yang.Vnfc> vnfcs = new ArrayList<org.onap.aai.domain.yang.Vnfc>();
org.onap.aai.domain.yang.Vnfc vnfc = new org.onap.aai.domain.yang.Vnfc();
vnfc.setModelInvariantId("1");
vnfc.setVnfcName("name");
vnfc.setModelCustomizationId("2");
vnfcs.add(vnfc);
doReturn(vnfcs).when(workflowAction).getRelatedResourcesInVfModule(any(), any(), any(), any());
CvnfcConfigurationCustomization vfModuleCustomization = new CvnfcConfigurationCustomization();
ConfigurationResource configuration = new ConfigurationResource();
configuration.setToscaNodeType("FabricConfiguration");
configuration.setModelUUID("1");
vfModuleCustomization.setConfigurationResource(configuration);
doReturn(vfModuleCustomization).when(catalogDbClient).getCvnfcCustomization("1", "1", "1", "2");
prepareDelegateExecution();
List<ExecuteBuildingBlock> flowsToExecute = new ArrayList<>();
flowsToExecute.add(ebbActivateVfModule);
ArgumentCaptor<DelegateExecution> executionCaptor = ArgumentCaptor.forClass(DelegateExecution.class);
ArgumentCaptor<ExecuteBuildingBlock> bbCaptor = ArgumentCaptor.forClass(ExecuteBuildingBlock.class);
ArgumentCaptor<List> listCaptor = ArgumentCaptor.forClass(List.class);
execution.setVariable("requestAction", "replaceInstance");
execution.setVariable("completed", true);
workflowActionBBTasks.postProcessingExecuteBBActivateVfModule(execution, ebbActivateVfModule, flowsToExecute);
verify(workflowActionBBTasks, times(1)).postProcessingExecuteBBActivateVfModule(executionCaptor.capture(), bbCaptor.capture(), listCaptor.capture());
assertEquals(true, executionCaptor.getAllValues().get(0).getVariable("completed"));
}
use of org.onap.aai.domain.yang.VfModule in project policy-models by onap.
the class AaiCqResponse method getVfModuleCount.
/**
* Get the count of vfModules matching customizationId, InvariantId and VersionId.
*
* @param custId ModelCustomizationId
* @param invId ModelInvariantId
* @param verId ModelVersionId
* @return Returns the count of vf modules
*/
public int getVfModuleCount(String custId, String invId, String verId) {
List<VfModule> vfModuleList = this.getAllVfModules();
var count = 0;
for (VfModule vfModule : vfModuleList) {
if (vfModule.getModelCustomizationId() == null || vfModule.getModelInvariantId() == null || vfModule.getModelVersionId() == null) {
continue;
}
if (vfModule.getModelCustomizationId().equals(custId) && vfModule.getModelInvariantId().equals(invId) && vfModule.getModelVersionId().equals(verId)) {
count = count + 1;
}
}
return count;
}
Aggregations