Extended test cases for AssertThatBooleanCondition and AssertThatObjectIsNullOrNotNull.

This commit is contained in:
Chris Hodges 2019-04-29 20:10:55 +02:00
parent 3ece81b024
commit e55acf9c74
6 changed files with 15 additions and 7 deletions

View File

@ -14,7 +14,7 @@ internal class AssertThatBooleanConditionInspectionTest : AbstractCajonTest() {
runTest {
myFixture.enableInspections(AssertThatBooleanConditionInspection::class.java)
myFixture.configureByFile("BooleanConditionBefore.java")
executeQuickFixes(myFixture, Regex.fromLiteral("Replace isEqualTo() with isTrue()"), 4)
executeQuickFixes(myFixture, Regex.fromLiteral("Replace isEqualTo() with isTrue()"), 6)
executeQuickFixes(myFixture, Regex.fromLiteral("Replace isEqualTo() with isFalse()"), 5)
executeQuickFixes(myFixture, Regex.fromLiteral("Replace isNotEqualTo() with isTrue()"), 4)
executeQuickFixes(myFixture, Regex.fromLiteral("Replace isNotEqualTo() with isFalse()"), 4)

View File

@ -14,8 +14,8 @@ internal class AssertThatObjectIsNullOrNotNullInspectionTest : AbstractCajonTest
runTest {
myFixture.enableInspections(AssertThatObjectIsNullOrNotNullInspection::class.java)
myFixture.configureByFile("ObjectIsNullOrNotNullBefore.java")
executeQuickFixes(myFixture, Regex.fromLiteral("Replace isEqualTo() with isNull()"), 3)
executeQuickFixes(myFixture, Regex.fromLiteral("Replace isNotEqualTo() with isNotNull()"), 3)
executeQuickFixes(myFixture, Regex.fromLiteral("Replace isEqualTo() with isNull()"), 4)
executeQuickFixes(myFixture, Regex.fromLiteral("Replace isNotEqualTo() with isNotNull()"), 4)
myFixture.checkResultByFile("ObjectIsNullOrNotNullAfter.java")
}
}

View File

@ -6,7 +6,7 @@ public class BooleanCondition {
boolean primitive = false;
Boolean object = Boolean.TRUE;
assertThat(primitive).isTrue();
assertThat(primitive).as("foo").isTrue();
assertThat(primitive).isFalse();
assertThat(object).isTrue();
assertThat(object).isFalse();
@ -15,7 +15,7 @@ public class BooleanCondition {
assertThat(object).isTrue();
assertThat(object).isFalse();
assertThat(primitive).isFalse();
assertThat(primitive).as("foo").isFalse();
assertThat(primitive).isTrue();
assertThat(object).isFalse();
assertThat(object).isTrue();
@ -28,5 +28,7 @@ public class BooleanCondition {
assertThat(object).isEqualTo(Boolean.TRUE && !Boolean.TRUE);
assertThat("").isEqualTo(Boolean.TRUE);
assertThat(primitive).isTrue().as("foo").isTrue().as("bar").isTrue().isFalse();
}
}

View File

@ -6,7 +6,7 @@ public class BooleanCondition {
boolean primitive = false;
Boolean object = Boolean.TRUE;
assertThat(primitive).isEqualTo(Boolean.TRUE);
assertThat(primitive).as("foo").isEqualTo(Boolean.TRUE);
assertThat(primitive).isEqualTo(Boolean.FALSE);
assertThat(object).isEqualTo(Boolean.TRUE);
assertThat(object).isEqualTo(Boolean.FALSE);
@ -15,7 +15,7 @@ public class BooleanCondition {
assertThat(object).isEqualTo(true);
assertThat(object).isEqualTo(false);
assertThat(primitive).isNotEqualTo(Boolean.TRUE);
assertThat(primitive).as("foo").isNotEqualTo(Boolean.TRUE);
assertThat(primitive).isNotEqualTo(Boolean.FALSE);
assertThat(object).isNotEqualTo(Boolean.TRUE);
assertThat(object).isNotEqualTo(Boolean.FALSE);
@ -28,5 +28,7 @@ public class BooleanCondition {
assertThat(object).isEqualTo(Boolean.TRUE && !Boolean.TRUE);
assertThat("").isEqualTo(Boolean.TRUE);
assertThat(primitive).isEqualTo(Boolean.TRUE).as("foo").isEqualTo(true).as("bar").isTrue().isFalse();
}
}

View File

@ -10,5 +10,7 @@ public class ObjectIsNull {
assertThat("").isNotNull();
assertThat("").as("nah").isNotNull();
assertThat(new Object()).isNotNull();
assertThat(new Object()).as("foo").isNotNull().as("bar").isEqualTo(new Object()).as("etc").isNull();
}
}

View File

@ -10,5 +10,7 @@ public class ObjectIsNull {
assertThat("").isNotEqualTo(null);
assertThat("").as("nah").isNotEqualTo(null);
assertThat(new Object()).isNotEqualTo(null);
assertThat(new Object()).as("foo").isNotEqualTo(null).as("bar").isEqualTo(new Object()).as("etc").isEqualTo(null);
}
}