@Test public void getRegistryValuesFromLines() throws Exception { final String key = "HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings"; final String content = IOUtils.readContentAsUtf8String(RegistryQueryTest.class.getResourceAsStream("reg_query.out")); final List<String> lines = Arrays.asList(content.split(System.lineSeparator())); final Map<String, RegistryValue> values = RegistryQuery.getRegistryValuesFromLines(key, lines); Assertions.assertEquals(14, values.size()); Assertions.assertNotNull(values.get("DisableCachingOfSSLPages")); Assertions.assertEquals(RegistryValueType.REG_DWORD, values.get("DisableCachingOfSSLPages").getType()); Assertions.assertEquals("0x0", values.get("DisableCachingOfSSLPages").getValue()); Assertions.assertFalse(values.get("DisableCachingOfSSLPages").getValueAsBoolean()); Assertions.assertNotNull(values.get("MigrateProxy")); Assertions.assertEquals(RegistryValueType.REG_DWORD, values.get("MigrateProxy").getType()); Assertions.assertEquals("0x1", values.get("MigrateProxy").getValue()); Assertions.assertTrue(values.get("MigrateProxy").getValueAsBoolean()); Assertions.assertNotNull(values.get("ProxyServer")); Assertions.assertEquals(RegistryValueType.REG_SZ, values.get("ProxyServer").getType()); Assertions.assertEquals("loooocalhost:80", values.get("ProxyServer").getValue()); Assertions.assertNotNull(values.get("AutoConfigURL")); Assertions.assertEquals(RegistryValueType.REG_SZ, values.get("AutoConfigURL").getType()); Assertions.assertEquals("huhu", values.get("AutoConfigURL").getValue()); }
static Map<String, RegistryValue> getRegistryValuesFromLines(final String key, final List<String> lines) { return lines.stream() .filter(l -> !l.contains(key)) .map(String::trim) .filter(l -> !l.isEmpty()) .map(RegistryQuery::parseSingleLine) .collect(Collectors.toMap(RegistryValue::getName, Function.identity())); }
RegistryQuery { static Map<String, RegistryValue> getRegistryValuesFromLines(final String key, final List<String> lines) { return lines.stream() .filter(l -> !l.contains(key)) .map(String::trim) .filter(l -> !l.isEmpty()) .map(RegistryQuery::parseSingleLine) .collect(Collectors.toMap(RegistryValue::getName, Function.identity())); } }
RegistryQuery { static Map<String, RegistryValue> getRegistryValuesFromLines(final String key, final List<String> lines) { return lines.stream() .filter(l -> !l.contains(key)) .map(String::trim) .filter(l -> !l.isEmpty()) .map(RegistryQuery::parseSingleLine) .collect(Collectors.toMap(RegistryValue::getName, Function.identity())); }  }
RegistryQuery { static Map<String, RegistryValue> getRegistryValuesFromLines(final String key, final List<String> lines) { return lines.stream() .filter(l -> !l.contains(key)) .map(String::trim) .filter(l -> !l.isEmpty()) .map(RegistryQuery::parseSingleLine) .collect(Collectors.toMap(RegistryValue::getName, Function.identity())); }  static RegistryQueryResult getAllValuesForKey(final String key); }
RegistryQuery { static Map<String, RegistryValue> getRegistryValuesFromLines(final String key, final List<String> lines) { return lines.stream() .filter(l -> !l.contains(key)) .map(String::trim) .filter(l -> !l.isEmpty()) .map(RegistryQuery::parseSingleLine) .collect(Collectors.toMap(RegistryValue::getName, Function.identity())); }  static RegistryQueryResult getAllValuesForKey(final String key);  }