public Set<Guid> fetchMemoryDisks(XmlDocument xmlDocument) { Set<Guid> memoryDiskIds = new HashSet<>(); xmlDocument.selectNodes("ovf:SnapshotsSection_Type"); XmlNode content = xmlDocument.selectSingleNode("//*/Content"); XmlNodeList nodeList = content.selectNodes("Section"); if (nodeList != null) { for (XmlNode section : nodeList) { String value = section.attributes.get("xsi:type").getValue(); if (value.equals("ovf:SnapshotsSection_Type")) { Iterator<XmlNode> snapshotIter = section.selectNodes("Snapshot").iterator(); while (snapshotIter.hasNext()) { XmlNode memorySnapshot = snapshotIter.next().selectSingleNode("Memory"); if (memorySnapshot != null) { List<Guid> guids = Guid.createGuidListFromString(memorySnapshot.innerText); memoryDiskIds.add(guids.get(2)); memoryDiskIds.add(guids.get(4)); } } } } } return memoryDiskIds; }
@Test public void testNullGuidListValues() { List<Guid> stringList = Guid.createGuidListFromString(null); List<Guid> expectedList = new ArrayList<>(); assertEquals(expectedList, stringList); } }
@Test public void testEmptyGuidListValues() { String listValues = ""; List<Guid> stringList = Guid.createGuidListFromString(listValues); List<Guid> expectedList = new ArrayList<>(); assertEquals(expectedList, stringList); }
@Test public void testGuidListValuesWithOneGuid() { String listValues = "e61f7070-cd52-46ca-88c2-686e1c70fe44"; List<Guid> stringList = Guid.createGuidListFromString(listValues); List<Guid> expectedList = new ArrayList<>(); expectedList.add(new Guid("e61f7070-cd52-46ca-88c2-686e1c70fe44")); assertEquals(expectedList, stringList); }
@Test public void testGuidListValues() { String listValues = "e61f7070-cd52-46ca-88c2-686e1c70fe44,1eaa381a-fbf9-4ef5-bec2-6e4337f85d66"; List<Guid> stringList = Guid.createGuidListFromString(listValues); List<Guid> expectedList = new ArrayList<>(); expectedList.add(new Guid("e61f7070-cd52-46ca-88c2-686e1c70fe44")); expectedList.add(new Guid("1eaa381a-fbf9-4ef5-bec2-6e4337f85d66")); assertEquals(expectedList, stringList); }
.getTimestamp("lastModified"))); entity.setAppList(rs.getString("app_list")); entity.setStorageIds(Guid.createGuidListFromString(rs.getString("storage_id"))); entity.setStorageTypes(getStorageTypesList(rs.getString("storage_type"))); entity.setStoragesNames(split(rs.getString("storage_name")));
entity.setSpiceCopyPasteEnabled(rs.getBoolean("is_spice_copy_paste_enabled")); entity.setMigrationSupport(MigrationSupport.forValue(rs.getInt("migration_support"))); entity.setDedicatedVmForVdsList(Guid.createGuidListFromString(rs.getString("dedicated_vm_for_vds"))); entity.setMinAllocatedMem(rs.getInt("min_allocated_mem")); entity.setQuotaId(getGuid(rs, "quota_id"));
XmlNode memory = selectSingleNode(node, "Memory", _xmlNS); if (memory != null) { List<Guid> guids = Guid.createGuidListFromString(memory.innerText); snapshot.setMemoryDiskId(guids.get(2)); snapshot.setMetadataDiskId(guids.get(4));