### Question:
UriUtils { public static URI getParent(final URI uri) { if (isRoot(uri)) { return null; } else { final URI parent = uri.getPath().endsWith("/") ? uri.resolve("..") : uri.resolve("."); final String parentStr = parent.toString(); return isRoot(parent) ? parent : URI.create(parentStr.substring(0, parentStr.length() - 1)); } } private  UriUtils(); static URI getParent(final URI uri);  }### Answer:
@Test public void test() { final URI root1 = URI.create(INTERNAL_URI_PREFIX + "/"); assertNull("parent should be null", UriUtils.getParent(root1)); }
@Test public void testChildOfRoot() { final URI uri = URI.create(INTERNAL_URI_PREFIX + "/test"); assertEquals("incorrect parent", URI.create(INTERNAL_URI_PREFIX + "/"), UriUtils.getParent(uri)); }
@Test public void testGrandchildOfRoot() { final URI uri = URI.create(INTERNAL_URI_PREFIX + "/child/grandchild"); assertEquals("incorrect parent", URI.create(INTERNAL_URI_PREFIX + "/child"), UriUtils.getParent(uri)); }