### Question:
Path { public Path extract(Map params, Path toMatch) { return extract(params, toMatch, false); } Path();  Path(Path path);  Path(String... part);  Path(List<String> parts); List<String> parts(); String first(); String last(); String get(int index); void add(String parts); String remove(int index); boolean startsWith(List<String> partsToMatch); int size(); String toString(); boolean equals(Object o); Path subpath(int fromIndex, int toIndex); boolean isStatic(int index); boolean isWildcard(int index); boolean isVar(int index); String getVarName(int index); boolean isOptional(int index); boolean matches(String toMatch); boolean matches(Path concretePath); Path extract(Map params, Path toMatch); Path extract(Map params, Path matchingConcretePath, boolean greedy);  }### Answer:
@Test public void extract_regexDoesNotMatch_error() { boolean error = false; try { Map<String, String> params = new HashMap<>(); Path rule = new Path("part1/{part2:[0-9a-zA-Z]{1,8}}/part3/*"); Path path = new Path("part1/23452345234523452345/part3/part4"); Path matched = rule.extract(params, path); } catch (Exception e) { error = true; } assertTrue(error, "The test should have errored because 'the regex does not match'"); }
@Test public void extract_pathDoesNotMatch_error() { boolean error = false; try { Map<String, String> params = new HashMap<>(); Path rule = new Path("part1/part2/part3/*"); Path path = new Path("part1/part5/part3/part4"); Path matched = rule.extract(params, path); } catch (Exception e) { error = true; } assertTrue(error, "The test should have errored because 'the paths do not match'"); }
@Test public void extract_missingClosingBracketIsConsideredLiteralNotVariable() { Map<String, String> params = new HashMap<>(); Path rule = new Path("part1/{part2/part3/*"); Path path = new Path("part1/val2/part3/part4"); boolean error = false; try { rule.extract(params, path); } catch (Exception ex) { error = true; } assertTrue(error, "The test should have errored because '{part2' is not a literal match fror 'val2'"); }