NetworkUtils { public static String getAbsoluteUrl(String url) { String absoluteUrl = url; if (!TextUtils.isEmpty(absoluteUrl) && !absoluteUrl.startsWith("http")) { absoluteUrl = StringUtils.appendOptional(BuildConfig.WS_ENDPOINT, absoluteUrl); } return absoluteUrl; } private  NetworkUtils(); static boolean isNetworkAvailable(Context context); static String getAbsoluteUrl(String url); static String getTwitterUrl(String username);  }
@Test public void should_return_same_url_if_absolute() { String url = "http: String result = NetworkUtils.getAbsoluteUrl(url); assertThat(result).isEqualTo(url); }
@Test public void should_transform_relative_to_absolute_url() { String url = "/imgs/nilhcem.jpg"; String result = NetworkUtils.getAbsoluteUrl(url); assertThat(result).isEqualTo(BuildConfig.WS_ENDPOINT + url); }