### Question:
Uri { public String toRelativeUrl() { StringBuilder sb = StringBuilderPool.DEFAULT.stringBuilder(); if (MiscUtils.isNonEmpty(path)) sb.append(path); else sb.append('/'); if (query != null) sb.append('?').append(query); return sb.toString(); } Uri(String scheme,
             String userInfo,
             String host,
             int port,
             String path,
             String query,
             String fragment); static Uri create(String originalUrl); static Uri create(Uri context, final String originalUrl); String getQuery(); String getPath(); String getUserInfo(); int getPort(); String getScheme(); String getHost(); String getFragment(); boolean isSecured(); boolean isWebSocket(); URI toJavaNetURI(); int getExplicitPort(); int getSchemeDefaultPort(); String toUrl(); String toBaseUrl(); String toRelativeUrl(); String toFullUrl(); String getBaseUrl(); String getAuthority(); boolean isSameBase(Uri other); String getNonEmptyPath(); @Override String toString(); Uri withNewScheme(String newScheme); Uri withNewQuery(String newQuery); @Override int hashCode(); @Override boolean equals(Object obj); static void validateSupportedScheme(Uri uri); static final String HTTP; static final String HTTPS; static final String WS; static final String WSS; }### Answer:
@Test public void testToRelativeUrl() { Uri uri = new Uri("http", "user", "example.com", 44, "/path/path2", "query=4", null); String relativeUrl = uri.toRelativeUrl(); assertEquals(relativeUrl, "/path/path2?query=4", "toRelativeUrl returned incorrect url"); }
@Test public void testToRelativeUrlWithEmptyPath() { Uri uri = new Uri("http", "user", "example.com", 44, null, "query=4", null); String relativeUrl = uri.toRelativeUrl(); assertEquals(relativeUrl, "/?query=4", "toRelativeUrl returned incorrect url"); }