The JoinAssertThatStatements inspection will now add line breaks on joining statements.
Unrelated: Upgraded Gradle to 5.4.1. Upgraded kotlin to 1.3.40. Upgraded jacoco to 0.8.4. Minor style change for immediate returns. Increased test/branch coverage.
This commit is contained in:
@@ -23,6 +23,7 @@ abstract class AbstractCajonTest {
|
||||
protected fun executeQuickFixes(myFixture: JavaCodeInsightTestFixture, regex: Regex, expectedFixes: Int) {
|
||||
val quickfixes = myFixture.getAllQuickFixes().filter { it.text.matches(regex) }
|
||||
assertThat(quickfixes).`as`("Fixes matched by $regex: ${myFixture.getAllQuickFixes().map { it.text }}").hasSize(expectedFixes)
|
||||
quickfixes.forEach { it.familyName }
|
||||
quickfixes.forEach(myFixture::launchAction)
|
||||
}
|
||||
|
||||
|
||||
+7
@@ -5,6 +5,7 @@ import de.platon42.intellij.jupiter.MyFixture
|
||||
import de.platon42.intellij.jupiter.TestDataSubPath
|
||||
import de.platon42.intellij.plugins.cajon.AbstractCajonTest
|
||||
import org.assertj.core.api.Assertions.assertThat
|
||||
import org.assertj.core.api.Assertions.assertThatThrownBy
|
||||
import org.junit.jupiter.api.Test
|
||||
|
||||
|
||||
@@ -70,4 +71,10 @@ internal class ExtractorReferenceContributorTest : AbstractCajonTest() {
|
||||
myFixture.configureByFiles("FindReference10.java", "Address.java", "Contact.java")
|
||||
assertThat(myFixture.elementAtCaret.text).startsWith("public String getStreetName()")
|
||||
}
|
||||
|
||||
@Test
|
||||
internal fun extractor_is_unable_to_find_reference(@MyFixture myFixture: JavaCodeInsightTestFixture) {
|
||||
myFixture.configureByFiles("FindReference11.java", "Address.java", "Contact.java")
|
||||
assertThatThrownBy { myFixture.elementAtCaret.text }.isInstanceOf(AssertionError::class.java)
|
||||
}
|
||||
}
|
||||
@@ -195,5 +195,8 @@ public class BinaryExpression {
|
||||
assertThat(primAct == primExp).isFalse().as("doh!").isEqualTo(true);
|
||||
|
||||
assertThat(numberObjAct.equals(numberObjExp)).as("doh!").isTrue().isEqualTo(true);
|
||||
|
||||
org.junit.Assert.assertThat(foo, null);
|
||||
fail("oh no!");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -195,5 +195,8 @@ public class BinaryExpression {
|
||||
assertThat(primAct == primExp).isFalse().as("doh!").isEqualTo(true);
|
||||
|
||||
assertThat(numberObjAct.equals(numberObjExp)).as("doh!").isTrue().isEqualTo(true);
|
||||
|
||||
org.junit.Assert.assertThat(foo, null);
|
||||
fail("oh no!");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,5 +30,9 @@ public class BooleanCondition {
|
||||
assertThat("").isEqualTo(Boolean.TRUE);
|
||||
|
||||
assertThat(primitive).isTrue().as("foo").isTrue().as("bar").isTrue().isFalse();
|
||||
|
||||
assertThat(object).isEqualTo(Boolean.TYPE);
|
||||
org.junit.Assert.assertThat(foo, null);
|
||||
fail("oh no!");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,5 +30,9 @@ public class BooleanCondition {
|
||||
assertThat("").isEqualTo(Boolean.TRUE);
|
||||
|
||||
assertThat(primitive).isEqualTo(Boolean.TRUE).as("foo").isEqualTo(true).as("bar").isTrue().isFalse();
|
||||
|
||||
assertThat(object).isEqualTo(Boolean.TYPE);
|
||||
org.junit.Assert.assertThat(foo, null);
|
||||
fail("oh no!");
|
||||
}
|
||||
}
|
||||
|
||||
+3
@@ -40,5 +40,8 @@ public class CollectionMapExpression {
|
||||
assertThat(stringList).as("foo").isNotEmpty().as("bar").isNotEmpty();
|
||||
assertThat(stringList.isEmpty()).as("foo").isEqualTo(false).as("bar").isTrue();
|
||||
assertThat(stringList.isEmpty()).as("foo").satisfies(it -> it.booleanValue()).as("bar").isFalse();
|
||||
|
||||
org.junit.Assert.assertThat(foo, null);
|
||||
fail("oh no!");
|
||||
}
|
||||
}
|
||||
|
||||
+3
@@ -40,5 +40,8 @@ public class CollectionMapExpression {
|
||||
assertThat(stringList.isEmpty()).as("foo").isEqualTo(false).as("bar").isFalse();
|
||||
assertThat(stringList.isEmpty()).as("foo").isEqualTo(false).as("bar").isTrue();
|
||||
assertThat(stringList.isEmpty()).as("foo").satisfies(it -> it.booleanValue()).as("bar").isFalse();
|
||||
|
||||
org.junit.Assert.assertThat(foo, null);
|
||||
fail("oh no!");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,5 +16,8 @@ public class EnumerableIsEmpty {
|
||||
assertThat(new Long[1]).as("etc").hasSize(1);
|
||||
|
||||
assertThat("string").as("foo").hasSize(0).hasSameSizeAs("foo").isEmpty();
|
||||
|
||||
org.junit.Assert.assertThat(foo, null);
|
||||
fail("oh no!");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,5 +16,8 @@ public class EnumerableIsEmpty {
|
||||
assertThat(new Long[1]).as("etc").hasSize(1);
|
||||
|
||||
assertThat("string").as("foo").hasSize(0).hasSameSizeAs("foo").hasSize(0);
|
||||
|
||||
org.junit.Assert.assertThat(foo, null);
|
||||
fail("oh no!");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -56,5 +56,10 @@ public class GuavaOptional {
|
||||
|
||||
assertThat(opt).as("foo").isPresent().as("bar").isPresent();
|
||||
assertThat(opt.isPresent()).as("foo").isEqualTo(true).as("bar").isEqualTo(Boolean.FALSE);
|
||||
|
||||
assertThat(opt.orNull()).as("foo").isEqualTo(null).isNotNull();
|
||||
|
||||
org.junit.Assert.assertThat(foo, null);
|
||||
fail("oh no!");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -56,5 +56,10 @@ public class GuavaOptional {
|
||||
|
||||
assertThat(opt.isPresent()).as("foo").isEqualTo(true).as("bar").isEqualTo(Boolean.TRUE);
|
||||
assertThat(opt.isPresent()).as("foo").isEqualTo(true).as("bar").isEqualTo(Boolean.FALSE);
|
||||
|
||||
assertThat(opt.orNull()).as("foo").isEqualTo(null).isNotNull();
|
||||
|
||||
org.junit.Assert.assertThat(foo, null);
|
||||
fail("oh no!");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -284,5 +284,8 @@ public class ImplicitAssertion {
|
||||
assertThat(guavaOptional).contains("foo");
|
||||
assertThat(guavaOptional).extractingValue().isEqualTo("foo");
|
||||
assertThat(guavaOptional).extractingCharSequence().isEqualTo("foo");
|
||||
|
||||
org.junit.Assert.assertThat(foo, null);
|
||||
fail("oh no!");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -284,5 +284,8 @@ public class ImplicitAssertion {
|
||||
assertThat(guavaOptional).isPresent().contains("foo");
|
||||
assertThat(guavaOptional).isPresent().extractingValue().isEqualTo("foo");
|
||||
assertThat(guavaOptional).isPresent().extractingCharSequence().isEqualTo("foo");
|
||||
|
||||
org.junit.Assert.assertThat(foo, null);
|
||||
fail("oh no!");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,5 +21,8 @@ public class InstanceOf {
|
||||
|
||||
assertThat(object).as("foo").isInstanceOf(Boolean.class).as("bar").isInstanceOf(Boolean.class);
|
||||
assertThat(object instanceof Boolean).as("foo").isEqualTo(Boolean.TRUE).as("bar").isEqualTo(false);
|
||||
|
||||
org.junit.Assert.assertThat(foo, null);
|
||||
fail("oh no!");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,5 +21,8 @@ public class InstanceOf {
|
||||
|
||||
assertThat(object instanceof Boolean).as("foo").isEqualTo(Boolean.TRUE).as("bar").isEqualTo(true);
|
||||
assertThat(object instanceof Boolean).as("foo").isEqualTo(Boolean.TRUE).as("bar").isEqualTo(false);
|
||||
|
||||
org.junit.Assert.assertThat(foo, null);
|
||||
fail("oh no!");
|
||||
}
|
||||
}
|
||||
|
||||
+3
@@ -35,5 +35,8 @@ public class InvertedBooleanCondition {
|
||||
|
||||
assertThat(primitive).as("foo").isFalse().as("bar").isFalse();
|
||||
assertThat(primitive).as("foo").isFalse().as("bar").isTrue();
|
||||
|
||||
org.junit.Assert.assertThat(foo, null);
|
||||
fail("oh no!");
|
||||
}
|
||||
}
|
||||
|
||||
+3
@@ -35,5 +35,8 @@ public class InvertedBooleanCondition {
|
||||
|
||||
assertThat(!primitive).as("foo").isEqualTo(Boolean.TRUE).as("bar").isNotEqualTo(false);
|
||||
assertThat(!primitive).as("foo").isEqualTo(Boolean.TRUE).as("bar").isNotEqualTo(true);
|
||||
|
||||
org.junit.Assert.assertThat(foo, null);
|
||||
fail("oh no!");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,5 +43,10 @@ public class Java8Optional {
|
||||
assertThat(opt.get()).isEqualTo("foo").isSameAs("foo").isNotEqualTo("foo").isNotSameAs("foo");
|
||||
|
||||
assertThat(opt.orElse("foo")).as("foo").isEqualTo(null);
|
||||
|
||||
assertThat(opt.orElse(null)).as("foo").isEqualTo(null).isNotNull();
|
||||
|
||||
org.junit.Assert.assertThat(foo, null);
|
||||
fail("oh no!");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,5 +43,10 @@ public class Java8Optional {
|
||||
assertThat(opt.get()).isEqualTo("foo").isSameAs("foo").isNotEqualTo("foo").isNotSameAs("foo");
|
||||
|
||||
assertThat(opt.orElse("foo")).as("foo").isEqualTo(null);
|
||||
|
||||
assertThat(opt.orElse(null)).as("foo").isEqualTo(null).isNotNull();
|
||||
|
||||
org.junit.Assert.assertThat(foo, null);
|
||||
fail("oh no!");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import java.util.*;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.fail;
|
||||
|
||||
public class JoinStatements {
|
||||
|
||||
@@ -24,21 +25,28 @@ public class JoinStatements {
|
||||
.doesNotContain("foobar");
|
||||
|
||||
assertThat("narf").isNotEqualTo("puit");
|
||||
assertThat(list).as("bar").contains("barbar").as("foo").hasSize(2);
|
||||
assertThat(list).as("bar").contains("barbar")
|
||||
.as("foo").hasSize(2);
|
||||
assertThat(list).as("evil").extracting(String::length).contains(2);
|
||||
|
||||
assertThat(list).as("bar").contains("barbar");
|
||||
assertThat(otherList).contains("puit");
|
||||
assertThat(list).as("foo").hasSize(2);
|
||||
if (true) {
|
||||
assertThat(list).doesNotContain("narf").as("bar").contains("barbar");
|
||||
assertThat(list).doesNotContain("narf")
|
||||
.as("bar").contains("barbar");
|
||||
}
|
||||
assertThat(list.get(0)).isNotEmpty().hasSize(3).isEqualTo("bar");
|
||||
assertThat(list.get(0)).isNotEmpty()
|
||||
.hasSize(3)
|
||||
.isEqualTo("bar");
|
||||
|
||||
assertThat(otherList.get(0)).isNotEmpty();
|
||||
assertThat(list.get(0)).hasSize(3);
|
||||
|
||||
assertThat(list.get(0) + "foo").isEqualTo("bar").doesNotStartWith("foo");
|
||||
assertThat(list.get(0) + "foo").isNotNull()
|
||||
// hey, a comment mixed with line breaks due to too many joins
|
||||
.isEqualTo("bar")
|
||||
.doesNotStartWith("foo");
|
||||
|
||||
assertThat(otherList.get(0) + "foo").isEqualTo("bar");
|
||||
assertThat(list.get(0) + "foo").doesNotStartWith("foo");
|
||||
@@ -57,5 +65,8 @@ public class JoinStatements {
|
||||
assertThat(list.get(i++).toLowerCase()).isEqualTo("foo");
|
||||
assertThat(list.get(--i)).isEqualTo("foo");
|
||||
assertThat(list.get(--i)).isEqualTo("foo");
|
||||
|
||||
org.junit.Assert.assertThat(foo, null);
|
||||
fail("oh no!");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import java.util.*;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.fail;
|
||||
|
||||
public class JoinStatements {
|
||||
|
||||
@@ -39,6 +40,8 @@ public class JoinStatements {
|
||||
assertThat(otherList.get(0)).isNotEmpty();
|
||||
assertThat(list.get(0)).hasSize(3);
|
||||
|
||||
assertThat(list.get(0) + "foo").isNotNull();
|
||||
// hey, a comment mixed with line breaks due to too many joins
|
||||
assertThat(list.get(0) + "foo").isEqualTo("bar");
|
||||
assertThat(list.get(0) + "foo").doesNotStartWith("foo");
|
||||
|
||||
@@ -59,5 +62,8 @@ public class JoinStatements {
|
||||
assertThat(list.get(i++).toLowerCase()).isEqualTo("foo");
|
||||
assertThat(list.get(--i)).isEqualTo("foo");
|
||||
assertThat(list.get(--i)).isEqualTo("foo");
|
||||
|
||||
org.junit.Assert.assertThat(foo, null);
|
||||
fail("oh no!");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,5 +23,8 @@ public class ObjectExpression {
|
||||
assertThat(object.equals(otherObject)).isEqualTo(foo);
|
||||
|
||||
assertThat(object).as("doh!").isEqualTo(otherObject).isEqualTo(otherObject);
|
||||
|
||||
org.junit.Assert.assertThat(foo, null);
|
||||
fail("oh no!");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,5 +23,8 @@ public class ObjectExpression {
|
||||
assertThat(object.equals(otherObject)).isEqualTo(foo);
|
||||
|
||||
assertThat(object.equals(otherObject)).as("doh!").isTrue().isEqualTo(true);
|
||||
|
||||
org.junit.Assert.assertThat(foo, null);
|
||||
fail("oh no!");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,5 +13,8 @@ public class ObjectIsNull {
|
||||
|
||||
assertThat(new Object()).as("foo").isNotNull().as("bar").isEqualTo(new Object()).as("etc").isNull();
|
||||
assertThat(new Object()).as("foo").isEqualTo(null).as("bar").isEqualTo(new Object()).as("etc").isNotNull();
|
||||
|
||||
org.junit.Assert.assertThat(foo, null);
|
||||
fail("oh no!");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,5 +13,8 @@ public class ObjectIsNull {
|
||||
|
||||
assertThat(new Object()).as("foo").isNotEqualTo(null).as("bar").isEqualTo(new Object()).as("etc").isEqualTo(null);
|
||||
assertThat(new Object()).as("foo").isEqualTo(null).as("bar").isEqualTo(new Object()).as("etc").isNotEqualTo(null);
|
||||
|
||||
org.junit.Assert.assertThat(foo, null);
|
||||
fail("oh no!");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -99,5 +99,12 @@ public class Size {
|
||||
assertThat(stringBuilder.length()).as("foo").isEqualTo(0).isZero().as("bar").isNotZero().isEqualTo(10);
|
||||
|
||||
assertThat(stringBuilder).as("foo").isNotEmpty().hasSize(2).as("bar").hasSameSizeAs(otherList).hasSameSizeAs(array);
|
||||
|
||||
int foo = 1;
|
||||
assertThat(foo).isEqualTo(0);
|
||||
assertThat(string.length()).isPositive();
|
||||
|
||||
org.junit.Assert.assertThat(foo, null);
|
||||
fail("oh no!");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -99,5 +99,12 @@ public class Size {
|
||||
assertThat(stringBuilder.length()).as("foo").isEqualTo(0).isZero().as("bar").isNotZero().isEqualTo(10);
|
||||
|
||||
assertThat(stringBuilder).as("foo").isNotEmpty().hasSize(2).as("bar").hasSize(otherList.size()).hasSize(array.length);
|
||||
|
||||
int foo = 1;
|
||||
assertThat(foo).isEqualTo(0);
|
||||
assertThat(string.length()).isPositive();
|
||||
|
||||
org.junit.Assert.assertThat(foo, null);
|
||||
fail("oh no!");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,5 +49,8 @@ public class StringExpression {
|
||||
assertThat(string).as("foo").doesNotEndWith("foo").as("bar").doesNotEndWith("foo");
|
||||
assertThat(string.endsWith("foo")).as("foo").isEqualTo(false).as("bar").isTrue();
|
||||
assertThat(string.endsWith("foo")).as("foo").satisfies(it -> it.booleanValue()).as("bar").isFalse();
|
||||
|
||||
org.junit.Assert.assertThat(foo, null);
|
||||
fail("oh no!");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,5 +49,8 @@ public class StringExpression {
|
||||
assertThat(string.endsWith("foo")).as("foo").isEqualTo(false).as("bar").isFalse();
|
||||
assertThat(string.endsWith("foo")).as("foo").isEqualTo(false).as("bar").isTrue();
|
||||
assertThat(string.endsWith("foo")).as("foo").satisfies(it -> it.booleanValue()).as("bar").isFalse();
|
||||
|
||||
org.junit.Assert.assertThat(foo, null);
|
||||
fail("oh no!");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,5 +18,8 @@ public class StringIsEmpty {
|
||||
|
||||
assertThat(string).as("foo").isEqualTo("").as("bar").hasSize(0).hasSameSizeAs("foo").isEmpty();
|
||||
assertThat(string).as("foo").isEqualTo("").as("bar").hasSize(0).hasSameSizeAs("foo").isEmpty();
|
||||
|
||||
org.junit.Assert.assertThat(foo, null);
|
||||
fail("oh no!");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,5 +18,8 @@ public class StringIsEmpty {
|
||||
|
||||
assertThat(string).as("foo").isEqualTo("").as("bar").hasSize(0).hasSameSizeAs("foo").isEqualTo("");
|
||||
assertThat(string).as("foo").isEqualTo("").as("bar").hasSize(0).hasSameSizeAs("foo").hasSize(0);
|
||||
|
||||
org.junit.Assert.assertThat(foo, null);
|
||||
fail("oh no!");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
import org.assertj.core.extractor.Extractors;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
public class FindReference10 {
|
||||
|
||||
private void findReferences() {
|
||||
List<Contact> contactList = Collections.emptyList();
|
||||
|
||||
assertThat(contactList).extracting("narf<caret>").isEqualTo("foo");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user