diff options
author | 2021-10-20 15:30:34 -0400 | |
---|---|---|
committer | 2021-10-20 15:33:52 -0400 | |
commit | a01bad71f9e8de0effb443bd0266c5c9db033bdf (patch) | |
tree | b3a3916fca9c429b7aed9faa36f2ea6fba7da5e8 /bpmn/so-bpmn-tasks/src/test/java/org/onap | |
parent | b94c8572015765a2312839427a71148f4ef37ae3 (diff) |
Add missing code for enabling VNF LCM features
This ensures isBase is set on vf-modules in delete flows, which will
ensure correct deletion order. It also adds a AAI lookup for vnfs to
fetch modelCustomization ids, which are necessary for validations in
service-macro-upgrade.
Issue-ID: SO-3794
Signed-off-by: Jozsef Csongvai <jozsef.csongvai@bell.ca>
Change-Id: I4a6f5eb21633b4a8be8107b290b04c77d854bc0d
Diffstat (limited to 'bpmn/so-bpmn-tasks/src/test/java/org/onap')
3 files changed, 42 insertions, 1 deletions
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionTest.java index 021bac3a7a..52196aae49 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionTest.java @@ -66,7 +66,9 @@ import org.junit.Test; import org.junit.rules.ExpectedException; import org.mockito.InjectMocks; import org.mockito.Mock; +import org.mockito.Mockito; import org.mockito.Spy; +import org.onap.aai.domain.yang.GenericVnf; import org.onap.aai.domain.yang.Relationship; import org.onap.aai.domain.yang.RelationshipList; import org.onap.aai.domain.yang.ServiceInstance; @@ -409,6 +411,7 @@ public class WorkflowActionTest extends BaseTaskTest { doReturn(serviceInstanceAAI).when(bbSetupUtils).getAAIServiceInstanceById("si0"); doReturn(serviceInstanceMSO).when(bbInputSetup).getExistingServiceInstance(serviceInstanceAAI); + doReturn(Mockito.mock(GenericVnf.class)).when(bbSetupUtils).getAAIGenericVnf(any()); when(catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner(gAction, resource, false, "my-custom-cloud-owner")).thenReturn(northBoundRequest); workflowAction.selectExecutionList(execution); @@ -931,6 +934,7 @@ public class WorkflowActionTest extends BaseTaskTest { doReturn(serviceInstanceAAI).when(bbSetupUtils).getAAIServiceInstanceById("123"); doReturn(serviceInstanceMSO).when(bbInputSetup).getExistingServiceInstance(serviceInstanceAAI); + doReturn(Mockito.mock(GenericVnf.class)).when(bbSetupUtils).getAAIGenericVnf(any()); when(catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner(gAction, resource, false, "my-custom-cloud-owner")).thenReturn(northBoundRequest); workflowAction.selectExecutionList(execution); @@ -1011,6 +1015,7 @@ public class WorkflowActionTest extends BaseTaskTest { doReturn(serviceInstanceAAI).when(bbSetupUtils).getAAIServiceInstanceById("123"); doReturn(serviceInstanceMSO).when(bbInputSetup).getExistingServiceInstance(serviceInstanceAAI); + doReturn(Mockito.mock(GenericVnf.class)).when(bbSetupUtils).getAAIGenericVnf(any()); when(catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner(gAction, resource, false, "my-custom-cloud-owner")).thenReturn(northBoundRequest); workflowAction.selectExecutionList(execution); diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ebb/loader/ServiceEBBLoaderTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ebb/loader/ServiceEBBLoaderTest.java index 7a26422eb9..2725626c1a 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ebb/loader/ServiceEBBLoaderTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ebb/loader/ServiceEBBLoaderTest.java @@ -41,6 +41,7 @@ import org.onap.so.bpmn.infrastructure.workflow.tasks.Resource; import org.onap.so.bpmn.infrastructure.workflow.tasks.VrfBondingServiceException; import org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowType; import org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration; +import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf; import org.onap.so.bpmn.servicedecomposition.tasks.BBInputSetup; import org.onap.so.bpmn.servicedecomposition.tasks.BBInputSetupUtils; import org.onap.so.client.exception.ExceptionBuilder; @@ -206,13 +207,16 @@ public class ServiceEBBLoaderTest extends BaseTaskTest { serviceInstanceAAI.setServiceInstanceId(resourceId); org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance serviceInstance = setServiceInstance(); - setGenericVnf(); + GenericVnf genericVnf = setGenericVnf(); setVfModule(true); setVolumeGroup(); setL3Network(); setCollection(); setConfiguration(); + org.onap.aai.domain.yang.GenericVnf genericVnfAai = new org.onap.aai.domain.yang.GenericVnf(); + genericVnfAai.setModelCustomizationId(genericVnf.getModelInfoGenericVnf().getModelCustomizationUuid()); + Configuration config = new Configuration(); config.setConfigurationId("testConfigurationId2"); serviceInstance.getConfigurations().add(config); @@ -236,6 +240,7 @@ public class ServiceEBBLoaderTest extends BaseTaskTest { aaiConfiguration2.setRelationshipList(relationshipList1); try { + doReturn(genericVnfAai).when(mockBbInputSetupUtils).getAAIGenericVnf(genericVnf.getVnfId()); doReturn(serviceInstanceAAI).when(mockBbInputSetupUtils).getAAIServiceInstanceById(resourceId); doReturn(serviceInstance).when(mockBbInputSetup).getExistingServiceInstance(serviceInstanceAAI); doReturn(Optional.of(aaiConfiguration1)).when(mockAaiConfigurationResources) diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ebb/loader/VnfEBBLoaderTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ebb/loader/VnfEBBLoaderTest.java index a9bfde9bab..78a9628243 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ebb/loader/VnfEBBLoaderTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ebb/loader/VnfEBBLoaderTest.java @@ -32,8 +32,11 @@ import org.camunda.bpm.extension.mockito.delegate.DelegateExecutionFake; import org.javatuples.Pair; import org.junit.Before; import org.junit.Test; +import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf; import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance; import org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowType; +import org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule; +import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoVfModule; import org.onap.so.bpmn.servicedecomposition.tasks.BBInputSetup; import org.onap.so.bpmn.servicedecomposition.tasks.BBInputSetupUtils; import org.onap.so.client.exception.ExceptionBuilder; @@ -41,6 +44,7 @@ import org.onap.so.bpmn.infrastructure.workflow.tasks.Resource; import java.util.ArrayList; import java.util.List; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.mock; @@ -82,4 +86,31 @@ public class VnfEBBLoaderTest { cut.traverseAAIVnf(delegateExecution, resourceList, serviceId, vnfId, aaiResourceIds); assertEquals(WorkflowType.SERVICE, resourceList.get(0).getResourceType()); } + + @Test + public void traverseAAIVnf_should_add_vnfs_and_vfmodules() throws Exception { + List<Resource> resourceList = new ArrayList<>(); + List<Pair<WorkflowType, String>> aaiResourceIds = new ArrayList<>(); + + GenericVnf genericVnf = mock(GenericVnf.class); + doReturn(vnfId).when(genericVnf).getVnfId(); + + VfModule vfModule = mock(VfModule.class); + ModelInfoVfModule modelInfoVfModule = new ModelInfoVfModule(); + modelInfoVfModule.setIsBaseBoolean(true); + doReturn(modelInfoVfModule).when(vfModule).getModelInfoVfModule(); + + doReturn(serviceInstanceAAI).when(bbInputSetupUtils).getAAIServiceInstanceById(serviceId); + doReturn(serviceInstanceMSO).when(bbInputSetup).getExistingServiceInstance(serviceInstanceAAI); + doReturn(List.of(genericVnf)).when(serviceInstanceMSO).getVnfs(); + doReturn(List.of(vfModule)).when(genericVnf).getVfModules(); + cut = new VnfEBBLoader(bbInputSetupUtils, bbInputSetup, workflowActionUtils, exceptionBuilder); + + cut.traverseAAIVnf(delegateExecution, resourceList, serviceId, vnfId, aaiResourceIds); + + assertEquals(3, resourceList.size()); + assertEquals(WorkflowType.VNF, resourceList.get(1).getResourceType()); + assertEquals(WorkflowType.VFMODULE, resourceList.get(2).getResourceType()); + assertTrue(resourceList.get(2).isBaseVfModule()); + } } |