From ac05c158cfdaa6007429844c58be2cc02d123b7c Mon Sep 17 00:00:00 2001 From: Luciano Balmaceda Date: Tue, 16 Jul 2019 18:15:10 -0300 Subject: [PATCH 1/2] update gradle wrapper and android plugin version --- auth0/build.gradle | 2 +- build.gradle | 2 +- gradle/wrapper/gradle-wrapper.properties | 3 ++- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/auth0/build.gradle b/auth0/build.gradle index 88d0c06ea..612d2d201 100644 --- a/auth0/build.gradle +++ b/auth0/build.gradle @@ -73,7 +73,7 @@ dependencies { implementation 'com.squareup.okhttp:okhttp:2.7.5' implementation 'com.squareup.okhttp:logging-interceptor:2.7.5' implementation 'com.google.code.gson:gson:2.8.5' - implementation 'com.auth0.android:jwtdecode:1.1.1' + implementation 'com.auth0.android:jwtdecode:1.3.0' testImplementation 'junit:junit:4.12' testImplementation 'org.hamcrest:java-hamcrest:2.0.0.0' diff --git a/build.gradle b/build.gradle index 848580c20..4fb3d3a5d 100644 --- a/build.gradle +++ b/build.gradle @@ -9,7 +9,7 @@ buildscript { google() } dependencies { - classpath 'com.android.tools.build:gradle:3.2.1' + classpath 'com.android.tools.build:gradle:3.4.2' classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.4' } } diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index d76b502e2..ac870fab5 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,6 @@ +#Tue Jul 16 17:46:54 ART 2019 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.2-all.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-all.zip From e7bff70a335986dbc6f99bdf412f537175e605d4 Mon Sep 17 00:00:00 2001 From: Luciano Balmaceda Date: Wed, 17 Jul 2019 16:50:15 -0300 Subject: [PATCH 2/2] run android lint and fix issues --- .../com/auth0/android/Auth0Exception.java | 3 + .../provider/AuthenticationActivity.java | 2 +- .../android/provider/CustomTabsOptions.java | 2 + .../android/provider/WebAuthActivity.java | 12 +- .../android/provider/WebAuthProvider.java | 3 + .../java/com/auth0/android/Auth0Test.java | 54 ++-- .../AuthenticationAPIClientTest.java | 15 +- .../AuthenticationExceptionTest.java | 67 +++-- .../authentication/ParameterBuilderTest.java | 44 +-- .../DatabaseConnectionRequestTest.java | 16 +- .../request/DelegationRequestTest.java | 14 +- .../request/ProfileRequestTest.java | 20 +- .../request/SignUpRequestTest.java | 32 +-- .../request/TokenRequestTest.java | 8 +- .../JsonRequiredTypeAdapterFactoryTest.java | 6 +- .../storage/CredentialsManagerTest.java | 45 ++- .../storage/CryptoUtilTest.java | 31 +- .../storage/SecureCredentialsManagerTest.java | 69 +++-- .../storage/SharedPreferencesStorageTest.java | 44 ++- .../management/UsersAPIClientTest.java | 12 +- .../android/provider/AuthProviderTest.java | 34 ++- .../provider/AuthenticationActivityTest.java | 31 +- .../android/provider/AuthorizeResultTest.java | 14 +- .../android/provider/CallbackHelperTest.java | 28 +- .../provider/CustomTabsControllerTest.java | 30 +- .../provider/CustomTabsOptionsTest.java | 10 +- .../android/provider/FlagCheckerTest.java | 4 +- .../android/provider/LogoutManagerTest.java | 10 +- .../android/provider/OAuthManagerTest.java | 31 +- .../com/auth0/android/provider/PKCETest.java | 18 +- .../provider/PermissionHandlerTest.java | 26 +- .../provider/RedirectActivityTest.java | 9 +- .../android/provider/WebAuthProviderTest.java | 265 +++++++++--------- .../AuthenticationErrorBuilderTest.java | 10 +- .../BaseAuthenticationRequestTest.java | 6 +- .../request/internal/BaseRequestTest.java | 30 +- .../internal/CredentialsDeserializerTest.java | 2 +- .../request/internal/CredentialsGsonTest.java | 4 +- .../internal/ManagementErrorBuilderTest.java | 10 +- .../request/internal/RequestFactoryTest.java | 30 +- .../internal/UserIdentityGsonTest.java | 2 +- .../request/internal/UserProfileGsonTest.java | 2 +- .../android/result/AuthenticationTest.java | 6 +- .../auth0/android/result/CredentialsTest.java | 6 +- .../android/result/DatabaseUserTest.java | 8 +- .../auth0/android/result/DelegationTest.java | 8 +- .../JsonRequiredTypeAdapterFactoryTest.java | 6 +- .../android/result/UserIdentityTest.java | 16 +- .../auth0/android/result/UserProfileTest.java | 33 ++- .../util/MockAuthenticationCallback.java | 4 +- .../auth0/android/util/MockBaseCallback.java | 4 +- .../android/util/MockManagementCallback.java | 4 +- .../com/auth0/android/util/TelemetryTest.java | 14 +- 53 files changed, 597 insertions(+), 617 deletions(-) diff --git a/auth0/src/main/java/com/auth0/android/Auth0Exception.java b/auth0/src/main/java/com/auth0/android/Auth0Exception.java index 0d31deced..ee85f354b 100755 --- a/auth0/src/main/java/com/auth0/android/Auth0Exception.java +++ b/auth0/src/main/java/com/auth0/android/Auth0Exception.java @@ -30,8 +30,11 @@ public class Auth0Exception extends RuntimeException { public static final String UNKNOWN_ERROR = "a0.sdk.internal_error.unknown"; + @SuppressWarnings("WeakerAccess") public static final String NON_JSON_ERROR = "a0.sdk.internal_error.plain"; + @SuppressWarnings("WeakerAccess") public static final String EMPTY_BODY_ERROR = "a0.sdk.internal_error.empty"; + @SuppressWarnings("WeakerAccess") public static final String EMPTY_RESPONSE_BODY_DESCRIPTION = "Empty response body"; public Auth0Exception(String message, Throwable cause) { diff --git a/auth0/src/main/java/com/auth0/android/provider/AuthenticationActivity.java b/auth0/src/main/java/com/auth0/android/provider/AuthenticationActivity.java index 7708cee1d..cc763a0cd 100644 --- a/auth0/src/main/java/com/auth0/android/provider/AuthenticationActivity.java +++ b/auth0/src/main/java/com/auth0/android/provider/AuthenticationActivity.java @@ -15,8 +15,8 @@ public class AuthenticationActivity extends Activity { static final String EXTRA_USE_FULL_SCREEN = "com.auth0.android.EXTRA_USE_FULL_SCREEN"; static final String EXTRA_CONNECTION_NAME = "com.auth0.android.EXTRA_CONNECTION_NAME"; static final String EXTRA_AUTHORIZE_URI = "com.auth0.android.EXTRA_AUTHORIZE_URI"; - static final String EXTRA_INTENT_LAUNCHED = "com.auth0.android.EXTRA_INTENT_LAUNCHED"; static final String EXTRA_CT_OPTIONS = "com.auth0.android.EXTRA_CT_OPTIONS"; + private static final String EXTRA_INTENT_LAUNCHED = "com.auth0.android.EXTRA_INTENT_LAUNCHED"; private boolean intentLaunched; private CustomTabsController customTabsController; diff --git a/auth0/src/main/java/com/auth0/android/provider/CustomTabsOptions.java b/auth0/src/main/java/com/auth0/android/provider/CustomTabsOptions.java index 0a2bf59da..3952ccbca 100644 --- a/auth0/src/main/java/com/auth0/android/provider/CustomTabsOptions.java +++ b/auth0/src/main/java/com/auth0/android/provider/CustomTabsOptions.java @@ -1,5 +1,6 @@ package com.auth0.android.provider; +import android.annotation.SuppressLint; import android.content.Context; import android.content.Intent; import android.os.Parcel; @@ -33,6 +34,7 @@ public static Builder newBuilder() { } + @SuppressLint("ResourceType") Intent toIntent(Context context, CustomTabsSession session) { final CustomTabsIntent.Builder builder = new CustomTabsIntent.Builder(session) .setShowTitle(showTitle); diff --git a/auth0/src/main/java/com/auth0/android/provider/WebAuthActivity.java b/auth0/src/main/java/com/auth0/android/provider/WebAuthActivity.java index 5bebd30a1..1529c50c1 100644 --- a/auth0/src/main/java/com/auth0/android/provider/WebAuthActivity.java +++ b/auth0/src/main/java/com/auth0/android/provider/WebAuthActivity.java @@ -24,6 +24,7 @@ package com.auth0.android.provider; +import android.annotation.SuppressLint; import android.annotation.TargetApi; import android.content.Context; import android.content.Intent; @@ -83,15 +84,15 @@ protected void onCreate(Bundle savedInstanceState) { bar.setDisplayShowCustomEnabled(true); bar.setTitle(serviceName); } - webView = (WebView) findViewById(R.id.com_auth0_lock_webview); + webView = findViewById(R.id.com_auth0_lock_webview); webView.setVisibility(View.INVISIBLE); - progressBar = (ProgressBar) findViewById(R.id.com_auth0_lock_progressbar); + progressBar = findViewById(R.id.com_auth0_lock_progressbar); progressBar.setIndeterminate(true); progressBar.setMax(100); errorView = findViewById(R.id.com_auth0_lock_error_view); errorView.setVisibility(View.GONE); - errorMessage = (TextView) findViewById(R.id.com_auth0_lock_text); - Button retryButton = (Button) findViewById(R.id.com_auth0_lock_retry); + errorMessage = findViewById(R.id.com_auth0_lock_text); + Button retryButton = findViewById(R.id.com_auth0_lock_retry); retryButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { @@ -112,6 +113,7 @@ public void onWindowFocusChanged(boolean hasFocus) { } } + @SuppressLint("SetJavaScriptEnabled") private void startUrlLoading() { if (!isNetworkAvailable()) { renderLoadError(getString(R.string.com_auth0_webauth_network_error)); @@ -162,7 +164,6 @@ public void onPageStarted(WebView view, String url, Bitmap favicon) { progressBar.setVisibility(View.VISIBLE); } - @SuppressWarnings("deprecation") @Override public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) { Log.w(TAG, String.format("Load error (%d) %s", errorCode, description)); @@ -196,6 +197,7 @@ private boolean isNetworkAvailable() { boolean available = true; ConnectivityManager connectivityManager = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE); try { + @SuppressLint("MissingPermission") NetworkInfo activeNetworkInfo = connectivityManager.getActiveNetworkInfo(); available = activeNetworkInfo != null && activeNetworkInfo.isConnectedOrConnecting(); Log.v(TAG, "Is network available? " + available); diff --git a/auth0/src/main/java/com/auth0/android/provider/WebAuthProvider.java b/auth0/src/main/java/com/auth0/android/provider/WebAuthProvider.java index 19f20ad3e..3239fce33 100644 --- a/auth0/src/main/java/com/auth0/android/provider/WebAuthProvider.java +++ b/auth0/src/main/java/com/auth0/android/provider/WebAuthProvider.java @@ -24,6 +24,7 @@ package com.auth0.android.provider; +import android.annotation.SuppressLint; import android.app.Activity; import android.content.ActivityNotFoundException; import android.content.Context; @@ -160,6 +161,7 @@ public static class Builder { * @return the current builder instance * @deprecated This method has been deprecated since it only applied to WebView authentication and Google is no longer supporting it. You should use the default value (use browser). */ + @SuppressWarnings("DeprecatedIsStillUsed") @Deprecated public Builder useBrowser(boolean useBrowser) { this.useBrowser = useBrowser; @@ -342,6 +344,7 @@ Builder withPKCE(PKCE pkce) { * @param requestCode to use in the authentication request * @deprecated This method has been deprecated since it only applied to WebView authentication and Google is no longer supporting it. Please use {@link WebAuthProvider.Builder#start(Activity, AuthCallback)} */ + @SuppressLint("VisibleForTests") @Deprecated public void start(@NonNull Activity activity, @NonNull AuthCallback callback, int requestCode) { resetManagerInstance(); diff --git a/auth0/src/test/java/com/auth0/android/Auth0Test.java b/auth0/src/test/java/com/auth0/android/Auth0Test.java index ffcb828af..00b8e412e 100755 --- a/auth0/src/test/java/com/auth0/android/Auth0Test.java +++ b/auth0/src/test/java/com/auth0/android/Auth0Test.java @@ -68,12 +68,12 @@ public class Auth0Test { private static final String OTHER_DOMAIN = "samples-test.other-subdomain.other.auth0.com"; @Before - public void setUp() throws Exception { + public void setUp() { MockitoAnnotations.initMocks(this); } @Test - public void shouldBeOIDCConformant() throws Exception { + public void shouldBeOIDCConformant() { Auth0 auth0 = new Auth0(CLIENT_ID, DOMAIN); auth0.setOIDCConformant(true); @@ -81,7 +81,7 @@ public void shouldBeOIDCConformant() throws Exception { } @Test - public void shouldNotBeOIDCConformant() throws Exception { + public void shouldNotBeOIDCConformant() { Auth0 auth0 = new Auth0(CLIENT_ID, DOMAIN); auth0.setOIDCConformant(false); @@ -89,13 +89,13 @@ public void shouldNotBeOIDCConformant() throws Exception { } @Test - public void shouldNotBeOIDCConformantByDefault() throws Exception { + public void shouldNotBeOIDCConformantByDefault() { Auth0 auth0 = new Auth0(CLIENT_ID, DOMAIN); assertThat(auth0.isOIDCConformant(), is(false)); } @Test - public void shouldHaveLoggingEnabled() throws Exception { + public void shouldHaveLoggingEnabled() { Auth0 auth0 = new Auth0(CLIENT_ID, DOMAIN); auth0.setLoggingEnabled(true); @@ -103,7 +103,7 @@ public void shouldHaveLoggingEnabled() throws Exception { } @Test - public void shouldNotHaveLoggingEnabled() throws Exception { + public void shouldNotHaveLoggingEnabled() { Auth0 auth0 = new Auth0(CLIENT_ID, DOMAIN); auth0.setLoggingEnabled(false); @@ -111,13 +111,13 @@ public void shouldNotHaveLoggingEnabled() throws Exception { } @Test - public void shouldNotEnforceTLS12ByDefault() throws Exception { + public void shouldNotEnforceTLS12ByDefault() { Auth0 auth0 = new Auth0(CLIENT_ID, DOMAIN); assertThat(auth0.isTLS12Enforced(), is(false)); } @Test - public void shouldHaveTLS12Enforced() throws Exception { + public void shouldHaveTLS12Enforced() { Auth0 auth0 = new Auth0(CLIENT_ID, DOMAIN); auth0.setTLS12Enforced(true); @@ -125,7 +125,7 @@ public void shouldHaveTLS12Enforced() throws Exception { } @Test - public void shouldNotHaveTLS12Enforced() throws Exception { + public void shouldNotHaveTLS12Enforced() { Auth0 auth0 = new Auth0(CLIENT_ID, DOMAIN); auth0.setTLS12Enforced(false); @@ -133,7 +133,7 @@ public void shouldNotHaveTLS12Enforced() throws Exception { } @Test - public void shouldHaveConnectTimeout() throws Exception { + public void shouldHaveConnectTimeout() { Auth0 auth0 = new Auth0(CLIENT_ID, DOMAIN); auth0.setConnectTimeoutInSeconds(5); @@ -141,7 +141,7 @@ public void shouldHaveConnectTimeout() throws Exception { } @Test - public void shouldReadHaveTimeout() throws Exception { + public void shouldReadHaveTimeout() { Auth0 auth0 = new Auth0(CLIENT_ID, DOMAIN); auth0.setReadTimeoutInSeconds(15); @@ -149,7 +149,7 @@ public void shouldReadHaveTimeout() throws Exception { } @Test - public void shouldHaveWriteTimeout() throws Exception { + public void shouldHaveWriteTimeout() { Auth0 auth0 = new Auth0(CLIENT_ID, DOMAIN); auth0.setWriteTimeoutInSeconds(20); @@ -157,13 +157,13 @@ public void shouldHaveWriteTimeout() throws Exception { } @Test - public void shouldNotHaveLoggingEnabledByDefault() throws Exception { + public void shouldNotHaveLoggingEnabledByDefault() { Auth0 auth0 = new Auth0(CLIENT_ID, DOMAIN); assertThat(auth0.isLoggingEnabled(), is(false)); } @Test - public void shouldBuildFromResources() throws Exception { + public void shouldBuildFromResources() { Resources resources = Mockito.mock(Resources.class); when(context.getResources()).thenReturn(resources); when(resources.getIdentifier(eq("com_auth0_client_id"), eq("string"), anyString())).thenReturn(222); @@ -181,7 +181,7 @@ public void shouldBuildFromResources() throws Exception { } @Test - public void shouldFailToBuildFromResourcesWithoutClientID() throws Exception { + public void shouldFailToBuildFromResourcesWithoutClientID() { Resources resources = Mockito.mock(Resources.class); when(context.getResources()).thenReturn(resources); when(resources.getIdentifier(eq("com_auth0_client_id"), eq("string"), anyString())).thenReturn(0); @@ -194,7 +194,7 @@ public void shouldFailToBuildFromResourcesWithoutClientID() throws Exception { } @Test - public void shouldFailToBuildFromResourcesWithoutDomain() throws Exception { + public void shouldFailToBuildFromResourcesWithoutDomain() { Resources resources = Mockito.mock(Resources.class); when(context.getResources()).thenReturn(resources); when(resources.getIdentifier(eq("com_auth0_client_id"), eq("string"), anyString())).thenReturn(222); @@ -207,7 +207,7 @@ public void shouldFailToBuildFromResourcesWithoutDomain() throws Exception { } @Test - public void shouldBuildWithClientIdAndDomain() throws Exception { + public void shouldBuildWithClientIdAndDomain() { Auth0 auth0 = new Auth0(CLIENT_ID, DOMAIN); assertThat(auth0.getClientId(), equalTo(CLIENT_ID)); assertThat(HttpUrl.parse(auth0.getDomainUrl()), equalTo(HttpUrl.parse("https://samples.auth0.com"))); @@ -215,7 +215,7 @@ public void shouldBuildWithClientIdAndDomain() throws Exception { } @Test - public void shouldBuildWithConfigurationDomainToo() throws Exception { + public void shouldBuildWithConfigurationDomainToo() { Auth0 auth0 = new Auth0(CLIENT_ID, DOMAIN, CONFIG_DOMAIN_CUSTOM); assertThat(auth0.getClientId(), equalTo(CLIENT_ID)); assertThat(HttpUrl.parse(auth0.getDomainUrl()), equalTo(HttpUrl.parse("https://samples.auth0.com"))); @@ -223,7 +223,7 @@ public void shouldBuildWithConfigurationDomainToo() throws Exception { } @Test - public void shouldHandleEUInstance() throws Exception { + public void shouldHandleEUInstance() { Auth0 auth0 = new Auth0(CLIENT_ID, EU_DOMAIN); assertThat(auth0.getClientId(), equalTo(CLIENT_ID)); assertThat(HttpUrl.parse(auth0.getDomainUrl()), equalTo(HttpUrl.parse("https://samples.eu.auth0.com"))); @@ -231,7 +231,7 @@ public void shouldHandleEUInstance() throws Exception { } @Test - public void shouldHandleAUInstance() throws Exception { + public void shouldHandleAUInstance() { Auth0 auth0 = new Auth0(CLIENT_ID, AU_DOMAIN); assertThat(auth0.getClientId(), equalTo(CLIENT_ID)); assertThat(HttpUrl.parse(auth0.getDomainUrl()), equalTo(HttpUrl.parse("https://samples.au.auth0.com"))); @@ -239,7 +239,7 @@ public void shouldHandleAUInstance() throws Exception { } @Test - public void shouldHandleOtherInstance() throws Exception { + public void shouldHandleOtherInstance() { Auth0 auth0 = new Auth0(CLIENT_ID, OTHER_DOMAIN); assertThat(auth0.getClientId(), equalTo(CLIENT_ID)); assertThat(HttpUrl.parse(auth0.getDomainUrl()), equalTo(HttpUrl.parse("https://samples-test.other-subdomain.other.auth0.com"))); @@ -247,7 +247,7 @@ public void shouldHandleOtherInstance() throws Exception { } @Test - public void shouldHandleNonAuth0Domain() throws Exception { + public void shouldHandleNonAuth0Domain() { Auth0 auth0 = new Auth0(CLIENT_ID, "mydomain.com"); assertThat(auth0.getClientId(), equalTo(CLIENT_ID)); assertThat(HttpUrl.parse(auth0.getDomainUrl()), equalTo(HttpUrl.parse("https://mydomain.com"))); @@ -255,13 +255,13 @@ public void shouldHandleNonAuth0Domain() throws Exception { } @Test - public void shouldThrowWhenInvalidDomain() throws Exception { + public void shouldThrowWhenInvalidDomain() { expectedException.expect(IllegalArgumentException.class); new Auth0(CLIENT_ID, "some invalid domain.com"); } @Test - public void shouldReturnAuthorizeUrl() throws Exception { + public void shouldReturnAuthorizeUrl() { Auth0 auth0 = new Auth0(CLIENT_ID, DOMAIN); final HttpUrl url = HttpUrl.parse(auth0.getAuthorizeUrl()); @@ -271,7 +271,7 @@ public void shouldReturnAuthorizeUrl() throws Exception { } @Test - public void shouldReturnLogoutUrl() throws Exception { + public void shouldReturnLogoutUrl() { Auth0 auth0 = new Auth0(CLIENT_ID, DOMAIN); final HttpUrl url = HttpUrl.parse(auth0.getLogoutUrl()); @@ -281,14 +281,14 @@ public void shouldReturnLogoutUrl() throws Exception { } @Test - public void shouldNotReturnTelemetryWhenExplicitlyDisabledThem() throws Exception { + public void shouldNotReturnTelemetryWhenExplicitlyDisabledThem() { Auth0 auth0 = new Auth0(CLIENT_ID, DOMAIN); auth0.doNotSendTelemetry(); assertThat(auth0.getTelemetry(), is(nullValue())); } @Test - public void shouldSetCustomTelemetry() throws Exception { + public void shouldSetCustomTelemetry() { Telemetry customTelemetry = new Telemetry("custom", "9.9.9", "1.1.1"); Auth0 auth0 = new Auth0(CLIENT_ID, DOMAIN); auth0.setTelemetry(customTelemetry); diff --git a/auth0/src/test/java/com/auth0/android/authentication/AuthenticationAPIClientTest.java b/auth0/src/test/java/com/auth0/android/authentication/AuthenticationAPIClientTest.java index 044e54b98..e22697427 100755 --- a/auth0/src/test/java/com/auth0/android/authentication/AuthenticationAPIClientTest.java +++ b/auth0/src/test/java/com/auth0/android/authentication/AuthenticationAPIClientTest.java @@ -96,7 +96,6 @@ public class AuthenticationAPIClientTest { private static final String OPENID = "openid"; private AuthenticationAPIClient client; - private Auth0 auth0; private Gson gson; private AuthenticationAPI mockAPI; @@ -105,7 +104,7 @@ public class AuthenticationAPIClientTest { public void setUp() throws Exception { mockAPI = new AuthenticationAPI(); final String domain = mockAPI.getDomain(); - auth0 = new Auth0(CLIENT_ID, domain, domain); + Auth0 auth0 = new Auth0(CLIENT_ID, domain, domain); client = new AuthenticationAPIClient(auth0); gson = new GsonBuilder().serializeNulls().create(); } @@ -116,7 +115,7 @@ public void tearDown() throws Exception { } @Test - public void shouldSetUserAgent() throws Exception { + public void shouldSetUserAgent() { Auth0 account = mock(Auth0.class); RequestFactory factory = mock(RequestFactory.class); OkHttpClientFactory clientFactory = mock(OkHttpClientFactory.class); @@ -126,7 +125,7 @@ public void shouldSetUserAgent() throws Exception { } @Test - public void shouldSetTelemetryIfPresent() throws Exception { + public void shouldSetTelemetryIfPresent() { final Telemetry telemetry = mock(Telemetry.class); when(telemetry.getValue()).thenReturn("the-telemetry-data"); RequestFactory factory = mock(RequestFactory.class); @@ -138,7 +137,7 @@ public void shouldSetTelemetryIfPresent() throws Exception { } @Test - public void shouldNotSetTelemetryIfMissing() throws Exception { + public void shouldNotSetTelemetryIfMissing() { RequestFactory factory = mock(RequestFactory.class); OkHttpClientFactory clientFactory = mock(OkHttpClientFactory.class); Auth0 auth0 = new Auth0(CLIENT_ID, DOMAIN); @@ -148,7 +147,7 @@ public void shouldNotSetTelemetryIfMissing() throws Exception { } @Test - public void shouldCreateClientWithAccountInfo() throws Exception { + public void shouldCreateClientWithAccountInfo() { AuthenticationAPIClient client = new AuthenticationAPIClient(new Auth0(CLIENT_ID, DOMAIN)); assertThat(client, is(notNullValue())); assertThat(client.getClientId(), equalTo(CLIENT_ID)); @@ -160,7 +159,7 @@ public void shouldCreateClientWithAccountInfo() throws Exception { } @Test - public void shouldCreateClientWithContextInfo() throws Exception { + public void shouldCreateClientWithContextInfo() { Context context = Mockito.mock(Context.class); Resources resources = Mockito.mock(Resources.class); when(context.getResources()).thenReturn(resources); @@ -1743,7 +1742,7 @@ public void shouldParseUnauthorizedPKCEError() throws Exception { assertThat(callback.getError().getDescription(), is(equalTo("Unauthorized"))); } - private Map bodyFromRequest(RecordedRequest request) throws java.io.IOException { + private Map bodyFromRequest(RecordedRequest request) { final Type mapType = new TypeToken>() { }.getType(); return gson.fromJson(request.getBody().readUtf8(), mapType); diff --git a/auth0/src/test/java/com/auth0/android/authentication/AuthenticationExceptionTest.java b/auth0/src/test/java/com/auth0/android/authentication/AuthenticationExceptionTest.java index b4dbaa7a7..430e645ec 100644 --- a/auth0/src/test/java/com/auth0/android/authentication/AuthenticationExceptionTest.java +++ b/auth0/src/test/java/com/auth0/android/authentication/AuthenticationExceptionTest.java @@ -28,7 +28,6 @@ import static org.hamcrest.CoreMatchers.nullValue; import static org.junit.Assert.assertThat; -@SuppressWarnings("ThrowableInstanceNeverThrown") @RunWith(RobolectricTestRunner.class) @Config(sdk = 21) public class AuthenticationExceptionTest { @@ -46,18 +45,18 @@ public class AuthenticationExceptionTest { private Map values; @Before - public void setUp() throws Exception { + public void setUp() { values = new HashMap<>(); } @Test - public void shouldGetUnknownCode() throws Exception { + public void shouldGetUnknownCode() { AuthenticationException ex = new AuthenticationException(values); assertThat(ex.getCode(), is(equalTo(UNKNOWN_ERROR))); } @Test - public void shouldGetPreferErrorOverCode() throws Exception { + public void shouldGetPreferErrorOverCode() { values.put(ERROR_KEY, "a_valid_error"); values.put(CODE_KEY, "a_valid_code"); AuthenticationException ex = new AuthenticationException(values); @@ -65,21 +64,21 @@ public void shouldGetPreferErrorOverCode() throws Exception { } @Test - public void shouldGetValidCode() throws Exception { + public void shouldGetValidCode() { values.put(CODE_KEY, "a_valid_code"); AuthenticationException ex = new AuthenticationException(values); assertThat(ex.getCode(), is(equalTo("a_valid_code"))); } @Test - public void shouldGetValidError() throws Exception { + public void shouldGetValidError() { values.put(ERROR_KEY, "a_valid_error"); AuthenticationException ex = new AuthenticationException(values); assertThat(ex.getCode(), is(equalTo("a_valid_error"))); } @Test - public void shouldGetPreferDescriptionOverErrorDescription() throws Exception { + public void shouldGetPreferDescriptionOverErrorDescription() { values.put(ERROR_DESCRIPTION_KEY, "a_valid_error_description"); values.put(DESCRIPTION_KEY, "a_valid_description"); AuthenticationException ex = new AuthenticationException(values); @@ -87,40 +86,40 @@ public void shouldGetPreferDescriptionOverErrorDescription() throws Exception { } @Test - public void shouldGetValidDescription() throws Exception { + public void shouldGetValidDescription() { values.put(DESCRIPTION_KEY, "a_valid_error_description"); AuthenticationException ex = new AuthenticationException(values); assertThat(ex.getDescription(), is(equalTo("a_valid_error_description"))); } @Test - public void shouldGetValidErrorDescription() throws Exception { + public void shouldGetValidErrorDescription() { values.put(ERROR_DESCRIPTION_KEY, "a_valid_error_description"); AuthenticationException ex = new AuthenticationException(values); assertThat(ex.getDescription(), is(equalTo("a_valid_error_description"))); } @Test - public void shouldGetPlainTextAsDescription() throws Exception { + public void shouldGetPlainTextAsDescription() { AuthenticationException ex = new AuthenticationException("Payload", 404); assertThat(ex.getDescription(), is(equalTo("Payload"))); } @Test - public void shouldGetMessageWithUnknownCodeIfNullDescription() throws Exception { + public void shouldGetMessageWithUnknownCodeIfNullDescription() { AuthenticationException ex = new AuthenticationException(values); assertThat(ex.getDescription(), is(equalTo(String.format("Received error with code %s", UNKNOWN_ERROR)))); } @Test - public void shouldNotGetEmptyDescription() throws Exception { + public void shouldNotGetEmptyDescription() { values.put(CODE_KEY, "a_valid_code"); AuthenticationException ex = new AuthenticationException(values); assertThat(ex.getDescription(), is(equalTo("Failed with unknown error"))); } @Test - public void shouldGetValuesFromTheMap() throws Exception { + public void shouldGetValuesFromTheMap() { values.put("key", "value"); AuthenticationException ex = new AuthenticationException(values); assertThat(ex.getValue("key"), is(notNullValue())); @@ -129,7 +128,7 @@ public void shouldGetValuesFromTheMap() throws Exception { } @Test - public void shouldReturnNullIfMapDoesNotExist() throws Exception { + public void shouldReturnNullIfMapDoesNotExist() { AuthenticationException ex1 = new AuthenticationException("code", "description"); AuthenticationException ex2 = new AuthenticationException("message"); AuthenticationException ex3 = new AuthenticationException("code", new Auth0Exception("message")); @@ -153,7 +152,7 @@ public void shouldHaveNetworkError() { } @Test - public void shouldHaveExpiredMultifactorTokenOnOIDCMode() throws Exception { + public void shouldHaveExpiredMultifactorTokenOnOIDCMode() { values.put(ERROR_KEY, "expired_token"); values.put(ERROR_DESCRIPTION_KEY, "mfa_token is expired"); AuthenticationException ex = new AuthenticationException(values); @@ -161,7 +160,7 @@ public void shouldHaveExpiredMultifactorTokenOnOIDCMode() throws Exception { } @Test - public void shouldHaveMalformedMultifactorTokenOnOIDCMode() throws Exception { + public void shouldHaveMalformedMultifactorTokenOnOIDCMode() { values.put(ERROR_KEY, "invalid_grant"); values.put(ERROR_DESCRIPTION_KEY, "Malformed mfa_token"); AuthenticationException ex = new AuthenticationException(values); @@ -169,7 +168,7 @@ public void shouldHaveMalformedMultifactorTokenOnOIDCMode() throws Exception { } @Test - public void shouldRequireMultifactorOnOIDCMode() throws Exception { + public void shouldRequireMultifactorOnOIDCMode() { values.put(ERROR_KEY, "mfa_required"); values.put("mfa_token", "some-random-token"); AuthenticationException ex = new AuthenticationException(values); @@ -178,14 +177,14 @@ public void shouldRequireMultifactorOnOIDCMode() throws Exception { } @Test - public void shouldRequireMultifactor() throws Exception { + public void shouldRequireMultifactor() { values.put(CODE_KEY, "a0.mfa_required"); AuthenticationException ex = new AuthenticationException(values); assertThat(ex.isMultifactorRequired(), is(true)); } @Test - public void shouldRequireMultifactorEnrollOnOIDCMode() throws Exception { + public void shouldRequireMultifactorEnrollOnOIDCMode() { values.put(ERROR_KEY, "unsupported_challenge_type"); values.put(ERROR_DESCRIPTION_KEY, "User is not enrolled with guardian"); AuthenticationException ex = new AuthenticationException(values); @@ -193,14 +192,14 @@ public void shouldRequireMultifactorEnrollOnOIDCMode() throws Exception { } @Test - public void shouldRequireMultifactorEnroll() throws Exception { + public void shouldRequireMultifactorEnroll() { values.put(CODE_KEY, "a0.mfa_registration_required"); AuthenticationException ex = new AuthenticationException(values); assertThat(ex.isMultifactorEnrollRequired(), is(true)); } @Test - public void shouldHaveInvalidMultifactorCodeOnOIDCMode() throws Exception { + public void shouldHaveInvalidMultifactorCodeOnOIDCMode() { values.put(ERROR_KEY, "invalid_grant"); values.put(ERROR_DESCRIPTION_KEY, "Invalid otp_code."); AuthenticationException ex = new AuthenticationException(values); @@ -208,14 +207,14 @@ public void shouldHaveInvalidMultifactorCodeOnOIDCMode() throws Exception { } @Test - public void shouldHaveInvalidMultifactorCode() throws Exception { + public void shouldHaveInvalidMultifactorCode() { values.put(CODE_KEY, "a0.mfa_invalid_code"); AuthenticationException ex = new AuthenticationException(values); assertThat(ex.isMultifactorCodeInvalid(), is(true)); } @Test - public void shouldHaveNotStrongPassword() throws Exception { + public void shouldHaveNotStrongPassword() { values.put(CODE_KEY, "invalid_password"); values.put(NAME_KEY, "PasswordStrengthError"); AuthenticationException ex = new AuthenticationException(values); @@ -238,7 +237,7 @@ public void shouldHaveNotStrongPasswordWithDetailedDescription() throws Exceptio } @Test - public void shouldHaveAlreadyUsedPassword() throws Exception { + public void shouldHaveAlreadyUsedPassword() { values.put(CODE_KEY, "invalid_password"); values.put(NAME_KEY, "PasswordHistoryError"); AuthenticationException ex = new AuthenticationException(values); @@ -246,21 +245,21 @@ public void shouldHaveAlreadyUsedPassword() throws Exception { } @Test - public void shouldHaveRuleError() throws Exception { + public void shouldHaveRuleError() { values.put(CODE_KEY, "unauthorized"); AuthenticationException ex = new AuthenticationException(values); assertThat(ex.isRuleError(), is(true)); } @Test - public void shouldHaveInvalidCredentials() throws Exception { + public void shouldHaveInvalidCredentials() { values.put(CODE_KEY, "invalid_user_password"); AuthenticationException ex = new AuthenticationException(values); assertThat(ex.isInvalidCredentials(), is(true)); } @Test - public void shouldHaveOIDCInvalidCredentials() throws Exception { + public void shouldHaveOIDCInvalidCredentials() { values.put(CODE_KEY, "invalid_grant"); values.put(ERROR_DESCRIPTION_KEY, "Wrong email or password."); AuthenticationException ex = new AuthenticationException(values); @@ -268,49 +267,49 @@ public void shouldHaveOIDCInvalidCredentials() throws Exception { } @Test - public void shouldHaveAccessDenied() throws Exception { + public void shouldHaveAccessDenied() { values.put(CODE_KEY, "access_denied"); AuthenticationException ex = new AuthenticationException(values); assertThat(ex.isAccessDenied(), is(true)); } @Test - public void shouldHaveInvalidAuthorizeUrl() throws Exception { + public void shouldHaveInvalidAuthorizeUrl() { values.put(CODE_KEY, "a0.invalid_authorize_url"); AuthenticationException ex = new AuthenticationException(values); assertThat(ex.isInvalidAuthorizeURL(), is(true)); } @Test - public void shouldHaveInvalidConfiguration() throws Exception { + public void shouldHaveInvalidConfiguration() { values.put(CODE_KEY, "a0.invalid_configuration"); AuthenticationException ex = new AuthenticationException(values); assertThat(ex.isInvalidConfiguration(), is(true)); } @Test - public void shouldHaveAuthenticationCanceled() throws Exception { + public void shouldHaveAuthenticationCanceled() { values.put(CODE_KEY, "a0.authentication_canceled"); AuthenticationException ex = new AuthenticationException(values); assertThat(ex.isAuthenticationCanceled(), is(true)); } @Test - public void shouldHavePasswordLeaked() throws Exception { + public void shouldHavePasswordLeaked() { values.put(CODE_KEY, "password_leaked"); AuthenticationException ex = new AuthenticationException(values); assertThat(ex.isPasswordLeaked(), is(true)); } @Test - public void shouldHaveLoginRequired() throws Exception { + public void shouldHaveLoginRequired() { values.put(CODE_KEY, "login_required"); AuthenticationException ex = new AuthenticationException(values); assertThat(ex.isLoginRequired(), is(true)); } @Test - public void shouldHaveMissingBrowserApp() throws Exception { + public void shouldHaveMissingBrowserApp() { values.put(CODE_KEY, "a0.browser_not_available"); AuthenticationException ex = new AuthenticationException(values); assertThat(ex.isBrowserAppNotAvailable(), is(true)); diff --git a/auth0/src/test/java/com/auth0/android/authentication/ParameterBuilderTest.java b/auth0/src/test/java/com/auth0/android/authentication/ParameterBuilderTest.java index d31b432b7..76c9edab4 100755 --- a/auth0/src/test/java/com/auth0/android/authentication/ParameterBuilderTest.java +++ b/auth0/src/test/java/com/auth0/android/authentication/ParameterBuilderTest.java @@ -56,101 +56,101 @@ public class ParameterBuilderTest { private ParameterBuilder builder; @Before - public void setUp() throws Exception { + public void setUp() { this.builder = ParameterBuilder.newAuthenticationBuilder(); } @Test - public void shouldInstantiateWithNoArguments() throws Exception { + public void shouldInstantiateWithNoArguments() { assertThat(ParameterBuilder.newAuthenticationBuilder(), is(notNullValue())); } @Test - public void shouldInstantiateWithDefaultScope() throws Exception { + public void shouldInstantiateWithDefaultScope() { assertThat(ParameterBuilder.newAuthenticationBuilder().asDictionary(), hasEntry("scope", ParameterBuilder.SCOPE_OPENID)); } @Test - public void shouldInstantiateWithArguments() throws Exception { + public void shouldInstantiateWithArguments() { assertThat(ParameterBuilder.newBuilder(new HashMap()), is(notNullValue())); } @Test - public void shouldFailToInstantiateWithNullParametersInFactoryMethod() throws Exception { + public void shouldFailToInstantiateWithNullParametersInFactoryMethod() { expectedException.expect(IllegalArgumentException.class); expectedException.expectMessage(equalToIgnoringCase("Must provide non-null parameters")); ParameterBuilder.newBuilder(null); } @Test - public void shouldSetClientID() throws Exception { + public void shouldSetClientID() { assertThat(builder.setClientId(CLIENT_ID).asDictionary(), hasEntry("client_id", CLIENT_ID)); } @Test - public void shouldSetScope() throws Exception { + public void shouldSetScope() { Map parameters = builder.setScope(ParameterBuilder.SCOPE_OFFLINE_ACCESS).asDictionary(); assertThat(parameters, hasEntry("scope", ParameterBuilder.SCOPE_OFFLINE_ACCESS)); } @Test - public void shouldSetAudience() throws Exception { + public void shouldSetAudience() { Map parameters = builder.setAudience("https://domain.auth0.com/api").asDictionary(); assertThat(parameters, hasEntry("audience", "https://domain.auth0.com/api")); } @Test - public void shouldSetDevice() throws Exception { + public void shouldSetDevice() { Map parameters = builder.setDevice(DEVICE).asDictionary(); assertThat(parameters, hasEntry("device", DEVICE)); } @Test - public void shouldSetRefreshToken() throws Exception { + public void shouldSetRefreshToken() { Map parameters = builder.setRefreshToken(DEVICE).asDictionary(); assertThat(parameters, hasEntry("refresh_token", DEVICE)); } @Test - public void shouldSetScopeWithOfflineAccess() throws Exception { + public void shouldSetScopeWithOfflineAccess() { Map parameters = builder.setScope(ParameterBuilder.SCOPE_OFFLINE_ACCESS).asDictionary(); assertThat(parameters, hasEntry("scope", ParameterBuilder.SCOPE_OFFLINE_ACCESS)); } @Test - public void shouldSetGrantType() throws Exception { + public void shouldSetGrantType() { assertThat(builder.setGrantType(GRANT_TYPE).asDictionary(), hasEntry("grant_type", GRANT_TYPE)); } @Test - public void shouldSetConnection() throws Exception { + public void shouldSetConnection() { assertThat(builder.setConnection(CONNECTION).asDictionary(), hasEntry("connection", CONNECTION)); } @Test - public void shouldSetRealm() throws Exception { + public void shouldSetRealm() { assertThat(builder.setRealm(REALM).asDictionary(), hasEntry("realm", REALM)); } @Test - public void shouldAddArbitraryEntry() throws Exception { + public void shouldAddArbitraryEntry() { assertThat(builder.set("key", "value").asDictionary(), hasEntry("key", "value")); } @Test - public void shouldNotAddNullEntry() throws Exception { + public void shouldNotAddNullEntry() { assertThat(builder.set("key", null).asDictionary(), not(hasEntry("key", null))); } @Test - public void shouldAddAllFromDictionary() throws Exception { + public void shouldAddAllFromDictionary() { Map parameters = new HashMap<>(); parameters.put("key", "value"); assertThat(builder.addAll(parameters).asDictionary(), hasEntry("key", "value")); } @Test - public void shouldSkipNullValuesOnAddAllFromDictionary() throws Exception { + public void shouldSkipNullValuesOnAddAllFromDictionary() { Map parameters = new HashMap<>(); parameters.put("key", "value"); parameters.put("null", null); @@ -159,7 +159,7 @@ public void shouldSkipNullValuesOnAddAllFromDictionary() throws Exception { } @Test - public void shouldClearAllValues() throws Exception { + public void shouldClearAllValues() { Map parameters = new HashMap<>(); parameters.put("key", "value"); builder.addAll(parameters); @@ -169,19 +169,19 @@ public void shouldClearAllValues() throws Exception { } @Test - public void shouldDoNothingWhenAddingNullParameters() throws Exception { + public void shouldDoNothingWhenAddingNullParameters() { assertThat(builder.addAll(null).asDictionary(), hasEntry("scope", ParameterBuilder.SCOPE_OPENID)); } @Test - public void shouldProvideADictionaryCopy() throws Exception { + public void shouldProvideADictionaryCopy() { Map parameters = builder.setClientId(CLIENT_ID).asDictionary(); builder.set("key", "value"); assertThat(parameters, not(hasEntry("key", "value"))); } @Test - public void shouldProvideAnImmutableDictionary() throws Exception { + public void shouldProvideAnImmutableDictionary() { Map parameters = builder.setClientId(CLIENT_ID).asDictionary(); try { parameters.put("key", "value"); diff --git a/auth0/src/test/java/com/auth0/android/authentication/request/DatabaseConnectionRequestTest.java b/auth0/src/test/java/com/auth0/android/authentication/request/DatabaseConnectionRequestTest.java index 921692854..d7dd1ab54 100644 --- a/auth0/src/test/java/com/auth0/android/authentication/request/DatabaseConnectionRequestTest.java +++ b/auth0/src/test/java/com/auth0/android/authentication/request/DatabaseConnectionRequestTest.java @@ -3,12 +3,10 @@ import com.auth0.android.callback.BaseCallback; import com.auth0.android.request.ParameterizableRequest; -import org.hamcrest.CoreMatchers; import org.junit.Assert; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; -import org.mockito.Mockito; import org.robolectric.RobolectricTestRunner; import org.robolectric.annotation.Config; @@ -27,13 +25,13 @@ public class DatabaseConnectionRequestTest { private DatabaseConnectionRequest dbRequest; @Before - public void setUp() throws Exception { + public void setUp() { mockRequest = mock(ParameterizableRequest.class); dbRequest = new DatabaseConnectionRequest<>(mockRequest); } @Test - public void shouldAddAllTheParameters() throws Exception { + public void shouldAddAllTheParameters() { final Map params = mock(Map.class); final DatabaseConnectionRequest req = dbRequest.addParameters(params); verify(mockRequest).addParameters(params); @@ -42,7 +40,7 @@ public void shouldAddAllTheParameters() throws Exception { } @Test - public void shouldAddParameter() throws Exception { + public void shouldAddParameter() { final DatabaseConnectionRequest req = dbRequest.addParameter("key", "value"); verify(mockRequest).addParameter("key", "value"); Assert.assertThat(req, is(notNullValue())); @@ -50,7 +48,7 @@ public void shouldAddParameter() throws Exception { } @Test - public void shouldAddHeader() throws Exception { + public void shouldAddHeader() { final DatabaseConnectionRequest req = dbRequest.addHeader("header", "value"); verify(mockRequest).addHeader("header", "value"); Assert.assertThat(req, is(notNullValue())); @@ -58,7 +56,7 @@ public void shouldAddHeader() throws Exception { } @Test - public void shouldSetConnection() throws Exception { + public void shouldSetConnection() { final DatabaseConnectionRequest req = dbRequest.setConnection("my-connection"); verify(mockRequest).addParameter("connection", "my-connection"); Assert.assertThat(req, is(notNullValue())); @@ -66,14 +64,14 @@ public void shouldSetConnection() throws Exception { } @Test - public void shouldStartTheRequest() throws Exception { + public void shouldStartTheRequest() { final BaseCallback callback = mock(BaseCallback.class); dbRequest.start(callback); verify(mockRequest).start(callback); } @Test - public void shouldExecuteTheRequest() throws Exception { + public void shouldExecuteTheRequest() { dbRequest.execute(); verify(mockRequest).execute(); } diff --git a/auth0/src/test/java/com/auth0/android/authentication/request/DelegationRequestTest.java b/auth0/src/test/java/com/auth0/android/authentication/request/DelegationRequestTest.java index 13427cfd6..9c9536a3b 100644 --- a/auth0/src/test/java/com/auth0/android/authentication/request/DelegationRequestTest.java +++ b/auth0/src/test/java/com/auth0/android/authentication/request/DelegationRequestTest.java @@ -25,13 +25,13 @@ public class DelegationRequestTest { private DelegationRequest delegationRequest; @Before - public void setUp() throws Exception { + public void setUp() { mockRequest = mock(ParameterizableRequest.class); delegationRequest = new DelegationRequest(mockRequest); } @Test - public void shouldAddAllTheParameters() throws Exception { + public void shouldAddAllTheParameters() { final Map params = mock(Map.class); final DelegationRequest req = delegationRequest.addParameters(params); verify(mockRequest).addParameters(params); @@ -40,7 +40,7 @@ public void shouldAddAllTheParameters() throws Exception { } @Test - public void shouldSetApiType() throws Exception { + public void shouldSetApiType() { final DelegationRequest req = delegationRequest.setApiType("type-auth0"); verify(mockRequest).addParameter("api_type", "type-auth0"); Assert.assertThat(req, is(notNullValue())); @@ -48,7 +48,7 @@ public void shouldSetApiType() throws Exception { } @Test - public void shouldSetScope() throws Exception { + public void shouldSetScope() { final DelegationRequest req = delegationRequest.setScope("oauth2 offline_access profile"); verify(mockRequest).addParameter("scope", "oauth2 offline_access profile"); Assert.assertThat(req, is(notNullValue())); @@ -56,7 +56,7 @@ public void shouldSetScope() throws Exception { } @Test - public void shouldSetTarget() throws Exception { + public void shouldSetTarget() { final DelegationRequest req = delegationRequest.setTarget("target-is"); verify(mockRequest).addParameter("target", "target-is"); Assert.assertThat(req, is(notNullValue())); @@ -64,14 +64,14 @@ public void shouldSetTarget() throws Exception { } @Test - public void shouldStartTheRequest() throws Exception { + public void shouldStartTheRequest() { final BaseCallback callback = mock(BaseCallback.class); delegationRequest.start(callback); verify(mockRequest).start(callback); } @Test - public void shouldExecuteTheRequest() throws Exception { + public void shouldExecuteTheRequest() { delegationRequest.execute(); verify(mockRequest).execute(); } diff --git a/auth0/src/test/java/com/auth0/android/authentication/request/ProfileRequestTest.java b/auth0/src/test/java/com/auth0/android/authentication/request/ProfileRequestTest.java index d677ba59c..faa8e4de8 100644 --- a/auth0/src/test/java/com/auth0/android/authentication/request/ProfileRequestTest.java +++ b/auth0/src/test/java/com/auth0/android/authentication/request/ProfileRequestTest.java @@ -42,14 +42,14 @@ public class ProfileRequestTest { private ProfileRequest profileRequest; @Before - public void setUp() throws Exception { + public void setUp() { credentialsMockRequest = mock(AuthenticationRequest.class); userInfoMockRequest = mock(ParameterizableRequest.class); profileRequest = new ProfileRequest(credentialsMockRequest, userInfoMockRequest); } @Test - public void shouldAddParameters() throws Exception { + public void shouldAddParameters() { final Map params = mock(Map.class); final ProfileRequest req = profileRequest.addParameters(params); verify(credentialsMockRequest).addAuthenticationParameters(params); @@ -58,7 +58,7 @@ public void shouldAddParameters() throws Exception { } @Test - public void shouldSetScope() throws Exception { + public void shouldSetScope() { final ProfileRequest req = profileRequest.setScope("oauth2 offline_access profile"); verify(credentialsMockRequest).setScope("oauth2 offline_access profile"); Assert.assertThat(req, is(CoreMatchers.notNullValue())); @@ -66,7 +66,7 @@ public void shouldSetScope() throws Exception { } @Test - public void shouldSetConnection() throws Exception { + public void shouldSetConnection() { final ProfileRequest req = profileRequest.setConnection("my-connection"); verify(credentialsMockRequest).setConnection("my-connection"); Assert.assertThat(req, is(CoreMatchers.notNullValue())); @@ -74,7 +74,7 @@ public void shouldSetConnection() throws Exception { } @Test - public void shouldReturnAuthenticationAfterStartingTheRequest() throws Exception { + public void shouldReturnAuthenticationAfterStartingTheRequest() { final UserProfile userProfile = mock(UserProfile.class); final Credentials credentials = mock(Credentials.class); @@ -100,7 +100,7 @@ public void shouldReturnAuthenticationAfterStartingTheRequest() throws Exception } @Test - public void shouldReturnErrorAfterStartingTheRequestIfAuthenticationRequestFails() throws Exception { + public void shouldReturnErrorAfterStartingTheRequestIfAuthenticationRequestFails() { final UserProfile userProfile = mock(UserProfile.class); final AuthenticationException error = mock(AuthenticationException.class); @@ -118,7 +118,7 @@ public void shouldReturnErrorAfterStartingTheRequestIfAuthenticationRequestFails } @Test - public void shouldReturnErrorAfterStartingTheRequestIfTokenInfoRequestFails() throws Exception { + public void shouldReturnErrorAfterStartingTheRequestIfTokenInfoRequestFails() { final Credentials credentials = mock(Credentials.class); final AuthenticationException error = mock(AuthenticationException.class); @@ -136,11 +136,11 @@ public void shouldReturnErrorAfterStartingTheRequestIfTokenInfoRequestFails() th } @Test - public void shouldExecuteTheRequest() throws Exception { + public void shouldExecuteTheRequest() { final Credentials credentials = mock(Credentials.class); when(credentialsMockRequest.execute()).thenAnswer(new Answer() { @Override - public Object answer(InvocationOnMock invocation) throws Throwable { + public Object answer(InvocationOnMock invocation) { return credentials; } }); @@ -149,7 +149,7 @@ public Object answer(InvocationOnMock invocation) throws Throwable { when(userInfoMockRequest.addHeader(anyString(), anyString())).thenReturn(userInfoMockRequest); when(userInfoMockRequest.execute()).thenAnswer(new Answer() { @Override - public Object answer(InvocationOnMock invocation) throws Throwable { + public Object answer(InvocationOnMock invocation) { return userProfile; } }); diff --git a/auth0/src/test/java/com/auth0/android/authentication/request/SignUpRequestTest.java b/auth0/src/test/java/com/auth0/android/authentication/request/SignUpRequestTest.java index 35ae6057b..51dfbe94e 100644 --- a/auth0/src/test/java/com/auth0/android/authentication/request/SignUpRequestTest.java +++ b/auth0/src/test/java/com/auth0/android/authentication/request/SignUpRequestTest.java @@ -35,14 +35,14 @@ public class SignUpRequestTest { private SignUpRequest signUpRequest; @Before - public void setUp() throws Exception { + public void setUp() { dbMockRequest = mock(DatabaseConnectionRequest.class); authenticationMockRequest = mock(AuthenticationRequest.class); signUpRequest = new SignUpRequest(dbMockRequest, authenticationMockRequest); } @Test - public void shouldAddSignUpParameters() throws Exception { + public void shouldAddSignUpParameters() { final Map params = mock(Map.class); final SignUpRequest req = signUpRequest.addSignUpParameters(params); verify(dbMockRequest).addParameters(params); @@ -51,7 +51,7 @@ public void shouldAddSignUpParameters() throws Exception { } @Test - public void shouldAddAuthenticationParameters() throws Exception { + public void shouldAddAuthenticationParameters() { final Map params = mock(Map.class); final SignUpRequest req = signUpRequest.addAuthenticationParameters(params); verify(authenticationMockRequest).addAuthenticationParameters(params); @@ -60,7 +60,7 @@ public void shouldAddAuthenticationParameters() throws Exception { } @Test - public void shouldSetScope() throws Exception { + public void shouldSetScope() { final SignUpRequest req = signUpRequest.setScope("oauth2 offline_access profile"); verify(authenticationMockRequest).setScope("oauth2 offline_access profile"); Assert.assertThat(req, is(notNullValue())); @@ -68,7 +68,7 @@ public void shouldSetScope() throws Exception { } @Test - public void shouldSetAudience() throws Exception { + public void shouldSetAudience() { final AuthenticationRequest req = signUpRequest.setAudience("https://domain.auth0.com/api"); verify(authenticationMockRequest).setAudience("https://domain.auth0.com/api"); Assert.assertThat(req, is(notNullValue())); @@ -76,7 +76,7 @@ public void shouldSetAudience() throws Exception { } @Test - public void shouldSetDevice() throws Exception { + public void shouldSetDevice() { final AuthenticationRequest req = signUpRequest.setDevice("nexus-5x"); verify(authenticationMockRequest).setDevice("nexus-5x"); Assert.assertThat(req, is(notNullValue())); @@ -84,7 +84,7 @@ public void shouldSetDevice() throws Exception { } @Test - public void shouldSetGrantType() throws Exception { + public void shouldSetGrantType() { final AuthenticationRequest req = signUpRequest.setGrantType("token"); verify(authenticationMockRequest).setGrantType("token"); Assert.assertThat(req, is(notNullValue())); @@ -92,7 +92,7 @@ public void shouldSetGrantType() throws Exception { } @Test - public void shouldSetAccessToken() throws Exception { + public void shouldSetAccessToken() { final AuthenticationRequest req = signUpRequest.setAccessToken("super-access-token"); verify(authenticationMockRequest).setAccessToken("super-access-token"); Assert.assertThat(req, is(notNullValue())); @@ -100,7 +100,7 @@ public void shouldSetAccessToken() throws Exception { } @Test - public void shouldSetConnection() throws Exception { + public void shouldSetConnection() { final SignUpRequest req = signUpRequest.setConnection("my-connection"); verify(dbMockRequest).setConnection("my-connection"); verify(authenticationMockRequest).setConnection("my-connection"); @@ -109,7 +109,7 @@ public void shouldSetConnection() throws Exception { } @Test - public void shouldSetRealm() throws Exception { + public void shouldSetRealm() { final SignUpRequest req = signUpRequest.setRealm("users"); verify(dbMockRequest).setConnection("users"); verify(authenticationMockRequest).setRealm("users"); @@ -118,7 +118,7 @@ public void shouldSetRealm() throws Exception { } @Test - public void shouldReturnCredentialsAfterStartingTheRequest() throws Exception { + public void shouldReturnCredentialsAfterStartingTheRequest() { final DatabaseUser user = mock(DatabaseUser.class); final Credentials credentials = mock(Credentials.class); final DatabaseConnectionRequestMock dbRequestMock = new DatabaseConnectionRequestMock(user, null); @@ -134,7 +134,7 @@ public void shouldReturnCredentialsAfterStartingTheRequest() throws Exception { } @Test - public void shouldReturnErrorAfterStartingTheRequestIfDatabaseRequestFails() throws Exception { + public void shouldReturnErrorAfterStartingTheRequestIfDatabaseRequestFails() { final AuthenticationException error = mock(AuthenticationException.class); final Credentials credentials = mock(Credentials.class); final DatabaseConnectionRequestMock dbRequestMock = new DatabaseConnectionRequestMock(null, error); @@ -150,7 +150,7 @@ public void shouldReturnErrorAfterStartingTheRequestIfDatabaseRequestFails() thr } @Test - public void shouldReturnErrorAfterStartingTheRequestIfAuthenticationRequestFails() throws Exception { + public void shouldReturnErrorAfterStartingTheRequestIfAuthenticationRequestFails() { final DatabaseUser user = mock(DatabaseUser.class); final AuthenticationException error = mock(AuthenticationException.class); final DatabaseConnectionRequestMock dbRequestMock = new DatabaseConnectionRequestMock(user, null); @@ -166,17 +166,17 @@ public void shouldReturnErrorAfterStartingTheRequestIfAuthenticationRequestFails } @Test - public void shouldExecuteTheRequest() throws Exception { + public void shouldExecuteTheRequest() { when(dbMockRequest.execute()).thenAnswer(new Answer() { @Override - public Object answer(InvocationOnMock invocation) throws Throwable { + public Object answer(InvocationOnMock invocation) { return null; } }); final Credentials credentials = mock(Credentials.class); when(authenticationMockRequest.execute()).thenAnswer(new Answer() { @Override - public Object answer(InvocationOnMock invocation) throws Throwable { + public Object answer(InvocationOnMock invocation) { return credentials; } }); diff --git a/auth0/src/test/java/com/auth0/android/authentication/request/TokenRequestTest.java b/auth0/src/test/java/com/auth0/android/authentication/request/TokenRequestTest.java index 40fcaebe7..48bce76a4 100644 --- a/auth0/src/test/java/com/auth0/android/authentication/request/TokenRequestTest.java +++ b/auth0/src/test/java/com/auth0/android/authentication/request/TokenRequestTest.java @@ -23,13 +23,13 @@ public class TokenRequestTest { private TokenRequest tokenRequest; @Before - public void setUp() throws Exception { + public void setUp() { mockRequest = mock(ParameterizableRequest.class); tokenRequest = new TokenRequest(mockRequest); } @Test - public void shouldSetCodeVerifier() throws Exception { + public void shouldSetCodeVerifier() { final TokenRequest req = tokenRequest.setCodeVerifier("1234567890"); verify(mockRequest).addParameter("code_verifier", "1234567890"); Assert.assertThat(req, is(notNullValue())); @@ -37,14 +37,14 @@ public void shouldSetCodeVerifier() throws Exception { } @Test - public void shouldStartTheRequest() throws Exception { + public void shouldStartTheRequest() { final BaseCallback callback = mock(BaseCallback.class); tokenRequest.start(callback); verify(mockRequest).start(callback); } @Test - public void shouldExecuteTheRequest() throws Exception { + public void shouldExecuteTheRequest() { tokenRequest.execute(); verify(mockRequest).execute(); } diff --git a/auth0/src/test/java/com/auth0/android/authentication/result/JsonRequiredTypeAdapterFactoryTest.java b/auth0/src/test/java/com/auth0/android/authentication/result/JsonRequiredTypeAdapterFactoryTest.java index 2c8a2196d..70ddd9411 100755 --- a/auth0/src/test/java/com/auth0/android/authentication/result/JsonRequiredTypeAdapterFactoryTest.java +++ b/auth0/src/test/java/com/auth0/android/authentication/result/JsonRequiredTypeAdapterFactoryTest.java @@ -21,14 +21,14 @@ public class JsonRequiredTypeAdapterFactoryTest { Gson gson; @Before - public void setUp() throws Exception { + public void setUp() { gson = new GsonBuilder() .registerTypeAdapterFactory(new JsonRequiredTypeAdapterFactory()) .create(); } @Test - public void shouldThrowExceptionIfMissingFieldIsRequired() throws Exception { + public void shouldThrowExceptionIfMissingFieldIsRequired() { Exception error = null; try { gson.fromJson(missingValue, RequiredClass.class); @@ -41,7 +41,7 @@ public void shouldThrowExceptionIfMissingFieldIsRequired() throws Exception { } @Test - public void shouldNotThrowExceptionIfMissingFieldIsNotRequired() throws Exception { + public void shouldNotThrowExceptionIfMissingFieldIsNotRequired() { NotRequiredClass bean = null; Exception error = null; try { diff --git a/auth0/src/test/java/com/auth0/android/authentication/storage/CredentialsManagerTest.java b/auth0/src/test/java/com/auth0/android/authentication/storage/CredentialsManagerTest.java index adc35f51c..edd3ad223 100644 --- a/auth0/src/test/java/com/auth0/android/authentication/storage/CredentialsManagerTest.java +++ b/auth0/src/test/java/com/auth0/android/authentication/storage/CredentialsManagerTest.java @@ -67,7 +67,7 @@ public class CredentialsManagerTest { private ArgumentCaptor> requestCallbackCaptor; @Before - public void setUp() throws Exception { + public void setUp() { MockitoAnnotations.initMocks(this); CredentialsManager credentialsManager = new CredentialsManager(client, storage); manager = spy(credentialsManager); @@ -75,7 +75,7 @@ public void setUp() throws Exception { doReturn(CredentialsMock.CURRENT_TIME_MS).when(manager).getCurrentTimeInMillis(); doAnswer(new Answer() { @Override - public Object answer(InvocationOnMock invocation) throws Throwable { + public Object answer(InvocationOnMock invocation) { String idToken = invocation.getArgumentAt(0, String.class); String accessToken = invocation.getArgumentAt(1, String.class); String type = invocation.getArgumentAt(2, String.class); @@ -88,7 +88,7 @@ public Object answer(InvocationOnMock invocation) throws Throwable { } @Test - public void shouldSaveCredentialsInStorage() throws Exception { + public void shouldSaveCredentialsInStorage() { long expirationTime = CredentialsMock.CURRENT_TIME_MS + 123456 * 1000; Credentials credentials = new CredentialsMock("idToken", "accessToken", "type", "refreshToken", new Date(expirationTime), "scope"); manager.saveCredentials(credentials); @@ -103,7 +103,7 @@ public void shouldSaveCredentialsInStorage() throws Exception { } @Test - public void shouldThrowOnSetIfCredentialsDoesNotHaveIdTokenOrAccessToken() throws Exception { + public void shouldThrowOnSetIfCredentialsDoesNotHaveIdTokenOrAccessToken() { exception.expect(CredentialsManagerException.class); exception.expectMessage("Credentials must have a valid date of expiration and a valid access_token or id_token value."); @@ -113,7 +113,7 @@ public void shouldThrowOnSetIfCredentialsDoesNotHaveIdTokenOrAccessToken() throw @SuppressWarnings("ConstantConditions") @Test - public void shouldThrowOnSetIfCredentialsDoesNotHaveExpiresAt() throws Exception { + public void shouldThrowOnSetIfCredentialsDoesNotHaveExpiresAt() { exception.expect(CredentialsManagerException.class); exception.expectMessage("Credentials must have a valid date of expiration and a valid access_token or id_token value."); @@ -123,19 +123,19 @@ public void shouldThrowOnSetIfCredentialsDoesNotHaveExpiresAt() throws Exception } @Test - public void shouldNotThrowOnSetIfCredentialsHaveAccessTokenAndExpiresIn() throws Exception { + public void shouldNotThrowOnSetIfCredentialsHaveAccessTokenAndExpiresIn() { Credentials credentials = new CredentialsMock(null, "accessToken", "type", "refreshToken", 123456L); manager.saveCredentials(credentials); } @Test - public void shouldNotThrowOnSetIfCredentialsHaveIdTokenAndExpiresIn() throws Exception { + public void shouldNotThrowOnSetIfCredentialsHaveIdTokenAndExpiresIn() { Credentials credentials = new CredentialsMock("idToken", null, "type", "refreshToken", 123456L); manager.saveCredentials(credentials); } @Test - public void shouldFailOnGetCredentialsWhenNoAccessTokenOrIdTokenWasSaved() throws Exception { + public void shouldFailOnGetCredentialsWhenNoAccessTokenOrIdTokenWasSaved() { verifyNoMoreInteractions(client); when(storage.retrieveString("com.auth0.id_token")).thenReturn(null); @@ -155,7 +155,7 @@ public void shouldFailOnGetCredentialsWhenNoAccessTokenOrIdTokenWasSaved() throw } @Test - public void shouldFailOnGetCredentialsWhenNoExpirationTimeWasSaved() throws Exception { + public void shouldFailOnGetCredentialsWhenNoExpirationTimeWasSaved() { verifyNoMoreInteractions(client); when(storage.retrieveString("com.auth0.id_token")).thenReturn("idToken"); @@ -173,9 +173,8 @@ public void shouldFailOnGetCredentialsWhenNoExpirationTimeWasSaved() throws Exce assertThat(exception.getMessage(), is("No Credentials were previously set.")); } - @SuppressWarnings("UnnecessaryLocalVariable") @Test - public void shouldFailOnGetCredentialsWhenExpiredAndNoRefreshTokenWasSaved() throws Exception { + public void shouldFailOnGetCredentialsWhenExpiredAndNoRefreshTokenWasSaved() { verifyNoMoreInteractions(client); when(storage.retrieveString("com.auth0.id_token")).thenReturn("idToken"); @@ -195,7 +194,7 @@ public void shouldFailOnGetCredentialsWhenExpiredAndNoRefreshTokenWasSaved() thr } @Test - public void shouldGetNonExpiredCredentialsFromStorage() throws Exception { + public void shouldGetNonExpiredCredentialsFromStorage() { verifyNoMoreInteractions(client); when(storage.retrieveString("com.auth0.id_token")).thenReturn("idToken"); @@ -222,7 +221,7 @@ public void shouldGetNonExpiredCredentialsFromStorage() throws Exception { } @Test - public void shouldGetNonExpiredCredentialsFromStorageWhenOnlyIdTokenIsAvailable() throws Exception { + public void shouldGetNonExpiredCredentialsFromStorageWhenOnlyIdTokenIsAvailable() { verifyNoMoreInteractions(client); when(storage.retrieveString("com.auth0.id_token")).thenReturn("idToken"); @@ -249,7 +248,7 @@ public void shouldGetNonExpiredCredentialsFromStorageWhenOnlyIdTokenIsAvailable( } @Test - public void shouldGetNonExpiredCredentialsFromStorageWhenOnlyAccessTokenIsAvailable() throws Exception { + public void shouldGetNonExpiredCredentialsFromStorageWhenOnlyAccessTokenIsAvailable() { verifyNoMoreInteractions(client); when(storage.retrieveString("com.auth0.id_token")).thenReturn(null); @@ -275,9 +274,8 @@ public void shouldGetNonExpiredCredentialsFromStorageWhenOnlyAccessTokenIsAvaila assertThat(retrievedCredentials.getScope(), is("scope")); } - @SuppressWarnings("UnnecessaryLocalVariable") @Test - public void shouldGetAndSuccessfullyRenewExpiredCredentials() throws Exception { + public void shouldGetAndSuccessfullyRenewExpiredCredentials() { when(storage.retrieveString("com.auth0.id_token")).thenReturn("idToken"); when(storage.retrieveString("com.auth0.access_token")).thenReturn("accessToken"); when(storage.retrieveString("com.auth0.refresh_token")).thenReturn("refreshToken"); @@ -319,9 +317,8 @@ public void shouldGetAndSuccessfullyRenewExpiredCredentials() throws Exception { assertThat(retrievedCredentials.getScope(), is("newScope")); } - @SuppressWarnings("UnnecessaryLocalVariable") @Test - public void shouldGetAndFailToRenewExpiredCredentials() throws Exception { + public void shouldGetAndFailToRenewExpiredCredentials() { when(storage.retrieveString("com.auth0.id_token")).thenReturn("idToken"); when(storage.retrieveString("com.auth0.access_token")).thenReturn("accessToken"); when(storage.retrieveString("com.auth0.refresh_token")).thenReturn("refreshToken"); @@ -351,7 +348,7 @@ public void shouldGetAndFailToRenewExpiredCredentials() throws Exception { } @Test - public void shouldClearCredentials() throws Exception { + public void shouldClearCredentials() { manager.clearCredentials(); verify(storage).remove("com.auth0.id_token"); @@ -364,7 +361,7 @@ public void shouldClearCredentials() throws Exception { } @Test - public void shouldHaveCredentialsWhenTokenHasNotExpired() throws Exception { + public void shouldHaveCredentialsWhenTokenHasNotExpired() { long expirationTime = CredentialsMock.CURRENT_TIME_MS + 123456L * 1000; when(storage.retrieveLong("com.auth0.expires_at")).thenReturn(expirationTime); @@ -378,7 +375,7 @@ public void shouldHaveCredentialsWhenTokenHasNotExpired() throws Exception { } @Test - public void shouldNotHaveCredentialsWhenTokenHasExpiredAndNoRefreshTokenIsAvailable() throws Exception { + public void shouldNotHaveCredentialsWhenTokenHasExpiredAndNoRefreshTokenIsAvailable() { long expirationTime = CredentialsMock.CURRENT_TIME_MS; //Same as current time --> expired when(storage.retrieveLong("com.auth0.expires_at")).thenReturn(expirationTime); when(storage.retrieveString("com.auth0.refresh_token")).thenReturn(null); @@ -393,7 +390,7 @@ public void shouldNotHaveCredentialsWhenTokenHasExpiredAndNoRefreshTokenIsAvaila } @Test - public void shouldHaveCredentialsWhenTokenHasExpiredButRefreshTokenIsAvailable() throws Exception { + public void shouldHaveCredentialsWhenTokenHasExpiredButRefreshTokenIsAvailable() { long expirationTime = CredentialsMock.CURRENT_TIME_MS; //Same as current time --> expired when(storage.retrieveLong("com.auth0.expires_at")).thenReturn(expirationTime); when(storage.retrieveString("com.auth0.refresh_token")).thenReturn("refreshToken"); @@ -408,7 +405,7 @@ public void shouldHaveCredentialsWhenTokenHasExpiredButRefreshTokenIsAvailable() } @Test - public void shouldNotHaveCredentialsWhenAccessTokenAndIdTokenAreMissing() throws Exception { + public void shouldNotHaveCredentialsWhenAccessTokenAndIdTokenAreMissing() { when(storage.retrieveString("com.auth0.id_token")).thenReturn(null); when(storage.retrieveString("com.auth0.access_token")).thenReturn(null); @@ -416,7 +413,7 @@ public void shouldNotHaveCredentialsWhenAccessTokenAndIdTokenAreMissing() throws } @Test - public void shouldRecreateTheCredentials() throws Exception { + public void shouldRecreateTheCredentials() { CredentialsManager credentialsManager = new CredentialsManager(client, storage); Date now = new Date(); final Credentials credentials = credentialsManager.recreateCredentials("idTOKEN", "accessTOKEN", "tokenTYPE", "refreshTOKEN", now, "openid profile"); diff --git a/auth0/src/test/java/com/auth0/android/authentication/storage/CryptoUtilTest.java b/auth0/src/test/java/com/auth0/android/authentication/storage/CryptoUtilTest.java index a91aedfe5..f4950a78e 100644 --- a/auth0/src/test/java/com/auth0/android/authentication/storage/CryptoUtilTest.java +++ b/auth0/src/test/java/com/auth0/android/authentication/storage/CryptoUtilTest.java @@ -32,7 +32,6 @@ import java.math.BigInteger; import java.security.InvalidAlgorithmParameterException; import java.security.InvalidKeyException; -import java.security.Key; import java.security.KeyPairGenerator; import java.security.KeyStore; import java.security.KeyStoreException; @@ -110,7 +109,7 @@ public void setUp() throws Exception { PowerMockito.mockStatic(TextUtils.class); PowerMockito.when(TextUtils.isEmpty(anyString())).then(new Answer() { @Override - public Boolean answer(InvocationOnMock invocation) throws Throwable { + public Boolean answer(InvocationOnMock invocation) { String input = invocation.getArgumentAt(0, String.class); return input == null || input.isEmpty(); } @@ -125,7 +124,7 @@ public Boolean answer(InvocationOnMock invocation) throws Throwable { */ @Test - public void shouldThrowWhenRSAKeyAliasIsInvalid() throws Exception { + public void shouldThrowWhenRSAKeyAliasIsInvalid() { exception.expect(IllegalArgumentException.class); exception.expectMessage("RSA and AES Key alias must be valid."); new CryptoUtil(RuntimeEnvironment.application, storage, " "); @@ -547,16 +546,16 @@ public void shouldThrowOnInvalidAlgorithmParameterExceptionWhenTryingToObtainRSA */ @Test - public void shouldCreateAESKeyIfMissing() throws Exception { + public void shouldCreateAESKeyIfMissing() { byte[] sampleBytes = new byte[]{0, 1, 2, 3, 4, 5}; PowerMockito.mockStatic(Base64.class); PowerMockito.when(Base64.encode(sampleBytes, Base64.DEFAULT)).thenReturn("data".getBytes()); PowerMockito.when(storage.retrieveString(KEY_ALIAS)).thenReturn(null); doReturn(sampleBytes).when(cryptoUtil).RSAEncrypt(sampleBytes); - Key secretKey = PowerMockito.mock(SecretKey.class); + SecretKey secretKey = PowerMockito.mock(SecretKey.class); PowerMockito.when(secretKey.getEncoded()).thenReturn(sampleBytes); - PowerMockito.when(keyGenerator.generateKey()).thenReturn((SecretKey) secretKey); + PowerMockito.when(keyGenerator.generateKey()).thenReturn(secretKey); final byte[] aesKey = cryptoUtil.getAESKey(); @@ -570,7 +569,7 @@ public void shouldCreateAESKeyIfMissing() throws Exception { } @Test - public void shouldUseExistingAESKey() throws Exception { + public void shouldUseExistingAESKey() { byte[] sampleBytes = new byte[]{0, 1, 2, 3, 4, 5}; PowerMockito.mockStatic(Base64.class); PowerMockito.when(Base64.decode("data", Base64.DEFAULT)).thenReturn(sampleBytes); @@ -841,7 +840,7 @@ public void shouldAESEncryptData() throws Exception { } @Test - public void shouldThrowOnCryptoExceptionOnRSAKeyReadingWhenTryingToAESEncrypt() throws Exception { + public void shouldThrowOnCryptoExceptionOnRSAKeyReadingWhenTryingToAESEncrypt() { exception.expect(CryptoException.class); PowerMockito.mockStatic(Base64.class); @@ -853,7 +852,7 @@ public void shouldThrowOnCryptoExceptionOnRSAKeyReadingWhenTryingToAESEncrypt() } @Test - public void shouldThrowOnCryptoExceptionOnAESKeyReadingWhenTryingToAESEncrypt() throws Exception { + public void shouldThrowOnCryptoExceptionOnAESKeyReadingWhenTryingToAESEncrypt() { exception.expect(CryptoException.class); doThrow(new CryptoException(null, null)).when(cryptoUtil).getAESKey(); @@ -861,7 +860,7 @@ public void shouldThrowOnCryptoExceptionOnAESKeyReadingWhenTryingToAESEncrypt() } @Test - public void shouldThrowOnIncompatibleDeviceExceptionOnRSAKeyReadingWhenTryingToAESEncrypt() throws Exception { + public void shouldThrowOnIncompatibleDeviceExceptionOnRSAKeyReadingWhenTryingToAESEncrypt() { exception.expect(IncompatibleDeviceException.class); exception.expectMessage("The device is not compatible with the CryptoUtil class"); @@ -874,7 +873,7 @@ public void shouldThrowOnIncompatibleDeviceExceptionOnRSAKeyReadingWhenTryingToA } @Test - public void shouldThrowOnIncompatibleDeviceExceptionOnAESKeyReadingWhenTryingToAESEncrypt() throws Exception { + public void shouldThrowOnIncompatibleDeviceExceptionOnAESKeyReadingWhenTryingToAESEncrypt() { exception.expect(IncompatibleDeviceException.class); exception.expectMessage("The device is not compatible with the CryptoUtil class"); @@ -994,7 +993,7 @@ public void shouldAESDecryptData() throws Exception { } @Test - public void shouldThrowOnCryptoExceptionOnRSAKeyReadingWhenTryingToAESDecrypt() throws Exception { + public void shouldThrowOnCryptoExceptionOnRSAKeyReadingWhenTryingToAESDecrypt() { exception.expect(CryptoException.class); PowerMockito.mockStatic(Base64.class); @@ -1006,7 +1005,7 @@ public void shouldThrowOnCryptoExceptionOnRSAKeyReadingWhenTryingToAESDecrypt() } @Test - public void shouldThrowOnCryptoExceptionOnAESKeyReadingWhenTryingToAESDecrypt() throws Exception { + public void shouldThrowOnCryptoExceptionOnAESKeyReadingWhenTryingToAESDecrypt() { exception.expect(CryptoException.class); doThrow(new CryptoException(null, null)).when(cryptoUtil).getAESKey(); @@ -1014,7 +1013,7 @@ public void shouldThrowOnCryptoExceptionOnAESKeyReadingWhenTryingToAESDecrypt() } @Test - public void shouldThrowOnIncompatibleDeviceExceptionOnRSAKeyReadingWhenTryingToAESDecrypt() throws Exception { + public void shouldThrowOnIncompatibleDeviceExceptionOnRSAKeyReadingWhenTryingToAESDecrypt() { exception.expect(IncompatibleDeviceException.class); exception.expectMessage("The device is not compatible with the CryptoUtil class"); @@ -1027,7 +1026,7 @@ public void shouldThrowOnIncompatibleDeviceExceptionOnRSAKeyReadingWhenTryingToA } @Test - public void shouldThrowOnIncompatibleDeviceExceptionOnAESKeyReadingWhenTryingToAESDecrypt() throws Exception { + public void shouldThrowOnIncompatibleDeviceExceptionOnAESKeyReadingWhenTryingToAESDecrypt() { exception.expect(IncompatibleDeviceException.class); exception.expectMessage("The device is not compatible with the CryptoUtil class"); @@ -1223,7 +1222,7 @@ private CryptoUtil newCryptoUtilSpy() throws Exception { PowerMockito.mockStatic(Cipher.class); PowerMockito.when(Cipher.getInstance(anyString())).then(new Answer() { @Override - public Cipher answer(InvocationOnMock invocation) throws Throwable { + public Cipher answer(InvocationOnMock invocation) { String transformation = invocation.getArgumentAt(0, String.class); if (RSA_TRANSFORMATION.equals(transformation)) { return rsaCipher; diff --git a/auth0/src/test/java/com/auth0/android/authentication/storage/SecureCredentialsManagerTest.java b/auth0/src/test/java/com/auth0/android/authentication/storage/SecureCredentialsManagerTest.java index 74842ecd1..da04abd92 100644 --- a/auth0/src/test/java/com/auth0/android/authentication/storage/SecureCredentialsManagerTest.java +++ b/auth0/src/test/java/com/auth0/android/authentication/storage/SecureCredentialsManagerTest.java @@ -85,7 +85,7 @@ public class SecureCredentialsManagerTest { private Gson gson; @Before - public void setUp() throws Exception { + public void setUp() { MockitoAnnotations.initMocks(this); Activity activity = Robolectric.buildActivity(Activity.class).create().start().resume().get(); Activity activityContext = spy(activity); @@ -99,7 +99,7 @@ public void setUp() throws Exception { } @Test - public void shouldCreateAManagerInstance() throws Exception { + public void shouldCreateAManagerInstance() { Context context = Robolectric.buildActivity(Activity.class).create().start().resume().get(); AuthenticationAPIClient apiClient = new AuthenticationAPIClient(new Auth0("clientId", "domain")); Storage storage = new SharedPreferencesStorage(context); @@ -112,7 +112,7 @@ public void shouldCreateAManagerInstance() throws Exception { */ @Test - public void shouldSaveRefreshableCredentialsInStorage() throws Exception { + public void shouldSaveRefreshableCredentialsInStorage() { long expirationTime = CredentialsMock.CURRENT_TIME_MS + 123456 * 1000; Credentials credentials = new CredentialsMock("idToken", "accessToken", "type", "refreshToken", new Date(expirationTime), "scope"); String json = gson.toJson(credentials); @@ -138,7 +138,7 @@ public void shouldSaveRefreshableCredentialsInStorage() throws Exception { } @Test - public void shouldSaveNonRefreshableCredentialsInStorage() throws Exception { + public void shouldSaveNonRefreshableCredentialsInStorage() { long expirationTime = CredentialsMock.CURRENT_TIME_MS + 123456 * 1000; Credentials credentials = new CredentialsMock("idToken", "accessToken", "type", null, new Date(expirationTime), "scope"); String json = gson.toJson(credentials); @@ -164,7 +164,7 @@ public void shouldSaveNonRefreshableCredentialsInStorage() throws Exception { } @Test - public void shouldClearStoredCredentialsAndThrowOnSaveOnCryptoException() throws Exception { + public void shouldClearStoredCredentialsAndThrowOnSaveOnCryptoException() { long expirationTime = CredentialsMock.CURRENT_TIME_MS + 123456 * 1000; Credentials credentials = new CredentialsMock("idToken", "accessToken", "type", "refreshToken", new Date(expirationTime), "scope"); when(crypto.encrypt(any(byte[].class))).thenThrow(new CryptoException(null, null)); @@ -185,7 +185,7 @@ public void shouldClearStoredCredentialsAndThrowOnSaveOnCryptoException() throws } @Test - public void shouldThrowOnSaveOnIncompatibleDeviceException() throws Exception { + public void shouldThrowOnSaveOnIncompatibleDeviceException() { long expirationTime = CredentialsMock.CURRENT_TIME_MS + 123456 * 1000; Credentials credentials = new CredentialsMock("idToken", "accessToken", "type", "refreshToken", new Date(expirationTime), "scope"); when(crypto.encrypt(any(byte[].class))).thenThrow(new IncompatibleDeviceException(null)); @@ -202,7 +202,7 @@ public void shouldThrowOnSaveOnIncompatibleDeviceException() throws Exception { } @Test - public void shouldThrowOnSaveIfCredentialsDoesNotHaveIdTokenOrAccessToken() throws Exception { + public void shouldThrowOnSaveIfCredentialsDoesNotHaveIdTokenOrAccessToken() { exception.expect(CredentialsManagerException.class); exception.expectMessage("Credentials must have a valid date of expiration and a valid access_token or id_token value."); @@ -212,7 +212,7 @@ public void shouldThrowOnSaveIfCredentialsDoesNotHaveIdTokenOrAccessToken() thro @SuppressWarnings("ConstantConditions") @Test - public void shouldThrowOnSaveIfCredentialsDoesNotHaveExpiresAt() throws Exception { + public void shouldThrowOnSaveIfCredentialsDoesNotHaveExpiresAt() { exception.expect(CredentialsManagerException.class); exception.expectMessage("Credentials must have a valid date of expiration and a valid access_token or id_token value."); @@ -222,14 +222,14 @@ public void shouldThrowOnSaveIfCredentialsDoesNotHaveExpiresAt() throws Exceptio } @Test - public void shouldNotThrowOnSaveIfCredentialsHaveAccessTokenAndExpiresIn() throws Exception { + public void shouldNotThrowOnSaveIfCredentialsHaveAccessTokenAndExpiresIn() { Credentials credentials = new CredentialsMock(null, "accessToken", "type", "refreshToken", 123456L); when(crypto.encrypt(any(byte[].class))).thenReturn(new byte[]{12, 34, 56, 78}); manager.saveCredentials(credentials); } @Test - public void shouldNotThrowOnSaveIfCredentialsHaveIdTokenAndExpiresIn() throws Exception { + public void shouldNotThrowOnSaveIfCredentialsHaveIdTokenAndExpiresIn() { Credentials credentials = new CredentialsMock("idToken", null, "type", "refreshToken", 123456L); when(crypto.encrypt(any(byte[].class))).thenReturn(new byte[]{12, 34, 56, 78}); manager.saveCredentials(credentials); @@ -240,7 +240,7 @@ public void shouldNotThrowOnSaveIfCredentialsHaveIdTokenAndExpiresIn() throws Ex */ @Test - public void shouldClearStoredCredentialsAndFailOnGetCredentialsWhenCryptoExceptionIsThrown() throws Exception { + public void shouldClearStoredCredentialsAndFailOnGetCredentialsWhenCryptoExceptionIsThrown() { verifyNoMoreInteractions(client); Date expiresAt = new Date(CredentialsMock.CURRENT_TIME_MS + 123456L * 1000); @@ -262,7 +262,7 @@ public void shouldClearStoredCredentialsAndFailOnGetCredentialsWhenCryptoExcepti } @Test - public void shouldFailOnGetCredentialsWhenIncompatibleDeviceExceptionIsThrown() throws Exception { + public void shouldFailOnGetCredentialsWhenIncompatibleDeviceExceptionIsThrown() { verifyNoMoreInteractions(client); Date expiresAt = new Date(CredentialsMock.CURRENT_TIME_MS + 123456L * 1000); @@ -282,7 +282,7 @@ public void shouldFailOnGetCredentialsWhenIncompatibleDeviceExceptionIsThrown() } @Test - public void shouldFailOnGetCredentialsWhenNoAccessTokenOrIdTokenWasSaved() throws Exception { + public void shouldFailOnGetCredentialsWhenNoAccessTokenOrIdTokenWasSaved() { verifyNoMoreInteractions(client); Date expiresAt = new Date(CredentialsMock.CURRENT_TIME_MS + 123456L * 1000); @@ -296,7 +296,7 @@ public void shouldFailOnGetCredentialsWhenNoAccessTokenOrIdTokenWasSaved() throw } @Test - public void shouldFailOnGetCredentialsWhenNoExpirationTimeWasSaved() throws Exception { + public void shouldFailOnGetCredentialsWhenNoExpirationTimeWasSaved() { verifyNoMoreInteractions(client); insertTestCredentials(false, false, true, null); @@ -308,9 +308,8 @@ public void shouldFailOnGetCredentialsWhenNoExpirationTimeWasSaved() throws Exce assertThat(exception.getMessage(), is("No Credentials were previously set.")); } - @SuppressWarnings("UnnecessaryLocalVariable") @Test - public void shouldFailOnGetCredentialsWhenExpiredAndNoRefreshTokenWasSaved() throws Exception { + public void shouldFailOnGetCredentialsWhenExpiredAndNoRefreshTokenWasSaved() { verifyNoMoreInteractions(client); Date expiresAt = new Date(CredentialsMock.CURRENT_TIME_MS); //Same as current time --> expired @@ -324,7 +323,7 @@ public void shouldFailOnGetCredentialsWhenExpiredAndNoRefreshTokenWasSaved() thr } @Test - public void shouldGetNonExpiredCredentialsFromStorage() throws Exception { + public void shouldGetNonExpiredCredentialsFromStorage() { verifyNoMoreInteractions(client); Date expiresAt = new Date(CredentialsMock.CURRENT_TIME_MS + 123456L * 1000); @@ -345,7 +344,7 @@ public void shouldGetNonExpiredCredentialsFromStorage() throws Exception { } @Test - public void shouldGetNonExpiredCredentialsFromStorageWhenOnlyIdTokenIsAvailable() throws Exception { + public void shouldGetNonExpiredCredentialsFromStorageWhenOnlyIdTokenIsAvailable() { verifyNoMoreInteractions(client); Date expiresAt = new Date(CredentialsMock.CURRENT_TIME_MS + 123456L * 1000); @@ -367,7 +366,7 @@ public void shouldGetNonExpiredCredentialsFromStorageWhenOnlyIdTokenIsAvailable( } @Test - public void shouldGetNonExpiredCredentialsFromStorageWhenOnlyAccessTokenIsAvailable() throws Exception { + public void shouldGetNonExpiredCredentialsFromStorageWhenOnlyAccessTokenIsAvailable() { verifyNoMoreInteractions(client); Date expiresAt = new Date(CredentialsMock.CURRENT_TIME_MS + 123456L * 1000); @@ -387,9 +386,8 @@ public void shouldGetNonExpiredCredentialsFromStorageWhenOnlyAccessTokenIsAvaila assertThat(retrievedCredentials.getScope(), is("scope")); } - @SuppressWarnings("UnnecessaryLocalVariable") @Test - public void shouldGetAndSuccessfullyRenewExpiredCredentials() throws Exception { + public void shouldGetAndSuccessfullyRenewExpiredCredentials() { Date expiresAt = new Date(CredentialsMock.CURRENT_TIME_MS); insertTestCredentials(false, true, true, expiresAt); when(client.renewAuth("refreshToken")).thenReturn(request); @@ -434,9 +432,8 @@ public void shouldGetAndSuccessfullyRenewExpiredCredentials() throws Exception { assertThat(renewedStoredCredentials.getScope(), is("newScope")); } - @SuppressWarnings("UnnecessaryLocalVariable") @Test - public void shouldGetAndFailToRenewExpiredCredentials() throws Exception { + public void shouldGetAndFailToRenewExpiredCredentials() { Date expiresAt = new Date(CredentialsMock.CURRENT_TIME_MS); insertTestCredentials(false, true, true, expiresAt); when(client.renewAuth("refreshToken")).thenReturn(request); @@ -465,7 +462,7 @@ public void shouldGetAndFailToRenewExpiredCredentials() throws Exception { */ @Test - public void shouldClearCredentials() throws Exception { + public void shouldClearCredentials() { manager.clearCredentials(); verify(storage).remove("com.auth0.credentials"); @@ -479,7 +476,7 @@ public void shouldClearCredentials() throws Exception { */ @Test - public void shouldHaveCredentialsWhenTokenHasNotExpired() throws Exception { + public void shouldHaveCredentialsWhenTokenHasNotExpired() { long expirationTime = CredentialsMock.CURRENT_TIME_MS + 123456L * 1000; when(storage.retrieveLong("com.auth0.credentials_expires_at")).thenReturn(expirationTime); when(storage.retrieveBoolean("com.auth0.credentials_can_refresh")).thenReturn(false); @@ -491,7 +488,7 @@ public void shouldHaveCredentialsWhenTokenHasNotExpired() throws Exception { } @Test - public void shouldNotHaveCredentialsWhenTokenHasExpiredAndNoRefreshTokenIsAvailable() throws Exception { + public void shouldNotHaveCredentialsWhenTokenHasExpiredAndNoRefreshTokenIsAvailable() { long expirationTime = CredentialsMock.CURRENT_TIME_MS; //Same as current time --> expired when(storage.retrieveLong("com.auth0.credentials_expires_at")).thenReturn(expirationTime); when(storage.retrieveBoolean("com.auth0.credentials_can_refresh")).thenReturn(false); @@ -503,7 +500,7 @@ public void shouldNotHaveCredentialsWhenTokenHasExpiredAndNoRefreshTokenIsAvaila } @Test - public void shouldHaveCredentialsWhenTokenHasExpiredButRefreshTokenIsAvailable() throws Exception { + public void shouldHaveCredentialsWhenTokenHasExpiredButRefreshTokenIsAvailable() { long expirationTime = CredentialsMock.CURRENT_TIME_MS; //Same as current time --> expired when(storage.retrieveLong("com.auth0.credentials_expires_at")).thenReturn(expirationTime); when(storage.retrieveBoolean("com.auth0.credentials_can_refresh")).thenReturn(true); @@ -515,7 +512,7 @@ public void shouldHaveCredentialsWhenTokenHasExpiredButRefreshTokenIsAvailable() } @Test - public void shouldNotHaveCredentialsWhenAccessTokenAndIdTokenAreMissing() throws Exception { + public void shouldNotHaveCredentialsWhenAccessTokenAndIdTokenAreMissing() { when(storage.retrieveString("com.auth0.credentials")).thenReturn("{\"token_type\":\"type\", \"refresh_token\":\"refreshToken\"}"); assertFalse(manager.hasValidCredentials()); @@ -526,7 +523,7 @@ public void shouldNotHaveCredentialsWhenAccessTokenAndIdTokenAreMissing() throws */ @Test - public void shouldThrowOnInvalidAuthenticationRequestCode() throws Exception { + public void shouldThrowOnInvalidAuthenticationRequestCode() { exception.expect(IllegalArgumentException.class); exception.expectMessage("Request code must be a value between 1 and 255."); Activity activity = Robolectric.buildActivity(Activity.class).create().start().resume().get(); @@ -537,7 +534,7 @@ public void shouldThrowOnInvalidAuthenticationRequestCode() throws Exception { @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP) @Test @Config(sdk = 21) - public void shouldNotRequireAuthenticationIfAPI21AndLockScreenDisabled() throws Exception { + public void shouldNotRequireAuthenticationIfAPI21AndLockScreenDisabled() { ReflectionHelpers.setStaticField(Build.VERSION.class, "SDK_INT", 21); Activity activity = spy(Robolectric.buildActivity(Activity.class).create().start().resume().get()); @@ -555,7 +552,7 @@ public void shouldNotRequireAuthenticationIfAPI21AndLockScreenDisabled() throws @RequiresApi(api = Build.VERSION_CODES.M) @Test @Config(sdk = 23) - public void shouldNotRequireAuthenticationIfAPI23AndLockScreenDisabled() throws Exception { + public void shouldNotRequireAuthenticationIfAPI23AndLockScreenDisabled() { ReflectionHelpers.setStaticField(Build.VERSION.class, "SDK_INT", 23); Activity activity = spy(Robolectric.buildActivity(Activity.class).create().start().resume().get()); @@ -573,7 +570,7 @@ public void shouldNotRequireAuthenticationIfAPI23AndLockScreenDisabled() throws @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP) @Test @Config(sdk = 21) - public void shouldRequireAuthenticationIfAPI21AndLockScreenEnabled() throws Exception { + public void shouldRequireAuthenticationIfAPI21AndLockScreenEnabled() { ReflectionHelpers.setStaticField(Build.VERSION.class, "SDK_INT", 21); Activity activity = spy(Robolectric.buildActivity(Activity.class).create().start().resume().get()); @@ -591,7 +588,7 @@ public void shouldRequireAuthenticationIfAPI21AndLockScreenEnabled() throws Exce @RequiresApi(api = Build.VERSION_CODES.M) @Test @Config(sdk = 23) - public void shouldRequireAuthenticationIfAPI23AndLockScreenEnabled() throws Exception { + public void shouldRequireAuthenticationIfAPI23AndLockScreenEnabled() { ReflectionHelpers.setStaticField(Build.VERSION.class, "SDK_INT", 23); Activity activity = spy(Robolectric.buildActivity(Activity.class).create().start().resume().get()); @@ -607,7 +604,7 @@ public void shouldRequireAuthenticationIfAPI23AndLockScreenEnabled() throws Exce } @Test - public void shouldGetCredentialsAfterAuthentication() throws Exception { + public void shouldGetCredentialsAfterAuthentication() { Date expiresAt = new Date(CredentialsMock.CURRENT_TIME_MS + 123456L * 1000); insertTestCredentials(true, true, false, expiresAt); @@ -649,7 +646,7 @@ public void shouldGetCredentialsAfterAuthentication() throws Exception { } @Test - public void shouldNotGetCredentialsAfterCanceledAuthentication() throws Exception { + public void shouldNotGetCredentialsAfterCanceledAuthentication() { Date expiresAt = new Date(CredentialsMock.CURRENT_TIME_MS + 123456L * 1000); insertTestCredentials(true, true, false, expiresAt); @@ -682,7 +679,7 @@ public void shouldNotGetCredentialsAfterCanceledAuthentication() throws Exceptio } @Test - public void shouldNotGetCredentialsOnDifferentAuthenticationRequestCode() throws Exception { + public void shouldNotGetCredentialsOnDifferentAuthenticationRequestCode() { Date expiresAt = new Date(CredentialsMock.CURRENT_TIME_MS + 123456L * 1000); insertTestCredentials(true, true, false, expiresAt); diff --git a/auth0/src/test/java/com/auth0/android/authentication/storage/SharedPreferencesStorageTest.java b/auth0/src/test/java/com/auth0/android/authentication/storage/SharedPreferencesStorageTest.java index 33e786398..183652900 100644 --- a/auth0/src/test/java/com/auth0/android/authentication/storage/SharedPreferencesStorageTest.java +++ b/auth0/src/test/java/com/auth0/android/authentication/storage/SharedPreferencesStorageTest.java @@ -21,7 +21,6 @@ import static org.mockito.Matchers.anyFloat; import static org.mockito.Matchers.anyInt; import static org.mockito.Matchers.anyLong; -import static org.mockito.Matchers.anySet; import static org.mockito.Matchers.anySetOf; import static org.mockito.Matchers.anyString; import static org.mockito.Matchers.eq; @@ -43,7 +42,7 @@ public class SharedPreferencesStorageTest { public ExpectedException exception = ExpectedException.none(); @Before - public void setUp() throws Exception { + public void setUp() { MockitoAnnotations.initMocks(this); when(context.getSharedPreferences(anyString(), eq(Context.MODE_PRIVATE))).thenReturn(sharedPreferences); when(sharedPreferences.edit()).thenReturn(sharedPreferencesEditor); @@ -57,20 +56,20 @@ public void setUp() throws Exception { } @Test - public void shouldCreateWithDefaultPreferencesFileName() throws Exception { + public void shouldCreateWithDefaultPreferencesFileName() { new SharedPreferencesStorage(context); verify(context).getSharedPreferences("com.auth0.authentication.storage", Context.MODE_PRIVATE); } @Test - public void shouldCreateWithCustomPreferencesFileName() throws Exception { + public void shouldCreateWithCustomPreferencesFileName() { new SharedPreferencesStorage(context, "my-preferences-file"); verify(context).getSharedPreferences("my-preferences-file", Context.MODE_PRIVATE); } @SuppressWarnings("ConstantConditions") @Test - public void shouldThrowOnCreateIfCustomPreferencesFileNameIsNull() throws Exception { + public void shouldThrowOnCreateIfCustomPreferencesFileNameIsNull() { exception.expect(IllegalArgumentException.class); exception.expectMessage("The SharedPreferences name is invalid"); new SharedPreferencesStorage(context, null); @@ -80,7 +79,7 @@ public void shouldThrowOnCreateIfCustomPreferencesFileNameIsNull() throws Except //Store @Test - public void shouldStoreStringValueOnPreferences() throws Exception { + public void shouldStoreStringValueOnPreferences() { SharedPreferencesStorage storage = new SharedPreferencesStorage(context); storage.store("name", "value"); verify(sharedPreferencesEditor).putString("name", "value"); @@ -88,7 +87,7 @@ public void shouldStoreStringValueOnPreferences() throws Exception { } @Test - public void shouldStoreLongValueOnPreferences() throws Exception { + public void shouldStoreLongValueOnPreferences() { SharedPreferencesStorage storage = new SharedPreferencesStorage(context); storage.store("name", 123L); verify(sharedPreferencesEditor).putLong("name", 123L); @@ -96,7 +95,7 @@ public void shouldStoreLongValueOnPreferences() throws Exception { } @Test - public void shouldStoreIntegerValueOnPreferences() throws Exception { + public void shouldStoreIntegerValueOnPreferences() { SharedPreferencesStorage storage = new SharedPreferencesStorage(context); storage.store("name", 123); verify(sharedPreferencesEditor).putInt("name", 123); @@ -104,7 +103,7 @@ public void shouldStoreIntegerValueOnPreferences() throws Exception { } @Test - public void shouldStoreBooleanValueOnPreferences() throws Exception { + public void shouldStoreBooleanValueOnPreferences() { SharedPreferencesStorage storage = new SharedPreferencesStorage(context); storage.store("name", true); verify(sharedPreferencesEditor).putBoolean("name", true); @@ -115,7 +114,7 @@ public void shouldStoreBooleanValueOnPreferences() throws Exception { //Retrieve @Test - public void shouldRetrieveNullStringValueIfMissingKeyFromPreferences() throws Exception { + public void shouldRetrieveNullStringValueIfMissingKeyFromPreferences() { when(sharedPreferences.contains("name")).thenReturn(false); SharedPreferencesStorage storage = new SharedPreferencesStorage(context); String value = storage.retrieveString("name"); @@ -123,7 +122,7 @@ public void shouldRetrieveNullStringValueIfMissingKeyFromPreferences() throws Ex } @Test - public void shouldRetrieveNullLongValueIfMissingKeyFromPreferences() throws Exception { + public void shouldRetrieveNullLongValueIfMissingKeyFromPreferences() { when(sharedPreferences.contains("name")).thenReturn(false); SharedPreferencesStorage storage = new SharedPreferencesStorage(context); Long value = storage.retrieveLong("name"); @@ -131,7 +130,7 @@ public void shouldRetrieveNullLongValueIfMissingKeyFromPreferences() throws Exce } @Test - public void shouldRetrieveNullIntegerValueIfMissingKeyFromPreferences() throws Exception { + public void shouldRetrieveNullIntegerValueIfMissingKeyFromPreferences() { when(sharedPreferences.contains("name")).thenReturn(false); SharedPreferencesStorage storage = new SharedPreferencesStorage(context); Integer value = storage.retrieveInteger("name"); @@ -139,7 +138,7 @@ public void shouldRetrieveNullIntegerValueIfMissingKeyFromPreferences() throws E } @Test - public void shouldRetrieveNullBooleanValueIfMissingKeyFromPreferences() throws Exception { + public void shouldRetrieveNullBooleanValueIfMissingKeyFromPreferences() { when(sharedPreferences.contains("name")).thenReturn(false); SharedPreferencesStorage storage = new SharedPreferencesStorage(context); Boolean value = storage.retrieveBoolean("name"); @@ -147,7 +146,7 @@ public void shouldRetrieveNullBooleanValueIfMissingKeyFromPreferences() throws E } @Test - public void shouldRetrieveStringValueFromPreferences() throws Exception { + public void shouldRetrieveStringValueFromPreferences() { when(sharedPreferences.contains("name")).thenReturn(true); when(sharedPreferences.getString("name", null)).thenReturn("value"); SharedPreferencesStorage storage = new SharedPreferencesStorage(context); @@ -156,7 +155,7 @@ public void shouldRetrieveStringValueFromPreferences() throws Exception { } @Test - public void shouldRetrieveLongValueFromPreferences() throws Exception { + public void shouldRetrieveLongValueFromPreferences() { when(sharedPreferences.contains("name")).thenReturn(true); when(sharedPreferences.getLong("name", 0)).thenReturn(1234567890L); SharedPreferencesStorage storage = new SharedPreferencesStorage(context); @@ -165,7 +164,7 @@ public void shouldRetrieveLongValueFromPreferences() throws Exception { } @Test - public void shouldRetrieveIntegerValueFromPreferences() throws Exception { + public void shouldRetrieveIntegerValueFromPreferences() { when(sharedPreferences.contains("name")).thenReturn(true); when(sharedPreferences.getInt("name", 0)).thenReturn(123); SharedPreferencesStorage storage = new SharedPreferencesStorage(context); @@ -174,7 +173,7 @@ public void shouldRetrieveIntegerValueFromPreferences() throws Exception { } @Test - public void shouldRetrieveBooleanValueFromPreferences() throws Exception { + public void shouldRetrieveBooleanValueFromPreferences() { when(sharedPreferences.contains("name")).thenReturn(true); when(sharedPreferences.getBoolean("name", false)).thenReturn(true); SharedPreferencesStorage storage = new SharedPreferencesStorage(context); @@ -187,7 +186,7 @@ public void shouldRetrieveBooleanValueFromPreferences() throws Exception { @SuppressWarnings("ConstantConditions") @Test - public void shouldRemovePreferencesKeyOnNullStringValue() throws Exception { + public void shouldRemovePreferencesKeyOnNullStringValue() { SharedPreferencesStorage storage = new SharedPreferencesStorage(context); String value = null; storage.store("name", value); @@ -197,7 +196,7 @@ public void shouldRemovePreferencesKeyOnNullStringValue() throws Exception { @SuppressWarnings("ConstantConditions") @Test - public void shouldRemovePreferencesKeyOnNullLongValue() throws Exception { + public void shouldRemovePreferencesKeyOnNullLongValue() { SharedPreferencesStorage storage = new SharedPreferencesStorage(context); Long value = null; storage.store("name", value); @@ -207,7 +206,7 @@ public void shouldRemovePreferencesKeyOnNullLongValue() throws Exception { @SuppressWarnings("ConstantConditions") @Test - public void shouldRemovePreferencesKeyOnNullIntegerValue() throws Exception { + public void shouldRemovePreferencesKeyOnNullIntegerValue() { SharedPreferencesStorage storage = new SharedPreferencesStorage(context); Integer value = null; storage.store("name", value); @@ -217,7 +216,7 @@ public void shouldRemovePreferencesKeyOnNullIntegerValue() throws Exception { @SuppressWarnings("ConstantConditions") @Test - public void shouldRemovePreferencesKeyOnNullBooleanValue() throws Exception { + public void shouldRemovePreferencesKeyOnNullBooleanValue() { SharedPreferencesStorage storage = new SharedPreferencesStorage(context); Boolean value = null; storage.store("name", value); @@ -225,9 +224,8 @@ public void shouldRemovePreferencesKeyOnNullBooleanValue() throws Exception { verify(sharedPreferencesEditor).apply(); } - @SuppressWarnings("ConstantConditions") @Test - public void shouldRemovePreferencesKey() throws Exception { + public void shouldRemovePreferencesKey() { SharedPreferencesStorage storage = new SharedPreferencesStorage(context); storage.remove("name"); verify(sharedPreferencesEditor).remove("name"); diff --git a/auth0/src/test/java/com/auth0/android/management/UsersAPIClientTest.java b/auth0/src/test/java/com/auth0/android/management/UsersAPIClientTest.java index bd4659f77..fe2eb0750 100755 --- a/auth0/src/test/java/com/auth0/android/management/UsersAPIClientTest.java +++ b/auth0/src/test/java/com/auth0/android/management/UsersAPIClientTest.java @@ -110,7 +110,7 @@ public void tearDown() throws Exception { } @Test - public void shouldSetUserAgent() throws Exception { + public void shouldSetUserAgent() { Auth0 account = mock(Auth0.class); RequestFactory factory = mock(RequestFactory.class); OkHttpClientFactory clientFactory = mock(OkHttpClientFactory.class); @@ -120,7 +120,7 @@ public void shouldSetUserAgent() throws Exception { } @Test - public void shouldSetTelemetryIfPresent() throws Exception { + public void shouldSetTelemetryIfPresent() { final Telemetry telemetry = mock(Telemetry.class); when(telemetry.getValue()).thenReturn("the-telemetry-data"); RequestFactory factory = mock(RequestFactory.class); @@ -132,7 +132,7 @@ public void shouldSetTelemetryIfPresent() throws Exception { } @Test - public void shouldNotSetTelemetryIfMissing() throws Exception { + public void shouldNotSetTelemetryIfMissing() { RequestFactory factory = mock(RequestFactory.class); OkHttpClientFactory clientFactory = mock(OkHttpClientFactory.class); Auth0 auth0 = new Auth0(CLIENT_ID, DOMAIN); @@ -142,7 +142,7 @@ public void shouldNotSetTelemetryIfMissing() throws Exception { } @Test - public void shouldCreateClientWithAccountInfo() throws Exception { + public void shouldCreateClientWithAccountInfo() { UsersAPIClient client = new UsersAPIClient(new Auth0(CLIENT_ID, DOMAIN), TOKEN_PRIMARY); assertThat(client, is(notNullValue())); assertThat(client.getClientId(), equalTo(CLIENT_ID)); @@ -150,7 +150,7 @@ public void shouldCreateClientWithAccountInfo() throws Exception { } @Test - public void shouldCreateClientWithContextInfo() throws Exception { + public void shouldCreateClientWithContextInfo() { Context context = mock(Context.class); Resources resources = mock(Resources.class); when(context.getResources()).thenReturn(resources); @@ -342,7 +342,7 @@ public void shouldGetUserProfileSync() throws Exception { assertThat(result, isA(UserProfile.class)); } - private Map bodyFromRequest(RecordedRequest request) throws java.io.IOException { + private Map bodyFromRequest(RecordedRequest request) { final Type mapType = new TypeToken>() { }.getType(); return gson.fromJson(request.getBody().readUtf8(), mapType); diff --git a/auth0/src/test/java/com/auth0/android/provider/AuthProviderTest.java b/auth0/src/test/java/com/auth0/android/provider/AuthProviderTest.java index b76b614bc..c97b77262 100644 --- a/auth0/src/test/java/com/auth0/android/provider/AuthProviderTest.java +++ b/auth0/src/test/java/com/auth0/android/provider/AuthProviderTest.java @@ -31,8 +31,6 @@ import android.support.v4.content.PermissionChecker; import android.widget.TextView; -import org.hamcrest.Matcher; -import org.hamcrest.collection.IsMapContaining; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; @@ -79,7 +77,7 @@ public class AuthProviderTest { private static final int[] PERMISSIONS_GRANTED = new int[]{PermissionChecker.PERMISSION_GRANTED, PermissionChecker.PERMISSION_GRANTED}; @Before - public void setUp() throws Exception { + public void setUp() { MockitoAnnotations.initMocks(this); processAuthenticationCalled = false; provider = new AuthProvider(handler) { @@ -102,7 +100,7 @@ public String[] getRequiredAndroidPermissions() { } @Test - public void shouldHavePermissionHandler() throws Exception { + public void shouldHavePermissionHandler() { AuthProvider provider = new AuthProvider() { @Override protected void requestAuth(Activity activity, int requestCode) { @@ -124,12 +122,12 @@ public String[] getRequiredAndroidPermissions() { } @Test - public void shouldStop() throws Exception { + public void shouldStop() { provider.stop(); } @Test - public void shouldClearSession() throws Exception { + public void shouldClearSession() { assertThat(provider.getCallback(), is(nullValue())); provider.start(activity, callback, PERMISSION_REQUEST_CODE, AUTHENTICATION_REQUEST_CODE); assertThat(provider.getCallback(), is(notNullValue())); @@ -138,7 +136,7 @@ public void shouldClearSession() throws Exception { } @Test - public void shouldCallProcessAuthenticationIfPermissionsWereAlreadyGranted() throws Exception { + public void shouldCallProcessAuthenticationIfPermissionsWereAlreadyGranted() { when(handler.areAllPermissionsGranted(activity, PROVIDER_PERMISSIONS)).thenReturn(true); provider.start(activity, callback, PERMISSION_REQUEST_CODE, AUTHENTICATION_REQUEST_CODE); @@ -146,7 +144,7 @@ public void shouldCallProcessAuthenticationIfPermissionsWereAlreadyGranted() thr } @Test - public void shouldCallProcessAuthenticationIfPermissionsAreGranted() throws Exception { + public void shouldCallProcessAuthenticationIfPermissionsAreGranted() { when(handler.areAllPermissionsGranted(activity, PROVIDER_PERMISSIONS)).thenReturn(false); when(handler.parseRequestResult(PERMISSION_REQUEST_CODE, PROVIDER_PERMISSIONS, PERMISSIONS_GRANTED)).thenReturn(Collections.emptyList()); provider.start(activity, callback, PERMISSION_REQUEST_CODE, AUTHENTICATION_REQUEST_CODE); @@ -156,14 +154,14 @@ public void shouldCallProcessAuthenticationIfPermissionsAreGranted() throws Exce } @Test - public void shouldCallCheckPermissionsOnHandler() throws Exception { + public void shouldCallCheckPermissionsOnHandler() { provider.start(activity, callback, PERMISSION_REQUEST_CODE, AUTHENTICATION_REQUEST_CODE); verify(handler).areAllPermissionsGranted(activity, PROVIDER_PERMISSIONS); } @Test - public void shouldCallRequestPermissionsOnHandlerIfPermissionsAreNotAlreadyGranted() throws Exception { + public void shouldCallRequestPermissionsOnHandlerIfPermissionsAreNotAlreadyGranted() { when(handler.areAllPermissionsGranted(activity, PROVIDER_PERMISSIONS)).thenReturn(false); provider.start(activity, callback, PERMISSION_REQUEST_CODE, AUTHENTICATION_REQUEST_CODE); @@ -171,14 +169,14 @@ public void shouldCallRequestPermissionsOnHandlerIfPermissionsAreNotAlreadyGrant } @Test - public void shouldDeliverOnRequestPermissionsResultToHandler() throws Exception { + public void shouldDeliverOnRequestPermissionsResultToHandler() { provider.onRequestPermissionsResult(activity, PERMISSION_REQUEST_CODE, PROVIDER_PERMISSIONS, PERMISSIONS_GRANTED); verify(handler).parseRequestResult(PERMISSION_REQUEST_CODE, PROVIDER_PERMISSIONS, PERMISSIONS_GRANTED); } @Test - public void shouldFailWithDialogWhenPermissionsAreNotGranted() throws Exception { + public void shouldFailWithDialogWhenPermissionsAreNotGranted() { when(handler.parseRequestResult(PERMISSION_REQUEST_CODE, PROVIDER_PERMISSIONS, PERMISSIONS_GRANTED)).thenReturn(Arrays.asList("some", "values")); Activity activity = Robolectric.buildActivity(Activity.class).create().resume().get(); provider.start(activity, callback, PERMISSION_REQUEST_CODE, AUTHENTICATION_REQUEST_CODE); @@ -190,13 +188,13 @@ public void shouldFailWithDialogWhenPermissionsAreNotGranted() throws Exception assertThat(dialog, is(instanceOf(Dialog.class))); assertThat(dialog, is(notNullValue())); dialog.show(); //Load the layout - TextView messageTV = (TextView) dialog.findViewById(android.R.id.message); + TextView messageTV = dialog.findViewById(android.R.id.message); assertThat(messageTV.getText().toString(), containsString("Some permissions required by this provider were not granted. You can try to authenticate again or go to " + "the application's permission screen in the phone settings and grant them. The missing permissions are:\n" + "[some, values]")); } @Test - public void shouldSetParameters() throws Exception { + public void shouldSetParameters() { Map params = new HashMap<>(); params.put("key", "value"); provider.setParameters(params); @@ -207,13 +205,13 @@ public void shouldSetParameters() throws Exception { } @Test - public void shouldReturnFalseWhenCalledWithIntentByDefault() throws Exception { + public void shouldReturnFalseWhenCalledWithIntentByDefault() { boolean authorizeResult = provider.authorize(new Intent()); assertFalse(authorizeResult); } @Test - public void shouldReturnCallback() throws Exception { + public void shouldReturnCallback() { Mockito.when(handler.areAllPermissionsGranted(activity, PROVIDER_PERMISSIONS)).thenReturn(true); provider.start(activity, callback, PERMISSION_REQUEST_CODE, AUTHENTICATION_REQUEST_CODE); @@ -221,14 +219,14 @@ public void shouldReturnCallback() throws Exception { } @Test - public void shouldReturnNullCallbackIfNotStarted() throws Exception { + public void shouldReturnNullCallbackIfNotStarted() { Mockito.when(handler.areAllPermissionsGranted(activity, PROVIDER_PERMISSIONS)).thenReturn(true); assertThat(provider.getCallback(), is(nullValue())); } @Test - public void shouldReturnNullCallbackIfSessionCleared() throws Exception { + public void shouldReturnNullCallbackIfSessionCleared() { Mockito.when(handler.areAllPermissionsGranted(activity, PROVIDER_PERMISSIONS)).thenReturn(true); provider.start(activity, callback, PERMISSION_REQUEST_CODE, AUTHENTICATION_REQUEST_CODE); provider.clearSession(); diff --git a/auth0/src/test/java/com/auth0/android/provider/AuthenticationActivityTest.java b/auth0/src/test/java/com/auth0/android/provider/AuthenticationActivityTest.java index 104a26f33..e37f70679 100644 --- a/auth0/src/test/java/com/auth0/android/provider/AuthenticationActivityTest.java +++ b/auth0/src/test/java/com/auth0/android/provider/AuthenticationActivityTest.java @@ -57,7 +57,7 @@ public class AuthenticationActivityTest { private ActivityController activityController; @Before - public void setUp() throws Exception { + public void setUp() { MockitoAnnotations.initMocks(this); callerActivity = spy(Robolectric.buildActivity(Activity.class).get()); } @@ -68,9 +68,8 @@ private void createActivity(Intent configurationIntent) { activity.setCustomTabsController(customTabsController); } - @SuppressWarnings("deprecation") @Test - public void shouldFinishGracefullyWhenCalledByError() throws Exception { + public void shouldFinishGracefullyWhenCalledByError() { Intent intent = new Intent(callerActivity, AuthenticationActivity.class); //An invalid call will not pass any expected extras createActivity(intent); @@ -84,9 +83,8 @@ public void shouldFinishGracefullyWhenCalledByError() throws Exception { activityController.destroy(); } - @SuppressWarnings("deprecation") @Test - public void shouldAuthenticateUsingBrowser() throws Exception { + public void shouldAuthenticateUsingBrowser() { AuthenticationActivity.authenticateUsingBrowser(callerActivity, uri, customTabsOptions); verify(callerActivity).startActivity(intentCaptor.capture()); @@ -115,9 +113,8 @@ public void shouldAuthenticateUsingBrowser() throws Exception { verify(customTabsController).unbindService(); } - @SuppressWarnings("deprecation") @Test - public void shouldAuthenticateAfterRecreatedUsingBrowser() throws Exception { + public void shouldAuthenticateAfterRecreatedUsingBrowser() { AuthenticationActivity.authenticateUsingBrowser(callerActivity, uri, customTabsOptions); verify(callerActivity).startActivity(intentCaptor.capture()); @@ -144,9 +141,8 @@ public void shouldAuthenticateAfterRecreatedUsingBrowser() throws Exception { verify(customTabsController).unbindService(); } - @SuppressWarnings("deprecation") @Test - public void shouldCancelAuthenticationUsingBrowser() throws Exception { + public void shouldCancelAuthenticationUsingBrowser() { AuthenticationActivity.authenticateUsingBrowser(callerActivity, uri, customTabsOptions); verify(callerActivity).startActivity(intentCaptor.capture()); @@ -171,9 +167,8 @@ public void shouldCancelAuthenticationUsingBrowser() throws Exception { verify(customTabsController).unbindService(); } - @SuppressWarnings("deprecation") @Test - public void shouldAuthenticateUsingWebView() throws Exception { + public void shouldAuthenticateUsingWebView() { verifyNoMoreInteractions(customTabsController); AuthenticationActivity.authenticateUsingWebView(callerActivity, uri, 123, "facebook", true); @@ -208,9 +203,8 @@ public void shouldAuthenticateUsingWebView() throws Exception { activityController.destroy(); } - @SuppressWarnings("deprecation") @Test - public void shouldAuthenticateAfterRecreatedUsingWebView() throws Exception { + public void shouldAuthenticateAfterRecreatedUsingWebView() { verifyNoMoreInteractions(customTabsController); AuthenticationActivity.authenticateUsingWebView(callerActivity, uri, 123, "facebook", true); @@ -245,9 +239,8 @@ public void shouldAuthenticateAfterRecreatedUsingWebView() throws Exception { activityController.destroy(); } - @SuppressWarnings("deprecation") @Test - public void shouldCancelAuthenticationUsingWebView() throws Exception { + public void shouldCancelAuthenticationUsingWebView() { verifyNoMoreInteractions(customTabsController); AuthenticationActivity.authenticateUsingWebView(callerActivity, uri, 123, "facebook", true); @@ -280,9 +273,8 @@ public void shouldCancelAuthenticationUsingWebView() throws Exception { activityController.destroy(); } - @SuppressWarnings("deprecation") @Test - public void shouldLaunchForBrowserAuthentication() throws Exception { + public void shouldLaunchForBrowserAuthentication() { AuthenticationActivity.authenticateUsingBrowser(callerActivity, uri, customTabsOptions); verify(callerActivity).startActivity(intentCaptor.capture()); @@ -301,9 +293,8 @@ public void shouldLaunchForBrowserAuthentication() throws Exception { Assert.assertThat((CustomTabsOptions) extras.getParcelable(AuthenticationActivity.EXTRA_CT_OPTIONS), is(customTabsOptions)); } - @SuppressWarnings("deprecation") @Test - public void shouldLaunchForWebViewAuthentication() throws Exception { + public void shouldLaunchForWebViewAuthentication() { AuthenticationActivity.authenticateUsingWebView(callerActivity, uri, 123, "facebook", true); verify(callerActivity).startActivityForResult(intentCaptor.capture(), eq(123)); @@ -325,7 +316,7 @@ public void shouldLaunchForWebViewAuthentication() throws Exception { } @Test - public void shouldCreateCustomTabsController() throws Exception { + public void shouldCreateCustomTabsController() { final AuthenticationActivity authenticationActivity = new AuthenticationActivity(); final CustomTabsController controller = authenticationActivity.createCustomTabsController(RuntimeEnvironment.application); diff --git a/auth0/src/test/java/com/auth0/android/provider/AuthorizeResultTest.java b/auth0/src/test/java/com/auth0/android/provider/AuthorizeResultTest.java index 63c23fa4e..96702f101 100644 --- a/auth0/src/test/java/com/auth0/android/provider/AuthorizeResultTest.java +++ b/auth0/src/test/java/com/auth0/android/provider/AuthorizeResultTest.java @@ -53,14 +53,14 @@ public class AuthorizeResultTest { private Intent intent; @Before - public void setUp() throws Exception { + public void setUp() { intent = Mockito.mock(Intent.class); Uri data = Uri.parse(CALLBACK_URL + SAMPLE_HASH); when(intent.getData()).thenReturn(data); } @Test - public void shouldNotBeValidForOtherResult() throws Exception { + public void shouldNotBeValidForOtherResult() { AuthorizeResult authorizeResult = new AuthorizeResult(REQUEST_CODE, Activity.RESULT_OK, intent); boolean isValid = authorizeResult.isValid(OTHER_REQUEST_CODE); @@ -69,7 +69,7 @@ public void shouldNotBeValidForOtherResult() throws Exception { } @Test - public void shouldBeValidAndCanceledForNullUri() throws Exception { + public void shouldBeValidAndCanceledForNullUri() { when(intent.getData()).thenReturn(null); AuthorizeResult authorizeResult = new AuthorizeResult(intent); @@ -78,7 +78,7 @@ public void shouldBeValidAndCanceledForNullUri() throws Exception { } @Test - public void shouldBeValidForCanceledResult() throws Exception { + public void shouldBeValidForCanceledResult() { when(intent.getData()).thenReturn(null); AuthorizeResult authorizeResult = new AuthorizeResult(REQUEST_CODE, Activity.RESULT_CANCELED, intent); @@ -86,21 +86,21 @@ public void shouldBeValidForCanceledResult() throws Exception { } @Test - public void shouldBeValidForExpectedActivityResult() throws Exception { + public void shouldBeValidForExpectedActivityResult() { AuthorizeResult authorizeResult = new AuthorizeResult(REQUEST_CODE, Activity.RESULT_OK, intent); assertThat(authorizeResult.isValid(REQUEST_CODE), is(true)); } @Test - public void shouldBeValid() throws Exception { + public void shouldBeValid() { AuthorizeResult authorizeResult = new AuthorizeResult(intent); assertThat(authorizeResult.isValid(0), is(true)); } @Test - public void shouldCreateAValidResultWithOnlyTheIntent() throws Exception { + public void shouldCreateAValidResultWithOnlyTheIntent() { AuthorizeResult authorizeResult = new AuthorizeResult(intent); assertThat(authorizeResult.getIntentData(), is(notNullValue())); diff --git a/auth0/src/test/java/com/auth0/android/provider/CallbackHelperTest.java b/auth0/src/test/java/com/auth0/android/provider/CallbackHelperTest.java index 75d0b2f78..c44ac8097 100644 --- a/auth0/src/test/java/com/auth0/android/provider/CallbackHelperTest.java +++ b/auth0/src/test/java/com/auth0/android/provider/CallbackHelperTest.java @@ -56,7 +56,7 @@ public class CallbackHelperTest { private static final String DEFAULT_SCHEME = "https"; @Test - public void shouldGetCallbackURI() throws Exception { + public void shouldGetCallbackURI() { final Uri expected = Uri.parse(DOMAIN + "/android/" + PACKAGE_NAME + "/callback"); final Uri result = Uri.parse(CallbackHelper.getCallbackUri(DEFAULT_SCHEME, PACKAGE_NAME, DOMAIN)); @@ -70,7 +70,7 @@ public void shouldGetCallbackURI() throws Exception { } @Test - public void shouldGetCallbackURIWithCustomScheme() throws Exception { + public void shouldGetCallbackURIWithCustomScheme() { final Uri expected = Uri.parse("myapp://" + "my-domain.auth0.com" + "/android/" + PACKAGE_NAME + "/callback"); final Uri result = Uri.parse(CallbackHelper.getCallbackUri("myapp", PACKAGE_NAME, DOMAIN)); @@ -84,7 +84,7 @@ public void shouldGetCallbackURIWithCustomScheme() throws Exception { } @Test - public void shouldGetCallbackURIIfDomainEndsWithSlash() throws Exception { + public void shouldGetCallbackURIIfDomainEndsWithSlash() { final Uri expected = Uri.parse(DOMAIN + "/android/" + PACKAGE_NAME + "/callback"); final Uri result = Uri.parse(CallbackHelper.getCallbackUri(DEFAULT_SCHEME, PACKAGE_NAME, DOMAIN_WITH_TRAILING_SLASH)); @@ -98,13 +98,13 @@ public void shouldGetCallbackURIIfDomainEndsWithSlash() throws Exception { } @Test - public void shouldGetNullCallbackURIIfInvalidDomain() throws Exception { + public void shouldGetNullCallbackURIIfInvalidDomain() { String uri = CallbackHelper.getCallbackUri(DEFAULT_SCHEME, PACKAGE_NAME, INVALID_DOMAIN); assertThat(uri, nullValue()); } @Test - public void shouldParseQueryValues() throws Exception { + public void shouldParseQueryValues() { String uriString = "https://lbalmaceda.auth0.com/android/com.auth0.android.lock.app/callback?code=soMec0d3ML8B&state=810132b-486aa-4aa8-1768-a1dcd3368fae"; Uri uri = Uri.parse(uriString); final Map values = CallbackHelper.getValuesFromUri(uri); @@ -116,7 +116,7 @@ public void shouldParseQueryValues() throws Exception { } @Test - public void shouldParseFragmentValues() throws Exception { + public void shouldParseFragmentValues() { String uriString = "https://lbalmaceda.auth0.com/android/com.auth0.android.lock.app/callback#code=soMec0d3ML8B&state=810132b-486aa-4aa8-1768-a1dcd3368fae"; Uri uri = Uri.parse(uriString); final Map values = CallbackHelper.getValuesFromUri(uri); @@ -128,7 +128,7 @@ public void shouldParseFragmentValues() throws Exception { } @Test - public void shouldReturnEmptyQueryValues() throws Exception { + public void shouldReturnEmptyQueryValues() { String uriString = "https://lbalmaceda.auth0.com/android/com.auth0.android.lock.app/callback?"; Uri uri = Uri.parse(uriString); final Map values = CallbackHelper.getValuesFromUri(uri); @@ -138,7 +138,7 @@ public void shouldReturnEmptyQueryValues() throws Exception { } @Test - public void shouldReturnEmptyFragmentValues() throws Exception { + public void shouldReturnEmptyFragmentValues() { String uriString = "https://lbalmaceda.auth0.com/android/com.auth0.android.lock.app/callback#"; Uri uri = Uri.parse(uriString); final Map values = CallbackHelper.getValuesFromUri(uri); @@ -148,7 +148,7 @@ public void shouldReturnEmptyFragmentValues() throws Exception { } @Test - public void shouldGetEmptyValuesWhenQueryOrFragmentIsMissing() throws Exception { + public void shouldGetEmptyValuesWhenQueryOrFragmentIsMissing() { String uriString = "https://my.website.com/some/page"; Uri uri = Uri.parse(uriString); final Map values = CallbackHelper.getValuesFromUri(uri); @@ -157,7 +157,7 @@ public void shouldGetEmptyValuesWhenQueryOrFragmentIsMissing() throws Exception } @Test - public void shouldGetEmptyValuesWhenQueryIsEmpty() throws Exception { + public void shouldGetEmptyValuesWhenQueryIsEmpty() { String uriString = "https://my.website.com/some/page?"; Uri uri = Uri.parse(uriString); final Map values = CallbackHelper.getValuesFromUri(uri); @@ -166,7 +166,7 @@ public void shouldGetEmptyValuesWhenQueryIsEmpty() throws Exception { } @Test - public void shouldGetEmptyValuesWhenQueryBeginsWithAmpersand() throws Exception { + public void shouldGetEmptyValuesWhenQueryBeginsWithAmpersand() { String uriString = "https://my.website.com/some/page?&key_without_value"; Uri uri = Uri.parse(uriString); final Map values = CallbackHelper.getValuesFromUri(uri); @@ -175,7 +175,7 @@ public void shouldGetEmptyValuesWhenQueryBeginsWithAmpersand() throws Exception } @Test - public void shouldGetEmptyValuesWhenFragmentIsEmpty() throws Exception { + public void shouldGetEmptyValuesWhenFragmentIsEmpty() { String uriString = "https://my.website.com/some/page#"; Uri uri = Uri.parse(uriString); final Map values = CallbackHelper.getValuesFromUri(uri); @@ -184,7 +184,7 @@ public void shouldGetEmptyValuesWhenFragmentIsEmpty() throws Exception { } @Test - public void shouldGetEmptyValuesWhenFragmentBeginsWithAmpersand() throws Exception { + public void shouldGetEmptyValuesWhenFragmentBeginsWithAmpersand() { String uriString = "https://my.website.com/some/page#&key_without_value"; Uri uri = Uri.parse(uriString); final Map values = CallbackHelper.getValuesFromUri(uri); @@ -193,7 +193,7 @@ public void shouldGetEmptyValuesWhenFragmentBeginsWithAmpersand() throws Excepti } @Test - public void shouldGetEmptyValuesWhenUriIsNull() throws Exception { + public void shouldGetEmptyValuesWhenUriIsNull() { Uri uri = null; final Map values = CallbackHelper.getValuesFromUri(uri); assertThat(values, notNullValue()); diff --git a/auth0/src/test/java/com/auth0/android/provider/CustomTabsControllerTest.java b/auth0/src/test/java/com/auth0/android/provider/CustomTabsControllerTest.java index 820976112..7d8ca496a 100644 --- a/auth0/src/test/java/com/auth0/android/provider/CustomTabsControllerTest.java +++ b/auth0/src/test/java/com/auth0/android/provider/CustomTabsControllerTest.java @@ -85,7 +85,7 @@ public class CustomTabsControllerTest { @Before - public void setUp() throws Exception { + public void setUp() { MockitoAnnotations.initMocks(this); Activity activity = Robolectric.setupActivity(Activity.class); context = spy(activity); @@ -94,13 +94,13 @@ public void setUp() throws Exception { } @Test - public void shouldNotHaveCustomizationOptionsSetByDefault() throws Exception { + public void shouldNotHaveCustomizationOptionsSetByDefault() { CustomTabsController controller = new CustomTabsController(context, DEFAULT_BROWSER_PACKAGE); assertThat(controller.getCustomizationOptions(), is(nullValue())); } @Test - public void shouldChangeCustomizationOptions() throws Exception { + public void shouldChangeCustomizationOptions() { CustomTabsOptions options = mock(CustomTabsOptions.class); CustomTabsController controller = new CustomTabsController(context, DEFAULT_BROWSER_PACKAGE); controller.setCustomizationOptions(options); @@ -108,56 +108,56 @@ public void shouldChangeCustomizationOptions() throws Exception { } @Test - public void shouldChooseNullBrowserIfNoBrowserAvailable() throws Exception { + public void shouldChooseNullBrowserIfNoBrowserAvailable() { preparePackageManagerForCustomTabs(null); String bestPackage = CustomTabsController.getBestBrowserPackage(context); assertThat(bestPackage, is(nullValue())); } @Test - public void shouldChooseDefaultBrowserIfIsCustomTabsCapable() throws Exception { + public void shouldChooseDefaultBrowserIfIsCustomTabsCapable() { preparePackageManagerForCustomTabs(DEFAULT_BROWSER_PACKAGE, DEFAULT_BROWSER_PACKAGE); String bestPackage = CustomTabsController.getBestBrowserPackage(context); assertThat(bestPackage, is(DEFAULT_BROWSER_PACKAGE)); } @Test - public void shouldReturnNullIfNoBrowserIsCustomTabsCapable() throws Exception { + public void shouldReturnNullIfNoBrowserIsCustomTabsCapable() { preparePackageManagerForCustomTabs(DEFAULT_BROWSER_PACKAGE); String bestPackage = CustomTabsController.getBestBrowserPackage(context); assertThat(bestPackage, is(nullValue())); } @Test - public void shouldChooseChromeStableOverOtherCustomTabsCapableBrowsers() throws Exception { + public void shouldChooseChromeStableOverOtherCustomTabsCapableBrowsers() { preparePackageManagerForCustomTabs(DEFAULT_BROWSER_PACKAGE, CHROME_STABLE_PACKAGE, CHROME_SYSTEM_PACKAGE, CHROME_BETA_PACKAGE, CHROME_DEV_PACKAGE, CUSTOM_TABS_BROWSER_1, CUSTOM_TABS_BROWSER_2); String bestPackage = CustomTabsController.getBestBrowserPackage(context); assertThat(bestPackage, is(CHROME_STABLE_PACKAGE)); } @Test - public void shouldChooseChromeSystemOverOtherCustomTabsCapableBrowsers() throws Exception { + public void shouldChooseChromeSystemOverOtherCustomTabsCapableBrowsers() { preparePackageManagerForCustomTabs(DEFAULT_BROWSER_PACKAGE, CHROME_SYSTEM_PACKAGE, CHROME_BETA_PACKAGE, CHROME_DEV_PACKAGE, CUSTOM_TABS_BROWSER_1, CUSTOM_TABS_BROWSER_2); String bestPackage = CustomTabsController.getBestBrowserPackage(context); assertThat(bestPackage, is(CHROME_SYSTEM_PACKAGE)); } @Test - public void shouldChooseChromeBetaOverOtherCustomTabsCapableBrowsers() throws Exception { + public void shouldChooseChromeBetaOverOtherCustomTabsCapableBrowsers() { preparePackageManagerForCustomTabs(DEFAULT_BROWSER_PACKAGE, CHROME_BETA_PACKAGE, CHROME_DEV_PACKAGE, CUSTOM_TABS_BROWSER_1, CUSTOM_TABS_BROWSER_2); String bestPackage = CustomTabsController.getBestBrowserPackage(context); assertThat(bestPackage, is(CHROME_BETA_PACKAGE)); } @Test - public void shouldChooseChromeDevOverOtherCustomTabsCapableBrowsers() throws Exception { + public void shouldChooseChromeDevOverOtherCustomTabsCapableBrowsers() { preparePackageManagerForCustomTabs(DEFAULT_BROWSER_PACKAGE, CHROME_DEV_PACKAGE, CUSTOM_TABS_BROWSER_1, CUSTOM_TABS_BROWSER_2); String bestPackage = CustomTabsController.getBestBrowserPackage(context); assertThat(bestPackage, is(CHROME_DEV_PACKAGE)); } @Test - public void shouldChooseCustomTabsCapableBrowserIfAvailable() throws Exception { + public void shouldChooseCustomTabsCapableBrowserIfAvailable() { preparePackageManagerForCustomTabs(DEFAULT_BROWSER_PACKAGE, CUSTOM_TABS_BROWSER_1, CUSTOM_TABS_BROWSER_2); String bestPackage = CustomTabsController.getBestBrowserPackage(context); assertThat(bestPackage, is(CUSTOM_TABS_BROWSER_1)); @@ -203,7 +203,7 @@ public void shouldBindAndLaunchUri() throws Exception { } @Test - public void shouldLaunchUriUsingFallbackWhenNoCustomTabsCompatibleBrowserIsAvailable() throws Exception { + public void shouldLaunchUriUsingFallbackWhenNoCustomTabsCompatibleBrowserIsAvailable() { CustomTabsController controller = new CustomTabsController(context, null); controller.launchUri(uri); @@ -242,7 +242,7 @@ public void shouldBindAndLaunchUriWithCustomization() throws Exception { } @Test - public void shouldFailToBindButLaunchUri() throws Exception { + public void shouldFailToBindButLaunchUri() { bindService(false); controller.launchUri(uri); @@ -255,7 +255,7 @@ public void shouldFailToBindButLaunchUri() throws Exception { } @Test - public void shouldNotLaunchUriIfContextNoLongerValid() throws Exception { + public void shouldNotLaunchUriIfContextNoLongerValid() { bindService(true); controller.clearContext(); controller.launchUri(uri); @@ -263,7 +263,7 @@ public void shouldNotLaunchUriIfContextNoLongerValid() throws Exception { } @Test - public void shouldLaunchUriWithFallbackIfCustomTabIntentFails() throws Exception { + public void shouldLaunchUriWithFallbackIfCustomTabIntentFails() { doThrow(ActivityNotFoundException.class) .doNothing() .when(context).startActivity(any(Intent.class)); diff --git a/auth0/src/test/java/com/auth0/android/provider/CustomTabsOptionsTest.java b/auth0/src/test/java/com/auth0/android/provider/CustomTabsOptionsTest.java index db232ea4c..d536ffe2a 100644 --- a/auth0/src/test/java/com/auth0/android/provider/CustomTabsOptionsTest.java +++ b/auth0/src/test/java/com/auth0/android/provider/CustomTabsOptionsTest.java @@ -24,18 +24,18 @@ public class CustomTabsOptionsTest { private Activity context; @Before - public void setUp() throws Exception { + public void setUp() { context = Robolectric.setupActivity(Activity.class); } @Test - public void shouldCreateNewBuilder() throws Exception { + public void shouldCreateNewBuilder() { CustomTabsOptions.Builder builder = CustomTabsOptions.newBuilder(); assertThat(builder, is(notNullValue())); } @Test - public void shouldHaveDefaultValues() throws Exception { + public void shouldHaveDefaultValues() { CustomTabsOptions options = CustomTabsOptions.newBuilder().build(); assertThat(options, is(notNullValue())); @@ -63,7 +63,7 @@ public void shouldHaveDefaultValues() throws Exception { } @Test - public void shouldSetShowTitle() throws Exception { + public void shouldSetShowTitle() { CustomTabsOptions options = CustomTabsOptions.newBuilder() .showTitle(true) .build(); @@ -89,7 +89,7 @@ public void shouldSetShowTitle() throws Exception { } @Test - public void shouldSetToolbarColor() throws Exception { + public void shouldSetToolbarColor() { CustomTabsOptions options = CustomTabsOptions.newBuilder() .withToolbarColor(android.R.color.black) .build(); diff --git a/auth0/src/test/java/com/auth0/android/provider/FlagCheckerTest.java b/auth0/src/test/java/com/auth0/android/provider/FlagCheckerTest.java index 1ca3fc107..479e509bd 100644 --- a/auth0/src/test/java/com/auth0/android/provider/FlagCheckerTest.java +++ b/auth0/src/test/java/com/auth0/android/provider/FlagCheckerTest.java @@ -11,14 +11,14 @@ public class FlagCheckerTest { private static final int FLAG_B = 1 << 2; @Test - public void shouldHaveFlags() throws Exception { + public void shouldHaveFlags() { int value = FLAG_A | FLAG_B; assertTrue(FlagChecker.hasFlag(value, FLAG_A)); assertTrue(FlagChecker.hasFlag(value, FLAG_B)); } @Test - public void shouldNotHaveFlags() throws Exception { + public void shouldNotHaveFlags() { int value = 0; assertFalse(FlagChecker.hasFlag(value, FLAG_A)); assertFalse(FlagChecker.hasFlag(value, FLAG_B)); diff --git a/auth0/src/test/java/com/auth0/android/provider/LogoutManagerTest.java b/auth0/src/test/java/com/auth0/android/provider/LogoutManagerTest.java index 21e736733..dab93b790 100644 --- a/auth0/src/test/java/com/auth0/android/provider/LogoutManagerTest.java +++ b/auth0/src/test/java/com/auth0/android/provider/LogoutManagerTest.java @@ -37,18 +37,18 @@ public class LogoutManagerTest { VoidCallback callback; @Before - public void setUp() throws Exception { + public void setUp() { MockitoAnnotations.initMocks(this); } @Test - public void shouldNotHaveCustomTabsOptionsByDefault() throws Exception { + public void shouldNotHaveCustomTabsOptionsByDefault() { LogoutManager manager = new LogoutManager(account, callback, "https://auth0.com/android/my.app.name/callback"); assertThat(manager.customTabsOptions(), is(nullValue())); } @Test - public void shouldSetCustomTabsOptions() throws Exception { + public void shouldSetCustomTabsOptions() { CustomTabsOptions options = mock(CustomTabsOptions.class); LogoutManager manager = new LogoutManager(account, callback, "https://auth0.com/android/my.app.name/callback"); manager.setCustomTabsOptions(options); @@ -56,7 +56,7 @@ public void shouldSetCustomTabsOptions() throws Exception { } @Test - public void shouldCallOnFailureWhenResumedWithCanceledResult() throws Exception { + public void shouldCallOnFailureWhenResumedWithCanceledResult() { LogoutManager manager = new LogoutManager(account, callback, "https://auth0.com/android/my.app.name/callback"); AuthorizeResult result = mock(AuthorizeResult.class); when(result.isCanceled()).thenReturn(true); @@ -68,7 +68,7 @@ public void shouldCallOnFailureWhenResumedWithCanceledResult() throws Exception } @Test - public void shouldCallOnSuccessWhenResumedWithValidResult() throws Exception { + public void shouldCallOnSuccessWhenResumedWithValidResult() { LogoutManager manager = new LogoutManager(account, callback, "https://auth0.com/android/my.app.name/callback"); AuthorizeResult result = mock(AuthorizeResult.class); when(result.isCanceled()).thenReturn(false); diff --git a/auth0/src/test/java/com/auth0/android/provider/OAuthManagerTest.java b/auth0/src/test/java/com/auth0/android/provider/OAuthManagerTest.java index b315c39d4..b0cd60451 100644 --- a/auth0/src/test/java/com/auth0/android/provider/OAuthManagerTest.java +++ b/auth0/src/test/java/com/auth0/android/provider/OAuthManagerTest.java @@ -38,44 +38,44 @@ public class OAuthManagerTest { AuthCallback callback; @Before - public void setUp() throws Exception { + public void setUp() { MockitoAnnotations.initMocks(this); } @Test - public void shouldUseBrowserByDefault() throws Exception { + public void shouldUseBrowserByDefault() { OAuthManager manager = new OAuthManager(account, callback, new HashMap()); assertTrue(manager.useBrowser()); } @Test - public void shouldNotUseBrowser() throws Exception { + public void shouldNotUseBrowser() { OAuthManager manager = new OAuthManager(account, callback, new HashMap()); manager.useBrowser(false); assertFalse(manager.useBrowser()); } @Test - public void shouldNotUseFullScreenByDefault() throws Exception { + public void shouldNotUseFullScreenByDefault() { OAuthManager manager = new OAuthManager(account, callback, new HashMap()); assertFalse(manager.useFullScreen()); } @Test - public void shouldUseFullScreen() throws Exception { + public void shouldUseFullScreen() { OAuthManager manager = new OAuthManager(account, callback, new HashMap()); manager.useFullScreen(true); assertTrue(manager.useFullScreen()); } @Test - public void shouldNotHaveCustomTabsOptionsByDefault() throws Exception { + public void shouldNotHaveCustomTabsOptionsByDefault() { OAuthManager manager = new OAuthManager(account, callback, new HashMap()); assertThat(manager.customTabsOptions(), is(nullValue())); } @Test - public void shouldSetCustomTabsOptions() throws Exception { + public void shouldSetCustomTabsOptions() { CustomTabsOptions options = mock(CustomTabsOptions.class); OAuthManager manager = new OAuthManager(account, callback, new HashMap()); manager.setCustomTabsOptions(options); @@ -83,7 +83,7 @@ public void shouldSetCustomTabsOptions() throws Exception { } @Test - public void shouldMergeCredentials() throws Exception { + public void shouldMergeCredentials() { Date expiresAt = new Date(); Credentials urlCredentials = new Credentials("urlId", "urlAccess", "urlType", "urlRefresh", expiresAt, "urlScope"); Credentials codeCredentials = new Credentials("codeId", "codeAccess", "codeType", "codeRefresh", expiresAt, "codeScope"); @@ -100,8 +100,7 @@ public void shouldMergeCredentials() throws Exception { } @Test - @SuppressWarnings("ConstantConditions") - public void shouldPreferNonNullValuesWhenMergingCredentials() throws Exception { + public void shouldPreferNonNullValuesWhenMergingCredentials() { Credentials urlCredentials = new Credentials("urlId", "urlAccess", "urlType", "urlRefresh", new Date(), "urlScope"); Credentials codeCredentials = new Credentials(null, null, null, null, null, null); Credentials merged = OAuthManager.mergeCredentials(urlCredentials, codeCredentials); @@ -116,35 +115,35 @@ public void shouldPreferNonNullValuesWhenMergingCredentials() throws Exception { } @Test - public void shouldHaveValidState() throws Exception { + public void shouldHaveValidState() { OAuthManager.assertValidState("1234567890", "1234567890"); } @Test - public void shouldHaveInvalidState() throws Exception { + public void shouldHaveInvalidState() { exception.expect(AuthenticationException.class); OAuthManager.assertValidState("0987654321", "1234567890"); } @Test - public void shouldHaveInvalidStateWhenOneIsNull() throws Exception { + public void shouldHaveInvalidStateWhenOneIsNull() { exception.expect(AuthenticationException.class); OAuthManager.assertValidState("0987654321", null); } @Test - public void shouldHaveValidNonce() throws Exception { + public void shouldHaveValidNonce() { OAuthManager.assertValidNonce("1234567890", "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJub25jZSI6IjEyMzQ1Njc4OTAifQ.oUb6xFIEPJQrFbel_Js4SaOwpFfM_kxHxI7xDOHgghk"); } @Test - public void shouldHaveInvalidNonce() throws Exception { + public void shouldHaveInvalidNonce() { exception.expect(AuthenticationException.class); OAuthManager.assertValidNonce("0987654321", "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJub25jZSI6IjEyMzQ1Njc4OTAifQ.oUb6xFIEPJQrFbel_Js4SaOwpFfM_kxHxI7xDOHgghk"); } @Test - public void shouldHaveInvalidNonceOnDecodeException() throws Exception { + public void shouldHaveInvalidNonceOnDecodeException() { exception.expect(AuthenticationException.class); OAuthManager.assertValidNonce("0987654321", "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVC.eyJub25jZSI6IjEyMzQ1Njc4OTAifQ.oUb6xFIEPJQrFbel_Js4SaOwpFfM_kxHxI7xDOHgghk"); } diff --git a/auth0/src/test/java/com/auth0/android/provider/PKCETest.java b/auth0/src/test/java/com/auth0/android/provider/PKCETest.java index a6137848b..89350b0eb 100644 --- a/auth0/src/test/java/com/auth0/android/provider/PKCETest.java +++ b/auth0/src/test/java/com/auth0/android/provider/PKCETest.java @@ -75,19 +75,19 @@ public class PKCETest { private AuthCallback callback; @Before - public void setUp() throws Exception { + public void setUp() { MockitoAnnotations.initMocks(this); pkce = new PKCE(apiClient, new AlgorithmHelperMock(CODE_VERIFIER), REDIRECT_URI); } @Test - public void shouldGenerateChallengeFromRandomVerifier() throws Exception { + public void shouldGenerateChallengeFromRandomVerifier() { PKCE pkce = new PKCE(apiClient, REDIRECT_URI); assertThat(pkce.getCodeChallenge(), is(notNullValue())); } @Test - public void shouldGenerateValidRandomCodeChallenge() throws Exception { + public void shouldGenerateValidRandomCodeChallenge() { PKCE randomPKCE = new PKCE(apiClient, REDIRECT_URI); String challenge = randomPKCE.getCodeChallenge(); assertThat(challenge, is(notNullValue())); @@ -98,13 +98,13 @@ public void shouldGenerateValidRandomCodeChallenge() throws Exception { } @Test - public void shouldGenerateExpectedCodeChallenge() throws Exception { + public void shouldGenerateExpectedCodeChallenge() { String challenge = pkce.getCodeChallenge(); assertThat(challenge, is(equalTo(CODE_CHALLENGE))); } @Test - public void shouldGetToken() throws Exception { + public void shouldGetToken() { TokenRequest tokenRequest = mock(TokenRequest.class); when(apiClient.token(AUTHORIZATION_CODE, REDIRECT_URI)).thenReturn(tokenRequest); when(tokenRequest.setCodeVerifier(CODE_VERIFIER)).thenReturn(tokenRequest); @@ -119,7 +119,7 @@ public void shouldGetToken() throws Exception { } @Test - public void shouldFailToGetToken() throws Exception { + public void shouldFailToGetToken() { TokenRequest tokenRequest = mock(TokenRequest.class); when(apiClient.token(AUTHORIZATION_CODE, REDIRECT_URI)).thenReturn(tokenRequest); when(tokenRequest.setCodeVerifier(CODE_VERIFIER)).thenReturn(tokenRequest); @@ -133,21 +133,21 @@ public void shouldFailToGetToken() throws Exception { } @Test - public void shouldNotHavePKCEAvailableIfSHA256IsNotAvailable() throws Exception { + public void shouldNotHavePKCEAvailableIfSHA256IsNotAvailable() { AlgorithmHelper algorithmHelper = Mockito.mock(AlgorithmHelper.class); when(algorithmHelper.getSHA256(any(byte[].class))).thenThrow(NoSuchAlgorithmException.class); assertFalse(PKCE.isAvailable(algorithmHelper)); } @Test - public void shouldNotHavePKCEAvailableIfASCIIIsNotAvailable() throws Exception { + public void shouldNotHavePKCEAvailableIfASCIIIsNotAvailable() { AlgorithmHelper algorithmHelper = Mockito.mock(AlgorithmHelper.class); when(algorithmHelper.getASCIIBytes(anyString())).thenThrow(UnsupportedEncodingException.class); assertFalse(PKCE.isAvailable(algorithmHelper)); } @Test - public void shouldHavePKCEAvailable() throws Exception { + public void shouldHavePKCEAvailable() { AlgorithmHelper algorithmHelper = Mockito.mock(AlgorithmHelper.class); when(algorithmHelper.getSHA256(any(byte[].class))).thenReturn(new byte[]{1, 2, 1, 2, 1, 2, 1, 2, 1}); when(algorithmHelper.getASCIIBytes(anyString())).thenReturn(new byte[]{1, 2, 1, 2, 1, 2, 1, 2, 1}); diff --git a/auth0/src/test/java/com/auth0/android/provider/PermissionHandlerTest.java b/auth0/src/test/java/com/auth0/android/provider/PermissionHandlerTest.java index 64e2d3b79..7c75ab67f 100644 --- a/auth0/src/test/java/com/auth0/android/provider/PermissionHandlerTest.java +++ b/auth0/src/test/java/com/auth0/android/provider/PermissionHandlerTest.java @@ -36,40 +36,40 @@ public class PermissionHandlerTest { private PermissionHandler handler; @Before - public void setUp() throws Exception { + public void setUp() { handler = new PermissionHandler(); } @Test - public void shouldHavePermissionGranted() throws Exception { + public void shouldHavePermissionGranted() { final Activity activity = mock(Activity.class); when(activity.checkPermission(eq("permission"), anyInt(), anyInt())).thenReturn(PackageManager.PERMISSION_GRANTED); assertTrue(handler.isPermissionGranted(activity, "permission")); } @Test - public void shouldHavePermissionDeclined() throws Exception { + public void shouldHavePermissionDeclined() { final Activity activity = mock(Activity.class); when(activity.checkPermission(eq("permission"), anyInt(), anyInt())).thenReturn(PackageManager.PERMISSION_DENIED); assertFalse(handler.isPermissionGranted(activity, "permission")); } @Test - public void shouldHaveAllPermissionsGranted() throws Exception { + public void shouldHaveAllPermissionsGranted() { final Activity activity = mock(Activity.class); when(activity.checkPermission(anyString(), anyInt(), anyInt())).thenReturn(PackageManager.PERMISSION_GRANTED); assertTrue(handler.areAllPermissionsGranted(activity, new String[]{"permission1", "permission2"})); } @Test - public void shouldHaveAllPermissionsDeclined() throws Exception { + public void shouldHaveAllPermissionsDeclined() { final Activity activity = mock(Activity.class); when(activity.checkPermission(anyString(), anyInt(), anyInt())).thenReturn(PackageManager.PERMISSION_DENIED); assertFalse(handler.areAllPermissionsGranted(activity, new String[]{"permission1", "permission2"})); } @Test - public void shouldHaveAllPermissionsDeclinedIfOneIsDenied() throws Exception { + public void shouldHaveAllPermissionsDeclinedIfOneIsDenied() { final Activity activity = mock(Activity.class); when(activity.checkPermission(eq("permission1"), anyInt(), anyInt())).thenReturn(PackageManager.PERMISSION_GRANTED); when(activity.checkPermission(eq("permission2"), anyInt(), anyInt())).thenReturn(PackageManager.PERMISSION_DENIED); @@ -78,7 +78,7 @@ public void shouldHaveAllPermissionsDeclinedIfOneIsDenied() throws Exception { @TargetApi(Build.VERSION_CODES.M) @Test - public void requestPermissions() throws Exception { + public void requestPermissions() { final Activity activity = mock(Activity.class); when(activity.checkPermission(eq("permission1"), anyInt(), anyInt())).thenReturn(PackageManager.PERMISSION_GRANTED); when(activity.checkPermission(eq("permission2"), anyInt(), anyInt())).thenReturn(PackageManager.PERMISSION_DENIED); @@ -91,7 +91,7 @@ public void requestPermissions() throws Exception { @TargetApi(Build.VERSION_CODES.M) @Test - public void shouldExplainPermissions() throws Exception { + public void shouldExplainPermissions() { final Activity activity = mock(Activity.class); when(activity.shouldShowRequestPermissionRationale("permission1")).thenReturn(true); when(activity.shouldShowRequestPermissionRationale("permission2")).thenReturn(false); @@ -105,7 +105,7 @@ public void shouldExplainPermissions() throws Exception { } @Test - public void shouldSetLastRequestCode() throws Exception { + public void shouldSetLastRequestCode() { final Activity activity = mock(Activity.class); String[] permissions = new String[]{"permission1", "permission2"}; handler.requestPermissions(activity, permissions, 100); @@ -114,7 +114,7 @@ public void shouldSetLastRequestCode() throws Exception { } @Test - public void shouldReturnAllPermissionDeclinedWhenInvalidRequestCode() throws Exception { + public void shouldReturnAllPermissionDeclinedWhenInvalidRequestCode() { final Activity activity = mock(Activity.class); String[] permissions = new String[]{"permission1", "permission2"}; int[] grantResults = new int[]{PackageManager.PERMISSION_GRANTED, PackageManager.PERMISSION_GRANTED}; @@ -126,7 +126,7 @@ public void shouldReturnAllPermissionDeclinedWhenInvalidRequestCode() throws Exc } @Test - public void shouldHaveAllPermissionDeclinedByUser() throws Exception { + public void shouldHaveAllPermissionDeclinedByUser() { final Activity activity = mock(Activity.class); handler.requestPermissions(activity, new String[]{}, 100); final List result = handler.parseRequestResult(100, new String[]{}, new int[]{}); @@ -136,7 +136,7 @@ public void shouldHaveAllPermissionDeclinedByUser() throws Exception { } @Test - public void shouldHaveSomePermissionsDeclinedByUser() throws Exception { + public void shouldHaveSomePermissionsDeclinedByUser() { final Activity activity = mock(Activity.class); String[] permissions = new String[]{"permission1", "permission2"}; int[] grantResults = new int[]{PackageManager.PERMISSION_GRANTED, PackageManager.PERMISSION_DENIED}; @@ -148,7 +148,7 @@ public void shouldHaveSomePermissionsDeclinedByUser() throws Exception { } @Test - public void shouldHaveAllPermissionsGrantedByUser() throws Exception { + public void shouldHaveAllPermissionsGrantedByUser() { final Activity activity = mock(Activity.class); String[] permissions = new String[]{"permission1", "permission2"}; int[] grantResults = new int[]{PackageManager.PERMISSION_GRANTED, PackageManager.PERMISSION_GRANTED}; diff --git a/auth0/src/test/java/com/auth0/android/provider/RedirectActivityTest.java b/auth0/src/test/java/com/auth0/android/provider/RedirectActivityTest.java index c28bfb2aa..6e6a1e46c 100644 --- a/auth0/src/test/java/com/auth0/android/provider/RedirectActivityTest.java +++ b/auth0/src/test/java/com/auth0/android/provider/RedirectActivityTest.java @@ -12,7 +12,6 @@ import org.robolectric.RobolectricTestRunner; import org.robolectric.android.controller.ActivityController; import org.robolectric.annotation.Config; -import org.robolectric.shadows.ShadowActivity; import static android.support.test.espresso.intent.matcher.IntentMatchers.hasComponent; import static android.support.test.espresso.intent.matcher.IntentMatchers.hasData; @@ -35,7 +34,7 @@ public class RedirectActivityTest { private ActivityController activityController; @Before - public void setUp() throws Exception { + public void setUp() { MockitoAnnotations.initMocks(this); } @@ -44,9 +43,8 @@ private void createActivity(Intent launchIntent) { activity = activityController.get(); } - @SuppressWarnings("deprecation") @Test - public void shouldLaunchAuthenticationActivityWithDataOnSuccess() throws Exception { + public void shouldLaunchAuthenticationActivityWithDataOnSuccess() { Intent resultIntent = new Intent(); resultIntent.setData(uri); @@ -63,9 +61,8 @@ public void shouldLaunchAuthenticationActivityWithDataOnSuccess() throws Excepti activityController.destroy(); } - @SuppressWarnings("deprecation") @Test - public void shouldLaunchAuthenticationActivityWithoutDataOnCancel() throws Exception { + public void shouldLaunchAuthenticationActivityWithoutDataOnCancel() { Intent resultIntent = new Intent(); resultIntent.setData(null); diff --git a/auth0/src/test/java/com/auth0/android/provider/WebAuthProviderTest.java b/auth0/src/test/java/com/auth0/android/provider/WebAuthProviderTest.java index 833873123..adfc4055b 100644 --- a/auth0/src/test/java/com/auth0/android/provider/WebAuthProviderTest.java +++ b/auth0/src/test/java/com/auth0/android/provider/WebAuthProviderTest.java @@ -106,7 +106,7 @@ public class WebAuthProviderTest { @Before - public void setUp() throws Exception { + public void setUp() { MockitoAnnotations.initMocks(this); activity = spy(Robolectric.buildActivity(Activity.class).get()); account = new Auth0("clientId", "domain"); @@ -127,7 +127,7 @@ public void setUp() throws Exception { @SuppressWarnings("deprecation") @Test - public void shouldLoginWithAccount() throws Exception { + public void shouldLoginWithAccount() { WebAuthProvider.login(account) .start(activity, callback, REQUEST_CODE); @@ -136,7 +136,7 @@ public void shouldLoginWithAccount() throws Exception { @SuppressWarnings("deprecation") @Test - public void shouldInitWithAccount() throws Exception { + public void shouldInitWithAccount() { WebAuthProvider.init(account) .start(activity, callback, REQUEST_CODE); @@ -144,7 +144,7 @@ public void shouldInitWithAccount() throws Exception { } @Test - public void shouldInitWithContext() throws Exception { + public void shouldInitWithContext() { Context context = Mockito.mock(Context.class); Resources resources = Mockito.mock(Resources.class); when(context.getResources()).thenReturn(resources); @@ -162,14 +162,14 @@ public void shouldInitWithContext() throws Exception { @SuppressWarnings("deprecation") @Test - public void shouldNotResumeLoginWithRequestCodeWhenNotInit() throws Exception { + public void shouldNotResumeLoginWithRequestCodeWhenNotInit() { Intent intentMock = Mockito.mock(Intent.class); assertFalse(WebAuthProvider.resume(0, 0, intentMock)); } @Test - public void shouldNotResumeLoginWithIntentWhenNotInit() throws Exception { + public void shouldNotResumeLoginWithIntentWhenNotInit() { Intent intentMock = Mockito.mock(Intent.class); assertFalse(WebAuthProvider.resume(intentMock)); @@ -178,7 +178,7 @@ public void shouldNotResumeLoginWithIntentWhenNotInit() throws Exception { //scheme @Test - public void shouldHaveDefaultSchemeOnLogin() throws Exception { + public void shouldHaveDefaultSchemeOnLogin() { WebAuthProvider.init(account) .start(activity, callback); verify(activity).startActivity(intentCaptor.capture()); @@ -191,7 +191,7 @@ public void shouldHaveDefaultSchemeOnLogin() throws Exception { } @Test - public void shouldSetSchemeOnLogin() throws Exception { + public void shouldSetSchemeOnLogin() { WebAuthProvider.init(account) .withScheme("myapp") .start(activity, callback); @@ -208,7 +208,7 @@ public void shouldSetSchemeOnLogin() throws Exception { //connection @Test - public void shouldNotHaveDefaultConnectionOnLogin() throws Exception { + public void shouldNotHaveDefaultConnectionOnLogin() { WebAuthProvider.init(account) .start(activity, callback); @@ -220,7 +220,7 @@ public void shouldNotHaveDefaultConnectionOnLogin() throws Exception { } @Test - public void shouldSetConnectionFromParametersOnLogin() throws Exception { + public void shouldSetConnectionFromParametersOnLogin() { Map parameters = Collections.singletonMap("connection", (Object) "my-connection"); WebAuthProvider.init(account) .withConnection("some-connection") @@ -235,7 +235,7 @@ public void shouldSetConnectionFromParametersOnLogin() throws Exception { } @Test - public void shouldSetConnectionFromSetterOnLogin() throws Exception { + public void shouldSetConnectionFromSetterOnLogin() { Map parameters = Collections.singletonMap("connection", (Object) "my-connection"); WebAuthProvider.init(account) .withParameters(parameters) @@ -250,7 +250,7 @@ public void shouldSetConnectionFromSetterOnLogin() throws Exception { } @Test - public void shouldNotOverrideConnectionValueWithDefaultConnectionOnLogin() throws Exception { + public void shouldNotOverrideConnectionValueWithDefaultConnectionOnLogin() { Map parameters = Collections.singletonMap("connection", (Object) "my-connection"); WebAuthProvider.init(account) .withParameters(parameters) @@ -264,7 +264,7 @@ public void shouldNotOverrideConnectionValueWithDefaultConnectionOnLogin() throw } @Test - public void shouldSetConnectionOnLogin() throws Exception { + public void shouldSetConnectionOnLogin() { WebAuthProvider.init(account) .withConnection("some-connection") .start(activity, callback); @@ -279,7 +279,7 @@ public void shouldSetConnectionOnLogin() throws Exception { //audience @Test - public void shouldNotHaveDefaultAudienceOnLogin() throws Exception { + public void shouldNotHaveDefaultAudienceOnLogin() { WebAuthProvider.init(account) .start(activity, callback); @@ -291,7 +291,7 @@ public void shouldNotHaveDefaultAudienceOnLogin() throws Exception { } @Test - public void shouldSetAudienceFromParametersOnLogin() throws Exception { + public void shouldSetAudienceFromParametersOnLogin() { Map parameters = Collections.singletonMap("audience", (Object) "https://mydomain.auth0.com/myapi"); WebAuthProvider.init(account) .withAudience("https://google.com/apis") @@ -306,7 +306,7 @@ public void shouldSetAudienceFromParametersOnLogin() throws Exception { } @Test - public void shouldSetAudienceFromSetterOnLogin() throws Exception { + public void shouldSetAudienceFromSetterOnLogin() { Map parameters = Collections.singletonMap("audience", (Object) "https://mydomain.auth0.com/myapi"); WebAuthProvider.init(account) .withParameters(parameters) @@ -321,7 +321,7 @@ public void shouldSetAudienceFromSetterOnLogin() throws Exception { } @Test - public void shouldNotOverrideAudienceValueWithDefaultAudienceOnLogin() throws Exception { + public void shouldNotOverrideAudienceValueWithDefaultAudienceOnLogin() { Map parameters = Collections.singletonMap("audience", (Object) "https://mydomain.auth0.com/myapi"); WebAuthProvider.init(account) .withParameters(parameters) @@ -335,7 +335,7 @@ public void shouldNotOverrideAudienceValueWithDefaultAudienceOnLogin() throws Ex } @Test - public void shouldSetAudienceOnLogin() throws Exception { + public void shouldSetAudienceOnLogin() { WebAuthProvider.init(account) .withAudience("https://google.com/apis") .start(activity, callback); @@ -351,7 +351,7 @@ public void shouldSetAudienceOnLogin() throws Exception { //scope @Test - public void shouldHaveDefaultScopeOnLogin() throws Exception { + public void shouldHaveDefaultScopeOnLogin() { WebAuthProvider.init(account) .start(activity, callback); @@ -363,7 +363,7 @@ public void shouldHaveDefaultScopeOnLogin() throws Exception { } @Test - public void shouldSetScopeFromParametersOnLogin() throws Exception { + public void shouldSetScopeFromParametersOnLogin() { Map parameters = Collections.singletonMap("scope", (Object) "openid email contacts"); WebAuthProvider.init(account) .withScope("profile super_scope") @@ -378,7 +378,7 @@ public void shouldSetScopeFromParametersOnLogin() throws Exception { } @Test - public void shouldSetScopeFromSetterOnLogin() throws Exception { + public void shouldSetScopeFromSetterOnLogin() { Map parameters = Collections.singletonMap("scope", (Object) "openid email contacts"); WebAuthProvider.init(account) .withParameters(parameters) @@ -393,7 +393,7 @@ public void shouldSetScopeFromSetterOnLogin() throws Exception { } @Test - public void shouldNotOverrideScopeValueWithDefaultScopeOnLogin() throws Exception { + public void shouldNotOverrideScopeValueWithDefaultScopeOnLogin() { Map parameters = Collections.singletonMap("scope", (Object) "openid email contacts"); WebAuthProvider.init(account) .withParameters(parameters) @@ -407,7 +407,7 @@ public void shouldNotOverrideScopeValueWithDefaultScopeOnLogin() throws Exceptio } @Test - public void shouldSetScopeOnLogin() throws Exception { + public void shouldSetScopeOnLogin() { WebAuthProvider.init(account) .withScope("profile super_scope") .start(activity, callback); @@ -423,7 +423,7 @@ public void shouldSetScopeOnLogin() throws Exception { //connection scope @Test - public void shouldNotHaveDefaultConnectionScopeOnLogin() throws Exception { + public void shouldNotHaveDefaultConnectionScopeOnLogin() { WebAuthProvider.init(account) .start(activity, callback); @@ -435,7 +435,7 @@ public void shouldNotHaveDefaultConnectionScopeOnLogin() throws Exception { } @Test - public void shouldSetConnectionScopeFromParametersOnLogin() throws Exception { + public void shouldSetConnectionScopeFromParametersOnLogin() { Map parameters = Collections.singletonMap("connection_scope", (Object) "openid,email,contacts"); WebAuthProvider.init(account) .withConnectionScope("profile", "super_scope") @@ -450,7 +450,7 @@ public void shouldSetConnectionScopeFromParametersOnLogin() throws Exception { } @Test - public void shouldSetConnectionScopeFromSetterOnLogin() throws Exception { + public void shouldSetConnectionScopeFromSetterOnLogin() { Map parameters = Collections.singletonMap("connection_scope", (Object) "openid,email,contacts"); WebAuthProvider.init(account) .withParameters(parameters) @@ -465,7 +465,7 @@ public void shouldSetConnectionScopeFromSetterOnLogin() throws Exception { } @Test - public void shouldNotOverrideConnectionScopeValueWithDefaultConnectionScopeOnLogin() throws Exception { + public void shouldNotOverrideConnectionScopeValueWithDefaultConnectionScopeOnLogin() { Map parameters = Collections.singletonMap("connection_scope", (Object) "openid,email,contacts"); WebAuthProvider.init(account) .withParameters(parameters) @@ -479,7 +479,7 @@ public void shouldNotOverrideConnectionScopeValueWithDefaultConnectionScopeOnLog } @Test - public void shouldSetConnectionScopeOnLogin() throws Exception { + public void shouldSetConnectionScopeOnLogin() { WebAuthProvider.init(account) .withConnectionScope("the", "scope", "of", "my", "connection") .start(activity, callback); @@ -495,7 +495,7 @@ public void shouldSetConnectionScopeOnLogin() throws Exception { //state @Test - public void shouldHaveDefaultStateOnLogin() throws Exception { + public void shouldHaveDefaultStateOnLogin() { WebAuthProvider.init(account) .start(activity, callback); @@ -507,7 +507,7 @@ public void shouldHaveDefaultStateOnLogin() throws Exception { } @Test - public void shouldSetNonNullStateOnLogin() throws Exception { + public void shouldSetNonNullStateOnLogin() { WebAuthProvider.init(account) .withState(null) .start(activity, callback); @@ -520,7 +520,7 @@ public void shouldSetNonNullStateOnLogin() throws Exception { } @Test - public void shouldSetStateFromParametersOnLogin() throws Exception { + public void shouldSetStateFromParametersOnLogin() { Map parameters = Collections.singletonMap("state", (Object) "1234567890"); WebAuthProvider.init(account) .withState("abcdefg") @@ -535,7 +535,7 @@ public void shouldSetStateFromParametersOnLogin() throws Exception { } @Test - public void shouldSetStateFromSetterOnLogin() throws Exception { + public void shouldSetStateFromSetterOnLogin() { Map parameters = Collections.singletonMap("state", (Object) "1234567890"); WebAuthProvider.init(account) .withParameters(parameters) @@ -550,7 +550,7 @@ public void shouldSetStateFromSetterOnLogin() throws Exception { } @Test - public void shouldNotOverrideStateValueWithDefaultStateOnLogin() throws Exception { + public void shouldNotOverrideStateValueWithDefaultStateOnLogin() { Map parameters = Collections.singletonMap("state", (Object) "1234567890"); WebAuthProvider.init(account) .withParameters(parameters) @@ -564,7 +564,7 @@ public void shouldNotOverrideStateValueWithDefaultStateOnLogin() throws Exceptio } @Test - public void shouldSetStateOnLogin() throws Exception { + public void shouldSetStateOnLogin() { WebAuthProvider.init(account) .withState("abcdefg") .start(activity, callback); @@ -579,7 +579,7 @@ public void shouldSetStateOnLogin() throws Exception { //nonce @Test - public void shouldNotSetNonceByDefaultIfResponseTypeIsCodeOnLogin() throws Exception { + public void shouldNotSetNonceByDefaultIfResponseTypeIsCodeOnLogin() { WebAuthProvider.init(account) .withResponseType(ResponseType.CODE) .start(activity, callback); @@ -592,7 +592,7 @@ public void shouldNotSetNonceByDefaultIfResponseTypeIsCodeOnLogin() throws Excep } @Test - public void shouldNotSetNonceByDefaultIfResponseTypeIsTokenOnLogin() throws Exception { + public void shouldNotSetNonceByDefaultIfResponseTypeIsTokenOnLogin() { WebAuthProvider.init(account) .withResponseType(ResponseType.TOKEN) .start(activity, callback); @@ -605,7 +605,7 @@ public void shouldNotSetNonceByDefaultIfResponseTypeIsTokenOnLogin() throws Exce } @Test - public void shouldHaveDefaultNonceOnLogin() throws Exception { + public void shouldHaveDefaultNonceOnLogin() { WebAuthProvider.init(account) .withResponseType(ResponseType.ID_TOKEN) .start(activity, callback); @@ -618,7 +618,7 @@ public void shouldHaveDefaultNonceOnLogin() throws Exception { } @Test - public void shouldSetNonNullNonceOnLogin() throws Exception { + public void shouldSetNonNullNonceOnLogin() { WebAuthProvider.init(account) .withNonce(null) .withResponseType(ResponseType.ID_TOKEN) @@ -632,7 +632,7 @@ public void shouldSetNonNullNonceOnLogin() throws Exception { } @Test - public void shouldSetUserNonceIfResponseTypeIsTokenOnLogin() throws Exception { + public void shouldSetUserNonceIfResponseTypeIsTokenOnLogin() { WebAuthProvider.init(account) .withResponseType(ResponseType.TOKEN) .withNonce("1234567890") @@ -646,7 +646,7 @@ public void shouldSetUserNonceIfResponseTypeIsTokenOnLogin() throws Exception { } @Test - public void shouldSetUserNonceIfResponseTypeIsCodeOnLogin() throws Exception { + public void shouldSetUserNonceIfResponseTypeIsCodeOnLogin() { WebAuthProvider.init(account) .withResponseType(ResponseType.CODE) .withNonce("1234567890") @@ -660,7 +660,7 @@ public void shouldSetUserNonceIfResponseTypeIsCodeOnLogin() throws Exception { } @Test - public void shouldSetNonceFromParametersOnLogin() throws Exception { + public void shouldSetNonceFromParametersOnLogin() { Map parameters = Collections.singletonMap("nonce", (Object) "1234567890"); WebAuthProvider.init(account) .withResponseType(ResponseType.ID_TOKEN) @@ -676,7 +676,7 @@ public void shouldSetNonceFromParametersOnLogin() throws Exception { } @Test - public void shouldSetNonceFromSetterOnLogin() throws Exception { + public void shouldSetNonceFromSetterOnLogin() { Map parameters = Collections.singletonMap("nonce", (Object) "1234567890"); WebAuthProvider.init(account) .withResponseType(ResponseType.ID_TOKEN) @@ -692,7 +692,7 @@ public void shouldSetNonceFromSetterOnLogin() throws Exception { } @Test - public void shouldNotOverrideNonceValueWithDefaultNonceOnLogin() throws Exception { + public void shouldNotOverrideNonceValueWithDefaultNonceOnLogin() { Map parameters = Collections.singletonMap("nonce", (Object) "1234567890"); WebAuthProvider.init(account) .withResponseType(ResponseType.ID_TOKEN) @@ -707,7 +707,7 @@ public void shouldNotOverrideNonceValueWithDefaultNonceOnLogin() throws Exceptio } @Test - public void shouldSetNonceOnLogin() throws Exception { + public void shouldSetNonceOnLogin() { WebAuthProvider.init(account) .withResponseType(ResponseType.ID_TOKEN) .withNonce("abcdefg") @@ -721,7 +721,7 @@ public void shouldSetNonceOnLogin() throws Exception { } @Test - public void shouldGenerateRandomStringIfDefaultValueMissingOnLogin() throws Exception { + public void shouldGenerateRandomStringIfDefaultValueMissingOnLogin() { WebAuthProvider.init(account) .start(activity, callback); String random1 = OAuthManager.getRandomString(null); @@ -733,7 +733,7 @@ public void shouldGenerateRandomStringIfDefaultValueMissingOnLogin() throws Exce } @Test - public void shouldNotGenerateRandomStringIfDefaultValuePresentOnLogin() throws Exception { + public void shouldNotGenerateRandomStringIfDefaultValuePresentOnLogin() { WebAuthProvider.init(account) .start(activity, callback); String random1 = OAuthManager.getRandomString("some"); @@ -747,7 +747,7 @@ public void shouldNotGenerateRandomStringIfDefaultValuePresentOnLogin() throws E // auth0 related @Test - public void shouldHaveClientIdOnLogin() throws Exception { + public void shouldHaveClientIdOnLogin() { WebAuthProvider.init(account) .start(activity, callback); @@ -759,7 +759,7 @@ public void shouldHaveClientIdOnLogin() throws Exception { } @Test - public void shouldHaveTelemetryInfoOnLogin() throws Exception { + public void shouldHaveTelemetryInfoOnLogin() { WebAuthProvider.init(account) .start(activity, callback); @@ -771,7 +771,7 @@ public void shouldHaveTelemetryInfoOnLogin() throws Exception { } @Test - public void shouldHaveRedirectUriOnLogin() throws Exception { + public void shouldHaveRedirectUriOnLogin() { WebAuthProvider.init(account) .start(activity, callback); @@ -785,7 +785,7 @@ public void shouldHaveRedirectUriOnLogin() throws Exception { //response type @Test - public void shouldHaveDefaultResponseTypeOnLogin() throws Exception { + public void shouldHaveDefaultResponseTypeOnLogin() { WebAuthProvider.init(account) .start(activity, callback); @@ -797,7 +797,7 @@ public void shouldHaveDefaultResponseTypeOnLogin() throws Exception { } @Test - public void shouldSetResponseTypeTokenOnLogin() throws Exception { + public void shouldSetResponseTypeTokenOnLogin() { WebAuthProvider.init(account) .withResponseType(ResponseType.TOKEN) .start(activity, callback); @@ -810,7 +810,7 @@ public void shouldSetResponseTypeTokenOnLogin() throws Exception { } @Test - public void shouldSetResponseTypeIdTokenOnLogin() throws Exception { + public void shouldSetResponseTypeIdTokenOnLogin() { WebAuthProvider.init(account) .withResponseType(ResponseType.ID_TOKEN) .start(activity, callback); @@ -823,7 +823,7 @@ public void shouldSetResponseTypeIdTokenOnLogin() throws Exception { } @Test - public void shouldSetResponseTypeCodeOnLogin() throws Exception { + public void shouldSetResponseTypeCodeOnLogin() { WebAuthProvider.init(account) .withResponseType(ResponseType.CODE) .start(activity, callback); @@ -836,7 +836,7 @@ public void shouldSetResponseTypeCodeOnLogin() throws Exception { } @Test - public void shouldSetResponseTypeCodeTokenOnLogin() throws Exception { + public void shouldSetResponseTypeCodeTokenOnLogin() { WebAuthProvider.init(account) .withResponseType(ResponseType.CODE | ResponseType.TOKEN) .start(activity, callback); @@ -849,7 +849,7 @@ public void shouldSetResponseTypeCodeTokenOnLogin() throws Exception { } @Test - public void shouldSetResponseTypeCodeIdTokenOnLogin() throws Exception { + public void shouldSetResponseTypeCodeIdTokenOnLogin() { WebAuthProvider.init(account) .withResponseType(ResponseType.CODE | ResponseType.ID_TOKEN) .start(activity, callback); @@ -862,7 +862,7 @@ public void shouldSetResponseTypeCodeIdTokenOnLogin() throws Exception { } @Test - public void shouldSetResponseTypeIdTokenTokenOnLogin() throws Exception { + public void shouldSetResponseTypeIdTokenTokenOnLogin() { WebAuthProvider.init(account) .withResponseType(ResponseType.ID_TOKEN | ResponseType.TOKEN) .start(activity, callback); @@ -875,7 +875,7 @@ public void shouldSetResponseTypeIdTokenTokenOnLogin() throws Exception { } @Test - public void shouldSetResponseTypeCodeIdTokenTokenOnLogin() throws Exception { + public void shouldSetResponseTypeCodeIdTokenTokenOnLogin() { WebAuthProvider.init(account) .withResponseType(ResponseType.CODE | ResponseType.ID_TOKEN | ResponseType.TOKEN) .start(activity, callback); @@ -888,7 +888,7 @@ public void shouldSetResponseTypeCodeIdTokenTokenOnLogin() throws Exception { } @Test - public void shouldSetNonNullAuthenticationParametersOnLogin() throws Exception { + public void shouldSetNonNullAuthenticationParametersOnLogin() { Map parameters = new HashMap<>(); parameters.put("a", "valid"); parameters.put("b", null); @@ -905,7 +905,7 @@ public void shouldSetNonNullAuthenticationParametersOnLogin() throws Exception { } @Test - public void shouldBuildAuthorizeURIWithoutNullsOnLogin() throws Exception { + public void shouldBuildAuthorizeURIWithoutNullsOnLogin() { WebAuthProvider.init(account) .start(activity, callback); @@ -921,7 +921,7 @@ public void shouldBuildAuthorizeURIWithoutNullsOnLogin() throws Exception { } @Test - public void shouldBuildAuthorizeURIWithCorrectSchemeHostAndPathOnLogin() throws Exception { + public void shouldBuildAuthorizeURIWithCorrectSchemeHostAndPathOnLogin() { WebAuthProvider.init(account) .withResponseType(ResponseType.ID_TOKEN) .withState("a-state") @@ -939,7 +939,7 @@ public void shouldBuildAuthorizeURIWithCorrectSchemeHostAndPathOnLogin() throws } @Test - public void shouldBuildAuthorizeURIWithResponseTypeIdTokenOnLogin() throws Exception { + public void shouldBuildAuthorizeURIWithResponseTypeIdTokenOnLogin() { WebAuthProvider.init(account) .withResponseType(ResponseType.ID_TOKEN) .withState("a-state") @@ -957,7 +957,7 @@ public void shouldBuildAuthorizeURIWithResponseTypeIdTokenOnLogin() throws Excep } @Test - public void shouldBuildAuthorizeURIWithResponseTypeTokenOnLogin() throws Exception { + public void shouldBuildAuthorizeURIWithResponseTypeTokenOnLogin() { WebAuthProvider.init(account) .withResponseType(ResponseType.TOKEN) .withState("a-state") @@ -974,7 +974,7 @@ public void shouldBuildAuthorizeURIWithResponseTypeTokenOnLogin() throws Excepti } @Test - public void shouldBuildAuthorizeURIWithResponseTypeCodeOnLogin() throws Exception { + public void shouldBuildAuthorizeURIWithResponseTypeCodeOnLogin() { WebAuthProvider.init(account) .withResponseType(ResponseType.CODE) .withState("a-state") @@ -992,7 +992,7 @@ public void shouldBuildAuthorizeURIWithResponseTypeCodeOnLogin() throws Exceptio @SuppressWarnings("deprecation") @Test - public void shouldStartLoginWithBrowserCustomTabsOptions() throws Exception { + public void shouldStartLoginWithBrowserCustomTabsOptions() { CustomTabsOptions options = mock(CustomTabsOptions.class); WebAuthProvider.init(account) .withCustomTabsOptions(options) @@ -1019,7 +1019,7 @@ public void shouldStartLoginWithBrowserCustomTabsOptions() throws Exception { @SuppressWarnings("deprecation") @Test - public void shouldStartLoginWithBrowser() throws Exception { + public void shouldStartLoginWithBrowser() { WebAuthProvider.init(account) .useBrowser(true) .useCodeGrant(false) @@ -1045,7 +1045,7 @@ public void shouldStartLoginWithBrowser() throws Exception { @SuppressWarnings("deprecation") @Test - public void shouldStartLoginWithWebViewAndDefaultConnection() throws Exception { + public void shouldStartLoginWithWebViewAndDefaultConnection() { WebAuthProvider.init(account) .useBrowser(false) .useCodeGrant(false) @@ -1073,7 +1073,7 @@ public void shouldStartLoginWithWebViewAndDefaultConnection() throws Exception { @SuppressWarnings("deprecation") @Test - public void shouldStartLoginWithWebViewAndCustomConnection() throws Exception { + public void shouldStartLoginWithWebViewAndCustomConnection() { WebAuthProvider.init(account) .useBrowser(false) .withConnection("my-connection") @@ -1102,7 +1102,7 @@ public void shouldStartLoginWithWebViewAndCustomConnection() throws Exception { @SuppressWarnings("deprecation") @Test - public void shouldResumeLoginWithRequestCodeWithResponseTypeIdToken() throws Exception { + public void shouldResumeLoginWithRequestCodeWithResponseTypeIdToken() { WebAuthProvider.init(account) .withResponseType(ResponseType.ID_TOKEN) .start(activity, callback, REQUEST_CODE); @@ -1122,7 +1122,7 @@ public void shouldResumeLoginWithRequestCodeWithResponseTypeIdToken() throws Exc } @Test - public void shouldResumeLoginWithIntentWithResponseTypeIdToken() throws Exception { + public void shouldResumeLoginWithIntentWithResponseTypeIdToken() { WebAuthProvider.init(account) .withResponseType(ResponseType.ID_TOKEN) .start(activity, callback); @@ -1144,12 +1144,12 @@ public void shouldResumeLoginWithIntentWithResponseTypeIdToken() throws Exceptio @SuppressWarnings("deprecation") @Test - public void shouldStartLoginWithValidRequestCode() throws Exception { + public void shouldStartLoginWithValidRequestCode() { final Credentials credentials = Mockito.mock(Credentials.class); PKCE pkce = Mockito.mock(PKCE.class); Mockito.doAnswer(new Answer() { @Override - public Object answer(InvocationOnMock invocation) throws Throwable { + public Object answer(InvocationOnMock invocation) { callback.onSuccess(credentials); return null; } @@ -1166,13 +1166,13 @@ public Object answer(InvocationOnMock invocation) throws Throwable { @SuppressWarnings("deprecation") @Test - public void shouldResumeLoginWithIntentWithCodeGrant() throws Exception { + public void shouldResumeLoginWithIntentWithCodeGrant() { Date expiresAt = new Date(); final Credentials codeCredentials = new Credentials("codeId", "codeAccess", "codeType", "codeRefresh", expiresAt, "codeScope"); PKCE pkce = Mockito.mock(PKCE.class); Mockito.doAnswer(new Answer() { @Override - public Object answer(InvocationOnMock invocation) throws Throwable { + public Object answer(InvocationOnMock invocation) { callbackCaptor.getValue().onSuccess(codeCredentials); return null; } @@ -1205,13 +1205,13 @@ public Object answer(InvocationOnMock invocation) throws Throwable { @SuppressWarnings("deprecation") @Test - public void shouldResumeLoginWithRequestCodeWithCodeGrant() throws Exception { + public void shouldResumeLoginWithRequestCodeWithCodeGrant() { Date expiresAt = new Date(); final Credentials codeCredentials = new Credentials("codeId", "codeAccess", "codeType", "codeRefresh", expiresAt, "codeScope"); PKCE pkce = Mockito.mock(PKCE.class); Mockito.doAnswer(new Answer() { @Override - public Object answer(InvocationOnMock invocation) throws Throwable { + public Object answer(InvocationOnMock invocation) { callbackCaptor.getValue().onSuccess(codeCredentials); return null; } @@ -1244,7 +1244,7 @@ public Object answer(InvocationOnMock invocation) throws Throwable { @SuppressWarnings("deprecation") @Test - public void shouldResumeLoginWithIntentWithImplicitGrant() throws Exception { + public void shouldResumeLoginWithIntentWithImplicitGrant() { WebAuthProvider.init(account) .useCodeGrant(false) .start(activity, callback); @@ -1271,7 +1271,7 @@ public void shouldResumeLoginWithIntentWithImplicitGrant() throws Exception { @SuppressWarnings("deprecation") @Test - public void shouldResumeLoginWithRequestCodeWithImplicitGrant() throws Exception { + public void shouldResumeLoginWithRequestCodeWithImplicitGrant() { WebAuthProvider.init(account) .useCodeGrant(false) .start(activity, callback, REQUEST_CODE); @@ -1298,7 +1298,7 @@ public void shouldResumeLoginWithRequestCodeWithImplicitGrant() throws Exception @SuppressWarnings("deprecation") @Test - public void shouldResumeLoginWithRequestCodeWhenResultCancelled() throws Exception { + public void shouldResumeLoginWithRequestCodeWhenResultCancelled() { WebAuthProvider.init(account) .useCodeGrant(false) .start(activity, callback, REQUEST_CODE); @@ -1315,7 +1315,7 @@ public void shouldResumeLoginWithRequestCodeWhenResultCancelled() throws Excepti @SuppressWarnings("deprecation") @Test - public void shouldResumeLoginWithIntentWhenResultCancelled() throws Exception { + public void shouldResumeLoginWithIntentWhenResultCancelled() { WebAuthProvider.init(account) .useCodeGrant(false) .start(activity, callback); @@ -1331,7 +1331,7 @@ public void shouldResumeLoginWithIntentWhenResultCancelled() throws Exception { } @Test - public void shouldCalculateExpiresAtDateOnResumeLogin() throws Exception { + public void shouldCalculateExpiresAtDateOnResumeLogin() { WebAuthProvider.init(account) .useCodeGrant(false) .start(activity, callback, REQUEST_CODE); @@ -1358,12 +1358,12 @@ public void shouldCalculateExpiresAtDateOnResumeLogin() throws Exception { @SuppressWarnings("deprecation") @Test - public void shouldReThrowAnyFailedCodeExchangeDialogOnLogin() throws Exception { + public void shouldReThrowAnyFailedCodeExchangeDialogOnLogin() { final Dialog dialog = Mockito.mock(Dialog.class); PKCE pkce = Mockito.mock(PKCE.class); Mockito.doAnswer(new Answer() { @Override - public Object answer(InvocationOnMock invocation) throws Throwable { + public Object answer(InvocationOnMock invocation) { callbackCaptor.getValue().onFailure(dialog); return null; } @@ -1381,12 +1381,12 @@ public Object answer(InvocationOnMock invocation) throws Throwable { @SuppressWarnings("deprecation") @Test - public void shouldReThrowAnyFailedCodeExchangeExceptionOnLogin() throws Exception { + public void shouldReThrowAnyFailedCodeExchangeExceptionOnLogin() { final AuthenticationException exception = Mockito.mock(AuthenticationException.class); PKCE pkce = Mockito.mock(PKCE.class); Mockito.doAnswer(new Answer() { @Override - public Object answer(InvocationOnMock invocation) throws Throwable { + public Object answer(InvocationOnMock invocation) { callbackCaptor.getValue().onFailure(exception); return null; } @@ -1402,9 +1402,9 @@ public Object answer(InvocationOnMock invocation) throws Throwable { verify(callback).onFailure(exception); } - @SuppressWarnings({"deprecation", "ThrowableResultOfMethodCallIgnored"}) + @SuppressWarnings({"deprecation"}) @Test - public void shouldFailToResumeLoginWithIntentWithAccessDenied() throws Exception { + public void shouldFailToResumeLoginWithIntentWithAccessDenied() { WebAuthProvider.init(account) .withState("1234567890") .useCodeGrant(false) @@ -1419,9 +1419,9 @@ public void shouldFailToResumeLoginWithIntentWithAccessDenied() throws Exception assertThat(authExceptionCaptor.getValue().getDescription(), is("Permissions were not granted. Try again.")); } - @SuppressWarnings({"deprecation", "ThrowableResultOfMethodCallIgnored"}) + @SuppressWarnings({"deprecation"}) @Test - public void shouldFailToResumeLoginWithRequestCodeWithAccessDenied() throws Exception { + public void shouldFailToResumeLoginWithRequestCodeWithAccessDenied() { WebAuthProvider.init(account) .withState("1234567890") .useCodeGrant(false) @@ -1436,9 +1436,9 @@ public void shouldFailToResumeLoginWithRequestCodeWithAccessDenied() throws Exce assertThat(authExceptionCaptor.getValue().getDescription(), is("Permissions were not granted. Try again.")); } - @SuppressWarnings({"deprecation", "ThrowableResultOfMethodCallIgnored"}) + @SuppressWarnings({"deprecation"}) @Test - public void shouldFailToResumeLoginWithIntentWithRuleError() throws Exception { + public void shouldFailToResumeLoginWithIntentWithRuleError() { WebAuthProvider.init(account) .withState("1234567890") .useCodeGrant(false) @@ -1453,9 +1453,9 @@ public void shouldFailToResumeLoginWithIntentWithRuleError() throws Exception { assertThat(authExceptionCaptor.getValue().getDescription(), is("Custom Rule Error")); } - @SuppressWarnings({"deprecation", "ThrowableResultOfMethodCallIgnored"}) + @SuppressWarnings({"deprecation"}) @Test - public void shouldFailToResumeLoginWithRequestCodeWithRuleError() throws Exception { + public void shouldFailToResumeLoginWithRequestCodeWithRuleError() { WebAuthProvider.init(account) .withState("1234567890") .useCodeGrant(false) @@ -1470,9 +1470,9 @@ public void shouldFailToResumeLoginWithRequestCodeWithRuleError() throws Excepti assertThat(authExceptionCaptor.getValue().getDescription(), is("Custom Rule Error")); } - @SuppressWarnings({"deprecation", "ThrowableResultOfMethodCallIgnored"}) + @SuppressWarnings({"deprecation"}) @Test - public void shouldFailToResumeLoginWithIntentWithConfigurationInvalid() throws Exception { + public void shouldFailToResumeLoginWithIntentWithConfigurationInvalid() { WebAuthProvider.init(account) .withState("1234567890") .useCodeGrant(false) @@ -1487,9 +1487,9 @@ public void shouldFailToResumeLoginWithIntentWithConfigurationInvalid() throws E assertThat(authExceptionCaptor.getValue().getDescription(), is("The application isn't configured properly for the social connection. Please check your Auth0's application configuration")); } - @SuppressWarnings({"deprecation", "ThrowableResultOfMethodCallIgnored"}) + @SuppressWarnings({"deprecation"}) @Test - public void shouldFailToResumeLoginWithRequestCodeWithConfigurationInvalid() throws Exception { + public void shouldFailToResumeLoginWithRequestCodeWithConfigurationInvalid() { WebAuthProvider.init(account) .withState("1234567890") .useCodeGrant(false) @@ -1504,9 +1504,9 @@ public void shouldFailToResumeLoginWithRequestCodeWithConfigurationInvalid() thr assertThat(authExceptionCaptor.getValue().getDescription(), is("The application isn't configured properly for the social connection. Please check your Auth0's application configuration")); } - @SuppressWarnings({"deprecation", "ThrowableResultOfMethodCallIgnored"}) + @SuppressWarnings({"deprecation"}) @Test - public void shouldFailToResumeLoginWithIntentWithLoginRequired() throws Exception { + public void shouldFailToResumeLoginWithIntentWithLoginRequired() { WebAuthProvider.init(account) .withState("1234567890") .useCodeGrant(false) @@ -1521,9 +1521,9 @@ public void shouldFailToResumeLoginWithIntentWithLoginRequired() throws Exceptio assertThat(authExceptionCaptor.getValue().getDescription(), is("Login Required")); } - @SuppressWarnings({"deprecation", "ThrowableResultOfMethodCallIgnored"}) + @SuppressWarnings({"deprecation"}) @Test - public void shouldFailToResumeLoginWithRequestCodeWithLoginRequired() throws Exception { + public void shouldFailToResumeLoginWithRequestCodeWithLoginRequired() { WebAuthProvider.init(account) .withState("1234567890") .useCodeGrant(false) @@ -1538,9 +1538,9 @@ public void shouldFailToResumeLoginWithRequestCodeWithLoginRequired() throws Exc assertThat(authExceptionCaptor.getValue().getDescription(), is("Login Required")); } - @SuppressWarnings({"deprecation", "ThrowableResultOfMethodCallIgnored"}) + @SuppressWarnings({"deprecation"}) @Test - public void shouldFailToResumeLoginWithIntentWithInvalidState() throws Exception { + public void shouldFailToResumeLoginWithIntentWithInvalidState() { WebAuthProvider.init(account) .withState("abcdefghijk") .useCodeGrant(false) @@ -1555,9 +1555,9 @@ public void shouldFailToResumeLoginWithIntentWithInvalidState() throws Exception assertThat(authExceptionCaptor.getValue().getDescription(), is("The received state is invalid. Try again.")); } - @SuppressWarnings({"deprecation", "ThrowableResultOfMethodCallIgnored"}) + @SuppressWarnings({"deprecation"}) @Test - public void shouldFailToResumeLoginWithRequestCodeWithInvalidState() throws Exception { + public void shouldFailToResumeLoginWithRequestCodeWithInvalidState() { WebAuthProvider.init(account) .withState("abcdefghijk") .useCodeGrant(false) @@ -1572,9 +1572,9 @@ public void shouldFailToResumeLoginWithRequestCodeWithInvalidState() throws Exce assertThat(authExceptionCaptor.getValue().getDescription(), is("The received state is invalid. Try again.")); } - @SuppressWarnings({"deprecation", "ThrowableResultOfMethodCallIgnored"}) + @SuppressWarnings({"deprecation"}) @Test - public void shouldFailToResumeLoginWithIntentWithInvalidNonce() throws Exception { + public void shouldFailToResumeLoginWithIntentWithInvalidNonce() { WebAuthProvider.init(account) .withState("state") .withNonce("0987654321") @@ -1590,9 +1590,9 @@ public void shouldFailToResumeLoginWithIntentWithInvalidNonce() throws Exception assertThat(authExceptionCaptor.getValue().getDescription(), is("The received nonce is invalid. Try again.")); } - @SuppressWarnings({"deprecation", "ThrowableResultOfMethodCallIgnored"}) + @SuppressWarnings({"deprecation"}) @Test - public void shouldFailToResumeLoginWithRequestCodeWithInvalidNonce() throws Exception { + public void shouldFailToResumeLoginWithRequestCodeWithInvalidNonce() { WebAuthProvider.init(account) .withState("state") .withNonce("0987654321") @@ -1610,7 +1610,7 @@ public void shouldFailToResumeLoginWithRequestCodeWithInvalidNonce() throws Exce @SuppressWarnings("deprecation") @Test - public void shouldFailToResumeLoginWithUnexpectedRequestCode() throws Exception { + public void shouldFailToResumeLoginWithUnexpectedRequestCode() { verifyNoMoreInteractions(callback); WebAuthProvider.init(account) .useCodeGrant(false) @@ -1622,7 +1622,7 @@ public void shouldFailToResumeLoginWithUnexpectedRequestCode() throws Exception @SuppressWarnings("deprecation") @Test - public void shouldFailToResumeLoginWithResultNotOK() throws Exception { + public void shouldFailToResumeLoginWithResultNotOK() { verifyNoMoreInteractions(callback); WebAuthProvider.init(account) .useCodeGrant(false) @@ -1634,7 +1634,7 @@ public void shouldFailToResumeLoginWithResultNotOK() throws Exception { @SuppressWarnings("deprecation") @Test - public void shouldFailToResumeLoginWithIntentWithEmptyUriValues() throws Exception { + public void shouldFailToResumeLoginWithIntentWithEmptyUriValues() { verifyNoMoreInteractions(callback); WebAuthProvider.init(account) .withState("abcdefghijk") @@ -1647,7 +1647,7 @@ public void shouldFailToResumeLoginWithIntentWithEmptyUriValues() throws Excepti @SuppressWarnings("deprecation") @Test - public void shouldFailToResumeLoginWithRequestCodeWithEmptyUriValues() throws Exception { + public void shouldFailToResumeLoginWithRequestCodeWithEmptyUriValues() { verifyNoMoreInteractions(callback); WebAuthProvider.init(account) .withState("abcdefghijk") @@ -1659,7 +1659,7 @@ public void shouldFailToResumeLoginWithRequestCodeWithEmptyUriValues() throws Ex } @Test - public void shouldFailToResumeLoginWithIntentWithoutFirstInitProvider() throws Exception { + public void shouldFailToResumeLoginWithIntentWithoutFirstInitProvider() { WebAuthProvider.resetManagerInstance(); Intent intent = createAuthIntent(""); @@ -1668,7 +1668,7 @@ public void shouldFailToResumeLoginWithIntentWithoutFirstInitProvider() throws E @SuppressWarnings("deprecation") @Test - public void shouldFailToResumeLoginWithRequestCodeWithoutFirstInitProvider() throws Exception { + public void shouldFailToResumeLoginWithRequestCodeWithoutFirstInitProvider() { WebAuthProvider.resetManagerInstance(); Intent intent = createAuthIntent(""); @@ -1677,7 +1677,7 @@ public void shouldFailToResumeLoginWithRequestCodeWithoutFirstInitProvider() thr @SuppressWarnings("deprecation") @Test - public void shouldResumeLoginWithIntentWithNullIntent() throws Exception { + public void shouldResumeLoginWithIntentWithNullIntent() { WebAuthProvider.init(account) .withState("abcdefghijk") .useCodeGrant(false) @@ -1687,7 +1687,7 @@ public void shouldResumeLoginWithIntentWithNullIntent() throws Exception { @SuppressWarnings("deprecation") @Test - public void shouldFailToResumeLoginWithRequestCodeWithNullIntent() throws Exception { + public void shouldFailToResumeLoginWithRequestCodeWithNullIntent() { WebAuthProvider.init(account) .withState("abcdefghijk") .useCodeGrant(false) @@ -1696,7 +1696,7 @@ public void shouldFailToResumeLoginWithRequestCodeWithNullIntent() throws Except } @Test - public void shouldClearInstanceAfterSuccessLoginWithIntent() throws Exception { + public void shouldClearInstanceAfterSuccessLoginWithIntent() { WebAuthProvider.init(account) .start(activity, callback); @@ -1708,7 +1708,7 @@ public void shouldClearInstanceAfterSuccessLoginWithIntent() throws Exception { @SuppressWarnings("deprecation") @Test - public void shouldClearInstanceAfterSuccessLoginWithRequestCode() throws Exception { + public void shouldClearInstanceAfterSuccessLoginWithRequestCode() { WebAuthProvider.init(account) .start(activity, callback, REQUEST_CODE); @@ -1719,7 +1719,7 @@ public void shouldClearInstanceAfterSuccessLoginWithRequestCode() throws Excepti } @Test - public void shouldFailToStartLoginWithBrowserWhenNoBrowserAppIsInstalled() throws Exception { + public void shouldFailToStartLoginWithBrowserWhenNoBrowserAppIsInstalled() { prepareBrowserApp(false, null); WebAuthProvider.init(account) .useBrowser(true) @@ -1735,7 +1735,7 @@ public void shouldFailToStartLoginWithBrowserWhenNoBrowserAppIsInstalled() throw @SuppressWarnings("deprecation") @Test - public void shouldNotFailToStartLoginWithWebviewWhenNoBrowserAppIsInstalled() throws Exception { + public void shouldNotFailToStartLoginWithWebviewWhenNoBrowserAppIsInstalled() { prepareBrowserApp(false, null); WebAuthProvider.init(account) .useBrowser(false) @@ -1759,7 +1759,7 @@ public void shouldNotFailToStartLoginWithWebviewWhenNoBrowserAppIsInstalled() th //** ** ** ** ** ** **// @Test - public void shouldInitLogoutWithAccount() throws Exception { + public void shouldInitLogoutWithAccount() { WebAuthProvider.logout(account) .start(activity, voidCallback); @@ -1769,7 +1769,7 @@ public void shouldInitLogoutWithAccount() throws Exception { //scheme @Test - public void shouldHaveDefaultSchemeOnLogout() throws Exception { + public void shouldHaveDefaultSchemeOnLogout() { WebAuthProvider.logout(account) .start(activity, voidCallback); verify(activity).startActivity(intentCaptor.capture()); @@ -1782,7 +1782,7 @@ public void shouldHaveDefaultSchemeOnLogout() throws Exception { } @Test - public void shouldSetSchemeOnLogout() throws Exception { + public void shouldSetSchemeOnLogout() { WebAuthProvider.logout(account) .withScheme("myapp") .start(activity, voidCallback); @@ -1799,7 +1799,7 @@ public void shouldSetSchemeOnLogout() throws Exception { // client id @Test - public void shouldAlwaysSetClientIdOnLogout() throws Exception { + public void shouldAlwaysSetClientIdOnLogout() { WebAuthProvider.logout(account) .start(activity, voidCallback); @@ -1813,7 +1813,7 @@ public void shouldAlwaysSetClientIdOnLogout() throws Exception { // auth0 related @Test - public void shouldHaveTelemetryInfoOnLogout() throws Exception { + public void shouldHaveTelemetryInfoOnLogout() { WebAuthProvider.logout(account) .start(activity, voidCallback); @@ -1825,7 +1825,7 @@ public void shouldHaveTelemetryInfoOnLogout() throws Exception { } @Test - public void shouldHaveReturnToUriOnLogout() throws Exception { + public void shouldHaveReturnToUriOnLogout() { WebAuthProvider.logout(account) .start(activity, voidCallback); @@ -1840,9 +1840,8 @@ public void shouldHaveReturnToUriOnLogout() throws Exception { // Launch log out - @SuppressWarnings("deprecation") @Test - public void shouldStartLogout() throws Exception { + public void shouldStartLogout() { WebAuthProvider.logout(account) .start(activity, voidCallback); @@ -1865,7 +1864,7 @@ public void shouldStartLogout() throws Exception { } @Test - public void shouldStartLogoutWithCustomTabsOptions() throws Exception { + public void shouldStartLogoutWithCustomTabsOptions() { CustomTabsOptions options = mock(CustomTabsOptions.class); WebAuthProvider.logout(account) .withCustomTabsOptions(options) @@ -1890,7 +1889,7 @@ public void shouldStartLogoutWithCustomTabsOptions() throws Exception { } @Test - public void shouldFailToStartLogoutWhenNoBrowserAppIsInstalled() throws Exception { + public void shouldFailToStartLogoutWhenNoBrowserAppIsInstalled() { prepareBrowserApp(false, null); WebAuthProvider.logout(account) .start(activity, voidCallback); @@ -1906,7 +1905,7 @@ public void shouldFailToStartLogoutWhenNoBrowserAppIsInstalled() throws Exceptio } @Test - public void shouldResumeLogoutSuccessfullyWithIntent() throws Exception { + public void shouldResumeLogoutSuccessfullyWithIntent() { WebAuthProvider.logout(account) .start(activity, voidCallback); @@ -1921,7 +1920,7 @@ public void shouldResumeLogoutSuccessfullyWithIntent() throws Exception { } @Test - public void shouldResumeLogoutFailingWithIntent() throws Exception { + public void shouldResumeLogoutFailingWithIntent() { WebAuthProvider.logout(account) .start(activity, voidCallback); @@ -1941,7 +1940,7 @@ public void shouldResumeLogoutFailingWithIntent() throws Exception { } @Test - public void shouldClearLogoutManagerInstanceAfterSuccessfulLogout() throws Exception { + public void shouldClearLogoutManagerInstanceAfterSuccessfulLogout() { WebAuthProvider.logout(account) .start(activity, voidCallback); diff --git a/auth0/src/test/java/com/auth0/android/request/internal/AuthenticationErrorBuilderTest.java b/auth0/src/test/java/com/auth0/android/request/internal/AuthenticationErrorBuilderTest.java index e75e7176d..79739c576 100644 --- a/auth0/src/test/java/com/auth0/android/request/internal/AuthenticationErrorBuilderTest.java +++ b/auth0/src/test/java/com/auth0/android/request/internal/AuthenticationErrorBuilderTest.java @@ -26,12 +26,12 @@ public class AuthenticationErrorBuilderTest { private AuthenticationErrorBuilder builder; @Before - public void setUp() throws Exception { + public void setUp() { builder = new AuthenticationErrorBuilder(); } @Test - public void shouldCreateFromMessage() throws Exception { + public void shouldCreateFromMessage() { final AuthenticationException ex = builder.from("message"); assertThat(ex.getCause(), is(nullValue())); @@ -41,7 +41,7 @@ public void shouldCreateFromMessage() throws Exception { } @Test - public void shouldCreateFromMessageAndException() throws Exception { + public void shouldCreateFromMessageAndException() { final Auth0Exception auth0Ex = Mockito.mock(Auth0Exception.class); final AuthenticationException ex = builder.from("message", auth0Ex); @@ -52,7 +52,7 @@ public void shouldCreateFromMessageAndException() throws Exception { } @Test - public void shouldCreateFromStringPayloadAndIntCode() throws Exception { + public void shouldCreateFromStringPayloadAndIntCode() { final AuthenticationException ex = builder.from("message", 999); assertThat(ex.getCause(), is(nullValue())); @@ -62,7 +62,7 @@ public void shouldCreateFromStringPayloadAndIntCode() throws Exception { } @Test - public void shouldCreateFromMap() throws Exception { + public void shouldCreateFromMap() { Map map = new HashMap<>(); map.put("key", "value"); map.put("asd", "123"); diff --git a/auth0/src/test/java/com/auth0/android/request/internal/BaseAuthenticationRequestTest.java b/auth0/src/test/java/com/auth0/android/request/internal/BaseAuthenticationRequestTest.java index 5559db733..c2cf2e50c 100644 --- a/auth0/src/test/java/com/auth0/android/request/internal/BaseAuthenticationRequestTest.java +++ b/auth0/src/test/java/com/auth0/android/request/internal/BaseAuthenticationRequestTest.java @@ -63,7 +63,7 @@ private BaseAuthenticationRequest createRequest(HttpUrl url) { return new BaseAuthenticationRequest(url, new OkHttpClient(), gson, "POST", Credentials.class); } - private Map bodyFromRequest(RecordedRequest request) throws java.io.IOException { + private Map bodyFromRequest(RecordedRequest request) { final Type mapType = new TypeToken>() { }.getType(); return gson.fromJson(request.getBody().readUtf8(), mapType); @@ -92,7 +92,7 @@ public void shouldSetConnection() throws Exception { } @Test - public void shouldNotSetConnectionOnNonLegacyEndpoints() throws Exception { + public void shouldNotSetConnectionOnNonLegacyEndpoints() { exception.expect(IllegalArgumentException.class); exception.expectMessage("method POST must have a request body."); //no body was sent @@ -125,7 +125,7 @@ public void shouldSetRealm() throws Exception { } @Test - public void shouldNotSetRealmOnLegacyEndpoints() throws Exception { + public void shouldNotSetRealmOnLegacyEndpoints() { exception.expect(IllegalArgumentException.class); exception.expectMessage("method POST must have a request body."); //no body was sent diff --git a/auth0/src/test/java/com/auth0/android/request/internal/BaseRequestTest.java b/auth0/src/test/java/com/auth0/android/request/internal/BaseRequestTest.java index 8501462fc..8ff1cda14 100755 --- a/auth0/src/test/java/com/auth0/android/request/internal/BaseRequestTest.java +++ b/auth0/src/test/java/com/auth0/android/request/internal/BaseRequestTest.java @@ -85,7 +85,7 @@ public class BaseRequestTest { private ArgumentCaptor> mapCaptor; @Before - public void setUp() throws Exception { + public void setUp() { MockitoAnnotations.initMocks(this); HttpUrl url = HttpUrl.parse("https://auth0.com"); parameterBuilder = ParameterBuilder.newBuilder(); @@ -97,7 +97,7 @@ public String execute() throws Auth0Exception { } @Override - public void onResponse(Response response) throws IOException { + public void onResponse(Response response) { } @@ -109,35 +109,35 @@ protected Request doBuildRequest() throws RequestBodyBuildException { } @Test - public void shouldUpdateTheCallback() throws Exception { + public void shouldUpdateTheCallback() { BaseCallback diffCallback = mock(BaseCallback.class); baseRequest.setCallback(diffCallback); assertThat(baseRequest.getCallback(), CoreMatchers.equalTo(diffCallback)); } @Test - public void shouldGetTheCallback() throws Exception { + public void shouldGetTheCallback() { assertThat(baseRequest.getCallback(), CoreMatchers.equalTo(callback)); } @Test - public void shouldGetTheErrorBuilder() throws Exception { + public void shouldGetTheErrorBuilder() { assertThat(baseRequest.getErrorBuilder(), CoreMatchers.equalTo(errorBuilder)); } @Test - public void shouldGetTheAdapter() throws Exception { + public void shouldGetTheAdapter() { assertThat(baseRequest.getAdapter(), CoreMatchers.equalTo(adapter)); } @Test - public void shouldAddHeaders() throws Exception { + public void shouldAddHeaders() { baseRequest.addHeader("name", "value"); verify(headers).put("name", "value"); } @Test - public void shouldAddASingleParameter() throws Exception { + public void shouldAddASingleParameter() { baseRequest.addParameter("name", "value"); final Map result = parameterBuilder.asDictionary(); @@ -146,7 +146,7 @@ public void shouldAddASingleParameter() throws Exception { } @Test - public void shouldAddParameters() throws Exception { + public void shouldAddParameters() { Map params = new HashMap<>(); params.put("name", "value"); params.put("asd", "123"); @@ -159,33 +159,33 @@ public void shouldAddParameters() throws Exception { } @Test - public void shouldSetBearer() throws Exception { + public void shouldSetBearer() { baseRequest.setBearer("my-jwt-token"); verify(headers).put("Authorization", "Bearer my-jwt-token"); } @Test - public void shouldPostOnSuccess() throws Exception { + public void shouldPostOnSuccess() { baseRequest.postOnSuccess("OK"); verify(callback).onSuccess(eq("OK")); verifyNoMoreInteractions(callback); } @Test - public void shouldPostOnFailure() throws Exception { + public void shouldPostOnFailure() { baseRequest.postOnFailure(throwable); verify(callback).onFailure(eq(throwable)); verifyNoMoreInteractions(callback); } @Test - public void shouldBuildNetworkErrorException() throws Exception { + public void shouldBuildNetworkErrorException() { baseRequest.onFailure(null, mock(IOException.class)); verify(errorBuilder).from(eq("Request failed"), any(NetworkErrorException.class)); } @Test - public void shouldParseUnsuccessfulJsonResponse() throws Exception { + public void shouldParseUnsuccessfulJsonResponse() { String payload = "{key: \"value\", asd: \"123\"}"; final Response response = createJsonResponse(payload, 401); baseRequest.parseUnsuccessfulResponse(response); @@ -196,7 +196,7 @@ public void shouldParseUnsuccessfulJsonResponse() throws Exception { } @Test - public void shouldParseUnsuccessfulNotJsonResponse() throws Exception { + public void shouldParseUnsuccessfulNotJsonResponse() { String payload = "n=ot_a valid json {{]"; final Response response = createJsonResponse(payload, 401); baseRequest.parseUnsuccessfulResponse(response); diff --git a/auth0/src/test/java/com/auth0/android/request/internal/CredentialsDeserializerTest.java b/auth0/src/test/java/com/auth0/android/request/internal/CredentialsDeserializerTest.java index d95ee203a..094f722ab 100644 --- a/auth0/src/test/java/com/auth0/android/request/internal/CredentialsDeserializerTest.java +++ b/auth0/src/test/java/com/auth0/android/request/internal/CredentialsDeserializerTest.java @@ -26,7 +26,7 @@ public class CredentialsDeserializerTest { private Gson gson; @Before - public void setUp() throws Exception { + public void setUp() { final CredentialsDeserializerMock deserializer = new CredentialsDeserializerMock(); gson = new GsonBuilder() .setDateFormat(GsonProvider.DATE_FORMAT) diff --git a/auth0/src/test/java/com/auth0/android/request/internal/CredentialsGsonTest.java b/auth0/src/test/java/com/auth0/android/request/internal/CredentialsGsonTest.java index e3d44a6ec..3a0caa443 100755 --- a/auth0/src/test/java/com/auth0/android/request/internal/CredentialsGsonTest.java +++ b/auth0/src/test/java/com/auth0/android/request/internal/CredentialsGsonTest.java @@ -34,7 +34,7 @@ public class CredentialsGsonTest extends GsonBaseTest { public ExpectedException expectedException = ExpectedException.none(); @Before - public void setUp() throws Exception { + public void setUp() { gson = GsonProvider.buildGson(); } @@ -115,7 +115,7 @@ public void shouldReturnWithRefreshToken() throws Exception { } @Test - public void shouldSerializeCredentials() throws Exception { + public void shouldSerializeCredentials() { Date expiresAt = new Date(CredentialsMock.CURRENT_TIME_MS + 123456 * 1000); final String expectedExpiresAt = GsonProvider.formatDate(expiresAt); diff --git a/auth0/src/test/java/com/auth0/android/request/internal/ManagementErrorBuilderTest.java b/auth0/src/test/java/com/auth0/android/request/internal/ManagementErrorBuilderTest.java index 1c8eba53b..4f3a8ccc5 100644 --- a/auth0/src/test/java/com/auth0/android/request/internal/ManagementErrorBuilderTest.java +++ b/auth0/src/test/java/com/auth0/android/request/internal/ManagementErrorBuilderTest.java @@ -21,12 +21,12 @@ public class ManagementErrorBuilderTest { private ManagementErrorBuilder builder; @Before - public void setUp() throws Exception { + public void setUp() { builder = new ManagementErrorBuilder(); } @Test - public void shouldCreateFromMessage() throws Exception { + public void shouldCreateFromMessage() { final ManagementException ex = builder.from("message"); assertThat(ex.getCause(), is(nullValue())); @@ -36,7 +36,7 @@ public void shouldCreateFromMessage() throws Exception { } @Test - public void shouldCreateFromMessageAndException() throws Exception { + public void shouldCreateFromMessageAndException() { final Auth0Exception auth0Ex = Mockito.mock(Auth0Exception.class); final ManagementException ex = builder.from("message", auth0Ex); @@ -47,7 +47,7 @@ public void shouldCreateFromMessageAndException() throws Exception { } @Test - public void shouldCreateFromStringPayloadAndIntCode() throws Exception { + public void shouldCreateFromStringPayloadAndIntCode() { final ManagementException ex = builder.from("message", 999); assertThat(ex.getCause(), is(nullValue())); @@ -57,7 +57,7 @@ public void shouldCreateFromStringPayloadAndIntCode() throws Exception { } @Test - public void shouldCreateFromMap() throws Exception { + public void shouldCreateFromMap() { Map map = new HashMap<>(); map.put("key", "value"); map.put("asd", "123"); diff --git a/auth0/src/test/java/com/auth0/android/request/internal/RequestFactoryTest.java b/auth0/src/test/java/com/auth0/android/request/internal/RequestFactoryTest.java index 74e01da9b..e3b3554aa 100644 --- a/auth0/src/test/java/com/auth0/android/request/internal/RequestFactoryTest.java +++ b/auth0/src/test/java/com/auth0/android/request/internal/RequestFactoryTest.java @@ -44,7 +44,7 @@ public class RequestFactoryTest { private HttpUrl url; @Before - public void setUp() throws Exception { + public void setUp() { MockitoAnnotations.initMocks(this); gson = new Gson(); url = HttpUrl.parse("http://domain.auth0.com"); @@ -52,14 +52,14 @@ public void setUp() throws Exception { } @Test - public void shouldHaveNonNullHeaders() throws Exception { + public void shouldHaveNonNullHeaders() { final RequestFactory factory = new RequestFactory(); assertThat(factory.getHeaders(), is(notNullValue())); } @Test - public void shouldHaveAcceptLanguageHeader() throws Exception { + public void shouldHaveAcceptLanguageHeader() { final RequestFactory factory = new RequestFactory(); assertThat(factory.getHeaders().size(), is(1)); @@ -67,7 +67,7 @@ public void shouldHaveAcceptLanguageHeader() throws Exception { } @Test - public void shouldHaveClientInfoHeader() throws Exception { + public void shouldHaveClientInfoHeader() { final RequestFactory factory = new RequestFactory(); factory.setClientInfo(CLIENT_INFO); @@ -76,7 +76,7 @@ public void shouldHaveClientInfoHeader() throws Exception { } @Test - public void shouldHaveUserAgentHeader() throws Exception { + public void shouldHaveUserAgentHeader() { final RequestFactory factory = new RequestFactory(); factory.setUserAgent(USER_AGENT); @@ -85,7 +85,7 @@ public void shouldHaveUserAgentHeader() throws Exception { } @Test - public void shouldHaveAuthorizationHeader() throws Exception { + public void shouldHaveAuthorizationHeader() { final RequestFactory factory = new RequestFactory(TOKEN); assertThat(factory.getHeaders().size(), is(2)); @@ -93,7 +93,7 @@ public void shouldHaveAuthorizationHeader() throws Exception { } @Test - public void shouldCreateAuthenticationPOSTRequest() throws Exception { + public void shouldCreateAuthenticationPOSTRequest() { final MockAuthenticationRequest request = (MockAuthenticationRequest) factory.authenticationPOST(url, client, gson); assertThat(request, is(notNullValue())); @@ -102,7 +102,7 @@ public void shouldCreateAuthenticationPOSTRequest() throws Exception { } @Test - public void shouldCreatePOSTRequestOfTClass() throws Exception { + public void shouldCreatePOSTRequestOfTClass() { ParameterizableRequest request = factory.POST(url, client, gson, Auth0.class, builder); assertThat(request, is(notNullValue())); @@ -111,7 +111,7 @@ public void shouldCreatePOSTRequestOfTClass() throws Exception { } @Test - public void shouldCreatePOSTRequestOfTToken() throws Exception { + public void shouldCreatePOSTRequestOfTToken() { TypeToken typeToken = createTypeToken(); final ParameterizableRequest request = factory.POST(url, client, gson, typeToken, builder); @@ -121,7 +121,7 @@ public void shouldCreatePOSTRequestOfTToken() throws Exception { } @Test - public void shouldCreateVoidPOSTRequest() throws Exception { + public void shouldCreateVoidPOSTRequest() { final ParameterizableRequest request = factory.POST(url, client, gson, builder); assertThat(request, is(notNullValue())); @@ -130,7 +130,7 @@ public void shouldCreateVoidPOSTRequest() throws Exception { } @Test - public void shouldCreateRawPOSTRequest() throws Exception { + public void shouldCreateRawPOSTRequest() { final ParameterizableRequest, Auth0Exception> request = factory.rawPOST(url, client, gson, builder); assertThat(request, is(notNullValue())); @@ -139,7 +139,7 @@ public void shouldCreateRawPOSTRequest() throws Exception { } @Test - public void shouldCreatePATCHRequestOfTClass() throws Exception { + public void shouldCreatePATCHRequestOfTClass() { final ParameterizableRequest request = factory.PATCH(url, client, gson, Auth0.class, builder); assertThat(request, is(notNullValue())); @@ -148,7 +148,7 @@ public void shouldCreatePATCHRequestOfTClass() throws Exception { } @Test - public void shouldCreateDELETERequestOfTToken() throws Exception { + public void shouldCreateDELETERequestOfTToken() { TypeToken typeToken = createTypeToken(); final ParameterizableRequest request = factory.DELETE(url, client, gson, typeToken, builder); @@ -158,7 +158,7 @@ public void shouldCreateDELETERequestOfTToken() throws Exception { } @Test - public void shouldGetDefaultLocale() throws Exception { + public void shouldGetDefaultLocale() { final Locale localeJP = new Locale("ja", "JP"); Locale.setDefault(localeJP); assertThat(RequestFactory.getDefaultLocale(), is("ja_JP")); @@ -169,7 +169,7 @@ public void shouldGetDefaultLocale() throws Exception { } @Test - public void shouldAlwaysReturnValidLocale() throws Exception { + public void shouldAlwaysReturnValidLocale() { final Locale locale = new Locale(""); Locale.setDefault(locale); assertThat(RequestFactory.getDefaultLocale(), is("en_US")); diff --git a/auth0/src/test/java/com/auth0/android/request/internal/UserIdentityGsonTest.java b/auth0/src/test/java/com/auth0/android/request/internal/UserIdentityGsonTest.java index bfcf55ca3..344333bcc 100755 --- a/auth0/src/test/java/com/auth0/android/request/internal/UserIdentityGsonTest.java +++ b/auth0/src/test/java/com/auth0/android/request/internal/UserIdentityGsonTest.java @@ -24,7 +24,7 @@ public class UserIdentityGsonTest extends GsonBaseTest { public ExpectedException expectedException = ExpectedException.none(); @Before - public void setUp() throws Exception { + public void setUp() { gson = GsonProvider.buildGson(); } diff --git a/auth0/src/test/java/com/auth0/android/request/internal/UserProfileGsonTest.java b/auth0/src/test/java/com/auth0/android/request/internal/UserProfileGsonTest.java index db4126570..73af775f7 100755 --- a/auth0/src/test/java/com/auth0/android/request/internal/UserProfileGsonTest.java +++ b/auth0/src/test/java/com/auth0/android/request/internal/UserProfileGsonTest.java @@ -43,7 +43,7 @@ public class UserProfileGsonTest extends GsonBaseTest { public ExpectedException expectedException = ExpectedException.none(); @Before - public void setUp() throws Exception { + public void setUp() { gson = GsonProvider.buildGson(); } diff --git a/auth0/src/test/java/com/auth0/android/result/AuthenticationTest.java b/auth0/src/test/java/com/auth0/android/result/AuthenticationTest.java index f06500603..9dd78a795 100644 --- a/auth0/src/test/java/com/auth0/android/result/AuthenticationTest.java +++ b/auth0/src/test/java/com/auth0/android/result/AuthenticationTest.java @@ -15,19 +15,19 @@ public class AuthenticationTest { private Authentication authentication; @Before - public void setUp() throws Exception { + public void setUp() { credentials = Mockito.mock(Credentials.class); profile = Mockito.mock(UserProfile.class); authentication = new Authentication(profile, credentials); } @Test - public void getProfile() throws Exception { + public void getProfile() { assertThat(authentication.getProfile(), is(profile)); } @Test - public void getCredentials() throws Exception { + public void getCredentials() { assertThat(authentication.getCredentials(), is(credentials)); } diff --git a/auth0/src/test/java/com/auth0/android/result/CredentialsTest.java b/auth0/src/test/java/com/auth0/android/result/CredentialsTest.java index 43c31dc40..f6443965d 100644 --- a/auth0/src/test/java/com/auth0/android/result/CredentialsTest.java +++ b/auth0/src/test/java/com/auth0/android/result/CredentialsTest.java @@ -10,7 +10,7 @@ public class CredentialsTest { @Test - public void shouldCreateWithExpiresAtDateAndSetExpiresIn() throws Exception { + public void shouldCreateWithExpiresAtDateAndSetExpiresIn() { Date date = new Date(); long expiresIn = (date.getTime() - CredentialsMock.CURRENT_TIME_MS) / 1000; Credentials credentials = new CredentialsMock("idToken", "accessToken", "type", "refreshToken", date, "scope"); @@ -24,7 +24,7 @@ public void shouldCreateWithExpiresAtDateAndSetExpiresIn() throws Exception { } @Test - public void shouldCreateWithExpiresInAndSetExpiresAt() throws Exception { + public void shouldCreateWithExpiresInAndSetExpiresAt() { Credentials credentials = new CredentialsMock("idToken", "accessToken", "type", "refreshToken", 86400L); assertThat(credentials.getIdToken(), is("idToken")); assertThat(credentials.getAccessToken(), is("accessToken")); @@ -36,7 +36,7 @@ public void shouldCreateWithExpiresInAndSetExpiresAt() throws Exception { } @Test - public void getScope() throws Exception { + public void getScope() { Credentials credentials = new Credentials("idToken", "accessToken", "type", "refreshToken", new Date(), "openid profile"); assertThat(credentials.getScope(), is("openid profile")); } diff --git a/auth0/src/test/java/com/auth0/android/result/DatabaseUserTest.java b/auth0/src/test/java/com/auth0/android/result/DatabaseUserTest.java index 68d501fa2..a59fb6cef 100644 --- a/auth0/src/test/java/com/auth0/android/result/DatabaseUserTest.java +++ b/auth0/src/test/java/com/auth0/android/result/DatabaseUserTest.java @@ -11,22 +11,22 @@ public class DatabaseUserTest { private DatabaseUser databaseUser; @Before - public void setUp() throws Exception { + public void setUp() { databaseUser = new DatabaseUser("email", "username", true); } @Test - public void getEmail() throws Exception { + public void getEmail() { assertThat(databaseUser.getEmail(), is("email")); } @Test - public void getUsername() throws Exception { + public void getUsername() { assertThat(databaseUser.getUsername(), is("username")); } @Test - public void isEmailVerified() throws Exception { + public void isEmailVerified() { assertThat(databaseUser.isEmailVerified(), is(true)); } diff --git a/auth0/src/test/java/com/auth0/android/result/DelegationTest.java b/auth0/src/test/java/com/auth0/android/result/DelegationTest.java index d94938102..d14c489b3 100644 --- a/auth0/src/test/java/com/auth0/android/result/DelegationTest.java +++ b/auth0/src/test/java/com/auth0/android/result/DelegationTest.java @@ -11,22 +11,22 @@ public class DelegationTest { private Delegation delegation; @Before - public void setUp() throws Exception { + public void setUp() { delegation = new Delegation("idToken", "type", 1234567890L); } @Test - public void getIdToken() throws Exception { + public void getIdToken() { assertThat(delegation.getIdToken(), is("idToken")); } @Test - public void getType() throws Exception { + public void getType() { assertThat(delegation.getType(), is("type")); } @Test - public void getExpiresIn() throws Exception { + public void getExpiresIn() { assertThat(delegation.getExpiresIn(), is(1234567890L)); } } \ No newline at end of file diff --git a/auth0/src/test/java/com/auth0/android/result/JsonRequiredTypeAdapterFactoryTest.java b/auth0/src/test/java/com/auth0/android/result/JsonRequiredTypeAdapterFactoryTest.java index 254c2a118..e76d3d45e 100755 --- a/auth0/src/test/java/com/auth0/android/result/JsonRequiredTypeAdapterFactoryTest.java +++ b/auth0/src/test/java/com/auth0/android/result/JsonRequiredTypeAdapterFactoryTest.java @@ -21,14 +21,14 @@ public class JsonRequiredTypeAdapterFactoryTest { Gson gson; @Before - public void setUp() throws Exception { + public void setUp() { gson = new GsonBuilder() .registerTypeAdapterFactory(new JsonRequiredTypeAdapterFactory()) .create(); } @Test - public void shouldThrowExceptionIfMissingFieldIsRequired() throws Exception { + public void shouldThrowExceptionIfMissingFieldIsRequired() { Exception error = null; try { gson.fromJson(missingValue, RequiredClass.class); @@ -41,7 +41,7 @@ public void shouldThrowExceptionIfMissingFieldIsRequired() throws Exception { } @Test - public void shouldNotThrowExceptionIfMissingFieldIsNotRequired() throws Exception { + public void shouldNotThrowExceptionIfMissingFieldIsNotRequired() { NotRequiredClass bean = null; Exception error = null; try { diff --git a/auth0/src/test/java/com/auth0/android/result/UserIdentityTest.java b/auth0/src/test/java/com/auth0/android/result/UserIdentityTest.java index f311e24c4..c244b4b10 100644 --- a/auth0/src/test/java/com/auth0/android/result/UserIdentityTest.java +++ b/auth0/src/test/java/com/auth0/android/result/UserIdentityTest.java @@ -15,43 +15,43 @@ public class UserIdentityTest { private UserIdentity userIdentity; @Before - public void setUp() throws Exception { + public void setUp() { profileInfo = Mockito.mock(Map.class); userIdentity = new UserIdentity("id", "connection", "provider", true, "accessToken", "accessTokenSecret", profileInfo); } @Test - public void getId() throws Exception { + public void getId() { assertThat(userIdentity.getId(), is("id")); } @Test - public void getConnection() throws Exception { + public void getConnection() { assertThat(userIdentity.getConnection(), is("connection")); } @Test - public void getProvider() throws Exception { + public void getProvider() { assertThat(userIdentity.getProvider(), is("provider")); } @Test - public void isSocial() throws Exception { + public void isSocial() { assertThat(userIdentity.isSocial(), is(true)); } @Test - public void getAccessToken() throws Exception { + public void getAccessToken() { assertThat(userIdentity.getAccessToken(), is("accessToken")); } @Test - public void getAccessTokenSecret() throws Exception { + public void getAccessTokenSecret() { assertThat(userIdentity.getAccessTokenSecret(), is("accessTokenSecret")); } @Test - public void getProfileInfo() throws Exception { + public void getProfileInfo() { assertThat(userIdentity.getProfileInfo(), is(profileInfo)); } diff --git a/auth0/src/test/java/com/auth0/android/result/UserProfileTest.java b/auth0/src/test/java/com/auth0/android/result/UserProfileTest.java index 4f42386c4..bedf09e81 100644 --- a/auth0/src/test/java/com/auth0/android/result/UserProfileTest.java +++ b/auth0/src/test/java/com/auth0/android/result/UserProfileTest.java @@ -24,7 +24,7 @@ public class UserProfileTest { private UserProfile userProfile; @Before - public void setUp() throws Exception { + public void setUp() { createdAt = Mockito.mock(Date.class); identities = Mockito.mock(List.class); extraInfo = Mockito.mock(Map.class); @@ -34,82 +34,81 @@ public void setUp() throws Exception { } @Test - public void getId() throws Exception { + public void getId() { assertThat(userProfile.getId(), is("id")); } @SuppressWarnings("unchecked") @Test - public void shouldReturnSubIfMissingId() throws Exception { + public void shouldReturnSubIfMissingId() { Map extraInfo = Collections.singletonMap("sub", "fromSub"); userProfile = new UserProfile(null, null, null, null, null, false, null, null, null, extraInfo, null, null, null); assertThat(userProfile.getId(), is("fromSub")); } - @SuppressWarnings("unchecked") @Test - public void shouldGetNullIdIfMissing() throws Exception { + public void shouldGetNullIdIfMissing() { userProfile = new UserProfile(null, null, null, null, null, false, null, null, null, null, null, null, null); assertThat(userProfile.getId(), is(nullValue())); } @Test - public void getName() throws Exception { + public void getName() { assertThat(userProfile.getName(), is("name")); } @Test - public void getNickname() throws Exception { + public void getNickname() { assertThat(userProfile.getNickname(), is("nickname")); } @Test - public void getEmail() throws Exception { + public void getEmail() { assertThat(userProfile.getEmail(), is("email")); } @Test - public void isEmailVerified() throws Exception { + public void isEmailVerified() { assertThat(userProfile.isEmailVerified(), is(true)); } @Test - public void getPictureURL() throws Exception { + public void getPictureURL() { assertThat(userProfile.getPictureURL(), is("pictureUrl")); } @Test - public void getCreatedAt() throws Exception { + public void getCreatedAt() { assertThat(userProfile.getCreatedAt(), is(createdAt)); } @Test - public void getGivenName() throws Exception { + public void getGivenName() { assertThat(userProfile.getGivenName(), is("givenName")); } @Test - public void getFamilyName() throws Exception { + public void getFamilyName() { assertThat(userProfile.getFamilyName(), is("familyName")); } @Test - public void getUserMetadata() throws Exception { + public void getUserMetadata() { assertThat(userProfile.getUserMetadata(), is(userMetadata)); } @Test - public void getAppMetadata() throws Exception { + public void getAppMetadata() { assertThat(userProfile.getAppMetadata(), is(appMetadata)); } @Test - public void getExtraInfo() throws Exception { + public void getExtraInfo() { assertThat(userProfile.getExtraInfo(), is(extraInfo)); } @Test - public void getIdentities() throws Exception { + public void getIdentities() { assertThat(userProfile.getIdentities(), is(identities)); } diff --git a/auth0/src/test/java/com/auth0/android/util/MockAuthenticationCallback.java b/auth0/src/test/java/com/auth0/android/util/MockAuthenticationCallback.java index bf6fd4193..078ce6b57 100755 --- a/auth0/src/test/java/com/auth0/android/util/MockAuthenticationCallback.java +++ b/auth0/src/test/java/com/auth0/android/util/MockAuthenticationCallback.java @@ -47,7 +47,7 @@ public void onSuccess(T payload) { public Callable error() { return new Callable() { @Override - public AuthenticationException call() throws Exception { + public AuthenticationException call() { return error; } }; @@ -56,7 +56,7 @@ public AuthenticationException call() throws Exception { public Callable payload() { return new Callable() { @Override - public T call() throws Exception { + public T call() { return payload; } }; diff --git a/auth0/src/test/java/com/auth0/android/util/MockBaseCallback.java b/auth0/src/test/java/com/auth0/android/util/MockBaseCallback.java index 9e8d23b9b..02165dacb 100755 --- a/auth0/src/test/java/com/auth0/android/util/MockBaseCallback.java +++ b/auth0/src/test/java/com/auth0/android/util/MockBaseCallback.java @@ -47,7 +47,7 @@ public void onFailure(U error) { public Callable payload() { return new Callable() { @Override - public T call() throws Exception { + public T call() { return payload; } }; @@ -56,7 +56,7 @@ public T call() throws Exception { public Callable error() { return new Callable() { @Override - public U call() throws Exception { + public U call() { return error; } }; diff --git a/auth0/src/test/java/com/auth0/android/util/MockManagementCallback.java b/auth0/src/test/java/com/auth0/android/util/MockManagementCallback.java index 110f06b06..752fdb957 100755 --- a/auth0/src/test/java/com/auth0/android/util/MockManagementCallback.java +++ b/auth0/src/test/java/com/auth0/android/util/MockManagementCallback.java @@ -47,7 +47,7 @@ public void onSuccess(T payload) { public Callable error() { return new Callable() { @Override - public ManagementException call() throws Exception { + public ManagementException call() { return error; } }; @@ -56,7 +56,7 @@ public ManagementException call() throws Exception { public Callable payload() { return new Callable() { @Override - public T call() throws Exception { + public T call() { return payload; } }; diff --git a/auth0/src/test/java/com/auth0/android/util/TelemetryTest.java b/auth0/src/test/java/com/auth0/android/util/TelemetryTest.java index 391c100be..751a0c838 100755 --- a/auth0/src/test/java/com/auth0/android/util/TelemetryTest.java +++ b/auth0/src/test/java/com/auth0/android/util/TelemetryTest.java @@ -25,7 +25,7 @@ public class TelemetryTest { @Test @Config(sdk = 21) - public void shouldAlwaysIncludeAndroidVersionAPI21() throws Exception { + public void shouldAlwaysIncludeAndroidVersionAPI21() { Telemetry telemetry = new Telemetry("auth0-java", null); assertThat(telemetry.getEnvironment(), is(notNullValue())); assertThat(telemetry.getEnvironment().get("android"), is("21")); @@ -33,40 +33,40 @@ public void shouldAlwaysIncludeAndroidVersionAPI21() throws Exception { @Test @Config(sdk = 23) - public void shouldAlwaysIncludeAndroidVersionAPI23() throws Exception { + public void shouldAlwaysIncludeAndroidVersionAPI23() { Telemetry telemetry = new Telemetry("auth0-java", null); assertThat(telemetry.getEnvironment(), is(notNullValue())); assertThat(telemetry.getEnvironment().get("android"), is("23")); } @Test - public void shouldNotAcceptNullName() throws Exception { + public void shouldNotAcceptNullName() { Telemetry telemetry = new Telemetry(null, null); assertThat(telemetry.getValue(), is(nullValue())); assertThat(telemetry.getEnvironment(), is(notNullValue())); } @Test - public void shouldNotIncludeLibraryVersionIfNotProvided() throws Exception { + public void shouldNotIncludeLibraryVersionIfNotProvided() { Telemetry telemetry = new Telemetry(null, null); assertThat(telemetry.getEnvironment(), is(notNullValue())); assertThat(telemetry.getEnvironment().containsKey("auth0.android"), is(false)); } @Test - public void shouldGetName() throws Exception { + public void shouldGetName() { Telemetry telemetry = new Telemetry("auth0-java", "1.0.0", "1.2.3"); assertThat(telemetry.getName(), is("auth0-java")); } @Test - public void shouldGetVersion() throws Exception { + public void shouldGetVersion() { Telemetry telemetry = new Telemetry("auth0-java", "1.0.0", "1.2.3"); assertThat(telemetry.getVersion(), is("1.0.0")); } @Test - public void shouldGetLibraryVersion() throws Exception { + public void shouldGetLibraryVersion() { Telemetry telemetry = new Telemetry("auth0-java", "1.0.0", "1.2.3"); assertThat(telemetry.getLibraryVersion(), is("1.2.3")); assertThat(telemetry.getEnvironment().get("auth0.android"), is("1.2.3"));