Back to project page klarna-on-demand-android.
The source code is released under:
Apache License
If you think the Android project klarna-on-demand-android listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.klarna.ondemand; // w w w . ja va 2s. com import junit.framework.TestCase; import java.util.Locale; public class UrlHelperTest extends TestCase { String token = "my_token"; @Override public void setUp() throws java.lang.Exception { Context.setApiKey("test_skadoo"); } //region .registrationUrl public void testRegistrationUrl_ShouldReturnPlaygroundUrl_WhenTokenIsForPlayground() { assertTrue(UrlHelper.registrationUrl().startsWith("https://inapp.playground.klarna.com/registration/new")); } public void testRegistrationUrl_ShouldReturnProductionUrl_WhenTokenIsForProduction() { Context.setApiKey("skadoo"); assertTrue(UrlHelper.registrationUrl().startsWith("https://inapp.klarna.com/registration/new")); } public void testRegistrationUrl_ShouldReturnUrlWithSwedishLocale_WhenLocaleIsSwedish() { Locale.setDefault(new Locale("sv")); assertTrue(UrlHelper.registrationUrl().contains("locale=sv")); Locale.setDefault(Locale.ENGLISH); } //endregion //region .PreferencesUrlWithToken public void testPreferencesUrlWithToken_ShouldReturnPlaygroundUrl_WhenTokenIsForPlayground() { String expectedPrefix = "https://inapp.playground.klarna.com/users/" + token + "/preferences"; assertTrue(UrlHelper.preferencesUrl(token).startsWith(expectedPrefix)); } public void testPreferencesUrlWithToken_ShouldReturnProductionUrl_WhenTokenIsForProduction() { Context.setApiKey("skadoo"); String expectedPrefix = "https://inapp.klarna.com/users/" + token + "/preferences"; assertTrue(UrlHelper.preferencesUrl(token).startsWith(expectedPrefix)); } public void testPreferencesUrlWithToken_ShouldReturnUrlWithSwedishLocale_WhenLocaleIsSwedish() { Locale.setDefault(new Locale("sv")); assertTrue(UrlHelper.preferencesUrl(token).contains("locale=sv")); Locale.setDefault(Locale.ENGLISH); } //endregion }