Skip to content

Commit

Permalink
Merge pull request #330 from auth0/remove-unneeded-throws-from-tests
Browse files Browse the repository at this point in the history
Remove unnecessary throws from tests
  • Loading branch information
lbalmaceda authored Feb 5, 2021
2 parents 33ace7c + 666f2d2 commit eb1d2be
Show file tree
Hide file tree
Showing 45 changed files with 317 additions and 317 deletions.
96 changes: 48 additions & 48 deletions src/test/java/com/auth0/client/auth/AuthAPITest.java

Large diffs are not rendered by default.

46 changes: 23 additions & 23 deletions src/test/java/com/auth0/client/auth/AuthorizeUrlBuilderTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,61 +23,61 @@ public class AuthorizeUrlBuilderTest {
public ExpectedException exception = ExpectedException.none();

@Test
public void shouldThrowWhenBaseUrlIsNull() throws Exception {
public void shouldThrowWhenBaseUrlIsNull() {
exception.expect(IllegalArgumentException.class);
exception.expectMessage("'base url' cannot be null!");
AuthorizeUrlBuilder.newInstance(null, CLIENT_ID, REDIRECT_URI);
}

@Test
public void shouldThrowWhenRedirectUriIsNull() throws Exception {
public void shouldThrowWhenRedirectUriIsNull() {
exception.expect(IllegalArgumentException.class);
exception.expectMessage("'redirect uri' cannot be null!");
AuthorizeUrlBuilder.newInstance(DOMAIN, CLIENT_ID, null);
}

@Test
public void shouldThrowWhenClientIdIsNull() throws Exception {
public void shouldThrowWhenClientIdIsNull() {
exception.expect(IllegalArgumentException.class);
exception.expectMessage("'client id' cannot be null!");
AuthorizeUrlBuilder.newInstance(DOMAIN, null, REDIRECT_URI);
}

@Test
public void shouldGetNewInstance() throws Exception {
public void shouldGetNewInstance() {
AuthorizeUrlBuilder instance = AuthorizeUrlBuilder.newInstance(DOMAIN, CLIENT_ID, REDIRECT_URI);
assertThat(instance, is(notNullValue()));
}

@Test
public void shouldBuildValidAuthorizeUrlWithHttp() throws Exception {
public void shouldBuildValidAuthorizeUrlWithHttp() {
HttpUrl httpBaseUrl = HttpUrl.parse("http://domain.auth0.com");
String url = AuthorizeUrlBuilder.newInstance(httpBaseUrl, CLIENT_ID, REDIRECT_URI).build();
assertThat(url, isUrl("http", "domain.auth0.com", "/authorize"));
}

@Test
public void shouldBuildValidAuthorizeUrlWithHttps() throws Exception {
public void shouldBuildValidAuthorizeUrlWithHttps() {
HttpUrl httpsBaseUrl = HttpUrl.parse("https://domain.auth0.com");
String url = AuthorizeUrlBuilder.newInstance(httpsBaseUrl, CLIENT_ID, REDIRECT_URI).build();
assertThat(url, isUrl("https", "domain.auth0.com", "/authorize"));
}

@Test
public void shouldAddResponseTypeCode() throws Exception {
public void shouldAddResponseTypeCode() {
String url = AuthorizeUrlBuilder.newInstance(DOMAIN, CLIENT_ID, REDIRECT_URI).build();
assertThat(url, hasQueryParameter("response_type", "code"));
}

@Test
public void shouldAddClientId() throws Exception {
public void shouldAddClientId() {
String url = AuthorizeUrlBuilder.newInstance(DOMAIN, CLIENT_ID, REDIRECT_URI).build();
assertThat(url, hasQueryParameter("client_id", CLIENT_ID));

}

@Test
public void shouldAddRedirectUri() throws Exception {
public void shouldAddRedirectUri() {
String url = AuthorizeUrlBuilder.newInstance(DOMAIN, CLIENT_ID, REDIRECT_URI).build();
assertThat(url, hasQueryParameter("redirect_uri", REDIRECT_URI));
}
Expand All @@ -90,106 +90,106 @@ public void shouldNotEncodeTwiceTheRedirectUri() throws Exception {
}

@Test
public void shouldSetConnection() throws Exception {
public void shouldSetConnection() {
String url = AuthorizeUrlBuilder.newInstance(DOMAIN, CLIENT_ID, REDIRECT_URI)
.withConnection("my-connection")
.build();
assertThat(url, hasQueryParameter("connection", "my-connection"));
}

@Test
public void shouldThrowWhenConnectionIsNull() throws Exception {
public void shouldThrowWhenConnectionIsNull() {
exception.expect(IllegalArgumentException.class);
exception.expectMessage("'connection' cannot be null!");
AuthorizeUrlBuilder.newInstance(DOMAIN, CLIENT_ID, REDIRECT_URI)
.withConnection(null);
}

@Test
public void shouldSetAudience() throws Exception {
public void shouldSetAudience() {
String url = AuthorizeUrlBuilder.newInstance(DOMAIN, CLIENT_ID, REDIRECT_URI)
.withAudience("https://myapi.domain.com/users")
.build();
assertThat(url, hasQueryParameter("audience", "https://myapi.domain.com/users"));
}

@Test
public void shouldThrowWhenAudienceIsNull() throws Exception {
public void shouldThrowWhenAudienceIsNull() {
exception.expect(IllegalArgumentException.class);
exception.expectMessage("'audience' cannot be null!");
AuthorizeUrlBuilder.newInstance(DOMAIN, CLIENT_ID, REDIRECT_URI)
.withAudience(null);
}

@Test
public void shouldSetState() throws Exception {
public void shouldSetState() {
String url = AuthorizeUrlBuilder.newInstance(DOMAIN, CLIENT_ID, REDIRECT_URI)
.withState("1234567890")
.build();
assertThat(url, hasQueryParameter("state", "1234567890"));
}

@Test
public void shouldThrowWhenStateIsNull() throws Exception {
public void shouldThrowWhenStateIsNull() {
exception.expect(IllegalArgumentException.class);
exception.expectMessage("'state' cannot be null!");
AuthorizeUrlBuilder.newInstance(DOMAIN, CLIENT_ID, REDIRECT_URI)
.withState(null);
}

@Test
public void shouldSetScope() throws Exception {
public void shouldSetScope() {
String url = AuthorizeUrlBuilder.newInstance(DOMAIN, CLIENT_ID, REDIRECT_URI)
.withScope("profile email contacts")
.build();
assertThat(url, hasQueryParameter("scope", "profile email contacts"));
}

@Test
public void shouldThrowWhenScopeIsNull() throws Exception {
public void shouldThrowWhenScopeIsNull() {
exception.expect(IllegalArgumentException.class);
exception.expectMessage("'scope' cannot be null!");
AuthorizeUrlBuilder.newInstance(DOMAIN, CLIENT_ID, REDIRECT_URI)
.withScope(null);
}

@Test
public void shouldSetResponseType() throws Exception {
public void shouldSetResponseType() {
String url = AuthorizeUrlBuilder.newInstance(DOMAIN, CLIENT_ID, REDIRECT_URI)
.withResponseType("token id_token")
.build();
assertThat(url, hasQueryParameter("response_type", "token id_token"));
}

@Test
public void shouldThrowWhenResponseTypeIsNull() throws Exception {
public void shouldThrowWhenResponseTypeIsNull() {
exception.expect(IllegalArgumentException.class);
exception.expectMessage("'response type' cannot be null!");
AuthorizeUrlBuilder.newInstance(DOMAIN, CLIENT_ID, REDIRECT_URI)
.withResponseType(null);
}

@Test
public void shouldSetCustomParameter() throws Exception {
public void shouldSetCustomParameter() {
String url = AuthorizeUrlBuilder.newInstance(DOMAIN, CLIENT_ID, REDIRECT_URI)
.withParameter("name", "value")
.build();
assertThat(url, hasQueryParameter("name", "value"));
}

@Test
public void shouldThrowWhenCustomParameterNameIsNull() throws Exception {
public void shouldThrowWhenCustomParameterNameIsNull() {
exception.expect(IllegalArgumentException.class);
exception.expectMessage("'name' cannot be null!");
AuthorizeUrlBuilder.newInstance(DOMAIN, CLIENT_ID, REDIRECT_URI)
.withParameter(null, "value");
}

@Test
public void shouldThrowWhenCustomParameterValueIsNull() throws Exception {
public void shouldThrowWhenCustomParameterValueIsNull() {
exception.expect(IllegalArgumentException.class);
exception.expectMessage("'value' cannot be null!");
AuthorizeUrlBuilder.newInstance(DOMAIN, CLIENT_ID, REDIRECT_URI)
.withParameter("name", null);
}
}
}
24 changes: 12 additions & 12 deletions src/test/java/com/auth0/client/auth/LogoutUrlBuilderTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,46 +23,46 @@ public class LogoutUrlBuilderTest {
public ExpectedException exception = ExpectedException.none();

@Test
public void shouldThrowWhenBaseUrlIsNull() throws Exception {
public void shouldThrowWhenBaseUrlIsNull() {
exception.expect(IllegalArgumentException.class);
exception.expectMessage("'base url' cannot be null!");
LogoutUrlBuilder.newInstance(null, CLIENT_ID, RETURN_TO_URL, true);
}

@Test
public void shouldThrowWhenReturnToURLIsNull() throws Exception {
public void shouldThrowWhenReturnToURLIsNull() {
exception.expect(IllegalArgumentException.class);
exception.expectMessage("'return to url' cannot be null!");
LogoutUrlBuilder.newInstance(DOMAIN, CLIENT_ID, null, true);
}

@Test
public void shouldNotThrowWhenClientIdIsNull() throws Exception {
public void shouldNotThrowWhenClientIdIsNull() {
LogoutUrlBuilder.newInstance(DOMAIN, null, RETURN_TO_URL, true);
}

@Test
public void shouldGetNewInstance() throws Exception {
public void shouldGetNewInstance() {
LogoutUrlBuilder instance = LogoutUrlBuilder.newInstance(DOMAIN, CLIENT_ID, RETURN_TO_URL, true);
assertThat(instance, is(notNullValue()));
}

@Test
public void shouldBuildValidLogoutUrlWithHttp() throws Exception {
public void shouldBuildValidLogoutUrlWithHttp() {
HttpUrl httpBaseUrl = HttpUrl.parse("http://domain.auth0.com");
String url = LogoutUrlBuilder.newInstance(httpBaseUrl, CLIENT_ID, RETURN_TO_URL, true).build();
assertThat(url, isUrl("http", "domain.auth0.com", "/v2/logout"));
}

@Test
public void shouldBuildValidLogoutUrlWithHttps() throws Exception {
public void shouldBuildValidLogoutUrlWithHttps() {
HttpUrl httpsBaseUrl = HttpUrl.parse("https://domain.auth0.com");
String url = LogoutUrlBuilder.newInstance(httpsBaseUrl, CLIENT_ID, RETURN_TO_URL, true).build();
assertThat(url, isUrl("https", "domain.auth0.com", "/v2/logout"));
}

@Test
public void shouldAddReturnToURL() throws Exception {
public void shouldAddReturnToURL() {
String url = LogoutUrlBuilder.newInstance(DOMAIN, CLIENT_ID, RETURN_TO_URL, true).build();
assertThat(url, hasQueryParameter("returnTo", RETURN_TO_URL));
}
Expand All @@ -75,31 +75,31 @@ public void shouldNotEncodeTwiceTheReturnToURL() throws Exception {
}

@Test
public void shouldNotAddClientId() throws Exception {
public void shouldNotAddClientId() {
String url = LogoutUrlBuilder.newInstance(DOMAIN, CLIENT_ID, RETURN_TO_URL, false).build();
assertThat(url, hasQueryParameter("client_id", null));
}

@Test
public void shouldAddClientId() throws Exception {
public void shouldAddClientId() {
String url = LogoutUrlBuilder.newInstance(DOMAIN, CLIENT_ID, RETURN_TO_URL, true).build();
assertThat(url, hasQueryParameter("client_id", CLIENT_ID));
}

@Test
public void shouldUseFederated() throws Exception {
public void shouldUseFederated() {
String url = LogoutUrlBuilder.newInstance(DOMAIN, CLIENT_ID, RETURN_TO_URL, true)
.useFederated(true)
.build();
assertThat(url, hasQueryParameter("federated", ""));
}

@Test
public void shouldNotUseFederated() throws Exception {
public void shouldNotUseFederated() {
String url = LogoutUrlBuilder.newInstance(DOMAIN, CLIENT_ID, RETURN_TO_URL, true)
.useFederated(false)
.build();
assertThat(url, hasQueryParameter("federated", null));
}

}
}
4 changes: 2 additions & 2 deletions src/test/java/com/auth0/client/mgmt/BlacklistsEntityTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
public class BlacklistsEntityTest extends BaseMgmtEntityTest {

@Test
public void shouldThrowOnGetBlacklistedTokensWithNullAudience() throws Exception {
public void shouldThrowOnGetBlacklistedTokensWithNullAudience() {
exception.expect(IllegalArgumentException.class);
exception.expectMessage("'audience' cannot be null!");
api.blacklists().getBlacklist(null);
Expand Down Expand Up @@ -53,7 +53,7 @@ public void shouldReturnEmptyBlacklistedTokens() throws Exception {
}

@Test
public void shouldThrowOnBlacklistTokensWithNullToken() throws Exception {
public void shouldThrowOnBlacklistTokensWithNullToken() {
exception.expect(IllegalArgumentException.class);
exception.expectMessage("'token' cannot be null!");
api.blacklists().blacklistToken(null);
Expand Down
12 changes: 6 additions & 6 deletions src/test/java/com/auth0/client/mgmt/ClientGrantsEntityTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -133,21 +133,21 @@ public void shouldReturnEmptyClientGrants() throws Exception {
}

@Test
public void shouldThrowOnCreateClientGrantWithNullClientId() throws Exception {
public void shouldThrowOnCreateClientGrantWithNullClientId() {
exception.expect(IllegalArgumentException.class);
exception.expectMessage("'client id' cannot be null!");
api.clientGrants().create(null, "audience", new String[]{"openid"});
}

@Test
public void shouldThrowOnCreateClientGrantWithNullAudience() throws Exception {
public void shouldThrowOnCreateClientGrantWithNullAudience() {
exception.expect(IllegalArgumentException.class);
exception.expectMessage("'audience' cannot be null!");
api.clientGrants().create("clientId", null, new String[]{"openid"});
}

@Test
public void shouldThrowOnCreateClientGrantWithNullScope() throws Exception {
public void shouldThrowOnCreateClientGrantWithNullScope() {
exception.expect(IllegalArgumentException.class);
exception.expectMessage("'scope' cannot be null!");
api.clientGrants().create("clientId", "audience", null);
Expand Down Expand Up @@ -177,7 +177,7 @@ public void shouldCreateClientGrant() throws Exception {
}

@Test
public void shouldThrowOnDeleteClientGrantWithNullId() throws Exception {
public void shouldThrowOnDeleteClientGrantWithNullId() {
exception.expect(IllegalArgumentException.class);
exception.expectMessage("'client grant id' cannot be null!");
api.clientGrants().delete(null);
Expand All @@ -198,14 +198,14 @@ public void shouldDeleteClientGrant() throws Exception {
}

@Test
public void shouldThrowOnUpdateClientGrantWithNullId() throws Exception {
public void shouldThrowOnUpdateClientGrantWithNullId() {
exception.expect(IllegalArgumentException.class);
exception.expectMessage("'client grant id' cannot be null!");
api.clientGrants().update(null, new String[]{});
}

@Test
public void shouldThrowOnUpdateClientGrantWithNullScope() throws Exception {
public void shouldThrowOnUpdateClientGrantWithNullScope() {
exception.expect(IllegalArgumentException.class);
exception.expectMessage("'scope' cannot be null!");
api.clientGrants().update("clientGrantId", null);
Expand Down
Loading

0 comments on commit eb1d2be

Please sign in to comment.