Another fix for AssertThatStringIsEmpty, added support for CharSequences, added hasSize(0) case, refactored stuff. Added missing html.

This commit is contained in:
2019-03-24 13:03:53 +01:00
parent 458542de7c
commit e2ffce753c
13 changed files with 91 additions and 85 deletions
@@ -1,7 +1,5 @@
package de.platon42.intellij.playground;
import org.assertj.core.api.AbstractStringAssert;
import java.util.ArrayList;
import static org.assertj.core.api.Assertions.assertThat;
@@ -52,8 +50,8 @@ public class Playground {
private void stringIsEmpty() {
String foo = "bar";
AbstractStringAssert<?> abstractStringAssert = assertThat(foo);
abstractStringAssert.isEqualTo("");
assertThat(foo).isEqualTo("");
assertThat(foo).hasSize(0);
}
}
@@ -14,7 +14,7 @@ internal class AssertThatObjectIsNotNullInspectionTest : AbstractCajonTest() {
runTest {
myFixture.enableInspections(AssertThatObjectIsNotNullInspection::class.java)
myFixture.configureByFile("ObjectIsNotNullBefore.java")
executeQuickFixes(myFixture, Regex.fromLiteral("Replace isNotEqualTo(null) with isNotNull()"), 3)
executeQuickFixes(myFixture, Regex.fromLiteral("Replace isNotEqualTo() with isNotNull()"), 3)
myFixture.checkResultByFile("ObjectIsNotNullAfter.java")
}
}
@@ -14,7 +14,7 @@ internal class AssertThatObjectIsNullInspectionTest : AbstractCajonTest() {
runTest {
myFixture.enableInspections(AssertThatObjectIsNullInspection::class.java)
myFixture.configureByFile("ObjectIsNullBefore.java")
executeQuickFixes(myFixture, Regex.fromLiteral("Replace isEqualTo(null) with isNull()"), 3)
executeQuickFixes(myFixture, Regex.fromLiteral("Replace isEqualTo() with isNull()"), 3)
myFixture.checkResultByFile("ObjectIsNullAfter.java")
}
}
@@ -14,7 +14,7 @@ internal class AssertThatStringIsEmptyInspectionTest : AbstractCajonTest() {
runTest {
myFixture.enableInspections(AssertThatStringIsEmptyInspection::class.java)
myFixture.configureByFile("StringIsEmptyBefore.java")
executeQuickFixes(myFixture, Regex("Replace is.*"), 1)
executeQuickFixes(myFixture, Regex("Replace .*"), 4)
myFixture.checkResultByFile("StringIsEmptyAfter.java")
}
}
@@ -4,9 +4,16 @@ public class StringIsEmpty {
private void stringIsEmpty() {
String string = "string";
StringBuilder stringBuilder = new StringBuilder();
assertThat(string).isEqualTo("foo");
assertThat(string).as("foo").isEmpty();
assertThat(string).as("bar").isEmpty();
assertThat(stringBuilder).isEqualTo("foo");
assertThat(stringBuilder).as("foo").isEmpty();
assertThat(stringBuilder).as("bar").isEmpty();
assertThat(new Object()).isEqualTo("");
}
}
@@ -4,9 +4,16 @@ public class StringIsEmpty {
private void stringIsEmpty() {
String string = "string";
StringBuilder stringBuilder = new StringBuilder();
assertThat(string).isEqualTo("foo");
assertThat(string).as("foo").isEqualTo("");
assertThat(string).as("bar").hasSize(0);
assertThat(stringBuilder).isEqualTo("foo");
assertThat(stringBuilder).as("foo").isEqualTo("");
assertThat(stringBuilder).as("bar").hasSize(0);
assertThat(new Object()).isEqualTo("");
}
}