@Test public void testParse() throws Exception { try { PathParser.ParsedPath parsed = PathParser.parse(testCase.path); assertEquals(testCase.expectedPath, parsed); try { assertEquals(testCase.generatedPath.orElse("No generated URL expected"), parsed.toPath()); } catch (IllegalArgumentException e) { testCase.generatedPath.ifPresent(s -> fail("Expected URL but IAE generated: " + e.getMessage())); } } catch (PathParser.ParseException e) { testCase.generatedPath.ifPresent(s -> fail(e.getMessage())); } }
public static ParsedPath parse(String path) { Parser parser = new Parser(path); List<Segment> segments = new ArrayList<>(); while (parser.hasNext()) { Segment segment = parseSegment(parser); if (segment != null) { segments.add(segment); } } return new ParsedPath(segments); }
PathParser { public static ParsedPath parse(String path) { Parser parser = new Parser(path); List<Segment> segments = new ArrayList<>(); while (parser.hasNext()) { Segment segment = parseSegment(parser); if (segment != null) { segments.add(segment); } } return new ParsedPath(segments); } }
PathParser { public static ParsedPath parse(String path) { Parser parser = new Parser(path); List<Segment> segments = new ArrayList<>(); while (parser.hasNext()) { Segment segment = parseSegment(parser); if (segment != null) { segments.add(segment); } } return new ParsedPath(segments); }  }
PathParser { public static ParsedPath parse(String path) { Parser parser = new Parser(path); List<Segment> segments = new ArrayList<>(); while (parser.hasNext()) { Segment segment = parseSegment(parser); if (segment != null) { segments.add(segment); } } return new ParsedPath(segments); }  static ParsedPath parse(String path); }
PathParser { public static ParsedPath parse(String path) { Parser parser = new Parser(path); List<Segment> segments = new ArrayList<>(); while (parser.hasNext()) { Segment segment = parseSegment(parser); if (segment != null) { segments.add(segment); } } return new ParsedPath(segments); }  static ParsedPath parse(String path);  }