]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-6383 SONAR-6376 remove url object from JSON response 234/head
authorSébastien Lesaint <sebastien.lesaint@sonarsource.com>
Mon, 20 Apr 2015 13:02:18 +0000 (15:02 +0200)
committerSébastien Lesaint <sebastien.lesaint@sonarsource.com>
Tue, 21 Apr 2015 07:26:34 +0000 (09:26 +0200)
we should use a flat structure as much as possible

server/sonar-server/src/main/java/org/sonar/server/plugins/ws/PluginWSCommons.java
server/sonar-server/src/main/resources/org/sonar/server/plugins/ws/example-installed_plugins.json
server/sonar-server/src/main/resources/org/sonar/server/plugins/ws/example-pending_plugins.json
server/sonar-server/src/test/java/org/sonar/server/plugins/ws/InstalledPluginsWsActionTest.java
server/sonar-server/src/test/java/org/sonar/server/plugins/ws/PendingPluginsWsActionTest.java
server/sonar-server/src/test/java/org/sonar/server/plugins/ws/PluginWSCommonsTest.java

index 65cee10963d070a6c3674714436c343160cf5a68..4a81554765c7ed20555d8dd72bf5a5aca0c9c0c4 100644 (file)
@@ -36,9 +36,8 @@ public class PluginWSCommons {
   static final String PROPERTY_ORGANIZATION_URL = "organizationUrl";
   static final String PROPERTY_DATE = "date";
   static final String PROPERTY_STATUS = "status";
-  static final String OBJECT_URLS = "urls";
   static final String PROPERTY_HOMEPAGE = "homepage";
-  static final String PROPERTY_ISSUE_TRACKER = "issueTracker";
+  static final String PROPERTY_ISSUE_TRACKER_URL = "issueTrackerUrl";
   static final String OBJECT_ARTIFACT = "artifact";
   static final String PROPERTY_URL = "url";
   static final String PROPERTY_TERMS_AND_CONDITIONS_URL = "termsAndConditionsUrl";
@@ -52,8 +51,6 @@ public class PluginWSCommons {
 
     writeMetadata(jsonWriter, pluginMetadata);
 
-    writeUrls(jsonWriter, pluginMetadata);
-
     writeArtifact(jsonWriter, pluginMetadata);
 
     jsonWriter.endObject();
@@ -67,14 +64,8 @@ public class PluginWSCommons {
     jsonWriter.prop(PROPERTY_LICENSE, pluginMetadata.getLicense());
     jsonWriter.prop(PROPERTY_ORGANIZATION_NAME, pluginMetadata.getOrganization());
     jsonWriter.prop(PROPERTY_ORGANIZATION_URL, pluginMetadata.getOrganizationUrl());
-  }
-
-  public void writeUrls(JsonWriter jsonWriter, PluginMetadata pluginMetadata) {
-    jsonWriter.name(OBJECT_URLS);
-    jsonWriter.beginObject();
     jsonWriter.prop(PROPERTY_HOMEPAGE, pluginMetadata.getHomepage());
-    jsonWriter.prop(PROPERTY_ISSUE_TRACKER, pluginMetadata.getIssueTrackerUrl());
-    jsonWriter.endObject();
+    jsonWriter.prop(PROPERTY_ISSUE_TRACKER_URL, pluginMetadata.getIssueTrackerUrl());
   }
 
   public void writeArtifact(JsonWriter jsonWriter, PluginMetadata pluginMetadata) {
index ed3b0f7481630f296dd1b1a47d6728d531f2aee5..4ae7034f0b2966980c6ac6b41822d88e54ebc9be 100644 (file)
@@ -8,10 +8,8 @@
       "license": "GNU LGPL 3",
       "organizationName": "SonarSource",
       "organizationUrl": "http://www.sonarsource.com",
-      "urls": {
-        "homepage": "http://redirect.sonarsource.com/plugins/scmgit.html",
-        "issueTracker": "http://jira.codehaus.org/browse/SONARSCGIT"
-      },
+      "homepage": "http://redirect.sonarsource.com/plugins/scmgit.html",
+      "issueTrackerUrl": "http://jira.codehaus.org/browse/SONARSCGIT",
       "artifact": {
         "name": "sonar-scm-git-plugin-1.0.jar"
       }
       "license": "GNU LGPL 3",
       "organizationName": "SonarSource",
       "organizationUrl": "http://www.sonarsource.com",
-      "urls": {
-        "homepage": "http://redirect.sonarsource.com/plugins/java.html",
-        "issueTracker": "http://jira.codehaus.org/browse/SONARJAVA"
-      },
+      "homepage": "http://redirect.sonarsource.com/plugins/java.html",
+      "issueTrackerUrl": "http://jira.codehaus.org/browse/SONARJAVA",
       "artifact": {
         "name": "sonar-java-plugin-3.0.jar"
       }
       "license": "GNU LGPL 3",
       "organizationName": "SonarSource",
       "organizationUrl": "http://www.sonarsource.com",
-      "urls": {
-        "homepage": "http://redirect.sonarsource.com/plugins/scmsvn.html",
-        "issueTracker": "http://jira.codehaus.org/browse/SONARSCSVN"
-      },
+      "homepage": "http://redirect.sonarsource.com/plugins/scmsvn.html",
+      "issueTrackerUrl": "http://jira.codehaus.org/browse/SONARSCSVN",
       "artifact": {
         "name": "sonar-scm-svn-plugin-1.0.jar"
       }
index 46de637234824dbbfc1d07f73f46516b995647bd..4e47bfe774bd015d86df674c6725d11a8119d16e 100644 (file)
@@ -9,10 +9,8 @@
       "license": "GNU LGPL 3",
       "organizationName": "SonarSource",
       "organizationUrl": "http://www.sonarsource.com",
-      "urls": {
-        "homepage": "http://redirect.sonarsource.com/plugins/scmgit.html",
-        "issueTracker": "http://jira.codehaus.org/browse/SONARSCGIT"
-      },
+      "homepage": "http://redirect.sonarsource.com/plugins/scmgit.html",
+      "issueTrackerUrl": "http://jira.codehaus.org/browse/SONARSCGIT",
       "artifact": {
         "name": "sonar-scm-git-plugin-1.0.jar"
       }
       "license": "GNU LGPL 3",
       "organizationName": "SonarSource",
       "organizationUrl": "http://www.sonarsource.com",
-      "urls": {
-        "homepage": "http://redirect.sonarsource.com/plugins/java.html",
-        "issueTracker": "http://jira.codehaus.org/browse/SONARJAVA"
-      },
+      "homepage": "http://redirect.sonarsource.com/plugins/java.html",
+      "issueTrackerUrl": "http://jira.codehaus.org/browse/SONARJAVA",
       "artifact": {
         "name": "sonar-java-plugin-3.0.jar"
       }
       "license": "GNU LGPL 3",
       "organizationName": "SonarSource",
       "organizationUrl": "http://www.sonarsource.com",
-      "urls": {
-        "homepage": "http://redirect.sonarsource.com/plugins/scmsvn.html",
-        "issueTracker": "http://jira.codehaus.org/browse/SONARSCSVN"
-      },
+      "homepage": "http://redirect.sonarsource.com/plugins/scmsvn.html",
+      "issueTrackerUrl": "http://jira.codehaus.org/browse/SONARSCSVN",
       "artifact": {
         "name": "sonar-scm-svn-plugin-1.0.jar"
       }
index 36cb35e5692f3994e2a340e55eb69e1c7e83d900..6edf1af52644a66323e1a1ac0952373683569e87 100644 (file)
@@ -126,11 +126,8 @@ public class InstalledPluginsWsActionTest {
         "      \"license\": \"license_hey\"," +
         "      \"organizationName\": \"org_name\"," +
         "      \"organizationUrl\": \"org_url\"," +
-        "      \"urls\":" +
-        "      {" +
-        "        \"homepage\": \"homepage_url\"," +
-        "        \"issueTracker\": \"issueTracker_url\"" +
-        "      }," +
+        "      \"homepage\": \"homepage_url\"," +
+        "      \"issueTrackerUrl\": \"issueTracker_url\"," +
         "      \"artifact\":" +
         "      {" +
         "        \"name\": \"some.jar\"" +
index f54b49f80f6c09791ac8a61194f72d775342c53a..9cace284a825fece6242fe21c25d9de16e0f86a2 100644 (file)
@@ -107,10 +107,8 @@ public class PendingPluginsWsActionTest {
         "      \"license\": \"GNU LGPL 3\"," +
         "      \"organizationName\": \"SonarSource\"," +
         "      \"organizationUrl\": \"http://www.sonarsource.com\"," +
-        "      \"urls\": {" +
-        "        \"homepage\": \"http://redirect.sonarsource.com/plugins/scmgit.html\"," +
-        "        \"issueTracker\": \"http://jira.codehaus.org/browse/SONARSCGIT\"" +
-        "      }," +
+        "      \"homepage\": \"http://redirect.sonarsource.com/plugins/scmgit.html\"," +
+        "      \"issueTrackerUrl\": \"http://jira.codehaus.org/browse/SONARSCGIT\"," +
         "      \"artifact\": {" +
         "        \"name\": \"sonar-scm-git-plugin-1.0.jar\"" +
         "      }" +
@@ -140,10 +138,8 @@ public class PendingPluginsWsActionTest {
         "      \"license\": \"GNU LGPL 3\"," +
         "      \"organizationName\": \"SonarSource\"," +
         "      \"organizationUrl\": \"http://www.sonarsource.com\"," +
-        "      \"urls\": {" +
-        "        \"homepage\": \"http://redirect.sonarsource.com/plugins/scmgit.html\"," +
-        "        \"issueTracker\": \"http://jira.codehaus.org/browse/SONARSCGIT\"" +
-        "      }," +
+        "      \"homepage\": \"http://redirect.sonarsource.com/plugins/scmgit.html\"," +
+        "      \"issueTrackerUrl\": \"http://jira.codehaus.org/browse/SONARSCGIT\"," +
         "      \"artifact\": {" +
         "        \"name\": \"sonar-scm-git-plugin-1.0.jar\"" +
         "      }" +
index 679ab5fc27800f01e4b929121f89cd5acc0c3840..b4b8a31f351f8690bf66ca533aaa2baaa96fbc2e 100644 (file)
@@ -58,10 +58,8 @@ public class PluginWSCommonsTest {
         "  \"license\": \"GNU LGPL 3\"," +
         "  \"organizationName\": \"SonarSource\"," +
         "  \"organizationUrl\": \"http://www.sonarsource.com\"," +
-        "  \"urls\": {" +
-        "    \"homepage\": \"http://redirect.sonarsource.com/plugins/scmgit.html\"," +
-        "    \"issueTracker\": \"http://jira.codehaus.org/browse/SONARSCGIT\"" +
-        "  }," +
+        "  \"homepage\": \"http://redirect.sonarsource.com/plugins/scmgit.html\"," +
+        "  \"issueTrackerUrl\": \"http://jira.codehaus.org/browse/SONARSCGIT\"," +
         "  \"artifact\": {" +
         "    \"name\": \"sonar-scm-git-plugin-1.0.jar\"" +
         "  }" +
@@ -83,21 +81,8 @@ public class PluginWSCommonsTest {
         "  \"license\": \"GNU LGPL 3\"," +
         "  \"organizationName\": \"SonarSource\"," +
         "  \"organizationUrl\": \"http://www.sonarsource.com\"," +
-        "}");
-  }
-
-  @Test
-  public void verify_properties_written_by_writeUrls() throws Exception {
-    jsonWriter.beginObject();
-    underTest.writeUrls(jsonWriter, GIT_PLUGIN_METADATA);
-    jsonWriter.endObject();
-
-    jsonWriter.close();
-    assertJson(response.outputAsString()).setStrictArrayOrder(true).isSimilarTo("{" +
-        "  \"urls\": {" +
-        "    \"homepage\": \"http://redirect.sonarsource.com/plugins/scmgit.html\"," +
-        "    \"issueTracker\": \"http://jira.codehaus.org/browse/SONARSCGIT\"" +
-        "  }," +
+        "  \"homepage\": \"http://redirect.sonarsource.com/plugins/scmgit.html\"," +
+        "  \"issueTrackerUrl\": \"http://jira.codehaus.org/browse/SONARSCGIT\"," +
         "}");
   }