diff options
author | Simon Brandhof <simon.brandhof@sonarsource.com> | 2017-02-19 13:07:11 +0100 |
---|---|---|
committer | Simon Brandhof <simon.brandhof@sonarsource.com> | 2017-02-19 13:07:11 +0100 |
commit | 4dcf22377c7823584f0d9d7dbb85641980245fd8 (patch) | |
tree | 28594d8d59c4f64deb7e3aa6f06f48b0e737cdb1 /sonar-core | |
parent | c3ae1aa643eb9edb168016bfadfbab3af9024962 (diff) | |
download | sonarqube-4dcf22377c7823584f0d9d7dbb85641980245fd8.tar.gz sonarqube-4dcf22377c7823584f0d9d7dbb85641980245fd8.zip |
Clean-up sonar-testing-harness dependencies
and decrease usages of Hamcrest
Diffstat (limited to 'sonar-core')
-rw-r--r-- | sonar-core/pom.xml | 20 | ||||
-rw-r--r-- | sonar-core/src/test/java/org/sonar/core/i18n/RuleI18nManagerTest.java | 23 | ||||
-rw-r--r-- | sonar-core/src/test/java/org/sonar/core/util/stream/CollectorsTest.java | 20 |
3 files changed, 43 insertions, 20 deletions
diff --git a/sonar-core/pom.xml b/sonar-core/pom.xml index 7f7f817bd5a..81b868c6576 100644 --- a/sonar-core/pom.xml +++ b/sonar-core/pom.xml @@ -82,6 +82,26 @@ <!-- tests --> <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.assertj</groupId> + <artifactId>assertj-core</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>com.tngtech.java</groupId> + <artifactId>junit-dataprovider</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.mockito</groupId> + <artifactId>mockito-core</artifactId> + <scope>test</scope> + </dependency> + <dependency> <groupId>${project.groupId}</groupId> <artifactId>sonar-testing-harness</artifactId> <scope>test</scope> diff --git a/sonar-core/src/test/java/org/sonar/core/i18n/RuleI18nManagerTest.java b/sonar-core/src/test/java/org/sonar/core/i18n/RuleI18nManagerTest.java index 65319c55858..c30ab6bf991 100644 --- a/sonar-core/src/test/java/org/sonar/core/i18n/RuleI18nManagerTest.java +++ b/sonar-core/src/test/java/org/sonar/core/i18n/RuleI18nManagerTest.java @@ -20,12 +20,9 @@ package org.sonar.core.i18n; import java.util.Locale; -import org.hamcrest.core.Is; import org.junit.Test; -import static org.hamcrest.Matchers.is; -import static org.hamcrest.Matchers.nullValue; -import static org.junit.Assert.assertThat; +import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verifyNoMoreInteractions; @@ -67,7 +64,7 @@ public class RuleI18nManagerTest { RuleI18nManager ruleI18n = new RuleI18nManager(i18n); String description = ruleI18n.getDescription("checkstyle", "com.puppycrawl.tools.checkstyle.checks.annotation.AnnotationUseStyleCheck", Locale.ENGLISH); - assertThat(description, is("Description")); + assertThat(description).isEqualTo("Description"); verify(i18n).messageFromFile(Locale.ENGLISH, "rules/checkstyle/com.puppycrawl.tools.checkstyle.checks.annotation.AnnotationUseStyleCheck.html", propertyKeyForName); verifyNoMoreInteractions(i18n); @@ -84,7 +81,7 @@ public class RuleI18nManagerTest { RuleI18nManager ruleI18n = new RuleI18nManager(i18n); String description = ruleI18n.getDescription("checkstyle", "com.puppycrawl.tools.checkstyle.checks.annotation.AnnotationUseStyleCheck", Locale.ENGLISH); - assertThat(description, is("Description")); + assertThat(description).isEqualTo("Description"); verify(i18n).messageFromFile(Locale.ENGLISH, "rules/checkstyle/com.puppycrawl.tools.checkstyle.checks.annotation.AnnotationUseStyleCheck.html", propertyKeyForName); verify(i18n).messageFromFile(Locale.ENGLISH, "com.puppycrawl.tools.checkstyle.checks.annotation.AnnotationUseStyleCheck.html", propertyKeyForName); @@ -96,21 +93,21 @@ public class RuleI18nManagerTest { DefaultI18n i18n = mock(DefaultI18n.class); RuleI18nManager ruleI18n = new RuleI18nManager(i18n); - assertThat(ruleI18n.getDescription("checkstyle", "com.puppycrawl.tools.checkstyle.checks.annotation.AnnotationUseStyleCheck", Locale.ENGLISH), nullValue()); + assertThat(ruleI18n.getDescription("checkstyle", "com.puppycrawl.tools.checkstyle.checks.annotation.AnnotationUseStyleCheck", Locale.ENGLISH)).isNull(); } @Test public void shouldBeRuleKey() { - assertThat(RuleI18nManager.isRuleProperty("rule.checkstyle.com.puppycrawl.tools.checkstyle.checks.annotation.AnnotationUseStyleCheck.name"), Is.is(true)); - assertThat(RuleI18nManager.isRuleProperty("rule.pmd.Header.name"), Is.is(true)); + assertThat(RuleI18nManager.isRuleProperty("rule.checkstyle.com.puppycrawl.tools.checkstyle.checks.annotation.AnnotationUseStyleCheck.name")).isTrue(); + assertThat(RuleI18nManager.isRuleProperty("rule.pmd.Header.name")).isTrue(); } @Test public void shouldNotBeRuleKey() { // this is the parameter "name" - assertThat(RuleI18nManager.isRuleProperty("rule.checkstyle.com.puppycrawl.tools.checkstyle.checks.annotation.AnnotationUseStyleCheck.param.name"), Is.is(false)); - assertThat(RuleI18nManager.isRuleProperty("by"), Is.is(false)); - assertThat(RuleI18nManager.isRuleProperty("something.else"), Is.is(false)); - assertThat(RuleI18nManager.isRuleProperty("checkstyle.page.name"), Is.is(false)); + assertThat(RuleI18nManager.isRuleProperty("rule.checkstyle.com.puppycrawl.tools.checkstyle.checks.annotation.AnnotationUseStyleCheck.param.name")).isFalse(); + assertThat(RuleI18nManager.isRuleProperty("by")).isFalse(); + assertThat(RuleI18nManager.isRuleProperty("something.else")).isFalse(); + assertThat(RuleI18nManager.isRuleProperty("checkstyle.page.name")).isFalse(); } } diff --git a/sonar-core/src/test/java/org/sonar/core/util/stream/CollectorsTest.java b/sonar-core/src/test/java/org/sonar/core/util/stream/CollectorsTest.java index 73230684be1..d15ae533cf6 100644 --- a/sonar-core/src/test/java/org/sonar/core/util/stream/CollectorsTest.java +++ b/sonar-core/src/test/java/org/sonar/core/util/stream/CollectorsTest.java @@ -25,6 +25,7 @@ import com.google.common.collect.ImmutableSet; import com.google.common.collect.Multimap; import java.util.ArrayList; import java.util.Arrays; +import java.util.Collection; import java.util.Collections; import java.util.HashSet; import java.util.List; @@ -39,7 +40,6 @@ import org.junit.rules.ExpectedException; import static java.util.function.Function.identity; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.entry; -import static org.assertj.guava.api.Assertions.assertThat; import static org.sonar.core.util.stream.Collectors.index; import static org.sonar.core.util.stream.Collectors.join; import static org.sonar.core.util.stream.Collectors.toArrayList; @@ -343,8 +343,8 @@ public class CollectorsTest { @Test public void index_empty_stream_returns_empty_map() { - assertThat(Collections.<MyObj>emptyList().stream().collect(index(MyObj::getId))).isEmpty(); - assertThat(Collections.<MyObj>emptyList().stream().collect(index(MyObj::getId, MyObj::getText))).isEmpty(); + assertThat(Collections.<MyObj>emptyList().stream().collect(index(MyObj::getId)).size()).isEqualTo(0); + assertThat(Collections.<MyObj>emptyList().stream().collect(index(MyObj::getId, MyObj::getText)).size()).isEqualTo(0); } @Test @@ -414,16 +414,22 @@ public class CollectorsTest { public void index_returns_multimap() { Multimap<Integer, MyObj> multimap = LIST.stream().collect(index(MyObj::getId)); - assertThat(multimap).hasSize(3); - assertThat(multimap).contains(entry(1, MY_OBJ_1_A), entry(2, MY_OBJ_2_B), entry(3, MY_OBJ_3_C)); + assertThat(multimap.size()).isEqualTo(3); + Map<Integer, Collection<MyObj>> map = multimap.asMap(); + assertThat(map.get(1)).containsOnly(MY_OBJ_1_A); + assertThat(map.get(2)).containsOnly(MY_OBJ_2_B); + assertThat(map.get(3)).containsOnly(MY_OBJ_3_C); } @Test public void index_with_valueFunction_returns_multimap() { Multimap<Integer, String> multimap = LIST.stream().collect(index(MyObj::getId, MyObj::getText)); - assertThat(multimap).hasSize(3); - assertThat(multimap).contains(entry(1, "A"), entry(2, "B"), entry(3, "C")); + assertThat(multimap.size()).isEqualTo(3); + Map<Integer, Collection<String>> map = multimap.asMap(); + assertThat(map.get(1)).containsOnly("A"); + assertThat(map.get(2)).containsOnly("B"); + assertThat(map.get(3)).containsOnly("C"); } @Test |