OnDemandScreenshotService { static Map<String, String> keyValueMapFor(String logLine) { Map<String, String> keyValueMap = new HashMap<String, String>(); Matcher matcher = KEY_VALUE_HOLDER_PATTERN.matcher(logLine); if (matcher.find()) { for (String keyValuePair : matcher.group(1).split(",")) { int separatorIndex = keyValuePair.indexOf("="); if (separatorIndex > 0) { String key = keyValuePair.substring(0, separatorIndex); String value = keyValuePair.substring(separatorIndex + 1); keyValueMap.put(key, value); } } } return keyValueMap; } OnDemandScreenshotService(IDevice device, ScreenshotProcessor... processors); void start(); void finish();  }
@Test public void shouldParseLogLineWithPrefixFields() { assertThat(keyValueMapFor("02-28 11:37:49.629 D/screenshot_request(26711): {name=beta}"), IsMap.containingOnly("name", "beta")); }
@Test public void shouldParseLogLineWithKeyValue() { assertThat(keyValueMapFor("{name=ConfigureMorseActivity-SOS}"), IsMap.containingOnly("name", "ConfigureMorseActivity-SOS")); }
@Test public void shouldParseLogLineWithTwoKeyValues() { assertThat(keyValueMapFor("{foo=bar,alpha=beta}"), IsMap.containingOnly("foo", "bar").and("alpha", "beta")); }