]> source.dussan.org Git - sonarqube.git/commitdiff
Remove useless old debt model synchronization and renamed some debt classes
authorJulien Lancelot <julien.lancelot@sonarsource.com>
Fri, 14 Mar 2014 13:02:28 +0000 (14:02 +0100)
committerJulien Lancelot <julien.lancelot@sonarsource.com>
Fri, 14 Mar 2014 13:02:28 +0000 (14:02 +0100)
49 files changed:
sonar-core/src/main/java/org/sonar/core/technicaldebt/CharacteristicsDebtModelSynchronizer.java [deleted file]
sonar-core/src/main/java/org/sonar/core/technicaldebt/CharacteristicsDebtModelXMLImporter.java [deleted file]
sonar-core/src/main/java/org/sonar/core/technicaldebt/DebtCharacteristicsXMLImporter.java [new file with mode: 0644]
sonar-core/src/main/java/org/sonar/core/technicaldebt/DebtModelSynchronizer.java [new file with mode: 0644]
sonar-core/src/main/java/org/sonar/core/technicaldebt/DebtRulesXMLImporter.java [new file with mode: 0644]
sonar-core/src/main/java/org/sonar/core/technicaldebt/RulesDebtModelXMLImporter.java [deleted file]
sonar-core/src/test/java/org/sonar/core/technicaldebt/CharacteristicsDebtModelSynchronizerTest.java [deleted file]
sonar-core/src/test/java/org/sonar/core/technicaldebt/CharacteristicsDebtModelXMLImporterTest.java [deleted file]
sonar-core/src/test/java/org/sonar/core/technicaldebt/DebtCharacteristicsXMLImporterTest.java [new file with mode: 0644]
sonar-core/src/test/java/org/sonar/core/technicaldebt/DebtModelSynchronizerTest.java [new file with mode: 0644]
sonar-core/src/test/java/org/sonar/core/technicaldebt/DebtRulesXMLImporterTest.java [new file with mode: 0644]
sonar-core/src/test/java/org/sonar/core/technicaldebt/RulesDebtModelXMLImporterTest.java [deleted file]
sonar-core/src/test/resources/org/sonar/core/technicaldebt/CharacteristicsDebtModelXMLImporterTest/import_badly_formatted_xml.xml [deleted file]
sonar-core/src/test/resources/org/sonar/core/technicaldebt/CharacteristicsDebtModelXMLImporterTest/import_characteristics.xml [deleted file]
sonar-core/src/test/resources/org/sonar/core/technicaldebt/DebtCharacteristicsXMLImporterTest/import_badly_formatted_xml.xml [new file with mode: 0644]
sonar-core/src/test/resources/org/sonar/core/technicaldebt/DebtCharacteristicsXMLImporterTest/import_characteristics.xml [new file with mode: 0644]
sonar-core/src/test/resources/org/sonar/core/technicaldebt/DebtRulesXMLImporterTest/convert_deprecated_linear_with_threshold_function_by_linear_function.xml [new file with mode: 0644]
sonar-core/src/test/resources/org/sonar/core/technicaldebt/DebtRulesXMLImporterTest/ignore_deprecated_constant_per_file_function.xml [new file with mode: 0644]
sonar-core/src/test/resources/org/sonar/core/technicaldebt/DebtRulesXMLImporterTest/ignore_invalid_value.xml [new file with mode: 0644]
sonar-core/src/test/resources/org/sonar/core/technicaldebt/DebtRulesXMLImporterTest/ignore_rule_on_root_characteristics.xml [new file with mode: 0644]
sonar-core/src/test/resources/org/sonar/core/technicaldebt/DebtRulesXMLImporterTest/import_badly_formatted_xml.xml [new file with mode: 0644]
sonar-core/src/test/resources/org/sonar/core/technicaldebt/DebtRulesXMLImporterTest/import_constant_issue.xml [new file with mode: 0644]
sonar-core/src/test/resources/org/sonar/core/technicaldebt/DebtRulesXMLImporterTest/import_linear.xml [new file with mode: 0644]
sonar-core/src/test/resources/org/sonar/core/technicaldebt/DebtRulesXMLImporterTest/import_linear_with_offset.xml [new file with mode: 0644]
sonar-core/src/test/resources/org/sonar/core/technicaldebt/DebtRulesXMLImporterTest/import_rules.xml [new file with mode: 0644]
sonar-core/src/test/resources/org/sonar/core/technicaldebt/DebtRulesXMLImporterTest/replace_mn_by_min.xml [new file with mode: 0644]
sonar-core/src/test/resources/org/sonar/core/technicaldebt/DebtRulesXMLImporterTest/use_default_unit_when_no_unit.xml [new file with mode: 0644]
sonar-core/src/test/resources/org/sonar/core/technicaldebt/RulesDebtModelXMLImporterTest/convert_deprecated_linear_with_threshold_function_by_linear_function.xml [deleted file]
sonar-core/src/test/resources/org/sonar/core/technicaldebt/RulesDebtModelXMLImporterTest/ignore_deprecated_constant_per_file_function.xml [deleted file]
sonar-core/src/test/resources/org/sonar/core/technicaldebt/RulesDebtModelXMLImporterTest/ignore_invalid_value.xml [deleted file]
sonar-core/src/test/resources/org/sonar/core/technicaldebt/RulesDebtModelXMLImporterTest/ignore_rule_on_root_characteristics.xml [deleted file]
sonar-core/src/test/resources/org/sonar/core/technicaldebt/RulesDebtModelXMLImporterTest/import_badly_formatted_xml.xml [deleted file]
sonar-core/src/test/resources/org/sonar/core/technicaldebt/RulesDebtModelXMLImporterTest/import_constant_issue.xml [deleted file]
sonar-core/src/test/resources/org/sonar/core/technicaldebt/RulesDebtModelXMLImporterTest/import_linear.xml [deleted file]
sonar-core/src/test/resources/org/sonar/core/technicaldebt/RulesDebtModelXMLImporterTest/import_linear_with_offset.xml [deleted file]
sonar-core/src/test/resources/org/sonar/core/technicaldebt/RulesDebtModelXMLImporterTest/import_rules.xml [deleted file]
sonar-core/src/test/resources/org/sonar/core/technicaldebt/RulesDebtModelXMLImporterTest/replace_mn_by_min.xml [deleted file]
sonar-core/src/test/resources/org/sonar/core/technicaldebt/RulesDebtModelXMLImporterTest/use_default_unit_when_no_unit.xml [deleted file]
sonar-server/src/main/java/org/sonar/server/platform/Platform.java
sonar-server/src/main/java/org/sonar/server/rule/DeprecatedRuleDefinitions.java
sonar-server/src/main/java/org/sonar/server/rule/RuleRegistration.java
sonar-server/src/main/java/org/sonar/server/startup/RegisterDebtCharacteristicModel.java [deleted file]
sonar-server/src/main/java/org/sonar/server/startup/RegisterDebtModel.java [new file with mode: 0644]
sonar-server/src/main/java/org/sonar/server/startup/RegisterTechnicalDebtModel.java [deleted file]
sonar-server/src/test/java/org/sonar/server/rule/DeprecatedRuleDefinitionsTest.java
sonar-server/src/test/java/org/sonar/server/rule/RuleRegistrationTest.java
sonar-server/src/test/java/org/sonar/server/startup/RegisterDebtCharacteristicModelTest.java [deleted file]
sonar-server/src/test/java/org/sonar/server/startup/RegisterDebtModelTest.java [new file with mode: 0644]
sonar-server/src/test/java/org/sonar/server/startup/RegisterTechnicalDebtModelTest.java [deleted file]

diff --git a/sonar-core/src/main/java/org/sonar/core/technicaldebt/CharacteristicsDebtModelSynchronizer.java b/sonar-core/src/main/java/org/sonar/core/technicaldebt/CharacteristicsDebtModelSynchronizer.java
deleted file mode 100644 (file)
index 2caec82..0000000
+++ /dev/null
@@ -1,112 +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.core.technicaldebt;
-
-import org.apache.commons.io.IOUtils;
-import org.apache.ibatis.session.SqlSession;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.sonar.api.ServerExtension;
-import org.sonar.api.technicaldebt.batch.internal.DefaultCharacteristic;
-import org.sonar.api.utils.ValidationMessages;
-import org.sonar.core.persistence.MyBatis;
-import org.sonar.core.technicaldebt.db.CharacteristicDao;
-import org.sonar.core.technicaldebt.db.CharacteristicDto;
-
-import java.io.Reader;
-import java.util.List;
-
-import static com.google.common.collect.Lists.newArrayList;
-
-public class CharacteristicsDebtModelSynchronizer implements ServerExtension {
-
-  private static final Logger LOG = LoggerFactory.getLogger(CharacteristicsDebtModelSynchronizer.class);
-
-  private final MyBatis mybatis;
-  private final CharacteristicDao dao;
-  private final TechnicalDebtModelRepository languageModelFinder;
-  private final CharacteristicsDebtModelXMLImporter importer;
-
-  public CharacteristicsDebtModelSynchronizer(MyBatis mybatis, CharacteristicDao dao, TechnicalDebtModelRepository modelRepository, CharacteristicsDebtModelXMLImporter importer) {
-    this.mybatis = mybatis;
-    this.dao = dao;
-    this.languageModelFinder = modelRepository;
-    this.importer = importer;
-  }
-
-  public List<CharacteristicDto> synchronize(ValidationMessages messages) {
-    SqlSession session = mybatis.openSession();
-
-    List<CharacteristicDto> model = newArrayList();
-    try {
-      model = synchronize(messages, session);
-      session.commit();
-    } finally {
-      MyBatis.closeQuietly(session);
-    }
-    return model;
-  }
-
-  public List<CharacteristicDto> synchronize(ValidationMessages messages, SqlSession session) {
-    DefaultTechnicalDebtModel defaultModel = loadModelFromXml(TechnicalDebtModelRepository.DEFAULT_MODEL, messages);
-    List<CharacteristicDto> model = loadOrCreateModelFromDb(defaultModel, session);
-    messages.log(LOG);
-    return model;
-  }
-
-  private List<CharacteristicDto> loadOrCreateModelFromDb(DefaultTechnicalDebtModel defaultModel, SqlSession session) {
-    List<CharacteristicDto> characteristicDtos = loadModel();
-    if (characteristicDtos.isEmpty()) {
-      return createTechnicalDebtModel(defaultModel, session);
-    }
-    return characteristicDtos;
-  }
-
-  private List<CharacteristicDto> loadModel() {
-    return dao.selectEnabledCharacteristics();
-  }
-
-  private List<CharacteristicDto> createTechnicalDebtModel(DefaultTechnicalDebtModel defaultModel, SqlSession session) {
-    List<CharacteristicDto> characteristics = newArrayList();
-    for (DefaultCharacteristic rootCharacteristic : defaultModel.rootCharacteristics()) {
-      CharacteristicDto rootCharacteristicDto = CharacteristicDto.toDto(rootCharacteristic, null);
-      dao.insert(rootCharacteristicDto, session);
-      characteristics.add(rootCharacteristicDto);
-      for (DefaultCharacteristic characteristic : rootCharacteristic.children()) {
-        CharacteristicDto characteristicDto = CharacteristicDto.toDto(characteristic, rootCharacteristicDto.getId());
-        dao.insert(characteristicDto, session);
-        characteristics.add(characteristicDto);
-      }
-    }
-    return characteristics;
-  }
-
-  public DefaultTechnicalDebtModel loadModelFromXml(String pluginKey, ValidationMessages messages) {
-    Reader xmlFileReader = null;
-    try {
-      xmlFileReader = languageModelFinder.createReaderForXMLFile(pluginKey);
-      return importer.importXML(xmlFileReader, messages);
-    } finally {
-      IOUtils.closeQuietly(xmlFileReader);
-    }
-  }
-
-}
diff --git a/sonar-core/src/main/java/org/sonar/core/technicaldebt/CharacteristicsDebtModelXMLImporter.java b/sonar-core/src/main/java/org/sonar/core/technicaldebt/CharacteristicsDebtModelXMLImporter.java
deleted file mode 100644 (file)
index 24c6876..0000000
+++ /dev/null
@@ -1,113 +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.core.technicaldebt;
-
-import org.apache.commons.lang.StringUtils;
-import org.codehaus.stax2.XMLInputFactory2;
-import org.codehaus.staxmate.SMInputFactory;
-import org.codehaus.staxmate.in.SMHierarchicCursor;
-import org.codehaus.staxmate.in.SMInputCursor;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.sonar.api.ServerExtension;
-import org.sonar.api.technicaldebt.batch.internal.DefaultCharacteristic;
-import org.sonar.api.utils.ValidationMessages;
-
-import javax.xml.stream.XMLInputFactory;
-import javax.xml.stream.XMLStreamException;
-
-import java.io.Reader;
-import java.io.StringReader;
-
-public class CharacteristicsDebtModelXMLImporter implements ServerExtension {
-
-  private static final Logger LOG = LoggerFactory.getLogger(CharacteristicsDebtModelXMLImporter.class);
-
-  public static final String CHARACTERISTIC = "chc";
-  public static final String CHARACTERISTIC_KEY = "key";
-  public static final String CHARACTERISTIC_NAME = "name";
-
-  public DefaultTechnicalDebtModel importXML(String xml, ValidationMessages messages) {
-    return importXML(new StringReader(xml), messages);
-  }
-
-  public DefaultTechnicalDebtModel importXML(Reader xml, ValidationMessages messages) {
-    DefaultTechnicalDebtModel model = new DefaultTechnicalDebtModel();
-    try {
-      SMInputFactory inputFactory = initStax();
-      SMHierarchicCursor cursor = inputFactory.rootElementCursor(xml);
-
-      // advance to <sqale>
-      cursor.advance();
-      SMInputCursor chcCursor = cursor.childElementCursor(CHARACTERISTIC);
-
-      while (chcCursor.getNext() != null) {
-        processCharacteristic(model, null, chcCursor, messages);
-      }
-
-      cursor.getStreamReader().closeCompletely();
-
-    } catch (XMLStreamException e) {
-      LOG.error("XML is not valid", e);
-      messages.addErrorText("XML is not valid: " + e.getMessage());
-    }
-    return model;
-  }
-
-  private SMInputFactory initStax() {
-    XMLInputFactory xmlFactory = XMLInputFactory2.newInstance();
-    xmlFactory.setProperty(XMLInputFactory.IS_COALESCING, Boolean.TRUE);
-    xmlFactory.setProperty(XMLInputFactory.IS_NAMESPACE_AWARE, Boolean.FALSE);
-    xmlFactory.setProperty(XMLInputFactory.SUPPORT_DTD, Boolean.FALSE);
-    xmlFactory.setProperty(XMLInputFactory.IS_VALIDATING, Boolean.FALSE);
-    return new SMInputFactory(xmlFactory);
-  }
-
-  private DefaultCharacteristic processCharacteristic(DefaultTechnicalDebtModel model, DefaultCharacteristic parent, SMInputCursor chcCursor,
-                                                      ValidationMessages messages) throws XMLStreamException {
-    DefaultCharacteristic characteristic = new DefaultCharacteristic();
-    SMInputCursor cursor = chcCursor.childElementCursor();
-    while (cursor.getNext() != null) {
-      String node = cursor.getLocalName();
-      if (StringUtils.equals(node, CHARACTERISTIC_KEY)) {
-        characteristic.setKey(cursor.collectDescendantText().trim());
-        // Attached to parent only if a key is existing, otherwise characteristic with empty key can be added.
-        characteristic.setParent(parent);
-
-      } else if (StringUtils.equals(node, CHARACTERISTIC_NAME)) {
-        characteristic.setName(cursor.collectDescendantText().trim(), false);
-
-        // <chc> can contain characteristics or requirements
-      } else if (StringUtils.equals(node, CHARACTERISTIC)) {
-        processCharacteristic(model, characteristic, cursor, messages);
-
-      }
-    }
-
-    if (StringUtils.isNotBlank(characteristic.key()) && characteristic.isRoot()) {
-      characteristic.setOrder(model.rootCharacteristics().size() + 1);
-      model.addRootCharacteristic(characteristic);
-      return characteristic;
-    }
-    return null;
-  }
-
-}
diff --git a/sonar-core/src/main/java/org/sonar/core/technicaldebt/DebtCharacteristicsXMLImporter.java b/sonar-core/src/main/java/org/sonar/core/technicaldebt/DebtCharacteristicsXMLImporter.java
new file mode 100644 (file)
index 0000000..5b35bdf
--- /dev/null
@@ -0,0 +1,113 @@
+/*
+ * 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.core.technicaldebt;
+
+import org.apache.commons.lang.StringUtils;
+import org.codehaus.stax2.XMLInputFactory2;
+import org.codehaus.staxmate.SMInputFactory;
+import org.codehaus.staxmate.in.SMHierarchicCursor;
+import org.codehaus.staxmate.in.SMInputCursor;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.sonar.api.ServerExtension;
+import org.sonar.api.technicaldebt.batch.internal.DefaultCharacteristic;
+import org.sonar.api.utils.ValidationMessages;
+
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamException;
+
+import java.io.Reader;
+import java.io.StringReader;
+
+public class DebtCharacteristicsXMLImporter implements ServerExtension {
+
+  private static final Logger LOG = LoggerFactory.getLogger(DebtCharacteristicsXMLImporter.class);
+
+  public static final String CHARACTERISTIC = "chc";
+  public static final String CHARACTERISTIC_KEY = "key";
+  public static final String CHARACTERISTIC_NAME = "name";
+
+  public DefaultTechnicalDebtModel importXML(String xml, ValidationMessages messages) {
+    return importXML(new StringReader(xml), messages);
+  }
+
+  public DefaultTechnicalDebtModel importXML(Reader xml, ValidationMessages messages) {
+    DefaultTechnicalDebtModel model = new DefaultTechnicalDebtModel();
+    try {
+      SMInputFactory inputFactory = initStax();
+      SMHierarchicCursor cursor = inputFactory.rootElementCursor(xml);
+
+      // advance to <sqale>
+      cursor.advance();
+      SMInputCursor chcCursor = cursor.childElementCursor(CHARACTERISTIC);
+
+      while (chcCursor.getNext() != null) {
+        processCharacteristic(model, null, chcCursor, messages);
+      }
+
+      cursor.getStreamReader().closeCompletely();
+
+    } catch (XMLStreamException e) {
+      LOG.error("XML is not valid", e);
+      messages.addErrorText("XML is not valid: " + e.getMessage());
+    }
+    return model;
+  }
+
+  private SMInputFactory initStax() {
+    XMLInputFactory xmlFactory = XMLInputFactory2.newInstance();
+    xmlFactory.setProperty(XMLInputFactory.IS_COALESCING, Boolean.TRUE);
+    xmlFactory.setProperty(XMLInputFactory.IS_NAMESPACE_AWARE, Boolean.FALSE);
+    xmlFactory.setProperty(XMLInputFactory.SUPPORT_DTD, Boolean.FALSE);
+    xmlFactory.setProperty(XMLInputFactory.IS_VALIDATING, Boolean.FALSE);
+    return new SMInputFactory(xmlFactory);
+  }
+
+  private DefaultCharacteristic processCharacteristic(DefaultTechnicalDebtModel model, DefaultCharacteristic parent, SMInputCursor chcCursor,
+                                                      ValidationMessages messages) throws XMLStreamException {
+    DefaultCharacteristic characteristic = new DefaultCharacteristic();
+    SMInputCursor cursor = chcCursor.childElementCursor();
+    while (cursor.getNext() != null) {
+      String node = cursor.getLocalName();
+      if (StringUtils.equals(node, CHARACTERISTIC_KEY)) {
+        characteristic.setKey(cursor.collectDescendantText().trim());
+        // Attached to parent only if a key is existing, otherwise characteristic with empty key can be added.
+        characteristic.setParent(parent);
+
+      } else if (StringUtils.equals(node, CHARACTERISTIC_NAME)) {
+        characteristic.setName(cursor.collectDescendantText().trim(), false);
+
+        // <chc> can contain characteristics or requirements
+      } else if (StringUtils.equals(node, CHARACTERISTIC)) {
+        processCharacteristic(model, characteristic, cursor, messages);
+
+      }
+    }
+
+    if (StringUtils.isNotBlank(characteristic.key()) && characteristic.isRoot()) {
+      characteristic.setOrder(model.rootCharacteristics().size() + 1);
+      model.addRootCharacteristic(characteristic);
+      return characteristic;
+    }
+    return null;
+  }
+
+}
diff --git a/sonar-core/src/main/java/org/sonar/core/technicaldebt/DebtModelSynchronizer.java b/sonar-core/src/main/java/org/sonar/core/technicaldebt/DebtModelSynchronizer.java
new file mode 100644 (file)
index 0000000..7437d4d
--- /dev/null
@@ -0,0 +1,112 @@
+/*
+ * 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.core.technicaldebt;
+
+import org.apache.commons.io.IOUtils;
+import org.apache.ibatis.session.SqlSession;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.sonar.api.ServerExtension;
+import org.sonar.api.technicaldebt.batch.internal.DefaultCharacteristic;
+import org.sonar.api.utils.ValidationMessages;
+import org.sonar.core.persistence.MyBatis;
+import org.sonar.core.technicaldebt.db.CharacteristicDao;
+import org.sonar.core.technicaldebt.db.CharacteristicDto;
+
+import java.io.Reader;
+import java.util.List;
+
+import static com.google.common.collect.Lists.newArrayList;
+
+public class DebtModelSynchronizer implements ServerExtension {
+
+  private static final Logger LOG = LoggerFactory.getLogger(DebtModelSynchronizer.class);
+
+  private final MyBatis mybatis;
+  private final CharacteristicDao dao;
+  private final TechnicalDebtModelRepository languageModelFinder;
+  private final DebtCharacteristicsXMLImporter importer;
+
+  public DebtModelSynchronizer(MyBatis mybatis, CharacteristicDao dao, TechnicalDebtModelRepository modelRepository, DebtCharacteristicsXMLImporter importer) {
+    this.mybatis = mybatis;
+    this.dao = dao;
+    this.languageModelFinder = modelRepository;
+    this.importer = importer;
+  }
+
+  public List<CharacteristicDto> synchronize(ValidationMessages messages) {
+    SqlSession session = mybatis.openSession();
+
+    List<CharacteristicDto> model = newArrayList();
+    try {
+      model = synchronize(messages, session);
+      session.commit();
+    } finally {
+      MyBatis.closeQuietly(session);
+    }
+    return model;
+  }
+
+  public List<CharacteristicDto> synchronize(ValidationMessages messages, SqlSession session) {
+    DefaultTechnicalDebtModel defaultModel = loadModelFromXml(TechnicalDebtModelRepository.DEFAULT_MODEL, messages);
+    List<CharacteristicDto> model = loadOrCreateModelFromDb(defaultModel, session);
+    messages.log(LOG);
+    return model;
+  }
+
+  private List<CharacteristicDto> loadOrCreateModelFromDb(DefaultTechnicalDebtModel defaultModel, SqlSession session) {
+    List<CharacteristicDto> characteristicDtos = loadModel();
+    if (characteristicDtos.isEmpty()) {
+      return createTechnicalDebtModel(defaultModel, session);
+    }
+    return characteristicDtos;
+  }
+
+  private List<CharacteristicDto> loadModel() {
+    return dao.selectEnabledCharacteristics();
+  }
+
+  private List<CharacteristicDto> createTechnicalDebtModel(DefaultTechnicalDebtModel defaultModel, SqlSession session) {
+    List<CharacteristicDto> characteristics = newArrayList();
+    for (DefaultCharacteristic rootCharacteristic : defaultModel.rootCharacteristics()) {
+      CharacteristicDto rootCharacteristicDto = CharacteristicDto.toDto(rootCharacteristic, null);
+      dao.insert(rootCharacteristicDto, session);
+      characteristics.add(rootCharacteristicDto);
+      for (DefaultCharacteristic characteristic : rootCharacteristic.children()) {
+        CharacteristicDto characteristicDto = CharacteristicDto.toDto(characteristic, rootCharacteristicDto.getId());
+        dao.insert(characteristicDto, session);
+        characteristics.add(characteristicDto);
+      }
+    }
+    return characteristics;
+  }
+
+  public DefaultTechnicalDebtModel loadModelFromXml(String pluginKey, ValidationMessages messages) {
+    Reader xmlFileReader = null;
+    try {
+      xmlFileReader = languageModelFinder.createReaderForXMLFile(pluginKey);
+      return importer.importXML(xmlFileReader, messages);
+    } finally {
+      IOUtils.closeQuietly(xmlFileReader);
+    }
+  }
+
+}
diff --git a/sonar-core/src/main/java/org/sonar/core/technicaldebt/DebtRulesXMLImporter.java b/sonar-core/src/main/java/org/sonar/core/technicaldebt/DebtRulesXMLImporter.java
new file mode 100644 (file)
index 0000000..f0a43c3
--- /dev/null
@@ -0,0 +1,331 @@
+/*
+ * 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.core.technicaldebt;
+
+import com.google.common.base.Predicate;
+import com.google.common.base.Strings;
+import com.google.common.collect.Iterables;
+import org.apache.commons.lang.StringUtils;
+import org.apache.commons.lang.math.NumberUtils;
+import org.codehaus.stax2.XMLInputFactory2;
+import org.codehaus.staxmate.SMInputFactory;
+import org.codehaus.staxmate.in.SMHierarchicCursor;
+import org.codehaus.staxmate.in.SMInputCursor;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.sonar.api.ServerExtension;
+import org.sonar.api.rule.RemediationFunction;
+import org.sonar.api.rule.RuleKey;
+import org.sonar.api.utils.Duration;
+
+import javax.annotation.CheckForNull;
+import javax.annotation.Nullable;
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamException;
+
+import java.io.Reader;
+import java.io.StringReader;
+import java.util.List;
+
+import static com.google.common.collect.Lists.newArrayList;
+
+public class DebtRulesXMLImporter implements ServerExtension {
+
+  private static final Logger LOG = LoggerFactory.getLogger(DebtRulesXMLImporter.class);
+
+  public static final String CHARACTERISTIC = "chc";
+  public static final String CHARACTERISTIC_KEY = "key";
+  public static final String PROPERTY = "prop";
+
+  public static final String PROPERTY_KEY = "key";
+  public static final String PROPERTY_VALUE = "val";
+  public static final String PROPERTY_TEXT_VALUE = "txt";
+
+  public static final String REPOSITORY_KEY = "rule-repo";
+  public static final String RULE_KEY = "rule-key";
+
+  public static final String PROPERTY_FUNCTION = "remediationFunction";
+  public static final String PROPERTY_FACTOR = "remediationFactor";
+  public static final String PROPERTY_OFFSET = "offset";
+
+  public List<RuleDebt> importXML(String xml) {
+    return importXML(new StringReader(xml));
+  }
+
+  public List<RuleDebt> importXML(Reader xml) {
+    List<RuleDebt> ruleDebts = newArrayList();
+    try {
+      SMInputFactory inputFactory = initStax();
+      SMHierarchicCursor cursor = inputFactory.rootElementCursor(xml);
+
+      // advance to <sqale>
+      cursor.advance();
+      SMInputCursor rootCursor = cursor.childElementCursor(CHARACTERISTIC);
+      while (rootCursor.getNext() != null) {
+        processCharacteristic(ruleDebts, null, null, rootCursor);
+      }
+
+      cursor.getStreamReader().closeCompletely();
+    } catch (XMLStreamException e) {
+      LOG.error("XML is not valid", e);
+    }
+
+    return ruleDebts;
+  }
+
+  private SMInputFactory initStax() {
+    XMLInputFactory xmlFactory = XMLInputFactory2.newInstance();
+    xmlFactory.setProperty(XMLInputFactory.IS_COALESCING, Boolean.TRUE);
+    xmlFactory.setProperty(XMLInputFactory.IS_NAMESPACE_AWARE, Boolean.FALSE);
+    xmlFactory.setProperty(XMLInputFactory.SUPPORT_DTD, Boolean.FALSE);
+    xmlFactory.setProperty(XMLInputFactory.IS_VALIDATING, Boolean.FALSE);
+    return new SMInputFactory(xmlFactory);
+  }
+
+  private void processCharacteristic(List<RuleDebt> ruleDebts, @Nullable String rootKey, @Nullable String parentKey, SMInputCursor chcCursor) throws XMLStreamException {
+    String currentCharacteristicKey = null;
+    SMInputCursor cursor = chcCursor.childElementCursor();
+    while (cursor.getNext() != null) {
+      String node = cursor.getLocalName();
+      if (StringUtils.equals(node, CHARACTERISTIC_KEY)) {
+        currentCharacteristicKey = cursor.collectDescendantText().trim();
+      } else if (StringUtils.equals(node, CHARACTERISTIC)) {
+        processCharacteristic(ruleDebts, parentKey, currentCharacteristicKey, cursor);
+      } else if (StringUtils.equals(node, REPOSITORY_KEY)) {
+        RuleDebt ruleDebt = processRule(cursor);
+        if (ruleDebt != null) {
+          if (rootKey != null) {
+            ruleDebt.characteristicKey = parentKey;
+            ruleDebts.add(ruleDebt);
+          } else {
+            LOG.warn("Rule '" + ruleDebt.ruleKey + "' is ignored because it's defined directly under a root characteristic.");
+          }
+        }
+      }
+    }
+  }
+
+  private RuleDebt processRule(SMInputCursor cursor)
+    throws XMLStreamException {
+
+    RuleDebt ruleDebt = new RuleDebt();
+    String ruleRepositoryKey = cursor.collectDescendantText().trim();
+    String ruleKey = null;
+    Properties properties = new Properties();
+    while (cursor.getNext() != null) {
+      String node = cursor.getLocalName();
+      if (StringUtils.equals(node, PROPERTY)) {
+        properties.add(processProperty(cursor));
+      } else if (StringUtils.equals(node, RULE_KEY)) {
+        ruleKey = cursor.collectDescendantText().trim();
+      }
+    }
+    if (StringUtils.isNotBlank(ruleRepositoryKey) && StringUtils.isNotBlank(ruleKey)) {
+      ruleDebt.ruleKey = RuleKey.of(ruleRepositoryKey, ruleKey);
+    } else {
+      return null;
+    }
+    return processFunctionsOnRequirement(ruleDebt, properties);
+  }
+
+  private Property processProperty(SMInputCursor cursor) throws XMLStreamException {
+    SMInputCursor c = cursor.childElementCursor();
+    String key = null;
+    int value = 0;
+    String textValue = null;
+    while (c.getNext() != null) {
+      String node = c.getLocalName();
+      if (StringUtils.equals(node, PROPERTY_KEY)) {
+        key = c.collectDescendantText().trim();
+
+      } else if (StringUtils.equals(node, PROPERTY_VALUE)) {
+        String s = c.collectDescendantText().trim();
+        try {
+          Double valueDouble = NumberUtils.createDouble(s);
+          value = valueDouble.intValue();
+        } catch (NumberFormatException ex) {
+          LOG.error(String.format("Cannot import value '%s' for field %s - Expected a numeric value instead", s, key));
+        }
+      } else if (StringUtils.equals(node, PROPERTY_TEXT_VALUE)) {
+        textValue = c.collectDescendantText().trim();
+      }
+    }
+    return new Property(key, value, textValue);
+  }
+
+  @CheckForNull
+  private RuleDebt processFunctionsOnRequirement(RuleDebt requirement, Properties properties) {
+    Property function = properties.function();
+    Property factor = properties.factor();
+    Property offset = properties.offset();
+
+    if (function != null) {
+      // Init with default values
+      requirement.factor = "0" + Duration.DAY;
+      requirement.offset = "0" + Duration.DAY;
+
+      String functionKey = function.getTextValue();
+      if ("linear_threshold".equals(functionKey)) {
+        function.setTextValue(RemediationFunction.LINEAR.name().toLowerCase());
+        offset.setValue(0);
+        offset.setTextValue(Duration.DAY);
+        LOG.warn(String.format("Linear with threshold function is no longer used, remediation function of '%s' is replaced by linear.", requirement.ruleKey));
+      } else if ("constant_resource".equals(functionKey)) {
+        LOG.warn(String.format("Constant/file function is no longer used, technical debt definitions on '%s' are ignored.", requirement.ruleKey));
+        return null;
+      }
+
+      requirement.function = RemediationFunction.valueOf(function.getTextValue().toUpperCase());
+      if (factor != null) {
+        requirement.factor = Integer.toString(factor.getValue());
+        requirement.factor += !Strings.isNullOrEmpty(factor.getTextValue()) ? factor.getTextValue() : Duration.DAY;
+      }
+      if (offset != null) {
+        requirement.offset = Integer.toString(offset.getValue());
+        requirement.offset += !Strings.isNullOrEmpty(offset.getTextValue()) ? offset.getTextValue() : Duration.DAY;
+      }
+      return requirement;
+    }
+    return null;
+  }
+
+  private static class Properties {
+    List<Property> properties;
+
+    public Properties() {
+      this.properties = newArrayList();
+    }
+
+    public Properties add(Property property) {
+      this.properties.add(property);
+      return this;
+    }
+
+    public Property function() {
+      return find(PROPERTY_FUNCTION);
+    }
+
+    public Property factor() {
+      return find(PROPERTY_FACTOR);
+    }
+
+    public Property offset() {
+      return find(PROPERTY_OFFSET);
+    }
+
+    private Property find(final String key) {
+      return Iterables.find(properties, new Predicate<Property>() {
+        @Override
+        public boolean apply(Property input) {
+          return input.getKey().equals(key);
+        }
+      }, null);
+    }
+  }
+
+  private static class Property {
+    String key;
+    int value;
+    String textValue;
+
+    private Property(String key, int value, String textValue) {
+      this.key = key;
+      this.value = value;
+      this.textValue = textValue;
+    }
+
+    private Property setValue(int value) {
+      this.value = value;
+      return this;
+    }
+
+    private Property setTextValue(String textValue) {
+      this.textValue = textValue;
+      return this;
+    }
+
+    private String getKey() {
+      return key;
+    }
+
+    private int getValue() {
+      return value;
+    }
+
+    private String getTextValue() {
+      return "mn".equals(textValue) ? Duration.MINUTE : textValue;
+    }
+  }
+
+  public static class RuleDebt {
+    private RuleKey ruleKey;
+    private String characteristicKey;
+    private RemediationFunction function;
+    private String factor;
+    private String offset;
+
+    public RuleKey ruleKey() {
+      return ruleKey;
+    }
+
+    public RuleDebt setRuleKey(RuleKey ruleKey) {
+      this.ruleKey = ruleKey;
+      return this;
+    }
+
+    public String characteristicKey() {
+      return characteristicKey;
+    }
+
+    public RuleDebt setCharacteristicKey(String characteristicKey) {
+      this.characteristicKey = characteristicKey;
+      return this;
+    }
+
+    public RemediationFunction function() {
+      return function;
+    }
+
+    public RuleDebt setFunction(RemediationFunction function) {
+      this.function = function;
+      return this;
+    }
+
+    public String factor() {
+      return factor;
+    }
+
+    public RuleDebt setFactor(String factor) {
+      this.factor = factor;
+      return this;
+    }
+
+    public String offset() {
+      return offset;
+    }
+
+    public RuleDebt setOffset(String offset) {
+      this.offset = offset;
+      return this;
+    }
+  }
+
+}
diff --git a/sonar-core/src/main/java/org/sonar/core/technicaldebt/RulesDebtModelXMLImporter.java b/sonar-core/src/main/java/org/sonar/core/technicaldebt/RulesDebtModelXMLImporter.java
deleted file mode 100644 (file)
index f63c1cc..0000000
+++ /dev/null
@@ -1,331 +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.core.technicaldebt;
-
-import com.google.common.base.Predicate;
-import com.google.common.base.Strings;
-import com.google.common.collect.Iterables;
-import org.apache.commons.lang.StringUtils;
-import org.apache.commons.lang.math.NumberUtils;
-import org.codehaus.stax2.XMLInputFactory2;
-import org.codehaus.staxmate.SMInputFactory;
-import org.codehaus.staxmate.in.SMHierarchicCursor;
-import org.codehaus.staxmate.in.SMInputCursor;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.sonar.api.ServerExtension;
-import org.sonar.api.rule.RemediationFunction;
-import org.sonar.api.rule.RuleKey;
-import org.sonar.api.utils.Duration;
-
-import javax.annotation.CheckForNull;
-import javax.annotation.Nullable;
-import javax.xml.stream.XMLInputFactory;
-import javax.xml.stream.XMLStreamException;
-
-import java.io.Reader;
-import java.io.StringReader;
-import java.util.List;
-
-import static com.google.common.collect.Lists.newArrayList;
-
-public class RulesDebtModelXMLImporter implements ServerExtension {
-
-  private static final Logger LOG = LoggerFactory.getLogger(RulesDebtModelXMLImporter.class);
-
-  public static final String CHARACTERISTIC = "chc";
-  public static final String CHARACTERISTIC_KEY = "key";
-  public static final String PROPERTY = "prop";
-
-  public static final String PROPERTY_KEY = "key";
-  public static final String PROPERTY_VALUE = "val";
-  public static final String PROPERTY_TEXT_VALUE = "txt";
-
-  public static final String REPOSITORY_KEY = "rule-repo";
-  public static final String RULE_KEY = "rule-key";
-
-  public static final String PROPERTY_FUNCTION = "remediationFunction";
-  public static final String PROPERTY_FACTOR = "remediationFactor";
-  public static final String PROPERTY_OFFSET = "offset";
-
-  public List<RuleDebt> importXML(String xml) {
-    return importXML(new StringReader(xml));
-  }
-
-  public List<RuleDebt> importXML(Reader xml) {
-    List<RuleDebt> ruleDebts = newArrayList();
-    try {
-      SMInputFactory inputFactory = initStax();
-      SMHierarchicCursor cursor = inputFactory.rootElementCursor(xml);
-
-      // advance to <sqale>
-      cursor.advance();
-      SMInputCursor rootCursor = cursor.childElementCursor(CHARACTERISTIC);
-      while (rootCursor.getNext() != null) {
-        processCharacteristic(ruleDebts, null, null, rootCursor);
-      }
-
-      cursor.getStreamReader().closeCompletely();
-    } catch (XMLStreamException e) {
-      LOG.error("XML is not valid", e);
-    }
-
-    return ruleDebts;
-  }
-
-  private SMInputFactory initStax() {
-    XMLInputFactory xmlFactory = XMLInputFactory2.newInstance();
-    xmlFactory.setProperty(XMLInputFactory.IS_COALESCING, Boolean.TRUE);
-    xmlFactory.setProperty(XMLInputFactory.IS_NAMESPACE_AWARE, Boolean.FALSE);
-    xmlFactory.setProperty(XMLInputFactory.SUPPORT_DTD, Boolean.FALSE);
-    xmlFactory.setProperty(XMLInputFactory.IS_VALIDATING, Boolean.FALSE);
-    return new SMInputFactory(xmlFactory);
-  }
-
-  private void processCharacteristic(List<RuleDebt> ruleDebts, @Nullable String rootKey, @Nullable String parentKey, SMInputCursor chcCursor) throws XMLStreamException {
-    String currentCharacteristicKey = null;
-    SMInputCursor cursor = chcCursor.childElementCursor();
-    while (cursor.getNext() != null) {
-      String node = cursor.getLocalName();
-      if (StringUtils.equals(node, CHARACTERISTIC_KEY)) {
-        currentCharacteristicKey = cursor.collectDescendantText().trim();
-      } else if (StringUtils.equals(node, CHARACTERISTIC)) {
-        processCharacteristic(ruleDebts, parentKey, currentCharacteristicKey, cursor);
-      } else if (StringUtils.equals(node, REPOSITORY_KEY)) {
-        RuleDebt ruleDebt = processRule(cursor);
-        if (ruleDebt != null) {
-          if (rootKey != null) {
-            ruleDebt.characteristicKey = parentKey;
-            ruleDebts.add(ruleDebt);
-          } else {
-            LOG.warn("Rule '" + ruleDebt.ruleKey + "' is ignored because it's defined directly under a root characteristic.");
-          }
-        }
-      }
-    }
-  }
-
-  private RuleDebt processRule(SMInputCursor cursor)
-    throws XMLStreamException {
-
-    RuleDebt ruleDebt = new RuleDebt();
-    String ruleRepositoryKey = cursor.collectDescendantText().trim();
-    String ruleKey = null;
-    Properties properties = new Properties();
-    while (cursor.getNext() != null) {
-      String node = cursor.getLocalName();
-      if (StringUtils.equals(node, PROPERTY)) {
-        properties.add(processProperty(cursor));
-      } else if (StringUtils.equals(node, RULE_KEY)) {
-        ruleKey = cursor.collectDescendantText().trim();
-      }
-    }
-    if (StringUtils.isNotBlank(ruleRepositoryKey) && StringUtils.isNotBlank(ruleKey)) {
-      ruleDebt.ruleKey = RuleKey.of(ruleRepositoryKey, ruleKey);
-    } else {
-      return null;
-    }
-    return processFunctionsOnRequirement(ruleDebt, properties);
-  }
-
-  private Property processProperty(SMInputCursor cursor) throws XMLStreamException {
-    SMInputCursor c = cursor.childElementCursor();
-    String key = null;
-    int value = 0;
-    String textValue = null;
-    while (c.getNext() != null) {
-      String node = c.getLocalName();
-      if (StringUtils.equals(node, PROPERTY_KEY)) {
-        key = c.collectDescendantText().trim();
-
-      } else if (StringUtils.equals(node, PROPERTY_VALUE)) {
-        String s = c.collectDescendantText().trim();
-        try {
-          Double valueDouble = NumberUtils.createDouble(s);
-          value = valueDouble.intValue();
-        } catch (NumberFormatException ex) {
-          LOG.error(String.format("Cannot import value '%s' for field %s - Expected a numeric value instead", s, key));
-        }
-      } else if (StringUtils.equals(node, PROPERTY_TEXT_VALUE)) {
-        textValue = c.collectDescendantText().trim();
-      }
-    }
-    return new Property(key, value, textValue);
-  }
-
-  @CheckForNull
-  private RuleDebt processFunctionsOnRequirement(RuleDebt requirement, Properties properties) {
-    Property function = properties.function();
-    Property factor = properties.factor();
-    Property offset = properties.offset();
-
-    if (function != null) {
-      // Init with default values
-      requirement.factor = "0" + Duration.DAY;
-      requirement.offset = "0" + Duration.DAY;
-
-      String functionKey = function.getTextValue();
-      if ("linear_threshold".equals(functionKey)) {
-        function.setTextValue(RemediationFunction.LINEAR.name().toLowerCase());
-        offset.setValue(0);
-        offset.setTextValue(Duration.DAY);
-        LOG.warn(String.format("Linear with threshold function is no longer used, remediation function of '%s' is replaced by linear.", requirement.ruleKey));
-      } else if ("constant_resource".equals(functionKey)) {
-        LOG.warn(String.format("Constant/file function is no longer used, technical debt definitions on '%s' are ignored.", requirement.ruleKey));
-        return null;
-      }
-
-      requirement.function = RemediationFunction.valueOf(function.getTextValue().toUpperCase());
-      if (factor != null) {
-        requirement.factor = Integer.toString(factor.getValue());
-        requirement.factor += !Strings.isNullOrEmpty(factor.getTextValue()) ? factor.getTextValue() : Duration.DAY;
-      }
-      if (offset != null) {
-        requirement.offset = Integer.toString(offset.getValue());
-        requirement.offset += !Strings.isNullOrEmpty(offset.getTextValue()) ? offset.getTextValue() : Duration.DAY;
-      }
-      return requirement;
-    }
-    return null;
-  }
-
-  private static class Properties {
-    List<Property> properties;
-
-    public Properties() {
-      this.properties = newArrayList();
-    }
-
-    public Properties add(Property property) {
-      this.properties.add(property);
-      return this;
-    }
-
-    public Property function() {
-      return find(PROPERTY_FUNCTION);
-    }
-
-    public Property factor() {
-      return find(PROPERTY_FACTOR);
-    }
-
-    public Property offset() {
-      return find(PROPERTY_OFFSET);
-    }
-
-    private Property find(final String key) {
-      return Iterables.find(properties, new Predicate<Property>() {
-        @Override
-        public boolean apply(Property input) {
-          return input.getKey().equals(key);
-        }
-      }, null);
-    }
-  }
-
-  private static class Property {
-    String key;
-    int value;
-    String textValue;
-
-    private Property(String key, int value, String textValue) {
-      this.key = key;
-      this.value = value;
-      this.textValue = textValue;
-    }
-
-    private Property setValue(int value) {
-      this.value = value;
-      return this;
-    }
-
-    private Property setTextValue(String textValue) {
-      this.textValue = textValue;
-      return this;
-    }
-
-    private String getKey() {
-      return key;
-    }
-
-    private int getValue() {
-      return value;
-    }
-
-    private String getTextValue() {
-      return "mn".equals(textValue) ? Duration.MINUTE : textValue;
-    }
-  }
-
-  public static class RuleDebt {
-    private RuleKey ruleKey;
-    private String characteristicKey;
-    private RemediationFunction function;
-    private String factor;
-    private String offset;
-
-    public RuleKey ruleKey() {
-      return ruleKey;
-    }
-
-    public RuleDebt setRuleKey(RuleKey ruleKey) {
-      this.ruleKey = ruleKey;
-      return this;
-    }
-
-    public String characteristicKey() {
-      return characteristicKey;
-    }
-
-    public RuleDebt setCharacteristicKey(String characteristicKey) {
-      this.characteristicKey = characteristicKey;
-      return this;
-    }
-
-    public RemediationFunction function() {
-      return function;
-    }
-
-    public RuleDebt setFunction(RemediationFunction function) {
-      this.function = function;
-      return this;
-    }
-
-    public String factor() {
-      return factor;
-    }
-
-    public RuleDebt setFactor(String factor) {
-      this.factor = factor;
-      return this;
-    }
-
-    public String offset() {
-      return offset;
-    }
-
-    public RuleDebt setOffset(String offset) {
-      this.offset = offset;
-      return this;
-    }
-  }
-
-}
diff --git a/sonar-core/src/test/java/org/sonar/core/technicaldebt/CharacteristicsDebtModelSynchronizerTest.java b/sonar-core/src/test/java/org/sonar/core/technicaldebt/CharacteristicsDebtModelSynchronizerTest.java
deleted file mode 100644 (file)
index bdcd88d..0000000
+++ /dev/null
@@ -1,129 +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.core.technicaldebt;
-
-import com.google.common.collect.Lists;
-import org.apache.ibatis.session.SqlSession;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.ArgumentCaptor;
-import org.mockito.Mock;
-import org.mockito.invocation.InvocationOnMock;
-import org.mockito.runners.MockitoJUnitRunner;
-import org.mockito.stubbing.Answer;
-import org.sonar.api.technicaldebt.batch.internal.DefaultCharacteristic;
-import org.sonar.api.utils.ValidationMessages;
-import org.sonar.core.persistence.MyBatis;
-import org.sonar.core.technicaldebt.db.CharacteristicDao;
-import org.sonar.core.technicaldebt.db.CharacteristicDto;
-
-import java.io.Reader;
-import java.util.Collections;
-import java.util.List;
-
-import static org.fest.assertions.Assertions.assertThat;
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.eq;
-import static org.mockito.Mockito.*;
-
-@RunWith(MockitoJUnitRunner.class)
-public class CharacteristicsDebtModelSynchronizerTest {
-
-  @Mock
-  MyBatis myBatis;
-
-  @Mock
-  SqlSession session;
-
-  @Mock
-  TechnicalDebtModelRepository technicalDebtModelRepository;
-
-  @Mock
-  CharacteristicDao dao;
-
-  @Mock
-  CharacteristicsDebtModelXMLImporter xmlImporter;
-
-  Integer currentId = 1;
-
-  private DefaultTechnicalDebtModel defaultModel;
-
-  private CharacteristicsDebtModelSynchronizer manager;
-
-  @Before
-  public void initAndMerge() throws Exception {
-    when(myBatis.openSession()).thenReturn(session);
-
-    defaultModel = new DefaultTechnicalDebtModel();
-    Reader defaultModelReader = mock(Reader.class);
-    when(technicalDebtModelRepository.createReaderForXMLFile("technical-debt")).thenReturn(defaultModelReader);
-    when(xmlImporter.importXML(eq(defaultModelReader), any(ValidationMessages.class))).thenReturn(defaultModel);
-
-    doAnswer(new Answer() {
-      public Object answer(InvocationOnMock invocation) {
-        Object[] args = invocation.getArguments();
-        CharacteristicDto dto = (CharacteristicDto) args[0];
-        dto.setId(currentId++);
-        return null;
-      }
-    }).when(dao).insert(any(CharacteristicDto.class), any(SqlSession.class));
-
-
-    manager = new CharacteristicsDebtModelSynchronizer(myBatis, dao, technicalDebtModelRepository, xmlImporter);
-  }
-
-  @Test
-  public void create_default_model_on_first_execution_when_no_plugin() throws Exception {
-    DefaultCharacteristic rootCharacteristic = new DefaultCharacteristic().setKey("PORTABILITY");
-    new DefaultCharacteristic().setKey("COMPILER_RELATED_PORTABILITY").setParent(rootCharacteristic);
-    defaultModel.addRootCharacteristic(rootCharacteristic);
-
-    when(technicalDebtModelRepository.getContributingPluginList()).thenReturn(Collections.<String>emptyList());
-    when(dao.selectEnabledCharacteristics()).thenReturn(Lists.<CharacteristicDto>newArrayList());
-
-    manager.synchronize(ValidationMessages.create());
-
-    verify(dao).selectEnabledCharacteristics();
-    ArgumentCaptor<CharacteristicDto> characteristicCaptor = ArgumentCaptor.forClass(CharacteristicDto.class);
-    verify(dao, times(2)).insert(characteristicCaptor.capture(), eq(session));
-
-    List<CharacteristicDto> result = characteristicCaptor.getAllValues();
-    assertThat(result.get(0).getKey()).isEqualTo("PORTABILITY");
-    assertThat(result.get(1).getKey()).isEqualTo("COMPILER_RELATED_PORTABILITY");
-    verifyNoMoreInteractions(dao);
-  }
-
-  @Test
-  public void not_create_default_model_if_already_exists() throws Exception {
-    DefaultCharacteristic rootCharacteristic = new DefaultCharacteristic().setKey("PORTABILITY");
-    new DefaultCharacteristic().setKey("COMPILER_RELATED_PORTABILITY").setParent(rootCharacteristic);
-    defaultModel.addRootCharacteristic(rootCharacteristic);
-
-    when(technicalDebtModelRepository.getContributingPluginList()).thenReturn(Collections.<String>emptyList());
-    when(dao.selectEnabledCharacteristics()).thenReturn(Lists.newArrayList(new CharacteristicDto()));
-
-    manager.synchronize(ValidationMessages.create());
-
-    verify(dao, never()).insert(any(CharacteristicDto.class), eq(session));
-  }
-
-}
diff --git a/sonar-core/src/test/java/org/sonar/core/technicaldebt/CharacteristicsDebtModelXMLImporterTest.java b/sonar-core/src/test/java/org/sonar/core/technicaldebt/CharacteristicsDebtModelXMLImporterTest.java
deleted file mode 100644 (file)
index 4e2f75e..0000000
+++ /dev/null
@@ -1,93 +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.core.technicaldebt;
-
-import com.google.common.base.Charsets;
-import com.google.common.io.Resources;
-import org.junit.Test;
-import org.sonar.api.technicaldebt.batch.internal.DefaultCharacteristic;
-import org.sonar.api.utils.ValidationMessages;
-
-import java.io.IOException;
-
-import static org.fest.assertions.Assertions.assertThat;
-
-public class CharacteristicsDebtModelXMLImporterTest {
-
-  @Test
-  public void import_characteristics() {
-    String xml = getFileContent("import_characteristics.xml");
-
-    ValidationMessages messages = ValidationMessages.create();
-    DefaultTechnicalDebtModel debtModel = new CharacteristicsDebtModelXMLImporter().importXML(xml, messages);
-
-    assertThat(debtModel.rootCharacteristics()).hasSize(2);
-    assertThat(debtModel.rootCharacteristics().get(0).key()).isEqualTo("PORTABILITY");
-    assertThat(debtModel.rootCharacteristics().get(1).key()).isEqualTo("MAINTAINABILITY");
-
-    DefaultCharacteristic portability = debtModel.characteristicByKey("PORTABILITY");
-    assertThat(portability.order()).isEqualTo(1);
-    assertThat(portability.children()).hasSize(2);
-    assertThat(portability.children().get(0).key()).isEqualTo("COMPILER_RELATED_PORTABILITY");
-    assertThat(debtModel.characteristicByKey("COMPILER_RELATED_PORTABILITY").parent().key()).isEqualTo("PORTABILITY");
-    assertThat(portability.children().get(1).key()).isEqualTo("HARDWARE_RELATED_PORTABILITY");
-    assertThat(debtModel.characteristicByKey("HARDWARE_RELATED_PORTABILITY").parent().key()).isEqualTo("PORTABILITY");
-
-    DefaultCharacteristic maintainability = debtModel.characteristicByKey("MAINTAINABILITY");
-    assertThat(maintainability.order()).isEqualTo(2);
-    assertThat(maintainability.children()).hasSize(1);
-    assertThat(maintainability.children().get(0).key()).isEqualTo("READABILITY");
-    assertThat(debtModel.characteristicByKey("READABILITY").parent().key()).isEqualTo("MAINTAINABILITY");
-  }
-
-  @Test
-  public void import_badly_formatted_xml() {
-    String xml = getFileContent("import_badly_formatted_xml.xml");
-
-    ValidationMessages messages = ValidationMessages.create();
-    DefaultTechnicalDebtModel debtModel = new CharacteristicsDebtModelXMLImporter().importXML(xml, messages);
-
-    checkXmlCorrectlyImported(debtModel, messages);
-  }
-
-  private void checkXmlCorrectlyImported(DefaultTechnicalDebtModel sqale, ValidationMessages messages) {
-    assertThat(messages.getErrors()).isEmpty();
-
-    // characteristics
-    assertThat(sqale.rootCharacteristics()).hasSize(2);
-    DefaultCharacteristic efficiency = sqale.characteristicByKey("EFFICIENCY");
-    assertThat(efficiency.name()).isEqualTo("Efficiency");
-
-    // sub-characteristics
-    assertThat(efficiency.children()).hasSize(1);
-    DefaultCharacteristic memoryEfficiency = sqale.characteristicByKey("MEMORY_EFFICIENCY");
-    assertThat(memoryEfficiency.name()).isEqualTo("Memory use");
-  }
-
-  private String getFileContent(String file) {
-    try {
-      return Resources.toString(Resources.getResource(CharacteristicsDebtModelXMLImporterTest.class, "CharacteristicsDebtModelXMLImporterTest/" + file), Charsets.UTF_8);
-    } catch (IOException e) {
-      throw new RuntimeException(e);
-    }
-  }
-
-}
diff --git a/sonar-core/src/test/java/org/sonar/core/technicaldebt/DebtCharacteristicsXMLImporterTest.java b/sonar-core/src/test/java/org/sonar/core/technicaldebt/DebtCharacteristicsXMLImporterTest.java
new file mode 100644 (file)
index 0000000..d1a9246
--- /dev/null
@@ -0,0 +1,93 @@
+/*
+ * 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.core.technicaldebt;
+
+import com.google.common.base.Charsets;
+import com.google.common.io.Resources;
+import org.junit.Test;
+import org.sonar.api.technicaldebt.batch.internal.DefaultCharacteristic;
+import org.sonar.api.utils.ValidationMessages;
+
+import java.io.IOException;
+
+import static org.fest.assertions.Assertions.assertThat;
+
+public class DebtCharacteristicsXMLImporterTest {
+
+  @Test
+  public void import_characteristics() {
+    String xml = getFileContent("import_characteristics.xml");
+
+    ValidationMessages messages = ValidationMessages.create();
+    DefaultTechnicalDebtModel debtModel = new DebtCharacteristicsXMLImporter().importXML(xml, messages);
+
+    assertThat(debtModel.rootCharacteristics()).hasSize(2);
+    assertThat(debtModel.rootCharacteristics().get(0).key()).isEqualTo("PORTABILITY");
+    assertThat(debtModel.rootCharacteristics().get(1).key()).isEqualTo("MAINTAINABILITY");
+
+    DefaultCharacteristic portability = debtModel.characteristicByKey("PORTABILITY");
+    assertThat(portability.order()).isEqualTo(1);
+    assertThat(portability.children()).hasSize(2);
+    assertThat(portability.children().get(0).key()).isEqualTo("COMPILER_RELATED_PORTABILITY");
+    assertThat(debtModel.characteristicByKey("COMPILER_RELATED_PORTABILITY").parent().key()).isEqualTo("PORTABILITY");
+    assertThat(portability.children().get(1).key()).isEqualTo("HARDWARE_RELATED_PORTABILITY");
+    assertThat(debtModel.characteristicByKey("HARDWARE_RELATED_PORTABILITY").parent().key()).isEqualTo("PORTABILITY");
+
+    DefaultCharacteristic maintainability = debtModel.characteristicByKey("MAINTAINABILITY");
+    assertThat(maintainability.order()).isEqualTo(2);
+    assertThat(maintainability.children()).hasSize(1);
+    assertThat(maintainability.children().get(0).key()).isEqualTo("READABILITY");
+    assertThat(debtModel.characteristicByKey("READABILITY").parent().key()).isEqualTo("MAINTAINABILITY");
+  }
+
+  @Test
+  public void import_badly_formatted_xml() {
+    String xml = getFileContent("import_badly_formatted_xml.xml");
+
+    ValidationMessages messages = ValidationMessages.create();
+    DefaultTechnicalDebtModel debtModel = new DebtCharacteristicsXMLImporter().importXML(xml, messages);
+
+    checkXmlCorrectlyImported(debtModel, messages);
+  }
+
+  private void checkXmlCorrectlyImported(DefaultTechnicalDebtModel sqale, ValidationMessages messages) {
+    assertThat(messages.getErrors()).isEmpty();
+
+    // characteristics
+    assertThat(sqale.rootCharacteristics()).hasSize(2);
+    DefaultCharacteristic efficiency = sqale.characteristicByKey("EFFICIENCY");
+    assertThat(efficiency.name()).isEqualTo("Efficiency");
+
+    // sub-characteristics
+    assertThat(efficiency.children()).hasSize(1);
+    DefaultCharacteristic memoryEfficiency = sqale.characteristicByKey("MEMORY_EFFICIENCY");
+    assertThat(memoryEfficiency.name()).isEqualTo("Memory use");
+  }
+
+  private String getFileContent(String file) {
+    try {
+      return Resources.toString(Resources.getResource(DebtCharacteristicsXMLImporterTest.class, "DebtCharacteristicsXMLImporterTest/" + file), Charsets.UTF_8);
+    } catch (IOException e) {
+      throw new RuntimeException(e);
+    }
+  }
+
+}
diff --git a/sonar-core/src/test/java/org/sonar/core/technicaldebt/DebtModelSynchronizerTest.java b/sonar-core/src/test/java/org/sonar/core/technicaldebt/DebtModelSynchronizerTest.java
new file mode 100644 (file)
index 0000000..64525b0
--- /dev/null
@@ -0,0 +1,129 @@
+/*
+ * 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.core.technicaldebt;
+
+import com.google.common.collect.Lists;
+import org.apache.ibatis.session.SqlSession;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.ArgumentCaptor;
+import org.mockito.Mock;
+import org.mockito.invocation.InvocationOnMock;
+import org.mockito.runners.MockitoJUnitRunner;
+import org.mockito.stubbing.Answer;
+import org.sonar.api.technicaldebt.batch.internal.DefaultCharacteristic;
+import org.sonar.api.utils.ValidationMessages;
+import org.sonar.core.persistence.MyBatis;
+import org.sonar.core.technicaldebt.db.CharacteristicDao;
+import org.sonar.core.technicaldebt.db.CharacteristicDto;
+
+import java.io.Reader;
+import java.util.Collections;
+import java.util.List;
+
+import static org.fest.assertions.Assertions.assertThat;
+import static org.mockito.Matchers.any;
+import static org.mockito.Matchers.eq;
+import static org.mockito.Mockito.*;
+
+@RunWith(MockitoJUnitRunner.class)
+public class DebtModelSynchronizerTest {
+
+  @Mock
+  MyBatis myBatis;
+
+  @Mock
+  SqlSession session;
+
+  @Mock
+  TechnicalDebtModelRepository technicalDebtModelRepository;
+
+  @Mock
+  CharacteristicDao dao;
+
+  @Mock
+  DebtCharacteristicsXMLImporter xmlImporter;
+
+  Integer currentId = 1;
+
+  private DefaultTechnicalDebtModel defaultModel;
+
+  private DebtModelSynchronizer manager;
+
+  @Before
+  public void initAndMerge() throws Exception {
+    when(myBatis.openSession()).thenReturn(session);
+
+    defaultModel = new DefaultTechnicalDebtModel();
+    Reader defaultModelReader = mock(Reader.class);
+    when(technicalDebtModelRepository.createReaderForXMLFile("technical-debt")).thenReturn(defaultModelReader);
+    when(xmlImporter.importXML(eq(defaultModelReader), any(ValidationMessages.class))).thenReturn(defaultModel);
+
+    doAnswer(new Answer() {
+      public Object answer(InvocationOnMock invocation) {
+        Object[] args = invocation.getArguments();
+        CharacteristicDto dto = (CharacteristicDto) args[0];
+        dto.setId(currentId++);
+        return null;
+      }
+    }).when(dao).insert(any(CharacteristicDto.class), any(SqlSession.class));
+
+
+    manager = new DebtModelSynchronizer(myBatis, dao, technicalDebtModelRepository, xmlImporter);
+  }
+
+  @Test
+  public void create_default_model_on_first_execution_when_no_plugin() throws Exception {
+    DefaultCharacteristic rootCharacteristic = new DefaultCharacteristic().setKey("PORTABILITY");
+    new DefaultCharacteristic().setKey("COMPILER_RELATED_PORTABILITY").setParent(rootCharacteristic);
+    defaultModel.addRootCharacteristic(rootCharacteristic);
+
+    when(technicalDebtModelRepository.getContributingPluginList()).thenReturn(Collections.<String>emptyList());
+    when(dao.selectEnabledCharacteristics()).thenReturn(Lists.<CharacteristicDto>newArrayList());
+
+    manager.synchronize(ValidationMessages.create());
+
+    verify(dao).selectEnabledCharacteristics();
+    ArgumentCaptor<CharacteristicDto> characteristicCaptor = ArgumentCaptor.forClass(CharacteristicDto.class);
+    verify(dao, times(2)).insert(characteristicCaptor.capture(), eq(session));
+
+    List<CharacteristicDto> result = characteristicCaptor.getAllValues();
+    assertThat(result.get(0).getKey()).isEqualTo("PORTABILITY");
+    assertThat(result.get(1).getKey()).isEqualTo("COMPILER_RELATED_PORTABILITY");
+    verifyNoMoreInteractions(dao);
+  }
+
+  @Test
+  public void not_create_default_model_if_already_exists() throws Exception {
+    DefaultCharacteristic rootCharacteristic = new DefaultCharacteristic().setKey("PORTABILITY");
+    new DefaultCharacteristic().setKey("COMPILER_RELATED_PORTABILITY").setParent(rootCharacteristic);
+    defaultModel.addRootCharacteristic(rootCharacteristic);
+
+    when(technicalDebtModelRepository.getContributingPluginList()).thenReturn(Collections.<String>emptyList());
+    when(dao.selectEnabledCharacteristics()).thenReturn(Lists.newArrayList(new CharacteristicDto()));
+
+    manager.synchronize(ValidationMessages.create());
+
+    verify(dao, never()).insert(any(CharacteristicDto.class), eq(session));
+  }
+
+}
diff --git a/sonar-core/src/test/java/org/sonar/core/technicaldebt/DebtRulesXMLImporterTest.java b/sonar-core/src/test/java/org/sonar/core/technicaldebt/DebtRulesXMLImporterTest.java
new file mode 100644 (file)
index 0000000..5fd8081
--- /dev/null
@@ -0,0 +1,177 @@
+/*
+ * 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.core.technicaldebt;
+
+import com.google.common.base.Charsets;
+import com.google.common.io.Resources;
+import org.junit.Test;
+import org.sonar.api.rule.RemediationFunction;
+import org.sonar.api.rule.RuleKey;
+
+import java.io.IOException;
+import java.util.List;
+
+import static org.fest.assertions.Assertions.assertThat;
+
+public class DebtRulesXMLImporterTest {
+
+  DebtRulesXMLImporter importer = new DebtRulesXMLImporter();
+
+  @Test
+  public void import_rules() {
+    String xml = getFileContent("import_rules.xml");
+
+    List<DebtRulesXMLImporter.RuleDebt> results = importer.importXML(xml);
+    assertThat(results).hasSize(2);
+  }
+
+  @Test
+  public void import_linear() {
+    String xml = getFileContent("import_linear.xml");
+
+    List<DebtRulesXMLImporter.RuleDebt> results = importer.importXML(xml);
+    assertThat(results).hasSize(1);
+
+    DebtRulesXMLImporter.RuleDebt ruleDebt = results.get(0);
+    assertThat(ruleDebt.characteristicKey()).isEqualTo("MEMORY_EFFICIENCY");
+    assertThat(ruleDebt.ruleKey()).isEqualTo(RuleKey.of("checkstyle", "Regexp"));
+    assertThat(ruleDebt.function()).isEqualTo(RemediationFunction.LINEAR);
+    assertThat(ruleDebt.factor()).isEqualTo("3h");
+    assertThat(ruleDebt.offset()).isEqualTo("0d");
+  }
+
+  @Test
+  public void import_linear_with_offset() {
+    String xml = getFileContent("import_linear_with_offset.xml");
+
+    List<DebtRulesXMLImporter.RuleDebt> results = importer.importXML(xml);
+    assertThat(results).hasSize(1);
+
+    DebtRulesXMLImporter.RuleDebt ruleDebt = results.get(0);
+    assertThat(ruleDebt.characteristicKey()).isEqualTo("MEMORY_EFFICIENCY");
+    assertThat(ruleDebt.function()).isEqualTo(RemediationFunction.LINEAR_OFFSET);
+    assertThat(ruleDebt.factor()).isEqualTo("3h");
+    assertThat(ruleDebt.offset()).isEqualTo("1min");
+  }
+
+  @Test
+  public void import_constant_issue() {
+    String xml = getFileContent("import_constant_issue.xml");
+
+    List<DebtRulesXMLImporter.RuleDebt> results = importer.importXML(xml);
+    assertThat(results).hasSize(1);
+
+    DebtRulesXMLImporter.RuleDebt ruleDebt = results.get(0);
+    assertThat(ruleDebt.characteristicKey()).isEqualTo("MEMORY_EFFICIENCY");
+    assertThat(ruleDebt.function()).isEqualTo(RemediationFunction.CONSTANT_ISSUE);
+    assertThat(ruleDebt.factor()).isEqualTo("0d");
+    assertThat(ruleDebt.offset()).isEqualTo("3d");
+  }
+
+  @Test
+  public void use_default_unit_when_no_unit() {
+    String xml = getFileContent("use_default_unit_when_no_unit.xml");
+
+    List<DebtRulesXMLImporter.RuleDebt> results = importer.importXML(xml);
+    assertThat(results).hasSize(1);
+
+    DebtRulesXMLImporter.RuleDebt ruleDebt = results.get(0);
+    assertThat(ruleDebt.characteristicKey()).isEqualTo("MEMORY_EFFICIENCY");
+    assertThat(ruleDebt.function()).isEqualTo(RemediationFunction.LINEAR);
+    assertThat(ruleDebt.factor()).isEqualTo("3d");
+    assertThat(ruleDebt.offset()).isEqualTo("1d");
+  }
+
+  @Test
+  public void replace_mn_by_min() {
+    String xml = getFileContent("replace_mn_by_min.xml");
+
+    List<DebtRulesXMLImporter.RuleDebt> results = importer.importXML(xml);
+    assertThat(results).hasSize(1);
+
+    DebtRulesXMLImporter.RuleDebt ruleDebt = results.get(0);
+    assertThat(ruleDebt.characteristicKey()).isEqualTo("MEMORY_EFFICIENCY");
+    assertThat(ruleDebt.function()).isEqualTo(RemediationFunction.LINEAR);
+    assertThat(ruleDebt.factor()).isEqualTo("3min");
+    assertThat(ruleDebt.offset()).isEqualTo("0d");
+  }
+
+  @Test
+  public void convert_deprecated_linear_with_threshold_function_by_linear_function() {
+    String xml = getFileContent("convert_deprecated_linear_with_threshold_function_by_linear_function.xml");
+
+    List<DebtRulesXMLImporter.RuleDebt> results = importer.importXML(xml);
+    assertThat(results).hasSize(1);
+
+    DebtRulesXMLImporter.RuleDebt ruleDebt = results.get(0);
+    assertThat(ruleDebt.characteristicKey()).isEqualTo("MEMORY_EFFICIENCY");
+    assertThat(ruleDebt.function()).isEqualTo(RemediationFunction.LINEAR);
+    assertThat(ruleDebt.factor()).isEqualTo("3h");
+    assertThat(ruleDebt.offset()).isEqualTo("0d");
+  }
+
+  @Test
+  public void ignore_deprecated_constant_per_file_function() {
+    String xml = getFileContent("ignore_deprecated_constant_per_file_function.xml");
+
+    List<DebtRulesXMLImporter.RuleDebt> results = importer.importXML(xml);
+    assertThat(results).isEmpty();
+  }
+
+  @Test
+  public void ignore_rule_on_root_characteristics() {
+    String xml = getFileContent("ignore_rule_on_root_characteristics.xml");
+
+    List<DebtRulesXMLImporter.RuleDebt> results = importer.importXML(xml);
+    assertThat(results).isEmpty();
+  }
+
+  @Test
+  public void import_badly_formatted_xml() {
+    String xml = getFileContent("import_badly_formatted_xml.xml");
+
+    List<DebtRulesXMLImporter.RuleDebt> results = importer.importXML(xml);
+    assertThat(results).hasSize(1);
+
+    DebtRulesXMLImporter.RuleDebt ruleDebt = results.get(0);
+    assertThat(ruleDebt.characteristicKey()).isEqualTo("MEMORY_EFFICIENCY");
+    assertThat(ruleDebt.ruleKey()).isEqualTo(RuleKey.of("checkstyle", "Regexp"));
+    assertThat(ruleDebt.function()).isEqualTo(RemediationFunction.LINEAR);
+    assertThat(ruleDebt.factor()).isEqualTo("3h");
+    assertThat(ruleDebt.offset()).isEqualTo("0d");
+  }
+
+  @Test
+  public void ignore_invalid_value() throws Exception {
+    String xml = getFileContent("ignore_invalid_value.xml");
+    List<DebtRulesXMLImporter.RuleDebt> results = importer.importXML(xml);
+    assertThat(results).isEmpty();
+  }
+
+  private String getFileContent(String file) {
+    try {
+      return Resources.toString(Resources.getResource(DebtRulesXMLImporterTest.class, "DebtRulesXMLImporterTest/" + file), Charsets.UTF_8);
+    } catch (IOException e) {
+      throw new RuntimeException(e);
+    }
+  }
+
+}
diff --git a/sonar-core/src/test/java/org/sonar/core/technicaldebt/RulesDebtModelXMLImporterTest.java b/sonar-core/src/test/java/org/sonar/core/technicaldebt/RulesDebtModelXMLImporterTest.java
deleted file mode 100644 (file)
index bdd72eb..0000000
+++ /dev/null
@@ -1,177 +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.core.technicaldebt;
-
-import com.google.common.base.Charsets;
-import com.google.common.io.Resources;
-import org.junit.Test;
-import org.sonar.api.rule.RemediationFunction;
-import org.sonar.api.rule.RuleKey;
-
-import java.io.IOException;
-import java.util.List;
-
-import static org.fest.assertions.Assertions.assertThat;
-
-public class RulesDebtModelXMLImporterTest {
-
-  RulesDebtModelXMLImporter importer = new RulesDebtModelXMLImporter();
-
-  @Test
-  public void import_rules() {
-    String xml = getFileContent("import_rules.xml");
-
-    List<RulesDebtModelXMLImporter.RuleDebt> results = importer.importXML(xml);
-    assertThat(results).hasSize(2);
-  }
-
-  @Test
-  public void import_linear() {
-    String xml = getFileContent("import_linear.xml");
-
-    List<RulesDebtModelXMLImporter.RuleDebt> results = importer.importXML(xml);
-    assertThat(results).hasSize(1);
-
-    RulesDebtModelXMLImporter.RuleDebt ruleDebt = results.get(0);
-    assertThat(ruleDebt.characteristicKey()).isEqualTo("MEMORY_EFFICIENCY");
-    assertThat(ruleDebt.ruleKey()).isEqualTo(RuleKey.of("checkstyle", "Regexp"));
-    assertThat(ruleDebt.function()).isEqualTo(RemediationFunction.LINEAR);
-    assertThat(ruleDebt.factor()).isEqualTo("3h");
-    assertThat(ruleDebt.offset()).isEqualTo("0d");
-  }
-
-  @Test
-  public void import_linear_with_offset() {
-    String xml = getFileContent("import_linear_with_offset.xml");
-
-    List<RulesDebtModelXMLImporter.RuleDebt> results = importer.importXML(xml);
-    assertThat(results).hasSize(1);
-
-    RulesDebtModelXMLImporter.RuleDebt ruleDebt = results.get(0);
-    assertThat(ruleDebt.characteristicKey()).isEqualTo("MEMORY_EFFICIENCY");
-    assertThat(ruleDebt.function()).isEqualTo(RemediationFunction.LINEAR_OFFSET);
-    assertThat(ruleDebt.factor()).isEqualTo("3h");
-    assertThat(ruleDebt.offset()).isEqualTo("1min");
-  }
-
-  @Test
-  public void import_constant_issue() {
-    String xml = getFileContent("import_constant_issue.xml");
-
-    List<RulesDebtModelXMLImporter.RuleDebt> results = importer.importXML(xml);
-    assertThat(results).hasSize(1);
-
-    RulesDebtModelXMLImporter.RuleDebt ruleDebt = results.get(0);
-    assertThat(ruleDebt.characteristicKey()).isEqualTo("MEMORY_EFFICIENCY");
-    assertThat(ruleDebt.function()).isEqualTo(RemediationFunction.CONSTANT_ISSUE);
-    assertThat(ruleDebt.factor()).isEqualTo("0d");
-    assertThat(ruleDebt.offset()).isEqualTo("3d");
-  }
-
-  @Test
-  public void use_default_unit_when_no_unit() {
-    String xml = getFileContent("use_default_unit_when_no_unit.xml");
-
-    List<RulesDebtModelXMLImporter.RuleDebt> results = importer.importXML(xml);
-    assertThat(results).hasSize(1);
-
-    RulesDebtModelXMLImporter.RuleDebt ruleDebt = results.get(0);
-    assertThat(ruleDebt.characteristicKey()).isEqualTo("MEMORY_EFFICIENCY");
-    assertThat(ruleDebt.function()).isEqualTo(RemediationFunction.LINEAR);
-    assertThat(ruleDebt.factor()).isEqualTo("3d");
-    assertThat(ruleDebt.offset()).isEqualTo("1d");
-  }
-
-  @Test
-  public void replace_mn_by_min() {
-    String xml = getFileContent("replace_mn_by_min.xml");
-
-    List<RulesDebtModelXMLImporter.RuleDebt> results = importer.importXML(xml);
-    assertThat(results).hasSize(1);
-
-    RulesDebtModelXMLImporter.RuleDebt ruleDebt = results.get(0);
-    assertThat(ruleDebt.characteristicKey()).isEqualTo("MEMORY_EFFICIENCY");
-    assertThat(ruleDebt.function()).isEqualTo(RemediationFunction.LINEAR);
-    assertThat(ruleDebt.factor()).isEqualTo("3min");
-    assertThat(ruleDebt.offset()).isEqualTo("0d");
-  }
-
-  @Test
-  public void convert_deprecated_linear_with_threshold_function_by_linear_function() {
-    String xml = getFileContent("convert_deprecated_linear_with_threshold_function_by_linear_function.xml");
-
-    List<RulesDebtModelXMLImporter.RuleDebt> results = importer.importXML(xml);
-    assertThat(results).hasSize(1);
-
-    RulesDebtModelXMLImporter.RuleDebt ruleDebt = results.get(0);
-    assertThat(ruleDebt.characteristicKey()).isEqualTo("MEMORY_EFFICIENCY");
-    assertThat(ruleDebt.function()).isEqualTo(RemediationFunction.LINEAR);
-    assertThat(ruleDebt.factor()).isEqualTo("3h");
-    assertThat(ruleDebt.offset()).isEqualTo("0d");
-  }
-
-  @Test
-  public void ignore_deprecated_constant_per_file_function() {
-    String xml = getFileContent("ignore_deprecated_constant_per_file_function.xml");
-
-    List<RulesDebtModelXMLImporter.RuleDebt> results = importer.importXML(xml);
-    assertThat(results).isEmpty();
-  }
-
-  @Test
-  public void ignore_rule_on_root_characteristics() {
-    String xml = getFileContent("ignore_rule_on_root_characteristics.xml");
-
-    List<RulesDebtModelXMLImporter.RuleDebt> results = importer.importXML(xml);
-    assertThat(results).isEmpty();
-  }
-
-  @Test
-  public void import_badly_formatted_xml() {
-    String xml = getFileContent("import_badly_formatted_xml.xml");
-
-    List<RulesDebtModelXMLImporter.RuleDebt> results = importer.importXML(xml);
-    assertThat(results).hasSize(1);
-
-    RulesDebtModelXMLImporter.RuleDebt ruleDebt = results.get(0);
-    assertThat(ruleDebt.characteristicKey()).isEqualTo("MEMORY_EFFICIENCY");
-    assertThat(ruleDebt.ruleKey()).isEqualTo(RuleKey.of("checkstyle", "Regexp"));
-    assertThat(ruleDebt.function()).isEqualTo(RemediationFunction.LINEAR);
-    assertThat(ruleDebt.factor()).isEqualTo("3h");
-    assertThat(ruleDebt.offset()).isEqualTo("0d");
-  }
-
-  @Test
-  public void ignore_invalid_value() throws Exception {
-    String xml = getFileContent("ignore_invalid_value.xml");
-    List<RulesDebtModelXMLImporter.RuleDebt> results = importer.importXML(xml);
-    assertThat(results).isEmpty();
-  }
-
-  private String getFileContent(String file) {
-    try {
-      return Resources.toString(Resources.getResource(RulesDebtModelXMLImporterTest.class, "RulesDebtModelXMLImporterTest/" + file), Charsets.UTF_8);
-    } catch (IOException e) {
-      throw new RuntimeException(e);
-    }
-  }
-
-}
diff --git a/sonar-core/src/test/resources/org/sonar/core/technicaldebt/CharacteristicsDebtModelXMLImporterTest/import_badly_formatted_xml.xml b/sonar-core/src/test/resources/org/sonar/core/technicaldebt/CharacteristicsDebtModelXMLImporterTest/import_badly_formatted_xml.xml
deleted file mode 100644 (file)
index 7f19cf3..0000000
+++ /dev/null
@@ -1,43 +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.
-  -->
-
-<sqale>
-  <chc>
-    <key>USABILITY
-    </key>
-    <name>Usability
-    </name>
-    <desc>Estimate usability
-    </desc>
-  </chc>
-  <chc>
-    <key>EFFICIENCY
-    </key>
-    <name>Efficiency
-    </name>
-    <chc>
-      <key>MEMORY_EFFICIENCY
-      </key>
-      <name>Memory use
-      </name>
-    </chc>
-  </chc>
-
-</sqale>
diff --git a/sonar-core/src/test/resources/org/sonar/core/technicaldebt/CharacteristicsDebtModelXMLImporterTest/import_characteristics.xml b/sonar-core/src/test/resources/org/sonar/core/technicaldebt/CharacteristicsDebtModelXMLImporterTest/import_characteristics.xml
deleted file mode 100644 (file)
index bc7f756..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-<sqale>
-  <chc>
-    <key>PORTABILITY</key>
-    <name>Portability</name>
-    <chc>
-      <key>COMPILER_RELATED_PORTABILITY</key>
-      <name>Compiler related portability</name>
-    </chc>
-    <chc>
-      <key>HARDWARE_RELATED_PORTABILITY</key>
-      <name>Hardware related portability</name>
-    </chc>
-  </chc>
-  <chc>
-    <key>MAINTAINABILITY</key>
-    <name>Maintainability</name>
-    <chc>
-      <key>READABILITY</key>
-      <name>Readability</name>
-    </chc>
-  </chc>
-</sqale>
diff --git a/sonar-core/src/test/resources/org/sonar/core/technicaldebt/DebtCharacteristicsXMLImporterTest/import_badly_formatted_xml.xml b/sonar-core/src/test/resources/org/sonar/core/technicaldebt/DebtCharacteristicsXMLImporterTest/import_badly_formatted_xml.xml
new file mode 100644 (file)
index 0000000..7f19cf3
--- /dev/null
@@ -0,0 +1,43 @@
+<!--
+  ~ 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.
+  -->
+
+<sqale>
+  <chc>
+    <key>USABILITY
+    </key>
+    <name>Usability
+    </name>
+    <desc>Estimate usability
+    </desc>
+  </chc>
+  <chc>
+    <key>EFFICIENCY
+    </key>
+    <name>Efficiency
+    </name>
+    <chc>
+      <key>MEMORY_EFFICIENCY
+      </key>
+      <name>Memory use
+      </name>
+    </chc>
+  </chc>
+
+</sqale>
diff --git a/sonar-core/src/test/resources/org/sonar/core/technicaldebt/DebtCharacteristicsXMLImporterTest/import_characteristics.xml b/sonar-core/src/test/resources/org/sonar/core/technicaldebt/DebtCharacteristicsXMLImporterTest/import_characteristics.xml
new file mode 100644 (file)
index 0000000..bc7f756
--- /dev/null
@@ -0,0 +1,22 @@
+<sqale>
+  <chc>
+    <key>PORTABILITY</key>
+    <name>Portability</name>
+    <chc>
+      <key>COMPILER_RELATED_PORTABILITY</key>
+      <name>Compiler related portability</name>
+    </chc>
+    <chc>
+      <key>HARDWARE_RELATED_PORTABILITY</key>
+      <name>Hardware related portability</name>
+    </chc>
+  </chc>
+  <chc>
+    <key>MAINTAINABILITY</key>
+    <name>Maintainability</name>
+    <chc>
+      <key>READABILITY</key>
+      <name>Readability</name>
+    </chc>
+  </chc>
+</sqale>
diff --git a/sonar-core/src/test/resources/org/sonar/core/technicaldebt/DebtRulesXMLImporterTest/convert_deprecated_linear_with_threshold_function_by_linear_function.xml b/sonar-core/src/test/resources/org/sonar/core/technicaldebt/DebtRulesXMLImporterTest/convert_deprecated_linear_with_threshold_function_by_linear_function.xml
new file mode 100644 (file)
index 0000000..9ebc69b
--- /dev/null
@@ -0,0 +1,36 @@
+<sqale>
+  <chc>
+    <key>USABILITY</key>
+    <name>Usability</name>
+    <desc>Estimate usability</desc>
+  </chc>
+  <chc>
+    <key>EFFICIENCY</key>
+    <name>Efficiency</name>
+    <chc>
+      <key>MEMORY_EFFICIENCY</key>
+      <name>Memory use</name>
+      <chc>
+        <rule-repo>checkstyle</rule-repo>
+        <rule-key>Regexp</rule-key>
+        <prop>
+          <key>remediationFunction</key>
+          <!-- Should be replaced by linear -->
+          <txt>linear_threshold</txt>
+        </prop>
+        <prop>
+          <key>remediationFactor</key>
+          <val>3.0</val>
+          <txt>h</txt>
+        </prop>
+        <!-- Should be ignored -->
+        <prop>
+          <key>offset</key>
+          <val>1.0</val>
+          <txt>h</txt>
+        </prop>
+      </chc>
+    </chc>
+  </chc>
+
+</sqale>
diff --git a/sonar-core/src/test/resources/org/sonar/core/technicaldebt/DebtRulesXMLImporterTest/ignore_deprecated_constant_per_file_function.xml b/sonar-core/src/test/resources/org/sonar/core/technicaldebt/DebtRulesXMLImporterTest/ignore_deprecated_constant_per_file_function.xml
new file mode 100644 (file)
index 0000000..4b8ae3f
--- /dev/null
@@ -0,0 +1,25 @@
+<sqale>
+  <chc>
+    <key>EFFICIENCY</key>
+    <name>Efficiency</name>
+    <chc>
+      <key>MEMORY_EFFICIENCY</key>
+      <name>Memory use</name>
+      <!-- Should be ignored -->
+      <chc>
+        <rule-repo>checkstyle</rule-repo>
+        <rule-key>Regexp</rule-key>
+        <prop>
+          <key>remediationFactor</key>
+          <val>3.0</val>
+          <txt>h</txt>
+        </prop>
+        <prop>
+          <key>remediationFunction</key>
+          <txt>constant_resource</txt>
+        </prop>
+      </chc>
+    </chc>
+  </chc>
+
+</sqale>
diff --git a/sonar-core/src/test/resources/org/sonar/core/technicaldebt/DebtRulesXMLImporterTest/ignore_invalid_value.xml b/sonar-core/src/test/resources/org/sonar/core/technicaldebt/DebtRulesXMLImporterTest/ignore_invalid_value.xml
new file mode 100644 (file)
index 0000000..bb6bdbb
--- /dev/null
@@ -0,0 +1,28 @@
+<sqale>
+  <chc>
+    <key>USABILITY</key>
+    <name>Usability</name>
+    <desc>Estimate usability</desc>
+  </chc>
+  <chc>
+    <key>EFFICIENCY</key>
+    <name>Efficiency</name>
+    <chc>
+      <key>MEMORY_EFFICIENCY</key>
+      <name>Memory use</name>
+      <chc>
+        <rule-repo>checkstyle</rule-repo>
+        <rule-key>Regexp</rule-key>
+        <prop>
+          <key>factor</key>
+          <val>abc</val>
+        </prop>
+        <prop>
+          <key>function</key>
+          <txt>linear</txt>
+        </prop>
+      </chc>
+    </chc>
+  </chc>
+
+</sqale>
diff --git a/sonar-core/src/test/resources/org/sonar/core/technicaldebt/DebtRulesXMLImporterTest/ignore_rule_on_root_characteristics.xml b/sonar-core/src/test/resources/org/sonar/core/technicaldebt/DebtRulesXMLImporterTest/ignore_rule_on_root_characteristics.xml
new file mode 100644 (file)
index 0000000..bcf3ed8
--- /dev/null
@@ -0,0 +1,19 @@
+<sqale>
+  <chc>
+    <key>EFFICIENCY</key>
+    <name>Efficiency</name>
+    <chc>
+      <rule-repo>checkstyle</rule-repo>
+      <rule-key>Regexp</rule-key>
+      <prop>
+        <key>remediationFactor</key>
+        <val>3.0</val>
+        <txt>h</txt>
+      </prop>
+      <prop>
+        <key>remediationFunction</key>
+        <txt>linear</txt>
+      </prop>
+    </chc>
+  </chc>
+</sqale>
diff --git a/sonar-core/src/test/resources/org/sonar/core/technicaldebt/DebtRulesXMLImporterTest/import_badly_formatted_xml.xml b/sonar-core/src/test/resources/org/sonar/core/technicaldebt/DebtRulesXMLImporterTest/import_badly_formatted_xml.xml
new file mode 100644 (file)
index 0000000..6c7d153
--- /dev/null
@@ -0,0 +1,43 @@
+<sqale>
+  <chc>
+    <key>USABILITY
+    </key>
+    <name>Usability
+    </name>
+    <desc>Estimate usability
+    </desc>
+  </chc>
+  <chc>
+    <key>EFFICIENCY
+    </key>
+    <name>Efficiency
+    </name>
+    <chc>
+      <key>MEMORY_EFFICIENCY
+      </key>
+      <name>Memory use
+      </name>
+      <chc>
+        <rule-repo>checkstyle
+        </rule-repo>
+        <rule-key>Regexp
+        </rule-key>
+        <prop>
+          <key>remediationFactor
+          </key>
+          <val>3.0
+          </val>
+          <txt>h
+          </txt>
+        </prop>
+        <prop>
+          <key>remediationFunction
+          </key>
+          <txt>linear
+          </txt>
+        </prop>
+      </chc>
+    </chc>
+  </chc>
+
+</sqale>
diff --git a/sonar-core/src/test/resources/org/sonar/core/technicaldebt/DebtRulesXMLImporterTest/import_constant_issue.xml b/sonar-core/src/test/resources/org/sonar/core/technicaldebt/DebtRulesXMLImporterTest/import_constant_issue.xml
new file mode 100644 (file)
index 0000000..86b1f55
--- /dev/null
@@ -0,0 +1,29 @@
+<sqale>
+  <chc>
+    <key>USABILITY</key>
+    <name>Usability</name>
+    <desc>Estimate usability</desc>
+  </chc>
+  <chc>
+    <key>EFFICIENCY</key>
+    <name>Efficiency</name>
+    <chc>
+      <key>MEMORY_EFFICIENCY</key>
+      <name>Memory use</name>
+      <chc>
+        <rule-repo>checkstyle</rule-repo>
+        <rule-key>Regexp</rule-key>
+        <prop>
+          <key>offset</key>
+          <val>3.0</val>
+          <txt>d</txt>
+        </prop>
+        <prop>
+          <key>remediationFunction</key>
+          <txt>constant_issue</txt>
+        </prop>
+      </chc>
+    </chc>
+  </chc>
+
+</sqale>
diff --git a/sonar-core/src/test/resources/org/sonar/core/technicaldebt/DebtRulesXMLImporterTest/import_linear.xml b/sonar-core/src/test/resources/org/sonar/core/technicaldebt/DebtRulesXMLImporterTest/import_linear.xml
new file mode 100644 (file)
index 0000000..f641a51
--- /dev/null
@@ -0,0 +1,29 @@
+<sqale>
+  <chc>
+    <key>USABILITY</key>
+    <name>Usability</name>
+    <desc>Estimate usability</desc>
+  </chc>
+  <chc>
+    <key>EFFICIENCY</key>
+    <name>Efficiency</name>
+    <chc>
+      <key>MEMORY_EFFICIENCY</key>
+      <name>Memory use</name>
+      <chc>
+        <rule-repo>checkstyle</rule-repo>
+        <rule-key>Regexp</rule-key>
+        <prop>
+          <key>remediationFactor</key>
+          <val>3.0</val>
+          <txt>h</txt>
+        </prop>
+        <prop>
+          <key>remediationFunction</key>
+          <txt>linear</txt>
+        </prop>
+      </chc>
+    </chc>
+  </chc>
+
+</sqale>
diff --git a/sonar-core/src/test/resources/org/sonar/core/technicaldebt/DebtRulesXMLImporterTest/import_linear_with_offset.xml b/sonar-core/src/test/resources/org/sonar/core/technicaldebt/DebtRulesXMLImporterTest/import_linear_with_offset.xml
new file mode 100644 (file)
index 0000000..af05b27
--- /dev/null
@@ -0,0 +1,54 @@
+<!--
+  ~ 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.
+  -->
+
+<sqale>
+  <chc>
+    <key>USABILITY</key>
+    <name>Usability</name>
+    <desc>Estimate usability</desc>
+  </chc>
+  <chc>
+    <key>EFFICIENCY</key>
+    <name>Efficiency</name>
+    <chc>
+      <key>MEMORY_EFFICIENCY</key>
+      <name>Memory use</name>
+      <chc>
+        <rule-repo>checkstyle</rule-repo>
+        <rule-key>Regexp</rule-key>
+        <prop>
+          <key>remediationFactor</key>
+          <val>3.0</val>
+          <txt>h</txt>
+        </prop>
+        <prop>
+          <key>remediationFunction</key>
+          <txt>linear_offset</txt>
+        </prop>
+        <prop>
+          <key>offset</key>
+          <val>1.0</val>
+          <txt>min</txt>
+        </prop>
+      </chc>
+    </chc>
+  </chc>
+
+</sqale>
diff --git a/sonar-core/src/test/resources/org/sonar/core/technicaldebt/DebtRulesXMLImporterTest/import_rules.xml b/sonar-core/src/test/resources/org/sonar/core/technicaldebt/DebtRulesXMLImporterTest/import_rules.xml
new file mode 100644 (file)
index 0000000..d035d7b
--- /dev/null
@@ -0,0 +1,58 @@
+<sqale>
+  <chc>
+    <key>USABILITY</key>
+    <name>Usability</name>
+    <desc>Estimate usability</desc>
+  </chc>
+  <chc>
+    <key>EFFICIENCY</key>
+    <name>Efficiency</name>
+    <chc>
+      <key>MEMORY_EFFICIENCY</key>
+      <name>Memory use</name>
+      <chc>
+        <rule-repo>checkstyle</rule-repo>
+        <rule-key>Regexp</rule-key>
+        <prop>
+          <key>remediationFactor</key>
+          <val>3.0</val>
+          <txt>h</txt>
+        </prop>
+        <prop>
+          <key>remediationFunction</key>
+          <txt>linear</txt>
+        </prop>
+      </chc>
+    </chc>
+  </chc>
+  <chc>
+    <key>PORTABILITY</key>
+    <name>Portability</name>
+    <chc>
+      <key>COMPILER_RELATED_PORTABILITY</key>
+      <name>Compiler related portability</name>
+    </chc>
+    <chc>
+      <key>HARDWARE_RELATED_PORTABILITY</key>
+      <name>Hardware related portability</name>
+      <chc>
+        <rule-repo>checkstyle</rule-repo>
+        <rule-key>Regexp2</rule-key>
+        <prop>
+          <key>remediationFactor</key>
+          <val>3.0</val>
+          <txt>h</txt>
+        </prop>
+        <prop>
+          <key>remediationFunction</key>
+          <txt>linear</txt>
+        </prop>
+        <prop>
+          <key>offset</key>
+          <val>1.0</val>
+          <txt>h</txt>
+        </prop>
+      </chc>
+    </chc>
+  </chc>
+</sqale>
diff --git a/sonar-core/src/test/resources/org/sonar/core/technicaldebt/DebtRulesXMLImporterTest/replace_mn_by_min.xml b/sonar-core/src/test/resources/org/sonar/core/technicaldebt/DebtRulesXMLImporterTest/replace_mn_by_min.xml
new file mode 100644 (file)
index 0000000..a1aafd4
--- /dev/null
@@ -0,0 +1,49 @@
+<!--
+  ~ 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.
+  -->
+
+<sqale>
+  <chc>
+    <key>USABILITY</key>
+    <name>Usability</name>
+    <desc>Estimate usability</desc>
+  </chc>
+  <chc>
+    <key>EFFICIENCY</key>
+    <name>Efficiency</name>
+    <chc>
+      <key>MEMORY_EFFICIENCY</key>
+      <name>Memory use</name>
+      <chc>
+        <rule-repo>checkstyle</rule-repo>
+        <rule-key>Regexp</rule-key>
+        <prop>
+          <key>remediationFactor</key>
+          <val>3.0</val>
+          <txt>mn</txt>
+        </prop>
+        <prop>
+          <key>remediationFunction</key>
+          <txt>linear</txt>
+        </prop>
+      </chc>
+    </chc>
+  </chc>
+
+</sqale>
diff --git a/sonar-core/src/test/resources/org/sonar/core/technicaldebt/DebtRulesXMLImporterTest/use_default_unit_when_no_unit.xml b/sonar-core/src/test/resources/org/sonar/core/technicaldebt/DebtRulesXMLImporterTest/use_default_unit_when_no_unit.xml
new file mode 100644 (file)
index 0000000..f05e512
--- /dev/null
@@ -0,0 +1,32 @@
+<sqale>
+  <chc>
+    <key>USABILITY</key>
+    <name>Usability</name>
+    <desc>Estimate usability</desc>
+  </chc>
+  <chc>
+    <key>EFFICIENCY</key>
+    <name>Efficiency</name>
+    <chc>
+      <key>MEMORY_EFFICIENCY</key>
+      <name>Memory use</name>
+      <chc>
+        <rule-repo>checkstyle</rule-repo>
+        <rule-key>Regexp</rule-key>
+        <prop>
+          <key>remediationFactor</key>
+          <val>3.0</val>
+        </prop>
+        <prop>
+          <key>remediationFunction</key>
+          <txt>linear</txt>
+        </prop>
+        <prop>
+          <key>offset</key>
+          <val>1.0</val>
+        </prop>
+      </chc>
+    </chc>
+  </chc>
+
+</sqale>
diff --git a/sonar-core/src/test/resources/org/sonar/core/technicaldebt/RulesDebtModelXMLImporterTest/convert_deprecated_linear_with_threshold_function_by_linear_function.xml b/sonar-core/src/test/resources/org/sonar/core/technicaldebt/RulesDebtModelXMLImporterTest/convert_deprecated_linear_with_threshold_function_by_linear_function.xml
deleted file mode 100644 (file)
index 9ebc69b..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-<sqale>
-  <chc>
-    <key>USABILITY</key>
-    <name>Usability</name>
-    <desc>Estimate usability</desc>
-  </chc>
-  <chc>
-    <key>EFFICIENCY</key>
-    <name>Efficiency</name>
-    <chc>
-      <key>MEMORY_EFFICIENCY</key>
-      <name>Memory use</name>
-      <chc>
-        <rule-repo>checkstyle</rule-repo>
-        <rule-key>Regexp</rule-key>
-        <prop>
-          <key>remediationFunction</key>
-          <!-- Should be replaced by linear -->
-          <txt>linear_threshold</txt>
-        </prop>
-        <prop>
-          <key>remediationFactor</key>
-          <val>3.0</val>
-          <txt>h</txt>
-        </prop>
-        <!-- Should be ignored -->
-        <prop>
-          <key>offset</key>
-          <val>1.0</val>
-          <txt>h</txt>
-        </prop>
-      </chc>
-    </chc>
-  </chc>
-
-</sqale>
diff --git a/sonar-core/src/test/resources/org/sonar/core/technicaldebt/RulesDebtModelXMLImporterTest/ignore_deprecated_constant_per_file_function.xml b/sonar-core/src/test/resources/org/sonar/core/technicaldebt/RulesDebtModelXMLImporterTest/ignore_deprecated_constant_per_file_function.xml
deleted file mode 100644 (file)
index 4b8ae3f..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-<sqale>
-  <chc>
-    <key>EFFICIENCY</key>
-    <name>Efficiency</name>
-    <chc>
-      <key>MEMORY_EFFICIENCY</key>
-      <name>Memory use</name>
-      <!-- Should be ignored -->
-      <chc>
-        <rule-repo>checkstyle</rule-repo>
-        <rule-key>Regexp</rule-key>
-        <prop>
-          <key>remediationFactor</key>
-          <val>3.0</val>
-          <txt>h</txt>
-        </prop>
-        <prop>
-          <key>remediationFunction</key>
-          <txt>constant_resource</txt>
-        </prop>
-      </chc>
-    </chc>
-  </chc>
-
-</sqale>
diff --git a/sonar-core/src/test/resources/org/sonar/core/technicaldebt/RulesDebtModelXMLImporterTest/ignore_invalid_value.xml b/sonar-core/src/test/resources/org/sonar/core/technicaldebt/RulesDebtModelXMLImporterTest/ignore_invalid_value.xml
deleted file mode 100644 (file)
index bb6bdbb..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-<sqale>
-  <chc>
-    <key>USABILITY</key>
-    <name>Usability</name>
-    <desc>Estimate usability</desc>
-  </chc>
-  <chc>
-    <key>EFFICIENCY</key>
-    <name>Efficiency</name>
-    <chc>
-      <key>MEMORY_EFFICIENCY</key>
-      <name>Memory use</name>
-      <chc>
-        <rule-repo>checkstyle</rule-repo>
-        <rule-key>Regexp</rule-key>
-        <prop>
-          <key>factor</key>
-          <val>abc</val>
-        </prop>
-        <prop>
-          <key>function</key>
-          <txt>linear</txt>
-        </prop>
-      </chc>
-    </chc>
-  </chc>
-
-</sqale>
diff --git a/sonar-core/src/test/resources/org/sonar/core/technicaldebt/RulesDebtModelXMLImporterTest/ignore_rule_on_root_characteristics.xml b/sonar-core/src/test/resources/org/sonar/core/technicaldebt/RulesDebtModelXMLImporterTest/ignore_rule_on_root_characteristics.xml
deleted file mode 100644 (file)
index bcf3ed8..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-<sqale>
-  <chc>
-    <key>EFFICIENCY</key>
-    <name>Efficiency</name>
-    <chc>
-      <rule-repo>checkstyle</rule-repo>
-      <rule-key>Regexp</rule-key>
-      <prop>
-        <key>remediationFactor</key>
-        <val>3.0</val>
-        <txt>h</txt>
-      </prop>
-      <prop>
-        <key>remediationFunction</key>
-        <txt>linear</txt>
-      </prop>
-    </chc>
-  </chc>
-</sqale>
diff --git a/sonar-core/src/test/resources/org/sonar/core/technicaldebt/RulesDebtModelXMLImporterTest/import_badly_formatted_xml.xml b/sonar-core/src/test/resources/org/sonar/core/technicaldebt/RulesDebtModelXMLImporterTest/import_badly_formatted_xml.xml
deleted file mode 100644 (file)
index 6c7d153..0000000
+++ /dev/null
@@ -1,43 +0,0 @@
-<sqale>
-  <chc>
-    <key>USABILITY
-    </key>
-    <name>Usability
-    </name>
-    <desc>Estimate usability
-    </desc>
-  </chc>
-  <chc>
-    <key>EFFICIENCY
-    </key>
-    <name>Efficiency
-    </name>
-    <chc>
-      <key>MEMORY_EFFICIENCY
-      </key>
-      <name>Memory use
-      </name>
-      <chc>
-        <rule-repo>checkstyle
-        </rule-repo>
-        <rule-key>Regexp
-        </rule-key>
-        <prop>
-          <key>remediationFactor
-          </key>
-          <val>3.0
-          </val>
-          <txt>h
-          </txt>
-        </prop>
-        <prop>
-          <key>remediationFunction
-          </key>
-          <txt>linear
-          </txt>
-        </prop>
-      </chc>
-    </chc>
-  </chc>
-
-</sqale>
diff --git a/sonar-core/src/test/resources/org/sonar/core/technicaldebt/RulesDebtModelXMLImporterTest/import_constant_issue.xml b/sonar-core/src/test/resources/org/sonar/core/technicaldebt/RulesDebtModelXMLImporterTest/import_constant_issue.xml
deleted file mode 100644 (file)
index 86b1f55..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-<sqale>
-  <chc>
-    <key>USABILITY</key>
-    <name>Usability</name>
-    <desc>Estimate usability</desc>
-  </chc>
-  <chc>
-    <key>EFFICIENCY</key>
-    <name>Efficiency</name>
-    <chc>
-      <key>MEMORY_EFFICIENCY</key>
-      <name>Memory use</name>
-      <chc>
-        <rule-repo>checkstyle</rule-repo>
-        <rule-key>Regexp</rule-key>
-        <prop>
-          <key>offset</key>
-          <val>3.0</val>
-          <txt>d</txt>
-        </prop>
-        <prop>
-          <key>remediationFunction</key>
-          <txt>constant_issue</txt>
-        </prop>
-      </chc>
-    </chc>
-  </chc>
-
-</sqale>
diff --git a/sonar-core/src/test/resources/org/sonar/core/technicaldebt/RulesDebtModelXMLImporterTest/import_linear.xml b/sonar-core/src/test/resources/org/sonar/core/technicaldebt/RulesDebtModelXMLImporterTest/import_linear.xml
deleted file mode 100644 (file)
index f641a51..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-<sqale>
-  <chc>
-    <key>USABILITY</key>
-    <name>Usability</name>
-    <desc>Estimate usability</desc>
-  </chc>
-  <chc>
-    <key>EFFICIENCY</key>
-    <name>Efficiency</name>
-    <chc>
-      <key>MEMORY_EFFICIENCY</key>
-      <name>Memory use</name>
-      <chc>
-        <rule-repo>checkstyle</rule-repo>
-        <rule-key>Regexp</rule-key>
-        <prop>
-          <key>remediationFactor</key>
-          <val>3.0</val>
-          <txt>h</txt>
-        </prop>
-        <prop>
-          <key>remediationFunction</key>
-          <txt>linear</txt>
-        </prop>
-      </chc>
-    </chc>
-  </chc>
-
-</sqale>
diff --git a/sonar-core/src/test/resources/org/sonar/core/technicaldebt/RulesDebtModelXMLImporterTest/import_linear_with_offset.xml b/sonar-core/src/test/resources/org/sonar/core/technicaldebt/RulesDebtModelXMLImporterTest/import_linear_with_offset.xml
deleted file mode 100644 (file)
index af05b27..0000000
+++ /dev/null
@@ -1,54 +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.
-  -->
-
-<sqale>
-  <chc>
-    <key>USABILITY</key>
-    <name>Usability</name>
-    <desc>Estimate usability</desc>
-  </chc>
-  <chc>
-    <key>EFFICIENCY</key>
-    <name>Efficiency</name>
-    <chc>
-      <key>MEMORY_EFFICIENCY</key>
-      <name>Memory use</name>
-      <chc>
-        <rule-repo>checkstyle</rule-repo>
-        <rule-key>Regexp</rule-key>
-        <prop>
-          <key>remediationFactor</key>
-          <val>3.0</val>
-          <txt>h</txt>
-        </prop>
-        <prop>
-          <key>remediationFunction</key>
-          <txt>linear_offset</txt>
-        </prop>
-        <prop>
-          <key>offset</key>
-          <val>1.0</val>
-          <txt>min</txt>
-        </prop>
-      </chc>
-    </chc>
-  </chc>
-
-</sqale>
diff --git a/sonar-core/src/test/resources/org/sonar/core/technicaldebt/RulesDebtModelXMLImporterTest/import_rules.xml b/sonar-core/src/test/resources/org/sonar/core/technicaldebt/RulesDebtModelXMLImporterTest/import_rules.xml
deleted file mode 100644 (file)
index d035d7b..0000000
+++ /dev/null
@@ -1,58 +0,0 @@
-<sqale>
-  <chc>
-    <key>USABILITY</key>
-    <name>Usability</name>
-    <desc>Estimate usability</desc>
-  </chc>
-  <chc>
-    <key>EFFICIENCY</key>
-    <name>Efficiency</name>
-    <chc>
-      <key>MEMORY_EFFICIENCY</key>
-      <name>Memory use</name>
-      <chc>
-        <rule-repo>checkstyle</rule-repo>
-        <rule-key>Regexp</rule-key>
-        <prop>
-          <key>remediationFactor</key>
-          <val>3.0</val>
-          <txt>h</txt>
-        </prop>
-        <prop>
-          <key>remediationFunction</key>
-          <txt>linear</txt>
-        </prop>
-      </chc>
-    </chc>
-  </chc>
-  <chc>
-    <key>PORTABILITY</key>
-    <name>Portability</name>
-    <chc>
-      <key>COMPILER_RELATED_PORTABILITY</key>
-      <name>Compiler related portability</name>
-    </chc>
-    <chc>
-      <key>HARDWARE_RELATED_PORTABILITY</key>
-      <name>Hardware related portability</name>
-      <chc>
-        <rule-repo>checkstyle</rule-repo>
-        <rule-key>Regexp2</rule-key>
-        <prop>
-          <key>remediationFactor</key>
-          <val>3.0</val>
-          <txt>h</txt>
-        </prop>
-        <prop>
-          <key>remediationFunction</key>
-          <txt>linear</txt>
-        </prop>
-        <prop>
-          <key>offset</key>
-          <val>1.0</val>
-          <txt>h</txt>
-        </prop>
-      </chc>
-    </chc>
-  </chc>
-</sqale>
diff --git a/sonar-core/src/test/resources/org/sonar/core/technicaldebt/RulesDebtModelXMLImporterTest/replace_mn_by_min.xml b/sonar-core/src/test/resources/org/sonar/core/technicaldebt/RulesDebtModelXMLImporterTest/replace_mn_by_min.xml
deleted file mode 100644 (file)
index a1aafd4..0000000
+++ /dev/null
@@ -1,49 +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.
-  -->
-
-<sqale>
-  <chc>
-    <key>USABILITY</key>
-    <name>Usability</name>
-    <desc>Estimate usability</desc>
-  </chc>
-  <chc>
-    <key>EFFICIENCY</key>
-    <name>Efficiency</name>
-    <chc>
-      <key>MEMORY_EFFICIENCY</key>
-      <name>Memory use</name>
-      <chc>
-        <rule-repo>checkstyle</rule-repo>
-        <rule-key>Regexp</rule-key>
-        <prop>
-          <key>remediationFactor</key>
-          <val>3.0</val>
-          <txt>mn</txt>
-        </prop>
-        <prop>
-          <key>remediationFunction</key>
-          <txt>linear</txt>
-        </prop>
-      </chc>
-    </chc>
-  </chc>
-
-</sqale>
diff --git a/sonar-core/src/test/resources/org/sonar/core/technicaldebt/RulesDebtModelXMLImporterTest/use_default_unit_when_no_unit.xml b/sonar-core/src/test/resources/org/sonar/core/technicaldebt/RulesDebtModelXMLImporterTest/use_default_unit_when_no_unit.xml
deleted file mode 100644 (file)
index f05e512..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-<sqale>
-  <chc>
-    <key>USABILITY</key>
-    <name>Usability</name>
-    <desc>Estimate usability</desc>
-  </chc>
-  <chc>
-    <key>EFFICIENCY</key>
-    <name>Efficiency</name>
-    <chc>
-      <key>MEMORY_EFFICIENCY</key>
-      <name>Memory use</name>
-      <chc>
-        <rule-repo>checkstyle</rule-repo>
-        <rule-key>Regexp</rule-key>
-        <prop>
-          <key>remediationFactor</key>
-          <val>3.0</val>
-        </prop>
-        <prop>
-          <key>remediationFunction</key>
-          <txt>linear</txt>
-        </prop>
-        <prop>
-          <key>offset</key>
-          <val>1.0</val>
-        </prop>
-      </chc>
-    </chc>
-  </chc>
-
-</sqale>
index 556a357015c18458a84e781d75ce3cc21a9fe55d..b72c019dc07ca22d6d45c7397817c1ba7a27009a 100644 (file)
@@ -384,11 +384,11 @@ public final class Platform {
     // technical debt
     servicesContainer.addSingleton(DebtService.class);
     servicesContainer.addSingleton(TechnicalDebtModelSynchronizer.class);
-    servicesContainer.addSingleton(CharacteristicsDebtModelSynchronizer.class);
+    servicesContainer.addSingleton(DebtModelSynchronizer.class);
     servicesContainer.addSingleton(TechnicalDebtModelRepository.class);
     servicesContainer.addSingleton(TechnicalDebtXMLImporter.class);
-    servicesContainer.addSingleton(RulesDebtModelXMLImporter.class);
-    servicesContainer.addSingleton(CharacteristicsDebtModelXMLImporter.class);
+    servicesContainer.addSingleton(DebtRulesXMLImporter.class);
+    servicesContainer.addSingleton(DebtCharacteristicsXMLImporter.class);
     servicesContainer.addSingleton(DefaultTechnicalDebtManager.class);
 
     // source
@@ -437,8 +437,7 @@ public final class Platform {
     startupContainer.addSingleton(RuleRegistration.class);
     startupContainer.addSingleton(RegisterNewProfiles.class);
     startupContainer.addSingleton(JdbcDriverDeployer.class);
-    startupContainer.addSingleton(RegisterDebtCharacteristicModel.class);
-    startupContainer.addSingleton(RegisterTechnicalDebtModel.class);
+    startupContainer.addSingleton(RegisterDebtModel.class);
     startupContainer.addSingleton(GeneratePluginIndex.class);
     startupContainer.addSingleton(GenerateBootstrapIndex.class);
     startupContainer.addSingleton(RegisterNewMeasureFilters.class);
index 571d4af77cedfe0f7a3907a72ca4bf5a3cc67686..42171caef469aac508557e27653b61fc7685ce60 100644 (file)
@@ -31,7 +31,7 @@ import org.sonar.api.server.rule.RuleDefinitions;
 import org.sonar.api.server.rule.RuleParamType;
 import org.sonar.check.Cardinality;
 import org.sonar.core.i18n.RuleI18nManager;
-import org.sonar.core.technicaldebt.RulesDebtModelXMLImporter;
+import org.sonar.core.technicaldebt.DebtRulesXMLImporter;
 import org.sonar.core.technicaldebt.TechnicalDebtModelRepository;
 
 import javax.annotation.CheckForNull;
@@ -53,23 +53,23 @@ public class DeprecatedRuleDefinitions implements RuleDefinitions {
   private final RuleRepository[] repositories;
 
   private final TechnicalDebtModelRepository languageModelFinder;
-  private final RulesDebtModelXMLImporter importer;
+  private final DebtRulesXMLImporter importer;
 
-  public DeprecatedRuleDefinitions(RuleI18nManager i18n, RuleRepository[] repositories, TechnicalDebtModelRepository languageModelFinder, RulesDebtModelXMLImporter importer) {
+  public DeprecatedRuleDefinitions(RuleI18nManager i18n, RuleRepository[] repositories, TechnicalDebtModelRepository languageModelFinder, DebtRulesXMLImporter importer) {
     this.i18n = i18n;
     this.repositories = repositories;
     this.languageModelFinder = languageModelFinder;
     this.importer = importer;
   }
 
-  public DeprecatedRuleDefinitions(RuleI18nManager i18n, TechnicalDebtModelRepository languageModelFinder, RulesDebtModelXMLImporter importer) {
+  public DeprecatedRuleDefinitions(RuleI18nManager i18n, TechnicalDebtModelRepository languageModelFinder, DebtRulesXMLImporter importer) {
     this(i18n, new RuleRepository[0], languageModelFinder, importer);
   }
 
   @Override
   public void define(Context context) {
     // Load rule debt definitions from xml files provided by plugin
-    List<RulesDebtModelXMLImporter.RuleDebt> ruleDebts = loadRuleDebtList();
+    List<DebtRulesXMLImporter.RuleDebt> ruleDebts = loadRuleDebtList();
 
     for (RuleRepository repository : repositories) {
       // RuleRepository API does not handle difference between new and extended repositories,
@@ -101,8 +101,8 @@ public class DeprecatedRuleDefinitions implements RuleDefinitions {
     }
   }
 
-  private void updateRuleDebtDefinitions(NewRule newRule, String repoKey, String ruleKey, List<RulesDebtModelXMLImporter.RuleDebt> ruleDebts){
-    RulesDebtModelXMLImporter.RuleDebt ruleDebt = findRequirement(ruleDebts, repoKey, ruleKey);
+  private void updateRuleDebtDefinitions(NewRule newRule, String repoKey, String ruleKey, List<DebtRulesXMLImporter.RuleDebt> ruleDebts){
+    DebtRulesXMLImporter.RuleDebt ruleDebt = findRequirement(ruleDebts, repoKey, ruleKey);
     if (ruleDebt != null) {
       newRule.setCharacteristicKey(ruleDebt.characteristicKey());
       newRule.setRemediationFunction(ruleDebt.function());
@@ -138,15 +138,15 @@ public class DeprecatedRuleDefinitions implements RuleDefinitions {
     return StringUtils.defaultIfBlank(desc, null);
   }
 
-  public List<RulesDebtModelXMLImporter.RuleDebt> loadRuleDebtList() {
-    List<RulesDebtModelXMLImporter.RuleDebt> ruleDebtList = newArrayList();
+  public List<DebtRulesXMLImporter.RuleDebt> loadRuleDebtList() {
+    List<DebtRulesXMLImporter.RuleDebt> ruleDebtList = newArrayList();
     for (String pluginKey : getContributingPluginListWithoutSqale()) {
       ruleDebtList.addAll(loadRuleDebtsFromXml(pluginKey));
     }
     return ruleDebtList;
   }
 
-  public List<RulesDebtModelXMLImporter.RuleDebt> loadRuleDebtsFromXml(String pluginKey) {
+  public List<DebtRulesXMLImporter.RuleDebt> loadRuleDebtsFromXml(String pluginKey) {
     Reader xmlFileReader = null;
     try {
       xmlFileReader = languageModelFinder.createReaderForXMLFile(pluginKey);
@@ -163,10 +163,10 @@ public class DeprecatedRuleDefinitions implements RuleDefinitions {
   }
 
   @CheckForNull
-  private RulesDebtModelXMLImporter.RuleDebt findRequirement(List<RulesDebtModelXMLImporter.RuleDebt> requirements, final String repoKey, final String ruleKey) {
-    return Iterables.find(requirements, new Predicate<RulesDebtModelXMLImporter.RuleDebt>() {
+  private DebtRulesXMLImporter.RuleDebt findRequirement(List<DebtRulesXMLImporter.RuleDebt> requirements, final String repoKey, final String ruleKey) {
+    return Iterables.find(requirements, new Predicate<DebtRulesXMLImporter.RuleDebt>() {
       @Override
-      public boolean apply(RulesDebtModelXMLImporter.RuleDebt input) {
+      public boolean apply(DebtRulesXMLImporter.RuleDebt input) {
         return input.ruleKey().equals(RuleKey.of(repoKey, ruleKey));
       }
     }, null);
index afaa1b7d0fe36177cc283ccfd23681bac3b24ce3..f3e699dba4e27a46fa0d823fa035b204b1d476ab 100644 (file)
@@ -42,7 +42,7 @@ import org.sonar.core.rule.*;
 import org.sonar.core.technicaldebt.db.CharacteristicDao;
 import org.sonar.core.technicaldebt.db.CharacteristicDto;
 import org.sonar.server.qualityprofile.ProfilesManager;
-import org.sonar.server.startup.RegisterDebtCharacteristicModel;
+import org.sonar.server.startup.RegisterDebtModel;
 
 import javax.annotation.CheckForNull;
 
@@ -77,7 +77,7 @@ public class RuleRegistration implements Startable {
   public RuleRegistration(RuleDefinitionsLoader defLoader, ProfilesManager profilesManager,
                           RuleRegistry ruleRegistry, ESRuleTags esRuleTags, RuleTagOperations ruleTagOperations,
                           MyBatis myBatis, RuleDao ruleDao, RuleTagDao ruleTagDao, ActiveRuleDao activeRuleDao, CharacteristicDao characteristicDao,
-                          RegisterDebtCharacteristicModel registerTechnicalDebtModel) {
+                          RegisterDebtModel registerTechnicalDebtModel) {
     this.defLoader = defLoader;
     this.profilesManager = profilesManager;
     this.ruleRegistry = ruleRegistry;
diff --git a/sonar-server/src/main/java/org/sonar/server/startup/RegisterDebtCharacteristicModel.java b/sonar-server/src/main/java/org/sonar/server/startup/RegisterDebtCharacteristicModel.java
deleted file mode 100644 (file)
index fcd9f8b..0000000
+++ /dev/null
@@ -1,45 +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.startup;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.sonar.api.utils.TimeProfiler;
-import org.sonar.api.utils.ValidationMessages;
-import org.sonar.core.technicaldebt.CharacteristicsDebtModelSynchronizer;
-
-public class RegisterDebtCharacteristicModel {
-
-  private static final Logger LOGGER = LoggerFactory.getLogger(RegisterDebtCharacteristicModel.class);
-
-  private final CharacteristicsDebtModelSynchronizer manager;
-
-  public RegisterDebtCharacteristicModel(CharacteristicsDebtModelSynchronizer manager) {
-    this.manager = manager;
-  }
-
-  public void start() {
-    TimeProfiler profiler = new TimeProfiler(LOGGER).start("Register Debt Characteristics Model");
-    manager.synchronize(ValidationMessages.create());
-    profiler.stop();
-  }
-
-}
diff --git a/sonar-server/src/main/java/org/sonar/server/startup/RegisterDebtModel.java b/sonar-server/src/main/java/org/sonar/server/startup/RegisterDebtModel.java
new file mode 100644 (file)
index 0000000..7006a1f
--- /dev/null
@@ -0,0 +1,45 @@
+/*
+ * 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.startup;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.sonar.api.utils.TimeProfiler;
+import org.sonar.api.utils.ValidationMessages;
+import org.sonar.core.technicaldebt.DebtModelSynchronizer;
+
+public class RegisterDebtModel {
+
+  private static final Logger LOGGER = LoggerFactory.getLogger(RegisterDebtModel.class);
+
+  private final DebtModelSynchronizer manager;
+
+  public RegisterDebtModel(DebtModelSynchronizer manager) {
+    this.manager = manager;
+  }
+
+  public void start() {
+    TimeProfiler profiler = new TimeProfiler(LOGGER).start("Register technical debt model");
+    manager.synchronize(ValidationMessages.create());
+    profiler.stop();
+  }
+
+}
diff --git a/sonar-server/src/main/java/org/sonar/server/startup/RegisterTechnicalDebtModel.java b/sonar-server/src/main/java/org/sonar/server/startup/RegisterTechnicalDebtModel.java
deleted file mode 100644 (file)
index d533dd7..0000000
+++ /dev/null
@@ -1,53 +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.startup;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.sonar.api.rules.RuleFinder;
-import org.sonar.api.utils.TimeProfiler;
-import org.sonar.api.utils.ValidationMessages;
-import org.sonar.core.technicaldebt.TechnicalDebtModelSynchronizer;
-import org.sonar.core.technicaldebt.TechnicalDebtRuleCache;
-import org.sonar.server.rule.RuleRegistration;
-
-public final class RegisterTechnicalDebtModel {
-
-  private static final Logger LOGGER = LoggerFactory.getLogger(RegisterTechnicalDebtModel.class);
-
-  private final TechnicalDebtModelSynchronizer manager;
-  private final RuleFinder ruleFinder;
-
-  /**
-   * @param registerRulesBeforeModels used only to be started after the creation of check templates
-   */
-  public RegisterTechnicalDebtModel(TechnicalDebtModelSynchronizer manager, RuleFinder ruleFinder, RuleRegistration registerRulesBeforeModels) {
-    this.manager = manager;
-    this.ruleFinder = ruleFinder;
-  }
-
-  public void start() {
-    TimeProfiler profiler = new TimeProfiler(LOGGER).start("Register Technical Debt Model");
-    TechnicalDebtRuleCache technicalDebtRuleCache = new TechnicalDebtRuleCache(ruleFinder);
-    manager.synchronize(ValidationMessages.create(), technicalDebtRuleCache);
-    profiler.stop();
-  }
-
-}
index a34677da554c07c9821efff41b5b456dd757f642..d03dcefd2d68151cde03efd93d2d8358d6067fed 100644 (file)
@@ -32,7 +32,7 @@ import org.sonar.api.rules.RulePriority;
 import org.sonar.api.rules.RuleRepository;
 import org.sonar.api.server.rule.RuleDefinitions;
 import org.sonar.core.i18n.RuleI18nManager;
-import org.sonar.core.technicaldebt.RulesDebtModelXMLImporter;
+import org.sonar.core.technicaldebt.DebtRulesXMLImporter;
 import org.sonar.core.technicaldebt.TechnicalDebtModelRepository;
 
 import java.io.Reader;
@@ -55,7 +55,7 @@ public class DeprecatedRuleDefinitionsTest {
   TechnicalDebtModelRepository debtModelRepository;
 
   @Mock
-  RulesDebtModelXMLImporter importer;
+  DebtRulesXMLImporter importer;
 
   static class CheckstyleRules extends RuleRepository {
     public CheckstyleRules() {
@@ -154,8 +154,8 @@ public class DeprecatedRuleDefinitionsTest {
   public void define_rule_debt() throws Exception {
     RuleDefinitions.Context context = new RuleDefinitions.Context();
 
-    List<RulesDebtModelXMLImporter.RuleDebt> ruleDebts = newArrayList(
-      new RulesDebtModelXMLImporter.RuleDebt()
+    List<DebtRulesXMLImporter.RuleDebt> ruleDebts = newArrayList(
+      new DebtRulesXMLImporter.RuleDebt()
         .setCharacteristicKey("MEMORY_EFFICIENCY")
         .setRuleKey(RuleKey.of("checkstyle", "ConstantName"))
         .setFunction(RemediationFunction.LINEAR_OFFSET)
index 90f691f353f1c2ae8b27aa6ed8221973365cc1a2..5c07b56addd1f4d78d23c44ce9470af9cdd03422 100644 (file)
@@ -34,7 +34,7 @@ import org.sonar.core.rule.RuleDao;
 import org.sonar.core.rule.RuleTagDao;
 import org.sonar.core.technicaldebt.db.CharacteristicDao;
 import org.sonar.server.qualityprofile.ProfilesManager;
-import org.sonar.server.startup.RegisterDebtCharacteristicModel;
+import org.sonar.server.startup.RegisterDebtModel;
 
 import static org.fest.assertions.Assertions.assertThat;
 import static org.fest.assertions.Fail.fail;
@@ -68,7 +68,7 @@ public class RuleRegistrationTest extends AbstractDaoTestCase {
     ruleTagOperations = new RuleTagOperations(ruleTagDao, esRuleTags);
     characteristicDao = new CharacteristicDao(myBatis);
     task = new RuleRegistration(new RuleDefinitionsLoader(mock(RuleRepositories.class), new RuleDefinitions[]{new FakeRepository()}),
-      profilesManager, ruleRegistry, esRuleTags, ruleTagOperations, myBatis, ruleDao, ruleTagDao, activeRuleDao, characteristicDao, mock(RegisterDebtCharacteristicModel.class));
+      profilesManager, ruleRegistry, esRuleTags, ruleTagOperations, myBatis, ruleDao, ruleTagDao, activeRuleDao, characteristicDao, mock(RegisterDebtModel.class));
   }
 
   @Test
@@ -215,7 +215,7 @@ public class RuleRegistrationTest extends AbstractDaoTestCase {
   @Test
   public void test_high_number_of_rules() {
     task = new RuleRegistration(new RuleDefinitionsLoader(mock(RuleRepositories.class), new RuleDefinitions[]{new BigRepository()}),
-      profilesManager, ruleRegistry, esRuleTags, ruleTagOperations, myBatis, ruleDao, ruleTagDao, activeRuleDao, characteristicDao, mock(RegisterDebtCharacteristicModel.class));
+      profilesManager, ruleRegistry, esRuleTags, ruleTagOperations, myBatis, ruleDao, ruleTagDao, activeRuleDao, characteristicDao, mock(RegisterDebtModel.class));
 
     setupData("shared");
     task.start();
@@ -230,7 +230,7 @@ public class RuleRegistrationTest extends AbstractDaoTestCase {
   public void insert_extended_repositories() {
     task = new RuleRegistration(new RuleDefinitionsLoader(mock(RuleRepositories.class), new RuleDefinitions[]{
       new FindbugsRepository(), new FbContribRepository()}),
-      profilesManager, ruleRegistry, esRuleTags, ruleTagOperations, myBatis, ruleDao, ruleTagDao, activeRuleDao, characteristicDao, mock(RegisterDebtCharacteristicModel.class));
+      profilesManager, ruleRegistry, esRuleTags, ruleTagOperations, myBatis, ruleDao, ruleTagDao, activeRuleDao, characteristicDao, mock(RegisterDebtModel.class));
 
     setupData("empty");
     task.start();
diff --git a/sonar-server/src/test/java/org/sonar/server/startup/RegisterDebtCharacteristicModelTest.java b/sonar-server/src/test/java/org/sonar/server/startup/RegisterDebtCharacteristicModelTest.java
deleted file mode 100644 (file)
index 5260736..0000000
+++ /dev/null
@@ -1,41 +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.startup;
-
-import org.junit.Test;
-import org.sonar.api.utils.ValidationMessages;
-import org.sonar.core.technicaldebt.CharacteristicsDebtModelSynchronizer;
-
-import static org.mockito.Matchers.any;
-import static org.mockito.Mockito.*;
-
-public class RegisterDebtCharacteristicModelTest {
-
-  @Test
-  public void create_model() throws Exception {
-    CharacteristicsDebtModelSynchronizer synchronizer = mock(CharacteristicsDebtModelSynchronizer.class);
-    RegisterDebtCharacteristicModel sqaleDefinition = new RegisterDebtCharacteristicModel(synchronizer);
-
-    sqaleDefinition.start();
-
-    verify(synchronizer, times(1)).synchronize(any(ValidationMessages.class));
-  }
-}
diff --git a/sonar-server/src/test/java/org/sonar/server/startup/RegisterDebtModelTest.java b/sonar-server/src/test/java/org/sonar/server/startup/RegisterDebtModelTest.java
new file mode 100644 (file)
index 0000000..be235f4
--- /dev/null
@@ -0,0 +1,41 @@
+/*
+ * 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.startup;
+
+import org.junit.Test;
+import org.sonar.api.utils.ValidationMessages;
+import org.sonar.core.technicaldebt.DebtModelSynchronizer;
+
+import static org.mockito.Matchers.any;
+import static org.mockito.Mockito.*;
+
+public class RegisterDebtModelTest {
+
+  @Test
+  public void create_model() throws Exception {
+    DebtModelSynchronizer synchronizer = mock(DebtModelSynchronizer.class);
+    RegisterDebtModel sqaleDefinition = new RegisterDebtModel(synchronizer);
+
+    sqaleDefinition.start();
+
+    verify(synchronizer, times(1)).synchronize(any(ValidationMessages.class));
+  }
+}
diff --git a/sonar-server/src/test/java/org/sonar/server/startup/RegisterTechnicalDebtModelTest.java b/sonar-server/src/test/java/org/sonar/server/startup/RegisterTechnicalDebtModelTest.java
deleted file mode 100644 (file)
index 21015ed..0000000
+++ /dev/null
@@ -1,43 +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.startup;
-
-import org.junit.Test;
-import org.sonar.api.rules.RuleFinder;
-import org.sonar.api.utils.ValidationMessages;
-import org.sonar.core.technicaldebt.TechnicalDebtModelSynchronizer;
-import org.sonar.core.technicaldebt.TechnicalDebtRuleCache;
-
-import static org.mockito.Matchers.any;
-import static org.mockito.Mockito.*;
-
-public class RegisterTechnicalDebtModelTest {
-
-  @Test
-  public void create_model() throws Exception {
-    TechnicalDebtModelSynchronizer manger = mock(TechnicalDebtModelSynchronizer.class);
-    RuleFinder ruleFinder = mock(RuleFinder.class);
-    RegisterTechnicalDebtModel sqaleDefinition = new RegisterTechnicalDebtModel(manger, ruleFinder, null);
-
-    sqaleDefinition.start();
-
-    verify(manger, times(1)).synchronize(any(ValidationMessages.class), any(TechnicalDebtRuleCache.class));
-  }
-}