From: Godin Date: Tue, 7 Dec 2010 10:47:02 +0000 (+0000) Subject: SONAR-2024: Fix operations with generic types X-Git-Tag: 2.6~374 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=a02e4a3754fd80a0ee47fa1349e017d1da1aec59;p=sonarqube.git SONAR-2024: Fix operations with generic types --- diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/Sonar.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/Sonar.java index 22acd92d2f4..99cd619b958 100644 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/Sonar.java +++ b/sonar-ws-client/src/main/java/org/sonar/wsclient/Sonar.java @@ -76,7 +76,7 @@ public class Sonar { return result; } - public void delete(DeleteQuery query) { + public void delete(DeleteQuery query) { connector.execute(query); } diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/connectors/Connector.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/connectors/Connector.java index f6c7f1477b3..48599874db4 100644 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/connectors/Connector.java +++ b/sonar-ws-client/src/main/java/org/sonar/wsclient/connectors/Connector.java @@ -34,18 +34,18 @@ public abstract class Connector { * @return JSON response or null if 404 NOT FOUND error * @throws ConnectionException if connection error or HTTP status not in (200, 404) */ - public abstract String execute(Query query); + public abstract String execute(Query query); /** * @return JSON response or null if 404 NOT FOUND error * @since 2.2 */ - public abstract String execute(CreateQuery query); + public abstract String execute(CreateQuery query); /** * @return JSON response or null if 404 NOT FOUND error * @since 2.2 */ - public abstract String execute(DeleteQuery query); + public abstract String execute(DeleteQuery query); } diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/connectors/HttpClient3Connector.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/connectors/HttpClient3Connector.java index da660d1eb27..e3b2619549e 100644 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/connectors/HttpClient3Connector.java +++ b/sonar-ws-client/src/main/java/org/sonar/wsclient/connectors/HttpClient3Connector.java @@ -77,15 +77,15 @@ public class HttpClient3Connector extends Connector { } } - public String execute(Query query) { + public String execute(Query query) { return executeRequest(newGetRequest(query)); } - public String execute(CreateQuery query) { + public String execute(CreateQuery query) { return executeRequest(newPostRequest(query)); } - public String execute(DeleteQuery query) { + public String execute(DeleteQuery query) { return executeRequest(newDeleteRequest(query)); } @@ -114,7 +114,7 @@ public class HttpClient3Connector extends Connector { return json; } - private HttpMethodBase newGetRequest(Query query) { + private HttpMethodBase newGetRequest(Query query) { try { String url = server.getHost() + URIUtil.encodeQuery(query.getUrl()); HttpMethodBase method = new GetMethod(url); @@ -126,7 +126,7 @@ public class HttpClient3Connector extends Connector { } } - private HttpMethodBase newPostRequest(CreateQuery query) { + private HttpMethodBase newPostRequest(CreateQuery query) { try { String url = server.getHost() + URIUtil.encodeQuery(query.getUrl()); HttpMethodBase method = new PostMethod(url); @@ -138,7 +138,7 @@ public class HttpClient3Connector extends Connector { } } - private HttpMethodBase newDeleteRequest(DeleteQuery query) { + private HttpMethodBase newDeleteRequest(DeleteQuery query) { try { String url = server.getHost() + URIUtil.encodeQuery(query.getUrl()); HttpMethodBase method = new DeleteMethod(url); diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/connectors/HttpClient4Connector.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/connectors/HttpClient4Connector.java index 73d1d15630f..9bb556cf5fa 100644 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/connectors/HttpClient4Connector.java +++ b/sonar-ws-client/src/main/java/org/sonar/wsclient/connectors/HttpClient4Connector.java @@ -53,15 +53,15 @@ public class HttpClient4Connector extends Connector { this.server = server; } - public String execute(Query query) { + public String execute(Query query) { return executeRequest(newGetMethod(query)); } - public String execute(CreateQuery query) { + public String execute(CreateQuery query) { return executeRequest(newPostMethod(query)); } - public String execute(DeleteQuery query) { + public String execute(DeleteQuery query) { return executeRequest(newDeleteMethod(query)); } @@ -116,19 +116,19 @@ public class HttpClient4Connector extends Connector { return localcontext; } - private HttpGet newGetMethod(Query query) { + private HttpGet newGetMethod(Query query) { HttpGet get = new HttpGet(server.getHost() + query.getUrl()); setJsonHeader(get); return get; } - private HttpDelete newDeleteMethod(DeleteQuery query) { + private HttpDelete newDeleteMethod(DeleteQuery query) { HttpDelete delete = new HttpDelete(server.getHost() + query.getUrl()); setJsonHeader(delete); return delete; } - private HttpPost newPostMethod(CreateQuery query) { + private HttpPost newPostMethod(CreateQuery query) { HttpPost post = new HttpPost(server.getHost() + query.getUrl()); setJsonHeader(post); return post; @@ -145,7 +145,7 @@ public class HttpClient4Connector extends Connector { AuthState authState = (AuthState) context.getAttribute(ClientContext.TARGET_AUTH_STATE); - // If no auth scheme avaialble yet, try to initialize it preemptively + // If no auth scheme available yet, try to initialize it preemptively if (authState.getAuthScheme() == null) { AuthScheme authScheme = (AuthScheme) context.getAttribute("preemptive-auth"); CredentialsProvider credsProvider = (CredentialsProvider) context.getAttribute(ClientContext.CREDS_PROVIDER); @@ -164,4 +164,4 @@ public class HttpClient4Connector extends Connector { } } } -} \ No newline at end of file +} diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/FavouriteDeleteQuery.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/services/FavouriteDeleteQuery.java index 00af7895cd3..f11702f587d 100644 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/FavouriteDeleteQuery.java +++ b/sonar-ws-client/src/main/java/org/sonar/wsclient/services/FavouriteDeleteQuery.java @@ -19,7 +19,7 @@ */ package org.sonar.wsclient.services; -public class FavouriteDeleteQuery extends DeleteQuery { +public class FavouriteDeleteQuery extends DeleteQuery { private String idOrKey; diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/UserPropertyDeleteQuery.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/services/UserPropertyDeleteQuery.java index 1f4defd58b2..4d3a3161539 100644 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/UserPropertyDeleteQuery.java +++ b/sonar-ws-client/src/main/java/org/sonar/wsclient/services/UserPropertyDeleteQuery.java @@ -22,7 +22,7 @@ package org.sonar.wsclient.services; /** * @since 2.2 */ -public class UserPropertyDeleteQuery extends DeleteQuery { +public class UserPropertyDeleteQuery extends DeleteQuery { private String key; diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/unmarshallers/JsonUtils.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/unmarshallers/JsonUtils.java index 598812dc7e7..1df2dded901 100644 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/unmarshallers/JsonUtils.java +++ b/sonar-ws-client/src/main/java/org/sonar/wsclient/unmarshallers/JsonUtils.java @@ -24,6 +24,8 @@ import java.text.SimpleDateFormat; import java.util.Date; import java.util.Map; +// Godin: we will use raw types here, because typically JSONObject passed as an argument +@SuppressWarnings("rawtypes") public final class JsonUtils { private JsonUtils() { @@ -49,7 +51,7 @@ public final class JsonUtils { public static Boolean getBoolean(Map obj, String field) { Object value = obj.get(field); if (value != null) { - return (Boolean)value; + return (Boolean) value; } return null; } diff --git a/sonar-ws-client/src/test/java/org/sonar/wsclient/services/ResourceQueryTest.java b/sonar-ws-client/src/test/java/org/sonar/wsclient/services/ResourceQueryTest.java index 4c180bd240f..6581518d4bf 100644 --- a/sonar-ws-client/src/test/java/org/sonar/wsclient/services/ResourceQueryTest.java +++ b/sonar-ws-client/src/test/java/org/sonar/wsclient/services/ResourceQueryTest.java @@ -41,7 +41,7 @@ public class ResourceQueryTest { query.setMetrics("loc", "coverage", "lines"); assertThat(query.getUrl(), is("/api/resources?metrics=loc,coverage,lines&verbose=false&")); assertThat(query.getResourceKeyOrId(), nullValue()); - assertThat(query.getMetrics(), is(new String[]{"loc", "coverage", "lines"})); + assertThat(query.getMetrics(), is(new String[] { "loc", "coverage", "lines" })); } @Test @@ -62,7 +62,7 @@ public class ResourceQueryTest { @Test public void measuresOnRulePriorities() { ResourceQuery query = new ResourceQuery().setMetrics("violations"); - query.setRulePriorities("MAJOR,MINOR"); + query.setRuleSeverities("MAJOR,MINOR"); assertThat(query.getUrl(), is("/api/resources?metrics=violations&rule_priorities=MAJOR,MINOR&verbose=false&")); } @@ -71,6 +71,6 @@ public class ResourceQueryTest { public void build() { ResourceQuery query = ResourceQuery.createForMetrics("org.foo", "ncloc", "lines"); assertThat(query.getResourceKeyOrId(), is("org.foo")); - assertThat(query.getMetrics(), is(new String[]{"ncloc", "lines"})); + assertThat(query.getMetrics(), is(new String[] { "ncloc", "lines" })); } }