PathCorrector implements Function<String, String> { @Override public String apply(final String path) { if (isNull(path)) { return SLASH; } if (path.contains(" throw new InvalidConfigurationException("Route's path cannot contain string ' } if (SLASH.equals(path)) { return path; } if (BLANK_PATH.equals(path)) { return SLASH; } if (path.startsWith(SLASH) && !path.endsWith(SLASH)) { return path; } if (path.startsWith(SLASH) && path.endsWith(SLASH)) { return removeLastChar(path); } if (!path.startsWith(SLASH) && !path.endsWith(SLASH)) { return SLASH + path; } if (!path.startsWith(SLASH) && path.endsWith(SLASH)) { return SLASH + removeLastChar(path); } return path; }  @Override String apply(final String path);  }
@Test public void contains_single_slash() { String result = testedClass.apply("/"); assertEquals("/", result); }
@Test public void contains_blank_Path() { String result = testedClass.apply(""); assertEquals("/", result); }
@Test public void contains_starts_slash() { String result = testedClass.apply("/services/jokes/path"); assertEquals("/services/jokes/path", result); }
@Test public void contains_both_slash() { String result = testedClass.apply("/services/jokes/path/"); assertEquals("/services/jokes/path", result); }
@Test public void contains_both_without_slash() { String result = testedClass.apply("services/jokes/path"); assertEquals("/services/jokes/path", result); }
@Test public void contains_ends_slash() { String result = testedClass.apply("services/jokes/path/"); assertEquals("/services/jokes/path", result); }
@Test public void null_path() { String result = testedClass.apply(null); assertEquals("/", result); }
@Test(expected = InvalidConfigurationException.class) public void contains_double_slash() { testedClass.apply("/services }