### Question:
DownstreamPathCalculator { public String calculateDownstreamPath(final String receivedRequestUri) { String result = "/" + httpDownstreamPathPrefix + "/" + receivedRequestUri; result = result.replaceAll("/+", "/"); return result.length() == 1 ? result : result.replaceAll("/$", ""); } DownstreamPathCalculator(final String httpDownstreamPathPrefix); String calculateDownstreamPath(final String receivedRequestUri);  }### Answer:
@Test void blankRequestUriProducesAbsolutePathOfPrefix() { final DownstreamPathCalculator calc = new DownstreamPathCalculator("prefix"); final String result = calc.calculateDownstreamPath(""); assertThat(result).isEqualTo("/prefix"); }
@Test void slashRequestUriProducesAbsolutePathOfPrefix() { final DownstreamPathCalculator calc = new DownstreamPathCalculator("prefix"); final String result = calc.calculateDownstreamPath("/"); assertThat(result).isEqualTo("/prefix"); }
@Test void slashPrefixWithNoUriResultsInDownstreamOfJustSlash() { final DownstreamPathCalculator calc = new DownstreamPathCalculator("/"); final String result = calc.calculateDownstreamPath("/"); assertThat(result).isEqualTo("/"); }
@Test void emptyRootPathIsReplacedWithSlash() { final DownstreamPathCalculator calc = new DownstreamPathCalculator(""); final String result = calc.calculateDownstreamPath("arbitraryPath"); assertThat(result).isEqualTo("/arbitraryPath"); }
@Test void multipleSlashInRootAreDiscarded() { final DownstreamPathCalculator calc = new DownstreamPathCalculator(" final String result = calc.calculateDownstreamPath("arbitraryPath"); assertThat(result).isEqualTo("/arbitraryPath"); }