]> source.dussan.org Git - sonarqube.git/commitdiff
Rename a migration because the name is too long on windows
authorJulien Lancelot <julien.lancelot@gmail.com>
Thu, 26 Feb 2015 11:07:30 +0000 (12:07 +0100)
committerJulien Lancelot <julien.lancelot@gmail.com>
Thu, 26 Feb 2015 11:09:48 +0000 (12:09 +0100)
32 files changed:
server/sonar-server/src/main/java/org/sonar/server/db/migrations/DatabaseMigrations.java
server/sonar-server/src/main/java/org/sonar/server/db/migrations/v51/AddCharacteristicUsabilityAndSubCharacteristicsComplianceMigration.java [deleted file]
server/sonar-server/src/main/java/org/sonar/server/db/migrations/v51/AddNewCharacteristics.java [new file with mode: 0644]
server/sonar-server/src/test/java/org/sonar/server/db/migrations/v51/AddCharacteristicUsabilityAndSubCharacteristicsComplianceMigrationTest.java [deleted file]
server/sonar-server/src/test/java/org/sonar/server/db/migrations/v51/AddNewCharacteristicsTest.java [new file with mode: 0644]
server/sonar-server/src/test/resources/org/sonar/server/db/migrations/v51/AddCharacteristicUsabilityAndSubCharacteristicsComplianceMigrationTest/do_nothing_when_already_migrated.xml [deleted file]
server/sonar-server/src/test/resources/org/sonar/server/db/migrations/v51/AddCharacteristicUsabilityAndSubCharacteristicsComplianceMigrationTest/empty.xml [deleted file]
server/sonar-server/src/test/resources/org/sonar/server/db/migrations/v51/AddCharacteristicUsabilityAndSubCharacteristicsComplianceMigrationTest/fail_if_compliance_already_exists_as_characteristic.xml [deleted file]
server/sonar-server/src/test/resources/org/sonar/server/db/migrations/v51/AddCharacteristicUsabilityAndSubCharacteristicsComplianceMigrationTest/fail_if_compliance_already_exists_under_wrong_characteristic.xml [deleted file]
server/sonar-server/src/test/resources/org/sonar/server/db/migrations/v51/AddCharacteristicUsabilityAndSubCharacteristicsComplianceMigrationTest/fail_if_usability_exists_as_sub_characteristic.xml [deleted file]
server/sonar-server/src/test/resources/org/sonar/server/db/migrations/v51/AddCharacteristicUsabilityAndSubCharacteristicsComplianceMigrationTest/insert_usability_at_the_top_if_security_does_exists-result.xml [deleted file]
server/sonar-server/src/test/resources/org/sonar/server/db/migrations/v51/AddCharacteristicUsabilityAndSubCharacteristicsComplianceMigrationTest/insert_usability_at_the_top_if_security_does_exists.xml [deleted file]
server/sonar-server/src/test/resources/org/sonar/server/db/migrations/v51/AddCharacteristicUsabilityAndSubCharacteristicsComplianceMigrationTest/migrate-result.xml [deleted file]
server/sonar-server/src/test/resources/org/sonar/server/db/migrations/v51/AddCharacteristicUsabilityAndSubCharacteristicsComplianceMigrationTest/migrate.xml [deleted file]
server/sonar-server/src/test/resources/org/sonar/server/db/migrations/v51/AddCharacteristicUsabilityAndSubCharacteristicsComplianceMigrationTest/not_fail_if_some_deprecated_requirements_still_exists_in_db.xml [deleted file]
server/sonar-server/src/test/resources/org/sonar/server/db/migrations/v51/AddCharacteristicUsabilityAndSubCharacteristicsComplianceMigrationTest/schema.sql [deleted file]
server/sonar-server/src/test/resources/org/sonar/server/db/migrations/v51/AddCharacteristicUsabilityAndSubCharacteristicsComplianceMigrationTest/update_usability_if_already_exists-result.xml [deleted file]
server/sonar-server/src/test/resources/org/sonar/server/db/migrations/v51/AddCharacteristicUsabilityAndSubCharacteristicsComplianceMigrationTest/update_usability_if_already_exists.xml [deleted file]
server/sonar-server/src/test/resources/org/sonar/server/db/migrations/v51/AddNewCharacteristicsTest/do_nothing_when_already_migrated.xml [new file with mode: 0644]
server/sonar-server/src/test/resources/org/sonar/server/db/migrations/v51/AddNewCharacteristicsTest/empty.xml [new file with mode: 0644]
server/sonar-server/src/test/resources/org/sonar/server/db/migrations/v51/AddNewCharacteristicsTest/fail_if_compliance_already_exists_as_characteristic.xml [new file with mode: 0644]
server/sonar-server/src/test/resources/org/sonar/server/db/migrations/v51/AddNewCharacteristicsTest/fail_if_compliance_already_exists_under_wrong_characteristic.xml [new file with mode: 0644]
server/sonar-server/src/test/resources/org/sonar/server/db/migrations/v51/AddNewCharacteristicsTest/fail_if_usability_exists_as_sub_characteristic.xml [new file with mode: 0644]
server/sonar-server/src/test/resources/org/sonar/server/db/migrations/v51/AddNewCharacteristicsTest/insert_usability_at_the_top_if_security_does_exists-result.xml [new file with mode: 0644]
server/sonar-server/src/test/resources/org/sonar/server/db/migrations/v51/AddNewCharacteristicsTest/insert_usability_at_the_top_if_security_does_exists.xml [new file with mode: 0644]
server/sonar-server/src/test/resources/org/sonar/server/db/migrations/v51/AddNewCharacteristicsTest/migrate-result.xml [new file with mode: 0644]
server/sonar-server/src/test/resources/org/sonar/server/db/migrations/v51/AddNewCharacteristicsTest/migrate.xml [new file with mode: 0644]
server/sonar-server/src/test/resources/org/sonar/server/db/migrations/v51/AddNewCharacteristicsTest/not_fail_if_some_deprecated_requirements_still_exists_in_db.xml [new file with mode: 0644]
server/sonar-server/src/test/resources/org/sonar/server/db/migrations/v51/AddNewCharacteristicsTest/schema.sql [new file with mode: 0644]
server/sonar-server/src/test/resources/org/sonar/server/db/migrations/v51/AddNewCharacteristicsTest/update_usability_if_already_exists-result.xml [new file with mode: 0644]
server/sonar-server/src/test/resources/org/sonar/server/db/migrations/v51/AddNewCharacteristicsTest/update_usability_if_already_exists.xml [new file with mode: 0644]
server/sonar-web/src/main/webapp/WEB-INF/db/migrate/794_add_characteristic_usability_and_sub_characteristics_compliance.rb

index f454013b2a1c98c18b97fe4990ddb77c397bee81..6afedd0a1f63214530bd40deceabd86cefbc3060 100644 (file)
@@ -92,7 +92,7 @@ public interface DatabaseMigrations {
     FeedProjectMeasuresLongDates.class,
     FeedManualMeasuresLongDates.class,
     FeedEventsLongDates.class,
-    AddCharacteristicUsabilityAndSubCharacteristicsComplianceMigration.class,
+    AddNewCharacteristics.class,
     RemovePermissionsOnModulesMigration.class
     );
 }
diff --git a/server/sonar-server/src/main/java/org/sonar/server/db/migrations/v51/AddCharacteristicUsabilityAndSubCharacteristicsComplianceMigration.java b/server/sonar-server/src/main/java/org/sonar/server/db/migrations/v51/AddCharacteristicUsabilityAndSubCharacteristicsComplianceMigration.java
deleted file mode 100644 (file)
index 7c57144..0000000
+++ /dev/null
@@ -1,324 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-package org.sonar.server.db.migrations.v51;
-
-import com.google.common.base.Predicate;
-import com.google.common.collect.Iterables;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.sonar.api.utils.MessageException;
-import org.sonar.api.utils.System2;
-import org.sonar.core.persistence.Database;
-import org.sonar.server.db.migrations.BaseDataChange;
-import org.sonar.server.db.migrations.Select;
-
-import javax.annotation.CheckForNull;
-import javax.annotation.Nullable;
-
-import java.sql.SQLException;
-import java.util.Date;
-import java.util.List;
-
-/**
- * See http://jira.codehaus.org/browse/SONAR-6187
- *
- * Add a new Characteristic 'Usability' with 2 sub-characteristics 'Accessibility' and 'Ease of Use'
- * and add a new sub-characteristic 'Compliance' for all characteristics.
- *
- * Nothing will be done if there's no characteristics in db, as they're all gonna be created by {@link org.sonar.server.startup.RegisterDebtModel}
- *
- * Before 4.3 the characteristics table contains requirements, then when selecting characteristics we should not forget to exclude them (with a filter on rule_id IS NULL)
- *
- */
-public class AddCharacteristicUsabilityAndSubCharacteristicsComplianceMigration extends BaseDataChange {
-
-  private static final Logger LOGGER = LoggerFactory.getLogger(AddCharacteristicUsabilityAndSubCharacteristicsComplianceMigration.class);
-
-  private static final String COMPLIANCE_NAME = "Compliance";
-  private static final String COMPLIANCE_KEY_SUFFIX = "_COMPLIANCE";
-
-  private static final String SECURITY_KEY = "SECURITY";
-  private static final String USABILITY_KEY = "USABILITY";
-
-  private static final String ERROR_SUFFIX = "Please restore your DB backup, start the previous version of SonarQube " +
-    "and update your SQALE model to fix this issue before trying again to run the migration.";
-
-  private final System2 system;
-
-  public AddCharacteristicUsabilityAndSubCharacteristicsComplianceMigration(Database db, System2 system) {
-    super(db);
-    this.system = system;
-  }
-
-  @Override
-  public void execute(Context context) throws SQLException {
-    CharacteristicsContext characteristicsContext = new CharacteristicsContext(context, system);
-
-    // On an empty DB, there are no characteristics, they're all gonna be created after in RegisterDebtModel
-    if (!characteristicsContext.characteristics().isEmpty()) {
-      int usabilityOder = moveCharacteristicsDownToBeAbleToInsertUsability(characteristicsContext);
-      createOrUpdateUsabilityCharacteristicAndItsSubCharacteristic(characteristicsContext, usabilityOder);
-
-      createSubCharacteristic(characteristicsContext, "REUSABILITY" + COMPLIANCE_KEY_SUFFIX, "Reusability " + COMPLIANCE_NAME, "REUSABILITY");
-      createSubCharacteristic(characteristicsContext, "PORTABILITY" + COMPLIANCE_KEY_SUFFIX, "Portability " + COMPLIANCE_NAME, "PORTABILITY");
-      createSubCharacteristic(characteristicsContext, "MAINTAINABILITY" + COMPLIANCE_KEY_SUFFIX, "Maintainability " + COMPLIANCE_NAME, "MAINTAINABILITY");
-      createSubCharacteristic(characteristicsContext, SECURITY_KEY + COMPLIANCE_KEY_SUFFIX, "Security " + COMPLIANCE_NAME, SECURITY_KEY);
-      createSubCharacteristic(characteristicsContext, "EFFICIENCY" + COMPLIANCE_KEY_SUFFIX, "Efficiency " + COMPLIANCE_NAME, "EFFICIENCY");
-      createSubCharacteristic(characteristicsContext, "CHANGEABILITY" + COMPLIANCE_KEY_SUFFIX, "Changeability " + COMPLIANCE_NAME, "CHANGEABILITY");
-      createSubCharacteristic(characteristicsContext, "RELIABILITY" + COMPLIANCE_KEY_SUFFIX, "Reliability " + COMPLIANCE_NAME, "RELIABILITY");
-      createSubCharacteristic(characteristicsContext, "TESTABILITY" + COMPLIANCE_KEY_SUFFIX, "Testability " + COMPLIANCE_NAME, "TESTABILITY");
-    }
-  }
-
-  /**
-   * If the characteristic 'Security' exists, the new characteristic 'Usability' should be inserted just below it,
-   * so every existing characteristics below Security should move down.
-   *
-   * If the characteristic 'Security' does not exists, the new characteristic 'Usability' should be the first one,
-   * so every existing characteristics should move down.
-   *
-   * If the characteristic 'Usability' is already at the right place, nothing will be done.
-   */
-  private int moveCharacteristicsDownToBeAbleToInsertUsability(CharacteristicsContext characteristicsContext) throws SQLException {
-    Characteristic security = characteristicsContext.findCharacteristicByKey(SECURITY_KEY);
-    Characteristic usability = characteristicsContext.findCharacteristicByKey(USABILITY_KEY);
-
-    int usabilityOder = 1;
-    int indexToStart = 0;
-    if (security != null) {
-      indexToStart = characteristicsContext.characteristics().indexOf(security) + 1;
-      usabilityOder = security.getOrder() + 1;
-    }
-
-    if (usability == null || usability.getOrder() != usabilityOder) {
-      // Move root characteristics one step lower
-      for (int i = indexToStart; i < characteristicsContext.characteristics().size(); i++) {
-        Characteristic characteristic = characteristicsContext.characteristics().get(i);
-        if (characteristic.getParentId() == null) {
-          characteristicsContext.updateCharacteristicOrder(characteristic.getKey(), characteristic.getOrder() + 1);
-        }
-      }
-    }
-    return usabilityOder;
-  }
-
-  private void createOrUpdateUsabilityCharacteristicAndItsSubCharacteristic(CharacteristicsContext characteristicsContext, int newUsabilityOrder)
-    throws SQLException {
-    String usabilityKey = USABILITY_KEY;
-    Characteristic usability = characteristicsContext.findCharacteristicByKey(usabilityKey);
-    if (usability != null) {
-      if (usability.getOrder() != newUsabilityOrder) {
-        usability.setOrder(newUsabilityOrder);
-        characteristicsContext.updateCharacteristicOrder(usability.getKey(), usability.getOrder());
-      }
-    } else {
-      usability = new Characteristic().setKey(usabilityKey).setName("Usability").setOrder(newUsabilityOrder);
-      characteristicsContext.insertCharacteristic(usability);
-    }
-
-    createSubCharacteristic(characteristicsContext, "USABILITY_ACCESSIBILITY", "Accessibility", usabilityKey);
-    createSubCharacteristic(characteristicsContext, "USABILITY_EASE_OF_USE", "Ease of Use", usabilityKey);
-    createSubCharacteristic(characteristicsContext, USABILITY_KEY + COMPLIANCE_KEY_SUFFIX, "Usability " + COMPLIANCE_NAME, usabilityKey);
-  }
-
-  private void createSubCharacteristic(CharacteristicsContext characteristicsContext,
-    String subCharacteristicKey, String subCharacteristicName, String parentKey) throws SQLException {
-    Characteristic parent = characteristicsContext.findCharacteristicByKey(parentKey);
-    if (parent != null) {
-      Characteristic subCharacteristic = characteristicsContext.findSubCharacteristicByKey(subCharacteristicKey, parent);
-      if (subCharacteristic == null) {
-        characteristicsContext.insertCharacteristic(new Characteristic().setKey(subCharacteristicKey).setName(subCharacteristicName).setParentId(parent.getId()));
-      }
-    }
-    // If the characteristic parent does not exits, the sub-characteristic is not added
-  }
-
-  private static class Characteristic {
-    private Integer id;
-    private String key;
-    private String name;
-    private Integer order;
-    private Integer parentId;
-
-    public Integer getId() {
-      return id;
-    }
-
-    public Characteristic setId(Integer id) {
-      this.id = id;
-      return this;
-    }
-
-    public String getKey() {
-      return key;
-    }
-
-    public Characteristic setKey(String key) {
-      this.key = key;
-      return this;
-    }
-
-    public String getName() {
-      return name;
-    }
-
-    public Characteristic setName(String name) {
-      this.name = name;
-      return this;
-    }
-
-    /**
-     * On a characteristic, the order can never be null
-     */
-    public Integer getOrder() {
-      return parentId == null && order != null ? order : null;
-    }
-
-    public Characteristic setOrder(@Nullable Integer order) {
-      this.order = order;
-      return this;
-    }
-
-    @CheckForNull
-    public Integer getParentId() {
-      return parentId;
-    }
-
-    public Characteristic setParentId(@Nullable Integer parentId) {
-      this.parentId = parentId;
-      return this;
-    }
-  }
-
-  private static class CharacteristicsContext {
-    private final System2 system;
-    Context context;
-    Date now;
-    List<Characteristic> characteristics;
-
-    public CharacteristicsContext(Context context, System2 system) throws SQLException {
-      this.context = context;
-      this.system = system;
-      init();
-    }
-
-    private void init() throws SQLException {
-      now = new Date(system.now());
-      characteristics = selectEnabledCharacteristics();
-    }
-
-    public List<Characteristic> characteristics() {
-      return characteristics;
-    }
-
-    @CheckForNull
-    public Characteristic findCharacteristicByKey(final String key) {
-      Characteristic characteristic = Iterables.find(characteristics, new Predicate<Characteristic>() {
-        @Override
-        public boolean apply(@Nullable Characteristic input) {
-          return input != null && input.key.equals(key);
-        }
-      }, null);
-      if (characteristic != null && characteristic.getParentId() != null) {
-        throw MessageException.of(String.format("'%s' must be a characteristic. " + ERROR_SUFFIX, characteristic.getName()));
-      }
-      return characteristic;
-    }
-
-    @CheckForNull
-    public Characteristic findSubCharacteristicByKey(final String key, Characteristic parent) {
-      Characteristic characteristic = Iterables.find(characteristics, new Predicate<Characteristic>() {
-        @Override
-        public boolean apply(@Nullable Characteristic input) {
-          return input != null && input.key.equals(key);
-        }
-      }, null);
-      if (characteristic != null) {
-        Integer parentId = characteristic.getParentId();
-        if (parentId == null) {
-          throw MessageException.of(String.format("'%s' must be a sub-characteristic. " + ERROR_SUFFIX, characteristic.getName()));
-        } else if (!parentId.equals(parent.getId())) {
-          throw MessageException.of(String.format("'%s' must be defined under '%s'. " + ERROR_SUFFIX, characteristic.getName(), parent.getName()));
-        }
-      }
-      return characteristic;
-    }
-
-    private List<Characteristic> selectEnabledCharacteristics() throws SQLException {
-      return context.prepareSelect(
-        // Exclude requirements (to not fail when coming from a version older than 4.3)
-        "SELECT c.id, c.kee, c.name, c.characteristic_order, c.parent_id FROM characteristics c WHERE c.enabled=? AND c.rule_id IS NULL ORDER BY c.characteristic_order")
-        .setBoolean(1, true)
-        .list(new CharacteristicReader());
-    }
-
-    private int selectCharacteristicId(String key) throws SQLException {
-      return context.prepareSelect(
-        "SELECT c.id FROM characteristics c WHERE c.kee = ? AND c.enabled=?")
-        .setString(1, key)
-        .setBoolean(2, true)
-        .get(Select.LONG_READER).intValue();
-    }
-
-    public void insertCharacteristic(Characteristic characteristic) throws SQLException {
-      if (characteristic.getParentId() == null) {
-        LOGGER.info("Insert new characteristic '{}'", characteristic.getKey());
-      } else {
-        LOGGER.info("Insert new sub characteristic '{}'", characteristic.getKey());
-      }
-
-      context.prepareUpsert("INSERT INTO characteristics (kee, name, parent_id, characteristic_order, enabled, created_at) VALUES (?, ?, ?, ?, ?, ?)")
-        .setString(1, characteristic.getKey())
-        .setString(2, characteristic.getName())
-        .setInt(3, characteristic.getParentId())
-        .setInt(4, characteristic.getOrder())
-        .setBoolean(5, true)
-        .setDate(6, now)
-        .execute()
-        .commit();
-      characteristic.setId(selectCharacteristicId(characteristic.getKey()));
-
-      characteristics.add(characteristic);
-    }
-
-    public void updateCharacteristicOrder(String key, Integer order) throws SQLException {
-      LOGGER.info("Update characteristic '{}' order to {}", key, order);
-
-      context.prepareUpsert("UPDATE characteristics SET characteristic_order=?, updated_at=? WHERE kee=?")
-        .setInt(1, order)
-        .setDate(2, now)
-        .setString(3, key)
-        .execute()
-        .commit();
-    }
-
-    private static class CharacteristicReader implements Select.RowReader<Characteristic> {
-      @Override
-      public Characteristic read(Select.Row row) throws SQLException {
-        return new Characteristic()
-          .setId(row.getInt(1))
-          .setKey(row.getString(2))
-          .setName(row.getString(3))
-          .setOrder(row.getNullableInt(4))
-          .setParentId(row.getNullableInt(5));
-      }
-    }
-  }
-}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/db/migrations/v51/AddNewCharacteristics.java b/server/sonar-server/src/main/java/org/sonar/server/db/migrations/v51/AddNewCharacteristics.java
new file mode 100644 (file)
index 0000000..9b66e70
--- /dev/null
@@ -0,0 +1,323 @@
+/*
+ * SonarQube, open source software quality management tool.
+ * Copyright (C) 2008-2014 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * SonarQube is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * SonarQube is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+package org.sonar.server.db.migrations.v51;
+
+import com.google.common.base.Predicate;
+import com.google.common.collect.Iterables;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.sonar.api.utils.MessageException;
+import org.sonar.api.utils.System2;
+import org.sonar.core.persistence.Database;
+import org.sonar.server.db.migrations.BaseDataChange;
+import org.sonar.server.db.migrations.Select;
+
+import javax.annotation.CheckForNull;
+import javax.annotation.Nullable;
+import java.sql.SQLException;
+import java.util.Date;
+import java.util.List;
+
+/**
+ * See http://jira.codehaus.org/browse/SONAR-6187
+ *
+ * Add a new Characteristic 'Usability' with 2 sub-characteristics 'Accessibility' and 'Ease of Use'
+ * and add a new sub-characteristic 'Compliance' for all characteristics.
+ *
+ * Nothing will be done if there's no characteristics in db, as they're all gonna be created by {@link org.sonar.server.startup.RegisterDebtModel}
+ *
+ * Before 4.3 the characteristics table contains requirements, then when selecting characteristics we should not forget to exclude them (with a filter on rule_id IS NULL)
+ *
+ */
+public class AddNewCharacteristics extends BaseDataChange {
+
+  private static final Logger LOGGER = LoggerFactory.getLogger(AddNewCharacteristics.class);
+
+  private static final String COMPLIANCE_NAME = "Compliance";
+  private static final String COMPLIANCE_KEY_SUFFIX = "_COMPLIANCE";
+
+  private static final String SECURITY_KEY = "SECURITY";
+  private static final String USABILITY_KEY = "USABILITY";
+
+  private static final String ERROR_SUFFIX = "Please restore your DB backup, start the previous version of SonarQube " +
+    "and update your SQALE model to fix this issue before trying again to run the migration.";
+
+  private final System2 system;
+
+  public AddNewCharacteristics(Database db, System2 system) {
+    super(db);
+    this.system = system;
+  }
+
+  @Override
+  public void execute(Context context) throws SQLException {
+    CharacteristicsContext characteristicsContext = new CharacteristicsContext(context, system);
+
+    // On an empty DB, there are no characteristics, they're all gonna be created after in RegisterDebtModel
+    if (!characteristicsContext.characteristics().isEmpty()) {
+      int usabilityOder = moveCharacteristicsDownToBeAbleToInsertUsability(characteristicsContext);
+      createOrUpdateUsabilityCharacteristicAndItsSubCharacteristic(characteristicsContext, usabilityOder);
+
+      createSubCharacteristic(characteristicsContext, "REUSABILITY" + COMPLIANCE_KEY_SUFFIX, "Reusability " + COMPLIANCE_NAME, "REUSABILITY");
+      createSubCharacteristic(characteristicsContext, "PORTABILITY" + COMPLIANCE_KEY_SUFFIX, "Portability " + COMPLIANCE_NAME, "PORTABILITY");
+      createSubCharacteristic(characteristicsContext, "MAINTAINABILITY" + COMPLIANCE_KEY_SUFFIX, "Maintainability " + COMPLIANCE_NAME, "MAINTAINABILITY");
+      createSubCharacteristic(characteristicsContext, SECURITY_KEY + COMPLIANCE_KEY_SUFFIX, "Security " + COMPLIANCE_NAME, SECURITY_KEY);
+      createSubCharacteristic(characteristicsContext, "EFFICIENCY" + COMPLIANCE_KEY_SUFFIX, "Efficiency " + COMPLIANCE_NAME, "EFFICIENCY");
+      createSubCharacteristic(characteristicsContext, "CHANGEABILITY" + COMPLIANCE_KEY_SUFFIX, "Changeability " + COMPLIANCE_NAME, "CHANGEABILITY");
+      createSubCharacteristic(characteristicsContext, "RELIABILITY" + COMPLIANCE_KEY_SUFFIX, "Reliability " + COMPLIANCE_NAME, "RELIABILITY");
+      createSubCharacteristic(characteristicsContext, "TESTABILITY" + COMPLIANCE_KEY_SUFFIX, "Testability " + COMPLIANCE_NAME, "TESTABILITY");
+    }
+  }
+
+  /**
+   * If the characteristic 'Security' exists, the new characteristic 'Usability' should be inserted just below it,
+   * so every existing characteristics below Security should move down.
+   *
+   * If the characteristic 'Security' does not exists, the new characteristic 'Usability' should be the first one,
+   * so every existing characteristics should move down.
+   *
+   * If the characteristic 'Usability' is already at the right place, nothing will be done.
+   */
+  private int moveCharacteristicsDownToBeAbleToInsertUsability(CharacteristicsContext characteristicsContext) throws SQLException {
+    Characteristic security = characteristicsContext.findCharacteristicByKey(SECURITY_KEY);
+    Characteristic usability = characteristicsContext.findCharacteristicByKey(USABILITY_KEY);
+
+    int usabilityOder = 1;
+    int indexToStart = 0;
+    if (security != null) {
+      indexToStart = characteristicsContext.characteristics().indexOf(security) + 1;
+      usabilityOder = security.getOrder() + 1;
+    }
+
+    if (usability == null || usability.getOrder() != usabilityOder) {
+      // Move root characteristics one step lower
+      for (int i = indexToStart; i < characteristicsContext.characteristics().size(); i++) {
+        Characteristic characteristic = characteristicsContext.characteristics().get(i);
+        if (characteristic.getParentId() == null) {
+          characteristicsContext.updateCharacteristicOrder(characteristic.getKey(), characteristic.getOrder() + 1);
+        }
+      }
+    }
+    return usabilityOder;
+  }
+
+  private void createOrUpdateUsabilityCharacteristicAndItsSubCharacteristic(CharacteristicsContext characteristicsContext, int newUsabilityOrder)
+    throws SQLException {
+    String usabilityKey = USABILITY_KEY;
+    Characteristic usability = characteristicsContext.findCharacteristicByKey(usabilityKey);
+    if (usability != null) {
+      if (usability.getOrder() != newUsabilityOrder) {
+        usability.setOrder(newUsabilityOrder);
+        characteristicsContext.updateCharacteristicOrder(usability.getKey(), usability.getOrder());
+      }
+    } else {
+      usability = new Characteristic().setKey(usabilityKey).setName("Usability").setOrder(newUsabilityOrder);
+      characteristicsContext.insertCharacteristic(usability);
+    }
+
+    createSubCharacteristic(characteristicsContext, "USABILITY_ACCESSIBILITY", "Accessibility", usabilityKey);
+    createSubCharacteristic(characteristicsContext, "USABILITY_EASE_OF_USE", "Ease of Use", usabilityKey);
+    createSubCharacteristic(characteristicsContext, USABILITY_KEY + COMPLIANCE_KEY_SUFFIX, "Usability " + COMPLIANCE_NAME, usabilityKey);
+  }
+
+  private void createSubCharacteristic(CharacteristicsContext characteristicsContext,
+    String subCharacteristicKey, String subCharacteristicName, String parentKey) throws SQLException {
+    Characteristic parent = characteristicsContext.findCharacteristicByKey(parentKey);
+    if (parent != null) {
+      Characteristic subCharacteristic = characteristicsContext.findSubCharacteristicByKey(subCharacteristicKey, parent);
+      if (subCharacteristic == null) {
+        characteristicsContext.insertCharacteristic(new Characteristic().setKey(subCharacteristicKey).setName(subCharacteristicName).setParentId(parent.getId()));
+      }
+    }
+    // If the characteristic parent does not exits, the sub-characteristic is not added
+  }
+
+  private static class Characteristic {
+    private Integer id;
+    private String key;
+    private String name;
+    private Integer order;
+    private Integer parentId;
+
+    public Integer getId() {
+      return id;
+    }
+
+    public Characteristic setId(Integer id) {
+      this.id = id;
+      return this;
+    }
+
+    public String getKey() {
+      return key;
+    }
+
+    public Characteristic setKey(String key) {
+      this.key = key;
+      return this;
+    }
+
+    public String getName() {
+      return name;
+    }
+
+    public Characteristic setName(String name) {
+      this.name = name;
+      return this;
+    }
+
+    /**
+     * On a characteristic, the order can never be null
+     */
+    public Integer getOrder() {
+      return parentId == null && order != null ? order : null;
+    }
+
+    public Characteristic setOrder(@Nullable Integer order) {
+      this.order = order;
+      return this;
+    }
+
+    @CheckForNull
+    public Integer getParentId() {
+      return parentId;
+    }
+
+    public Characteristic setParentId(@Nullable Integer parentId) {
+      this.parentId = parentId;
+      return this;
+    }
+  }
+
+  private static class CharacteristicsContext {
+    private final System2 system;
+    Context context;
+    Date now;
+    List<Characteristic> characteristics;
+
+    public CharacteristicsContext(Context context, System2 system) throws SQLException {
+      this.context = context;
+      this.system = system;
+      init();
+    }
+
+    private void init() throws SQLException {
+      now = new Date(system.now());
+      characteristics = selectEnabledCharacteristics();
+    }
+
+    public List<Characteristic> characteristics() {
+      return characteristics;
+    }
+
+    @CheckForNull
+    public Characteristic findCharacteristicByKey(final String key) {
+      Characteristic characteristic = Iterables.find(characteristics, new Predicate<Characteristic>() {
+        @Override
+        public boolean apply(@Nullable Characteristic input) {
+          return input != null && input.key.equals(key);
+        }
+      }, null);
+      if (characteristic != null && characteristic.getParentId() != null) {
+        throw MessageException.of(String.format("'%s' must be a characteristic. " + ERROR_SUFFIX, characteristic.getName()));
+      }
+      return characteristic;
+    }
+
+    @CheckForNull
+    public Characteristic findSubCharacteristicByKey(final String key, Characteristic parent) {
+      Characteristic characteristic = Iterables.find(characteristics, new Predicate<Characteristic>() {
+        @Override
+        public boolean apply(@Nullable Characteristic input) {
+          return input != null && input.key.equals(key);
+        }
+      }, null);
+      if (characteristic != null) {
+        Integer parentId = characteristic.getParentId();
+        if (parentId == null) {
+          throw MessageException.of(String.format("'%s' must be a sub-characteristic. " + ERROR_SUFFIX, characteristic.getName()));
+        } else if (!parentId.equals(parent.getId())) {
+          throw MessageException.of(String.format("'%s' must be defined under '%s'. " + ERROR_SUFFIX, characteristic.getName(), parent.getName()));
+        }
+      }
+      return characteristic;
+    }
+
+    private List<Characteristic> selectEnabledCharacteristics() throws SQLException {
+      return context.prepareSelect(
+        // Exclude requirements (to not fail when coming from a version older than 4.3)
+        "SELECT c.id, c.kee, c.name, c.characteristic_order, c.parent_id FROM characteristics c WHERE c.enabled=? AND c.rule_id IS NULL ORDER BY c.characteristic_order")
+        .setBoolean(1, true)
+        .list(new CharacteristicReader());
+    }
+
+    private int selectCharacteristicId(String key) throws SQLException {
+      return context.prepareSelect(
+        "SELECT c.id FROM characteristics c WHERE c.kee = ? AND c.enabled=?")
+        .setString(1, key)
+        .setBoolean(2, true)
+        .get(Select.LONG_READER).intValue();
+    }
+
+    public void insertCharacteristic(Characteristic characteristic) throws SQLException {
+      if (characteristic.getParentId() == null) {
+        LOGGER.info("Insert new characteristic '{}'", characteristic.getKey());
+      } else {
+        LOGGER.info("Insert new sub characteristic '{}'", characteristic.getKey());
+      }
+
+      context.prepareUpsert("INSERT INTO characteristics (kee, name, parent_id, characteristic_order, enabled, created_at) VALUES (?, ?, ?, ?, ?, ?)")
+        .setString(1, characteristic.getKey())
+        .setString(2, characteristic.getName())
+        .setInt(3, characteristic.getParentId())
+        .setInt(4, characteristic.getOrder())
+        .setBoolean(5, true)
+        .setDate(6, now)
+        .execute()
+        .commit();
+      characteristic.setId(selectCharacteristicId(characteristic.getKey()));
+
+      characteristics.add(characteristic);
+    }
+
+    public void updateCharacteristicOrder(String key, Integer order) throws SQLException {
+      LOGGER.info("Update characteristic '{}' order to {}", key, order);
+
+      context.prepareUpsert("UPDATE characteristics SET characteristic_order=?, updated_at=? WHERE kee=?")
+        .setInt(1, order)
+        .setDate(2, now)
+        .setString(3, key)
+        .execute()
+        .commit();
+    }
+
+    private static class CharacteristicReader implements Select.RowReader<Characteristic> {
+      @Override
+      public Characteristic read(Select.Row row) throws SQLException {
+        return new Characteristic()
+          .setId(row.getInt(1))
+          .setKey(row.getString(2))
+          .setName(row.getString(3))
+          .setOrder(row.getNullableInt(4))
+          .setParentId(row.getNullableInt(5));
+      }
+    }
+  }
+}
diff --git a/server/sonar-server/src/test/java/org/sonar/server/db/migrations/v51/AddCharacteristicUsabilityAndSubCharacteristicsComplianceMigrationTest.java b/server/sonar-server/src/test/java/org/sonar/server/db/migrations/v51/AddCharacteristicUsabilityAndSubCharacteristicsComplianceMigrationTest.java
deleted file mode 100644 (file)
index 012cf06..0000000
+++ /dev/null
@@ -1,138 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-package org.sonar.server.db.migrations.v51;
-
-import org.junit.Before;
-import org.junit.ClassRule;
-import org.junit.Test;
-import org.sonar.api.utils.DateUtils;
-import org.sonar.api.utils.MessageException;
-import org.sonar.api.utils.System2;
-import org.sonar.core.persistence.DbTester;
-import org.sonar.server.db.migrations.DatabaseMigration;
-
-import static junit.framework.TestCase.fail;
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-public class AddCharacteristicUsabilityAndSubCharacteristicsComplianceMigrationTest {
-
-  @ClassRule
-  public static DbTester db = new DbTester().schema(AddCharacteristicUsabilityAndSubCharacteristicsComplianceMigrationTest.class, "schema.sql");
-
-  DatabaseMigration migration;
-
-  System2 system = mock(System2.class);
-
-  @Before
-  public void setUp() throws Exception {
-    db.executeUpdateSql("truncate table characteristics");
-
-    when(system.now()).thenReturn(DateUtils.parseDate("2015-02-15").getTime());
-
-    migration = new AddCharacteristicUsabilityAndSubCharacteristicsComplianceMigration(db.database(), system);
-  }
-
-  @Test
-  public void migrate() throws Exception {
-    db.prepareDbUnit(getClass(), "migrate.xml");
-    migration.execute();
-    db.assertDbUnit(getClass(), "migrate-result.xml", "characteristics");
-  }
-
-  @Test
-  public void do_nothing_when_already_migrated() throws Exception {
-    db.prepareDbUnit(getClass(), "do_nothing_when_already_migrated.xml");
-    migration.execute();
-    db.assertDbUnit(getClass(), "do_nothing_when_already_migrated.xml", "characteristics");
-  }
-
-  @Test
-  public void do_nothing_when_no_characteristics() throws Exception {
-    db.prepareDbUnit(getClass(), "empty.xml");
-    migration.execute();
-    assertThat(db.countRowsOfTable("characteristics")).isEqualTo(0);
-  }
-
-  @Test
-  public void insert_usability_at_the_top_if_security_does_exists() throws Exception {
-    db.prepareDbUnit(getClass(), "insert_usability_at_the_top_if_security_does_exists.xml");
-    migration.execute();
-    db.assertDbUnit(getClass(), "insert_usability_at_the_top_if_security_does_exists-result.xml", "characteristics");
-  }
-
-  @Test
-  public void update_usability_order_if_already_exists() throws Exception {
-    db.prepareDbUnit(getClass(), "update_usability_if_already_exists.xml");
-    migration.execute();
-    db.assertDbUnit(getClass(), "update_usability_if_already_exists-result.xml", "characteristics");
-  }
-
-  @Test
-  public void fail_if_usability_exists_as_sub_characteristic() throws Exception {
-    db.prepareDbUnit(getClass(), "fail_if_usability_exists_as_sub_characteristic.xml");
-
-    try {
-      migration.execute();
-      fail();
-    } catch (Exception e) {
-      assertThat(e).isInstanceOf(MessageException.class).hasMessage(
-        "'Usability' must be a characteristic. Please restore your DB backup, start the previous version of SonarQube " +
-          "and update your SQALE model to fix this issue before trying again to run the migration.");
-    }
-  }
-
-  @Test
-  public void fail_if_compliance_already_exists_as_characteristic() throws Exception {
-    db.prepareDbUnit(getClass(), "fail_if_compliance_already_exists_as_characteristic.xml");
-
-    try {
-      migration.execute();
-      fail();
-    } catch (Exception e) {
-      assertThat(e).isInstanceOf(MessageException.class).hasMessage(
-        "'Compliance' must be a sub-characteristic. Please restore your DB backup, start the previous version of SonarQube " +
-          "and update your SQALE model to fix this issue before trying again to run the migration.");
-    }
-  }
-
-  @Test
-  public void fail_if_compliance_already_exists_under_wrong_characteristic() throws Exception {
-    db.prepareDbUnit(getClass(), "fail_if_compliance_already_exists_under_wrong_characteristic.xml");
-
-    try {
-      migration.execute();
-      fail();
-    } catch (Exception e) {
-      assertThat(e).isInstanceOf(MessageException.class).hasMessage(
-        "'Reusability Compliance' must be defined under 'Reusability'. Please restore your DB backup, start the previous version of SonarQube " +
-          "and update your SQALE model to fix this issue before trying again to run the migration.");
-    }
-  }
-
-  @Test
-  public void not_fail_if_some_deprecated_requirements_still_exists_in_db() throws Exception {
-    db.prepareDbUnit(getClass(), "not_fail_if_some_deprecated_requirements_still_exists_in_db.xml");
-    migration.execute();
-    db.assertDbUnit(getClass(), "not_fail_if_some_deprecated_requirements_still_exists_in_db.xml", "characteristics");
-  }
-
-}
diff --git a/server/sonar-server/src/test/java/org/sonar/server/db/migrations/v51/AddNewCharacteristicsTest.java b/server/sonar-server/src/test/java/org/sonar/server/db/migrations/v51/AddNewCharacteristicsTest.java
new file mode 100644 (file)
index 0000000..4bc2d86
--- /dev/null
@@ -0,0 +1,138 @@
+/*
+ * SonarQube, open source software quality management tool.
+ * Copyright (C) 2008-2014 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * SonarQube is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * SonarQube is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+package org.sonar.server.db.migrations.v51;
+
+import org.junit.Before;
+import org.junit.ClassRule;
+import org.junit.Test;
+import org.sonar.api.utils.DateUtils;
+import org.sonar.api.utils.MessageException;
+import org.sonar.api.utils.System2;
+import org.sonar.core.persistence.DbTester;
+import org.sonar.server.db.migrations.DatabaseMigration;
+
+import static junit.framework.TestCase.fail;
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+public class AddNewCharacteristicsTest {
+
+  @ClassRule
+  public static DbTester db = new DbTester().schema(AddNewCharacteristicsTest.class, "schema.sql");
+
+  DatabaseMigration migration;
+
+  System2 system = mock(System2.class);
+
+  @Before
+  public void setUp() throws Exception {
+    db.executeUpdateSql("truncate table characteristics");
+
+    when(system.now()).thenReturn(DateUtils.parseDate("2015-02-15").getTime());
+
+    migration = new AddNewCharacteristics(db.database(), system);
+  }
+
+  @Test
+  public void migrate() throws Exception {
+    db.prepareDbUnit(getClass(), "migrate.xml");
+    migration.execute();
+    db.assertDbUnit(getClass(), "migrate-result.xml", "characteristics");
+  }
+
+  @Test
+  public void do_nothing_when_already_migrated() throws Exception {
+    db.prepareDbUnit(getClass(), "do_nothing_when_already_migrated.xml");
+    migration.execute();
+    db.assertDbUnit(getClass(), "do_nothing_when_already_migrated.xml", "characteristics");
+  }
+
+  @Test
+  public void do_nothing_when_no_characteristics() throws Exception {
+    db.prepareDbUnit(getClass(), "empty.xml");
+    migration.execute();
+    assertThat(db.countRowsOfTable("characteristics")).isEqualTo(0);
+  }
+
+  @Test
+  public void insert_usability_at_the_top_if_security_does_exists() throws Exception {
+    db.prepareDbUnit(getClass(), "insert_usability_at_the_top_if_security_does_exists.xml");
+    migration.execute();
+    db.assertDbUnit(getClass(), "insert_usability_at_the_top_if_security_does_exists-result.xml", "characteristics");
+  }
+
+  @Test
+  public void update_usability_order_if_already_exists() throws Exception {
+    db.prepareDbUnit(getClass(), "update_usability_if_already_exists.xml");
+    migration.execute();
+    db.assertDbUnit(getClass(), "update_usability_if_already_exists-result.xml", "characteristics");
+  }
+
+  @Test
+  public void fail_if_usability_exists_as_sub_characteristic() throws Exception {
+    db.prepareDbUnit(getClass(), "fail_if_usability_exists_as_sub_characteristic.xml");
+
+    try {
+      migration.execute();
+      fail();
+    } catch (Exception e) {
+      assertThat(e).isInstanceOf(MessageException.class).hasMessage(
+        "'Usability' must be a characteristic. Please restore your DB backup, start the previous version of SonarQube " +
+          "and update your SQALE model to fix this issue before trying again to run the migration.");
+    }
+  }
+
+  @Test
+  public void fail_if_compliance_already_exists_as_characteristic() throws Exception {
+    db.prepareDbUnit(getClass(), "fail_if_compliance_already_exists_as_characteristic.xml");
+
+    try {
+      migration.execute();
+      fail();
+    } catch (Exception e) {
+      assertThat(e).isInstanceOf(MessageException.class).hasMessage(
+        "'Compliance' must be a sub-characteristic. Please restore your DB backup, start the previous version of SonarQube " +
+          "and update your SQALE model to fix this issue before trying again to run the migration.");
+    }
+  }
+
+  @Test
+  public void fail_if_compliance_already_exists_under_wrong_characteristic() throws Exception {
+    db.prepareDbUnit(getClass(), "fail_if_compliance_already_exists_under_wrong_characteristic.xml");
+
+    try {
+      migration.execute();
+      fail();
+    } catch (Exception e) {
+      assertThat(e).isInstanceOf(MessageException.class).hasMessage(
+        "'Reusability Compliance' must be defined under 'Reusability'. Please restore your DB backup, start the previous version of SonarQube " +
+          "and update your SQALE model to fix this issue before trying again to run the migration.");
+    }
+  }
+
+  @Test
+  public void not_fail_if_some_deprecated_requirements_still_exists_in_db() throws Exception {
+    db.prepareDbUnit(getClass(), "not_fail_if_some_deprecated_requirements_still_exists_in_db.xml");
+    migration.execute();
+    db.assertDbUnit(getClass(), "not_fail_if_some_deprecated_requirements_still_exists_in_db.xml", "characteristics");
+  }
+
+}
diff --git a/server/sonar-server/src/test/resources/org/sonar/server/db/migrations/v51/AddCharacteristicUsabilityAndSubCharacteristicsComplianceMigrationTest/do_nothing_when_already_migrated.xml b/server/sonar-server/src/test/resources/org/sonar/server/db/migrations/v51/AddCharacteristicUsabilityAndSubCharacteristicsComplianceMigrationTest/do_nothing_when_already_migrated.xml
deleted file mode 100644 (file)
index b8ff37c..0000000
+++ /dev/null
@@ -1,53 +0,0 @@
-<dataset>
-
-  <characteristics id="1" kee="REUSABILITY" name="Reusability" parent_id="[null]" rule_id="[null]" characteristic_order="1" enabled="[true]" created_at="2013-11-20"
-                   updated_at="2013-11-22"/>
-  <characteristics id="2" kee="REUSABILITY_COMPLIANCE" name="Reusability Compliance" parent_id="1" rule_id="[null]" characteristic_order="[null]" enabled="[true]"
-                   created_at="2013-11-20" updated_at="[null]"/>
-
-  <characteristics id="3" kee="PORTABILITY" name="Portability" parent_id="[null]" rule_id="[null]" characteristic_order="2" enabled="[true]" created_at="2013-11-20"
-                   updated_at="2013-11-22"/>
-  <characteristics id="4" kee="PORTABILITY_COMPLIANCE" name="Portability Compliance" parent_id="3" rule_id="[null]" characteristic_order="[null]" enabled="[true]"
-                   created_at="2013-11-20" updated_at="[null]"/>
-
-  <characteristics id="5" kee="MAINTAINABILITY" name="Maintainability" parent_id="[null]" rule_id="[null]" characteristic_order="3" enabled="[true]" created_at="2013-11-20"
-                   updated_at="2013-11-22"/>
-  <characteristics id="6" kee="MAINTAINABILITY_COMPLIANCE" name="Maintainability Compliance" parent_id="5" rule_id="[null]" characteristic_order="[null]" enabled="[true]"
-                   created_at="2013-11-20" updated_at="[null]"/>
-
-  <characteristics id="7" kee="SECURITY" name="Security" parent_id="[null]" rule_id="[null]" characteristic_order="4" enabled="[true]" created_at="2013-11-20"
-                   updated_at="2013-11-22"/>
-  <characteristics id="8" kee="SECURITY_COMPLIANCE" name="Security Compliance" parent_id="7" rule_id="[null]" characteristic_order="[null]" enabled="[true]" created_at="2013-11-20"
-                   updated_at="[null]"/>
-
-  <characteristics id="9" kee="USABILITY" name="Usability" parent_id="[null]" rule_id="[null]" characteristic_order="5" enabled="[true]" created_at="2013-11-20"
-                   updated_at="[null]"/>
-  <characteristics id="10" kee="USABILITY_ACCESSIBILITY" name="Accessibility" parent_id="9" rule_id="[null]" characteristic_order="[null]" enabled="[true]" created_at="2013-11-20"
-                   updated_at="[null]"/>
-  <characteristics id="11" kee="USABILITY_EASE_OF_USE" name="Ease of Use" parent_id="9" rule_id="[null]" characteristic_order="[null]" enabled="[true]" created_at="2013-11-20"
-                   updated_at="[null]"/>
-  <characteristics id="12" kee="USABILITY_COMPLIANCE" name="Usability Compliance" parent_id="9" rule_id="[null]" characteristic_order="[null]" enabled="[true]"
-                   created_at="2013-11-20" updated_at="[null]"/>
-
-  <characteristics id="13" kee="EFFICIENCY" name="Efficiency" parent_id="[null]" rule_id="[null]" characteristic_order="6" enabled="[true]" created_at="2013-11-20"
-                   updated_at="2013-11-20"/>
-  <characteristics id="14" kee="EFFICIENCY_COMPLIANCE" name="Efficiency Compliance" parent_id="13" rule_id="[null]" characteristic_order="[null]" enabled="[true]"
-                   created_at="2013-11-20" updated_at="[null]"/>
-
-  <characteristics id="15" kee="CHANGEABILITY" name="Changeability" parent_id="[null]" rule_id="[null]" characteristic_order="7" enabled="[true]" created_at="2013-11-20"
-                   updated_at="2013-11-20"/>
-  <characteristics id="16" kee="CHANGEABILITY_COMPLIANCE" name="Changeability Compliance" parent_id="15" rule_id="[null]" characteristic_order="[null]" enabled="[true]"
-                   created_at="2013-11-20" updated_at="[null]"/>
-
-  <characteristics id="17" kee="RELIABILITY" name="Reliability" parent_id="[null]" rule_id="[null]" characteristic_order="8" enabled="[true]" created_at="2013-11-20"
-                   updated_at="2013-11-20"/>
-  <characteristics id="18" kee="RELIABILITY_COMPLIANCE" name="Reliability Compliance" parent_id="17" rule_id="[null]" characteristic_order="[null]" enabled="[true]"
-                   created_at="2013-11-20" updated_at="[null]"/>
-
-  <characteristics id="19" kee="TESTABILITY" name="Testability" parent_id="[null]" rule_id="[null]" characteristic_order="9" enabled="[true]" created_at="2013-11-20"
-                   updated_at="2013-11-20"/>
-  <characteristics id="20" kee="TESTABILITY_COMPLIANCE" name="Testability Compliance" parent_id="19" rule_id="[null]" characteristic_order="[null]" enabled="[true]"
-                   created_at="2013-11-20" updated_at="[null]"/>
-
-
-</dataset>
diff --git a/server/sonar-server/src/test/resources/org/sonar/server/db/migrations/v51/AddCharacteristicUsabilityAndSubCharacteristicsComplianceMigrationTest/empty.xml b/server/sonar-server/src/test/resources/org/sonar/server/db/migrations/v51/AddCharacteristicUsabilityAndSubCharacteristicsComplianceMigrationTest/empty.xml
deleted file mode 100644 (file)
index 871dedc..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-<dataset>
-
-</dataset>
diff --git a/server/sonar-server/src/test/resources/org/sonar/server/db/migrations/v51/AddCharacteristicUsabilityAndSubCharacteristicsComplianceMigrationTest/fail_if_compliance_already_exists_as_characteristic.xml b/server/sonar-server/src/test/resources/org/sonar/server/db/migrations/v51/AddCharacteristicUsabilityAndSubCharacteristicsComplianceMigrationTest/fail_if_compliance_already_exists_as_characteristic.xml
deleted file mode 100644 (file)
index 1f2f39b..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-<dataset>
-
-  <characteristics id="1" kee="REUSABILITY" name="Reusability" parent_id="[null]" rule_id="[null]" characteristic_order="1" enabled="[true]" created_at="2013-11-20"
-                   updated_at="2013-11-22"/>
-
-  <characteristics id="2" kee="REUSABILITY_COMPLIANCE" name="Compliance" parent_id="[null]" rule_id="[null]" characteristic_order="2" enabled="[true]" created_at="2013-11-20"
-                   updated_at="[null]"/>
-
-</dataset>
diff --git a/server/sonar-server/src/test/resources/org/sonar/server/db/migrations/v51/AddCharacteristicUsabilityAndSubCharacteristicsComplianceMigrationTest/fail_if_compliance_already_exists_under_wrong_characteristic.xml b/server/sonar-server/src/test/resources/org/sonar/server/db/migrations/v51/AddCharacteristicUsabilityAndSubCharacteristicsComplianceMigrationTest/fail_if_compliance_already_exists_under_wrong_characteristic.xml
deleted file mode 100644 (file)
index 3dbfebd..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-<dataset>
-
-  <characteristics id="1" kee="REUSABILITY" name="Reusability" parent_id="[null]" rule_id="[null]" characteristic_order="1" enabled="[true]" created_at="2013-11-20"
-                   updated_at="2013-11-22"/>
-
-  <characteristics id="2" kee="PORTABILITY" name="Portability" parent_id="[null]" rule_id="[null]" characteristic_order="2" enabled="[true]" created_at="2013-11-20"
-                   updated_at="2013-11-22"/>
-
-  <characteristics id="3" kee="REUSABILITY_COMPLIANCE" name="Reusability Compliance" parent_id="2" rule_id="[null]" characteristic_order="[null]" enabled="[true]"
-                   created_at="2013-11-20"
-                   updated_at="[null]"/>
-
-</dataset>
diff --git a/server/sonar-server/src/test/resources/org/sonar/server/db/migrations/v51/AddCharacteristicUsabilityAndSubCharacteristicsComplianceMigrationTest/fail_if_usability_exists_as_sub_characteristic.xml b/server/sonar-server/src/test/resources/org/sonar/server/db/migrations/v51/AddCharacteristicUsabilityAndSubCharacteristicsComplianceMigrationTest/fail_if_usability_exists_as_sub_characteristic.xml
deleted file mode 100644 (file)
index 70016cc..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-<dataset>
-
-  <characteristics id="1" kee="REUSABILITY" name="Reusability" parent_id="[null]" rule_id="[null]" characteristic_order="1" enabled="[true]" created_at="2013-11-20"
-                   updated_at="2013-11-22"/>
-
-  <characteristics id="2" kee="USABILITY" name="Usability" parent_id="1" rule_id="[null]" characteristic_order="[null]" enabled="[true]" created_at="2013-11-20"
-                   updated_at="2013-11-22"/>
-
-</dataset>
diff --git a/server/sonar-server/src/test/resources/org/sonar/server/db/migrations/v51/AddCharacteristicUsabilityAndSubCharacteristicsComplianceMigrationTest/insert_usability_at_the_top_if_security_does_exists-result.xml b/server/sonar-server/src/test/resources/org/sonar/server/db/migrations/v51/AddCharacteristicUsabilityAndSubCharacteristicsComplianceMigrationTest/insert_usability_at_the_top_if_security_does_exists-result.xml
deleted file mode 100644 (file)
index 4f59620..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-<dataset>
-
-  <!-- Oder has changed : this characteristic is now one step lower -->
-  <characteristics id="1" kee="REUSABILITY" name="Reusability" parent_id="[null]" rule_id="[null]" characteristic_order="2" enabled="[true]" created_at="2013-11-20"
-                   updated_at="2015-02-15"/>
-
-  <!-- Oder has changed : this characteristic is now one step lower -->
-  <characteristics id="2" kee="PORTABILITY" name="Portability" parent_id="[null]" rule_id="[null]" characteristic_order="3" enabled="[true]" created_at="2013-11-20"
-                   updated_at="2015-02-15"/>
-
-  <!-- New characteristic 'Usability' is on the top (order 1) -->
-  <characteristics id="3" kee="USABILITY" name="Usability" parent_id="[null]" rule_id="[null]" characteristic_order="1" enabled="[true]" created_at="2015-02-15"
-                   updated_at="[null]"/>
-  <characteristics id="4" kee="USABILITY_ACCESSIBILITY" name="Accessibility" parent_id="3" rule_id="[null]" characteristic_order="[null]" enabled="[true]" created_at="2015-02-15"
-                   updated_at="[null]"/>
-  <characteristics id="5" kee="USABILITY_EASE_OF_USE" name="Ease of Use" parent_id="3" rule_id="[null]" characteristic_order="[null]" enabled="[true]" created_at="2015-02-15"
-                   updated_at="[null]"/>
-  <characteristics id="6" kee="USABILITY_COMPLIANCE" name="Usability Compliance" parent_id="3" rule_id="[null]" characteristic_order="[null]" enabled="[true]"
-                   created_at="2015-02-15" updated_at="[null]"/>
-
-
-  <!-- New sub characteristic 'Compliance' under Reusability -->
-  <characteristics id="7" kee="REUSABILITY_COMPLIANCE" name="Reusability Compliance" parent_id="1" rule_id="[null]" characteristic_order="[null]" enabled="[true]"
-                   created_at="2015-02-15" updated_at="[null]"/>
-
-  <!-- New sub characteristic 'Compliance' under Portability -->
-  <characteristics id="8" kee="PORTABILITY_COMPLIANCE" name="Portability Compliance" parent_id="2" rule_id="[null]" characteristic_order="[null]" enabled="[true]"
-                   created_at="2015-02-15" updated_at="[null]"/>
-
-</dataset>
diff --git a/server/sonar-server/src/test/resources/org/sonar/server/db/migrations/v51/AddCharacteristicUsabilityAndSubCharacteristicsComplianceMigrationTest/insert_usability_at_the_top_if_security_does_exists.xml b/server/sonar-server/src/test/resources/org/sonar/server/db/migrations/v51/AddCharacteristicUsabilityAndSubCharacteristicsComplianceMigrationTest/insert_usability_at_the_top_if_security_does_exists.xml
deleted file mode 100644 (file)
index 7ab9a97..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-<dataset>
-
-  <characteristics id="1" kee="REUSABILITY" name="Reusability" parent_id="[null]" rule_id="[null]" characteristic_order="1" enabled="[true]" created_at="2013-11-20"
-                   updated_at="2013-11-22"/>
-
-  <characteristics id="2" kee="PORTABILITY" name="Portability" parent_id="[null]" rule_id="[null]" characteristic_order="2" enabled="[true]" created_at="2013-11-20"
-                   updated_at="2013-11-22"/>
-
-</dataset>
diff --git a/server/sonar-server/src/test/resources/org/sonar/server/db/migrations/v51/AddCharacteristicUsabilityAndSubCharacteristicsComplianceMigrationTest/migrate-result.xml b/server/sonar-server/src/test/resources/org/sonar/server/db/migrations/v51/AddCharacteristicUsabilityAndSubCharacteristicsComplianceMigrationTest/migrate-result.xml
deleted file mode 100644 (file)
index 91f1c6a..0000000
+++ /dev/null
@@ -1,74 +0,0 @@
-<dataset>
-
-  <characteristics id="1" kee="REUSABILITY" name="Reusability" parent_id="[null]" rule_id="[null]" characteristic_order="1" enabled="[true]" created_at="2013-11-20"
-                   updated_at="2013-11-22"/>
-
-  <characteristics id="2" kee="PORTABILITY" name="Portability" parent_id="[null]" rule_id="[null]" characteristic_order="2" enabled="[true]" created_at="2013-11-20"
-                   updated_at="2013-11-22"/>
-
-  <characteristics id="3" kee="MAINTAINABILITY" name="Maintainability" parent_id="[null]" rule_id="[null]" characteristic_order="3" enabled="[true]" created_at="2013-11-20"
-                   updated_at="2013-11-22"/>
-
-  <characteristics id="4" kee="SECURITY" name="Security" parent_id="[null]" rule_id="[null]" characteristic_order="4" enabled="[true]" created_at="2013-11-20"
-                   updated_at="2013-11-22"/>
-
-  <!-- Oder has changed : this characteristic is now one step lower -->
-  <characteristics id="5" kee="EFFICIENCY" name="Efficiency" parent_id="[null]" rule_id="[null]" characteristic_order="6" enabled="[true]" created_at="2013-11-20"
-                   updated_at="2015-02-15"/>
-
-  <!-- Oder has changed : this characteristic is now one step lower -->
-  <characteristics id="6" kee="CHANGEABILITY" name="Changeability" parent_id="[null]" rule_id="[null]" characteristic_order="7" enabled="[true]" created_at="2013-11-20"
-                   updated_at="2015-02-15"/>
-
-  <!-- Oder has changed : this characteristic is now one step lower -->
-  <characteristics id="7" kee="RELIABILITY" name="Reliability" parent_id="[null]" rule_id="[null]" characteristic_order="8" enabled="[true]" created_at="2013-11-20"
-                   updated_at="2015-02-15"/>
-
-  <!-- Oder has changed : this characteristic is now one step lower -->
-  <characteristics id="8" kee="TESTABILITY" name="Testability" parent_id="[null]" rule_id="[null]" characteristic_order="9" enabled="[true]" created_at="2013-11-20"
-                   updated_at="2015-02-15"/>
-
-  <!-- New characteristic 'Usability' is after Security -->
-  <characteristics id="9" kee="USABILITY" name="Usability" parent_id="[null]" rule_id="[null]" characteristic_order="5" enabled="[true]" created_at="2015-02-15"
-                   updated_at="[null]"/>
-  <!-- New sub characteristics under Usability -->
-  <characteristics id="10" kee="USABILITY_ACCESSIBILITY" name="Accessibility" parent_id="9" rule_id="[null]" characteristic_order="[null]" enabled="[true]" created_at="2015-02-15"
-                   updated_at="[null]"/>
-  <characteristics id="11" kee="USABILITY_EASE_OF_USE" name="Ease of Use" parent_id="9" rule_id="[null]" characteristic_order="[null]" enabled="[true]" created_at="2015-02-15"
-                   updated_at="[null]"/>
-  <characteristics id="12" kee="USABILITY_COMPLIANCE" name="Usability Compliance" parent_id="9" rule_id="[null]" characteristic_order="[null]" enabled="[true]"
-                   created_at="2015-02-15" updated_at="[null]"/>
-
-  <!-- New sub characteristic 'Compliance' under Reusability -->
-  <characteristics id="13" kee="REUSABILITY_COMPLIANCE" name="Reusability Compliance" parent_id="1" rule_id="[null]" characteristic_order="[null]" enabled="[true]"
-                   created_at="2015-02-15" updated_at="[null]"/>
-
-  <!-- New sub characteristic 'Compliance' under Portability -->
-  <characteristics id="14" kee="PORTABILITY_COMPLIANCE" name="Portability Compliance" parent_id="2" rule_id="[null]" characteristic_order="[null]" enabled="[true]"
-                   created_at="2015-02-15" updated_at="[null]"/>
-
-  <!-- New sub characteristic 'Compliance' under Maintainability -->
-  <characteristics id="15" kee="MAINTAINABILITY_COMPLIANCE" name="Maintainability Compliance" parent_id="3" rule_id="[null]" characteristic_order="[null]" enabled="[true]"
-                   created_at="2015-02-15" updated_at="[null]"/>
-
-  <!-- New sub characteristic 'Compliance' under Security -->
-  <characteristics id="16" kee="SECURITY_COMPLIANCE" name="Security Compliance" parent_id="4" rule_id="[null]" characteristic_order="[null]" enabled="[true]"
-                   created_at="2015-02-15" updated_at="[null]"/>
-
-  <!-- New sub characteristic 'Compliance' under Efficiency -->
-  <characteristics id="17" kee="EFFICIENCY_COMPLIANCE" name="Efficiency Compliance" parent_id="5" rule_id="[null]" characteristic_order="[null]" enabled="[true]"
-                   created_at="2015-02-15" updated_at="[null]"/>
-
-  <!-- New sub characteristic 'Compliance' under Changeability -->
-  <characteristics id="18" kee="CHANGEABILITY_COMPLIANCE" name="Changeability Compliance" parent_id="6" rule_id="[null]" characteristic_order="[null]" enabled="[true]"
-                   created_at="2015-02-15" updated_at="[null]"/>
-
-  <!-- New sub characteristic 'Compliance' under Reliability -->
-  <characteristics id="19" kee="RELIABILITY_COMPLIANCE" name="Reliability Compliance" parent_id="7" rule_id="[null]" characteristic_order="[null]" enabled="[true]"
-                   created_at="2015-02-15" updated_at="[null]"/>
-
-  <!-- New sub characteristic 'Compliance' under Testability -->
-  <characteristics id="20" kee="TESTABILITY_COMPLIANCE" name="Testability Compliance" parent_id="8" rule_id="[null]" characteristic_order="[null]" enabled="[true]"
-                   created_at="2015-02-15" updated_at="[null]"/>
-
-</dataset>
diff --git a/server/sonar-server/src/test/resources/org/sonar/server/db/migrations/v51/AddCharacteristicUsabilityAndSubCharacteristicsComplianceMigrationTest/migrate.xml b/server/sonar-server/src/test/resources/org/sonar/server/db/migrations/v51/AddCharacteristicUsabilityAndSubCharacteristicsComplianceMigrationTest/migrate.xml
deleted file mode 100644 (file)
index 2d92c7c..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-<dataset>
-
-  <characteristics id="1" kee="REUSABILITY" name="Reusability" parent_id="[null]" rule_id="[null]" characteristic_order="1" enabled="[true]" created_at="2013-11-20"
-                   updated_at="2013-11-22"/>
-
-  <characteristics id="2" kee="PORTABILITY" name="Portability" parent_id="[null]" rule_id="[null]" characteristic_order="2" enabled="[true]" created_at="2013-11-20"
-                   updated_at="2013-11-22"/>
-
-  <characteristics id="3" kee="MAINTAINABILITY" name="Maintainability" parent_id="[null]" rule_id="[null]" characteristic_order="3" enabled="[true]" created_at="2013-11-20"
-                   updated_at="2013-11-22"/>
-
-  <characteristics id="4" kee="SECURITY" name="Security" parent_id="[null]" rule_id="[null]" characteristic_order="4" enabled="[true]" created_at="2013-11-20"
-                   updated_at="2013-11-22"/>
-
-  <characteristics id="5" kee="EFFICIENCY" name="Efficiency" parent_id="[null]" rule_id="[null]" characteristic_order="5" enabled="[true]" created_at="2013-11-20"
-                   updated_at="2013-11-22"/>
-
-  <characteristics id="6" kee="CHANGEABILITY" name="Changeability" parent_id="[null]" rule_id="[null]" characteristic_order="6" enabled="[true]" created_at="2013-11-20"
-                   updated_at="2013-11-22"/>
-
-  <characteristics id="7" kee="RELIABILITY" name="Reliability" parent_id="[null]" rule_id="[null]" characteristic_order="7" enabled="[true]" created_at="2013-11-20"
-                   updated_at="2013-11-22"/>
-
-  <characteristics id="8" kee="TESTABILITY" name="Testability" parent_id="[null]" rule_id="[null]" characteristic_order="8" enabled="[true]" created_at="2013-11-20"
-                   updated_at="2013-11-22"/>
-
-</dataset>
diff --git a/server/sonar-server/src/test/resources/org/sonar/server/db/migrations/v51/AddCharacteristicUsabilityAndSubCharacteristicsComplianceMigrationTest/not_fail_if_some_deprecated_requirements_still_exists_in_db.xml b/server/sonar-server/src/test/resources/org/sonar/server/db/migrations/v51/AddCharacteristicUsabilityAndSubCharacteristicsComplianceMigrationTest/not_fail_if_some_deprecated_requirements_still_exists_in_db.xml
deleted file mode 100644 (file)
index 6953f52..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-<dataset>
-
-  <characteristics id="1" kee="USABILITY" name="Usability" parent_id="[null]" rule_id="[null]" characteristic_order="1" enabled="[true]" created_at="2013-11-20"
-                   updated_at="2013-11-22"/>
-  <characteristics id="2" kee="USABILITY_ACCESSIBILITY" name="Accessibility" parent_id="1" rule_id="[null]" characteristic_order="[null]" enabled="[true]" created_at="2013-11-20"
-                   updated_at="[null]"/>
-  <characteristics id="3" kee="USABILITY_EASE_OF_USE" name="Ease of Use" parent_id="1" rule_id="[null]" characteristic_order="[null]" enabled="[true]" created_at="2013-11-20"
-                   updated_at="[null]"/>
-  <characteristics id="4" kee="USABILITY_COMPLIANCE" name="Usability Compliance" parent_id="1" rule_id="[null]" characteristic_order="[null]" enabled="[true]"
-                   created_at="2013-11-20" updated_at="[null]"/>
-
-  <characteristics id="5" kee="[null]" name="[null]" parent_id="3" rule_id="3" characteristic_order="[null]" enabled="[true]" created_at="2013-11-20" updated_at="2013-11-22"/>
-
-</dataset>
diff --git a/server/sonar-server/src/test/resources/org/sonar/server/db/migrations/v51/AddCharacteristicUsabilityAndSubCharacteristicsComplianceMigrationTest/schema.sql b/server/sonar-server/src/test/resources/org/sonar/server/db/migrations/v51/AddCharacteristicUsabilityAndSubCharacteristicsComplianceMigrationTest/schema.sql
deleted file mode 100644 (file)
index 98c025d..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-CREATE TABLE "CHARACTERISTICS" (
-  "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1),
-  "KEE" VARCHAR(100),
-  "NAME" VARCHAR(100),
-  "PARENT_ID" INTEGER,
-  "RULE_ID" INTEGER,
-  "CHARACTERISTIC_ORDER" INTEGER,
-  "ENABLED" BOOLEAN,
-  "CREATED_AT" TIMESTAMP,
-  "UPDATED_AT" TIMESTAMP
-);
diff --git a/server/sonar-server/src/test/resources/org/sonar/server/db/migrations/v51/AddCharacteristicUsabilityAndSubCharacteristicsComplianceMigrationTest/update_usability_if_already_exists-result.xml b/server/sonar-server/src/test/resources/org/sonar/server/db/migrations/v51/AddCharacteristicUsabilityAndSubCharacteristicsComplianceMigrationTest/update_usability_if_already_exists-result.xml
deleted file mode 100644 (file)
index 1b12df0..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-<dataset>
-
-  <characteristics id="1" kee="SECURITY" name="Security" parent_id="[null]" rule_id="[null]" characteristic_order="4" enabled="[true]" created_at="2013-11-20"
-                   updated_at="2013-11-22"/>
-
-  <!-- Oder has changed : this characteristic is now one step lower -->
-  <characteristics id="2" kee="EFFICIENCY" name="Efficiency" parent_id="[null]" rule_id="[null]" characteristic_order="6" enabled="[true]" created_at="2013-11-20"
-                   updated_at="2015-02-15"/>
-
-  <!-- Usability is moved after Security -->
-  <characteristics id="3" kee="USABILITY" name="Usability" parent_id="[null]" rule_id="[null]" characteristic_order="5" enabled="[true]" created_at="2013-11-20"
-                   updated_at="2015-02-15"/>
-
-  <!-- New sub characteristics under Usability -->
-  <characteristics id="4" kee="USABILITY_ACCESSIBILITY" name="Accessibility" parent_id="3" rule_id="[null]" characteristic_order="[null]" enabled="[true]" created_at="2015-02-15"
-                   updated_at="[null]"/>
-  <characteristics id="5" kee="USABILITY_EASE_OF_USE" name="Ease of Use" parent_id="3" rule_id="[null]" characteristic_order="[null]" enabled="[true]" created_at="2015-02-15"
-                   updated_at="[null]"/>
-  <characteristics id="6" kee="USABILITY_COMPLIANCE" name="Usability Compliance" parent_id="3" rule_id="[null]" characteristic_order="[null]" enabled="[true]"
-                   created_at="2015-02-15" updated_at="[null]"/>
-
-  <!-- New sub characteristic 'Compliance' under Security -->
-  <characteristics id="7" kee="SECURITY_COMPLIANCE" name="Security Compliance" parent_id="1" rule_id="[null]" characteristic_order="[null]" enabled="[true]" created_at="2015-02-15"
-                   updated_at="[null]"/>
-
-  <!-- New sub characteristic 'Compliance' under Efficiency -->
-  <characteristics id="8" kee="EFFICIENCY_COMPLIANCE" name="Efficiency Compliance" parent_id="2" rule_id="[null]" characteristic_order="[null]" enabled="[true]"
-                   created_at="2015-02-15" updated_at="[null]"/>
-
-</dataset>
diff --git a/server/sonar-server/src/test/resources/org/sonar/server/db/migrations/v51/AddCharacteristicUsabilityAndSubCharacteristicsComplianceMigrationTest/update_usability_if_already_exists.xml b/server/sonar-server/src/test/resources/org/sonar/server/db/migrations/v51/AddCharacteristicUsabilityAndSubCharacteristicsComplianceMigrationTest/update_usability_if_already_exists.xml
deleted file mode 100644 (file)
index 33d901d..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-<dataset>
-
-  <characteristics id="1" kee="SECURITY" name="Security" parent_id="[null]" rule_id="[null]" characteristic_order="4" enabled="[true]" created_at="2013-11-20"
-                   updated_at="2013-11-22"/>
-
-  <characteristics id="2" kee="EFFICIENCY" name="Efficiency" parent_id="[null]" rule_id="[null]" characteristic_order="5" enabled="[true]" created_at="2013-11-20"
-                   updated_at="2013-11-22"/>
-
-  <!-- Usability should be move after Security -->
-  <characteristics id="3" kee="USABILITY" name="Usability" parent_id="[null]" rule_id="[null]" characteristic_order="6" enabled="[true]" created_at="2013-11-20"
-                   updated_at="2013-11-22"/>
-
-</dataset>
diff --git a/server/sonar-server/src/test/resources/org/sonar/server/db/migrations/v51/AddNewCharacteristicsTest/do_nothing_when_already_migrated.xml b/server/sonar-server/src/test/resources/org/sonar/server/db/migrations/v51/AddNewCharacteristicsTest/do_nothing_when_already_migrated.xml
new file mode 100644 (file)
index 0000000..b8ff37c
--- /dev/null
@@ -0,0 +1,53 @@
+<dataset>
+
+  <characteristics id="1" kee="REUSABILITY" name="Reusability" parent_id="[null]" rule_id="[null]" characteristic_order="1" enabled="[true]" created_at="2013-11-20"
+                   updated_at="2013-11-22"/>
+  <characteristics id="2" kee="REUSABILITY_COMPLIANCE" name="Reusability Compliance" parent_id="1" rule_id="[null]" characteristic_order="[null]" enabled="[true]"
+                   created_at="2013-11-20" updated_at="[null]"/>
+
+  <characteristics id="3" kee="PORTABILITY" name="Portability" parent_id="[null]" rule_id="[null]" characteristic_order="2" enabled="[true]" created_at="2013-11-20"
+                   updated_at="2013-11-22"/>
+  <characteristics id="4" kee="PORTABILITY_COMPLIANCE" name="Portability Compliance" parent_id="3" rule_id="[null]" characteristic_order="[null]" enabled="[true]"
+                   created_at="2013-11-20" updated_at="[null]"/>
+
+  <characteristics id="5" kee="MAINTAINABILITY" name="Maintainability" parent_id="[null]" rule_id="[null]" characteristic_order="3" enabled="[true]" created_at="2013-11-20"
+                   updated_at="2013-11-22"/>
+  <characteristics id="6" kee="MAINTAINABILITY_COMPLIANCE" name="Maintainability Compliance" parent_id="5" rule_id="[null]" characteristic_order="[null]" enabled="[true]"
+                   created_at="2013-11-20" updated_at="[null]"/>
+
+  <characteristics id="7" kee="SECURITY" name="Security" parent_id="[null]" rule_id="[null]" characteristic_order="4" enabled="[true]" created_at="2013-11-20"
+                   updated_at="2013-11-22"/>
+  <characteristics id="8" kee="SECURITY_COMPLIANCE" name="Security Compliance" parent_id="7" rule_id="[null]" characteristic_order="[null]" enabled="[true]" created_at="2013-11-20"
+                   updated_at="[null]"/>
+
+  <characteristics id="9" kee="USABILITY" name="Usability" parent_id="[null]" rule_id="[null]" characteristic_order="5" enabled="[true]" created_at="2013-11-20"
+                   updated_at="[null]"/>
+  <characteristics id="10" kee="USABILITY_ACCESSIBILITY" name="Accessibility" parent_id="9" rule_id="[null]" characteristic_order="[null]" enabled="[true]" created_at="2013-11-20"
+                   updated_at="[null]"/>
+  <characteristics id="11" kee="USABILITY_EASE_OF_USE" name="Ease of Use" parent_id="9" rule_id="[null]" characteristic_order="[null]" enabled="[true]" created_at="2013-11-20"
+                   updated_at="[null]"/>
+  <characteristics id="12" kee="USABILITY_COMPLIANCE" name="Usability Compliance" parent_id="9" rule_id="[null]" characteristic_order="[null]" enabled="[true]"
+                   created_at="2013-11-20" updated_at="[null]"/>
+
+  <characteristics id="13" kee="EFFICIENCY" name="Efficiency" parent_id="[null]" rule_id="[null]" characteristic_order="6" enabled="[true]" created_at="2013-11-20"
+                   updated_at="2013-11-20"/>
+  <characteristics id="14" kee="EFFICIENCY_COMPLIANCE" name="Efficiency Compliance" parent_id="13" rule_id="[null]" characteristic_order="[null]" enabled="[true]"
+                   created_at="2013-11-20" updated_at="[null]"/>
+
+  <characteristics id="15" kee="CHANGEABILITY" name="Changeability" parent_id="[null]" rule_id="[null]" characteristic_order="7" enabled="[true]" created_at="2013-11-20"
+                   updated_at="2013-11-20"/>
+  <characteristics id="16" kee="CHANGEABILITY_COMPLIANCE" name="Changeability Compliance" parent_id="15" rule_id="[null]" characteristic_order="[null]" enabled="[true]"
+                   created_at="2013-11-20" updated_at="[null]"/>
+
+  <characteristics id="17" kee="RELIABILITY" name="Reliability" parent_id="[null]" rule_id="[null]" characteristic_order="8" enabled="[true]" created_at="2013-11-20"
+                   updated_at="2013-11-20"/>
+  <characteristics id="18" kee="RELIABILITY_COMPLIANCE" name="Reliability Compliance" parent_id="17" rule_id="[null]" characteristic_order="[null]" enabled="[true]"
+                   created_at="2013-11-20" updated_at="[null]"/>
+
+  <characteristics id="19" kee="TESTABILITY" name="Testability" parent_id="[null]" rule_id="[null]" characteristic_order="9" enabled="[true]" created_at="2013-11-20"
+                   updated_at="2013-11-20"/>
+  <characteristics id="20" kee="TESTABILITY_COMPLIANCE" name="Testability Compliance" parent_id="19" rule_id="[null]" characteristic_order="[null]" enabled="[true]"
+                   created_at="2013-11-20" updated_at="[null]"/>
+
+
+</dataset>
diff --git a/server/sonar-server/src/test/resources/org/sonar/server/db/migrations/v51/AddNewCharacteristicsTest/empty.xml b/server/sonar-server/src/test/resources/org/sonar/server/db/migrations/v51/AddNewCharacteristicsTest/empty.xml
new file mode 100644 (file)
index 0000000..871dedc
--- /dev/null
@@ -0,0 +1,3 @@
+<dataset>
+
+</dataset>
diff --git a/server/sonar-server/src/test/resources/org/sonar/server/db/migrations/v51/AddNewCharacteristicsTest/fail_if_compliance_already_exists_as_characteristic.xml b/server/sonar-server/src/test/resources/org/sonar/server/db/migrations/v51/AddNewCharacteristicsTest/fail_if_compliance_already_exists_as_characteristic.xml
new file mode 100644 (file)
index 0000000..1f2f39b
--- /dev/null
@@ -0,0 +1,9 @@
+<dataset>
+
+  <characteristics id="1" kee="REUSABILITY" name="Reusability" parent_id="[null]" rule_id="[null]" characteristic_order="1" enabled="[true]" created_at="2013-11-20"
+                   updated_at="2013-11-22"/>
+
+  <characteristics id="2" kee="REUSABILITY_COMPLIANCE" name="Compliance" parent_id="[null]" rule_id="[null]" characteristic_order="2" enabled="[true]" created_at="2013-11-20"
+                   updated_at="[null]"/>
+
+</dataset>
diff --git a/server/sonar-server/src/test/resources/org/sonar/server/db/migrations/v51/AddNewCharacteristicsTest/fail_if_compliance_already_exists_under_wrong_characteristic.xml b/server/sonar-server/src/test/resources/org/sonar/server/db/migrations/v51/AddNewCharacteristicsTest/fail_if_compliance_already_exists_under_wrong_characteristic.xml
new file mode 100644 (file)
index 0000000..3dbfebd
--- /dev/null
@@ -0,0 +1,13 @@
+<dataset>
+
+  <characteristics id="1" kee="REUSABILITY" name="Reusability" parent_id="[null]" rule_id="[null]" characteristic_order="1" enabled="[true]" created_at="2013-11-20"
+                   updated_at="2013-11-22"/>
+
+  <characteristics id="2" kee="PORTABILITY" name="Portability" parent_id="[null]" rule_id="[null]" characteristic_order="2" enabled="[true]" created_at="2013-11-20"
+                   updated_at="2013-11-22"/>
+
+  <characteristics id="3" kee="REUSABILITY_COMPLIANCE" name="Reusability Compliance" parent_id="2" rule_id="[null]" characteristic_order="[null]" enabled="[true]"
+                   created_at="2013-11-20"
+                   updated_at="[null]"/>
+
+</dataset>
diff --git a/server/sonar-server/src/test/resources/org/sonar/server/db/migrations/v51/AddNewCharacteristicsTest/fail_if_usability_exists_as_sub_characteristic.xml b/server/sonar-server/src/test/resources/org/sonar/server/db/migrations/v51/AddNewCharacteristicsTest/fail_if_usability_exists_as_sub_characteristic.xml
new file mode 100644 (file)
index 0000000..70016cc
--- /dev/null
@@ -0,0 +1,9 @@
+<dataset>
+
+  <characteristics id="1" kee="REUSABILITY" name="Reusability" parent_id="[null]" rule_id="[null]" characteristic_order="1" enabled="[true]" created_at="2013-11-20"
+                   updated_at="2013-11-22"/>
+
+  <characteristics id="2" kee="USABILITY" name="Usability" parent_id="1" rule_id="[null]" characteristic_order="[null]" enabled="[true]" created_at="2013-11-20"
+                   updated_at="2013-11-22"/>
+
+</dataset>
diff --git a/server/sonar-server/src/test/resources/org/sonar/server/db/migrations/v51/AddNewCharacteristicsTest/insert_usability_at_the_top_if_security_does_exists-result.xml b/server/sonar-server/src/test/resources/org/sonar/server/db/migrations/v51/AddNewCharacteristicsTest/insert_usability_at_the_top_if_security_does_exists-result.xml
new file mode 100644 (file)
index 0000000..4f59620
--- /dev/null
@@ -0,0 +1,30 @@
+<dataset>
+
+  <!-- Oder has changed : this characteristic is now one step lower -->
+  <characteristics id="1" kee="REUSABILITY" name="Reusability" parent_id="[null]" rule_id="[null]" characteristic_order="2" enabled="[true]" created_at="2013-11-20"
+                   updated_at="2015-02-15"/>
+
+  <!-- Oder has changed : this characteristic is now one step lower -->
+  <characteristics id="2" kee="PORTABILITY" name="Portability" parent_id="[null]" rule_id="[null]" characteristic_order="3" enabled="[true]" created_at="2013-11-20"
+                   updated_at="2015-02-15"/>
+
+  <!-- New characteristic 'Usability' is on the top (order 1) -->
+  <characteristics id="3" kee="USABILITY" name="Usability" parent_id="[null]" rule_id="[null]" characteristic_order="1" enabled="[true]" created_at="2015-02-15"
+                   updated_at="[null]"/>
+  <characteristics id="4" kee="USABILITY_ACCESSIBILITY" name="Accessibility" parent_id="3" rule_id="[null]" characteristic_order="[null]" enabled="[true]" created_at="2015-02-15"
+                   updated_at="[null]"/>
+  <characteristics id="5" kee="USABILITY_EASE_OF_USE" name="Ease of Use" parent_id="3" rule_id="[null]" characteristic_order="[null]" enabled="[true]" created_at="2015-02-15"
+                   updated_at="[null]"/>
+  <characteristics id="6" kee="USABILITY_COMPLIANCE" name="Usability Compliance" parent_id="3" rule_id="[null]" characteristic_order="[null]" enabled="[true]"
+                   created_at="2015-02-15" updated_at="[null]"/>
+
+
+  <!-- New sub characteristic 'Compliance' under Reusability -->
+  <characteristics id="7" kee="REUSABILITY_COMPLIANCE" name="Reusability Compliance" parent_id="1" rule_id="[null]" characteristic_order="[null]" enabled="[true]"
+                   created_at="2015-02-15" updated_at="[null]"/>
+
+  <!-- New sub characteristic 'Compliance' under Portability -->
+  <characteristics id="8" kee="PORTABILITY_COMPLIANCE" name="Portability Compliance" parent_id="2" rule_id="[null]" characteristic_order="[null]" enabled="[true]"
+                   created_at="2015-02-15" updated_at="[null]"/>
+
+</dataset>
diff --git a/server/sonar-server/src/test/resources/org/sonar/server/db/migrations/v51/AddNewCharacteristicsTest/insert_usability_at_the_top_if_security_does_exists.xml b/server/sonar-server/src/test/resources/org/sonar/server/db/migrations/v51/AddNewCharacteristicsTest/insert_usability_at_the_top_if_security_does_exists.xml
new file mode 100644 (file)
index 0000000..7ab9a97
--- /dev/null
@@ -0,0 +1,9 @@
+<dataset>
+
+  <characteristics id="1" kee="REUSABILITY" name="Reusability" parent_id="[null]" rule_id="[null]" characteristic_order="1" enabled="[true]" created_at="2013-11-20"
+                   updated_at="2013-11-22"/>
+
+  <characteristics id="2" kee="PORTABILITY" name="Portability" parent_id="[null]" rule_id="[null]" characteristic_order="2" enabled="[true]" created_at="2013-11-20"
+                   updated_at="2013-11-22"/>
+
+</dataset>
diff --git a/server/sonar-server/src/test/resources/org/sonar/server/db/migrations/v51/AddNewCharacteristicsTest/migrate-result.xml b/server/sonar-server/src/test/resources/org/sonar/server/db/migrations/v51/AddNewCharacteristicsTest/migrate-result.xml
new file mode 100644 (file)
index 0000000..91f1c6a
--- /dev/null
@@ -0,0 +1,74 @@
+<dataset>
+
+  <characteristics id="1" kee="REUSABILITY" name="Reusability" parent_id="[null]" rule_id="[null]" characteristic_order="1" enabled="[true]" created_at="2013-11-20"
+                   updated_at="2013-11-22"/>
+
+  <characteristics id="2" kee="PORTABILITY" name="Portability" parent_id="[null]" rule_id="[null]" characteristic_order="2" enabled="[true]" created_at="2013-11-20"
+                   updated_at="2013-11-22"/>
+
+  <characteristics id="3" kee="MAINTAINABILITY" name="Maintainability" parent_id="[null]" rule_id="[null]" characteristic_order="3" enabled="[true]" created_at="2013-11-20"
+                   updated_at="2013-11-22"/>
+
+  <characteristics id="4" kee="SECURITY" name="Security" parent_id="[null]" rule_id="[null]" characteristic_order="4" enabled="[true]" created_at="2013-11-20"
+                   updated_at="2013-11-22"/>
+
+  <!-- Oder has changed : this characteristic is now one step lower -->
+  <characteristics id="5" kee="EFFICIENCY" name="Efficiency" parent_id="[null]" rule_id="[null]" characteristic_order="6" enabled="[true]" created_at="2013-11-20"
+                   updated_at="2015-02-15"/>
+
+  <!-- Oder has changed : this characteristic is now one step lower -->
+  <characteristics id="6" kee="CHANGEABILITY" name="Changeability" parent_id="[null]" rule_id="[null]" characteristic_order="7" enabled="[true]" created_at="2013-11-20"
+                   updated_at="2015-02-15"/>
+
+  <!-- Oder has changed : this characteristic is now one step lower -->
+  <characteristics id="7" kee="RELIABILITY" name="Reliability" parent_id="[null]" rule_id="[null]" characteristic_order="8" enabled="[true]" created_at="2013-11-20"
+                   updated_at="2015-02-15"/>
+
+  <!-- Oder has changed : this characteristic is now one step lower -->
+  <characteristics id="8" kee="TESTABILITY" name="Testability" parent_id="[null]" rule_id="[null]" characteristic_order="9" enabled="[true]" created_at="2013-11-20"
+                   updated_at="2015-02-15"/>
+
+  <!-- New characteristic 'Usability' is after Security -->
+  <characteristics id="9" kee="USABILITY" name="Usability" parent_id="[null]" rule_id="[null]" characteristic_order="5" enabled="[true]" created_at="2015-02-15"
+                   updated_at="[null]"/>
+  <!-- New sub characteristics under Usability -->
+  <characteristics id="10" kee="USABILITY_ACCESSIBILITY" name="Accessibility" parent_id="9" rule_id="[null]" characteristic_order="[null]" enabled="[true]" created_at="2015-02-15"
+                   updated_at="[null]"/>
+  <characteristics id="11" kee="USABILITY_EASE_OF_USE" name="Ease of Use" parent_id="9" rule_id="[null]" characteristic_order="[null]" enabled="[true]" created_at="2015-02-15"
+                   updated_at="[null]"/>
+  <characteristics id="12" kee="USABILITY_COMPLIANCE" name="Usability Compliance" parent_id="9" rule_id="[null]" characteristic_order="[null]" enabled="[true]"
+                   created_at="2015-02-15" updated_at="[null]"/>
+
+  <!-- New sub characteristic 'Compliance' under Reusability -->
+  <characteristics id="13" kee="REUSABILITY_COMPLIANCE" name="Reusability Compliance" parent_id="1" rule_id="[null]" characteristic_order="[null]" enabled="[true]"
+                   created_at="2015-02-15" updated_at="[null]"/>
+
+  <!-- New sub characteristic 'Compliance' under Portability -->
+  <characteristics id="14" kee="PORTABILITY_COMPLIANCE" name="Portability Compliance" parent_id="2" rule_id="[null]" characteristic_order="[null]" enabled="[true]"
+                   created_at="2015-02-15" updated_at="[null]"/>
+
+  <!-- New sub characteristic 'Compliance' under Maintainability -->
+  <characteristics id="15" kee="MAINTAINABILITY_COMPLIANCE" name="Maintainability Compliance" parent_id="3" rule_id="[null]" characteristic_order="[null]" enabled="[true]"
+                   created_at="2015-02-15" updated_at="[null]"/>
+
+  <!-- New sub characteristic 'Compliance' under Security -->
+  <characteristics id="16" kee="SECURITY_COMPLIANCE" name="Security Compliance" parent_id="4" rule_id="[null]" characteristic_order="[null]" enabled="[true]"
+                   created_at="2015-02-15" updated_at="[null]"/>
+
+  <!-- New sub characteristic 'Compliance' under Efficiency -->
+  <characteristics id="17" kee="EFFICIENCY_COMPLIANCE" name="Efficiency Compliance" parent_id="5" rule_id="[null]" characteristic_order="[null]" enabled="[true]"
+                   created_at="2015-02-15" updated_at="[null]"/>
+
+  <!-- New sub characteristic 'Compliance' under Changeability -->
+  <characteristics id="18" kee="CHANGEABILITY_COMPLIANCE" name="Changeability Compliance" parent_id="6" rule_id="[null]" characteristic_order="[null]" enabled="[true]"
+                   created_at="2015-02-15" updated_at="[null]"/>
+
+  <!-- New sub characteristic 'Compliance' under Reliability -->
+  <characteristics id="19" kee="RELIABILITY_COMPLIANCE" name="Reliability Compliance" parent_id="7" rule_id="[null]" characteristic_order="[null]" enabled="[true]"
+                   created_at="2015-02-15" updated_at="[null]"/>
+
+  <!-- New sub characteristic 'Compliance' under Testability -->
+  <characteristics id="20" kee="TESTABILITY_COMPLIANCE" name="Testability Compliance" parent_id="8" rule_id="[null]" characteristic_order="[null]" enabled="[true]"
+                   created_at="2015-02-15" updated_at="[null]"/>
+
+</dataset>
diff --git a/server/sonar-server/src/test/resources/org/sonar/server/db/migrations/v51/AddNewCharacteristicsTest/migrate.xml b/server/sonar-server/src/test/resources/org/sonar/server/db/migrations/v51/AddNewCharacteristicsTest/migrate.xml
new file mode 100644 (file)
index 0000000..2d92c7c
--- /dev/null
@@ -0,0 +1,27 @@
+<dataset>
+
+  <characteristics id="1" kee="REUSABILITY" name="Reusability" parent_id="[null]" rule_id="[null]" characteristic_order="1" enabled="[true]" created_at="2013-11-20"
+                   updated_at="2013-11-22"/>
+
+  <characteristics id="2" kee="PORTABILITY" name="Portability" parent_id="[null]" rule_id="[null]" characteristic_order="2" enabled="[true]" created_at="2013-11-20"
+                   updated_at="2013-11-22"/>
+
+  <characteristics id="3" kee="MAINTAINABILITY" name="Maintainability" parent_id="[null]" rule_id="[null]" characteristic_order="3" enabled="[true]" created_at="2013-11-20"
+                   updated_at="2013-11-22"/>
+
+  <characteristics id="4" kee="SECURITY" name="Security" parent_id="[null]" rule_id="[null]" characteristic_order="4" enabled="[true]" created_at="2013-11-20"
+                   updated_at="2013-11-22"/>
+
+  <characteristics id="5" kee="EFFICIENCY" name="Efficiency" parent_id="[null]" rule_id="[null]" characteristic_order="5" enabled="[true]" created_at="2013-11-20"
+                   updated_at="2013-11-22"/>
+
+  <characteristics id="6" kee="CHANGEABILITY" name="Changeability" parent_id="[null]" rule_id="[null]" characteristic_order="6" enabled="[true]" created_at="2013-11-20"
+                   updated_at="2013-11-22"/>
+
+  <characteristics id="7" kee="RELIABILITY" name="Reliability" parent_id="[null]" rule_id="[null]" characteristic_order="7" enabled="[true]" created_at="2013-11-20"
+                   updated_at="2013-11-22"/>
+
+  <characteristics id="8" kee="TESTABILITY" name="Testability" parent_id="[null]" rule_id="[null]" characteristic_order="8" enabled="[true]" created_at="2013-11-20"
+                   updated_at="2013-11-22"/>
+
+</dataset>
diff --git a/server/sonar-server/src/test/resources/org/sonar/server/db/migrations/v51/AddNewCharacteristicsTest/not_fail_if_some_deprecated_requirements_still_exists_in_db.xml b/server/sonar-server/src/test/resources/org/sonar/server/db/migrations/v51/AddNewCharacteristicsTest/not_fail_if_some_deprecated_requirements_still_exists_in_db.xml
new file mode 100644 (file)
index 0000000..6953f52
--- /dev/null
@@ -0,0 +1,14 @@
+<dataset>
+
+  <characteristics id="1" kee="USABILITY" name="Usability" parent_id="[null]" rule_id="[null]" characteristic_order="1" enabled="[true]" created_at="2013-11-20"
+                   updated_at="2013-11-22"/>
+  <characteristics id="2" kee="USABILITY_ACCESSIBILITY" name="Accessibility" parent_id="1" rule_id="[null]" characteristic_order="[null]" enabled="[true]" created_at="2013-11-20"
+                   updated_at="[null]"/>
+  <characteristics id="3" kee="USABILITY_EASE_OF_USE" name="Ease of Use" parent_id="1" rule_id="[null]" characteristic_order="[null]" enabled="[true]" created_at="2013-11-20"
+                   updated_at="[null]"/>
+  <characteristics id="4" kee="USABILITY_COMPLIANCE" name="Usability Compliance" parent_id="1" rule_id="[null]" characteristic_order="[null]" enabled="[true]"
+                   created_at="2013-11-20" updated_at="[null]"/>
+
+  <characteristics id="5" kee="[null]" name="[null]" parent_id="3" rule_id="3" characteristic_order="[null]" enabled="[true]" created_at="2013-11-20" updated_at="2013-11-22"/>
+
+</dataset>
diff --git a/server/sonar-server/src/test/resources/org/sonar/server/db/migrations/v51/AddNewCharacteristicsTest/schema.sql b/server/sonar-server/src/test/resources/org/sonar/server/db/migrations/v51/AddNewCharacteristicsTest/schema.sql
new file mode 100644 (file)
index 0000000..98c025d
--- /dev/null
@@ -0,0 +1,11 @@
+CREATE TABLE "CHARACTERISTICS" (
+  "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1),
+  "KEE" VARCHAR(100),
+  "NAME" VARCHAR(100),
+  "PARENT_ID" INTEGER,
+  "RULE_ID" INTEGER,
+  "CHARACTERISTIC_ORDER" INTEGER,
+  "ENABLED" BOOLEAN,
+  "CREATED_AT" TIMESTAMP,
+  "UPDATED_AT" TIMESTAMP
+);
diff --git a/server/sonar-server/src/test/resources/org/sonar/server/db/migrations/v51/AddNewCharacteristicsTest/update_usability_if_already_exists-result.xml b/server/sonar-server/src/test/resources/org/sonar/server/db/migrations/v51/AddNewCharacteristicsTest/update_usability_if_already_exists-result.xml
new file mode 100644 (file)
index 0000000..1b12df0
--- /dev/null
@@ -0,0 +1,30 @@
+<dataset>
+
+  <characteristics id="1" kee="SECURITY" name="Security" parent_id="[null]" rule_id="[null]" characteristic_order="4" enabled="[true]" created_at="2013-11-20"
+                   updated_at="2013-11-22"/>
+
+  <!-- Oder has changed : this characteristic is now one step lower -->
+  <characteristics id="2" kee="EFFICIENCY" name="Efficiency" parent_id="[null]" rule_id="[null]" characteristic_order="6" enabled="[true]" created_at="2013-11-20"
+                   updated_at="2015-02-15"/>
+
+  <!-- Usability is moved after Security -->
+  <characteristics id="3" kee="USABILITY" name="Usability" parent_id="[null]" rule_id="[null]" characteristic_order="5" enabled="[true]" created_at="2013-11-20"
+                   updated_at="2015-02-15"/>
+
+  <!-- New sub characteristics under Usability -->
+  <characteristics id="4" kee="USABILITY_ACCESSIBILITY" name="Accessibility" parent_id="3" rule_id="[null]" characteristic_order="[null]" enabled="[true]" created_at="2015-02-15"
+                   updated_at="[null]"/>
+  <characteristics id="5" kee="USABILITY_EASE_OF_USE" name="Ease of Use" parent_id="3" rule_id="[null]" characteristic_order="[null]" enabled="[true]" created_at="2015-02-15"
+                   updated_at="[null]"/>
+  <characteristics id="6" kee="USABILITY_COMPLIANCE" name="Usability Compliance" parent_id="3" rule_id="[null]" characteristic_order="[null]" enabled="[true]"
+                   created_at="2015-02-15" updated_at="[null]"/>
+
+  <!-- New sub characteristic 'Compliance' under Security -->
+  <characteristics id="7" kee="SECURITY_COMPLIANCE" name="Security Compliance" parent_id="1" rule_id="[null]" characteristic_order="[null]" enabled="[true]" created_at="2015-02-15"
+                   updated_at="[null]"/>
+
+  <!-- New sub characteristic 'Compliance' under Efficiency -->
+  <characteristics id="8" kee="EFFICIENCY_COMPLIANCE" name="Efficiency Compliance" parent_id="2" rule_id="[null]" characteristic_order="[null]" enabled="[true]"
+                   created_at="2015-02-15" updated_at="[null]"/>
+
+</dataset>
diff --git a/server/sonar-server/src/test/resources/org/sonar/server/db/migrations/v51/AddNewCharacteristicsTest/update_usability_if_already_exists.xml b/server/sonar-server/src/test/resources/org/sonar/server/db/migrations/v51/AddNewCharacteristicsTest/update_usability_if_already_exists.xml
new file mode 100644 (file)
index 0000000..33d901d
--- /dev/null
@@ -0,0 +1,13 @@
+<dataset>
+
+  <characteristics id="1" kee="SECURITY" name="Security" parent_id="[null]" rule_id="[null]" characteristic_order="4" enabled="[true]" created_at="2013-11-20"
+                   updated_at="2013-11-22"/>
+
+  <characteristics id="2" kee="EFFICIENCY" name="Efficiency" parent_id="[null]" rule_id="[null]" characteristic_order="5" enabled="[true]" created_at="2013-11-20"
+                   updated_at="2013-11-22"/>
+
+  <!-- Usability should be move after Security -->
+  <characteristics id="3" kee="USABILITY" name="Usability" parent_id="[null]" rule_id="[null]" characteristic_order="6" enabled="[true]" created_at="2013-11-20"
+                   updated_at="2013-11-22"/>
+
+</dataset>
index 4c65c3c38647af7004686beda1e1a9eb83f878da..3637819ad25e13bee769ec595d1fc50210491f30 100644 (file)
@@ -25,7 +25,7 @@
 class AddCharacteristicUsabilityAndSubCharacteristicsCompliance < ActiveRecord::Migration
 
   def self.up
-    execute_java_migration 'org.sonar.server.db.migrations.v51.AddCharacteristicUsabilityAndSubCharacteristicsComplianceMigration'
+    execute_java_migration 'org.sonar.server.db.migrations.v51.AddNewCharacteristics'
   end
 
 end