return result;
}
- public void delete(DeleteQuery query) {
+ public void delete(DeleteQuery<?> query) {
connector.execute(query);
}
* @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);
}
}
}
- 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));
}
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);
}
}
- private HttpMethodBase newPostRequest(CreateQuery query) {
+ private HttpMethodBase newPostRequest(CreateQuery<?> query) {
try {
String url = server.getHost() + URIUtil.encodeQuery(query.getUrl());
HttpMethodBase method = new PostMethod(url);
}
}
- private HttpMethodBase newDeleteRequest(DeleteQuery query) {
+ private HttpMethodBase newDeleteRequest(DeleteQuery<?> query) {
try {
String url = server.getHost() + URIUtil.encodeQuery(query.getUrl());
HttpMethodBase method = new DeleteMethod(url);
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));
}
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;
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);
}
}
}
-}
\ No newline at end of file
+}
*/
package org.sonar.wsclient.services;
-public class FavouriteDeleteQuery extends DeleteQuery {
+public class FavouriteDeleteQuery extends DeleteQuery<Favourite> {
private String idOrKey;
/**
* @since 2.2
*/
-public class UserPropertyDeleteQuery extends DeleteQuery {
+public class UserPropertyDeleteQuery extends DeleteQuery<Property> {
private String key;
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() {
public static Boolean getBoolean(Map obj, String field) {
Object value = obj.get(field);
if (value != null) {
- return (Boolean)value;
+ return (Boolean) value;
}
return null;
}
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
@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&"));
}
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" }));
}
}