LsBlkUtils { static List<LsBlkEntry> parseLsblkOutput(String lsblkOutput) { ArrayList<LsBlkEntry> lsBlkEntries = new ArrayList<>(); for (String line : lsblkOutput.split("\n")) { List<String> fields = splitFields(line.trim()); if (fields.size() > 0) { lsBlkEntries.add(new LsBlkEntry(fields)); } } return lsBlkEntries; } private  LsBlkUtils(); static List<LsBlkEntry> lsblk(ExtCmd extCmd); static boolean parentIsVDO(ExtCmd extCmd, @Nonnull List<String> devicePaths); static String[] blkid(ExtCmd extCmd); static List<LsBlkEntry> filterDeviceCandidates(List<LsBlkEntry> entries, final String[] blkIdEntries);  }
@Test public void testLsBlkParse() { List<LsBlkEntry> lsBlkEntries = LsBlkUtils.parseLsblkOutput(TEST_DATA); Assert.assertEquals(14, lsBlkEntries.size()); Assert.assertEquals("sr0", lsBlkEntries.get(0).getName()); Assert.assertEquals("drbd1001", lsBlkEntries.get(lsBlkEntries.size() - 1).getName()); }
@Test(expected = RuntimeException.class) public void testLsBlkParseMissingSpace() { LsBlkUtils.parseLsblkOutput(FAIL_INPUT_MIS_SPACE); }