Fix for multiple JUnit Conversions in batch mode with and without delta creating an exception.
Added new AssertThatObjectExpression inspection for toString() and hashCode() and moved equals() from AssertThatBinaryExpression there.
This commit is contained in:
-1
@@ -14,7 +14,6 @@ internal class AssertThatBinaryExpressionInspectionTest : AbstractCajonTest() {
|
||||
myFixture.enableInspections(AssertThatBinaryExpressionInspection::class.java)
|
||||
myFixture.configureByFile("BinaryExpressionBefore.java")
|
||||
executeQuickFixes(myFixture, Regex.fromLiteral("Split binary expression out of assertThat()"), 149)
|
||||
executeQuickFixes(myFixture, Regex.fromLiteral("Split equals() expression out of assertThat()"), 13)
|
||||
myFixture.checkResultByFile("BinaryExpressionAfter.java")
|
||||
}
|
||||
}
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
package de.platon42.intellij.plugins.cajon.inspections
|
||||
|
||||
import com.intellij.testFramework.fixtures.JavaCodeInsightTestFixture
|
||||
import de.platon42.intellij.jupiter.MyFixture
|
||||
import de.platon42.intellij.jupiter.TestDataSubPath
|
||||
import de.platon42.intellij.plugins.cajon.AbstractCajonTest
|
||||
import org.junit.jupiter.api.Test
|
||||
|
||||
internal class AssertThatObjectExpressionInspectionTest : AbstractCajonTest() {
|
||||
|
||||
@Test
|
||||
@TestDataSubPath("inspections/ObjectExpression")
|
||||
internal fun assertThat_with_certain_Object_methods(@MyFixture myFixture: JavaCodeInsightTestFixture) {
|
||||
myFixture.enableInspections(AssertThatObjectExpressionInspection::class.java)
|
||||
myFixture.configureByFile("ObjectExpressionBefore.java")
|
||||
executeQuickFixes(myFixture, Regex.fromLiteral("Remove equals() of actual expression and use assertThat().isEqualTo() instead"), 4)
|
||||
executeQuickFixes(myFixture, Regex.fromLiteral("Remove equals() of actual expression and use assertThat().isNotEqualTo() instead"), 3)
|
||||
executeQuickFixes(myFixture, Regex.fromLiteral("Replace calls to hashCode() with hasSameHashCodeAs()"), 1)
|
||||
executeQuickFixes(myFixture, Regex.fromLiteral("Remove toString() of actual expression and use assertThat().hasToString() instead"), 1)
|
||||
myFixture.checkResultByFile("ObjectExpressionAfter.java")
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -13,14 +13,14 @@ internal class AssertThatStringExpressionInspectionTest : AbstractCajonTest() {
|
||||
internal fun assertThat_with_certain_String_methods(@MyFixture myFixture: JavaCodeInsightTestFixture) {
|
||||
myFixture.enableInspections(AssertThatStringExpressionInspection::class.java)
|
||||
myFixture.configureByFile("StringExpressionBefore.java")
|
||||
executeQuickFixes(myFixture, Regex.fromLiteral("Remove isEmpty() of actual expression and use assertThat().isEmpty() instead"), 2)
|
||||
executeQuickFixes(myFixture, Regex.fromLiteral("Remove isEmpty() of actual expression and use assertThat().isEmpty() instead"), 3)
|
||||
executeQuickFixes(myFixture, Regex.fromLiteral("Remove equals() of actual expression and use assertThat().isEqualTo() instead"), 2)
|
||||
executeQuickFixes(myFixture, Regex.fromLiteral("Remove equalsIgnoreCase() of actual expression and use assertThat().isEqualToIgnoringCase() instead"), 2)
|
||||
executeQuickFixes(myFixture, Regex.fromLiteral("Remove contentEquals() of actual expression and use assertThat().isEqualTo() instead"), 4)
|
||||
executeQuickFixes(myFixture, Regex.fromLiteral("Remove contains() of actual expression and use assertThat().contains() instead"), 4)
|
||||
executeQuickFixes(myFixture, Regex.fromLiteral("Remove startsWith() of actual expression and use assertThat().startsWith() instead"), 2)
|
||||
executeQuickFixes(myFixture, Regex.fromLiteral("Remove endsWith() of actual expression and use assertThat().endsWith() instead"), 2)
|
||||
executeQuickFixes(myFixture, Regex.fromLiteral("Remove isEmpty() of actual expression and use assertThat().isNotEmpty() instead"), 2)
|
||||
executeQuickFixes(myFixture, Regex.fromLiteral("Remove isEmpty() of actual expression and use assertThat().isNotEmpty() instead"), 3)
|
||||
executeQuickFixes(myFixture, Regex.fromLiteral("Remove equals() of actual expression and use assertThat().isNotEqualTo() instead"), 2)
|
||||
executeQuickFixes(myFixture, Regex.fromLiteral("Remove equalsIgnoreCase() of actual expression and use assertThat().isNotEqualToIgnoringCase() instead"), 2)
|
||||
executeQuickFixes(myFixture, Regex.fromLiteral("Remove contentEquals() of actual expression and use assertThat().isNotEqualTo() instead"), 4)
|
||||
|
||||
@@ -146,12 +146,12 @@ public class BinaryExpression {
|
||||
assertThat(numberObjAct).isGreaterThan(1);
|
||||
assertThat(numberObjAct).isGreaterThan(1);
|
||||
|
||||
assertThat(numberObjAct).as("doh!").isEqualTo(numberObjExp);
|
||||
assertThat(numberObjAct).isEqualTo(numberObjExp);
|
||||
assertThat(numberObjAct).isEqualTo(numberObjExp);
|
||||
assertThat(numberObjAct).isNotEqualTo(numberObjExp);
|
||||
assertThat(numberObjAct).isNotEqualTo(numberObjExp);
|
||||
assertThat(numberObjAct).isNotEqualTo(numberObjExp);
|
||||
assertThat(numberObjAct.equals(numberObjExp)).as("doh!").isTrue();
|
||||
assertThat(numberObjAct.equals(numberObjExp)).isEqualTo(true);
|
||||
assertThat(numberObjAct.equals(numberObjExp)).isNotEqualTo(false);
|
||||
assertThat(numberObjAct.equals(numberObjExp)).isFalse();
|
||||
assertThat(numberObjAct.equals(numberObjExp)).isEqualTo(false);
|
||||
assertThat(numberObjAct.equals(numberObjExp)).isNotEqualTo(true);
|
||||
|
||||
assertThat(stringAct).as("doh!").isSameAs(stringExp);
|
||||
assertThat(stringAct).isSameAs(stringExp);
|
||||
@@ -160,12 +160,12 @@ public class BinaryExpression {
|
||||
assertThat(stringAct).isNotSameAs(stringExp);
|
||||
assertThat(stringAct).isNotSameAs(stringExp);
|
||||
|
||||
assertThat(stringAct).as("doh!").isEqualTo(stringExp);
|
||||
assertThat(stringAct).isEqualTo(stringExp);
|
||||
assertThat(stringAct).isEqualTo(stringExp);
|
||||
assertThat(stringAct).isNotEqualTo(stringExp);
|
||||
assertThat(stringAct).isNotEqualTo(stringExp);
|
||||
assertThat(stringAct).isNotEqualTo(stringExp);
|
||||
assertThat(stringAct.equals(stringExp)).as("doh!").isTrue();
|
||||
assertThat(stringAct.equals(stringExp)).isEqualTo(true);
|
||||
assertThat(stringAct.equals(stringExp)).isNotEqualTo(false);
|
||||
assertThat(stringAct.equals(stringExp)).isFalse();
|
||||
assertThat(stringAct.equals(stringExp)).isEqualTo(false);
|
||||
assertThat(stringAct.equals(stringExp)).isNotEqualTo(true);
|
||||
|
||||
assertThat(stringAct).as("doh!").isNotSameAs(stringExp);
|
||||
assertThat(stringAct).isNotSameAs(stringExp);
|
||||
@@ -194,6 +194,6 @@ public class BinaryExpression {
|
||||
assertThat(primAct).as("doh!").isEqualTo(primExp).isEqualTo(primExp);
|
||||
assertThat(primAct == primExp).isFalse().as("doh!").isEqualTo(true);
|
||||
|
||||
assertThat(numberObjAct).as("doh!").isEqualTo(numberObjExp).isEqualTo(numberObjExp);
|
||||
assertThat(numberObjAct.equals(numberObjExp)).as("doh!").isTrue().isEqualTo(true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
public class ObjectExpression {
|
||||
|
||||
private void objectExpression() {
|
||||
Integer object = 1;
|
||||
Integer otherObject = 1;
|
||||
boolean foo = false;
|
||||
|
||||
assertThat(object).hasToString("foo");
|
||||
assertThat(object.toString()).isNotEqualTo("foo");
|
||||
|
||||
assertThat(object).hasSameHashCodeAs(otherObject);
|
||||
assertThat(object.hashCode()).isEqualTo(123);
|
||||
|
||||
assertThat(object).as("doh!").isEqualTo(otherObject);
|
||||
assertThat(object).isEqualTo(otherObject);
|
||||
assertThat(object).isEqualTo(otherObject);
|
||||
assertThat(object).isNotEqualTo(otherObject);
|
||||
assertThat(object).isNotEqualTo(otherObject);
|
||||
assertThat(object).isNotEqualTo(otherObject);
|
||||
|
||||
assertThat(object.equals(otherObject)).isEqualTo(foo);
|
||||
|
||||
assertThat(object).as("doh!").isEqualTo(otherObject).isEqualTo(otherObject);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
public class ObjectExpression {
|
||||
|
||||
private void objectExpression() {
|
||||
Integer object = 1;
|
||||
Integer otherObject = 1;
|
||||
boolean foo = false;
|
||||
|
||||
assertThat(object.toString()).isEqualTo("foo");
|
||||
assertThat(object.toString()).isNotEqualTo("foo");
|
||||
|
||||
assertThat(object.hashCode()).isEqualTo(otherObject.hashCode());
|
||||
assertThat(object.hashCode()).isEqualTo(123);
|
||||
|
||||
assertThat(object.equals(otherObject)).as("doh!").isTrue();
|
||||
assertThat(object.equals(otherObject)).isEqualTo(true);
|
||||
assertThat(object.equals(otherObject)).isNotEqualTo(false);
|
||||
assertThat(object.equals(otherObject)).isFalse();
|
||||
assertThat(object.equals(otherObject)).isEqualTo(false);
|
||||
assertThat(object.equals(otherObject)).isNotEqualTo(true);
|
||||
|
||||
assertThat(object.equals(otherObject)).isEqualTo(foo);
|
||||
|
||||
assertThat(object.equals(otherObject)).as("doh!").isTrue().isEqualTo(true);
|
||||
}
|
||||
}
|
||||
@@ -8,6 +8,7 @@ public class StringExpression {
|
||||
|
||||
assertThat(string).as("foo").isEmpty();
|
||||
assertThat(string).isEmpty();
|
||||
assertThat(string).isEmpty();
|
||||
assertThat(string).isEqualTo("foo");
|
||||
assertThat(string).isEqualTo("foo");
|
||||
assertThat(string).isEqualToIgnoringCase("foo");
|
||||
@@ -27,6 +28,7 @@ public class StringExpression {
|
||||
|
||||
assertThat(string).as("foo").isNotEmpty();
|
||||
assertThat(string).isNotEmpty();
|
||||
assertThat(string).isNotEmpty();
|
||||
assertThat(string).isNotEqualTo("foo");
|
||||
assertThat(string).isNotEqualTo("foo");
|
||||
assertThat(string).isNotEqualToIgnoringCase("foo");
|
||||
|
||||
@@ -7,6 +7,7 @@ public class StringExpression {
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
|
||||
assertThat(string.isEmpty()).as("foo").isEqualTo(true);
|
||||
assertThat(string.isEmpty()).isNotEqualTo(false);
|
||||
assertThat(string.isEmpty()).isTrue();
|
||||
assertThat(string.equals("foo")).isEqualTo(true);
|
||||
assertThat(string.equals("foo")).isTrue();
|
||||
@@ -26,6 +27,7 @@ public class StringExpression {
|
||||
assertThat(string.endsWith("foo")).isTrue();
|
||||
|
||||
assertThat(string.isEmpty()).as("foo").isEqualTo(false);
|
||||
assertThat(string.isEmpty()).isNotEqualTo(true);
|
||||
assertThat(string.isEmpty()).isFalse();
|
||||
assertThat(string.equals("foo")).isEqualTo(false);
|
||||
assertThat(string.equals("foo")).isFalse();
|
||||
|
||||
Reference in New Issue
Block a user