RobotsUtilities { @Nonnull public String getResourceLocalComponents(@Nonnull URI resourceUri) { checkNotNull(resourceUri, "resourceUri"); StringBuilder builder = new StringBuilder(); builder.append(resourceUri.getPath()); if (resourceUri.getQuery() != null) { builder.append('?').append(resourceUri.getQuery()); } if (resourceUri.getFragment() != null) { builder.append('#').append(resourceUri.getFragment()); } return builder.toString(); }  @Nonnull URI getRobotsURIForResource(@Nonnull final URI resourceUri); @Nonnull String getResourceLocalComponents(@Nonnull URI resourceUri);  }
@Test(expected = NullPointerException.class) public void givenNullResource_whenGetResourceLocalComponents_thenThrowsNPE() { URI resource = null; utilities.getResourceLocalComponents(resource); }
@Test public void givenPath_whenGetResourceLocalComponents_thenResultEqualsPath() { URI resource = URI.create("http: String path = utilities.getResourceLocalComponents(resource); assertThat(path, equalTo("/path")); }
@Test public void givenFragment_whenGetResourceLocalComponents_thenResultEqualsFragment() { URI resource = URI.create("http: String result = utilities.getResourceLocalComponents(resource); assertThat(result, equalTo("#fragment")); }
@Test public void givenQuery_whenGetResourceLocalComponents_thenResultEqualsQuery() { URI resource = URI.create("http: String result = utilities.getResourceLocalComponents(resource); assertThat(result, equalTo("?query")); }
@Test public void givenPathAndQuery_whenGetResourceLocalComponents_thenResultEqualsExpected() { URI resource = URI.create("http: String result = utilities.getResourceLocalComponents(resource); assertThat(result, equalTo("/path?query")); }
@Test public void givenPathAndFragment_whenGetResourceLocalComponents_thenResultEqualsExpected() { URI resource = URI.create("http: String result = utilities.getResourceLocalComponents(resource); assertThat(result, equalTo("/path#fragment")); }
@Test public void givenPathAndQueryAndFragment_whenGetResourceLocalComponents_thenResultEqualsExpected() { URI resource = URI.create("http: String result = utilities.getResourceLocalComponents(resource); assertThat(result, equalTo("/path?query#fragment")); }