]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-6399 Make exporters and importers public WS
authorJean-Baptiste Lievremont <jean-baptiste.lievremont@sonarsource.com>
Thu, 16 Apr 2015 13:19:39 +0000 (15:19 +0200)
committerJean-Baptiste Lievremont <jean-baptiste.lievremont@sonarsource.com>
Fri, 17 Apr 2015 15:23:28 +0000 (17:23 +0200)
server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/QProfileExportAction.java
server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/QProfileExportersAction.java
server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/QProfileImportersAction.java
server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/QProfileExportActionTest.java
server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/QProfilesWsTest.java

index 7174e369b38034a8fe816454ff57c0d0841b2557..2af41d993ee865a72125feabdf1cd5421254e0ec 100644 (file)
@@ -44,7 +44,7 @@ public class QProfileExportAction implements BaseQProfileWsAction {
 
   private static final String PARAM_PROFILE_NAME = "name";
   private static final String PARAM_LANGUAGE = "language";
-  private static final String PARAM_FORMAT = "format";
+  private static final String PARAM_FORMAT = "exporterKey";
 
   private final DbClient dbClient;
 
@@ -89,7 +89,8 @@ public class QProfileExportAction implements BaseQProfileWsAction {
     }
     if (!exporterKeys.isEmpty()) {
       create.createParam(PARAM_FORMAT)
-        .setDescription("Output format. If left empty, the same format as api/qualityprofiles/backup is used.")
+        .setDescription("Output format. If left empty, the same format as api/qualityprofiles/backup is used. " +
+          "Possible values are described by api/qualityprofiles/exporters.")
         .setPossibleValues(exporterKeys);
     }
   }
index 74a567d96af30812580b6d68d31501732d332e88..76324f7484927fcb2db7fad7f42124eae63a6f98 100644 (file)
@@ -42,7 +42,6 @@ public class QProfileExportersAction implements BaseQProfileWsAction {
     context.createAction("exporters")
       .setDescription("Lists available profile export formats.")
       .setHandler(this)
-      .setInternal(true)
       .setResponseExample(getClass().getResource("example-exporters.json"))
       .setSince("5.2");
   }
index 90ba1f4459eaca2725fea49d9a7b9e87afe7a734..8b9389b4cc48a5ded78f5352729ae04d09281232 100644 (file)
@@ -42,7 +42,6 @@ public class QProfileImportersAction implements BaseQProfileWsAction {
     controller.createAction("importers")
       .setSince("5.2")
       .setDescription("List supported importers.")
-      .setInternal(true)
       .setResponseExample(getClass().getResource("example-importers.json"))
       .setHandler(this);
   }
index 6033875c4dd2c2e34600bbc00b4a1e7dfe6ce554..20b18432e739e77aa57e4a3ce2026be7b037e4db 100644 (file)
@@ -143,7 +143,7 @@ public class QProfileExportActionTest {
     session.commit();
 
     Result result = wsTester.newGetRequest("api/qualityprofiles", "export")
-      .setParam("language", profile.getLanguage()).setParam("name", profile.getName()).setParam("format", "polop").execute();
+      .setParam("language", profile.getLanguage()).setParam("name", profile.getName()).setParam("exporterKey", "polop").execute();
 
     assertThat(result.outputAsString()).isEqualTo("Profile " + profile.getName() + " exported by polop");
   }
@@ -156,7 +156,7 @@ public class QProfileExportActionTest {
     session.commit();
 
     Result result = wsTester.newGetRequest("api/qualityprofiles", "export")
-      .setParam("language", "xoo").setParam("format", "polop").execute();
+      .setParam("language", "xoo").setParam("exporterKey", "polop").execute();
 
     assertThat(result.outputAsString()).isEqualTo("Profile " + profile2.getName() + " exported by polop");
   }
@@ -164,7 +164,7 @@ public class QProfileExportActionTest {
   @Test(expected = NotFoundException.class)
   public void fail_on_unknown_profile() throws Exception {
     wsTester.newGetRequest("api/qualityprofiles", "export")
-      .setParam("language", "xoo").setParam("format", "polop").execute();
+      .setParam("language", "xoo").setParam("exporterKey", "polop").execute();
   }
 
   @Test(expected = IllegalArgumentException.class)
@@ -174,25 +174,25 @@ public class QProfileExportActionTest {
     session.commit();
 
     wsTester.newGetRequest("api/qualityprofiles", "export")
-      .setParam("language", "xoo").setParam("format", "unknown").execute();
+      .setParam("language", "xoo").setParam("exporterKey", "unknown").execute();
   }
 
   @Test
   public void do_not_fail_when_no_exporters() throws Exception {
-    exporters = new QProfileExporters(null, null, null, new ProfileExporter[0], null);
-    wsTester = new WsTester(new QProfilesWs(mock(RuleActivationActions.class),
+    QProfileExporters myExporters = new QProfileExporters(null, null, null, new ProfileExporter[0], null);
+    WsTester myWsTester = new WsTester(new QProfilesWs(mock(RuleActivationActions.class),
       mock(BulkRuleActivationActions.class),
       mock(ProjectAssociationActions.class),
-      new QProfileExportAction(dbClient, new QProfileFactory(dbClient), backuper, exporters, LanguageTesting.newLanguages("xoo"))));
+      new QProfileExportAction(dbClient, new QProfileFactory(dbClient), backuper, myExporters, LanguageTesting.newLanguages("xoo"))));
 
-    Action export = wsTester.controller("api/qualityprofiles").action("export");
+    Action export = myWsTester.controller("api/qualityprofiles").action("export");
     assertThat(export.params()).hasSize(2);
 
     QualityProfileDto profile = QProfileTesting.newXooP1();
     qualityProfileDao.insert(session, profile);
     session.commit();
 
-    wsTester.newGetRequest("api/qualityprofiles", "export").setParam("language", "xoo").setParam("name", profile.getName()).execute();
+    myWsTester.newGetRequest("api/qualityprofiles", "export").setParam("language", "xoo").setParam("name", profile.getName()).execute();
 
   }
 }
index 254793b663945f49950eb3cf2568417df2e43264..2eb2115666d06037909e5ff6efe880b76772dff0 100644 (file)
@@ -215,7 +215,6 @@ public class QProfilesWsTest {
     WebService.Action importers = controller.action("importers");
     assertThat(importers).isNotNull();
     assertThat(importers.isPost()).isFalse();
-    assertThat(importers.isInternal()).isTrue();
     assertThat(importers.params()).isEmpty();
     assertThat(importers.responseExampleAsString()).isNotEmpty();
   }