diff options
author | Julien Lancelot <julien.lancelot@sonarsource.com> | 2015-10-30 17:37:53 +0100 |
---|---|---|
committer | Julien Lancelot <julien.lancelot@sonarsource.com> | 2015-11-03 14:20:31 +0100 |
commit | a4aa639521c90b245e557c9030d34cfefd9f2eb6 (patch) | |
tree | 5d96d62e4fbb0ed3edf1cde4f3839c5de2a792c0 | |
parent | 208cbcc4b057f00bb0f694a5500605a5f1874120 (diff) | |
download | sonarqube-a4aa639521c90b245e557c9030d34cfefd9f2eb6.tar.gz sonarqube-a4aa639521c90b245e557c9030d34cfefd9f2eb6.zip |
Move debt ITs
22 files changed, 1327 insertions, 1 deletions
diff --git a/it/it-tests/src/test/java/it/Category2Suite.java b/it/it-tests/src/test/java/it/Category2Suite.java index 7a6a4d8f72b..eebf264646a 100644 --- a/it/it-tests/src/test/java/it/Category2Suite.java +++ b/it/it-tests/src/test/java/it/Category2Suite.java @@ -40,6 +40,12 @@ package it;/* import com.sonar.orchestrator.Orchestrator; import it.customMeasure.CustomMeasuresTest; +import it.debt.SqaleRatingMeasureTest; +import it.debt.TechnicalDebtInIssueChangelogTest; +import it.debt.TechnicalDebtMeasureTest; +import it.debt.TechnicalDebtPurgeTest; +import it.debt.TechnicalDebtTest; +import it.debt.TechnicalDebtWidgetTest; import it.issue.CommonRulesTest; import it.issue.CustomRulesTest; import it.issue.IssueActionTest; @@ -87,7 +93,14 @@ import static util.ItUtils.xooPlugin; IssuePurgeTest.class, IssueWorkflowTest.class, ManualRulesTest.class, - NewIssuesMeasureTest.class + NewIssuesMeasureTest.class, + // debt + SqaleRatingMeasureTest.class, + TechnicalDebtInIssueChangelogTest.class, + TechnicalDebtMeasureTest.class, + TechnicalDebtPurgeTest.class, + TechnicalDebtTest.class, + TechnicalDebtWidgetTest.class }) public class Category2Suite { diff --git a/it/it-tests/src/test/java/it/debt/SqaleRatingMeasureTest.java b/it/it-tests/src/test/java/it/debt/SqaleRatingMeasureTest.java new file mode 100644 index 00000000000..da898fe4125 --- /dev/null +++ b/it/it-tests/src/test/java/it/debt/SqaleRatingMeasureTest.java @@ -0,0 +1,183 @@ +/* + * 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 it.debt; + +import com.google.common.collect.ImmutableSet; +import com.sonar.orchestrator.Orchestrator; +import com.sonar.orchestrator.build.SonarRunner; +import com.sonar.orchestrator.locator.FileLocation; +import it.Category2Suite; +import org.junit.AfterClass; +import org.junit.Before; +import org.junit.ClassRule; +import org.junit.Test; +import org.sonar.wsclient.services.Measure; +import org.sonar.wsclient.services.Resource; +import org.sonar.wsclient.services.ResourceQuery; + +import static org.assertj.core.api.Assertions.assertThat; +import static util.ItUtils.projectDir; +import static util.ItUtils.setServerProperty; + +/** + * SONAR-4715 + */ +public class SqaleRatingMeasureTest { + + private static final String PROJECT = "com.sonarsource.it.samples:multi-modules-sample"; + private static final String MODULE = "com.sonarsource.it.samples:multi-modules-sample:module_a"; + private static final String SUB_MODULE = "com.sonarsource.it.samples:multi-modules-sample:module_a:module_a1"; + private static final String DIRECTORY = "com.sonarsource.it.samples:multi-modules-sample:module_a:module_a1:src/main/xoo/com/sonar/it/samples/modules/a1"; + private static final String FILE = "com.sonarsource.it.samples:multi-modules-sample:module_a:module_a1:src/main/xoo/com/sonar/it/samples/modules/a1/HelloA1.xoo"; + @ClassRule + public static Orchestrator orchestrator = Category2Suite.ORCHESTRATOR; + + private static void resetDevelopmentCost() { + for (String property : ImmutableSet.of("sonar.technicalDebt.developmentCost", "sonar.technicalDebt.sizeMetric", + "languageSpecificParameters", "languageSpecificParameters.0.language", "languageSpecificParameters.0.man_days", "languageSpecificParameters.0.size_metric", + "ratingGrid")) { + setServerProperty(orchestrator, property, null); + } + } + + @AfterClass + public static void reset() { + resetDevelopmentCost(); + } + + @Before + public void init() { + resetDevelopmentCost(); + orchestrator.resetData(); + } + + @Test + public void sqale_rating_measures() { + orchestrator.getServer().restoreProfile(FileLocation.ofClasspath("/debt/with-many-rules.xml")); + orchestrator.getServer().provisionProject(PROJECT, PROJECT); + orchestrator.getServer().associateProjectToQualityProfile(PROJECT, "xoo", "with-many-rules"); + + orchestrator.executeBuild(SonarRunner.create(projectDir("shared/xoo-multi-modules-sample"))); + + assertThat(getMeasure(PROJECT, "sqale_rating").getIntValue()).isEqualTo(3); + assertThat(getMeasure(PROJECT, "sqale_rating").getData()).isEqualTo("C"); + + assertThat(getMeasure(MODULE, "sqale_rating").getIntValue()).isEqualTo(3); + assertThat(getMeasure(MODULE, "sqale_rating").getData()).isEqualTo("C"); + + assertThat(getMeasure(SUB_MODULE, "sqale_rating").getIntValue()).isEqualTo(3); + assertThat(getMeasure(SUB_MODULE, "sqale_rating").getData()).isEqualTo("C"); + + assertThat(getMeasure(DIRECTORY, "sqale_rating").getIntValue()).isEqualTo(1); + assertThat(getMeasure(DIRECTORY, "sqale_rating").getData()).isEqualTo("A"); + + assertThat(getMeasure(FILE, "sqale_rating").getIntValue()).isEqualTo(1); + assertThat(getMeasure(FILE, "sqale_rating").getData()).isEqualTo("A"); + } + + @Test + public void sqale_debt_ratio_measures() { + orchestrator.getServer().restoreProfile(FileLocation.ofClasspath("/debt/with-many-rules.xml")); + orchestrator.getServer().provisionProject(PROJECT, PROJECT); + orchestrator.getServer().associateProjectToQualityProfile(PROJECT, "xoo", "with-many-rules"); + + orchestrator.executeBuild(SonarRunner.create(projectDir("shared/xoo-multi-modules-sample"))); + + assertThat(getMeasure(PROJECT, "sqale_debt_ratio").getValue()).isEqualTo(29.1d); + assertThat(getMeasure(MODULE, "sqale_debt_ratio").getValue()).isEqualTo(28.5d); + assertThat(getMeasure(SUB_MODULE, "sqale_debt_ratio").getValue()).isEqualTo(31.4d); + assertThat(getMeasure(DIRECTORY, "sqale_debt_ratio").getValue()).isEqualTo(7.8d); + assertThat(getMeasure(FILE, "sqale_debt_ratio").getValue()).isEqualTo(7.8d); + } + + @Test + public void use_development_cost_parameter() throws Exception { + orchestrator.getServer().restoreProfile(FileLocation.ofClasspath("/debt/one-issue-per-line.xml")); + orchestrator.getServer().provisionProject("sample", "sample"); + orchestrator.getServer().associateProjectToQualityProfile("sample", "xoo", "one-issue-per-line"); + + orchestrator.executeBuild(SonarRunner.create(projectDir("shared/xoo-sample"))); + + Measure rating = getMeasure("sample", "sqale_rating"); + assertThat(rating.getIntValue()).isEqualTo(1); + assertThat(rating.getData()).isEqualTo("A"); + + setServerProperty(orchestrator, "sonar.technicalDebt.developmentCost", "2"); + orchestrator.executeBuild(SonarRunner.create(projectDir("shared/xoo-sample"))); + + rating = getMeasure("sample", "sqale_rating"); + assertThat(rating.getIntValue()).isEqualTo(4); + assertThat(rating.getData()).isEqualTo("D"); + } + + @Test + public void use_language_specific_parameters() throws Exception { + orchestrator.getServer().restoreProfile(FileLocation.ofClasspath("/debt/one-issue-per-line.xml")); + orchestrator.getServer().provisionProject(PROJECT, PROJECT); + orchestrator.getServer().associateProjectToQualityProfile(PROJECT, "xoo", "one-issue-per-line"); + + orchestrator.executeBuild(SonarRunner.create(projectDir("shared/xoo-multi-modules-sample"))); + + Measure rating = getMeasure(PROJECT, "sqale_rating"); + assertThat(rating.getIntValue()).isEqualTo(1); + assertThat(rating.getData()).isEqualTo("A"); + + setServerProperty(orchestrator, "languageSpecificParameters", "0"); + setServerProperty(orchestrator, "languageSpecificParameters.0.language", "xoo"); + setServerProperty(orchestrator, "languageSpecificParameters.0.man_days", "1"); + setServerProperty(orchestrator, "languageSpecificParameters.0.size_metric", "ncloc"); + orchestrator.executeBuild( + SonarRunner.create(projectDir("shared/xoo-multi-modules-sample")) + .setProfile("one-issue-per-line")); + + rating = getMeasure(PROJECT, "sqale_rating"); + assertThat(rating.getIntValue()).isEqualTo(5); + assertThat(rating.getData()).isEqualTo("E"); + } + + @Test + public void use_rating_grid_parameter() throws Exception { + orchestrator.getServer().restoreProfile(FileLocation.ofClasspath("/debt/one-issue-per-line.xml")); + orchestrator.getServer().provisionProject("sample", "sample"); + orchestrator.getServer().associateProjectToQualityProfile("sample", "xoo", "one-issue-per-line"); + + orchestrator.executeBuild(SonarRunner.create(projectDir("shared/xoo-sample"))); + + Measure rating = getMeasure("sample", "sqale_rating"); + assertThat(rating.getIntValue()).isEqualTo(1); + assertThat(rating.getData()).isEqualTo("A"); + + setServerProperty(orchestrator, "ratingGrid", "0.001,0.005,0.010,0.015"); + orchestrator.executeBuild(SonarRunner.create(projectDir("shared/xoo-sample"))); + + rating = getMeasure("sample", "sqale_rating"); + assertThat(rating.getIntValue()).isEqualTo(5); + assertThat(rating.getData()).isEqualTo("E"); + } + + private Measure getMeasure(String resource, String metricKey) { + Resource res = orchestrator.getServer().getWsClient().find(ResourceQuery.createForMetrics(resource, metricKey)); + if (res == null) { + return null; + } + return res.getMeasure(metricKey); + } + +} diff --git a/it/it-tests/src/test/java/it/debt/TechnicalDebtInIssueChangelogTest.java b/it/it-tests/src/test/java/it/debt/TechnicalDebtInIssueChangelogTest.java new file mode 100644 index 00000000000..30f1ebf6ab5 --- /dev/null +++ b/it/it-tests/src/test/java/it/debt/TechnicalDebtInIssueChangelogTest.java @@ -0,0 +1,120 @@ +/* + * 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 it.debt; + +import com.sonar.orchestrator.Orchestrator; +import com.sonar.orchestrator.build.SonarRunner; +import com.sonar.orchestrator.locator.FileLocation; +import it.Category2Suite; +import java.util.List; +import org.junit.AfterClass; +import org.junit.Before; +import org.junit.ClassRule; +import org.junit.Test; +import org.sonar.wsclient.issue.Issue; +import org.sonar.wsclient.issue.IssueChange; +import org.sonar.wsclient.issue.IssueChangeDiff; +import org.sonar.wsclient.issue.IssueClient; +import org.sonar.wsclient.issue.IssueQuery; + +import static org.assertj.core.api.Assertions.assertThat; +import static util.ItUtils.projectDir; +import static util.ItUtils.setServerProperty; + +/** + * SONAR-4834 + */ +public class TechnicalDebtInIssueChangelogTest { + + @ClassRule + public static Orchestrator orchestrator = Category2Suite.ORCHESTRATOR; + + @AfterClass + public static void resetHoursInDay() throws Exception { + setServerProperty(orchestrator, "sonar.technicalDebt.hoursInDay", null); + } + + @Before + public void deleteAnalysisData() { + orchestrator.resetData(); + + // Set hours in day property to 8 + setServerProperty(orchestrator, "sonar.technicalDebt.hoursInDay", "8"); + } + + @Test + public void display_debt_in_issue_changelog() throws Exception { + orchestrator.getServer().restoreProfile(FileLocation.ofClasspath("/debt/one-issue-per-file.xml")); + orchestrator.getServer().provisionProject("sample", "sample"); + orchestrator.getServer().associateProjectToQualityProfile("sample", "xoo", "one-issue-per-file"); + + // Execute a first analysis to have a past snapshot + orchestrator.executeBuild(SonarRunner.create(projectDir("shared/xoo-sample"))); + + // Second analysis, existing issues on OneIssuePerFile will have their technical debt updated with the effort to fix + orchestrator.executeBuild(SonarRunner.create(projectDir("shared/xoo-sample")) + .setProperties("sonar.oneIssuePerFile.effortToFix", "10")); + + IssueClient issueClient = orchestrator.getServer().wsClient().issueClient(); + Issue issue = issueClient.find(IssueQuery.create()).list().get(0); + List<IssueChange> changes = issueClient.changes(issue.key()); + + assertThat(changes).hasSize(1); + IssueChange change = changes.get(0); + + assertThat(change.diffs()).hasSize(1); + IssueChangeDiff changeDiff = change.diffs().get(0); + assertThat(changeDiff.key()).isEqualTo("technicalDebt"); + assertThat(changeDiff.oldValue()).isEqualTo("10min"); + assertThat(changeDiff.newValue()).isEqualTo("1h40min"); + } + + @Test + public void use_hours_in_day_property_to_display_debt_in_issue_changelog() throws Exception { + orchestrator.getServer().restoreProfile(FileLocation.ofClasspath("/debt/one-issue-per-file.xml")); + orchestrator.getServer().provisionProject("sample", "sample"); + orchestrator.getServer().associateProjectToQualityProfile("sample", "xoo", "one-issue-per-file"); + + // Execute a first analysis to have a past snapshot + orchestrator.executeBuild(SonarRunner.create(projectDir("shared/xoo-sample"))); + + // One day -> 10 hours + setServerProperty(orchestrator, "sonar.technicalDebt.hoursInDay", "10"); + + orchestrator.executeBuild(SonarRunner.create(projectDir("shared/xoo-sample")) + // As OneIssuePerFile has a debt of 10 minutes, we multiply it by 72 to have 1 day and 2 hours of technical debtn + .setProperties("sonar.oneIssuePerFile.effortToFix", "72") + ); + + IssueClient issueClient = orchestrator.getServer().wsClient().issueClient(); + Issue issue = issueClient.find(IssueQuery.create()).list().get(0); + List<IssueChange> changes = issueClient.changes(issue.key()); + + assertThat(changes).hasSize(1); + IssueChange change = changes.get(0); + + assertThat(change.diffs()).hasSize(1); + IssueChangeDiff changeDiff = change.diffs().get(0); + assertThat(changeDiff.key()).isEqualTo("technicalDebt"); + assertThat(changeDiff.oldValue()).isEqualTo("10min"); + assertThat(changeDiff.newValue()).isEqualTo("1d2h"); + } + +} diff --git a/it/it-tests/src/test/java/it/debt/TechnicalDebtMeasureTest.java b/it/it-tests/src/test/java/it/debt/TechnicalDebtMeasureTest.java new file mode 100644 index 00000000000..9f4b0bdcd61 --- /dev/null +++ b/it/it-tests/src/test/java/it/debt/TechnicalDebtMeasureTest.java @@ -0,0 +1,164 @@ +/* + * 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 it.debt; + +import com.sonar.orchestrator.Orchestrator; +import com.sonar.orchestrator.build.SonarRunner; +import com.sonar.orchestrator.locator.FileLocation; +import it.Category2Suite; +import org.junit.BeforeClass; +import org.junit.ClassRule; +import org.junit.Test; +import org.sonar.wsclient.services.Measure; +import org.sonar.wsclient.services.Resource; +import org.sonar.wsclient.services.ResourceQuery; + +import static org.assertj.core.api.Assertions.assertThat; +import static util.ItUtils.projectDir; + +/** + * SONAR-4715 + */ +public class TechnicalDebtMeasureTest { + + private static final String PROJECT = "com.sonarsource.it.samples:multi-modules-sample"; + private static final String MODULE = "com.sonarsource.it.samples:multi-modules-sample:module_a"; + private static final String SUB_MODULE = "com.sonarsource.it.samples:multi-modules-sample:module_a:module_a1"; + private static final String DIRECTORY = "com.sonarsource.it.samples:multi-modules-sample:module_a:module_a1:src/main/xoo/com/sonar/it/samples/modules/a1"; + private static final String FILE = "com.sonarsource.it.samples:multi-modules-sample:module_a:module_a1:src/main/xoo/com/sonar/it/samples/modules/a1/HelloA1.xoo"; + private static final String TECHNICAL_DEBT_MEASURE = "sqale_index"; + @ClassRule + public static Orchestrator orchestrator = Category2Suite.ORCHESTRATOR; + + @BeforeClass + public static void init() { + orchestrator.resetData(); + + orchestrator.getServer().restoreProfile(FileLocation.ofClasspath("/debt/with-many-rules.xml")); + orchestrator.getServer().provisionProject(PROJECT, PROJECT); + orchestrator.getServer().associateProjectToQualityProfile(PROJECT, "xoo", "with-many-rules"); + orchestrator.executeBuild(SonarRunner.create(projectDir("shared/xoo-multi-modules-sample"))); + } + + @Test + public void technical_debt_measures() { + assertThat(getMeasure(PROJECT, TECHNICAL_DEBT_MEASURE).getValue()).isEqualTo(445); + assertThat(getMeasure(MODULE, TECHNICAL_DEBT_MEASURE).getValue()).isEqualTo(231); + assertThat(getMeasure(SUB_MODULE, TECHNICAL_DEBT_MEASURE).getValue()).isEqualTo(113); + assertThat(getMeasure(DIRECTORY, TECHNICAL_DEBT_MEASURE).getValue()).isEqualTo(28); + assertThat(getMeasure(FILE, TECHNICAL_DEBT_MEASURE).getValue()).isEqualTo(28); + } + + @Test + public void technical_debt_measures_on_characteristics_on_project() { + assertThat(getCharacteristicMeasure(PROJECT, TECHNICAL_DEBT_MEASURE, "PORTABILITY").getValue()).isEqualTo(0); + assertThat(getCharacteristicMeasure(PROJECT, TECHNICAL_DEBT_MEASURE, "MAINTAINABILITY").getValue()).isEqualTo(4); + assertThat(getCharacteristicMeasure(PROJECT, TECHNICAL_DEBT_MEASURE, "SECURITY").getValue()).isEqualTo(340); + assertThat(getCharacteristicMeasure(PROJECT, TECHNICAL_DEBT_MEASURE, "EFFICIENCY").getValue()).isEqualTo(61); + assertThat(getCharacteristicMeasure(PROJECT, TECHNICAL_DEBT_MEASURE, "CHANGEABILITY").getValue()).isEqualTo(40); + assertThat(getCharacteristicMeasure(PROJECT, TECHNICAL_DEBT_MEASURE, "RELIABILITY").getValue()).isEqualTo(0); + assertThat(getCharacteristicMeasure(PROJECT, TECHNICAL_DEBT_MEASURE, "READABILITY").getValue()).isEqualTo(4); + assertThat(getCharacteristicMeasure(PROJECT, TECHNICAL_DEBT_MEASURE, "TESTABILITY").getValue()).isEqualTo(0); + assertThat(getCharacteristicMeasure(PROJECT, TECHNICAL_DEBT_MEASURE, "REUSABILITY").getValue()).isEqualTo(0); + + // sub characteristics + assertThat(getCharacteristicMeasure(PROJECT, TECHNICAL_DEBT_MEASURE, "API_ABUSE").getValue()).isEqualTo(340); + assertThat(getCharacteristicMeasure(PROJECT, TECHNICAL_DEBT_MEASURE, "ARCHITECTURE_CHANGEABILITY").getValue()).isEqualTo(40); + assertThat(getCharacteristicMeasure(PROJECT, TECHNICAL_DEBT_MEASURE, "MEMORY_EFFICIENCY").getValue()).isEqualTo(61); + } + + @Test + public void technical_debt_measures_on_characteristics_on_modules() { + assertThat(getCharacteristicMeasure(MODULE, TECHNICAL_DEBT_MEASURE, "MAINTAINABILITY").getValue()).isEqualTo(4); + assertThat(getCharacteristicMeasure(MODULE, TECHNICAL_DEBT_MEASURE, "PORTABILITY").getValue()).isEqualTo(0); + assertThat(getCharacteristicMeasure(MODULE, TECHNICAL_DEBT_MEASURE, "SECURITY").getValue()).isEqualTo(170); + assertThat(getCharacteristicMeasure(MODULE, TECHNICAL_DEBT_MEASURE, "EFFICIENCY").getValue()).isEqualTo(37); + assertThat(getCharacteristicMeasure(MODULE, TECHNICAL_DEBT_MEASURE, "CHANGEABILITY").getValue()).isEqualTo(20); + assertThat(getCharacteristicMeasure(MODULE, TECHNICAL_DEBT_MEASURE, "RELIABILITY").getValue()).isEqualTo(0); + assertThat(getCharacteristicMeasure(MODULE, TECHNICAL_DEBT_MEASURE, "READABILITY").getValue()).isEqualTo(4); + assertThat(getCharacteristicMeasure(MODULE, TECHNICAL_DEBT_MEASURE, "TESTABILITY").getValue()).isEqualTo(0); + assertThat(getCharacteristicMeasure(MODULE, TECHNICAL_DEBT_MEASURE, "REUSABILITY").getValue()).isEqualTo(0); + + // sub characteristics + assertThat(getCharacteristicMeasure(MODULE, TECHNICAL_DEBT_MEASURE, "API_ABUSE").getValue()).isEqualTo(170); + assertThat(getCharacteristicMeasure(MODULE, TECHNICAL_DEBT_MEASURE, "ARCHITECTURE_CHANGEABILITY").getValue()).isEqualTo(20); + assertThat(getCharacteristicMeasure(MODULE, TECHNICAL_DEBT_MEASURE, "MEMORY_EFFICIENCY").getValue()).isEqualTo(37); + } + + @Test + public void technical_debt_measures_on_characteristics_on_directory() { + assertThat(getCharacteristicMeasure(DIRECTORY, TECHNICAL_DEBT_MEASURE, "PORTABILITY")).isNull(); + assertThat(getCharacteristicMeasure(DIRECTORY, TECHNICAL_DEBT_MEASURE, "MAINTAINABILITY").getValue()).isEqualTo(2); + assertThat(getCharacteristicMeasure(DIRECTORY, TECHNICAL_DEBT_MEASURE, "SECURITY")).isNull(); + assertThat(getCharacteristicMeasure(DIRECTORY, TECHNICAL_DEBT_MEASURE, "EFFICIENCY").getValue()).isEqualTo(16); + assertThat(getCharacteristicMeasure(DIRECTORY, TECHNICAL_DEBT_MEASURE, "CHANGEABILITY").getValue()).isEqualTo(10); + assertThat(getCharacteristicMeasure(DIRECTORY, TECHNICAL_DEBT_MEASURE, "RELIABILITY")).isNull(); + assertThat(getCharacteristicMeasure(DIRECTORY, TECHNICAL_DEBT_MEASURE, "READABILITY").getValue()).isEqualTo(2); + assertThat(getCharacteristicMeasure(DIRECTORY, TECHNICAL_DEBT_MEASURE, "TESTABILITY")).isNull(); + assertThat(getCharacteristicMeasure(DIRECTORY, TECHNICAL_DEBT_MEASURE, "REUSABILITY")).isNull(); + + // sub characteristics + assertThat(getCharacteristicMeasure(DIRECTORY, TECHNICAL_DEBT_MEASURE, "API_ABUSE")).isNull(); + assertThat(getCharacteristicMeasure(DIRECTORY, TECHNICAL_DEBT_MEASURE, "ARCHITECTURE_CHANGEABILITY").getValue()).isEqualTo(10); + assertThat(getCharacteristicMeasure(DIRECTORY, TECHNICAL_DEBT_MEASURE, "MEMORY_EFFICIENCY").getValue()).isEqualTo(16); + } + + @Test + public void technical_debt_measures_on_characteristics_on_file() { + assertThat(getCharacteristicMeasure(FILE, TECHNICAL_DEBT_MEASURE, "PORTABILITY")).isNull(); + assertThat(getCharacteristicMeasure(FILE, TECHNICAL_DEBT_MEASURE, "MAINTAINABILITY").getValue()).isEqualTo(2); + assertThat(getCharacteristicMeasure(FILE, TECHNICAL_DEBT_MEASURE, "SECURITY")).isNull(); + assertThat(getCharacteristicMeasure(FILE, TECHNICAL_DEBT_MEASURE, "EFFICIENCY").getValue()).isEqualTo(16); + assertThat(getCharacteristicMeasure(FILE, TECHNICAL_DEBT_MEASURE, "CHANGEABILITY").getValue()).isEqualTo(10); + assertThat(getCharacteristicMeasure(FILE, TECHNICAL_DEBT_MEASURE, "RELIABILITY")).isNull(); + assertThat(getCharacteristicMeasure(FILE, TECHNICAL_DEBT_MEASURE, "READABILITY").getValue()).isEqualTo(2); + assertThat(getCharacteristicMeasure(FILE, TECHNICAL_DEBT_MEASURE, "TESTABILITY")).isNull(); + assertThat(getCharacteristicMeasure(FILE, TECHNICAL_DEBT_MEASURE, "REUSABILITY")).isNull(); + + // sub characteristics + assertThat(getCharacteristicMeasure(FILE, TECHNICAL_DEBT_MEASURE, "API_ABUSE")).isNull(); + assertThat(getCharacteristicMeasure(FILE, TECHNICAL_DEBT_MEASURE, "ARCHITECTURE_CHANGEABILITY").getValue()).isEqualTo(10); + assertThat(getCharacteristicMeasure(FILE, TECHNICAL_DEBT_MEASURE, "MEMORY_EFFICIENCY").getValue()).isEqualTo(16); + } + + @Test + public void not_save_zero_value_on_non_top_characteristics() throws Exception { + String sqlRequest = "SELECT count(*) FROM project_measures WHERE characteristic_id IN (select id from characteristics where parent_id IS NOT NULL) AND value = 0"; + assertThat(orchestrator.getDatabase().countSql(sqlRequest)).isEqualTo(0); + } + + private Measure getMeasure(String resource, String metricKey) { + Resource res = orchestrator.getServer().getWsClient().find(ResourceQuery.createForMetrics(resource, metricKey)); + if (res == null) { + return null; + } + return res.getMeasure(metricKey); + } + + private Measure getCharacteristicMeasure(String resource, String metricKey, String characteristicKey) { + Resource res = orchestrator.getServer().getWsClient().find( + ResourceQuery.createForMetrics(resource, metricKey).setCharacteristics(characteristicKey)); + if (res == null) { + return null; + } + return res.getMeasure(metricKey); + } + +} diff --git a/it/it-tests/src/test/java/it/debt/TechnicalDebtPurgeTest.java b/it/it-tests/src/test/java/it/debt/TechnicalDebtPurgeTest.java new file mode 100644 index 00000000000..d72246a3b2c --- /dev/null +++ b/it/it-tests/src/test/java/it/debt/TechnicalDebtPurgeTest.java @@ -0,0 +1,74 @@ +/* + * 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 it.debt; + +import com.sonar.orchestrator.Orchestrator; +import com.sonar.orchestrator.build.SonarRunner; +import com.sonar.orchestrator.locator.FileLocation; +import it.Category2Suite; +import java.sql.SQLException; +import org.junit.Before; +import org.junit.ClassRule; +import org.junit.Test; + +import static org.assertj.core.api.Assertions.assertThat; +import static util.ItUtils.projectDir; + +public class TechnicalDebtPurgeTest { + + private static final String SQL_COUNT_MEASURES_ON_CHARACTERISTICS = "select count(*) from project_measures where characteristic_id is not null"; + private static final String SQL_COUNT_MEASURES_ON_DEBT_MEASURES_WITH_RULES = "select count(*) from project_measures where rule_id is not null and metric_id in (select id from metrics where name='sqale_index')"; + @ClassRule + public static Orchestrator orchestrator = Category2Suite.ORCHESTRATOR; + + private static void scanProject(String date) { + SonarRunner scan = SonarRunner.create(projectDir("shared/xoo-multi-modules-sample")) + .setProperties("sonar.projectDate", date); + orchestrator.executeBuild(scan); + } + + @Before + public void resetData() throws Exception { + orchestrator.resetData(); + + orchestrator.getServer().restoreProfile(FileLocation.ofClasspath("/debt/with-many-rules.xml")); + orchestrator.getServer().provisionProject("com.sonarsource.it.samples:multi-modules-sample", "com.sonarsource.it.samples:multi-modules-sample"); + orchestrator.getServer().associateProjectToQualityProfile("com.sonarsource.it.samples:multi-modules-sample", "xoo", "with-many-rules"); + } + + /** + * SONAR-2756 + */ + @Test + public void purge_measures_on_requirements() throws SQLException { + scanProject("2012-01-01"); + int onCharacteristicsCount = orchestrator.getDatabase().countSql(SQL_COUNT_MEASURES_ON_CHARACTERISTICS); + int onRequirementsCount = orchestrator.getDatabase().countSql(SQL_COUNT_MEASURES_ON_DEBT_MEASURES_WITH_RULES); + assertThat(onCharacteristicsCount).isGreaterThan(0); + assertThat(onRequirementsCount).isGreaterThan(0); + + scanProject("2012-02-02"); + // past measures on characteristics are not purged + assertThat(orchestrator.getDatabase().countSql(SQL_COUNT_MEASURES_ON_CHARACTERISTICS)).isGreaterThan(onCharacteristicsCount); + + // past measures on debt with rules are purged + assertThat(orchestrator.getDatabase().countSql(SQL_COUNT_MEASURES_ON_DEBT_MEASURES_WITH_RULES)).isEqualTo(onRequirementsCount); + } +} diff --git a/it/it-tests/src/test/java/it/debt/TechnicalDebtTest.java b/it/it-tests/src/test/java/it/debt/TechnicalDebtTest.java new file mode 100644 index 00000000000..9522ee9458f --- /dev/null +++ b/it/it-tests/src/test/java/it/debt/TechnicalDebtTest.java @@ -0,0 +1,116 @@ +/* + * 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 it.debt; + +import com.sonar.orchestrator.Orchestrator; +import com.sonar.orchestrator.build.SonarRunner; +import com.sonar.orchestrator.locator.FileLocation; +import it.Category2Suite; +import java.util.List; +import org.junit.AfterClass; +import org.junit.Before; +import org.junit.ClassRule; +import org.junit.Test; +import org.sonar.wsclient.issue.Issue; +import org.sonar.wsclient.issue.IssueClient; +import org.sonar.wsclient.issue.IssueQuery; + +import static org.assertj.core.api.Assertions.assertThat; +import static util.ItUtils.projectDir; +import static util.ItUtils.setServerProperty; + +public class TechnicalDebtTest { + + @ClassRule + public static Orchestrator orchestrator = Category2Suite.ORCHESTRATOR; + + @AfterClass + public static void resetHoursInDay() throws Exception { + setServerProperty(orchestrator, "sonar.technicalDebt.hoursInDay", null); + } + + @Before + public void deleteAnalysisData() { + orchestrator.resetData(); + // Set hours in day property to 8 + setServerProperty(orchestrator, "sonar.technicalDebt.hoursInDay", "8"); + } + + /** + * SONAR-4716 + */ + @Test + public void technical_debt_on_issue() throws Exception { + orchestrator.getServer().restoreProfile(FileLocation.ofClasspath("/debt/one-issue-per-line.xml")); + orchestrator.getServer().provisionProject("sample", "sample"); + orchestrator.getServer().associateProjectToQualityProfile("sample", "xoo", "one-issue-per-line"); + + // Generate some issues + orchestrator.executeBuild(SonarRunner.create(projectDir("shared/xoo-sample"))); + + // All the issues should have a technical debt + List<Issue> issues = orchestrator.getServer().wsClient().issueClient().find(IssueQuery.create()).list(); + assertThat(issues).isNotEmpty(); + for (Issue issue : issues) { + assertThat(issue.debt()).isEqualTo("1min"); + } + } + + @Test + public void use_hours_in_day_property_to_display_debt() throws Exception { + orchestrator.getServer().restoreProfile(FileLocation.ofClasspath("/debt/one-issue-per-file.xml")); + orchestrator.getServer().provisionProject("sample", "sample"); + orchestrator.getServer().associateProjectToQualityProfile("sample", "xoo", "one-issue-per-file"); + + // One day -> 10 hours + setServerProperty(orchestrator, "sonar.technicalDebt.hoursInDay", "10"); + + orchestrator.executeBuild(SonarRunner.create(projectDir("shared/xoo-sample")) + // As OneIssuePerFile has a debt of 10 minutes, we multiply it by 72 to have 1 day and 2 hours of technical debt + .setProperties("sonar.oneIssuePerFile.effortToFix", "72") + ); + + IssueClient issueClient = orchestrator.getServer().wsClient().issueClient(); + Issue issue = issueClient.find(IssueQuery.create()).list().get(0); + + assertThat(issue.debt()).isEqualTo("1d2h"); + } + + @Test + public void use_hours_in_day_property_during_analysis_to_convert_debt() throws Exception { + orchestrator.getServer().restoreProfile(FileLocation.ofClasspath("/debt/one-day-debt-per-file.xml")); + orchestrator.getServer().provisionProject("sample", "sample"); + orchestrator.getServer().associateProjectToQualityProfile("sample", "xoo", "one-day-debt-per-file"); + + // One day -> 10 hours : debt will be stored as 360.000 seconds (1 day * 10 hours per day * 60 * 60) + setServerProperty(orchestrator, "sonar.technicalDebt.hoursInDay", "10"); + + orchestrator.executeBuild(SonarRunner.create(projectDir("shared/xoo-sample"))); + + // Issue debt was 1 day during analysis but will be displayed as 1 day and 2 hours (hours in day property was set + // to 10 during analysis but is now 8) + setServerProperty(orchestrator, "sonar.technicalDebt.hoursInDay", "8"); + + IssueClient issueClient = orchestrator.getServer().wsClient().issueClient(); + Issue issue = issueClient.find(IssueQuery.create()).list().get(0); + assertThat(issue.debt()).isEqualTo("1d2h"); + } + +} diff --git a/it/it-tests/src/test/java/it/debt/TechnicalDebtWidgetTest.java b/it/it-tests/src/test/java/it/debt/TechnicalDebtWidgetTest.java new file mode 100644 index 00000000000..a9d9df0f6e7 --- /dev/null +++ b/it/it-tests/src/test/java/it/debt/TechnicalDebtWidgetTest.java @@ -0,0 +1,100 @@ +/* + * 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 it.debt; + +import com.sonar.orchestrator.Orchestrator; +import com.sonar.orchestrator.build.SonarRunner; +import com.sonar.orchestrator.locator.FileLocation; +import com.sonar.orchestrator.selenium.Selenese; +import it.Category2Suite; +import org.junit.BeforeClass; +import org.junit.ClassRule; +import org.junit.Test; +import util.selenium.SeleneseTest; + +import static util.ItUtils.projectDir; + +public class TechnicalDebtWidgetTest { + + @ClassRule + public static Orchestrator orchestrator = Category2Suite.ORCHESTRATOR; + + @BeforeClass + public static void init() { + orchestrator.resetData(); + + orchestrator.getServer().restoreProfile(FileLocation.ofClasspath("/debt/with-many-rules.xml")); + orchestrator.getServer().provisionProject("com.sonarsource.it.samples:multi-modules-sample", "com.sonarsource.it.samples:multi-modules-sample"); + orchestrator.getServer().associateProjectToQualityProfile("com.sonarsource.it.samples:multi-modules-sample", "xoo", "with-many-rules"); + + // need to execute the build twice in order to have history widgets + // we made some exclusions to have variations in diff mode + scanProject("2011-06-01", "**/a2/**"); + scanProject("2012-02-01", ""); + } + + private static void scanProject(String date, String excludes) { + SonarRunner scan = SonarRunner.create(projectDir("shared/xoo-multi-modules-sample")) + .setProperties("sonar.projectDate", date, "sonar.exclusions", excludes); + orchestrator.executeBuild(scan); + } + + /** + * SONAR-4717 + */ + @Test + public void technical_debt_in_issues_widget() { + new SeleneseTest(Selenese.builder() + .setHtmlTestsInClasspath("technical-debt-in-issues-widget", + "/debt/TechnicalDebtWidgetTest/technical-debt/should-have-correct-values.html", + "/debt/TechnicalDebtWidgetTest/technical-debt/should-open-remediationcost-on-drilldown-service.html", + "/debt/TechnicalDebtWidgetTest/technical-debt/display-differential-values.html", + // SONAR-4717 + "/debt/TechnicalDebtWidgetTest/technical-debt/is-in-issues-widget.html" + ).build()).runOn(orchestrator); + } + + /** + * SONAR-4718 + */ + @Test + public void technical_debt_pyramid_widget() { + new SeleneseTest(Selenese.builder() + .setHtmlTestsInClasspath("technical-debt-pyramid-widget", + "/debt/TechnicalDebtWidgetTest/technical-debt-pyramid/should-have-correct-values.html", + "/debt/TechnicalDebtWidgetTest/technical-debt-pyramid/should-open-links-on-drilldown-service.html", + "/debt/TechnicalDebtWidgetTest/technical-debt-pyramid/display-differential-values.html" + ).build()).runOn(orchestrator); + } + + /** + * SONAR-5450 + */ + @Test + public void debt_overview_widget() { + new SeleneseTest(Selenese.builder() + .setHtmlTestsInClasspath("debt-overview-widget", + "/debt/TechnicalDebtWidgetTest/debt-overview/should-have-correct-values.html", + "/debt/TechnicalDebtWidgetTest/debt-overview/should-open-links-on-drilldown-service.html", + "/debt/TechnicalDebtWidgetTest/debt-overview/display-differential-values.html" + ).build()).runOn(orchestrator); + } + +} diff --git a/it/it-tests/src/test/resources/debt/TechnicalDebtWidgetTest/debt-overview/display-differential-values.html b/it/it-tests/src/test/resources/debt/TechnicalDebtWidgetTest/debt-overview/display-differential-values.html new file mode 100644 index 00000000000..5d94a7352b7 --- /dev/null +++ b/it/it-tests/src/test/resources/debt/TechnicalDebtWidgetTest/debt-overview/display-differential-values.html @@ -0,0 +1,36 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> +<head profile="http://selenium-ide.openqa.org/profiles/test-case"> + <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> +</head> +<body> +<table cellpadding="1" cellspacing="1" border="1"> + <tbody> + <tr> + <td>open</td> + <td> + /sonar/widget?id=debt_overview&resource=com.sonarsource.it.samples:multi-modules-sample&period=1<br/> + </td> + <td></td> + </tr> + <tr> + <td>assertText</td> + <td>body</td> + <td>*29.1% (-1.2)*</td> + </tr> + <tr> + <td>assertText</td> + <td>body</td> + <td>*C*</td> + </tr> + <!--No diff value is displayed on the SQALE rating--> + <tr> + <td>assertNotText</td> + <td>body</td> + <td>*C (*</td> + </tr> + </tbody> +</table> +</body> +</html> diff --git a/it/it-tests/src/test/resources/debt/TechnicalDebtWidgetTest/debt-overview/should-have-correct-values.html b/it/it-tests/src/test/resources/debt/TechnicalDebtWidgetTest/debt-overview/should-have-correct-values.html new file mode 100644 index 00000000000..8d5dbc04842 --- /dev/null +++ b/it/it-tests/src/test/resources/debt/TechnicalDebtWidgetTest/debt-overview/should-have-correct-values.html @@ -0,0 +1,28 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> +<head profile="http://selenium-ide.openqa.org/profiles/test-case"> + <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> +</head> +<body> +<table cellpadding="1" cellspacing="1" border="1"> + <thead> + <tr> + <td rowspan="1" colspan="3">should-have-correct-values</td> + </tr> + </thead> + <tbody> + <tr> + <td>open</td> + <td>/sonar/widget?id=debt_overview&resource=com.sonarsource.it.samples:multi-modules-sample</td> + <td></td> + </tr> + <tr> + <td>assertText</td> + <td>body</td> + <td>*SQALE Rating*C*Technical Debt Ratio*29.1%*</td> + </tr> + </tbody> +</table> +</body> +</html> diff --git a/it/it-tests/src/test/resources/debt/TechnicalDebtWidgetTest/debt-overview/should-open-links-on-drilldown-service.html b/it/it-tests/src/test/resources/debt/TechnicalDebtWidgetTest/debt-overview/should-open-links-on-drilldown-service.html new file mode 100644 index 00000000000..7e5de269458 --- /dev/null +++ b/it/it-tests/src/test/resources/debt/TechnicalDebtWidgetTest/debt-overview/should-open-links-on-drilldown-service.html @@ -0,0 +1,48 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> +<head profile="http://selenium-ide.openqa.org/profiles/test-case"> + <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> +</head> +<body> +<table cellpadding="1" cellspacing="1" border="1"> + <thead> + <tr> + <td rowspan="1" colspan="3">should-open-links-on-drilldown-service</td> + </tr> + </thead> + <tbody> + <tr> + <td>open</td> + <td>/sonar/widget?id=debt_overview&resource=com.sonarsource.it.samples:multi-modules-sample</td> + <td></td> + </tr> + <tr> + <td>clickAndWait</td> + <td>link=C</td> + <td></td> + </tr> + <tr> + <td>assertText</td> + <td>content</td> + <td>*SQALE Rating*C*</td> + </tr> + <tr> + <td>open</td> + <td>/sonar/widget?id=debt_overview&resource=com.sonarsource.it.samples:multi-modules-sample</td> + <td></td> + </tr> + <tr> + <td>clickAndWait</td> + <td>link=29.1%</td> + <td></td> + </tr> + <tr> + <td>assertText</td> + <td>content</td> + <td>*Technical Debt Ratio*29.1%*</td> + </tr> + </tbody> +</table> +</body> +</html> diff --git a/it/it-tests/src/test/resources/debt/TechnicalDebtWidgetTest/technical-debt-pyramid/display-differential-values.html b/it/it-tests/src/test/resources/debt/TechnicalDebtWidgetTest/technical-debt-pyramid/display-differential-values.html new file mode 100644 index 00000000000..dde8c65b776 --- /dev/null +++ b/it/it-tests/src/test/resources/debt/TechnicalDebtWidgetTest/technical-debt-pyramid/display-differential-values.html @@ -0,0 +1,99 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> +<head profile="http://selenium-ide.openqa.org/profiles/test-case"> + <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> + <title>display-differential-values</title> +</head> +<body> +<table cellpadding="1" cellspacing="1" border="1"> + <tbody> + <tr> + <td>open</td> + <td>/sonar/widget?id=technical_debt_pyramid&resource=com.sonarsource.it.samples:multi-modules-sample&period=1</td> + <td></td> + </tr> + <tr> + <td>assertText</td> + <td>css=.value-debt-REUSABILITY</td> + <td>*0*(+0)*</td> + </tr> + <tr> + <td>assertText</td> + <td>css=.value-total-REUSABILITY</td> + <td>*7h 25min*(+1h 58min)*</td> + </tr> + <tr> + <td>assertText</td> + <td>css=.value-debt-PORTABILITY</td> + <td>*0*(+0)*</td> + </tr> + <tr> + <td>assertText</td> + <td>css=.value-total-PORTABILITY</td> + <td>*7h 25min*(+1h 58min)*</td> + </tr> + <tr> + <td>assertText</td> + <td>css=.value-debt-MAINTAINABILITY</td> + <td>*4min*(+2min)*</td> + </tr> + <tr> + <td>assertText</td> + <td>css=.value-total-MAINTAINABILITY</td> + <td>*7h 25min*(+1h 58min)*</td> + </tr> + <tr> + <td>assertText</td> + <td>css=.value-debt-SECURITY</td> + <td>*5h 40min*(+1h 25min)*</td> + </tr> + <tr> + <td>assertText</td> + <td>css=.value-total-SECURITY</td> + <td>*7h 21min*(+1h 56min)*</td> + </tr> + <tr> + <td>assertText</td> + <td>css=.value-debt-EFFICIENCY</td> + <td>*1h 1min*(+21min)*</td> + </tr> + <tr> + <td>assertText</td> + <td>css=.value-total-EFFICIENCY</td> + <td>*1h 41min*(+31min)*</td> + </tr> + <tr> + <td>assertText</td> + <td>css=.value-debt-CHANGEABILITY</td> + <td>*40min*(+10min)*</td> + </tr> + <tr> + <td>assertText</td> + <td>css=.value-total-CHANGEABILITY</td> + <td>*40min*(+10min)*</td> + </tr> + <tr> + <td>assertText</td> + <td>css=.value-debt-RELIABILITY</td> + <td>*0*(+0)*</td> + </tr> + <tr> + <td>assertText</td> + <td>css=.value-total-RELIABILITY</td> + <td>*0*(+0)*</td> + </tr> + <tr> + <td>assertText</td> + <td>css=.value-debt-TESTABILITY</td> + <td>*0*(+0)*</td> + </tr> + <tr> + <td>assertText</td> + <td>css=.value-total-TESTABILITY</td> + <td>*0*(+0)*</td> + </tr> + </tbody> +</table> +</body> +</html> diff --git a/it/it-tests/src/test/resources/debt/TechnicalDebtWidgetTest/technical-debt-pyramid/should-have-correct-values.html b/it/it-tests/src/test/resources/debt/TechnicalDebtWidgetTest/technical-debt-pyramid/should-have-correct-values.html new file mode 100644 index 00000000000..dc521b278a9 --- /dev/null +++ b/it/it-tests/src/test/resources/debt/TechnicalDebtWidgetTest/technical-debt-pyramid/should-have-correct-values.html @@ -0,0 +1,109 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> +<head profile="http://selenium-ide.openqa.org/profiles/test-case"> + <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> + <title>should-have-correct-values</title> +</head> +<body> +<table cellpadding="1" cellspacing="1" border="1"> + <thead> + <tr> + <td rowspan="1" colspan="3">should-have-correct-values</td> + </tr> + </thead> + <tbody> + <tr> + <td>open</td> + <td>/sonar/widget?id=technical_debt_pyramid&resource=com.sonarsource.it.samples:multi-modules-sample</td> + <td></td> + </tr> + <tr> + <td>assertText</td> + <td>block_1</td> + <td>*Reusability*Portability*Maintainability*Security*Efficiency*Changeability*Reliability*Testability*</td> + </tr> + <tr> + <td>assertText</td> + <td>css=.value-debt-REUSABILITY</td> + <td>*0*</td> + </tr> + <tr> + <td>assertText</td> + <td>css=.value-total-REUSABILITY</td> + <td>*7h 25min*</td> + </tr> + <tr> + <td>assertText</td> + <td>css=.value-debt-PORTABILITY</td> + <td>*0*</td> + </tr> + <tr> + <td>assertText</td> + <td>css=.value-total-PORTABILITY</td> + <td>*7h 25min*</td> + </tr> + <tr> + <td>assertText</td> + <td>css=.value-debt-MAINTAINABILITY</td> + <td>*4min*</td> + </tr> + <tr> + <td>assertText</td> + <td>css=.value-total-MAINTAINABILITY</td> + <td>*7h 25min*</td> + </tr> + <tr> + <td>assertText</td> + <td>css=.value-debt-SECURITY</td> + <td>*5h 40min*</td> + </tr> + <tr> + <td>assertText</td> + <td>css=.value-total-SECURITY</td> + <td>*7h 21min*</td> + </tr> + <tr> + <td>assertText</td> + <td>css=.value-debt-EFFICIENCY</td> + <td>*1h 1min*</td> + </tr> + <tr> + <td>assertText</td> + <td>css=.value-total-EFFICIENCY</td> + <td>*1h 41min*</td> + </tr> + <tr> + <td>assertText</td> + <td>css=.value-debt-CHANGEABILITY</td> + <td>*40min*</td> + </tr> + <tr> + <td>assertText</td> + <td>css=.value-total-CHANGEABILITY</td> + <td>*40min*</td> + </tr> + <tr> + <td>assertText</td> + <td>css=.value-debt-RELIABILITY</td> + <td>*0*</td> + </tr> + <tr> + <td>assertText</td> + <td>css=.value-total-RELIABILITY</td> + <td>*0*</td> + </tr> + <tr> + <td>assertText</td> + <td>css=.value-debt-TESTABILITY</td> + <td>*0*</td> + </tr> + <tr> + <td>assertText</td> + <td>css=.value-total-TESTABILITY</td> + <td>*0*</td> + </tr> + </tbody> +</table> +</body> +</html> diff --git a/it/it-tests/src/test/resources/debt/TechnicalDebtWidgetTest/technical-debt-pyramid/should-open-links-on-drilldown-service.html b/it/it-tests/src/test/resources/debt/TechnicalDebtWidgetTest/technical-debt-pyramid/should-open-links-on-drilldown-service.html new file mode 100644 index 00000000000..ccae72de85a --- /dev/null +++ b/it/it-tests/src/test/resources/debt/TechnicalDebtWidgetTest/technical-debt-pyramid/should-open-links-on-drilldown-service.html @@ -0,0 +1,34 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> +<head profile="http://selenium-ide.openqa.org/profiles/test-case"> + <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> + <title>should-open-links-on-drilldown-service</title> +</head> +<body> +<table cellpadding="1" cellspacing="1" border="1"> + <thead> + <tr> + <td rowspan="1" colspan="3">should-open-links-on-drilldown-service</td> + </tr> + </thead> + <tbody> + <tr> + <td>open</td> + <td>/sonar/widget?id=technical_debt_pyramid&resource=com.sonarsource.it.samples:multi-modules-sample</td> + <td></td> + </tr> + <tr> + <td>clickAndWait</td> + <td>css=.link-debt-SECURITY</td> + <td></td> + </tr> + <tr> + <td>assertText</td> + <td>content</td> + <td>*Technical Debt / Security*5h 40min*</td> + </tr> + </tbody> +</table> +</body> +</html> diff --git a/it/it-tests/src/test/resources/debt/TechnicalDebtWidgetTest/technical-debt/display-differential-values.html b/it/it-tests/src/test/resources/debt/TechnicalDebtWidgetTest/technical-debt/display-differential-values.html new file mode 100644 index 00000000000..0790348b98a --- /dev/null +++ b/it/it-tests/src/test/resources/debt/TechnicalDebtWidgetTest/technical-debt/display-differential-values.html @@ -0,0 +1,24 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> +<head profile="http://selenium-ide.openqa.org/profiles/test-case"> + <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> + <title>display-differential-values</title> +</head> +<body> +<table cellpadding="1" cellspacing="1" border="1"> + <tbody> + <tr> + <td>open</td> + <td>/sonar/widget?id=rules&resource=com.sonarsource.it.samples:multi-modules-sample&period=1</td> + <td></td> + </tr> + <tr> + <td>assertText</td> + <td>block_1</td> + <td>*7h 25min*(+1h 58min)*</td> + </tr> + </tbody> +</table> +</body> +</html> diff --git a/it/it-tests/src/test/resources/debt/TechnicalDebtWidgetTest/technical-debt/is-in-issues-widget.html b/it/it-tests/src/test/resources/debt/TechnicalDebtWidgetTest/technical-debt/is-in-issues-widget.html new file mode 100644 index 00000000000..46122acc3cd --- /dev/null +++ b/it/it-tests/src/test/resources/debt/TechnicalDebtWidgetTest/technical-debt/is-in-issues-widget.html @@ -0,0 +1,24 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> +<head profile="http://selenium-ide.openqa.org/profiles/test-case"> + <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> + <title>display-differential-values</title> +</head> +<body> +<table cellpadding="1" cellspacing="1" border="1"> + <tbody> + <tr> + <td>open</td> + <td>/sonar/widget?id=rules&amp;resource=com.sonarsource.it.samples:multi-modules-sample</td> + <td></td> + </tr> + <tr> + <td>assertText</td> + <td>body</td> + <td>*Debt*</td> + </tr> + </tbody> +</table> +</body> +</html> diff --git a/it/it-tests/src/test/resources/debt/TechnicalDebtWidgetTest/technical-debt/should-have-correct-values.html b/it/it-tests/src/test/resources/debt/TechnicalDebtWidgetTest/technical-debt/should-have-correct-values.html new file mode 100644 index 00000000000..5c47991b3c0 --- /dev/null +++ b/it/it-tests/src/test/resources/debt/TechnicalDebtWidgetTest/technical-debt/should-have-correct-values.html @@ -0,0 +1,29 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> +<head profile="http://selenium-ide.openqa.org/profiles/test-case"> + <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> + <title>should-have-correct-values</title> +</head> +<body> +<table cellpadding="1" cellspacing="1" border="1"> + <thead> + <tr> + <td rowspan="1" colspan="3">should-have-correct-values</td> + </tr> + </thead> + <tbody> + <tr> + <td>open</td> + <td>/sonar/widget?id=rules&resource=com.sonarsource.it.samples:multi-modules-sample</td> + <td></td> + </tr> + <tr> + <td>assertText</td> + <td>block_1</td> + <td>*7h 25min*</td> + </tr> + </tbody> +</table> +</body> +</html> diff --git a/it/it-tests/src/test/resources/debt/TechnicalDebtWidgetTest/technical-debt/should-open-remediationcost-on-drilldown-service.html b/it/it-tests/src/test/resources/debt/TechnicalDebtWidgetTest/technical-debt/should-open-remediationcost-on-drilldown-service.html new file mode 100644 index 00000000000..b1956068016 --- /dev/null +++ b/it/it-tests/src/test/resources/debt/TechnicalDebtWidgetTest/technical-debt/should-open-remediationcost-on-drilldown-service.html @@ -0,0 +1,39 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> +<head profile="http://selenium-ide.openqa.org/profiles/test-case"> + <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> + <title>should-open-remediationcost-on-drilldown-service</title> +</head> +<body> +<table cellpadding="1" cellspacing="1" border="1"> + <thead> + <tr> + <td rowspan="1" colspan="3">should-open-remediationcost-on-drilldown-service</td> + </tr> + </thead> + <tbody> + <tr> + <td>open</td> + <td>/sonar/widget?id=rules&resource=com.sonarsource.it.samples:multi-modules-sample</td> + <td></td> + </tr> + <tr> + <td>clickAndWait</td> + <td>css=.link-rules-debt</td> + <td></td> + </tr> + <tr> + <td>assertText</td> + <td>content</td> + <td>*Technical Debt*7h 25min*</td> + </tr> + <tr> + <td>assertText</td> + <td>content</td> + <td>*Module A*com/sonar/it/samples/modules/a1*HelloA1.xoo*</td> + </tr> + </tbody> +</table> +</body> +</html> diff --git a/it/it-tests/src/test/resources/debt/has-hello-tag.xml b/it/it-tests/src/test/resources/debt/has-hello-tag.xml new file mode 100644 index 00000000000..88cf4f9273e --- /dev/null +++ b/it/it-tests/src/test/resources/debt/has-hello-tag.xml @@ -0,0 +1,18 @@ +<?xml version="1.0" encoding="UTF-8"?> +<profile> + <name>has-tag</name> + <language>xoo</language> + <rules> + <rule> + <repositoryKey>xoo</repositoryKey> + <key>HasTag</key> + <priority>INFO</priority> + <parameters> + <parameter> + <key>tag</key> + <value>hello</value> + </parameter> + </parameters> + </rule> + </rules> +</profile> diff --git a/it/it-tests/src/test/resources/debt/one-day-debt-per-file.xml b/it/it-tests/src/test/resources/debt/one-day-debt-per-file.xml new file mode 100644 index 00000000000..cdebd7554c9 --- /dev/null +++ b/it/it-tests/src/test/resources/debt/one-day-debt-per-file.xml @@ -0,0 +1,12 @@ +<?xml version="1.0" encoding="UTF-8"?> +<profile> + <name>one-day-debt-per-file</name> + <language>xoo</language> + <rules> + <rule> + <repositoryKey>xoo</repositoryKey> + <key>OneDayDebtPerFile</key> + <priority>MINOR</priority> + </rule> + </rules> +</profile> diff --git a/it/it-tests/src/test/resources/debt/one-issue-per-file.xml b/it/it-tests/src/test/resources/debt/one-issue-per-file.xml new file mode 100644 index 00000000000..7193ebfd779 --- /dev/null +++ b/it/it-tests/src/test/resources/debt/one-issue-per-file.xml @@ -0,0 +1,12 @@ +<?xml version="1.0" encoding="UTF-8"?> +<profile> + <name>one-issue-per-file</name> + <language>xoo</language> + <rules> + <rule> + <repositoryKey>xoo</repositoryKey> + <key>OneIssuePerFile</key> + <priority>MINOR</priority> + </rule> + </rules> +</profile> diff --git a/it/it-tests/src/test/resources/debt/one-issue-per-line.xml b/it/it-tests/src/test/resources/debt/one-issue-per-line.xml new file mode 100644 index 00000000000..521adc7e06f --- /dev/null +++ b/it/it-tests/src/test/resources/debt/one-issue-per-line.xml @@ -0,0 +1,12 @@ +<?xml version="1.0" encoding="UTF-8"?> +<profile> + <name>one-issue-per-line</name> + <language>xoo</language> + <rules> + <rule> + <repositoryKey>xoo</repositoryKey> + <key>OneIssuePerLine</key> + <priority>MINOR</priority> + </rule> + </rules> +</profile>
\ No newline at end of file diff --git a/it/it-tests/src/test/resources/debt/with-many-rules.xml b/it/it-tests/src/test/resources/debt/with-many-rules.xml new file mode 100644 index 00000000000..f3d0baf0616 --- /dev/null +++ b/it/it-tests/src/test/resources/debt/with-many-rules.xml @@ -0,0 +1,32 @@ +<profile> + <name>with-many-rules</name> + <language>xoo</language> + <rules> + <rule> + <repositoryKey>xoo</repositoryKey> + <key>OneIssuePerLine</key> + <priority>MINOR</priority> + </rule> + <rule> + <repositoryKey>xoo</repositoryKey> + <key>OneIssuePerFile</key> + <priority>MAJOR</priority> + </rule> + <rule> + <repositoryKey>xoo</repositoryKey> + <key>OneIssuePerModule</key> + <priority>CRITICAL</priority> + </rule> + <rule> + <repositoryKey>xoo</repositoryKey> + <key>HasTag</key> + <priority>INFO</priority> + <parameters> + <parameter> + <key>tag</key> + <value>xoo</value> + </parameter> + </parameters> + </rule> + </rules> +</profile>
\ No newline at end of file |