OAuthsV1 { static String constructRequestURL(String url) { int index = url.indexOf('?'); String retVal = url; if (-1 != index) { retVal = retVal.substring(0, index); } int slashIndex = retVal.indexOf('/', AFTER_PROTOCOL_INDEX); String baseURL = retVal.substring(0, slashIndex).toLowerCase(); int colonIndex = baseURL.indexOf(':', AFTER_PROTOCOL_INDEX); if (-1 != colonIndex) { if (baseURL.startsWith("http: baseURL = baseURL.substring(0, colonIndex); } else if (baseURL.startsWith("https: baseURL = baseURL.substring(0, colonIndex); } } return baseURL + retVal.substring(slashIndex); } private  OAuthsV1();   }
@Test public void shouldDropPort80FromHttpUrl(){ String url = "http: String actual = OAuthsV1.constructRequestURL(url); assertEquals("http: }
@Test public void shouldKeepAnyPortFromHttpUrl(){ String url = "http: String actual = OAuthsV1.constructRequestURL(url); assertEquals(url, actual); }
@Test public void shouldDropPort443FromHttpsUrl(){ String url = "https: String actual = OAuthsV1.constructRequestURL(url); assertEquals("https: }
@Test public void shouldKeepAnyPortFromHttpsUrl(){ String url = "https: String actual = OAuthsV1.constructRequestURL(url); assertEquals(url, actual); }
@Test public void shouldKeepUrlUnchangedWhenNoPort(){ String url = "http: String actual = OAuthsV1.constructRequestURL(url); assertEquals(url, actual); }
@Test public void shouldDropUrlStringFromUrl(){ String url = "http: String actual = OAuthsV1.constructRequestURL(url); assertEquals("http: }