]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-5056 Refactoring of DebtModelService to have a clean dedicated server side...
authorJulien Lancelot <julien.lancelot@sonarsource.com>
Tue, 18 Mar 2014 08:34:41 +0000 (09:34 +0100)
committerJulien Lancelot <julien.lancelot@sonarsource.com>
Tue, 18 Mar 2014 09:29:58 +0000 (10:29 +0100)
20 files changed:
plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/technical_debt_pyramid.html.erb
sonar-core/src/main/java/org/sonar/core/technicaldebt/DefaultTechnicalDebtManager.java [deleted file]
sonar-core/src/test/java/org/sonar/core/technicaldebt/DefaultTechnicalDebtManagerTest.java [deleted file]
sonar-plugin-api/src/main/java/org/sonar/api/server/debt/DebtCharacteristic.java [new file with mode: 0644]
sonar-plugin-api/src/main/java/org/sonar/api/server/debt/DebtModel.java [new file with mode: 0644]
sonar-plugin-api/src/main/java/org/sonar/api/server/debt/internal/DefaultDebtCharacteristic.java [new file with mode: 0644]
sonar-plugin-api/src/main/java/org/sonar/api/server/debt/internal/package-info.java [new file with mode: 0644]
sonar-plugin-api/src/main/java/org/sonar/api/server/debt/package-info.java [new file with mode: 0644]
sonar-plugin-api/src/main/java/org/sonar/api/technicaldebt/server/Characteristic.java
sonar-plugin-api/src/main/java/org/sonar/api/technicaldebt/server/TechnicalDebtManager.java [deleted file]
sonar-plugin-api/src/main/java/org/sonar/api/technicaldebt/server/internal/DefaultCharacteristic.java
sonar-server/src/main/java/org/sonar/server/debt/DebtModelService.java [new file with mode: 0644]
sonar-server/src/main/java/org/sonar/server/debt/DebtService.java [deleted file]
sonar-server/src/main/java/org/sonar/server/issue/ws/IssueShowWsHandler.java
sonar-server/src/main/java/org/sonar/server/platform/ServerComponents.java
sonar-server/src/main/webapp/WEB-INF/app/controllers/issue_controller.rb
sonar-server/src/main/webapp/WEB-INF/app/models/internal.rb
sonar-server/src/test/java/org/sonar/server/debt/DebtModelServiceTest.java [new file with mode: 0644]
sonar-server/src/test/java/org/sonar/server/debt/DebtServiceTest.java [deleted file]
sonar-server/src/test/java/org/sonar/server/issue/ws/IssueShowWsHandlerTest.java

index a2ecdbd479f5a8e66e6efb4ca5d274b3b6cdf83b..cb4b9b3f8a39f07782f82429b33b7691c9fb956b 100644 (file)
@@ -1,7 +1,7 @@
 <%
    technical_debt = measure('sqale_index')
 
-   root_characteristics = Internal.debt.findRootCharacteristics().to_a
+   root_characteristics = Internal.debt.rootCharacteristics().to_a
 
    should_display_diff_measures = dashboard_configuration.selected_period? && technical_debt.variation(dashboard_configuration.period_index)!=nil
    if technical_debt.nil? || root_characteristics.empty?
diff --git a/sonar-core/src/main/java/org/sonar/core/technicaldebt/DefaultTechnicalDebtManager.java b/sonar-core/src/main/java/org/sonar/core/technicaldebt/DefaultTechnicalDebtManager.java
deleted file mode 100644 (file)
index b9d6d6b..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 org.sonar.api.rules.Rule;
-import org.sonar.api.technicaldebt.server.Characteristic;
-import org.sonar.api.technicaldebt.server.TechnicalDebtManager;
-import org.sonar.api.technicaldebt.server.internal.DefaultCharacteristic;
-import org.sonar.core.technicaldebt.db.CharacteristicDao;
-import org.sonar.core.technicaldebt.db.CharacteristicDto;
-
-import javax.annotation.CheckForNull;
-
-import java.util.List;
-
-import static com.google.common.collect.Lists.newArrayList;
-
-/**
- * TODO This class should be replaced or created by a TechnicalDebtManagerBuilder
- */
-public class DefaultTechnicalDebtManager implements TechnicalDebtManager {
-
-  private final CharacteristicDao dao;
-
-  public DefaultTechnicalDebtManager(CharacteristicDao dao) {
-    this.dao = dao;
-  }
-
-  public List<Characteristic> findRootCharacteristics() {
-    List<CharacteristicDto> dtos = dao.selectEnabledRootCharacteristics();
-    List<Characteristic> characteristics = newArrayList();
-    for (CharacteristicDto dto : dtos) {
-      characteristics.add(toCharacteristic(dto));
-    }
-    return characteristics;
-  }
-
-  @CheckForNull
-  public Characteristic findCharacteristicById(Integer id) {
-    CharacteristicDto dto = dao.selectById(id);
-    if (dto != null) {
-      return toCharacteristic(dto);
-    }
-    return null;
-  }
-
-  /**
-   * @deprecated since 4.3. Always return null
-   */
-  @Deprecated
-  @CheckForNull
-  public Characteristic findRequirementByRuleId(int ruleId) {
-    return null;
-  }
-
-  /**
-   * @deprecated since 4.3. Always return null
-   */
-  @Deprecated
-  @CheckForNull
-  public Characteristic findRequirementByRule(Rule rule) {
-    return null;
-  }
-
-  private static Characteristic toCharacteristic(CharacteristicDto dto) {
-    return new DefaultCharacteristic()
-      .setId(dto.getId())
-      .setKey(dto.getKey())
-      .setName(dto.getName())
-      .setOrder(dto.getOrder())
-      .setParentId(dto.getParentId());
-  }
-
-}
diff --git a/sonar-core/src/test/java/org/sonar/core/technicaldebt/DefaultTechnicalDebtManagerTest.java b/sonar-core/src/test/java/org/sonar/core/technicaldebt/DefaultTechnicalDebtManagerTest.java
deleted file mode 100644 (file)
index fb7b2a6..0000000
+++ /dev/null
@@ -1,107 +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.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.Mock;
-import org.mockito.runners.MockitoJUnitRunner;
-import org.sonar.api.rules.Rule;
-import org.sonar.api.technicaldebt.server.Characteristic;
-import org.sonar.core.technicaldebt.db.CharacteristicDao;
-import org.sonar.core.technicaldebt.db.CharacteristicDto;
-
-import java.util.List;
-
-import static com.google.common.collect.Lists.newArrayList;
-import static org.fest.assertions.Assertions.assertThat;
-import static org.mockito.Mockito.when;
-
-@RunWith(MockitoJUnitRunner.class)
-public class DefaultTechnicalDebtManagerTest {
-
-  @Mock
-  CharacteristicDao dao;
-
-  DefaultTechnicalDebtManager finder;
-
-  @Before
-  public void setUp() throws Exception {
-    finder = new DefaultTechnicalDebtManager(dao);
-  }
-
-  @Test
-  public void find_root_characteristics() throws Exception {
-    CharacteristicDto rootCharacteristicDto = new CharacteristicDto()
-      .setId(1)
-      .setKey("MEMORY_EFFICIENCY")
-      .setName("Memory use");
-    when(dao.selectEnabledRootCharacteristics()).thenReturn(newArrayList(rootCharacteristicDto));
-
-    List<Characteristic> result = finder.findRootCharacteristics();
-    assertThat(result).hasSize(1);
-
-    Characteristic rootCharacteristic = result.get(0);
-    assertThat(rootCharacteristic.key()).isEqualTo("MEMORY_EFFICIENCY");
-    assertThat(rootCharacteristic.name()).isEqualTo("Memory use");
-    assertThat(rootCharacteristic.parentId()).isNull();
-    assertThat(rootCharacteristic.rootId()).isNull();
-  }
-
-  @Test
-  public void find_characteristic() throws Exception {
-    Rule rule = Rule.create("repo", "key");
-    rule.setId(1);
-
-    when(dao.selectById(2)).thenReturn(
-      new CharacteristicDto().setId(2).setKey("COMPILER_RELATED_PORTABILITY").setName("Compiler").setParentId(1));
-
-    Characteristic result = finder.findCharacteristicById(2);
-
-    assertThat(result.id()).isEqualTo(2);
-    assertThat(result.parentId()).isEqualTo(1);
-    assertThat(result.key()).isEqualTo("COMPILER_RELATED_PORTABILITY");
-    assertThat(result.name()).isEqualTo("Compiler");
-  }
-
-  @Test
-  public void not_find_characteristic() throws Exception {
-    Rule rule = Rule.create("repo", "key");
-    rule.setId(1);
-
-    when(dao.selectById(rule.getId())).thenReturn(null);
-
-    Characteristic result = finder.findCharacteristicById(2);
-    assertThat(result).isNull();
-  }
-
-  @Test
-  public void find_requirement_always_return_null() throws Exception {
-    assertThat(finder.findRequirementByRule(Rule.create("repo", "key"))).isNull();
-  }
-
-  @Test
-  public void find_requirement_by_rule_id_always_return_null() throws Exception {
-    assertThat(finder.findRequirementByRuleId(1)).isNull();
-  }
-
-}
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/server/debt/DebtCharacteristic.java b/sonar-plugin-api/src/main/java/org/sonar/api/server/debt/DebtCharacteristic.java
new file mode 100644 (file)
index 0000000..8f3dd60
--- /dev/null
@@ -0,0 +1,40 @@
+/*
+ * 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.api.server.debt;
+
+import javax.annotation.CheckForNull;
+
+/**
+ * @since 4.3
+ */
+public interface DebtCharacteristic {
+  Integer id();
+
+  String key();
+
+  String name();
+
+  @CheckForNull
+  Integer order();
+
+  @CheckForNull
+  Integer parentId();
+}
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/server/debt/DebtModel.java b/sonar-plugin-api/src/main/java/org/sonar/api/server/debt/DebtModel.java
new file mode 100644 (file)
index 0000000..e2bd93c
--- /dev/null
@@ -0,0 +1,38 @@
+/*
+ * 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.api.server.debt;
+
+import org.sonar.api.ServerComponent;
+
+import java.util.List;
+
+/**
+ * @since 4.3
+ */
+public interface DebtModel extends ServerComponent {
+
+  List<DebtCharacteristic> characteristics();
+
+  List<DebtCharacteristic> rootCharacteristics();
+
+  DebtCharacteristic characteristicById(int id);
+
+}
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/server/debt/internal/DefaultDebtCharacteristic.java b/sonar-plugin-api/src/main/java/org/sonar/api/server/debt/internal/DefaultDebtCharacteristic.java
new file mode 100644 (file)
index 0000000..6b6fce0
--- /dev/null
@@ -0,0 +1,85 @@
+/*
+ * 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.api.server.debt.internal;
+
+import org.sonar.api.server.debt.DebtCharacteristic;
+
+/**
+ * @since 4.3
+ */
+public class DefaultDebtCharacteristic implements DebtCharacteristic {
+
+  private Integer id;
+  private String key;
+  private String name;
+  private Integer order;
+  private Integer parentId;
+
+  @Override
+  public Integer id() {
+    return id;
+  }
+
+  public DefaultDebtCharacteristic setId(Integer id) {
+    this.id = id;
+    return this;
+  }
+
+  @Override
+  public String key() {
+    return key;
+  }
+
+  public DefaultDebtCharacteristic setKey(String key) {
+    this.key = key;
+    return this;
+  }
+
+  @Override
+  public String name() {
+    return name;
+  }
+
+  public DefaultDebtCharacteristic setName(String name) {
+    this.name = name;
+    return this;
+  }
+
+  @Override
+  public Integer order() {
+    return order;
+  }
+
+  public DefaultDebtCharacteristic setOrder(Integer order) {
+    this.order = order;
+    return this;
+  }
+
+  @Override
+  public Integer parentId() {
+    return parentId;
+  }
+
+  public DefaultDebtCharacteristic setParentId(Integer parentId) {
+    this.parentId = parentId;
+    return this;
+  }
+}
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/server/debt/internal/package-info.java b/sonar-plugin-api/src/main/java/org/sonar/api/server/debt/internal/package-info.java
new file mode 100644 (file)
index 0000000..fc333da
--- /dev/null
@@ -0,0 +1,24 @@
+/*
+ * 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.
+ */
+
+@ParametersAreNonnullByDefault
+package org.sonar.api.server.debt.internal;
+
+import javax.annotation.ParametersAreNonnullByDefault;
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/server/debt/package-info.java b/sonar-plugin-api/src/main/java/org/sonar/api/server/debt/package-info.java
new file mode 100644 (file)
index 0000000..296802f
--- /dev/null
@@ -0,0 +1,24 @@
+/*
+ * 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.
+ */
+
+@ParametersAreNonnullByDefault
+package org.sonar.api.server.debt;
+
+import javax.annotation.ParametersAreNonnullByDefault;
index c39eba4108a9ddc6d334a374bb04417adc50671b..1e263a6fe202e794afc5cb54a79d3bbea14201c3 100644 (file)
@@ -27,8 +27,10 @@ import org.sonar.api.utils.internal.WorkDuration;
 import javax.annotation.CheckForNull;
 
 /**
- * @since 4.1
+ * @since 4.1 *
+ * @deprecated since 4.3.
  */
+@Deprecated
 public interface Characteristic {
 
   Integer id();
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/technicaldebt/server/TechnicalDebtManager.java b/sonar-plugin-api/src/main/java/org/sonar/api/technicaldebt/server/TechnicalDebtManager.java
deleted file mode 100644 (file)
index e3b1d84..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.api.technicaldebt.server;
-
-import org.sonar.api.ServerComponent;
-import org.sonar.api.rules.Rule;
-
-import java.util.List;
-
-/**
- * @since 4.1
- */
-
-public interface TechnicalDebtManager extends ServerComponent {
-
-  List<Characteristic> findRootCharacteristics();
-
-  /**
-   * @deprecated since 4.3. Always return null
-   */
-  @Deprecated
-  Characteristic findRequirementByRule(Rule rule);
-
-  Characteristic findCharacteristicById(Integer id);
-}
index 15a0e68dfd4ce5659396945f8116620a5b46e71f..1c49df8a6621fdde19470b7bff2a544a93e07954 100644 (file)
@@ -32,7 +32,9 @@ import javax.annotation.Nullable;
 
 /**
  * @since 4.1
+ * @deprecated since 4.3.
  */
+@Deprecated
 public class DefaultCharacteristic implements Characteristic {
 
   private Integer id;
diff --git a/sonar-server/src/main/java/org/sonar/server/debt/DebtModelService.java b/sonar-server/src/main/java/org/sonar/server/debt/DebtModelService.java
new file mode 100644 (file)
index 0000000..a5a3280
--- /dev/null
@@ -0,0 +1,81 @@
+/*
+ * 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.debt;
+
+import com.google.common.base.Function;
+import com.google.common.collect.Iterables;
+import org.sonar.api.server.debt.DebtCharacteristic;
+import org.sonar.api.server.debt.DebtModel;
+import org.sonar.api.server.debt.internal.DefaultDebtCharacteristic;
+import org.sonar.core.technicaldebt.db.CharacteristicDao;
+import org.sonar.core.technicaldebt.db.CharacteristicDto;
+
+import javax.annotation.CheckForNull;
+
+import java.util.Collection;
+import java.util.List;
+
+import static com.google.common.collect.Lists.newArrayList;
+
+/**
+ * Used through ruby code <pre>Internal.debt</pre>
+ */
+public class DebtModelService implements DebtModel {
+
+  private final CharacteristicDao dao;
+
+  public DebtModelService(CharacteristicDao dao) {
+    this.dao = dao;
+  }
+
+  public List<DebtCharacteristic> rootCharacteristics() {
+    return toCharacteristics(dao.selectEnabledRootCharacteristics());
+  }
+
+  public List<DebtCharacteristic> characteristics() {
+    return toCharacteristics(dao.selectEnabledCharacteristics());
+  }
+
+  @CheckForNull
+  public DebtCharacteristic characteristicById(int id) {
+    CharacteristicDto dto = dao.selectById(id);
+    return dto != null ? toCharacteristic(dto) : null;
+  }
+
+  private static List<DebtCharacteristic> toCharacteristics(Collection<CharacteristicDto> dtos) {
+    return newArrayList(Iterables.transform(dtos, new Function<CharacteristicDto, DebtCharacteristic>() {
+      @Override
+      public DebtCharacteristic apply(CharacteristicDto input) {
+        return toCharacteristic(input);
+      }
+    }));
+  }
+
+  private static DebtCharacteristic toCharacteristic(CharacteristicDto dto) {
+    return new DefaultDebtCharacteristic()
+      .setId(dto.getId())
+      .setKey(dto.getKey())
+      .setName(dto.getName())
+      .setOrder(dto.getOrder())
+      .setParentId(dto.getParentId());
+  }
+
+}
diff --git a/sonar-server/src/main/java/org/sonar/server/debt/DebtService.java b/sonar-server/src/main/java/org/sonar/server/debt/DebtService.java
deleted file mode 100644 (file)
index 4e5a84c..0000000
+++ /dev/null
@@ -1,56 +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.debt;
-
-import org.sonar.api.ServerComponent;
-import org.sonar.api.technicaldebt.server.Characteristic;
-import org.sonar.core.technicaldebt.DefaultTechnicalDebtManager;
-
-import javax.annotation.CheckForNull;
-
-import java.util.List;
-
-/**
- * Used through ruby code <pre>Internal.debt</pre>
- */
-public class DebtService implements ServerComponent {
-
-  private final DefaultTechnicalDebtManager finder;
-
-  public DebtService(DefaultTechnicalDebtManager finder) {
-    this.finder = finder;
-  }
-
-  public List<Characteristic> findRootCharacteristics() {
-    return finder.findRootCharacteristics();
-  }
-
-  @CheckForNull
-  public Characteristic findRequirementByRuleId(int ruleId) {
-    return finder.findRequirementByRuleId(ruleId);
-  }
-
-  @CheckForNull
-  public Characteristic findCharacteristic(int id) {
-    return finder.findCharacteristicById(id);
-  }
-
-}
index b3a1316ae42c76eb0c62fda2b58ff1d2db76d05f..e41a035ea08150fc99e9c2f7cfd7fc307a25b826 100644 (file)
@@ -27,10 +27,11 @@ import org.sonar.api.issue.*;
 import org.sonar.api.issue.action.Action;
 import org.sonar.api.issue.internal.DefaultIssue;
 import org.sonar.api.issue.internal.FieldDiffs;
+import org.sonar.api.server.debt.DebtCharacteristic;
+import org.sonar.api.server.debt.DebtModel;
 import org.sonar.api.server.ws.Request;
 import org.sonar.api.server.ws.RequestHandler;
 import org.sonar.api.server.ws.Response;
-import org.sonar.api.technicaldebt.server.Characteristic;
 import org.sonar.api.user.User;
 import org.sonar.api.utils.DateUtils;
 import org.sonar.api.utils.Duration;
@@ -39,7 +40,6 @@ import org.sonar.api.utils.text.JsonWriter;
 import org.sonar.api.web.UserRole;
 import org.sonar.core.component.ComponentDto;
 import org.sonar.core.issue.workflow.Transition;
-import org.sonar.core.technicaldebt.DefaultTechnicalDebtManager;
 import org.sonar.markdown.Markdown;
 import org.sonar.server.exceptions.NotFoundException;
 import org.sonar.server.issue.ActionService;
@@ -63,17 +63,17 @@ public class IssueShowWsHandler implements RequestHandler {
   private final IssueService issueService;
   private final IssueChangelogService issueChangelogService;
   private final ActionService actionService;
-  private final DefaultTechnicalDebtManager technicalDebtManager;
+  private final DebtModel debtModel;
   private final I18n i18n;
   private final Durations durations;
 
   public IssueShowWsHandler(IssueFinder issueFinder, IssueService issueService, IssueChangelogService issueChangelogService, ActionService actionService,
-                            DefaultTechnicalDebtManager technicalDebtManager, I18n i18n, Durations durations) {
+                            DebtModel debtModel, I18n i18n, Durations durations) {
     this.issueFinder = issueFinder;
     this.issueService = issueService;
     this.issueChangelogService = issueChangelogService;
     this.actionService = actionService;
-    this.technicalDebtManager = technicalDebtManager;
+    this.debtModel = debtModel;
     this.i18n = i18n;
     this.durations = durations;
   }
@@ -190,18 +190,18 @@ public class IssueShowWsHandler implements RequestHandler {
 
   private void addCharacteristics(IssueQueryResult result, DefaultIssue issue, JsonWriter json) {
     Integer subCharacteristicId = result.rule(issue).getCharacteristicId() != null ? result.rule(issue).getCharacteristicId() : result.rule(issue).getDefaultCharacteristicId();
-    Characteristic subCharacteristic = findCharacteristicById(subCharacteristicId);
+    DebtCharacteristic subCharacteristic = characteristicById(subCharacteristicId);
     if (subCharacteristic != null) {
       json.prop("subCharacteristic", subCharacteristic.name());
-      Characteristic characteristic = findCharacteristicById(subCharacteristic.parentId());
+      DebtCharacteristic characteristic = characteristicById(subCharacteristic.parentId());
       json.prop("characteristic", characteristic != null ? characteristic.name() : null);
     }
   }
 
   @CheckForNull
-  private Characteristic findCharacteristicById(@Nullable Integer id) {
+  private DebtCharacteristic characteristicById(@Nullable Integer id) {
     if (id != null) {
-      return technicalDebtManager.findCharacteristicById(id);
+      return debtModel.characteristicById(id);
     }
     return null;
   }
index 4b208704a7ea82055ebd31d30d6fd6ab8aed1ae7..87e242e4ae27b402f6223721d4d1ff4ca9747091 100644 (file)
@@ -52,13 +52,7 @@ import org.sonar.core.measure.MeasureFilterFactory;
 import org.sonar.core.metric.DefaultMetricFinder;
 import org.sonar.core.notification.DefaultNotificationManager;
 import org.sonar.core.permission.PermissionFacade;
-import org.sonar.core.persistence.DaoUtils;
-import org.sonar.core.persistence.DatabaseVersion;
-import org.sonar.core.persistence.DefaultDatabase;
-import org.sonar.core.persistence.MyBatis;
-import org.sonar.core.persistence.PreviewDatabaseFactory;
-import org.sonar.core.persistence.SemaphoreUpdater;
-import org.sonar.core.persistence.SemaphoresImpl;
+import org.sonar.core.persistence.*;
 import org.sonar.core.preview.PreviewCache;
 import org.sonar.core.profiling.Profiling;
 import org.sonar.core.purge.PurgeProfiler;
@@ -67,7 +61,6 @@ import org.sonar.core.qualitygate.db.QualityGateConditionDao;
 import org.sonar.core.qualitygate.db.QualityGateDao;
 import org.sonar.core.resource.DefaultResourcePermissions;
 import org.sonar.core.rule.DefaultRuleFinder;
-import org.sonar.core.technicaldebt.DefaultTechnicalDebtManager;
 import org.sonar.core.technicaldebt.TechnicalDebtModelRepository;
 import org.sonar.core.technicaldebt.TechnicalDebtModelSynchronizer;
 import org.sonar.core.technicaldebt.TechnicalDebtXMLImporter;
@@ -90,28 +83,12 @@ import org.sonar.server.db.EmbeddedDatabaseFactory;
 import org.sonar.server.db.migrations.DatabaseMigrations;
 import org.sonar.server.db.migrations.DatabaseMigrator;
 import org.sonar.server.debt.DebtCharacteristicsXMLImporter;
+import org.sonar.server.debt.DebtModelService;
 import org.sonar.server.debt.DebtModelSynchronizer;
 import org.sonar.server.debt.DebtRulesXMLImporter;
-import org.sonar.server.debt.DebtService;
 import org.sonar.server.es.ESIndex;
 import org.sonar.server.es.ESNode;
-import org.sonar.server.issue.ActionPlanService;
-import org.sonar.server.issue.ActionService;
-import org.sonar.server.issue.AssignAction;
-import org.sonar.server.issue.CommentAction;
-import org.sonar.server.issue.DefaultIssueFinder;
-import org.sonar.server.issue.InternalRubyIssueService;
-import org.sonar.server.issue.IssueBulkChangeService;
-import org.sonar.server.issue.IssueChangelogFormatter;
-import org.sonar.server.issue.IssueChangelogService;
-import org.sonar.server.issue.IssueCommentService;
-import org.sonar.server.issue.IssueService;
-import org.sonar.server.issue.IssueStatsFinder;
-import org.sonar.server.issue.PlanAction;
-import org.sonar.server.issue.PublicRubyIssueService;
-import org.sonar.server.issue.ServerIssueStorage;
-import org.sonar.server.issue.SetSeverityAction;
-import org.sonar.server.issue.TransitionAction;
+import org.sonar.server.issue.*;
 import org.sonar.server.issue.filter.IssueFilterService;
 import org.sonar.server.issue.filter.IssueFilterWs;
 import org.sonar.server.issue.ws.IssueShowWsHandler;
@@ -123,87 +100,29 @@ import org.sonar.server.permission.InternalPermissionTemplateService;
 import org.sonar.server.permission.PermissionFinder;
 import org.sonar.server.platform.ws.PlatformWs;
 import org.sonar.server.platform.ws.RestartHandler;
-import org.sonar.server.plugins.InstalledPluginReferentialFactory;
-import org.sonar.server.plugins.PluginDownloader;
-import org.sonar.server.plugins.ServerExtensionInstaller;
-import org.sonar.server.plugins.ServerPluginJarInstaller;
-import org.sonar.server.plugins.ServerPluginJarsInstaller;
-import org.sonar.server.plugins.ServerPluginRepository;
-import org.sonar.server.plugins.UpdateCenterClient;
-import org.sonar.server.plugins.UpdateCenterMatrixFactory;
+import org.sonar.server.plugins.*;
 import org.sonar.server.qualitygate.QgateProjectFinder;
 import org.sonar.server.qualitygate.QualityGates;
 import org.sonar.server.qualitygate.ws.QgateAppHandler;
 import org.sonar.server.qualitygate.ws.QualityGatesWs;
-import org.sonar.server.qualityprofile.ESActiveRule;
-import org.sonar.server.qualityprofile.ProfilesManager;
-import org.sonar.server.qualityprofile.QProfileActiveRuleOperations;
-import org.sonar.server.qualityprofile.QProfileBackup;
-import org.sonar.server.qualityprofile.QProfileLookup;
-import org.sonar.server.qualityprofile.QProfileOperations;
-import org.sonar.server.qualityprofile.QProfileProjectLookup;
-import org.sonar.server.qualityprofile.QProfileProjectOperations;
-import org.sonar.server.qualityprofile.QProfileRepositoryExporter;
-import org.sonar.server.qualityprofile.QProfileRuleLookup;
-import org.sonar.server.qualityprofile.QProfiles;
-import org.sonar.server.rule.DeprecatedRulesDefinition;
-import org.sonar.server.rule.ESRuleTags;
-import org.sonar.server.rule.RubyRuleService;
-import org.sonar.server.rule.RuleDefinitionsLoader;
-import org.sonar.server.rule.RuleOperations;
-import org.sonar.server.rule.RuleRegistration;
-import org.sonar.server.rule.RuleRegistry;
-import org.sonar.server.rule.RuleRepositories;
-import org.sonar.server.rule.RuleTagLookup;
-import org.sonar.server.rule.RuleTagOperations;
-import org.sonar.server.rule.RuleTags;
-import org.sonar.server.rule.Rules;
-import org.sonar.server.rule.ws.AddTagsWsHandler;
-import org.sonar.server.rule.ws.RemoveTagsWsHandler;
-import org.sonar.server.rule.ws.RuleSearchWsHandler;
-import org.sonar.server.rule.ws.RuleShowWsHandler;
-import org.sonar.server.rule.ws.RuleTagsWs;
-import org.sonar.server.rule.ws.RulesWs;
+import org.sonar.server.qualityprofile.*;
+import org.sonar.server.rule.*;
+import org.sonar.server.rule.ws.*;
 import org.sonar.server.source.CodeColorizers;
 import org.sonar.server.source.DeprecatedSourceDecorator;
 import org.sonar.server.source.HtmlSourceDecorator;
 import org.sonar.server.source.SourceService;
 import org.sonar.server.source.ws.SourcesShowWsHandler;
 import org.sonar.server.source.ws.SourcesWs;
-import org.sonar.server.startup.CleanPreviewAnalysisCache;
-import org.sonar.server.startup.CopyRequirementsFromCharacteristicsToRules;
-import org.sonar.server.startup.GenerateBootstrapIndex;
-import org.sonar.server.startup.GeneratePluginIndex;
-import org.sonar.server.startup.GwtPublisher;
-import org.sonar.server.startup.JdbcDriverDeployer;
-import org.sonar.server.startup.LogServerId;
-import org.sonar.server.startup.RegisterDebtModel;
-import org.sonar.server.startup.RegisterMetrics;
-import org.sonar.server.startup.RegisterNewDashboards;
-import org.sonar.server.startup.RegisterNewMeasureFilters;
-import org.sonar.server.startup.RegisterNewProfiles;
-import org.sonar.server.startup.RegisterPermissionTemplates;
-import org.sonar.server.startup.RegisterServletFilters;
-import org.sonar.server.startup.RenameDeprecatedPropertyKeys;
-import org.sonar.server.startup.ServerMetadataPersister;
+import org.sonar.server.startup.*;
 import org.sonar.server.text.MacroInterpreter;
 import org.sonar.server.text.RubyTextService;
 import org.sonar.server.ui.JRubyI18n;
 import org.sonar.server.ui.JRubyProfiling;
 import org.sonar.server.ui.PageDecorations;
 import org.sonar.server.ui.Views;
-import org.sonar.server.user.DefaultUserService;
-import org.sonar.server.user.GroupMembershipFinder;
-import org.sonar.server.user.GroupMembershipService;
-import org.sonar.server.user.NewUserNotifier;
-import org.sonar.server.user.SecurityRealmFactory;
-import org.sonar.server.util.BooleanTypeValidation;
-import org.sonar.server.util.FloatTypeValidation;
-import org.sonar.server.util.IntegerTypeValidation;
-import org.sonar.server.util.StringListTypeValidation;
-import org.sonar.server.util.StringTypeValidation;
-import org.sonar.server.util.TextTypeValidation;
-import org.sonar.server.util.TypeValidations;
+import org.sonar.server.user.*;
+import org.sonar.server.util.*;
 import org.sonar.server.ws.ListingWs;
 import org.sonar.server.ws.WebServiceEngine;
 
@@ -428,14 +347,13 @@ class ServerComponents {
     pico.addSingleton(TransitionAction.class);
 
     // technical debt
-    pico.addSingleton(DebtService.class);
+    pico.addSingleton(DebtModelService.class);
     pico.addSingleton(TechnicalDebtModelSynchronizer.class);
     pico.addSingleton(DebtModelSynchronizer.class);
     pico.addSingleton(TechnicalDebtModelRepository.class);
     pico.addSingleton(TechnicalDebtXMLImporter.class);
     pico.addSingleton(DebtRulesXMLImporter.class);
     pico.addSingleton(DebtCharacteristicsXMLImporter.class);
-    pico.addSingleton(DefaultTechnicalDebtManager.class);
 
     // source
     pico.addSingleton(HtmlSourceDecorator.class);
index 2df6b11d23dc4cd6b5e64974a6356be9be7e9150..43542de752048f66b038af6f6b6252b3e94da8c3 100644 (file)
@@ -189,8 +189,8 @@ class IssueController < ApplicationController
     @rule = Rule.first(:conditions => ['plugin_name=? and plugin_rule_key=?', rule_key[0], rule_key[1]])
     characteristic_id = @rule.characteristic_id || @rule.default_characteristic_id
     if characteristic_id
-      @characteristic = Internal.debt.findCharacteristic(characteristic_id)
-      @root_characteristic = Internal.debt.findCharacteristic(@characteristic.parentId())
+      @characteristic = Internal.debt.characteristicById(characteristic_id)
+      @root_characteristic = Internal.debt.characteristicById(@characteristic.parentId())
     end
     render :partial => 'issue/rule'
   end
index 154934351260d216c677ee616daeb020a5a00c77..ae569edb0c18d3b26d3ddb97c8fd616535932686 100644 (file)
@@ -55,7 +55,7 @@ class Internal
   end
 
   def self.debt
-    component(Java::OrgSonarServerDebt::DebtService.java_class)
+    component(Java::OrgSonarServerDebt::DebtModelService.java_class)
   end
 
   def self.profiling
diff --git a/sonar-server/src/test/java/org/sonar/server/debt/DebtModelServiceTest.java b/sonar-server/src/test/java/org/sonar/server/debt/DebtModelServiceTest.java
new file mode 100644 (file)
index 0000000..8a59e05
--- /dev/null
@@ -0,0 +1,88 @@
+/*
+ * 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.debt;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.runners.MockitoJUnitRunner;
+import org.sonar.api.server.debt.DebtCharacteristic;
+import org.sonar.core.technicaldebt.db.CharacteristicDao;
+import org.sonar.core.technicaldebt.db.CharacteristicDto;
+
+import static com.google.common.collect.Lists.newArrayList;
+import static org.fest.assertions.Assertions.assertThat;
+import static org.mockito.Mockito.when;
+
+@RunWith(MockitoJUnitRunner.class)
+public class DebtModelServiceTest {
+
+  @Mock
+  CharacteristicDao dao;
+
+  DebtModelService service;
+
+  @Before
+  public void setUp() throws Exception {
+    service = new DebtModelService(dao);
+  }
+
+  @Test
+  public void find_root_characteristics() {
+    CharacteristicDto dto = new CharacteristicDto()
+      .setId(1)
+      .setKey("MEMORY_EFFICIENCY")
+      .setName("Memory use");
+    when(dao.selectEnabledRootCharacteristics()).thenReturn(newArrayList(dto));
+    assertThat(service.rootCharacteristics()).hasSize(1);
+  }
+
+  @Test
+  public void find_characteristics() {
+    CharacteristicDto dto = new CharacteristicDto()
+      .setId(1)
+      .setKey("MEMORY_EFFICIENCY")
+      .setName("Memory use");
+    when(dao.selectEnabledCharacteristics()).thenReturn(newArrayList(dto));
+    assertThat(service.characteristics()).hasSize(1);
+  }
+
+  @Test
+  public void find_characteristic_by_id() {
+    CharacteristicDto dto = new CharacteristicDto()
+      .setId(1)
+      .setKey("MEMORY_EFFICIENCY")
+      .setName("Memory use")
+      .setParentId(2)
+      .setOrder(1);
+    when(dao.selectById(1)).thenReturn(dto);
+
+    DebtCharacteristic characteristic = service.characteristicById(1);
+    assertThat(characteristic.id()).isEqualTo(1);
+    assertThat(characteristic.key()).isEqualTo("MEMORY_EFFICIENCY");
+    assertThat(characteristic.name()).isEqualTo("Memory use");
+    assertThat(characteristic.parentId()).isEqualTo(2);
+    assertThat(characteristic.order()).isEqualTo(1);
+
+    assertThat(service.characteristicById(10)).isNull();
+  }
+
+}
diff --git a/sonar-server/src/test/java/org/sonar/server/debt/DebtServiceTest.java b/sonar-server/src/test/java/org/sonar/server/debt/DebtServiceTest.java
deleted file mode 100644 (file)
index d9c3070..0000000
+++ /dev/null
@@ -1,65 +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.debt;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.sonar.api.technicaldebt.server.Characteristic;
-import org.sonar.api.technicaldebt.server.internal.DefaultCharacteristic;
-import org.sonar.core.technicaldebt.DefaultTechnicalDebtManager;
-
-import java.util.List;
-
-import static com.google.common.collect.Lists.newArrayList;
-import static org.fest.assertions.Assertions.assertThat;
-import static org.mockito.Mockito.*;
-
-public class DebtServiceTest {
-
-  DefaultTechnicalDebtManager finder = mock(DefaultTechnicalDebtManager.class);
-
-  DebtService service;
-
-  @Before
-  public void setUp() throws Exception {
-    service = new DebtService(finder);
-  }
-
-  @Test
-  public void find_root_characteristics() {
-    List<Characteristic> rootCharacteristics = newArrayList();
-    when(finder.findRootCharacteristics()).thenReturn(rootCharacteristics);
-    assertThat(service.findRootCharacteristics()).isEqualTo(rootCharacteristics);
-  }
-
-  @Test
-  public void find_requirement_by_rule_id() {
-    service.findRequirementByRuleId(1);
-    verify(finder).findRequirementByRuleId(1);
-  }
-
-  @Test
-  public void find_characteristic() {
-    Characteristic characteristic = new DefaultCharacteristic();
-    when(finder.findCharacteristicById(1)).thenReturn(characteristic);
-    assertThat(service.findCharacteristic(1)).isEqualTo(characteristic);
-  }
-
-}
index b27ded9403b7eced401cfae55d55c5f8c68de8dc..1624b8704f0bc71f5cb1f9c4b18c5252c32091d4 100644 (file)
@@ -37,8 +37,9 @@ import org.sonar.api.issue.internal.DefaultIssueComment;
 import org.sonar.api.issue.internal.FieldDiffs;
 import org.sonar.api.rule.RuleKey;
 import org.sonar.api.rules.Rule;
+import org.sonar.api.server.debt.DebtModel;
+import org.sonar.api.server.debt.internal.DefaultDebtCharacteristic;
 import org.sonar.api.server.ws.WsTester;
-import org.sonar.api.technicaldebt.server.internal.DefaultCharacteristic;
 import org.sonar.api.user.User;
 import org.sonar.api.utils.DateUtils;
 import org.sonar.api.utils.Duration;
@@ -48,7 +49,6 @@ import org.sonar.core.component.ComponentDto;
 import org.sonar.core.issue.DefaultActionPlan;
 import org.sonar.core.issue.DefaultIssueQueryResult;
 import org.sonar.core.issue.workflow.Transition;
-import org.sonar.core.technicaldebt.DefaultTechnicalDebtManager;
 import org.sonar.core.user.DefaultUser;
 import org.sonar.server.issue.ActionService;
 import org.sonar.server.issue.IssueChangelog;
@@ -84,7 +84,7 @@ public class IssueShowWsHandlerTest {
   ActionService actionService;
 
   @Mock
-  DefaultTechnicalDebtManager technicalDebtManager;
+  DebtModel debtModel;
 
   @Mock
   I18n i18n;
@@ -113,7 +113,7 @@ public class IssueShowWsHandlerTest {
 
     when(i18n.message(any(Locale.class), eq("created"), eq((String) null))).thenReturn("Created");
 
-    tester = new WsTester(new IssuesWs(new IssueShowWsHandler(issueFinder, issueService, issueChangelogService, actionService, technicalDebtManager, i18n, durations)));
+    tester = new WsTester(new IssuesWs(new IssueShowWsHandler(issueFinder, issueService, issueChangelogService, actionService, debtModel, i18n, durations)));
   }
 
   @Test
@@ -323,8 +323,8 @@ public class IssueShowWsHandlerTest {
     issues.add(issue);
 
     result.rule(issue).setCharacteristicId(2);
-    when(technicalDebtManager.findCharacteristicById(1)).thenReturn(new DefaultCharacteristic().setId(1).setName("Maintainability"));
-    when(technicalDebtManager.findCharacteristicById(2)).thenReturn(new DefaultCharacteristic().setId(2).setName("Readability").setParentId(1));
+    when(debtModel.characteristicById(1)).thenReturn(new DefaultDebtCharacteristic().setId(1).setName("Maintainability"));
+    when(debtModel.characteristicById(2)).thenReturn(new DefaultDebtCharacteristic().setId(2).setName("Readability").setParentId(1));
 
     MockUserSession.set();
     WsTester.TestRequest request = tester.newRequest("show").setParam("key", issue.key());
@@ -337,8 +337,8 @@ public class IssueShowWsHandlerTest {
     issues.add(issue);
 
     result.rule(issue).setDefaultCharacteristicId(2);
-    when(technicalDebtManager.findCharacteristicById(1)).thenReturn(new DefaultCharacteristic().setId(1).setName("Maintainability"));
-    when(technicalDebtManager.findCharacteristicById(2)).thenReturn(new DefaultCharacteristic().setId(2).setName("Readability").setParentId(1));
+    when(debtModel.characteristicById(1)).thenReturn(new DefaultDebtCharacteristic().setId(1).setName("Maintainability"));
+    when(debtModel.characteristicById(2)).thenReturn(new DefaultDebtCharacteristic().setId(2).setName("Readability").setParentId(1));
 
     MockUserSession.set();
     WsTester.TestRequest request = tester.newRequest("show").setParam("key", issue.key());
@@ -351,12 +351,12 @@ public class IssueShowWsHandlerTest {
     issues.add(issue);
 
     result.rule(issue).setCharacteristicId(2);
-    when(technicalDebtManager.findCharacteristicById(1)).thenReturn(new DefaultCharacteristic().setId(1).setName("Maintainability"));
-    when(technicalDebtManager.findCharacteristicById(2)).thenReturn(new DefaultCharacteristic().setId(2).setName("Readability").setParentId(1));
+    when(debtModel.characteristicById(1)).thenReturn(new DefaultDebtCharacteristic().setId(1).setName("Maintainability"));
+    when(debtModel.characteristicById(2)).thenReturn(new DefaultDebtCharacteristic().setId(2).setName("Readability").setParentId(1));
 
     result.rule(issue).setDefaultCharacteristicId(20);
-    when(technicalDebtManager.findCharacteristicById(10)).thenReturn(new DefaultCharacteristic().setId(10).setName("Default Maintainability"));
-    when(technicalDebtManager.findCharacteristicById(20)).thenReturn(new DefaultCharacteristic().setId(20).setName("Default Readability").setParentId(10));
+    when(debtModel.characteristicById(10)).thenReturn(new DefaultDebtCharacteristic().setId(10).setName("Default Maintainability"));
+    when(debtModel.characteristicById(20)).thenReturn(new DefaultDebtCharacteristic().setId(20).setName("Default Readability").setParentId(10));
 
     MockUserSession.set();
     WsTester.TestRequest request = tester.newRequest("show").setParam("key", issue.key());