]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-9954 return sonar.editions.jsonUrl in api/navigation/global
authorSébastien Lesaint <sebastien.lesaint@sonarsource.com>
Tue, 17 Oct 2017 09:00:21 +0000 (11:00 +0200)
committerGrégoire Aubert <gregoire.aubert@sonarsource.com>
Mon, 23 Oct 2017 15:01:13 +0000 (08:01 -0700)
server/sonar-server/src/main/java/org/sonar/server/ui/ws/GlobalAction.java
server/sonar-server/src/test/java/org/sonar/server/ui/ws/GlobalActionTest.java
server/sonar-server/src/test/resources/org/sonar/server/ui/ws/GlobalActionTest/deprecated_logo_settings.json [deleted file]
server/sonar-server/src/test/resources/org/sonar/server/ui/ws/GlobalActionTest/empty.json [deleted file]
server/sonar-server/src/test/resources/org/sonar/server/ui/ws/GlobalActionTest/global_pages.json [deleted file]
server/sonar-server/src/test/resources/org/sonar/server/ui/ws/GlobalActionTest/organization_support.json [deleted file]
server/sonar-server/src/test/resources/org/sonar/server/ui/ws/GlobalActionTest/production_database.json [deleted file]
server/sonar-server/src/test/resources/org/sonar/server/ui/ws/GlobalActionTest/qualifiers.json [deleted file]
server/sonar-server/src/test/resources/org/sonar/server/ui/ws/GlobalActionTest/settings.json [deleted file]
server/sonar-server/src/test/resources/org/sonar/server/ui/ws/GlobalActionTest/version.json [deleted file]

index 42652292532fbffd9729f793729f5940489b76ab..6ff1646ac0291435f36a5b2629c44c8829208f4d 100644 (file)
@@ -40,6 +40,7 @@ import org.sonar.server.ui.VersionFormatter;
 import org.sonar.server.user.UserSession;
 
 import static org.sonar.api.CoreProperties.RATING_GRID;
+import static org.sonar.core.config.CorePropertyDefinitions.EDITIONS_CONFIG_URL;
 import static org.sonar.core.config.WebConstants.SONARCLOUD_ENABLED;
 import static org.sonar.core.config.WebConstants.SONAR_LF_ENABLE_GRAVATAR;
 import static org.sonar.core.config.WebConstants.SONAR_LF_GRAVATAR_SERVER_URL;
@@ -55,6 +56,7 @@ public class GlobalAction implements NavigationWsAction {
     SONAR_LF_ENABLE_GRAVATAR,
     SONAR_LF_GRAVATAR_SERVER_URL,
     SONAR_UPDATECENTER_ACTIVATE,
+    EDITIONS_CONFIG_URL,
     SONARCLOUD_ENABLED,
     RATING_GRID);
 
index bdc667d415faa2743d9f7fa6d41a0b9ab453db11..1576a6429f904ed354adc31c17105ab6da497847 100644 (file)
@@ -67,7 +67,11 @@ public class GlobalActionTest {
   public void empty_call() throws Exception {
     init();
 
-    executeAndVerify("empty.json");
+    assertJson(call()).isSimilarTo("{" +
+      "  \"globalPages\": []," +
+      "  \"settings\": {}," +
+      "  \"qualifiers\": []" +
+      "}");
   }
 
   @Test
@@ -85,7 +89,9 @@ public class GlobalActionTest {
         .build()
     });
 
-    executeAndVerify("qualifiers.json");
+    assertJson(call()).isSimilarTo("{" +
+      "  \"qualifiers\": [\"POL\", \"PAL\"]" +
+      "}");
   }
 
   @Test
@@ -97,11 +103,23 @@ public class GlobalActionTest {
     settings.setProperty("sonar.lf.enableGravatar", true);
     settings.setProperty("sonar.sonarcloud.enabled", true);
     settings.setProperty("sonar.updatecenter.activate", false);
+    settings.setProperty("sonar.editions.jsonUrl", "https://foo.bar/editions.json");
     settings.setProperty("sonar.technicalDebt.ratingGrid", "0.05,0.1,0.2,0.5");
     // This setting should be ignored as it's not needed
     settings.setProperty("sonar.defaultGroup", "sonar-users");
 
-    executeAndVerify("settings.json");
+    assertJson(call()).isSimilarTo("{" +
+      "  \"settings\": {" +
+      "    \"sonar.lf.logoUrl\": \"http://example.com/my-custom-logo.png\"," +
+      "    \"sonar.lf.logoWidthPx\": \"135\"," +
+      "    \"sonar.lf.gravatarServerUrl\": \"https://secure.gravatar.com/avatar/{EMAIL_MD5}.jpg?s={SIZE}&d=identicon\"," +
+      "    \"sonar.lf.enableGravatar\": \"true\"," +
+      "    \"sonar.sonarcloud.enabled\": \"true\"," +
+      "    \"sonar.editions.jsonUrl\": \"https://foo.bar/editions.json\"," +
+      "    \"sonar.updatecenter.activate\": \"false\"," +
+      "    \"sonar.technicalDebt.ratingGrid\": \"0.05,0.1,0.2,0.5\"" +
+      "  }" +
+      "}");
   }
 
   @Test
@@ -110,14 +128,32 @@ public class GlobalActionTest {
     settings.setProperty("sonar.lf.logoUrl", "http://example.com/my-custom-logo.png");
     settings.setProperty("sonar.lf.logoWidthPx", 135);
 
-    executeAndVerify("deprecated_logo_settings.json");
+    assertJson(call()).isSimilarTo("{" +
+      "  \"settings\": {" +
+      "    \"sonar.lf.logoUrl\": \"http://example.com/my-custom-logo.png\"," +
+      "    \"sonar.lf.logoWidthPx\": \"135\"" +
+      "  }," +
+      "  \"logoUrl\": \"http://example.com/my-custom-logo.png\"," +
+      "  \"logoWidth\": \"135\"" +
+      "}");
   }
 
   @Test
   public void the_returned_global_pages_do_not_include_administration_pages() throws Exception {
     init(createPages(), new ResourceTypeTree[] {});
 
-    executeAndVerify("global_pages.json");
+    assertJson(call()).isSimilarTo("{" +
+      "  \"globalPages\": [" +
+      "    {" +
+      "      \"key\": \"another_plugin/page\"," +
+      "      \"name\": \"My Another Page\"" +
+      "    }," +
+      "    {" +
+      "      \"key\": \"my_plugin/page\"," +
+      "      \"name\": \"My Plugin Page\"" +
+      "    }" +
+      "  ]" +
+      "}");
   }
 
   @Test
@@ -125,7 +161,9 @@ public class GlobalActionTest {
     init();
     when(server.getVersion()).thenReturn("6.2");
 
-    executeAndVerify("version.json");
+    assertJson(call()).isSimilarTo("{" +
+      "  \"version\": \"6.2\"" +
+      "}");
   }
 
   @Test
@@ -153,7 +191,9 @@ public class GlobalActionTest {
     init();
     when(dbClient.getDatabase().getDialect()).thenReturn(new MySql());
 
-    executeAndVerify("production_database.json");
+    assertJson(call()).isSimilarTo("{" +
+      "  \"productionDatabase\": true" +
+      "}");
   }
 
   @Test
@@ -161,7 +201,10 @@ public class GlobalActionTest {
     init();
     organizationFlags.setEnabled(true);
 
-    executeAndVerify("organization_support.json");
+    assertJson(call()).isSimilarTo("{" +
+      "  \"organizationsEnabled\": true," +
+      "  \"defaultOrganization\": \"key_foo\"" +
+      "}");
   }
 
   @Test
@@ -228,10 +271,6 @@ public class GlobalActionTest {
       dbClient, organizationFlags, defaultOrganizationProvider, branchFeature, userSession));
   }
 
-  private void executeAndVerify(String json) {
-    assertJson(call()).isSimilarTo(getClass().getResource(GlobalActionTest.class.getSimpleName() + "/" + json));
-  }
-
   private String call() {
     return ws.newRequest().execute().getInput();
   }
diff --git a/server/sonar-server/src/test/resources/org/sonar/server/ui/ws/GlobalActionTest/deprecated_logo_settings.json b/server/sonar-server/src/test/resources/org/sonar/server/ui/ws/GlobalActionTest/deprecated_logo_settings.json
deleted file mode 100644 (file)
index 13930da..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-{
-  "settings": {
-    "sonar.lf.logoUrl": "http://example.com/my-custom-logo.png",
-    "sonar.lf.logoWidthPx": "135"
-  },
-  "logoUrl": "http://example.com/my-custom-logo.png",
-  "logoWidth": "135"
-}
diff --git a/server/sonar-server/src/test/resources/org/sonar/server/ui/ws/GlobalActionTest/empty.json b/server/sonar-server/src/test/resources/org/sonar/server/ui/ws/GlobalActionTest/empty.json
deleted file mode 100644 (file)
index cc5448c..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-{
-  "globalPages": [],
-  "settings": {},
-  "qualifiers": []
-}
diff --git a/server/sonar-server/src/test/resources/org/sonar/server/ui/ws/GlobalActionTest/global_pages.json b/server/sonar-server/src/test/resources/org/sonar/server/ui/ws/GlobalActionTest/global_pages.json
deleted file mode 100644 (file)
index 014d6a5..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-{
-  "globalPages": [
-    {
-      "key": "another_plugin/page",
-      "name": "My Another Page"
-    },
-    {
-      "key": "my_plugin/page",
-      "name": "My Plugin Page"
-    }
-  ]
-}
diff --git a/server/sonar-server/src/test/resources/org/sonar/server/ui/ws/GlobalActionTest/organization_support.json b/server/sonar-server/src/test/resources/org/sonar/server/ui/ws/GlobalActionTest/organization_support.json
deleted file mode 100644 (file)
index b2778b2..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-{
-  "organizationsEnabled": true,
-  "defaultOrganization": "key_foo"
-}
diff --git a/server/sonar-server/src/test/resources/org/sonar/server/ui/ws/GlobalActionTest/production_database.json b/server/sonar-server/src/test/resources/org/sonar/server/ui/ws/GlobalActionTest/production_database.json
deleted file mode 100644 (file)
index ae8359c..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-{
-  "productionDatabase": true
-}
diff --git a/server/sonar-server/src/test/resources/org/sonar/server/ui/ws/GlobalActionTest/qualifiers.json b/server/sonar-server/src/test/resources/org/sonar/server/ui/ws/GlobalActionTest/qualifiers.json
deleted file mode 100644 (file)
index ef2107c..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-{
-  "qualifiers": ["POL", "PAL"]
-}
diff --git a/server/sonar-server/src/test/resources/org/sonar/server/ui/ws/GlobalActionTest/settings.json b/server/sonar-server/src/test/resources/org/sonar/server/ui/ws/GlobalActionTest/settings.json
deleted file mode 100644 (file)
index 885c52b..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-{
-  "settings": {
-    "sonar.lf.logoUrl": "http://example.com/my-custom-logo.png",
-    "sonar.lf.logoWidthPx": "135",
-    "sonar.lf.gravatarServerUrl": "https://secure.gravatar.com/avatar/{EMAIL_MD5}.jpg?s={SIZE}&d=identicon",
-    "sonar.lf.enableGravatar": "true",
-    "sonar.sonarcloud.enabled": "true",
-    "sonar.updatecenter.activate": "false",
-    "sonar.technicalDebt.ratingGrid": "0.05,0.1,0.2,0.5"
-  }
-}
diff --git a/server/sonar-server/src/test/resources/org/sonar/server/ui/ws/GlobalActionTest/version.json b/server/sonar-server/src/test/resources/org/sonar/server/ui/ws/GlobalActionTest/version.json
deleted file mode 100644 (file)
index 21cd139..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-{
-  "version": "6.2"
-}