diff options
author | Pierre <pierre.guillot@sonarsource.com> | 2020-12-07 15:44:01 +0100 |
---|---|---|
committer | sonartech <sonartech@sonarsource.com> | 2020-12-09 20:07:20 +0000 |
commit | 91c611fe568a94170adb174e63940db060932bb8 (patch) | |
tree | e3772597dd8d36fade5235f282542178101b08e4 /sonar-plugin-api | |
parent | 5f1b82343cb99caae29ce07f316b3b6b556c8b33 (diff) | |
download | sonarqube-91c611fe568a94170adb174e63940db060932bb8.tar.gz sonarqube-91c611fe568a94170adb174e63940db060932bb8.zip |
fix assertions on incompatible types on overall code
Diffstat (limited to 'sonar-plugin-api')
4 files changed, 12 insertions, 16 deletions
diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/batch/scm/BlameLineTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/batch/scm/BlameLineTest.java index 458323bfbd2..622615132aa 100644 --- a/sonar-plugin-api/src/test/java/org/sonar/api/batch/scm/BlameLineTest.java +++ b/sonar-plugin-api/src/test/java/org/sonar/api/batch/scm/BlameLineTest.java @@ -22,13 +22,14 @@ package org.sonar.api.batch.scm; import org.junit.Test; import java.util.Date; +import org.junit.jupiter.api.Assertions; import static org.assertj.core.api.Assertions.assertThat; public class BlameLineTest { @Test - public void testBlameLine() { + public void testEqualBlameLine() { Date date = new Date(); BlameLine line1 = new BlameLine().date(date).revision("1").author("foo"); BlameLine line1b = new BlameLine().date(date).revision("1").author("foo"); @@ -38,12 +39,11 @@ public class BlameLineTest { assertThat(line1.date()).isEqualTo(date); assertThat(line1.revision()).isEqualTo("1"); - assertThat(line1).isEqualTo(line1); + Assertions.assertEquals(line1, line1); assertThat(line1).isNotEqualTo(null); assertThat(line1).isEqualTo(line1b); assertThat(line1.hashCode()).isEqualTo(line1b.hashCode()); assertThat(line1).isNotEqualTo(line2); - assertThat(line1).isNotEqualTo("foo"); assertThat(line1.toString()).contains("revision=1,author=foo"); } diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/config/CategoryTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/config/CategoryTest.java index d95da63a476..2f86737ee1a 100644 --- a/sonar-plugin-api/src/test/java/org/sonar/api/config/CategoryTest.java +++ b/sonar-plugin-api/src/test/java/org/sonar/api/config/CategoryTest.java @@ -30,7 +30,7 @@ public class CategoryTest { assertThat(new Category("Licenses")).isEqualTo(new Category("licenses")); // Just to raise coverage - assertThat(new Category("Licenses")).isNotEqualTo("Licenses"); + assertThat(new Category("Licenses").key()).isNotEqualTo("Licenses"); } @Test diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/server/profile/BuiltInQualityProfilesDefinitionTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/server/profile/BuiltInQualityProfilesDefinitionTest.java index 0ca116e2626..53c407de4bc 100644 --- a/sonar-plugin-api/src/test/java/org/sonar/api/server/profile/BuiltInQualityProfilesDefinitionTest.java +++ b/sonar-plugin-api/src/test/java/org/sonar/api/server/profile/BuiltInQualityProfilesDefinitionTest.java @@ -23,6 +23,7 @@ import java.util.Map; import java.util.function.Consumer; import org.junit.Rule; import org.junit.Test; +import org.junit.jupiter.api.Assertions; import org.junit.rules.ExpectedException; import org.sonar.api.rule.RuleKey; import org.sonar.api.server.profile.BuiltInQualityProfilesDefinition.BuiltInQualityProfile; @@ -56,7 +57,7 @@ public class BuiltInQualityProfilesDefinitionTest { } @Test - public void sanityCheck() { + public void sanityEqualCheck() { Map<String, Map<String, BuiltInQualityProfile>> profiles = define(c -> { NewBuiltInQualityProfile profile1 = c.createBuiltInQualityProfile("Foo1", "xoo"); NewBuiltInActiveRule rule = profile1.activateRule("repo", "rule"); @@ -65,9 +66,9 @@ public class BuiltInQualityProfilesDefinitionTest { profile2.done(); NewBuiltInQualityProfile profile3 = c.createBuiltInQualityProfile("Foo1", "xoo2"); profile3.done(); - assertThat(profile1).isEqualTo(profile1); + Assertions.assertEquals(profile1, profile1); assertThat(profile1).isNotEqualTo(null); - assertThat(profile1).isNotEqualTo("Foo"); + assertThat(profile1.name()).isNotEqualTo("Foo"); assertThat(profile1).isNotEqualTo(profile2); assertThat(profile1).isNotEqualTo(profile3); assertThat(profile1.hashCode()).isNotEqualTo(profile2.hashCode()); @@ -79,7 +80,7 @@ public class BuiltInQualityProfilesDefinitionTest { BuiltInQualityProfile profile3 = profiles.get("xoo2").get("Foo1"); assertThat(profile1).isEqualTo(profile1); assertThat(profile1).isNotEqualTo(null); - assertThat(profile1).isNotEqualTo("Foo"); + assertThat(profile1.name()).isNotEqualTo("Foo"); assertThat(profile1).isNotEqualTo(profile2); assertThat(profile1).isNotEqualTo(profile3); assertThat(profile1.hashCode()).isNotEqualTo(profile2.hashCode()); diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/server/rule/RulesDefinitionTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/server/rule/RulesDefinitionTest.java index 3c8f2c1cd7c..4fcf716522e 100644 --- a/sonar-plugin-api/src/test/java/org/sonar/api/server/rule/RulesDefinitionTest.java +++ b/sonar-plugin-api/src/test/java/org/sonar/api/server/rule/RulesDefinitionTest.java @@ -29,9 +29,11 @@ import java.net.URL; import java.util.List; import java.util.Set; import java.util.stream.Collectors; +import org.junit.Assert; import org.junit.Assume; import org.junit.Rule; import org.junit.Test; +import org.junit.jupiter.api.Assertions; import org.junit.rules.ExpectedException; import org.junit.runner.RunWith; import org.sonar.api.rule.RuleKey; @@ -45,6 +47,7 @@ import org.sonar.api.impl.server.RulesDefinitionContext; import static org.assertj.core.api.Assertions.assertThat; import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.assertEquals; @RunWith(DataProviderRunner.class) public class RulesDefinitionTest { @@ -135,10 +138,6 @@ public class RulesDefinitionTest { RulesDefinition.Rule otherRule = repo.rule("ABC"); assertThat(otherRule.htmlDescription()).isNull(); assertThat(otherRule.markdownDescription()).isEqualTo("ABC"); - - // test equals() and hashCode() - assertThat(rule).isEqualTo(rule).isNotEqualTo(otherRule).isNotEqualTo("NPE").isNotEqualTo(null); - assertThat(rule.hashCode()).isEqualTo(rule.hashCode()); } @Test @@ -221,10 +220,6 @@ public class RulesDefinitionTest { RulesDefinition.Rule otherRule = repo.rule("ABC"); assertThat(otherRule.htmlDescription()).isNull(); assertThat(otherRule.markdownDescription()).isEqualTo("ABC"); - - // test equals() and hashCode() - assertThat(rule).isEqualTo(rule).isNotEqualTo(otherRule).isNotEqualTo("NPE").isNotEqualTo(null); - assertThat(rule.hashCode()).isEqualTo(rule.hashCode()); } @Test |