]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-4443 The wsclient class PropertyCreateQuery can not be used to create properties
authorSimon Brandhof <simon.brandhof@gmail.com>
Wed, 26 Jun 2013 10:38:33 +0000 (12:38 +0200)
committerSimon Brandhof <simon.brandhof@gmail.com>
Wed, 26 Jun 2013 10:38:42 +0000 (12:38 +0200)
sonar-server/src/main/webapp/WEB-INF/app/controllers/api/properties_controller.rb
sonar-ws-client/src/main/java/org/sonar/wsclient/services/PropertyCreateQuery.java
sonar-ws-client/src/main/java/org/sonar/wsclient/services/PropertyQuery.java
sonar-ws-client/src/test/java/org/sonar/wsclient/services/PropertyCreateQueryTest.java
sonar-ws-client/src/test/java/org/sonar/wsclient/services/PropertyQueryTest.java

index e1feb9bfd87b150768ac5f7f49680573b4ed14dd..b0f0a97aa9643e5fdf77c3e8780de856278d9476 100644 (file)
@@ -82,12 +82,12 @@ class Api::PropertiesController < Api::ApiController
     end
   end
 
-  # curl -u admin:admin -v -X PUT http://localhost:9000/api/properties/foo?value=bar[&resource=<resource>]
+  # curl -u admin:admin -v -X POST http://localhost:9000/api/properties/foo?value=bar[&resource=<resource>]
   def create
     update
   end
 
-  # curl -u admin:admin -v -X POST http://localhost:9000/api/properties/foo?value=bar[&resource=<resource>]
+  # curl -u admin:admin -v -X PUT http://localhost:9000/api/properties/foo?value=bar[&resource=<resource>]
   def update
     key = params[:id]
     bad_request('missing key') unless key.present?
index 9572bb396167cdc72beea7681cfd92813ce3f67e..406b5205b3e142282d31aa70ce9dc8aef6b88fcc 100644 (file)
@@ -78,8 +78,7 @@ public class PropertyCreateQuery extends CreateQuery<Property> {
   public String getUrl() {
     StringBuilder url = new StringBuilder();
     url.append(PropertyQuery.BASE_URL);
-    url.append("/").append(encode(key));
-    url.append('?');
+    url.append("?id=").append(encode(key)).append("&");
     appendUrlParameter(url, "value", value);
     appendUrlParameter(url, "resource", resourceKeyOrId);
     return url.toString();
index 5e2abc4547fe5991637422e4690088b9fe0f1698..3fee1d82af951c0126b8bda1767590b06db44dff 100644 (file)
@@ -46,10 +46,10 @@ public class PropertyQuery extends Query<Property> {
   @Override
   public String getUrl() {
     StringBuilder url = new StringBuilder(BASE_URL);
+    url.append('?');
     if (key != null) {
-      url.append("/").append(encode(key));
+      url.append("id=").append(encode(key)).append("&");
     }
-    url.append('?');
     appendUrlParameter(url, "resource", resourceKeyOrId);
     return url.toString();
   }
index 7a4c710fd1854390fba47e89a565ffdc69eeb853..b72e2e86b877704a751e9cfadb69c38b99998282 100644 (file)
@@ -29,14 +29,14 @@ public class PropertyCreateQueryTest extends QueryTestCase {
   @Test
   public void create() {
     PropertyCreateQuery query = new PropertyCreateQuery("foo", "bar");
-    assertThat(query.getUrl(), is("/api/properties/foo?value=bar&"));
+    assertThat(query.getUrl(), is("/api/properties?id=foo&value=bar&"));
     assertThat(query.getModelClass().getName(), is(Property.class.getName()));
   }
 
   @Test
   public void createForResource() {
     PropertyCreateQuery query = new PropertyCreateQuery("foo", "bar", "my:resource");
-    assertThat(query.getUrl(), is("/api/properties/foo?value=bar&resource=my%3Aresource&"));
+    assertThat(query.getUrl(), is("/api/properties?id=foo&value=bar&resource=my%3Aresource&"));
     assertThat(query.getModelClass().getName(), is(Property.class.getName()));
   }
 }
\ No newline at end of file
index fef66ec465827fa8e2b9c1927bceaa05a5b55d25..52d51e16154274c3c8f4ef5525ef1630514a1342 100644 (file)
@@ -43,14 +43,14 @@ public class PropertyQueryTest extends QueryTestCase {
   @Test
   public void test_global_property() {
     PropertyQuery query = PropertyQuery.createForKey("myprop");
-    assertThat(query.getUrl(), is("/api/properties/myprop?"));
+    assertThat(query.getUrl(), is("/api/properties?id=myprop&"));
     assertThat(query.getModelClass().getName(), is(Property.class.getName()));
   }
 
   @Test
   public void test_project_property() {
     PropertyQuery query = PropertyQuery.createForResource("myprop", "my:resource");
-    assertThat(query.getUrl(), is("/api/properties/myprop?resource=my%3Aresource&"));
+    assertThat(query.getUrl(), is("/api/properties?id=myprop&resource=my%3Aresource&"));
     assertThat(query.getModelClass().getName(), is(Property.class.getName()));
   }
 }