### Question:
ProtobufPathParser { static List<PathFragment> parse(String protobufPath) { validatePrefix(protobufPath); String[] tokens = protobufPath.substring(2).split("\\."); List<PathFragment> pathFragments = new ArrayList<>(); for (String token : tokens) { Matcher repeatedFieldMatcher = REPEATED_FIELD_PATTERN.matcher(token); if (repeatedFieldMatcher.matches()) { pathFragments.add(parseRepeatedField(protobufPath, repeatedFieldMatcher)); continue; } Matcher plainFieldMatcher = PLAIN_FIELD_PATTERN.matcher(token); if (plainFieldMatcher.matches()) { pathFragments.add(parsePlainField(plainFieldMatcher)); continue; } throw new IllegalArgumentException("Parse error in " + protobufPath + " at " + token); } return pathFragments; }    }### Answer:
@Test public void exampleUsage() { List<PathFragment> fragments = ProtobufPathParser.parse("$.foo.bar.baz"); assertThat(fragments, Matchers.contains(fragment("foo"), fragment("bar"), fragment("baz"))); }
@Test public void repeatedField() { List<PathFragment> fragments = ProtobufPathParser.parse("$.foo[1].bar[7]"); assertThat(fragments, Matchers.contains(fragment("foo", 1), fragment("bar", 7))); }