From e55acf9c7452412e965c93b791b9929ddbde34a4 Mon Sep 17 00:00:00 2001 From: chrisly42 Date: Mon, 29 Apr 2019 20:10:55 +0200 Subject: [PATCH] Extended test cases for AssertThatBooleanCondition and AssertThatObjectIsNullOrNotNull. --- .../inspections/AssertThatBooleanConditionInspectionTest.kt | 2 +- .../AssertThatObjectIsNullOrNotNullInspectionTest.kt | 4 ++-- .../inspections/BooleanCondition/BooleanConditionAfter.java | 6 ++++-- .../BooleanCondition/BooleanConditionBefore.java | 6 ++++-- .../ObjectIsNullOrNotNull/ObjectIsNullOrNotNullAfter.java | 2 ++ .../ObjectIsNullOrNotNull/ObjectIsNullOrNotNullBefore.java | 2 ++ 6 files changed, 15 insertions(+), 7 deletions(-) diff --git a/src/test/java/de/platon42/intellij/plugins/cajon/inspections/AssertThatBooleanConditionInspectionTest.kt b/src/test/java/de/platon42/intellij/plugins/cajon/inspections/AssertThatBooleanConditionInspectionTest.kt index 4934343..63c4e7c 100644 --- a/src/test/java/de/platon42/intellij/plugins/cajon/inspections/AssertThatBooleanConditionInspectionTest.kt +++ b/src/test/java/de/platon42/intellij/plugins/cajon/inspections/AssertThatBooleanConditionInspectionTest.kt @@ -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) diff --git a/src/test/java/de/platon42/intellij/plugins/cajon/inspections/AssertThatObjectIsNullOrNotNullInspectionTest.kt b/src/test/java/de/platon42/intellij/plugins/cajon/inspections/AssertThatObjectIsNullOrNotNullInspectionTest.kt index 1cb29b7..5219eaf 100644 --- a/src/test/java/de/platon42/intellij/plugins/cajon/inspections/AssertThatObjectIsNullOrNotNullInspectionTest.kt +++ b/src/test/java/de/platon42/intellij/plugins/cajon/inspections/AssertThatObjectIsNullOrNotNullInspectionTest.kt @@ -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") } } diff --git a/src/test/resources/inspections/BooleanCondition/BooleanConditionAfter.java b/src/test/resources/inspections/BooleanCondition/BooleanConditionAfter.java index 3610d63..c25b0bb 100644 --- a/src/test/resources/inspections/BooleanCondition/BooleanConditionAfter.java +++ b/src/test/resources/inspections/BooleanCondition/BooleanConditionAfter.java @@ -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(); } } diff --git a/src/test/resources/inspections/BooleanCondition/BooleanConditionBefore.java b/src/test/resources/inspections/BooleanCondition/BooleanConditionBefore.java index 14ec27b..e3ecf27 100644 --- a/src/test/resources/inspections/BooleanCondition/BooleanConditionBefore.java +++ b/src/test/resources/inspections/BooleanCondition/BooleanConditionBefore.java @@ -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(); } } diff --git a/src/test/resources/inspections/ObjectIsNullOrNotNull/ObjectIsNullOrNotNullAfter.java b/src/test/resources/inspections/ObjectIsNullOrNotNull/ObjectIsNullOrNotNullAfter.java index 88de037..ae5598d 100644 --- a/src/test/resources/inspections/ObjectIsNullOrNotNull/ObjectIsNullOrNotNullAfter.java +++ b/src/test/resources/inspections/ObjectIsNullOrNotNull/ObjectIsNullOrNotNullAfter.java @@ -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(); } } diff --git a/src/test/resources/inspections/ObjectIsNullOrNotNull/ObjectIsNullOrNotNullBefore.java b/src/test/resources/inspections/ObjectIsNullOrNotNull/ObjectIsNullOrNotNullBefore.java index 697f7e5..da35a8c 100644 --- a/src/test/resources/inspections/ObjectIsNullOrNotNull/ObjectIsNullOrNotNullBefore.java +++ b/src/test/resources/inspections/ObjectIsNullOrNotNull/ObjectIsNullOrNotNullBefore.java @@ -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); } }