PackageReferenceListParser { public PackageReferenceList parse(String specifier) { if (Strings.isNullOrEmpty(specifier)) return new PackageReferenceList(); final PackageReferenceList result = new PackageReferenceList(); String segments[] = specifier.split("\\s*,\\s*"); for (String segment : segments) { if (segment.contains("|")) result.add(parseOrReference(segment)); else result.add(parseSingle(segment)); } return result; }  PackageReferenceList parse(String specifier);  }
@Test public void testParseSingleWithVersion() throws Exception { final String input = "foo-data (<< 2.15-2)"; PackageReferenceList list = parse(input); assertSingle(list, 0, "foo-data", PackageReference.Relation.EARLIER, "2.15", "2"); }
@Test public void testParseMultiple() throws Exception { final String input = "foo-data, bar, baz"; PackageReferenceList list = parse(input); assertSingle(list, 0, "foo-data"); assertSingle(list, 1, "bar"); assertSingle(list, 2, "baz"); }
@Test public void testParseMultipleWithVersion() throws Exception { final String input = "foo-data (<< 2.15-2), bar (= 23-1), baz (>> 15)"; PackageReferenceList list = parse(input); assertSingle(list, 0, "foo-data", PackageReference.Relation.EARLIER, "2.15", "2"); assertSingle(list, 1, "bar", PackageReference.Relation.EQUAL, "23", "1"); assertSingle(list, 2, "baz", PackageReference.Relation.LATER, "15", null); }