use of org.onap.aai.domain.yang.ServiceInstance in project so by onap.
the class WorkflowActionTest method selectExecutionListVnfMacroReplaceTest.
@Test
public void selectExecutionListVnfMacroReplaceTest() throws Exception {
String gAction = "replaceInstance";
String resource = "Vnf";
String bpmnRequest = readBpmnRequestFromFile(MACRO_VNF_MACRO_REPLACE_JSON);
initExecution(gAction, bpmnRequest, false);
execution.setVariable("requestUri", "v7/serviceInstances/123/vnfs/1234/replace");
execution.setVariable("serviceInstanceId", "123");
execution.setVariable("vnfId", "1234");
NorthBoundRequest northBoundRequest = new NorthBoundRequest();
List<OrchestrationFlow> orchFlows = createFlowList("AAICheckVnfInMaintBB", "AAISetVnfInMaintBB", "DeactivateFabricConfigurationBB", "UnassignFabricConfigurationBB", "DeactivateVfModuleBB", "DeleteVfModuleBB", "DeactivateVnfBB", "ChangeModelVfModuleBB", "CreateVfModuleBB", "ActivateVfModuleBB", "AssignFabricConfigurationBB", "ActivateFabricConfigurationBB", "ChangeModelVnfBB", "ActivateVnfBB", "ChangeModelServiceInstanceBB", "SDNOVnfHealthCheckBB", "AAIUnsetVnfInMaintBB");
northBoundRequest.setOrchestrationFlowList(orchFlows);
ServiceInstance serviceInstanceAAI = new ServiceInstance();
serviceInstanceAAI.setServiceInstanceId("123");
org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance serviceInstanceMSO = new org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance();
org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf vnf = new org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf();
vnf.setVnfId("1234");
org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule vfModule = new org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule();
vfModule.setVfModuleId("vfModule1");
vnf.getVfModules().add(vfModule);
org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule vfModule2 = new org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule();
vfModule2.setVfModuleId("vfModule2");
vnf.getVfModules().add(vfModule2);
serviceInstanceMSO.getVnfs().add(vnf);
VfModule vfModuleAAI1 = new VfModule();
vfModuleAAI1.setIsBaseVfModule(false);
VfModule vfModuleAAI2 = new VfModule();
vfModuleAAI2.setIsBaseVfModule(false);
vfModuleAAI2.setVfModuleId("vfModule2");
RelationshipList relationshipList = new RelationshipList();
Relationship relationship = new Relationship();
relationshipList.getRelationship().add(relationship);
vfModuleAAI2.setRelationshipList(relationshipList);
Relationships relationships = new Relationships("abc");
Configuration config = new Configuration();
config.setConfigurationId("configId");
Optional<Configuration> configOp = Optional.of(config);
Optional<Relationships> relationshipsOp = Optional.of(relationships);
doReturn(new org.onap.aai.domain.yang.GenericVnf()).when(bbSetupUtils).getAAIGenericVnf(vnf.getVnfId());
doReturn(relationshipsOp).when(workflowActionUtils).extractRelationshipsVnfc(isA(Relationships.class));
doReturn(configOp).when(workflowActionUtils).extractRelationshipsConfiguration(isA(Relationships.class));
doReturn(vfModuleAAI1).when(bbSetupUtils).getAAIVfModule("1234", "vfModule1");
doReturn(vfModuleAAI2).when(bbSetupUtils).getAAIVfModule("1234", "vfModule2");
doReturn(serviceInstanceAAI).when(bbSetupUtils).getAAIServiceInstanceById("123");
doReturn(serviceInstanceMSO).when(bbInputSetup).getExistingServiceInstance(serviceInstanceAAI);
when(catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner(gAction, resource, false, "cloud-owner")).thenReturn(northBoundRequest);
workflowAction.selectExecutionList(execution);
List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
assertEqualsBulkFlowName(ebbs, "AAICheckVnfInMaintBB", "AAISetVnfInMaintBB", "DeactivateVfModuleBB", "DeleteVfModuleBB", "DeactivateFabricConfigurationBB", "UnassignFabricConfigurationBB", "DeactivateVfModuleBB", "DeleteVfModuleBB", "DeactivateVnfBB", "ChangeModelVfModuleBB", "CreateVfModuleBB", "ActivateVfModuleBB", "ChangeModelVfModuleBB", "CreateVfModuleBB", "ActivateVfModuleBB", "AssignFabricConfigurationBB", "ActivateFabricConfigurationBB", "ChangeModelVnfBB", "ActivateVnfBB", "ChangeModelServiceInstanceBB", "SDNOVnfHealthCheckBB", "AAIUnsetVnfInMaintBB");
for (ExecuteBuildingBlock executeBuildingBlock : ebbs) {
assertEquals("123", executeBuildingBlock.getWorkflowResourceIds().getServiceInstanceId());
}
}
use of org.onap.aai.domain.yang.ServiceInstance in project so by onap.
the class WorkflowActionTest method selectExecutionListServiceMacroDeleteWithPnfTest.
@Test
public void selectExecutionListServiceMacroDeleteWithPnfTest() throws Exception {
String gAction = "deleteInstance";
String resource = "Service";
String bpmnRequest = readBpmnRequestFromFile(MACRO_ACTIVATE_DELETE_UNASSIGN_JSON);
initExecution(gAction, bpmnRequest, false);
execution.setVariable("requestUri", "v6/serviceInstances/123");
NorthBoundRequest northBoundRequest = new NorthBoundRequest();
List<OrchestrationFlow> orchFlows = createFlowList("DeactivateVfModuleBB", "DeleteVfModuleBB", "DeactivateVolumeGroupBB", "DeleteVolumeGroupBB", "DeactivateVnfBB", "DeactivatePnfBB", "DeactivateNetworkBB", "DeleteNetworkBB", "DeleteNetworkCollectionBB", "DeactivateServiceInstanceBB", "UnassignVfModuleBB", "UnassignVolumeGroupBB", "UnassignVnfBB", "UnassignNetworkBB", "UnassignServiceInstanceBB");
northBoundRequest.setOrchestrationFlowList(orchFlows);
ServiceInstance serviceInstanceAAI = new ServiceInstance();
serviceInstanceAAI.setServiceInstanceId("aaisi123");
org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance serviceInstanceMSO = new org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance();
org.onap.so.bpmn.servicedecomposition.bbobjects.Pnf pnf = new org.onap.so.bpmn.servicedecomposition.bbobjects.Pnf();
pnf.setPnfId("pnfId123");
serviceInstanceMSO.getPnfs().add(pnf);
doReturn(serviceInstanceAAI).when(bbSetupUtils).getAAIServiceInstanceById("123");
doReturn(serviceInstanceMSO).when(bbInputSetup).getExistingServiceInstance(serviceInstanceAAI);
when(catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner(gAction, resource, false, "my-custom-cloud-owner")).thenReturn(northBoundRequest);
workflowAction.selectExecutionList(execution);
List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
assertEqualsBulkFlowName(ebbs, "DeactivatePnfBB", "DeactivateServiceInstanceBB", "UnassignServiceInstanceBB");
}
use of org.onap.aai.domain.yang.ServiceInstance 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.ServiceInstance 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.ServiceInstance in project so by onap.
the class WorkflowActionBBTasksTest method setServiceInstanceNameTest.
@Test
public void setServiceInstanceNameTest() {
String resourceId = "40bc4ebd-11df-4610-8055-059f7441ec1c";
WorkflowType resourceType = WorkflowType.SERVICE;
InfraActiveRequests request = new InfraActiveRequests();
ServiceInstance service = new ServiceInstance();
service.setServiceInstanceName("serviceInstanceName");
doReturn(service).when(bbSetupUtils).getAAIServiceInstanceById(resourceId);
workflowActionBBTasks.setInstanceName(resourceId, resourceType, request);
assertEquals("serviceInstanceName", request.getServiceInstanceName());
}
Aggregations