]> source.dussan.org Git - sonarqube.git/commitdiff
Add missing tests for WS action declarations
authorJean-Baptiste Lievremont <jean-baptiste.lievremont@sonarsource.com>
Thu, 16 Apr 2015 13:59:28 +0000 (15:59 +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/QProfileChangeParentAction.java
server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/QProfilesWsTest.java

index 17a171d665e373f1f97ac62087a3a82abf518a16..2412b4de93669d07ef4c8c1de94f68c4dcb7b7a5 100644 (file)
@@ -59,6 +59,7 @@ public class QProfileChangeParentAction implements BaseQProfileWsAction {
   public void define(NewController context) {
     NewAction inheritance = context.createAction("change_parent")
       .setSince("5.2")
+      .setPost(true)
       .setDescription("Change a quality profile's parent.")
       .setHandler(this);
 
index 2eb2115666d06037909e5ff6efe880b76772dff0..592033e1a61d4ead3b4ecc3838d71ec622e8d7ea 100644 (file)
@@ -30,6 +30,7 @@ import org.sonar.api.resources.Languages;
 import org.sonar.api.server.ws.WebService;
 import org.sonar.api.utils.ValidationMessages;
 import org.sonar.server.language.LanguageTesting;
+import org.sonar.server.qualityprofile.QProfileExporters;
 import org.sonar.server.qualityprofile.QProfileService;
 import org.sonar.server.rule.RuleService;
 import org.sonar.server.ws.WsTester;
@@ -66,7 +67,16 @@ public class QProfilesWsTest {
       new QProfileSetDefaultAction(languages, null, null),
       new QProfileProjectsAction(null),
       new QProfileBackupAction(null, null, null, languages),
-      new QProfileRestoreAction(null, languages)
+      new QProfileRestoreAction(null, languages),
+      new QProfileChangelogAction(null, null, null, languages),
+      new QProfileChangeParentAction(null, null, null, languages),
+      new QProfileCompareAction(null, null, null, languages),
+      new QProfileCopyAction(null, languages),
+      new QProfileDeleteAction(languages, null, null),
+      new QProfileExportAction(null, null, null, mock(QProfileExporters.class), languages),
+      new QProfileExportersAction(),
+      new QProfileInheritanceAction(null, null, null, null, languages),
+      new QProfileRenameAction(null)
     )).controller(QProfilesWs.API_ENDPOINT);
   }
 
@@ -92,7 +102,7 @@ public class QProfilesWsTest {
     assertThat(controller).isNotNull();
     assertThat(controller.path()).isEqualTo(QProfilesWs.API_ENDPOINT);
     assertThat(controller.description()).isNotEmpty();
-    assertThat(controller.actions()).hasSize(14);
+    assertThat(controller.actions()).hasSize(23);
   }
 
   @Test
@@ -218,4 +228,97 @@ public class QProfilesWsTest {
     assertThat(importers.params()).isEmpty();
     assertThat(importers.responseExampleAsString()).isNotEmpty();
   }
+
+  @Test
+  public void define_changelog_action() throws Exception {
+    WebService.Action changelog = controller.action("changelog");
+    assertThat(changelog).isNotNull();
+    assertThat(changelog.isPost()).isFalse();
+    assertThat(changelog.params()).hasSize(7).extracting("key").containsOnly(
+      "profileKey", "profileName", "language", "since", "to", "p", "ps"
+      );
+    assertThat(changelog.responseExampleAsString()).isNotEmpty();
+  }
+
+  @Test
+  public void define_change_parent_action() throws Exception {
+    WebService.Action changeParent = controller.action("change_parent");
+    assertThat(changeParent).isNotNull();
+    assertThat(changeParent.isPost()).isTrue();
+    assertThat(changeParent.params()).hasSize(5).extracting("key").containsOnly(
+      "profileKey", "profileName", "language", "parentKey", "parentName"
+      );
+  }
+
+  @Test
+  public void define_compare_action() throws Exception {
+    WebService.Action compare = controller.action("compare");
+    assertThat(compare).isNotNull();
+    assertThat(compare.isPost()).isFalse();
+    assertThat(compare.isInternal()).isTrue();
+    assertThat(compare.params()).hasSize(2).extracting("key").containsOnly(
+      "leftKey", "rightKey"
+      );
+    assertThat(compare.responseExampleAsString()).isNotEmpty();
+  }
+
+  @Test
+  public void define_copy_action() throws Exception {
+    WebService.Action copy = controller.action("copy");
+    assertThat(copy).isNotNull();
+    assertThat(copy.isPost()).isTrue();
+    assertThat(copy.params()).hasSize(2).extracting("key").containsOnly(
+      "fromKey", "toName"
+      );
+  }
+
+  @Test
+  public void define_delete_action() throws Exception {
+    WebService.Action delete = controller.action("delete");
+    assertThat(delete).isNotNull();
+    assertThat(delete.isPost()).isTrue();
+    assertThat(delete.params()).hasSize(3).extracting("key").containsOnly(
+      "profileKey", "language", "profileName"
+      );
+  }
+
+  @Test
+  public void define_export_action() throws Exception {
+    WebService.Action export = controller.action("export");
+    assertThat(export).isNotNull();
+    assertThat(export.isPost()).isFalse();
+    assertThat(export.params()).hasSize(2).extracting("key").containsOnly(
+      "language", "name"
+      );
+  }
+
+  @Test
+  public void define_exporters_action() throws Exception {
+    WebService.Action exporters = controller.action("exporters");
+    assertThat(exporters).isNotNull();
+    assertThat(exporters.isPost()).isFalse();
+    assertThat(exporters.params()).isEmpty();
+    assertThat(exporters.responseExampleAsString()).isNotEmpty();
+  }
+
+  @Test
+  public void define_inheritance_action() throws Exception {
+    WebService.Action inheritance = controller.action("inheritance");
+    assertThat(inheritance).isNotNull();
+    assertThat(inheritance.isPost()).isFalse();
+    assertThat(inheritance.params()).hasSize(3).extracting("key").containsOnly(
+      "profileKey", "language", "profileName"
+      );
+    assertThat(inheritance.responseExampleAsString()).isNotEmpty();
+  }
+
+  @Test
+  public void define_rename_action() throws Exception {
+    WebService.Action rename = controller.action("rename");
+    assertThat(rename).isNotNull();
+    assertThat(rename.isPost()).isTrue();
+    assertThat(rename.params()).hasSize(2).extracting("key").containsOnly(
+      "key", "name"
+      );
+  }
 }