diff options
author | Kuleshov, Elena <evn@att.com> | 2019-12-18 09:24:33 -0500 |
---|---|---|
committer | Benjamin, Max (mb388a) <mb388a@att.com> | 2019-12-18 09:24:34 -0500 |
commit | c0fbd45596e038ecceb77422c4cae840ad114efa (patch) | |
tree | c9b76ff27774b5a87e6539c3995fd5778907f965 /bpmn/MSOCommonBPMN/src | |
parent | 145eb372a14a2dd25f75033acd37e269c33caf95 (diff) |
Support for volume groups on replace VF Module.
Support for volume groups on replace VF Module.
[MSO-8375 R2002} Add full JUnit coverage for replaceVFModule scenarios,
add replace changes to general macro data.
Fix a JUnit to pass correct parameters to a method.
Add back setting volume group id for new volume group on replace action.
Issue-ID: SO-2577
Signed-off-by: Benjamin, Max (mb388a) <mb388a@att.com>
Change-Id: I73289da21e0c7de7451b63e99e184692e800aaf0
Diffstat (limited to 'bpmn/MSOCommonBPMN/src')
4 files changed, 80 insertions, 1 deletions
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetup.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetup.java index 7e982369bb..88c36bec3a 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetup.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetup.java @@ -117,6 +117,7 @@ public class BBInputSetup implements JavaDelegate { private static final String VNF = "Vnf"; private static final String NETWORK_COLLECTION = "NetworkCollection"; private static final String PREPROV = "PREPROV"; + private static final String CREATEVOLUME = "CreateVolume"; @Autowired private BBInputSetupUtils bbInputSetupUtils; @@ -381,7 +382,8 @@ public class BBInputSetup implements JavaDelegate { this.populateGenericVnf(requestId, modelInfo, instanceName, platform, lineOfBusiness, service, bbName, serviceInstance, lookupKeyMap, relatedInstanceList, resourceId, vnfType, null, productFamilyId, applicationId); - } else if (modelType.equals(ModelType.volumeGroup)) { + } else if (modelType.equals(ModelType.volumeGroup) || (modelType.equals(ModelType.vfModule) + && (bbName.equalsIgnoreCase(AssignFlows.VOLUME_GROUP.toString()) || bbName.startsWith(CREATEVOLUME)))) { lookupKeyMap.put(ResourceKey.VOLUME_GROUP_ID, resourceId); this.populateVolumeGroup(requestId, modelInfo, service, bbName, serviceInstance, lookupKeyMap, resourceId, relatedInstanceList, instanceName, vnfType, null); @@ -605,6 +607,7 @@ public class BBInputSetup implements JavaDelegate { bbInputSetupUtils.getAAIVolumeGroup(cloudOwner, cloudRegionId, volumeGroup.getVolumeGroupId()) .getModelCustomizationId(); if (modelInfo.getModelCustomizationId().equalsIgnoreCase(volumeGroupCustId)) { + logger.debug("Found volume group for vfModule: " + volumeGroup.getVolumeGroupId()); return Optional.of(volumeGroup.getVolumeGroupId()); } } diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupUtils.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupUtils.java index 3d5533de32..994abda083 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupUtils.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupUtils.java @@ -571,6 +571,24 @@ public class BBInputSetupUtils { } } + public Optional<VolumeGroup> getRelatedVolumeGroupFromVfModule(String vnfId, String vfModuleId) throws Exception { + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.VF_MODULE, vnfId, vfModuleId); + uri.relatedTo(AAIObjectPlurals.VOLUME_GROUP); + Optional<VolumeGroups> volumeGroups = injectionHelper.getAaiClient().get(VolumeGroups.class, uri); + VolumeGroup volumeGroup = null; + if (!volumeGroups.isPresent()) { + logger.debug("VfModule does not have a volume group attached"); + return Optional.empty(); + } else { + if (volumeGroups.get().getVolumeGroup().size() > 1) { + throw new Exception("Multiple VolumeGroups Returned"); + } else { + volumeGroup = volumeGroups.get().getVolumeGroup().get(0); + } + return Optional.of(volumeGroup); + } + } + public Optional<org.onap.aai.domain.yang.VpnBinding> getAICVpnBindingFromNetwork( org.onap.aai.domain.yang.L3Network aaiLocalNetwork) { AAIResultWrapper networkWrapper = new AAIResultWrapper(aaiLocalNetwork); diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupTest.java index ffbf673cdb..483b626f95 100644 --- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupTest.java +++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupTest.java @@ -888,6 +888,18 @@ public class BBInputSetupTest { lookupKeyMap, resourceId, relatedInstanceList, instanceName, null, cloudConfiguration, false); assertEquals("VfModuleId populated", true, lookupKeyMap.get(ResourceKey.VF_MODULE_ID).equalsIgnoreCase(resourceId)); + + String bbNameAssignVolume = AssignFlows.VOLUME_GROUP.toString(); + doReturn(ModelType.vfModule).when(modelInfo).getModelType(); + resourceId = "vfModuleId"; + doNothing().when(SPY_bbInputSetup).populateVolumeGroup(REQUEST_ID, modelInfo, service, bbNameAssignVolume, + serviceInstance, lookupKeyMap, resourceId, relatedInstanceList, instanceName, vnfType, null); + SPY_bbInputSetup.populateObjectsOnAssignAndCreateFlows(REQUEST_ID, requestDetails, service, bbNameAssignVolume, + serviceInstance, lookupKeyMap, resourceId, vnfType, null, null, false); + verify(SPY_bbInputSetup, times(1)).populateVolumeGroup(REQUEST_ID, modelInfo, service, bbNameAssignVolume, + serviceInstance, lookupKeyMap, resourceId, relatedInstanceList, instanceName, vnfType, null); + assertEquals("VolumeGroupId populated", true, + lookupKeyMap.get(ResourceKey.VOLUME_GROUP_ID).equalsIgnoreCase(resourceId)); } @Test diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupUtilsTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupUtilsTest.java index 2b78690e27..3fdbf39756 100644 --- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupUtilsTest.java +++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupUtilsTest.java @@ -815,6 +815,51 @@ public class BBInputSetupUtilsTest { } @Test + public void getRelatedVolumeGroupFromVfModuleMultipleVolumeGroupsExceptionTest() throws Exception { + expectedException.expect(Exception.class); + + String vnfId = "vnfId"; + String volumeGroupId = "volumeGroupId"; + + VolumeGroup volumeGroup = new VolumeGroup(); + volumeGroup.setVolumeGroupId("id123"); + volumeGroup.setVolumeGroupName("name123"); + + VolumeGroups expectedVolumeGroup = new VolumeGroups(); + expectedVolumeGroup.getVolumeGroup().add(volumeGroup); + expectedVolumeGroup.getVolumeGroup().add(volumeGroup); + + doReturn(expectedVolumeGroup).when(MOCK_aaiResourcesClient).get(eq(VolumeGroups.class), + any(AAIResourceUri.class)); + + bbInputSetupUtils.getRelatedVolumeGroupFromVfModule(vnfId, volumeGroupId); + } + + @Test + public void getRelatedVolumeGroupFromVfModuleNotFoundTest() throws Exception { + String vnfId = "vnfId"; + String volumeGroupId = "volumeGroupId"; + + doReturn(Optional.empty()).when(MOCK_aaiResourcesClient).get(eq(VolumeGroups.class), any(AAIResourceUri.class)); + + Optional<VolumeGroup> actualVolumeGroup = + bbInputSetupUtils.getRelatedVolumeGroupFromVfModule(vnfId, volumeGroupId); + + assertEquals(actualVolumeGroup, Optional.empty()); + } + + @Test + public void getRelatedVolumeGroupFromVfModuleTest() throws Exception { + Optional<VolumeGroups> expected = Optional.of(new VolumeGroups()); + VolumeGroup volumeGroup = new VolumeGroup(); + volumeGroup.setVolumeGroupId("id123"); + expected.get().getVolumeGroup().add(volumeGroup); + doReturn(expected).when(MOCK_aaiResourcesClient).get(eq(VolumeGroups.class), any(AAIResourceUri.class)); + Optional<VolumeGroup> actual = this.bbInputSetupUtils.getRelatedVolumeGroupFromVfModule("id123", "id123"); + assertEquals(actual.get().getVolumeGroupId(), expected.get().getVolumeGroup().get(0).getVolumeGroupId()); + } + + @Test public void getRelatedVolumeGroupByNameFromVfModuleMultipleVolumeGroupsExceptionTest() throws Exception { expectedException.expect(MultipleObjectsFoundException.class); expectedException.expectMessage(containsString( @@ -852,6 +897,7 @@ public class BBInputSetupUtilsTest { assertEquals(actualVolumeGroup, Optional.empty()); } + @Test public void loadOriginalFlowExecutionPathTest() throws Exception { |