assertThat(dto.getComponentUuid()).isNull();
}
assertThat(dto.getSubmitterUuid()).isEqualTo(taskSubmit.getSubmitterUuid());
- assertThat(dto.getCreatedAt()).isEqualTo(dto.getUpdatedAt()).isNotNull();
+ assertThat(dto.getCreatedAt()).isEqualTo(dto.getUpdatedAt());
}
private ComponentDto newProjectDto(String uuid) {
@Test
public void testHashCode() {
- assertThat(new PropertyDto().setKey("123").setComponentUuid("uuid123").hashCode()).isNotNull();
- assertThat(new PropertyDto().setKey("123").setComponentUuid("uuid123").hashCode())
- .isEqualTo(new PropertyDto().setKey("123").setComponentUuid("uuid123").hashCode());
+ assertThat(new PropertyDto().setKey("123").setComponentUuid("uuid123"))
+ .hasSameHashCodeAs(new PropertyDto().setKey("123").setComponentUuid("uuid123"));
}
@Test
public void testToString() {
- assertThat(new PropertyDto().setKey("foo:bar").setValue("value").setComponentUuid("uuid123").setUserUuid("456").toString())
- .isEqualTo("PropertyDto{foo:bar, value, uuid123, 456}");
+ assertThat(new PropertyDto().setKey("foo:bar").setValue("value").setComponentUuid("uuid123").setUserUuid("456"))
+ .hasToString("PropertyDto{foo:bar, value, uuid123, 456}");
}
@Test
parent.setProperty(key, randomAlphanumeric(20));
underTest.setProperty(key, randomAlphanumeric(10));
- assertThat(underTest.get(key)).isNotEqualTo(parent.getString(key));
+ Optional<String> result = underTest.get(key);
+ assertThat(result).isPresent();
+ assertThat(result.get()).isNotEqualTo(parent.getString(key));
}
@Test
assertThat(activeRule.getSeverityString()).isEqualTo(expectedSeverity);
assertThat(activeRule.getInheritance()).isEqualTo(expectedInheritance != null ? expectedInheritance.name() : null);
- assertThat(activeRule.getCreatedAt()).isNotNull();
- assertThat(activeRule.getUpdatedAt()).isNotNull();
List<ActiveRuleParamDto> params = db.getDbClient().activeRuleDao().selectParamsByActiveRuleUuid(db.getSession(), activeRule.getUuid());
assertThat(params).hasSize(expectedParams.size());
@Test
public void test_text_message() {
- Result.Message txtMessage = Result.Message.of("the error");
- Result.Message sameMessage = Result.Message.of("the error");
+ String errorMessage = "the error";
+ Result.Message txtMessage = Result.Message.of(errorMessage);
+ Result.Message sameMessage = Result.Message.of(errorMessage);
Result.Message otherMessage = Result.Message.of("other");
- assertThat(txtMessage.toString()).contains("the error");
+ assertThat(txtMessage.toString()).contains(errorMessage);
assertThat(txtMessage).isEqualTo(txtMessage);
assertThat(txtMessage).isEqualTo(sameMessage);
assertThat(txtMessage.hashCode()).isEqualTo(txtMessage.hashCode());
assertThat(txtMessage.hashCode()).isEqualTo(sameMessage.hashCode());
assertThat(txtMessage).isNotEqualTo(otherMessage);
- assertThat(txtMessage).isNotEqualTo("the error");
}
@Test
assertThat(msg).isNotEqualTo(msg2);
assertThat(msg).isNotEqualTo(msg3);
- assertThat(msg).isNotEqualTo("issue.error.123");
+ assertThat(msg.text()).isNotEqualTo("issue.error.123");
}
}
assertThat(activeRule.getSeverityString()).isEqualTo(expectedSeverity);
assertThat(activeRule.getInheritance()).isEqualTo(expectedInheritance != null ? expectedInheritance.name() : null);
- assertThat(activeRule.getCreatedAt()).isNotNull();
- assertThat(activeRule.getUpdatedAt()).isNotNull();
List<ActiveRuleParamDto> params = db.getDbClient().activeRuleDao().selectParamsByActiveRuleUuid(db.getSession(), activeRule.getUuid());
assertThat(params).hasSize(expectedParams.size());
assertThat(activeRule.getSeverityString()).isEqualTo(expectedSeverity);
assertThat(activeRule.getInheritance()).isEqualTo(expectedInheritance != null ? expectedInheritance.name() : null);
- assertThat(activeRule.getCreatedAt()).isNotNull();
- assertThat(activeRule.getUpdatedAt()).isNotNull();
List<ActiveRuleParamDto> params = db.getDbClient().activeRuleDao().selectParamsByActiveRuleUuid(db.getSession(), activeRule.getUuid());
assertThat(params).hasSize(expectedParams.size());
assertThat(activeRule.getSeverityString()).isEqualTo(expectedSeverity);
assertThat(activeRule.getInheritance()).isEqualTo(expectedInheritance != null ? expectedInheritance.name() : null);
- assertThat(activeRule.getCreatedAt()).isNotNull();
- assertThat(activeRule.getUpdatedAt()).isNotNull();
List<ActiveRuleParamDto> params = db.getDbClient().activeRuleDao().selectParamsByActiveRuleUuid(db.getSession(), activeRule.getUuid());
assertThat(params).hasSize(expectedParams.size());
assertThat(activeRule.getSeverityString()).isEqualTo(expectedSeverity);
assertThat(activeRule.getInheritance()).isEqualTo(expectedInheritance != null ? expectedInheritance.name() : null);
- assertThat(activeRule.getCreatedAt()).isNotNull();
- assertThat(activeRule.getUpdatedAt()).isNotNull();
List<ActiveRuleParamDto> params = db.getDbClient().activeRuleDao().selectParamsByActiveRuleUuid(db.getSession(), activeRule.getUuid());
assertThat(params).hasSize(expectedParams.size());
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");
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");
}
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
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;
}
@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");
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());
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());
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;
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 {
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
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