VcVmUtil { public static String getVolumes(String moid, List<Disk> disks) { final List<String> volumes = new ArrayList<String>(); if (disks != null && !disks.isEmpty()) { for (DiskSchema.Disk disk : disks) { if (StorageRead.DiskType.DATA_DISK.getType().equals(disk.type) || StorageRead.DiskType.SWAP_DISK.getType().equals(disk.type)) volumes.add(disk.type + ":" + VcVmUtil.fetchDiskUUID(moid, disk.externalAddress)); } } return (new Gson()).toJson(volumes); }  static boolean checkIpAddresses(final VcVirtualMachine vcVm); static List<String> getAllIpAddresses(final VcVirtualMachine vcVm); static Set<String> getAllIpAddresses(final VcVirtualMachine vcVm,
         final Set<String> portGroups, boolean inSession); static String getIpAddressOfPortGroup(final VcVirtualMachine vcVm,
         final String portGroup, boolean inSession); static ArrayList<String> getNodePrimaryMgtIPV4sFromEntitys(List<NodeEntity> nodes); static void populateNicInfo(final NicEntity nicEntity,
         final String moid, final String pgName); static String getGuestHostName(final VcVirtualMachine vcVm,
         boolean inSession); static boolean setBaseNodeForVm(BaseNode vNode, String vmId); static boolean verifyFTState(final VcVirtualMachine vm); static VirtualDisk findVirtualDisk(String vmMobId, String externalAddr); static String fetchDiskUUID(final String vmMobId, final String diskExtAddress); static void populateDiskInfo(final DiskEntity diskEntity,
         final String vmMobId); static boolean isDatastoreAccessible(String dsMobId); static void updateVm(String vmId); static boolean configIOShares(final String vmId,
         final Priority ioShares); static boolean runSPOnSingleVM(NodeEntity node, Callable<Void> call); static VcResourcePool getTargetRp(String clusterName,
         String groupName, NodeEntity node); static VmSchema getVmSchema(ClusterCreate spec, String nodeGroup,
         List<DiskSpec> diskSet, String templateVmId, String templateVmSnapId); static long makeVmMemoryDivisibleBy4(long memory); static void addBootupUUID(Map<String, String> bootupConfigs); static String getVolumes(String moid, List<Disk> disks); static List<DiskSpec> toDiskSpecList(Collection<DiskEntity> diskEntityCollection); static void sortDiskOrder(List<DiskSpec> diskSpecs); static String getVolumesFromSpecs(String moid, List<DiskSpec> diskEntities); static void destroyVm(final String vmId); static void destroyVm(final String vmId, Boolean inSession); static VcVirtualMachine findVmInRp(final VcResourcePool rp, final String vmName); static void rename(final String vmId, final String newName); static void enableFt(final VcVirtualMachine vm); static void disableHa(final VcVirtualMachine vm); static void enableDiskUUID(final VcVirtualMachine vm); static boolean enableOvfEnvTransport(final VcVirtualMachine vm); static boolean validateCPU(final String vmId, final int cpuNum); static boolean enableSyncTimeWithHost(final VcVirtualMachine vm); static void checkAndCreateSnapshot(final VmSchema vmSchema); static String getHostNameFromIpV4(VcVirtualMachine vcVm, String ipV4); static String getMgtHostName(VcVirtualMachine vcVm, String primaryMgtIpV4); static final String NIC_LABEL_PREFIX; }
@Test public void testGetVolumesByDiskSchema() { DiskSchema.Disk sysDisk = new Disk(); sysDisk.type = "OS"; sysDisk.externalAddress = "LSI0:0"; DiskSchema.Disk swapDisk = new Disk(); swapDisk.type = "SWAP"; swapDisk.externalAddress = "LSI0:1"; DiskSchema.Disk dataDisk0 = new Disk(); dataDisk0.type = "DATA"; dataDisk0.externalAddress = "PARA0:0"; DiskSchema.Disk dataDisk1 = new Disk(); dataDisk1.type = "DATA"; dataDisk1.externalAddress = "PARA1:0"; List<Disk> disks = new ArrayList<Disk>(); disks.add(sysDisk); disks.add(swapDisk); disks.add(dataDisk0); disks.add(dataDisk1); Mockit.setUpMock(MockVcVmUtil.class); String volumes = VcVmUtil.getVolumes("vm-01", disks); System.out.println(volumes); }