aboutsummaryrefslogtreecommitdiffstats
path: root/it
diff options
context:
space:
mode:
authorSébastien Lesaint <sebastien.lesaint@sonarsource.com>2015-10-20 13:56:54 +0200
committerJulien Lancelot <julien.lancelot@sonarsource.com>2015-10-23 10:44:15 +0200
commit0235ff6fffe8a45bfb5b82eb4c6d8aeb2b7eccf9 (patch)
tree51e2649dfca342c30c785e7398eae1cd2e1e7511 /it
parent0859e4eb39e20c5d41314d0a1a0a68edf23d9bc2 (diff)
downloadsonarqube-0235ff6fffe8a45bfb5b82eb4c6d8aeb2b7eccf9.tar.gz
sonarqube-0235ff6fffe8a45bfb5b82eb4c6d8aeb2b7eccf9.zip
reduce code duplication in package issue.suite
Diffstat (limited to 'it')
-rw-r--r--it/it-tests/src/test/java/analysis/suite/measure/NewDebtRatioMeasureTest.java14
-rw-r--r--it/it-tests/src/test/java/analysis/suite/measure/TechnicalDebtMeasureVariationTest.java2
-rw-r--r--it/it-tests/src/test/java/issue/suite/CommonRulesTest.java9
-rw-r--r--it/it-tests/src/test/java/issue/suite/CustomRulesTest.java9
-rw-r--r--it/it-tests/src/test/java/issue/suite/IssueActionTest.java15
-rw-r--r--it/it-tests/src/test/java/issue/suite/IssueBulkChangeTest.java55
-rw-r--r--it/it-tests/src/test/java/issue/suite/IssueChangelogTest.java15
-rw-r--r--it/it-tests/src/test/java/issue/suite/IssueTestSuite.java27
-rw-r--r--it/it-tests/src/test/java/util/ItUtils.java55
9 files changed, 99 insertions, 102 deletions
diff --git a/it/it-tests/src/test/java/analysis/suite/measure/NewDebtRatioMeasureTest.java b/it/it-tests/src/test/java/analysis/suite/measure/NewDebtRatioMeasureTest.java
index 40d6c62e2fc..1c92aaac6a2 100644
--- a/it/it-tests/src/test/java/analysis/suite/measure/NewDebtRatioMeasureTest.java
+++ b/it/it-tests/src/test/java/analysis/suite/measure/NewDebtRatioMeasureTest.java
@@ -80,13 +80,13 @@ public class NewDebtRatioMeasureTest {
}
private void runSampleProjectAnalysis(String projectVersion, String... properties) {
- ItUtils.runProjectAnalysis(
- NewDebtRatioMeasureTest.orchestrator,
- "measure/xoo-new-debt-ratio-" + projectVersion,
- ItUtils.concat(properties,
- // disable standard scm support so that it does not interfere with Xoo Scm sensor
- "sonar.scm.disabled", "false")
- );
+ ItUtils.runVerboseProjectAnalysis(
+ NewDebtRatioMeasureTest.orchestrator,
+ "measure/xoo-new-debt-ratio-" + projectVersion,
+ ItUtils.concat(properties,
+ // disable standard scm support so that it does not interfere with Xoo Scm sensor
+ "sonar.scm.disabled", "false")
+ );
}
private Resource getFileResourceWithVariations(String metricKey) {
diff --git a/it/it-tests/src/test/java/analysis/suite/measure/TechnicalDebtMeasureVariationTest.java b/it/it-tests/src/test/java/analysis/suite/measure/TechnicalDebtMeasureVariationTest.java
index 24b78ebebb4..a28f40fe645 100644
--- a/it/it-tests/src/test/java/analysis/suite/measure/TechnicalDebtMeasureVariationTest.java
+++ b/it/it-tests/src/test/java/analysis/suite/measure/TechnicalDebtMeasureVariationTest.java
@@ -146,7 +146,7 @@ public class TechnicalDebtMeasureVariationTest {
}
private void runSampleProjectAnalysis(String... properties) {
- ItUtils.runProjectAnalysis(TechnicalDebtMeasureVariationTest.orchestrator, "shared/xoo-sample", properties);
+ ItUtils.runVerboseProjectAnalysis(TechnicalDebtMeasureVariationTest.orchestrator, "shared/xoo-sample", properties);
}
private Resource getSampleProjectResourceWithVariations(String metricKey) {
diff --git a/it/it-tests/src/test/java/issue/suite/CommonRulesTest.java b/it/it-tests/src/test/java/issue/suite/CommonRulesTest.java
index d844b0ae6ed..8805d2bfdba 100644
--- a/it/it-tests/src/test/java/issue/suite/CommonRulesTest.java
+++ b/it/it-tests/src/test/java/issue/suite/CommonRulesTest.java
@@ -6,7 +6,6 @@
package issue.suite;
import com.sonar.orchestrator.Orchestrator;
-import com.sonar.orchestrator.build.SonarRunner;
import com.sonar.orchestrator.locator.FileLocation;
import java.util.List;
import org.junit.BeforeClass;
@@ -15,8 +14,9 @@ import org.junit.Test;
import org.sonar.wsclient.issue.Issue;
import org.sonar.wsclient.issue.IssueQuery;
+import static issue.suite.IssueTestSuite.searchIssues;
import static org.assertj.core.api.Assertions.assertThat;
-import static util.ItUtils.projectDir;
+import static util.ItUtils.runProjectAnalysis;
public class CommonRulesTest {
@@ -32,10 +32,9 @@ public class CommonRulesTest {
orchestrator.getServer().restoreProfile(FileLocation.ofClasspath("/issue/suite/CommonRulesTest/xoo-common-rules-profile.xml"));
orchestrator.getServer().provisionProject("common-rules-project", "Sample");
orchestrator.getServer().associateProjectToQualityProfile("common-rules-project", "xoo", "xoo-common-rules");
- SonarRunner analysis = SonarRunner.create(projectDir("issue/common-rules"),
+ runProjectAnalysis(orchestrator, "issue/common-rules",
"sonar.cpd.xoo.minimumTokens", "2",
"sonar.cpd.xoo.minimumLines", "2");
- orchestrator.executeBuild(analysis);
}
@Test
@@ -72,6 +71,6 @@ public class CommonRulesTest {
}
private List<Issue> findIssues(String componentKey, String ruleKey) {
- return orchestrator.getServer().wsClient().issueClient().find(IssueQuery.create().components(componentKey).rules(ruleKey)).list();
+ return searchIssues(IssueQuery.create().components(componentKey).rules(ruleKey));
}
}
diff --git a/it/it-tests/src/test/java/issue/suite/CustomRulesTest.java b/it/it-tests/src/test/java/issue/suite/CustomRulesTest.java
index b0d29444734..2271dc3f951 100644
--- a/it/it-tests/src/test/java/issue/suite/CustomRulesTest.java
+++ b/it/it-tests/src/test/java/issue/suite/CustomRulesTest.java
@@ -6,17 +6,16 @@
package issue.suite;
import com.sonar.orchestrator.Orchestrator;
-import com.sonar.orchestrator.build.SonarRunner;
import com.sonar.orchestrator.locator.FileLocation;
import java.util.List;
import org.junit.Before;
import org.junit.ClassRule;
import org.junit.Test;
import org.sonar.wsclient.issue.Issue;
-import org.sonar.wsclient.issue.IssueQuery;
-import util.ItUtils;
+import static issue.suite.IssueTestSuite.searchIssues;
import static org.assertj.core.api.Assertions.assertThat;
+import static util.ItUtils.runProjectAnalysis;
public class CustomRulesTest {
@@ -44,9 +43,9 @@ public class CustomRulesTest {
orchestrator.getServer().provisionProject("sample", "Sample");
orchestrator.getServer().associateProjectToQualityProfile("sample", "xoo", "Custom");
- orchestrator.executeBuild(SonarRunner.create().setProjectDir(ItUtils.projectDir("shared/xoo-sample")));
+ runProjectAnalysis(orchestrator, "shared/xoo-sample");
- List<Issue> issues = orchestrator.getServer().adminWsClient().issueClient().find(IssueQuery.create()).list();
+ List<Issue> issues = searchIssues();
assertThat(issues).hasSize(1);
Issue issue = issues.get(0);
diff --git a/it/it-tests/src/test/java/issue/suite/IssueActionTest.java b/it/it-tests/src/test/java/issue/suite/IssueActionTest.java
index c6d1b75e982..8ea2c10b601 100644
--- a/it/it-tests/src/test/java/issue/suite/IssueActionTest.java
+++ b/it/it-tests/src/test/java/issue/suite/IssueActionTest.java
@@ -25,7 +25,6 @@ import com.sonar.orchestrator.locator.FileLocation;
import java.util.List;
import org.junit.Before;
import org.junit.ClassRule;
-import org.junit.Ignore;
import org.junit.Test;
import org.sonar.wsclient.base.HttpException;
import org.sonar.wsclient.issue.ActionPlan;
@@ -38,14 +37,13 @@ import org.sonar.wsclient.issue.NewActionPlan;
import static issue.suite.IssueTestSuite.ORCHESTRATOR;
import static issue.suite.IssueTestSuite.adminIssueClient;
-import static issue.suite.IssueTestSuite.issueClient;
import static issue.suite.IssueTestSuite.search;
import static issue.suite.IssueTestSuite.searchIssueByKey;
import static issue.suite.IssueTestSuite.searchIssues;
import static issue.suite.IssueTestSuite.searchRandomIssue;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.fail;
-import static util.ItUtils.projectDir;
+import static util.ItUtils.runProjectAnalysis;
import static util.ItUtils.toDate;
import static util.ItUtils.verifyHttpException;
@@ -72,8 +70,7 @@ public class IssueActionTest {
orchestrator.getServer().provisionProject("sample", "Sample");
orchestrator.getServer().associateProjectToQualityProfile("sample", "xoo", "xoo-one-issue-per-line-profile");
- scan = SonarRunner.create(projectDir("shared/xoo-sample"));
- orchestrator.executeBuild(scan);
+ scan = runProjectAnalysis(orchestrator, "shared/xoo-sample");
issue = searchRandomIssue();
}
@@ -91,7 +88,7 @@ public class IssueActionTest {
assertThat(comment.createdAt()).isNotNull();
// reload issue
- Issue reloaded = searchIssueByKey(issue.key());
+ Issue reloaded = searchIssues(issue.key(), true).iterator().next();
assertThat(reloaded.comments()).hasSize(1);
assertThat(reloaded.comments().get(0).key()).isEqualTo(comment.key());
@@ -149,7 +146,7 @@ public class IssueActionTest {
assertThat(issues.users()).isEmpty();
adminIssueClient().assign(issue.key(), "admin");
- assertThat(search(IssueQuery.create().assignees("admin")).list()).hasSize(1);
+ assertThat(searchIssues(IssueQuery.create().assignees("admin"))).hasSize(1);
orchestrator.executeBuild(scan);
Issue reloaded = searchIssueByKey(issue.key());
@@ -164,7 +161,7 @@ public class IssueActionTest {
adminIssueClient().assign(issue.key(), null);
reloaded = searchIssueByKey(issue.key());
assertThat(reloaded.assignee()).isNull();
- assertThat(issueClient().find(IssueQuery.create().assignees("admin")).list()).isEmpty();
+ assertThat(searchIssues(IssueQuery.create().assignees("admin"))).isEmpty();
}
/**
@@ -248,7 +245,7 @@ public class IssueActionTest {
adminIssueClient().doAction(issue.key(), "fake");
// reload issue
- Issue reloaded = searchIssueByKey(issue.key());
+ Issue reloaded = searchIssues(issue.key(), true).iterator().next();
assertThat(reloaded.comments()).hasSize(1);
assertThat(reloaded.comments().get(0).htmlText()).isEqualTo("New Comment from fake action");
diff --git a/it/it-tests/src/test/java/issue/suite/IssueBulkChangeTest.java b/it/it-tests/src/test/java/issue/suite/IssueBulkChangeTest.java
index 38c63b06e87..b1d4ca7177b 100644
--- a/it/it-tests/src/test/java/issue/suite/IssueBulkChangeTest.java
+++ b/it/it-tests/src/test/java/issue/suite/IssueBulkChangeTest.java
@@ -22,7 +22,6 @@ package issue.suite;
import com.google.common.base.Function;
import com.google.common.collect.FluentIterable;
import com.sonar.orchestrator.Orchestrator;
-import com.sonar.orchestrator.build.SonarRunner;
import com.sonar.orchestrator.locator.FileLocation;
import java.util.List;
import org.junit.Before;
@@ -34,14 +33,14 @@ import org.sonar.wsclient.issue.ActionPlanClient;
import org.sonar.wsclient.issue.BulkChange;
import org.sonar.wsclient.issue.BulkChangeQuery;
import org.sonar.wsclient.issue.Issue;
-import org.sonar.wsclient.issue.IssueClient;
-import org.sonar.wsclient.issue.IssueQuery;
import org.sonar.wsclient.issue.NewActionPlan;
import util.ItUtils;
import static issue.suite.IssueTestSuite.ORCHESTRATOR;
+import static issue.suite.IssueTestSuite.adminIssueClient;
+import static issue.suite.IssueTestSuite.issueClient;
import static org.assertj.core.api.Assertions.assertThat;
-import static util.ItUtils.projectDir;
+import static util.ItUtils.runProjectAnalysis;
/**
* SONAR-4421
@@ -90,7 +89,7 @@ public class IssueBulkChangeTest {
BulkChange bulkChange = buldChangeAssigneeOfIssues(issueKeys, "admin");
assertThat(bulkChange.totalIssuesChanged()).isEqualTo(BULK_EDITED_ISSUE_COUNT);
- for (Issue issue : searchIssues(issueKeys)) {
+ for (Issue issue : IssueTestSuite.searchIssues(issueKeys)) {
assertThat(issue.assignee()).isEqualTo("admin");
}
}
@@ -112,7 +111,7 @@ public class IssueBulkChangeTest {
);
assertThat(bulkChange.totalIssuesChanged()).isEqualTo(BULK_EDITED_ISSUE_COUNT);
- for (Issue issue : searchIssues(issueKeys)) {
+ for (Issue issue : IssueTestSuite.searchIssues(issueKeys)) {
assertThat(issue.actionPlan()).isEqualTo(newActionPlan.key());
}
}
@@ -133,7 +132,7 @@ public class IssueBulkChangeTest {
);
assertThat(bulkChange.totalIssuesChanged()).isEqualTo(BULK_EDITED_ISSUE_COUNT);
- for (Issue issue : searchIssues(issueKeys, true)) {
+ for (Issue issue : IssueTestSuite.searchIssues(issueKeys, true)) {
assertThat(issue.comments()).hasSize(1);
assertThat(issue.comments().get(0).htmlText()).isEqualTo(COMMENT_AS_HTML);
}
@@ -157,7 +156,7 @@ public class IssueBulkChangeTest {
);
assertThat(bulkChange.totalIssuesChanged()).isEqualTo(BULK_EDITED_ISSUE_COUNT);
- for (Issue issue : searchIssues(issueKeys, true)) {
+ for (Issue issue : IssueTestSuite.searchIssues(issueKeys, true)) {
assertThat(issue.status()).isEqualTo("CONFIRMED");
assertThat(issue.assignee()).isEqualTo("admin");
assertThat(issue.severity()).isEqualTo(newSeverity);
@@ -228,7 +227,7 @@ public class IssueBulkChangeTest {
String[] issueKeys = searchIssueKeys(nbIssues);
// Confirm an issue
- adminIssueClient().doTransition(searchIssues().iterator().next().key(), "confirm");
+ adminIssueClient().doTransition(IssueTestSuite.searchIssues().iterator().next().key(), "confirm");
// Apply a bulk change on unconfirm transition
BulkChangeQuery query = (BulkChangeQuery.create()
@@ -241,7 +240,7 @@ public class IssueBulkChangeTest {
assertThat(bulkChange.totalIssuesChanged()).isEqualTo(1);
int nbIssuesWithComment = 0;
- for (Issue issue : searchIssues(issueKeys, true)) {
+ for (Issue issue : IssueTestSuite.searchIssues(issueKeys, true)) {
if (!issue.comments().isEmpty()) {
nbIssuesWithComment++;
}
@@ -254,17 +253,17 @@ public class IssueBulkChangeTest {
orchestrator.getServer().restoreProfile(FileLocation.ofClasspath("/issue/suite/IssueBulkChangeTest/one-issue-per-line-profile.xml"));
orchestrator.getServer().provisionProject("sample", "Sample");
orchestrator.getServer().associateProjectToQualityProfile("sample", "xoo", "one-issue-per-line");
- orchestrator.executeBuild(SonarRunner.create(projectDir("shared/xoo-sample")));
+ runProjectAnalysis(orchestrator, "shared/xoo-sample");
}
private static void assertIssueSeverity(String[] issueKeys, String expectedSeverity) {
- for (Issue issue : searchIssues(issueKeys)) {
+ for (Issue issue : IssueTestSuite.searchIssues(issueKeys)) {
assertThat(issue.severity()).isEqualTo(expectedSeverity);
}
}
private static void assertIssueStatus(String[] issueKeys, String expectedStatus) {
- for (Issue issue : searchIssues(issueKeys)) {
+ for (Issue issue : IssueTestSuite.searchIssues(issueKeys)) {
assertThat(issue.status()).isEqualTo(expectedStatus);
}
}
@@ -315,36 +314,8 @@ public class IssueBulkChangeTest {
.toArray(String.class);
}
- private static List<Issue> searchIssues(String... issueKeys) {
- return searchIssues(issueKeys, false);
- }
-
- private static List<Issue> searchIssues(String[] issueKeys, boolean withComments) {
- IssueQuery query = IssueQuery.create().issues(issueKeys);
- if (withComments) {
- query.urlParams().put("additionalFields", "comments");
- }
- return searchIssues(query);
- }
-
- private static List<Issue> searchIssues() {
- return searchIssues(IssueQuery.create());
- }
-
private static String[] searchIssueKeys(int limit) {
- return getIssueKeys(searchIssues(), limit);
- }
-
- private static List<Issue> searchIssues(IssueQuery issueQuery) {
- return issueClient().find(issueQuery).list();
- }
-
- private static IssueClient issueClient() {
- return orchestrator.getServer().wsClient().issueClient();
- }
-
- private static IssueClient adminIssueClient() {
- return orchestrator.getServer().adminWsClient().issueClient();
+ return getIssueKeys(IssueTestSuite.searchIssues(), limit);
}
private static ActionPlanClient adminActionPlanClient() {
diff --git a/it/it-tests/src/test/java/issue/suite/IssueChangelogTest.java b/it/it-tests/src/test/java/issue/suite/IssueChangelogTest.java
index 199b6f6a2a1..a8b20a5f90f 100644
--- a/it/it-tests/src/test/java/issue/suite/IssueChangelogTest.java
+++ b/it/it-tests/src/test/java/issue/suite/IssueChangelogTest.java
@@ -29,12 +29,13 @@ 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 issue.suite.IssueTestSuite.ORCHESTRATOR;
+import static issue.suite.IssueTestSuite.adminIssueClient;
+import static issue.suite.IssueTestSuite.issueClient;
import static org.assertj.core.api.Assertions.assertThat;
-import static util.ItUtils.projectDir;
+import static util.ItUtils.runProjectAnalysis;
public class IssueChangelogTest {
@@ -50,8 +51,7 @@ public class IssueChangelogTest {
orchestrator.getServer().restoreProfile(FileLocation.ofClasspath("/issue/suite/IssueChangelogTest/one-issue-per-line-profile.xml"));
orchestrator.getServer().provisionProject("sample", "Sample");
orchestrator.getServer().associateProjectToQualityProfile("sample", "xoo", "one-issue-per-line");
- scan = SonarRunner.create(projectDir("shared/xoo-sample"));
- orchestrator.executeBuild(scan);
+ scan = runProjectAnalysis(orchestrator, "shared/xoo-sample");
issue = searchRandomIssue();
}
@@ -131,11 +131,4 @@ public class IssueChangelogTest {
return issueClient().changes(issueKey);
}
- private static IssueClient issueClient() {
- return orchestrator.getServer().wsClient().issueClient();
- }
-
- private static IssueClient adminIssueClient() {
- return orchestrator.getServer().adminWsClient().issueClient();
- }
}
diff --git a/it/it-tests/src/test/java/issue/suite/IssueTestSuite.java b/it/it-tests/src/test/java/issue/suite/IssueTestSuite.java
index ca2a494b6ae..5f730418629 100644
--- a/it/it-tests/src/test/java/issue/suite/IssueTestSuite.java
+++ b/it/it-tests/src/test/java/issue/suite/IssueTestSuite.java
@@ -56,14 +56,33 @@ public class IssueTestSuite {
return issueClient().find(issueQuery);
}
- static List<Issue> searchIssues(IssueQuery issueQuery) {
- return search(issueQuery).list();
- }
-
static Issue searchIssueByKey(String issueKey) {
List<Issue> issues = searchIssues(IssueQuery.create().issues(issueKey));
assertThat(issues).hasSize(1);
return issues.get(0);
}
+ static List<Issue> searchIssues(String... issueKeys) {
+ return searchIssues(issueKeys, false);
+ }
+
+ static List<Issue> searchIssues(String issueKey, boolean withComments) {
+ return searchIssues(new String[] { issueKey }, withComments);
+ }
+
+ static List<Issue> searchIssues(String[] issueKeys, boolean withComments) {
+ IssueQuery query = IssueQuery.create().issues(issueKeys);
+ if (withComments) {
+ query.urlParams().put("additionalFields", "comments");
+ }
+ return searchIssues(query);
+ }
+
+ static List<Issue> searchIssues() {
+ return searchIssues(IssueQuery.create());
+ }
+
+ static List<Issue> searchIssues(IssueQuery issueQuery) {
+ return issueClient().find(issueQuery).list();
+ }
}
diff --git a/it/it-tests/src/test/java/util/ItUtils.java b/it/it-tests/src/test/java/util/ItUtils.java
index 4cb4df2c045..b3cee3b3561 100644
--- a/it/it-tests/src/test/java/util/ItUtils.java
+++ b/it/it-tests/src/test/java/util/ItUtils.java
@@ -4,33 +4,34 @@ package util;/*
* mailto:contact AT sonarsource DOT com
*/
+import com.google.common.base.Supplier;
+import com.google.common.base.Suppliers;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Iterables;
import com.sonar.orchestrator.Orchestrator;
import com.sonar.orchestrator.build.BuildResult;
import com.sonar.orchestrator.build.SonarRunner;
+import com.sonar.orchestrator.locator.FileLocation;
+import java.io.File;
+import java.io.IOException;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+import javax.annotation.Nullable;
+import org.apache.commons.io.FileUtils;
import org.json.simple.JSONArray;
import org.json.simple.JSONObject;
import org.json.simple.JSONValue;
-import com.google.common.base.Supplier;
-import com.google.common.base.Suppliers;
-import com.sonar.orchestrator.locator.FileLocation;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
+import org.sonar.wsclient.base.HttpException;
+import org.sonar.wsclient.services.PropertyDeleteQuery;
+import org.sonar.wsclient.services.PropertyUpdateQuery;
import static com.google.common.collect.FluentIterable.from;
import static java.util.Arrays.asList;
-import static org.assertj.core.api.Assertions.fail;
-
import static org.assertj.core.api.Assertions.assertThat;
-import org.apache.commons.io.FileUtils;
-import org.sonar.wsclient.base.HttpException;
+import static org.assertj.core.api.Assertions.fail;
public class ItUtils {
@@ -92,7 +93,7 @@ public class ItUtils {
/**
* Locate the pom file of a sample project
*
- * @param relativePath project path related to the directory it/it-projects, for example "qualitygate/xoo-sample"
+ * @param projectName project path related to the directory it/it-projects, for example "qualitygate/xoo-sample"
*/
public static File projectPom(String projectName) {
File pom = new File(projectDir(projectName), "pom.xml");
@@ -136,19 +137,37 @@ public class ItUtils {
return count;
}
- public static void runProjectAnalysis(Orchestrator orchestrator, String projectRelativePath, String... properties) {
+ public static SonarRunner runVerboseProjectAnalysis(Orchestrator orchestrator, String projectRelativePath, String... properties) {
+ return runProjectAnalysis(orchestrator, projectRelativePath, true, properties);
+ }
+
+ public static SonarRunner runProjectAnalysis(Orchestrator orchestrator, String projectRelativePath, String... properties) {
+ return runProjectAnalysis(orchestrator, projectRelativePath, false, properties);
+ }
+
+ private static SonarRunner runProjectAnalysis(Orchestrator orchestrator, String projectRelativePath, boolean enableDebugLogs, String... properties) {
SonarRunner sonarRunner = SonarRunner.create(projectDir(projectRelativePath));
ImmutableMap.Builder<String, String> builder = ImmutableMap.builder();
- for (int i = 0; i < properties.length; i+=2) {
- builder.put(properties[i], properties[i+1]);
+ for (int i = 0; i < properties.length; i += 2) {
+ builder.put(properties[i], properties[i + 1]);
+ }
+ SonarRunner scan = sonarRunner.setDebugLogs(enableDebugLogs).setProperties(builder.build());
+ orchestrator.executeBuild(scan);
+ return scan;
+ }
+
+ public static void setServerProperty(Orchestrator orchestrator, String key, @Nullable String value) {
+ if (value == null) {
+ orchestrator.getServer().getAdminWsClient().delete(new PropertyDeleteQuery(key));
+ } else {
+ orchestrator.getServer().getAdminWsClient().update(new PropertyUpdateQuery().setKey(key).setValue(value));
}
- orchestrator.executeBuild(sonarRunner.setDebugLogs(true).setProperties(builder.build()));
}
/**
* Concatenates a vararg to a String array.
*
- * Useful when using {@link #runProjectAnalysis(Orchestrator, String, String...)}, eg.:
+ * Useful when using {@link #runVerboseProjectAnalysis(Orchestrator, String, String...)}, eg.:
* <pre>
* ItUtils.runProjectAnalysis(orchestrator, "project_name",
* ItUtils.concat(properties, "sonar.scm.disabled", "false")