UrlHelper { static String preferencesUrl(android.content.Context applicationContext, String token) { Uri.Builder builder = new Uri.Builder(); return builder.scheme("https") .authority(getAuthority()) .appendPath("users") .appendPath(token) .appendPath("preferences") .appendQueryParameter("api_key", Context.getApiKey()) .appendQueryParameter("locale", Context.getLanguage(applicationContext)) .build() .toString(); }    }
@Test public void preferencesUrlWithToken_ShouldReturnPlaygroundUrl_WhenTokenIsForPlayground() { String expectedPrefix = "https: assertThat(UrlHelper.preferencesUrl(context, TOKEN)).startsWith(expectedPrefix); }
@Test public void preferencesUrlWithToken_ShouldReturnProductionUrl_WhenTokenIsForProduction() { mockStatic(Context.class); when(Context.getApiKey()).thenReturn("skadoo"); String expectedPrefix = "https: assertThat(UrlHelper.preferencesUrl(context, TOKEN)).startsWith(expectedPrefix); }
@Test public void preferencesUrlWithToken_ShouldReturnUrlWithTheConfiguredLocale() { when(Context.getLanguage(context)).thenReturn("my_locale"); assertThat(UrlHelper.preferencesUrl(context, TOKEN)).contains("locale=my_locale"); }