diff options
author | Simon Brandhof <simon.brandhof@sonarsource.com> | 2017-11-11 16:57:30 +0100 |
---|---|---|
committer | Eric Hartmann <hartmann.eric@gmail.Com> | 2017-11-14 13:10:17 +0100 |
commit | d19b26a37c0810bc54659a167b779095912bc516 (patch) | |
tree | d986f98fdfa7ab39d89436dd3c179adfdb4aee57 /server/sonar-qa-util/src | |
parent | a55bd3e3c0dee50df1fe9ee79e032c5773bb7c07 (diff) | |
download | sonarqube-d19b26a37c0810bc54659a167b779095912bc516.tar.gz sonarqube-d19b26a37c0810bc54659a167b779095912bc516.zip |
Add category qualityModel to integration tests
Diffstat (limited to 'server/sonar-qa-util/src')
3 files changed, 67 insertions, 0 deletions
diff --git a/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/QModelTester.java b/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/QModelTester.java new file mode 100644 index 00000000000..e4c86b64413 --- /dev/null +++ b/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/QModelTester.java @@ -0,0 +1,55 @@ +/* + * SonarQube + * Copyright (C) 2009-2017 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program 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. + * + * This program 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.sonarqube.qa.util; + +import com.google.common.base.Joiner; + +import static com.google.common.base.Preconditions.checkState; + +public class QModelTester { + + private static final String DEV_COST_PROPERTY = "sonar.technicalDebt.developmentCost"; + private static final String RATING_GRID_PROPERTY = "sonar.technicalDebt.ratingGrid"; + private static final String DEV_COST_LANGUAGE_PROPERTY = "languageSpecificParameters"; + private static final String DEV_COST_LANGUAGE_NAME_PROPERTY = DEV_COST_LANGUAGE_PROPERTY + ".0.language"; + private static final String DEV_COST_LANGUAGE_COST_PROPERTY = DEV_COST_LANGUAGE_PROPERTY + ".0.man_days"; + private static final Joiner COMMA_JOINER = Joiner.on(","); + + private final TesterSession session; + + QModelTester(TesterSession session) { + this.session = session; + } + + public void updateDevelopmentCost(int developmentCost) { + session.settings().setGlobalSettings(DEV_COST_PROPERTY, Integer.toString(developmentCost)); + } + + public void updateLanguageDevelopmentCost(String language, int developmentCost) { + session.settings().setGlobalSettings(DEV_COST_LANGUAGE_PROPERTY, "0"); + session.settings().setGlobalSettings(DEV_COST_LANGUAGE_NAME_PROPERTY, language); + session.settings().setGlobalSettings(DEV_COST_LANGUAGE_COST_PROPERTY, Integer.toString(developmentCost)); + } + + public void updateRatingGrid(Double... ratingGrid) { + checkState(ratingGrid.length == 4, "Rating grid must contains 4 values"); + session.settings().setGlobalSettings(RATING_GRID_PROPERTY, COMMA_JOINER.join(ratingGrid)); + } +} diff --git a/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/Tester.java b/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/Tester.java index f5077ad3266..a755c60e1d3 100644 --- a/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/Tester.java +++ b/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/Tester.java @@ -178,6 +178,11 @@ public class Tester extends ExternalResource implements TesterSession { } @Override + public QModelTester qModel() { + return rootSession.qModel(); + } + + @Override public QProfileTester qProfiles() { return rootSession.qProfiles(); } @@ -229,6 +234,11 @@ public class Tester extends ExternalResource implements TesterSession { } @Override + public QModelTester qModel() { + return new QModelTester(this); + } + + @Override public QProfileTester qProfiles() { return new QProfileTester(this); } diff --git a/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/TesterSession.java b/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/TesterSession.java index 6c2673abcb2..551f9662816 100644 --- a/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/TesterSession.java +++ b/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/TesterSession.java @@ -31,6 +31,8 @@ public interface TesterSession { ProjectTester projects(); + QModelTester qModel(); + QProfileTester qProfiles(); UserTester users(); |