Search in sources :

Example 76 with RequestDetails

use of org.onap.so.serviceinstancebeans.RequestDetails in project so by onap.

the class WorkflowActionBBTasksTest method getExecuteBBForConfigTest.

@Test
public void getExecuteBBForConfigTest() throws CloneNotSupportedException {
    BuildingBlock bbActivateVfModule = new BuildingBlock().setBpmnFlowName("ActivateVfModuleBB");
    ExecuteBuildingBlock ebbActivateVfModule = new ExecuteBuildingBlock().setBuildingBlock(bbActivateVfModule);
    WorkflowResourceIds resourceIdsActivateVfModule = new WorkflowResourceIds();
    resourceIdsActivateVfModule.setServiceInstanceId("test-service-inbstance-id");
    resourceIdsActivateVfModule.setVnfId("test-vnf-id");
    resourceIdsActivateVfModule.setVfModuleId("test-vf-module-id");
    resourceIdsActivateVfModule.setConfigurationId("");
    RequestDetails requestDetails = new RequestDetails();
    ebbActivateVfModule.setApiVersion("7");
    ebbActivateVfModule.setaLaCarte(true);
    ebbActivateVfModule.setRequestAction("createInstance");
    ebbActivateVfModule.setVnfType("test-vnf-type");
    ebbActivateVfModule.setRequestId("f6c00ae2-a205-4cbd-b055-02e553efde12");
    ebbActivateVfModule.setRequestDetails(requestDetails);
    ebbActivateVfModule.setWorkflowResourceIds(resourceIdsActivateVfModule);
    ConfigurationResourceKeys configurationResourceKeys = new ConfigurationResourceKeys();
    configurationResourceKeys.setCvnfcCustomizationUUID("07d64cd2-4427-4156-b11d-d14b96b3e4cb");
    configurationResourceKeys.setVfModuleCustomizationUUID("50b61075-6ebb-4aab-a9fc-bedad9a2aa76");
    configurationResourceKeys.setVnfResourceCustomizationUUID("a1d0e36e-34a9-431b-b5ba-4bbb72f63c7c");
    configurationResourceKeys.setVnfcName("rdm54bvbgw5001vm018pim001");
    ExecuteBuildingBlock ebbAddFabricConfig = workflowActionBBTasks.getExecuteBBForConfig("AddFabricConfigurationBB", ebbActivateVfModule, "cc7e12f9-967c-4362-8d14-e5b2bf0608a4", configurationResourceKeys);
    assertEquals("7", ebbAddFabricConfig.getApiVersion());
    assertTrue(ebbAddFabricConfig.isaLaCarte());
    assertEquals("createInstance", ebbAddFabricConfig.getRequestAction());
    assertEquals("test-vnf-type", ebbAddFabricConfig.getVnfType());
    assertEquals("f6c00ae2-a205-4cbd-b055-02e553efde12", ebbAddFabricConfig.getRequestId());
    assertEquals(requestDetails, ebbAddFabricConfig.getRequestDetails());
    assertEquals("cc7e12f9-967c-4362-8d14-e5b2bf0608a4", ebbAddFabricConfig.getWorkflowResourceIds().getConfigurationId());
    assertEquals("test-service-inbstance-id", ebbAddFabricConfig.getWorkflowResourceIds().getServiceInstanceId());
    assertEquals("test-vnf-id", ebbAddFabricConfig.getWorkflowResourceIds().getVnfId());
    assertEquals("test-vf-module-id", ebbAddFabricConfig.getWorkflowResourceIds().getVfModuleId());
    assertThat(ebbAddFabricConfig.getConfigurationResourceKeys()).isEqualTo(configurationResourceKeys);
    assertThat(ebbAddFabricConfig.getWorkflowResourceIds()).isNotEqualTo(ebbActivateVfModule.getWorkflowResourceIds());
    assertThat(ebbAddFabricConfig.getWorkflowResourceIds().getConfigurationId()).isNotEqualTo(ebbActivateVfModule.getWorkflowResourceIds().getConfigurationId());
}
Also used : ExecuteBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock) BuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.BuildingBlock) ExecuteBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock) ConfigurationResourceKeys(org.onap.so.bpmn.servicedecomposition.entities.ConfigurationResourceKeys) RequestDetails(org.onap.so.serviceinstancebeans.RequestDetails) WorkflowResourceIds(org.onap.so.bpmn.servicedecomposition.entities.WorkflowResourceIds) BaseTaskTest(org.onap.so.bpmn.BaseTaskTest) Test(org.junit.Test)

Example 77 with RequestDetails

use of org.onap.so.serviceinstancebeans.RequestDetails in project so by onap.

the class WorkflowActionBBTasksTest method postProcessingExecuteBBActivateVfModuleReplaceInstanceHasConfigurationTest.

@Test
public void postProcessingExecuteBBActivateVfModuleReplaceInstanceHasConfigurationTest() throws CloneNotSupportedException {
    RequestDetails reqDetails = new RequestDetails();
    RelatedInstanceList[] list = new RelatedInstanceList[2];
    RelatedInstanceList vnfList = new RelatedInstanceList();
    RelatedInstanceList serviceList = new RelatedInstanceList();
    list[0] = vnfList;
    list[1] = serviceList;
    RelatedInstance vnfInstance = new RelatedInstance();
    RelatedInstance serviceInstance = new RelatedInstance();
    ModelInfo vnfModelInfo = new ModelInfo();
    vnfModelInfo.setModelType(ModelType.vnf);
    vnfModelInfo.setModelCustomizationId("1");
    ModelInfo serviceModelInfo = new ModelInfo();
    serviceModelInfo.setModelType(ModelType.service);
    serviceModelInfo.setModelVersionId("1");
    vnfInstance.setModelInfo(vnfModelInfo);
    serviceInstance.setModelInfo(serviceModelInfo);
    reqDetails.setRelatedInstanceList(list);
    vnfList.setRelatedInstance(vnfInstance);
    serviceList.setRelatedInstance(serviceInstance);
    ModelInfo vfModuleInfo = new ModelInfo();
    vfModuleInfo.setModelCustomizationId("1");
    reqDetails.setModelInfo(vfModuleInfo);
    BuildingBlock bbAddFabric = new BuildingBlock().setBpmnFlowName("AddFabricConfigurationBB");
    ExecuteBuildingBlock ebbAddFabric = new ExecuteBuildingBlock().setBuildingBlock(bbAddFabric);
    WorkflowResourceIds workflowResourceIds = new WorkflowResourceIds();
    workflowResourceIds.setServiceInstanceId("1");
    workflowResourceIds.setVnfId("1");
    ebbAddFabric.setWorkflowResourceIds(workflowResourceIds);
    ebbAddFabric.setResourceId("1");
    BuildingBlock bbActivateVfModule = new BuildingBlock().setBpmnFlowName("ActivateVfModuleBB");
    ExecuteBuildingBlock ebbActivateVfModule = new ExecuteBuildingBlock().setBuildingBlock(bbActivateVfModule);
    ebbActivateVfModule.setWorkflowResourceIds(workflowResourceIds);
    ebbActivateVfModule.setResourceId("1");
    ConfigurationResourceKeys configurationResourceKeys = new ConfigurationResourceKeys();
    ebbAddFabric.setConfigurationResourceKeys(configurationResourceKeys);
    ebbActivateVfModule.setRequestDetails(reqDetails);
    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(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());
}
Also used : ModelInfo(org.onap.so.serviceinstancebeans.ModelInfo) ExecuteBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock) BuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.BuildingBlock) GenericVnf(org.onap.aai.domain.yang.GenericVnf) RelatedInstanceList(org.onap.so.serviceinstancebeans.RelatedInstanceList) ArrayList(java.util.ArrayList) ServiceInstance(org.onap.aai.domain.yang.ServiceInstance) VfModule(org.onap.aai.domain.yang.VfModule) WorkflowResourceIds(org.onap.so.bpmn.servicedecomposition.entities.WorkflowResourceIds) ExecuteBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock) List(java.util.List) RelatedInstanceList(org.onap.so.serviceinstancebeans.RelatedInstanceList) ArrayList(java.util.ArrayList) RelatedInstance(org.onap.so.serviceinstancebeans.RelatedInstance) ConfigurationResource(org.onap.so.db.catalog.beans.ConfigurationResource) RequestDetails(org.onap.so.serviceinstancebeans.RequestDetails) ConfigurationResourceKeys(org.onap.so.bpmn.servicedecomposition.entities.ConfigurationResourceKeys) DelegateExecution(org.camunda.bpm.engine.delegate.DelegateExecution) CvnfcConfigurationCustomization(org.onap.so.db.catalog.beans.CvnfcConfigurationCustomization) BaseTaskTest(org.onap.so.bpmn.BaseTaskTest) Test(org.junit.Test)

Example 78 with RequestDetails

use of org.onap.so.serviceinstancebeans.RequestDetails in project so by onap.

the class WorkflowActionBBTasksTest method selectBBTest.

@Test
public void selectBBTest() {
    String vnfCustomizationUUID = "1234567";
    String modelUuid = "1234567";
    prepareDelegateExecution();
    List<ExecuteBuildingBlock> flowsToExecute = new ArrayList<>();
    BuildingBlock buildingBlock = new BuildingBlock().setBpmnFlowName("ConfigAssignVnfBB").setKey(vnfCustomizationUUID);
    RequestDetails rd = new RequestDetails();
    ModelInfo mi = new ModelInfo();
    mi.setModelUuid(modelUuid);
    rd.setModelInfo(mi);
    ExecuteBuildingBlock ebb = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock).setRequestDetails(rd);
    flowsToExecute.add(ebb);
    List<VnfResourceCustomization> vnfResourceCustomizations = new ArrayList<>();
    VnfResourceCustomization vrc = new VnfResourceCustomization();
    vrc.setSkipPostInstConf(false);
    vrc.setModelCustomizationUUID(vnfCustomizationUUID);
    vnfResourceCustomizations.add(vrc);
    GenericVnf genericVnf = new GenericVnf();
    genericVnf.setModelCustomizationId(vnfCustomizationUUID);
    doReturn(vnfResourceCustomizations).when(catalogDbClient).getVnfResourceCustomizationByModelUuid(modelUuid);
    doReturn(vrc).when(catalogDbClient).findVnfResourceCustomizationInList(vnfCustomizationUUID, vnfResourceCustomizations);
    execution.setVariable("flowsToExecute", flowsToExecute);
    workflowActionBBTasks.selectBB(execution);
    boolean success = (boolean) execution.getVariable("completed");
    int currentSequence = (int) execution.getVariable("gCurrentSequence");
    assertFalse(success);
    assertEquals(1, currentSequence);
}
Also used : ModelInfo(org.onap.so.serviceinstancebeans.ModelInfo) ExecuteBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock) ExecuteBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock) BuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.BuildingBlock) GenericVnf(org.onap.aai.domain.yang.GenericVnf) ArrayList(java.util.ArrayList) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) RequestDetails(org.onap.so.serviceinstancebeans.RequestDetails) VnfResourceCustomization(org.onap.so.db.catalog.beans.VnfResourceCustomization) BaseTaskTest(org.onap.so.bpmn.BaseTaskTest) Test(org.junit.Test)

Example 79 with RequestDetails

use of org.onap.so.serviceinstancebeans.RequestDetails in project so by onap.

the class UpgradePreWorkflowValidatorTest method validateHappyCase.

@Test
public void validateHappyCase() throws JsonProcessingException {
    ServiceInstancesRequest sir = new ServiceInstancesRequest();
    sir.setRequestDetails(new RequestDetails());
    sir.getRequestDetails().setModelInfo(new ModelInfo());
    sir.getRequestDetails().getModelInfo().setModelUuid(UUID.randomUUID().toString());
    String modelInvariantId = UUID.randomUUID().toString();
    sir.getRequestDetails().getModelInfo().setModelInvariantId(modelInvariantId);
    Resource serviceResource = new Resource(WorkflowType.SERVICE, "", false, null);
    serviceResource.setModelInvariantId(modelInvariantId);
    Resource vnfResource = new Resource(WorkflowType.VNF, "", false, serviceResource);
    String vnfCustomiationId = UUID.randomUUID().toString();
    vnfResource.setVnfCustomizationId(vnfCustomiationId);
    Service service = new Service();
    VnfResourceCustomization vnfCustomization = new VnfResourceCustomization();
    vnfCustomization.setModelCustomizationUUID(vnfCustomiationId);
    service.setVnfCustomizations(Arrays.asList(vnfCustomization));
    when(catalogDbClient.getServiceByModelUUID(anyString())).thenReturn(service);
    BuildingBlockExecution execution = createExecution(sir, Arrays.asList(serviceResource, vnfResource));
    Optional<String> message = validator.validate(execution);
    assertFalse(message.isPresent());
}
Also used : ModelInfo(org.onap.so.serviceinstancebeans.ModelInfo) BuildingBlockExecution(org.onap.so.bpmn.common.BuildingBlockExecution) Resource(org.onap.so.bpmn.infrastructure.workflow.tasks.Resource) Service(org.onap.so.db.catalog.beans.Service) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) ServiceInstancesRequest(org.onap.so.serviceinstancebeans.ServiceInstancesRequest) RequestDetails(org.onap.so.serviceinstancebeans.RequestDetails) VnfResourceCustomization(org.onap.so.db.catalog.beans.VnfResourceCustomization) Test(org.junit.Test)

Example 80 with RequestDetails

use of org.onap.so.serviceinstancebeans.RequestDetails in project so by onap.

the class UpgradePreWorkflowValidatorTest method validateAAIVnfsNotSupported.

@Test
public void validateAAIVnfsNotSupported() throws JsonProcessingException {
    ServiceInstancesRequest sir = new ServiceInstancesRequest();
    sir.setRequestDetails(new RequestDetails());
    sir.getRequestDetails().setModelInfo(new ModelInfo());
    sir.getRequestDetails().getModelInfo().setModelUuid(UUID.randomUUID().toString());
    String modelInvariantId = UUID.randomUUID().toString();
    sir.getRequestDetails().getModelInfo().setModelInvariantId(modelInvariantId);
    Resource serviceResource = new Resource(WorkflowType.SERVICE, "", false, null);
    serviceResource.setModelInvariantId(modelInvariantId);
    Resource vnfResource = new Resource(WorkflowType.VNF, "", false, serviceResource);
    vnfResource.setVnfCustomizationId(UUID.randomUUID().toString());
    Service service = new Service();
    VnfResourceCustomization vnfCustomization = new VnfResourceCustomization();
    vnfCustomization.setModelCustomizationUUID(UUID.randomUUID().toString());
    service.setVnfCustomizations(Arrays.asList(vnfCustomization));
    when(catalogDbClient.getServiceByModelUUID(anyString())).thenReturn(service);
    BuildingBlockExecution execution = createExecution(sir, Arrays.asList(serviceResource, vnfResource));
    Optional<String> message = validator.validate(execution);
    assertTrue(message.isPresent());
    assertTrue(message.get().startsWith("Existing vnfs in AAI are not supported by service model"));
}
Also used : ModelInfo(org.onap.so.serviceinstancebeans.ModelInfo) BuildingBlockExecution(org.onap.so.bpmn.common.BuildingBlockExecution) Resource(org.onap.so.bpmn.infrastructure.workflow.tasks.Resource) Service(org.onap.so.db.catalog.beans.Service) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) ServiceInstancesRequest(org.onap.so.serviceinstancebeans.ServiceInstancesRequest) RequestDetails(org.onap.so.serviceinstancebeans.RequestDetails) VnfResourceCustomization(org.onap.so.db.catalog.beans.VnfResourceCustomization) Test(org.junit.Test)

Aggregations

RequestDetails (org.onap.so.serviceinstancebeans.RequestDetails)163 Test (org.junit.Test)126 Service (org.onap.so.db.catalog.beans.Service)55 File (java.io.File)52 ResourceKey (org.onap.so.bpmn.servicedecomposition.entities.ResourceKey)51 ExecuteBuildingBlock (org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock)47 WorkflowResourceIds (org.onap.so.bpmn.servicedecomposition.entities.WorkflowResourceIds)43 ModelInfo (org.onap.so.serviceinstancebeans.ModelInfo)42 ServiceInstance (org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance)38 HashMap (java.util.HashMap)37 GeneralBuildingBlock (org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock)36 ServiceInstancesRequest (org.onap.so.serviceinstancebeans.ServiceInstancesRequest)36 ModelInfoServiceInstance (org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoServiceInstance)35 BuildingBlock (org.onap.so.bpmn.servicedecomposition.entities.BuildingBlock)27 RequestInfo (org.onap.so.serviceinstancebeans.RequestInfo)27 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)23 ConfigurationResourceKeys (org.onap.so.bpmn.servicedecomposition.entities.ConfigurationResourceKeys)21 CloudConfiguration (org.onap.so.serviceinstancebeans.CloudConfiguration)20 GenericVnf (org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf)19 GenericVnf (org.onap.aai.domain.yang.GenericVnf)18