diff options
author | Simon Brandhof <simon.brandhof@sonarsource.com> | 2017-11-23 22:01:21 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-11-23 22:01:21 +0100 |
commit | 4eb8c7f8657ebe5544fcd2283145d175713ab567 (patch) | |
tree | dd9e4078d15e052578874234bbb3761e20a448e4 /tests | |
parent | e02d9d4a80eeb4f5cff53dd057e86df2c48d4f7e (diff) | |
download | sonarqube-4eb8c7f8657ebe5544fcd2283145d175713ab567.tar.gz sonarqube-4eb8c7f8657ebe5544fcd2283145d175713ab567.zip |
Support build of SonarQube with JDK 9
Diffstat (limited to 'tests')
4 files changed, 36 insertions, 15 deletions
diff --git a/tests/pom.xml b/tests/pom.xml index c36c4aaee20..535ee0bcc2a 100644 --- a/tests/pom.xml +++ b/tests/pom.xml @@ -83,8 +83,8 @@ <artifactId>assertj-core</artifactId> </dependency> <dependency> - <groupId>org.hamcrest</groupId> - <artifactId>hamcrest-all</artifactId> + <groupId>org.assertj</groupId> + <artifactId>assertj-guava</artifactId> </dependency> <dependency> <groupId>com.googlecode.json-simple</groupId> diff --git a/tests/src/test/java/org/sonarqube/tests/plugins/checks/JavascriptCheck.java b/tests/src/test/java/org/sonarqube/tests/plugins/checks/JavascriptCheck.java index 40f74d64943..7fffd855060 100644 --- a/tests/src/test/java/org/sonarqube/tests/plugins/checks/JavascriptCheck.java +++ b/tests/src/test/java/org/sonarqube/tests/plugins/checks/JavascriptCheck.java @@ -30,6 +30,6 @@ public class JavascriptCheck implements Check { validation.mustHaveComments(SRC_DIR); validation.mustHaveComplexity(SRC_DIR); validation.mustHaveIssues(SRC_DIR + "/HasIssues.js"); - validation.mustHaveMeasuresGreaterThan(SRC_DIR + "/Person.js", 0, "coverage"); + validation.mustHaveMeasuresGreaterThanOrEquals(SRC_DIR + "/Person.js", 0, "coverage"); } } diff --git a/tests/src/test/java/org/sonarqube/tests/plugins/checks/Validation.java b/tests/src/test/java/org/sonarqube/tests/plugins/checks/Validation.java index 9b2f9a4ea21..0c1a76dba73 100644 --- a/tests/src/test/java/org/sonarqube/tests/plugins/checks/Validation.java +++ b/tests/src/test/java/org/sonarqube/tests/plugins/checks/Validation.java @@ -22,18 +22,19 @@ package org.sonarqube.tests.plugins.checks; import com.google.common.base.Joiner; import com.google.gson.Gson; import com.sonar.orchestrator.Orchestrator; -import org.sonarqube.tests.plugins.Project; import java.io.File; import java.util.List; import java.util.Map; -import org.hamcrest.Matchers; +import org.hamcrest.Description; +import org.hamcrest.TypeSafeMatcher; import org.junit.rules.ErrorCollector; +import org.sonarqube.tests.plugins.Project; import org.sonarqube.ws.client.GetRequest; import org.sonarqube.ws.client.WsResponse; import static java.util.Arrays.asList; -import static org.hamcrest.CoreMatchers.is; -import static org.hamcrest.CoreMatchers.notNullValue; +import static org.hamcrest.core.Is.is; +import static org.hamcrest.core.IsNull.notNullValue; import static util.ItUtils.getMeasuresAsDoubleByMetricKey; import static util.ItUtils.newAdminWsClient; @@ -57,22 +58,22 @@ public class Validation { public void mustHaveIssues(String path) { // TODO use the WS api/issues - mustHaveMeasuresGreaterThan(path, 1, "violations"); + mustHaveMeasuresGreaterThanOrEquals(path, 1, "violations"); } public void mustHaveComments(String path) { - mustHaveMeasuresGreaterThan(path, 0, "comment_lines", "comment_lines_density"); + mustHaveMeasuresGreaterThanOrEquals(path, 0, "comment_lines", "comment_lines_density"); } public void mustHaveComplexity(String path) { - mustHaveMeasuresGreaterThan(path, 0, "complexity"); + mustHaveMeasuresGreaterThanOrEquals(path, 0, "complexity"); } public void mustHaveSize(String path) { - mustHaveMeasuresGreaterThan(path, 0, "ncloc", "lines"); + mustHaveMeasuresGreaterThanOrEquals(path, 0, "ncloc", "lines"); } - public void mustHaveMeasuresGreaterThan(String path, int min, String... metricKeys) { + public void mustHaveMeasuresGreaterThanOrEquals(String path, int min, String... metricKeys) { for (String filePath : toFiles(path)) { fileMustHaveMeasures(filePath, metricKeys, min); } @@ -87,7 +88,17 @@ public class Validation { Double measure = measures.get(metricKey); errorCollector.checkThat("Measure " + metricKey + " is set on file " + filePath, measure, notNullValue()); if (measure != null) { - errorCollector.checkThat("Measure " + metricKey + " is positive on file " + filePath, measure.intValue(), Matchers.greaterThanOrEqualTo(min)); + errorCollector.checkThat("Measure " + metricKey + " is positive on file " + filePath, measure.intValue(), new TypeSafeMatcher<Integer>() { + @Override + protected boolean matchesSafely(Integer item) { + return item >= min; + } + + @Override + public void describeTo(Description description) { + description.appendText(metricKey).appendValue(min); + } + }); } } } @@ -111,7 +122,17 @@ public class Validation { errorCollector.checkThat("Source is set on file " + filePath, response.isSuccessful(), is(true)); Sources source = Sources.parse(response.content()); if (source != null) { - errorCollector.checkThat("Source is empty on file " + filePath, source.getSources().size(), Matchers.greaterThanOrEqualTo(minLines)); + errorCollector.checkThat("Source is empty on file " + filePath, source.getSources().size(), new TypeSafeMatcher<Integer>() { + @Override + protected boolean matchesSafely(Integer item) { + return item >= minLines; + } + + @Override + public void describeTo(Description description) { + description.appendValue(minLines); + } + }); } } } diff --git a/tests/src/test/java/util/ItUtils.java b/tests/src/test/java/util/ItUtils.java index f663c7d6b94..2e36b573136 100644 --- a/tests/src/test/java/util/ItUtils.java +++ b/tests/src/test/java/util/ItUtils.java @@ -335,7 +335,7 @@ public class ItUtils { private static Stream<Measure> getStreamMeasures(Orchestrator orchestrator, String componentKey, String... metricKeys) { return newWsClient(orchestrator).measures().component(new ComponentWsRequest() - .setComponentKey(componentKey) + .setComponent(componentKey) .setMetricKeys(asList(metricKeys))) .getComponent().getMeasuresList() .stream(); |