### Question:
AAIDataRetrieval { public List<VolumeGroup> getVolumeGroupsOfVnf(String vnfId) { List<VolumeGroup> volumeGroupList = new ArrayList<VolumeGroup>(); AAIPluralResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf(vnfId)) .relatedTo(Types.VOLUME_GROUPS.getFragment()); Optional<VolumeGroups> volumeGroups = getAaiResourcesClient().get(VolumeGroups.class, uri); if (!volumeGroups.isPresent() || volumeGroups.get().getVolumeGroup().isEmpty()) { logger.debug("No VolumeGroups attached to Vnf in AAI : {}", vnfId); } else { volumeGroupList = volumeGroups.get().getVolumeGroup(); } return volumeGroupList; }  ServiceInstance getServiceInstance(String serviceInstanceId); VfModule getAAIVfModule(String vnfId, String vfModuleId); GenericVnf getGenericVnf(String vnfId); VolumeGroup getVolumeGroup(String vnfId, String volumeGroupId); L3Network getNetwork(String networkId); boolean isVolumeGroupRelatedToVFModule(CloudConfiguration cloudConfig, String volumeGroupId); boolean isVnfRelatedToVolumes(String vnfId); boolean isNetworkRelatedToModules(String networkId); boolean isServiceRelatedToNetworks(String serviceInstanceId); boolean isServiceRelatedToGenericVnf(String serviceInstanceId); boolean isServiceRelatedToConfiguration(String serviceInstanceId); Service getService(String serviceId); Tenant getTenant(String cloudOwner, String cloudRegion, String tenantId); List<LInterface> getLinterfacesOfVnf(String vnfId); boolean isVnfRelatedToVFModule(String vnfId); List<VfModule> getVfModulesOfVnf(String vnfId); Optional<String> getVfModuleIdsByVnfId(String vnfId); List<VolumeGroup> getVolumeGroupsOfVnf(String vnfId); Optional<String> getVolumeGroupIdsByVnfId(String vnfId);  }### Answer:
@Test public void getVolumeGroupsOfVnfTest() throws Exception { VolumeGroups volumeGroups = getVolumeGroups(); AAIPluralResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf("vnfId")) .relatedTo(Types.VOLUME_GROUPS.getFragment()); doReturn(Optional.of(volumeGroups)).when(aaiResourcesClient).get(VolumeGroups.class, uri); List<VolumeGroup> volumeGroupList = aaiDataRetrieval.getVolumeGroupsOfVnf("vnfId"); assertEquals("vg1", volumeGroupList.get(0).getVolumeGroupId()); Optional<String> volumeGroupIds = aaiDataRetrieval.getVolumeGroupIdsByVnfId("vnfId"); assertEquals(Optional.of("vg1,vg2"), volumeGroupIds); }