RedisAdminImpl implements RedisAdmin { Map<String, String> parseInfo(String info) { Map<String, String> values = Maps.newHashMapWithExpectedSize(128); StringTokenizer tokenizer = new StringTokenizer(info, "\r\n"); while (tokenizer.hasMoreTokens()) { String line = tokenizer.nextToken(); if (!Strings.startsWith(line, '#')) { int index = line.indexOf(':'); values.put(line.substring(0, index), line.substring(index + 1)); } } return values; } RedisAdminImpl(RedisImpl redis); @Override Map<String, String> info();  }
@Test void parseInfo() { String info = "# Server\r\nredis_version:5.0.7\r\nconfig_file:\r\n\r\n# Clients\r\nconnected_clients:1\r\n"; Map<String, String> values = redis.parseInfo(info); assertThat(values) .containsEntry("redis_version", "5.0.7") .containsEntry("config_file", "") .containsEntry("connected_clients", "1"); }