Heavily reworked inspections for edge cases, such as multiple isEqualTo() calls inside a single statement. Corrected highlighting for most inspections. Lots of refactorings, tweakings. Added travis-ci file (untested). Added jacoco.
This commit is contained in:
@@ -283,6 +283,7 @@ public class Playground {
|
||||
assertFalse(!(new int[3].length == new ArrayList<Integer>().size()));
|
||||
assertThat(!(new int[3].length == new ArrayList<Integer>().size())).isFalse();
|
||||
assertThat((new int[3].length == new ArrayList<Integer>().size())).isTrue();
|
||||
assertThat(new int[3].length == new ArrayList<Integer>().size()).isTrue();
|
||||
assertThat(new int[3].length).isEqualTo(new ArrayList<Integer>().size());
|
||||
assertThat(new int[3]).hasSameSizeAs(new ArrayList<Integer>());
|
||||
|
||||
|
||||
@@ -60,8 +60,8 @@ abstract class AbstractCajonTest {
|
||||
}
|
||||
|
||||
protected fun executeQuickFixes(myFixture: JavaCodeInsightTestFixture, regex: Regex, expectedFixes: Int) {
|
||||
val quickfixes = myFixture.getAllQuickFixes().filter { it.familyName.matches(regex) }
|
||||
assertThat(quickfixes).`as`("Fixes matched by $regex: ${myFixture.getAllQuickFixes().map { it.familyName }}").hasSize(expectedFixes)
|
||||
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(myFixture::launchAction)
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -14,8 +14,8 @@ internal class AssertThatBinaryExpressionInspectionTest : AbstractCajonTest() {
|
||||
runTest {
|
||||
myFixture.enableInspections(AssertThatBinaryExpressionInspection::class.java)
|
||||
myFixture.configureByFile("BinaryExpressionBefore.java")
|
||||
executeQuickFixes(myFixture, Regex.fromLiteral("Split binary expression out of assertThat()"), 148)
|
||||
executeQuickFixes(myFixture, Regex.fromLiteral("Split equals() expression out of assertThat()"), 12)
|
||||
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")
|
||||
}
|
||||
}
|
||||
|
||||
+10
-15
@@ -17,19 +17,12 @@ internal class AssertThatGuavaOptionalInspectionTest : AbstractCajonTest() {
|
||||
runTest {
|
||||
myFixture.enableInspections(AssertThatGuavaOptionalInspection::class.java)
|
||||
myFixture.configureByFile("GuavaOptionalBefore.java")
|
||||
executeQuickFixes(myFixture, Regex.fromLiteral("Unwrap actual expression and replace isEqualTo() with Guava assertThat().isPresent()"), 2)
|
||||
executeQuickFixes(myFixture, Regex.fromLiteral("Unwrap actual expression and replace isNotEqualTo() with Guava assertThat().isPresent()"), 2)
|
||||
executeQuickFixes(myFixture, Regex.fromLiteral("Replace isNotEqualTo() with isPresent()"), 2)
|
||||
executeQuickFixes(myFixture, Regex.fromLiteral("Replace isNotEqualTo() with Guava assertThat().isPresent()"), 1)
|
||||
executeQuickFixes(myFixture, Regex.fromLiteral("Unwrap actual expression and replace isEqualTo() with Guava assertThat().isAbsent()"), 2)
|
||||
executeQuickFixes(myFixture, Regex.fromLiteral("Replace isEqualTo() with isAbsent()"), 2)
|
||||
executeQuickFixes(myFixture, Regex.fromLiteral("Replace isEqualTo() with Guava assertThat().isAbsent()"), 1)
|
||||
executeQuickFixes(myFixture, Regex.fromLiteral("Unwrap actual expression and replace isNotEqualTo() with Guava assertThat().isAbsent()"), 2)
|
||||
executeQuickFixes(myFixture, Regex.fromLiteral("Unwrap actual expression and replace isTrue() with Guava assertThat().isPresent()"), 1)
|
||||
executeQuickFixes(myFixture, Regex.fromLiteral("Unwrap actual expression and replace isFalse() with Guava assertThat().isAbsent()"), 1)
|
||||
executeQuickFixes(myFixture, Regex.fromLiteral("Unwrap actual expression and replace isEqualTo() with Guava assertThat().contains()"), 1)
|
||||
executeQuickFixes(myFixture, Regex.fromLiteral("Remove unwrapping of expected expression and replace isEqualTo() with contains()"), 4)
|
||||
executeQuickFixes(myFixture, Regex.fromLiteral("Remove unwrapping of expected expression and replace isEqualTo() with Guava assertThat().contains()"), 2)
|
||||
executeQuickFixes(myFixture, Regex.fromLiteral("Remove isPresent() of actual expression and use assertThat().isPresent() instead"), 6)
|
||||
executeQuickFixes(myFixture, Regex.fromLiteral("Remove isPresent() of actual expression and use assertThat().isAbsent() instead"), 5)
|
||||
executeQuickFixes(myFixture, Regex.fromLiteral("Remove get() of actual expression and use assertThat().contains() instead"), 1)
|
||||
executeQuickFixes(myFixture, Regex.fromLiteral("Unwrap expected expression and replace isEqualTo() with contains()"), 6)
|
||||
executeQuickFixes(myFixture, Regex.fromLiteral("Replace isEqualTo() with Guava assertThat().isAbsent()"), 3)
|
||||
executeQuickFixes(myFixture, Regex.fromLiteral("Replace isNotEqualTo() with Guava assertThat().isPresent()"), 3)
|
||||
myFixture.checkResultByFile("GuavaOptionalAfter.java")
|
||||
}
|
||||
}
|
||||
@@ -39,7 +32,8 @@ internal class AssertThatGuavaOptionalInspectionTest : AbstractCajonTest() {
|
||||
runTest {
|
||||
myFixture.enableInspections(AssertThatGuavaOptionalInspection::class.java)
|
||||
myFixture.configureByFile("WithoutPriorGuavaImportBefore.java")
|
||||
executeQuickFixes(myFixture, Regex(".*eplace .* with .*"), 7)
|
||||
executeQuickFixes(myFixture, Regex(".*eplace .* with .*"), 4)
|
||||
executeQuickFixes(myFixture, Regex("Remove .*"), 3)
|
||||
myFixture.checkResultByFile("WithoutPriorGuavaImportAfter.java")
|
||||
}
|
||||
}
|
||||
@@ -50,7 +44,8 @@ internal class AssertThatGuavaOptionalInspectionTest : AbstractCajonTest() {
|
||||
myFixture.enableInspections(AssertThatGuavaOptionalInspection::class.java)
|
||||
myFixture.configureByFile("WithoutPriorGuavaImportBefore.java")
|
||||
executeQuickFixes(myFixture, Regex.fromLiteral("Replace isEqualTo() with Guava assertThat().isAbsent()"), 1)
|
||||
executeQuickFixes(myFixture, Regex(".*eplace .* with .*"), 6)
|
||||
executeQuickFixes(myFixture, Regex(".*eplace .* with .*"), 3)
|
||||
executeQuickFixes(myFixture, Regex("Remove .*"), 3)
|
||||
myFixture.checkResultByFile("WithoutPriorGuavaImportAfter.java")
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -14,8 +14,8 @@ internal class AssertThatInstanceOfInspectionTest : AbstractCajonTest() {
|
||||
runTest {
|
||||
myFixture.enableInspections(AssertThatInstanceOfInspection::class.java)
|
||||
myFixture.configureByFile("InstanceOfBefore.java")
|
||||
executeQuickFixes(myFixture, Regex.fromLiteral("Replace instanceof expression by assertThat().isInstanceOf()"), 5)
|
||||
executeQuickFixes(myFixture, Regex.fromLiteral("Replace instanceof expression by assertThat().isNotInstanceOf()"), 6)
|
||||
executeQuickFixes(myFixture, Regex.fromLiteral("Remove instanceof in actual expression and use assertThat().isInstanceOf() instead"), 6)
|
||||
executeQuickFixes(myFixture, Regex.fromLiteral("Remove instanceof in actual expression and use assertThat().isNotInstanceOf() instead"), 6)
|
||||
myFixture.checkResultByFile("InstanceOfAfter.java")
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -14,7 +14,7 @@ internal class AssertThatInvertedBooleanConditionInspectionTest : AbstractCajonT
|
||||
runTest {
|
||||
myFixture.enableInspections(AssertThatInvertedBooleanConditionInspection::class.java)
|
||||
myFixture.configureByFile("InvertedBooleanConditionBefore.java")
|
||||
executeQuickFixes(myFixture, Regex.fromLiteral("Invert condition in assertThat()"), 21)
|
||||
executeQuickFixes(myFixture, Regex.fromLiteral("Invert condition in assertThat()"), 25)
|
||||
myFixture.checkResultByFile("InvertedBooleanConditionAfter.java")
|
||||
}
|
||||
}
|
||||
|
||||
+5
-9
@@ -14,17 +14,13 @@ internal class AssertThatJava8OptionalInspectionTest : AbstractCajonTest() {
|
||||
runTest {
|
||||
myFixture.enableInspections(AssertThatJava8OptionalInspection::class.java)
|
||||
myFixture.configureByFile("Java8OptionalBefore.java")
|
||||
executeQuickFixes(myFixture, Regex.fromLiteral("Unwrap actual expression and replace isEqualTo() with isPresent()"), 2)
|
||||
executeQuickFixes(myFixture, Regex.fromLiteral("Unwrap actual expression and replace isNotEqualTo() with isPresent()"), 2)
|
||||
executeQuickFixes(myFixture, Regex.fromLiteral("Unwrap actual expression and replace isEqualTo() with isNotPresent()"), 2)
|
||||
executeQuickFixes(myFixture, Regex.fromLiteral("Unwrap actual expression and replace isNotEqualTo() with isNotPresent()"), 2)
|
||||
executeQuickFixes(myFixture, Regex.fromLiteral("Unwrap actual expression and replace isTrue() with isPresent()"), 1)
|
||||
executeQuickFixes(myFixture, Regex.fromLiteral("Remove isPresent() of actual expression and use assertThat().isPresent() instead"), 6)
|
||||
executeQuickFixes(myFixture, Regex.fromLiteral("Remove isPresent() of actual expression and use assertThat().isNotPresent() instead"), 5)
|
||||
executeQuickFixes(myFixture, Regex.fromLiteral("Remove get() of actual expression and use assertThat().contains() instead"), 1)
|
||||
executeQuickFixes(myFixture, Regex.fromLiteral("Remove get() of actual expression and use assertThat().containsSame() instead"), 1)
|
||||
executeQuickFixes(myFixture, Regex.fromLiteral("Replace isEqualTo() with isNotPresent()"), 1)
|
||||
executeQuickFixes(myFixture, Regex.fromLiteral("Replace isNotEqualTo() with isPresent()"), 1)
|
||||
executeQuickFixes(myFixture, Regex.fromLiteral("Unwrap actual expression and replace isFalse() with isNotPresent()"), 1)
|
||||
executeQuickFixes(myFixture, Regex.fromLiteral("Remove unwrapping of expected expression and replace isEqualTo() with contains()"), 2)
|
||||
executeQuickFixes(myFixture, Regex.fromLiteral("Unwrap actual expression and replace isEqualTo() with contains()"), 1)
|
||||
executeQuickFixes(myFixture, Regex.fromLiteral("Unwrap actual expression and replace isSameAs() with containsSame()"), 1)
|
||||
executeQuickFixes(myFixture, Regex.fromLiteral("Unwrap expected expression and replace isEqualTo() with contains()"), 2)
|
||||
myFixture.checkResultByFile("Java8OptionalAfter.java")
|
||||
}
|
||||
}
|
||||
|
||||
+5
-1
@@ -4,6 +4,8 @@ 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.assertj.core.api.Assertions.assertThat
|
||||
import org.assertj.core.api.extrakting
|
||||
import org.junit.jupiter.api.Test
|
||||
|
||||
internal class AssertThatSizeInspectionTest : AbstractCajonTest() {
|
||||
@@ -14,6 +16,8 @@ internal class AssertThatSizeInspectionTest : AbstractCajonTest() {
|
||||
runTest {
|
||||
myFixture.enableInspections(AssertThatSizeInspection::class.java)
|
||||
myFixture.configureByFile("SizeBefore.java")
|
||||
assertThat(myFixture.doHighlighting()).extrakting { it.description }.containsOnlyOnce("Try to operate on the iterable itself rather than its size")
|
||||
|
||||
executeQuickFixes(myFixture, Regex.fromLiteral("Replace isEqualTo() with isEmpty()"), 4)
|
||||
executeQuickFixes(myFixture, Regex.fromLiteral("Replace isZero() with isEmpty()"), 4)
|
||||
executeQuickFixes(myFixture, Regex.fromLiteral("Replace isNotZero() with isNotEmpty()"), 4)
|
||||
@@ -27,7 +31,7 @@ internal class AssertThatSizeInspectionTest : AbstractCajonTest() {
|
||||
executeQuickFixes(myFixture, Regex.fromLiteral("Replace isGreaterThanOrEqualTo() with hasSizeGreaterThanOrEqualTo()"), 4)
|
||||
executeQuickFixes(myFixture, Regex.fromLiteral("Replace isLessThan() with hasSizeLessThan()"), 4)
|
||||
executeQuickFixes(myFixture, Regex.fromLiteral("Replace isLessThanOrEqualTo() with hasSizeLessThanOrEqualTo()"), 4)
|
||||
executeQuickFixes(myFixture, Regex.fromLiteral("Remove size determination of expected expression and replace hasSize() with hasSameSizeAs()"), 12)
|
||||
executeQuickFixes(myFixture, Regex.fromLiteral("Remove size determination of expected expression and replace hasSize() with hasSameSizeAs()"), 14)
|
||||
myFixture.checkResultByFile("SizeAfter.java")
|
||||
}
|
||||
}
|
||||
|
||||
+14
-14
@@ -14,20 +14,20 @@ internal class AssertThatStringExpressionInspectionTest : AbstractCajonTest() {
|
||||
runTest {
|
||||
myFixture.enableInspections(AssertThatStringExpressionInspection::class.java)
|
||||
myFixture.configureByFile("StringExpressionBefore.java")
|
||||
executeQuickFixes(myFixture, Regex.fromLiteral("Remove isEmpty() of expected expression and use assertThat().isEmpty() instead"), 2)
|
||||
executeQuickFixes(myFixture, Regex.fromLiteral("Remove equals() of expected expression and use assertThat().isEqualTo() instead"), 2)
|
||||
executeQuickFixes(myFixture, Regex.fromLiteral("Remove equalsIgnoreCase() of expected expression and use assertThat().isEqualToIgnoringCase() instead"), 2)
|
||||
executeQuickFixes(myFixture, Regex.fromLiteral("Remove contentEquals() of expected expression and use assertThat().isEqualTo() instead"), 4)
|
||||
executeQuickFixes(myFixture, Regex.fromLiteral("Remove contains() of expected expression and use assertThat().contains() instead"), 4)
|
||||
executeQuickFixes(myFixture, Regex.fromLiteral("Remove startsWith() of expected expression and use assertThat().startsWith() instead"), 2)
|
||||
executeQuickFixes(myFixture, Regex.fromLiteral("Remove endsWith() of expected expression and use assertThat().endsWith() instead"), 2)
|
||||
executeQuickFixes(myFixture, Regex.fromLiteral("Remove isEmpty() of expected expression and use assertThat().isNotEmpty() instead"), 2)
|
||||
executeQuickFixes(myFixture, Regex.fromLiteral("Remove equals() of expected expression and use assertThat().isNotEqualTo() instead"), 2)
|
||||
executeQuickFixes(myFixture, Regex.fromLiteral("Remove equalsIgnoreCase() of expected expression and use assertThat().isNotEqualToIgnoringCase() instead"), 2)
|
||||
executeQuickFixes(myFixture, Regex.fromLiteral("Remove contentEquals() of expected expression and use assertThat().isNotEqualTo() instead"), 4)
|
||||
executeQuickFixes(myFixture, Regex.fromLiteral("Remove contains() of expected expression and use assertThat().doesNotContain() instead"), 4)
|
||||
executeQuickFixes(myFixture, Regex.fromLiteral("Remove startsWith() of expected expression and use assertThat().doesNotStartWith() instead"), 2)
|
||||
executeQuickFixes(myFixture, Regex.fromLiteral("Remove endsWith() of expected expression and use assertThat().doesNotEndWith() instead"), 2)
|
||||
executeQuickFixes(myFixture, Regex.fromLiteral("Remove isEmpty() of actual expression and use assertThat().isEmpty() instead"), 2)
|
||||
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 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)
|
||||
executeQuickFixes(myFixture, Regex.fromLiteral("Remove contains() of actual expression and use assertThat().doesNotContain() instead"), 4)
|
||||
executeQuickFixes(myFixture, Regex.fromLiteral("Remove startsWith() of actual expression and use assertThat().doesNotStartWith() instead"), 2)
|
||||
executeQuickFixes(myFixture, Regex.fromLiteral("Remove endsWith() of actual expression and use assertThat().doesNotEndWith() instead"), 3)
|
||||
myFixture.checkResultByFile("StringExpressionAfter.java")
|
||||
}
|
||||
}
|
||||
|
||||
+7
@@ -4,6 +4,8 @@ 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.assertj.core.api.Assertions.assertThat
|
||||
import org.assertj.core.api.extrakting
|
||||
import org.junit.jupiter.api.Test
|
||||
|
||||
internal class AssertThatStringIsEmptyInspectionTest : AbstractCajonTest() {
|
||||
@@ -14,6 +16,11 @@ internal class AssertThatStringIsEmptyInspectionTest : AbstractCajonTest() {
|
||||
runTest {
|
||||
myFixture.enableInspections(AssertThatStringIsEmptyInspection::class.java)
|
||||
myFixture.configureByFile("StringIsEmptyBefore.java")
|
||||
val highlights = myFixture.doHighlighting()
|
||||
.asSequence()
|
||||
.filter { it.description?.contains(" can be simplified to") ?: false }
|
||||
.toList()
|
||||
assertThat(highlights).hasSize(6).extrakting { it.text }.doesNotContain("assertThat")
|
||||
executeQuickFixes(myFixture, Regex.fromLiteral("Replace isEqualTo() with isEmpty()"), 3)
|
||||
executeQuickFixes(myFixture, Regex.fromLiteral("Replace hasSize() with isEmpty()"), 3)
|
||||
myFixture.checkResultByFile("StringIsEmptyAfter.java")
|
||||
|
||||
+1
-1
@@ -18,7 +18,7 @@ internal class JUnitAssertToAssertJInspectionTest : AbstractCajonTest() {
|
||||
runTest {
|
||||
myFixture.enableInspections(JUnitAssertToAssertJInspection::class.java)
|
||||
myFixture.configureByFile("JUnitAssertToAssertJInspectionBefore.java")
|
||||
executeQuickFixes(myFixture, Regex("Replace .*"), 38)
|
||||
executeQuickFixes(myFixture, Regex("Convert assert.*\\(\\) to assertThat\\(\\).*"), 38)
|
||||
myFixture.checkResultByFile("JUnitAssertToAssertJInspectionAfter.java")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
package org.assertj.core.api
|
||||
|
||||
import org.assertj.core.groups.FieldsOrPropertiesExtractor
|
||||
import java.util.*
|
||||
|
||||
// Workaround for ambiguous method signature of .extracting() see https://github.com/joel-costigliola/assertj-core/issues/1499
|
||||
fun <SELF : AbstractIterableAssert<SELF, ACTUAL, ELEMENT, ELEMENT_ASSERT>,
|
||||
ACTUAL : Iterable<ELEMENT>,
|
||||
ELEMENT,
|
||||
ELEMENT_ASSERT : AbstractAssert<ELEMENT_ASSERT, ELEMENT>,
|
||||
V>
|
||||
AbstractIterableAssert<SELF, ACTUAL, ELEMENT, ELEMENT_ASSERT>.extrakting(extractor: (ELEMENT) -> V): AbstractListAssert<*, List<V>, V, ObjectAssert<V>> {
|
||||
val values = FieldsOrPropertiesExtractor.extract(actual, extractor)
|
||||
if (actual is SortedSet<*>) {
|
||||
usingDefaultElementComparator()
|
||||
}
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
return newListAssertInstance(values).withAssertionState(myself) as AbstractListAssert<*, List<V>, V, ObjectAssert<V>>
|
||||
}
|
||||
@@ -10,7 +10,7 @@ public class BinaryExpression {
|
||||
String stringExp = "foo";
|
||||
String stringAct = "bar";
|
||||
|
||||
assertThat(primAct).isEqualTo(primExp);
|
||||
assertThat(primAct).as("doh!").isEqualTo(primExp);
|
||||
assertThat(primAct).isEqualTo(primExp);
|
||||
assertThat(primAct).isEqualTo(primExp);
|
||||
assertThat(primAct).isEqualTo(primExp);
|
||||
@@ -25,7 +25,7 @@ public class BinaryExpression {
|
||||
assertThat(primAct).isNotEqualTo(1);
|
||||
assertThat(primAct).isNotEqualTo(1);
|
||||
|
||||
assertThat(primAct).isNotEqualTo(primExp);
|
||||
assertThat(primAct).as("doh!").isNotEqualTo(primExp);
|
||||
assertThat(primAct).isNotEqualTo(primExp);
|
||||
assertThat(primAct).isNotEqualTo(primExp);
|
||||
assertThat(primAct).isNotEqualTo(1);
|
||||
@@ -36,7 +36,7 @@ public class BinaryExpression {
|
||||
assertThat(primAct).isEqualTo(1);
|
||||
assertThat(primAct).isEqualTo(1);
|
||||
|
||||
assertThat(primAct).isGreaterThan(primExp);
|
||||
assertThat(primAct).as("doh!").isGreaterThan(primExp);
|
||||
assertThat(primAct).isGreaterThan(primExp);
|
||||
assertThat(primAct).isGreaterThan(primExp);
|
||||
assertThat(primAct).isGreaterThan(1);
|
||||
@@ -47,7 +47,7 @@ public class BinaryExpression {
|
||||
assertThat(primAct).isLessThanOrEqualTo(1);
|
||||
assertThat(primAct).isLessThanOrEqualTo(1);
|
||||
|
||||
assertThat(primAct).isGreaterThanOrEqualTo(primExp);
|
||||
assertThat(primAct).as("doh!").isGreaterThanOrEqualTo(primExp);
|
||||
assertThat(primAct).isGreaterThanOrEqualTo(primExp);
|
||||
assertThat(primAct).isGreaterThanOrEqualTo(primExp);
|
||||
assertThat(primAct).isGreaterThanOrEqualTo(1);
|
||||
@@ -58,7 +58,7 @@ public class BinaryExpression {
|
||||
assertThat(primAct).isLessThan(1);
|
||||
assertThat(primAct).isLessThan(1);
|
||||
|
||||
assertThat(primAct).isLessThan(primExp);
|
||||
assertThat(primAct).as("doh!").isLessThan(primExp);
|
||||
assertThat(primAct).isLessThan(primExp);
|
||||
assertThat(primAct).isLessThan(primExp);
|
||||
assertThat(primAct).isLessThan(1);
|
||||
@@ -69,7 +69,7 @@ public class BinaryExpression {
|
||||
assertThat(primAct).isGreaterThanOrEqualTo(1);
|
||||
assertThat(primAct).isGreaterThanOrEqualTo(1);
|
||||
|
||||
assertThat(primAct).isLessThanOrEqualTo(primExp);
|
||||
assertThat(primAct).as("doh!").isLessThanOrEqualTo(primExp);
|
||||
assertThat(primAct).isLessThanOrEqualTo(primExp);
|
||||
assertThat(primAct).isLessThanOrEqualTo(primExp);
|
||||
assertThat(primAct).isLessThanOrEqualTo(1);
|
||||
@@ -80,7 +80,7 @@ public class BinaryExpression {
|
||||
assertThat(primAct).isGreaterThan(1);
|
||||
assertThat(primAct).isGreaterThan(1);
|
||||
|
||||
assertThat(numberObjAct).isEqualTo(numberObjExp);
|
||||
assertThat(numberObjAct).as("doh!").isEqualTo(numberObjExp);
|
||||
assertThat(numberObjAct).isEqualTo(numberObjExp);
|
||||
assertThat(numberObjAct).isEqualTo(numberObjExp);
|
||||
assertThat(numberObjAct).isEqualTo(1);
|
||||
@@ -91,7 +91,7 @@ public class BinaryExpression {
|
||||
assertThat(numberObjAct).isNotEqualTo(1);
|
||||
assertThat(numberObjAct).isNotEqualTo(1);
|
||||
|
||||
assertThat(numberObjAct).isNotEqualTo(numberObjExp);
|
||||
assertThat(numberObjAct).as("doh!").isNotEqualTo(numberObjExp);
|
||||
assertThat(numberObjAct).isNotEqualTo(numberObjExp);
|
||||
assertThat(numberObjAct).isNotEqualTo(numberObjExp);
|
||||
assertThat(numberObjAct).isNotEqualTo(1);
|
||||
@@ -102,7 +102,7 @@ public class BinaryExpression {
|
||||
assertThat(numberObjAct).isEqualTo(1);
|
||||
assertThat(numberObjAct).isEqualTo(1);
|
||||
|
||||
assertThat(numberObjAct).isGreaterThan(numberObjExp);
|
||||
assertThat(numberObjAct).as("doh!").isGreaterThan(numberObjExp);
|
||||
assertThat(numberObjAct).isGreaterThan(numberObjExp);
|
||||
assertThat(numberObjAct).isGreaterThan(numberObjExp);
|
||||
assertThat(numberObjAct).isGreaterThan(1);
|
||||
@@ -113,7 +113,7 @@ public class BinaryExpression {
|
||||
assertThat(numberObjAct).isLessThanOrEqualTo(1);
|
||||
assertThat(numberObjAct).isLessThanOrEqualTo(1);
|
||||
|
||||
assertThat(numberObjAct).isGreaterThanOrEqualTo(numberObjExp);
|
||||
assertThat(numberObjAct).as("doh!").isGreaterThanOrEqualTo(numberObjExp);
|
||||
assertThat(numberObjAct).isGreaterThanOrEqualTo(numberObjExp);
|
||||
assertThat(numberObjAct).isGreaterThanOrEqualTo(numberObjExp);
|
||||
assertThat(numberObjAct).isGreaterThanOrEqualTo(1);
|
||||
@@ -124,7 +124,7 @@ public class BinaryExpression {
|
||||
assertThat(numberObjAct).isLessThan(1);
|
||||
assertThat(numberObjAct).isLessThan(1);
|
||||
|
||||
assertThat(numberObjAct).isLessThan(numberObjExp);
|
||||
assertThat(numberObjAct).as("doh!").isLessThan(numberObjExp);
|
||||
assertThat(numberObjAct).isLessThan(numberObjExp);
|
||||
assertThat(numberObjAct).isLessThan(numberObjExp);
|
||||
assertThat(numberObjAct).isLessThan(1);
|
||||
@@ -135,7 +135,7 @@ public class BinaryExpression {
|
||||
assertThat(numberObjAct).isGreaterThanOrEqualTo(1);
|
||||
assertThat(numberObjAct).isGreaterThanOrEqualTo(1);
|
||||
|
||||
assertThat(numberObjAct).isLessThanOrEqualTo(numberObjExp);
|
||||
assertThat(numberObjAct).as("doh!").isLessThanOrEqualTo(numberObjExp);
|
||||
assertThat(numberObjAct).isLessThanOrEqualTo(numberObjExp);
|
||||
assertThat(numberObjAct).isLessThanOrEqualTo(numberObjExp);
|
||||
assertThat(numberObjAct).isLessThanOrEqualTo(1);
|
||||
@@ -146,42 +146,42 @@ public class BinaryExpression {
|
||||
assertThat(numberObjAct).isGreaterThan(1);
|
||||
assertThat(numberObjAct).isGreaterThan(1);
|
||||
|
||||
assertThat(numberObjAct).isEqualTo(numberObjExp);
|
||||
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(stringAct).isSameAs(stringExp);
|
||||
assertThat(stringAct).as("doh!").isSameAs(stringExp);
|
||||
assertThat(stringAct).isSameAs(stringExp);
|
||||
assertThat(stringAct).isSameAs(stringExp);
|
||||
assertThat(stringAct).isNotSameAs(stringExp);
|
||||
assertThat(stringAct).isNotSameAs(stringExp);
|
||||
assertThat(stringAct).isNotSameAs(stringExp);
|
||||
|
||||
assertThat(stringAct).isEqualTo(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).isNotSameAs(stringExp);
|
||||
assertThat(stringAct).as("doh!").isNotSameAs(stringExp);
|
||||
assertThat(stringAct).isNotSameAs(stringExp);
|
||||
assertThat(stringAct).isNotSameAs(stringExp);
|
||||
assertThat(stringAct).isSameAs(stringExp);
|
||||
assertThat(stringAct).isSameAs(stringExp);
|
||||
assertThat(stringAct).isSameAs(stringExp);
|
||||
|
||||
assertThat(stringAct).isNull();
|
||||
assertThat(stringAct).as("doh!").isNull();
|
||||
assertThat(stringAct).isNull();
|
||||
assertThat(stringAct).isNull();
|
||||
assertThat(stringAct).isNotNull();
|
||||
assertThat(stringAct).isNotNull();
|
||||
assertThat(stringAct).isNotNull();
|
||||
|
||||
assertThat(stringAct).isNull();
|
||||
assertThat(stringAct).as("doh!").isNull();
|
||||
assertThat(stringAct).isNull();
|
||||
assertThat(stringAct).isNull();
|
||||
assertThat(stringAct).isNotNull();
|
||||
@@ -190,5 +190,10 @@ public class BinaryExpression {
|
||||
|
||||
assertThat(null == null).isTrue();
|
||||
assertThat(!false).isTrue();
|
||||
|
||||
assertThat(primAct).as("doh!").isEqualTo(primExp).isEqualTo(primExp);
|
||||
assertThat(primAct == primExp).isFalse().as("doh!").isEqualTo(true);
|
||||
|
||||
assertThat(numberObjAct).as("doh!").isEqualTo(numberObjExp).isEqualTo(numberObjExp);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ public class BinaryExpression {
|
||||
String stringExp = "foo";
|
||||
String stringAct = "bar";
|
||||
|
||||
assertThat(primAct == primExp).isTrue();
|
||||
assertThat(primAct == primExp).as("doh!").isTrue();
|
||||
assertThat(primAct == primExp).isEqualTo(true);
|
||||
assertThat(primAct == primExp).isEqualTo(Boolean.TRUE);
|
||||
assertThat(primAct == primExp).isNotEqualTo(false);
|
||||
@@ -25,7 +25,7 @@ public class BinaryExpression {
|
||||
assertThat(primAct == 1).isFalse();
|
||||
assertThat(1 == primAct).isFalse();
|
||||
|
||||
assertThat(primAct != primExp).isTrue();
|
||||
assertThat(primAct != primExp).as("doh!").isTrue();
|
||||
assertThat(primAct != primExp).isEqualTo(true);
|
||||
assertThat(primAct != primExp).isNotEqualTo(false);
|
||||
assertThat(primAct != 1).isTrue();
|
||||
@@ -36,7 +36,7 @@ public class BinaryExpression {
|
||||
assertThat(primAct != 1).isFalse();
|
||||
assertThat(1 != primAct).isFalse();
|
||||
|
||||
assertThat(primAct > primExp).isTrue();
|
||||
assertThat(primAct > primExp).as("doh!").isTrue();
|
||||
assertThat(primAct > primExp).isEqualTo(true);
|
||||
assertThat(primAct > primExp).isNotEqualTo(false);
|
||||
assertThat(primAct > 1).isTrue();
|
||||
@@ -47,7 +47,7 @@ public class BinaryExpression {
|
||||
assertThat(primAct > 1).isFalse();
|
||||
assertThat(1 < primAct).isFalse();
|
||||
|
||||
assertThat(primAct >= primExp).isTrue();
|
||||
assertThat(primAct >= primExp).as("doh!").isTrue();
|
||||
assertThat(primAct >= primExp).isEqualTo(true);
|
||||
assertThat(primAct >= primExp).isNotEqualTo(false);
|
||||
assertThat(primAct >= 1).isTrue();
|
||||
@@ -58,7 +58,7 @@ public class BinaryExpression {
|
||||
assertThat(primAct >= 1).isFalse();
|
||||
assertThat(1 <= primAct).isFalse();
|
||||
|
||||
assertThat(primAct < primExp).isTrue();
|
||||
assertThat(primAct < primExp).as("doh!").isTrue();
|
||||
assertThat(primAct < primExp).isEqualTo(true);
|
||||
assertThat(primAct < primExp).isNotEqualTo(false);
|
||||
assertThat(primAct < 1).isTrue();
|
||||
@@ -69,7 +69,7 @@ public class BinaryExpression {
|
||||
assertThat(primAct < 1).isFalse();
|
||||
assertThat(1 > primAct).isFalse();
|
||||
|
||||
assertThat(primAct <= primExp).isTrue();
|
||||
assertThat(primAct <= primExp).as("doh!").isTrue();
|
||||
assertThat(primAct <= primExp).isEqualTo(true);
|
||||
assertThat(primAct <= primExp).isNotEqualTo(false);
|
||||
assertThat(primAct <= 1).isTrue();
|
||||
@@ -80,7 +80,7 @@ public class BinaryExpression {
|
||||
assertThat(primAct <= 1).isFalse();
|
||||
assertThat(1 >= primAct).isFalse();
|
||||
|
||||
assertThat(numberObjAct == numberObjExp).isTrue();
|
||||
assertThat(numberObjAct == numberObjExp).as("doh!").isTrue();
|
||||
assertThat(numberObjAct == numberObjExp).isEqualTo(true);
|
||||
assertThat(numberObjAct == numberObjExp).isNotEqualTo(false);
|
||||
assertThat(numberObjAct == 1).isTrue();
|
||||
@@ -91,7 +91,7 @@ public class BinaryExpression {
|
||||
assertThat(numberObjAct == 1).isFalse();
|
||||
assertThat(1 == numberObjAct).isFalse();
|
||||
|
||||
assertThat(numberObjAct != numberObjExp).isTrue();
|
||||
assertThat(numberObjAct != numberObjExp).as("doh!").isTrue();
|
||||
assertThat(numberObjAct != numberObjExp).isEqualTo(true);
|
||||
assertThat(numberObjAct != numberObjExp).isNotEqualTo(false);
|
||||
assertThat(numberObjAct != 1).isTrue();
|
||||
@@ -102,7 +102,7 @@ public class BinaryExpression {
|
||||
assertThat(numberObjAct != 1).isFalse();
|
||||
assertThat(1 != numberObjAct).isFalse();
|
||||
|
||||
assertThat(numberObjAct > numberObjExp).isTrue();
|
||||
assertThat(numberObjAct > numberObjExp).as("doh!").isTrue();
|
||||
assertThat(numberObjAct > numberObjExp).isEqualTo(true);
|
||||
assertThat(numberObjAct > numberObjExp).isNotEqualTo(false);
|
||||
assertThat(numberObjAct > 1).isTrue();
|
||||
@@ -113,7 +113,7 @@ public class BinaryExpression {
|
||||
assertThat(numberObjAct > 1).isFalse();
|
||||
assertThat(1 < numberObjAct).isFalse();
|
||||
|
||||
assertThat(numberObjAct >= numberObjExp).isTrue();
|
||||
assertThat(numberObjAct >= numberObjExp).as("doh!").isTrue();
|
||||
assertThat(numberObjAct >= numberObjExp).isEqualTo(true);
|
||||
assertThat(numberObjAct >= numberObjExp).isNotEqualTo(false);
|
||||
assertThat(numberObjAct >= 1).isTrue();
|
||||
@@ -124,7 +124,7 @@ public class BinaryExpression {
|
||||
assertThat(numberObjAct >= 1).isFalse();
|
||||
assertThat(1 <= numberObjAct).isFalse();
|
||||
|
||||
assertThat(numberObjAct < numberObjExp).isTrue();
|
||||
assertThat(numberObjAct < numberObjExp).as("doh!").isTrue();
|
||||
assertThat(numberObjAct < numberObjExp).isEqualTo(true);
|
||||
assertThat(numberObjAct < numberObjExp).isNotEqualTo(false);
|
||||
assertThat(numberObjAct < 1).isTrue();
|
||||
@@ -135,7 +135,7 @@ public class BinaryExpression {
|
||||
assertThat(numberObjAct < 1).isFalse();
|
||||
assertThat(1 > numberObjAct).isFalse();
|
||||
|
||||
assertThat(numberObjAct <= numberObjExp).isTrue();
|
||||
assertThat(numberObjAct <= numberObjExp).as("doh!").isTrue();
|
||||
assertThat(numberObjAct <= numberObjExp).isEqualTo(true);
|
||||
assertThat(numberObjAct <= numberObjExp).isNotEqualTo(false);
|
||||
assertThat(numberObjAct <= 1).isTrue();
|
||||
@@ -146,42 +146,42 @@ public class BinaryExpression {
|
||||
assertThat(numberObjAct <= 1).isFalse();
|
||||
assertThat(1 >= numberObjAct).isFalse();
|
||||
|
||||
assertThat(numberObjAct.equals(numberObjExp)).isTrue();
|
||||
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 == stringExp).isTrue();
|
||||
assertThat(stringAct == stringExp).as("doh!").isTrue();
|
||||
assertThat(stringAct == stringExp).isEqualTo(true);
|
||||
assertThat(stringAct == stringExp).isNotEqualTo(false);
|
||||
assertThat(stringAct == stringExp).isFalse();
|
||||
assertThat(stringAct == stringExp).isEqualTo(false);
|
||||
assertThat(stringAct == stringExp).isNotEqualTo(true);
|
||||
|
||||
assertThat(stringAct.equals(stringExp)).isTrue();
|
||||
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 != stringExp).isTrue();
|
||||
assertThat(stringAct != stringExp).as("doh!").isTrue();
|
||||
assertThat(stringAct != stringExp).isEqualTo(true);
|
||||
assertThat(stringAct != stringExp).isNotEqualTo(false);
|
||||
assertThat(stringAct != stringExp).isFalse();
|
||||
assertThat(stringAct != stringExp).isEqualTo(false);
|
||||
assertThat(stringAct != stringExp).isNotEqualTo(true);
|
||||
|
||||
assertThat(stringAct == null).isTrue();
|
||||
assertThat(stringAct == null).as("doh!").isTrue();
|
||||
assertThat(stringAct == null).isEqualTo(true);
|
||||
assertThat(stringAct == null).isNotEqualTo(false);
|
||||
assertThat(stringAct == null).isFalse();
|
||||
assertThat(stringAct == null).isEqualTo(false);
|
||||
assertThat(stringAct == null).isNotEqualTo(true);
|
||||
|
||||
assertThat(null == stringAct).isTrue();
|
||||
assertThat(null == stringAct).as("doh!").isTrue();
|
||||
assertThat(null == stringAct).isEqualTo(true);
|
||||
assertThat(null == stringAct).isNotEqualTo(false);
|
||||
assertThat(null == stringAct).isFalse();
|
||||
@@ -190,5 +190,10 @@ public class BinaryExpression {
|
||||
|
||||
assertThat(null == null).isTrue();
|
||||
assertThat(!false).isTrue();
|
||||
|
||||
assertThat(primAct == primExp).as("doh!").isTrue().isEqualTo(true);
|
||||
assertThat(primAct == primExp).isFalse().as("doh!").isEqualTo(true);
|
||||
|
||||
assertThat(numberObjAct.equals(numberObjExp)).as("doh!").isTrue().isEqualTo(true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,24 +8,24 @@ public class GuavaOptional {
|
||||
private void guavaOptional() {
|
||||
Optional<String> opt = Optional.absent();
|
||||
|
||||
assertThat(opt).isPresent();
|
||||
assertThat(opt).as("foo").isPresent();
|
||||
assertThat(opt).isPresent();
|
||||
assertThat(opt).isPresent();
|
||||
assertThat(opt).isPresent();
|
||||
assertThat(opt).isPresent();
|
||||
|
||||
assertThat(opt).isAbsent();
|
||||
assertThat(opt).as("foo").isAbsent();
|
||||
assertThat(opt).isAbsent();
|
||||
assertThat(opt).isAbsent();
|
||||
assertThat(opt).isAbsent();
|
||||
assertThat(opt).isAbsent();
|
||||
|
||||
assertThat(opt).contains("foo");
|
||||
assertThat(opt).as("foo").contains("foo");
|
||||
assertThat(opt.get()).isSameAs("foo");
|
||||
assertThat(opt.get()).isNotEqualTo("foo");
|
||||
assertThat(opt.get()).isNotSameAs("foo");
|
||||
|
||||
assertThat(opt).contains("foo");
|
||||
assertThat(opt).as("foo").contains("foo");
|
||||
assertThat(opt).contains("foo");
|
||||
assertThat(opt).isNotEqualTo(Optional.of("foo"));
|
||||
assertThat(opt).isNotEqualTo(Optional.fromNullable("foo"));
|
||||
@@ -33,20 +33,23 @@ public class GuavaOptional {
|
||||
assertThat(opt).isAbsent();
|
||||
assertThat(opt).isPresent();
|
||||
|
||||
org.assertj.guava.api.Assertions.assertThat(opt).contains("foo");
|
||||
org.assertj.guava.api.Assertions.assertThat(opt).contains("foo");
|
||||
assertThat(opt).as("foo").contains("foo");
|
||||
assertThat(opt).contains("foo");
|
||||
org.assertj.guava.api.Assertions.assertThat(opt).isNotEqualTo(Optional.of("foo"));
|
||||
org.assertj.guava.api.Assertions.assertThat(opt).isNotEqualTo(Optional.fromNullable("foo"));
|
||||
|
||||
org.assertj.guava.api.Assertions.assertThat(opt).isAbsent();
|
||||
org.assertj.guava.api.Assertions.assertThat(opt).isPresent();
|
||||
assertThat(opt).as("foo").isAbsent();
|
||||
assertThat(opt).isPresent();
|
||||
|
||||
assertThat(opt).contains("foo");
|
||||
assertThat(opt).as("foo").contains("foo");
|
||||
assertThat(opt).contains("foo");
|
||||
org.assertj.core.api.Assertions.assertThat(opt).isNotEqualTo(Optional.of("foo"));
|
||||
org.assertj.core.api.Assertions.assertThat(opt).isNotEqualTo(Optional.fromNullable("foo"));
|
||||
|
||||
assertThat(opt).isAbsent();
|
||||
assertThat(opt).as("foo").isAbsent();
|
||||
assertThat(opt).isPresent();
|
||||
|
||||
assertThat(opt).as("foo").isPresent().as("bar").isPresent();
|
||||
assertThat(opt.isPresent()).as("foo").isEqualTo(true).as("bar").isEqualTo(Boolean.FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,24 +8,24 @@ public class GuavaOptional {
|
||||
private void guavaOptional() {
|
||||
Optional<String> opt = Optional.absent();
|
||||
|
||||
assertThat(opt.isPresent()).isEqualTo(true);
|
||||
assertThat(opt.isPresent()).as("foo").isEqualTo(true);
|
||||
assertThat(opt.isPresent()).isEqualTo(Boolean.TRUE);
|
||||
assertThat(opt.isPresent()).isNotEqualTo(false);
|
||||
assertThat(opt.isPresent()).isNotEqualTo(Boolean.FALSE);
|
||||
assertThat(opt.isPresent()).isTrue();
|
||||
|
||||
assertThat(opt.isPresent()).isEqualTo(false);
|
||||
assertThat(opt.isPresent()).as("foo").isEqualTo(false);
|
||||
assertThat(opt.isPresent()).isEqualTo(Boolean.FALSE);
|
||||
assertThat(opt.isPresent()).isNotEqualTo(true);
|
||||
assertThat(opt.isPresent()).isNotEqualTo(Boolean.TRUE);
|
||||
assertThat(opt.isPresent()).isFalse();
|
||||
|
||||
assertThat(opt.get()).isEqualTo("foo");
|
||||
assertThat(opt.get()).as("foo").isEqualTo("foo");
|
||||
assertThat(opt.get()).isSameAs("foo");
|
||||
assertThat(opt.get()).isNotEqualTo("foo");
|
||||
assertThat(opt.get()).isNotSameAs("foo");
|
||||
|
||||
assertThat(opt).isEqualTo(Optional.of("foo"));
|
||||
assertThat(opt).as("foo").isEqualTo(Optional.of("foo"));
|
||||
assertThat(opt).isEqualTo(Optional.fromNullable("foo"));
|
||||
assertThat(opt).isNotEqualTo(Optional.of("foo"));
|
||||
assertThat(opt).isNotEqualTo(Optional.fromNullable("foo"));
|
||||
@@ -33,20 +33,23 @@ public class GuavaOptional {
|
||||
assertThat(opt).isEqualTo(Optional.absent());
|
||||
assertThat(opt).isNotEqualTo(Optional.absent());
|
||||
|
||||
org.assertj.guava.api.Assertions.assertThat(opt).isEqualTo(Optional.of("foo"));
|
||||
org.assertj.guava.api.Assertions.assertThat(opt).as("foo").isEqualTo(Optional.of("foo"));
|
||||
org.assertj.guava.api.Assertions.assertThat(opt).isEqualTo(Optional.fromNullable("foo"));
|
||||
org.assertj.guava.api.Assertions.assertThat(opt).isNotEqualTo(Optional.of("foo"));
|
||||
org.assertj.guava.api.Assertions.assertThat(opt).isNotEqualTo(Optional.fromNullable("foo"));
|
||||
|
||||
org.assertj.guava.api.Assertions.assertThat(opt).isEqualTo(Optional.absent());
|
||||
org.assertj.guava.api.Assertions.assertThat(opt).as("foo").isEqualTo(Optional.absent());
|
||||
org.assertj.guava.api.Assertions.assertThat(opt).isNotEqualTo(Optional.absent());
|
||||
|
||||
org.assertj.core.api.Assertions.assertThat(opt).isEqualTo(Optional.of("foo"));
|
||||
org.assertj.core.api.Assertions.assertThat(opt).as("foo").isEqualTo(Optional.of("foo"));
|
||||
org.assertj.core.api.Assertions.assertThat(opt).isEqualTo(Optional.fromNullable("foo"));
|
||||
org.assertj.core.api.Assertions.assertThat(opt).isNotEqualTo(Optional.of("foo"));
|
||||
org.assertj.core.api.Assertions.assertThat(opt).isNotEqualTo(Optional.fromNullable("foo"));
|
||||
|
||||
org.assertj.core.api.Assertions.assertThat(opt).isEqualTo(Optional.absent());
|
||||
org.assertj.core.api.Assertions.assertThat(opt).as("foo").isEqualTo(Optional.absent());
|
||||
org.assertj.core.api.Assertions.assertThat(opt).isNotEqualTo(Optional.absent());
|
||||
|
||||
assertThat(opt.isPresent()).as("foo").isEqualTo(true).as("bar").isEqualTo(Boolean.TRUE);
|
||||
assertThat(opt.isPresent()).as("foo").isEqualTo(true).as("bar").isEqualTo(Boolean.FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,18 +5,21 @@ public class InstanceOf {
|
||||
private void instanceOf() {
|
||||
Boolean object = Boolean.TRUE;
|
||||
|
||||
assertThat(object).isInstanceOf(Boolean.class);
|
||||
assertThat(object).as("foo").isInstanceOf(Boolean.class);
|
||||
assertThat(object).isInstanceOf(Boolean.class);
|
||||
assertThat(object).isInstanceOf(Boolean.class);
|
||||
assertThat(object).isInstanceOf(Boolean.class);
|
||||
assertThat(object).isInstanceOf(Boolean.class);
|
||||
|
||||
assertThat(object).isNotInstanceOf(Boolean.class);
|
||||
assertThat(object).as("foo").isNotInstanceOf(Boolean.class);
|
||||
assertThat(object).isNotInstanceOf(Boolean.class);
|
||||
assertThat(object).isNotInstanceOf(Boolean.class);
|
||||
assertThat(object).isNotInstanceOf(Boolean.class);
|
||||
assertThat(object).isNotInstanceOf(Boolean.class);
|
||||
|
||||
assertThat(object).as("nah").isNotInstanceOf(Boolean.class);
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,18 +5,21 @@ public class InstanceOf {
|
||||
private void instanceOf() {
|
||||
Boolean object = Boolean.TRUE;
|
||||
|
||||
assertThat(object instanceof Boolean).isEqualTo(Boolean.TRUE);
|
||||
assertThat(object instanceof Boolean).as("foo").isEqualTo(Boolean.TRUE);
|
||||
assertThat(object instanceof Boolean).isEqualTo(true);
|
||||
assertThat(object instanceof Boolean).isNotEqualTo(Boolean.FALSE);
|
||||
assertThat(object instanceof Boolean).isNotEqualTo(false);
|
||||
assertThat(object instanceof Boolean).isTrue();
|
||||
|
||||
assertThat(object instanceof Boolean).isEqualTo(Boolean.FALSE);
|
||||
assertThat(object instanceof Boolean).as("foo").isEqualTo(Boolean.FALSE);
|
||||
assertThat(object instanceof Boolean).isEqualTo(false);
|
||||
assertThat(object instanceof Boolean).isNotEqualTo(Boolean.TRUE);
|
||||
assertThat(object instanceof Boolean).isNotEqualTo(true);
|
||||
assertThat(object instanceof Boolean).isFalse();
|
||||
|
||||
assertThat(((object)) instanceof Boolean).as("nah").isEqualTo(true && !true);
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
+9
-4
@@ -6,23 +6,25 @@ public class InvertedBooleanCondition {
|
||||
boolean primitive = false;
|
||||
Boolean object = Boolean.TRUE;
|
||||
|
||||
assertThat(primitive).as("foo").isFalse();
|
||||
assertThat(primitive).isFalse();
|
||||
assertThat(primitive).isFalse();
|
||||
assertThat(primitive).isFalse();
|
||||
assertThat(primitive).isFalse();
|
||||
assertThat(primitive).isFalse();
|
||||
assertThat(object).isFalse();
|
||||
|
||||
assertThat(object).as("foo").isFalse();
|
||||
assertThat(object).isFalse();
|
||||
assertThat(object).isFalse();
|
||||
assertThat(object).isFalse();
|
||||
assertThat(object).isFalse();
|
||||
|
||||
assertThat(primitive).as("foo").isTrue();
|
||||
assertThat(primitive).isTrue();
|
||||
assertThat(primitive).isTrue();
|
||||
assertThat(primitive).isTrue();
|
||||
assertThat(primitive).isTrue();
|
||||
assertThat(primitive).isTrue();
|
||||
assertThat(object).isTrue();
|
||||
|
||||
assertThat(object).as("foo").isTrue();
|
||||
assertThat(object).isTrue();
|
||||
assertThat(object).isTrue();
|
||||
assertThat(object).isTrue();
|
||||
@@ -30,5 +32,8 @@ public class InvertedBooleanCondition {
|
||||
|
||||
assertThat(!((primitive))).as("nah").isTrue();
|
||||
assertThat(!object).isEqualTo(Boolean.TRUE && !Boolean.TRUE);
|
||||
|
||||
assertThat(primitive).as("foo").isFalse().as("bar").isFalse();
|
||||
assertThat(primitive).as("foo").isFalse().as("bar").isTrue();
|
||||
}
|
||||
}
|
||||
|
||||
+9
-4
@@ -6,23 +6,25 @@ public class InvertedBooleanCondition {
|
||||
boolean primitive = false;
|
||||
Boolean object = Boolean.TRUE;
|
||||
|
||||
assertThat(!primitive).isEqualTo(Boolean.TRUE);
|
||||
assertThat(!primitive).as("foo").isEqualTo(Boolean.TRUE);
|
||||
assertThat(!primitive).isEqualTo(true);
|
||||
assertThat(!primitive).isNotEqualTo(Boolean.FALSE);
|
||||
assertThat(!primitive).isNotEqualTo(false);
|
||||
assertThat(!primitive).isTrue();
|
||||
assertThat(!object).isEqualTo(Boolean.TRUE);
|
||||
|
||||
assertThat(!object).as("foo").isEqualTo(Boolean.TRUE);
|
||||
assertThat(!object).isEqualTo(true);
|
||||
assertThat(!object).isNotEqualTo(Boolean.FALSE);
|
||||
assertThat(!object).isNotEqualTo(false);
|
||||
assertThat(!object).isTrue();
|
||||
|
||||
assertThat(!primitive).isEqualTo(Boolean.FALSE);
|
||||
assertThat(!primitive).as("foo").isEqualTo(Boolean.FALSE);
|
||||
assertThat(!primitive).isEqualTo(false);
|
||||
assertThat(!primitive).isNotEqualTo(Boolean.TRUE);
|
||||
assertThat(!primitive).isNotEqualTo(true);
|
||||
assertThat(!primitive).isFalse();
|
||||
assertThat(!object).isEqualTo(Boolean.FALSE);
|
||||
|
||||
assertThat(!object).as("foo").isEqualTo(Boolean.FALSE);
|
||||
assertThat(!object).isEqualTo(false);
|
||||
assertThat(!object).isNotEqualTo(Boolean.TRUE);
|
||||
assertThat(!object).isNotEqualTo(true);
|
||||
@@ -30,5 +32,8 @@ public class InvertedBooleanCondition {
|
||||
|
||||
assertThat(!(((!((primitive)))))).as("nah").isEqualTo(true && !true);
|
||||
assertThat(!object).isEqualTo(Boolean.TRUE && !Boolean.TRUE);
|
||||
|
||||
assertThat(!primitive).as("foo").isEqualTo(Boolean.TRUE).as("bar").isNotEqualTo(false);
|
||||
assertThat(!primitive).as("foo").isEqualTo(Boolean.TRUE).as("bar").isNotEqualTo(true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ public class Java8Optional {
|
||||
private void java8Optional() {
|
||||
Optional<String> opt = Optional.empty();
|
||||
|
||||
assertThat(opt).isPresent();
|
||||
assertThat(opt).as("foo").isPresent();
|
||||
assertThat(opt).isPresent();
|
||||
assertThat(opt).isPresent();
|
||||
assertThat(opt).isPresent();
|
||||
@@ -19,17 +19,22 @@ public class Java8Optional {
|
||||
assertThat(opt).isNotPresent();
|
||||
assertThat(opt).isNotPresent();
|
||||
|
||||
assertThat(opt).contains("foo");
|
||||
assertThat(opt).as("foo").contains("foo");
|
||||
assertThat(opt).containsSame("foo");
|
||||
assertThat(opt.get()).isNotEqualTo("foo");
|
||||
assertThat(opt.get()).isNotSameAs("foo");
|
||||
|
||||
assertThat(opt).contains("foo");
|
||||
assertThat(opt).as("foo").contains("foo");
|
||||
assertThat(opt).contains("foo");
|
||||
assertThat(opt).isNotEqualTo(Optional.of("foo"));
|
||||
assertThat(opt).isNotEqualTo(Optional.ofNullable("foo"));
|
||||
|
||||
assertThat(opt).isNotPresent();
|
||||
assertThat(opt).as("foo").isNotPresent();
|
||||
assertThat(opt).isPresent();
|
||||
|
||||
assertThat(opt).as("foo").isPresent().as("bar").isPresent();
|
||||
assertThat(opt.isPresent()).as("foo").isEqualTo(false).as("bar").isTrue();
|
||||
|
||||
assertThat(opt.get()).isEqualTo("foo").isSameAs("foo").isNotEqualTo("foo").isNotSameAs("foo");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ public class Java8Optional {
|
||||
private void java8Optional() {
|
||||
Optional<String> opt = Optional.empty();
|
||||
|
||||
assertThat(opt.isPresent()).isEqualTo(true);
|
||||
assertThat(opt.isPresent()).as("foo").isEqualTo(true);
|
||||
assertThat(opt.isPresent()).isEqualTo(Boolean.TRUE);
|
||||
assertThat(opt.isPresent()).isNotEqualTo(false);
|
||||
assertThat(opt.isPresent()).isNotEqualTo(Boolean.FALSE);
|
||||
@@ -19,17 +19,22 @@ public class Java8Optional {
|
||||
assertThat(opt.isPresent()).isNotEqualTo(Boolean.TRUE);
|
||||
assertThat(opt.isPresent()).isFalse();
|
||||
|
||||
assertThat(opt.get()).isEqualTo("foo");
|
||||
assertThat(opt.get()).as("foo").isEqualTo("foo");
|
||||
assertThat(opt.get()).isSameAs("foo");
|
||||
assertThat(opt.get()).isNotEqualTo("foo");
|
||||
assertThat(opt.get()).isNotSameAs("foo");
|
||||
|
||||
assertThat(opt).isEqualTo(Optional.of("foo"));
|
||||
assertThat(opt).as("foo").isEqualTo(Optional.of("foo"));
|
||||
assertThat(opt).isEqualTo(Optional.ofNullable("foo"));
|
||||
assertThat(opt).isNotEqualTo(Optional.of("foo"));
|
||||
assertThat(opt).isNotEqualTo(Optional.ofNullable("foo"));
|
||||
|
||||
assertThat(opt).isEqualTo(Optional.empty());
|
||||
assertThat(opt).as("foo").isEqualTo(Optional.empty());
|
||||
assertThat(opt).isNotEqualTo(Optional.empty());
|
||||
|
||||
assertThat(opt.isPresent()).as("foo").isEqualTo(true).as("bar").isTrue();
|
||||
assertThat(opt.isPresent()).as("foo").isEqualTo(false).as("bar").isTrue();
|
||||
|
||||
assertThat(opt.get()).isEqualTo("foo").isSameAs("foo").isNotEqualTo("foo").isNotSameAs("foo");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,5 +46,7 @@ public class JoinStatements {
|
||||
Iterator<String> iterator = list.iterator();
|
||||
assertThat(iterator.next()).isEqualTo("foo");
|
||||
assertThat(iterator.next()).isEqualTo("bar");
|
||||
assertThat(iterator.next().toLowerCase()).isEqualTo("foo");
|
||||
assertThat(iterator.next().toLowerCase()).isEqualTo("bar");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,5 +48,7 @@ public class JoinStatements {
|
||||
Iterator<String> iterator = list.iterator();
|
||||
assertThat(iterator.next()).isEqualTo("foo");
|
||||
assertThat(iterator.next()).isEqualTo("bar");
|
||||
assertThat(iterator.next().toLowerCase()).isEqualTo("foo");
|
||||
assertThat(iterator.next().toLowerCase()).isEqualTo("bar");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -95,5 +95,9 @@ public class Size {
|
||||
assertThat(stringBuilder).hasSameSizeAs(array);
|
||||
assertThat(stringBuilder).hasSameSizeAs(string);
|
||||
assertThat(stringBuilder).hasSameSizeAs(stringBuilder);
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -95,5 +95,9 @@ public class Size {
|
||||
assertThat(stringBuilder).hasSize(array.length);
|
||||
assertThat(stringBuilder).hasSize(string.length());
|
||||
assertThat(stringBuilder).hasSize(stringBuilder.length());
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ public class StringExpression {
|
||||
String string = "string";
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
|
||||
assertThat(string).isEmpty();
|
||||
assertThat(string).as("foo").isEmpty();
|
||||
assertThat(string).isEmpty();
|
||||
assertThat(string).isEqualTo("foo");
|
||||
assertThat(string).isEqualTo("foo");
|
||||
@@ -25,7 +25,7 @@ public class StringExpression {
|
||||
assertThat(string).endsWith("foo");
|
||||
assertThat(string).endsWith("foo");
|
||||
|
||||
assertThat(string).isNotEmpty();
|
||||
assertThat(string).as("foo").isNotEmpty();
|
||||
assertThat(string).isNotEmpty();
|
||||
assertThat(string).isNotEqualTo("foo");
|
||||
assertThat(string).isNotEqualTo("foo");
|
||||
@@ -43,5 +43,9 @@ public class StringExpression {
|
||||
assertThat(string).doesNotStartWith("foo");
|
||||
assertThat(string).doesNotEndWith("foo");
|
||||
assertThat(string).doesNotEndWith("foo");
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ public class StringExpression {
|
||||
String string = "string";
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
|
||||
assertThat(string.isEmpty()).isEqualTo(true);
|
||||
assertThat(string.isEmpty()).as("foo").isEqualTo(true);
|
||||
assertThat(string.isEmpty()).isTrue();
|
||||
assertThat(string.equals("foo")).isEqualTo(true);
|
||||
assertThat(string.equals("foo")).isTrue();
|
||||
@@ -14,8 +14,8 @@ public class StringExpression {
|
||||
assertThat(string.equalsIgnoreCase("foo")).isTrue();
|
||||
assertThat(string.contentEquals("foo")).isEqualTo(true);
|
||||
assertThat(string.contentEquals("foo")).isTrue();
|
||||
assertThat(string.contentEquals(stringBuilder)).isTrue();
|
||||
assertThat(string.contentEquals(stringBuilder)).isEqualTo(true);
|
||||
assertThat(string.contentEquals(stringBuilder)).isTrue();
|
||||
assertThat(string.contains("foo")).isEqualTo(true);
|
||||
assertThat(string.contains("foo")).isTrue();
|
||||
assertThat(string.contains(stringBuilder)).isEqualTo(true);
|
||||
@@ -25,7 +25,7 @@ public class StringExpression {
|
||||
assertThat(string.endsWith("foo")).isEqualTo(true);
|
||||
assertThat(string.endsWith("foo")).isTrue();
|
||||
|
||||
assertThat(string.isEmpty()).isEqualTo(false);
|
||||
assertThat(string.isEmpty()).as("foo").isEqualTo(false);
|
||||
assertThat(string.isEmpty()).isFalse();
|
||||
assertThat(string.equals("foo")).isEqualTo(false);
|
||||
assertThat(string.equals("foo")).isFalse();
|
||||
@@ -33,8 +33,8 @@ public class StringExpression {
|
||||
assertThat(string.equalsIgnoreCase("foo")).isFalse();
|
||||
assertThat(string.contentEquals("foo")).isEqualTo(false);
|
||||
assertThat(string.contentEquals("foo")).isFalse();
|
||||
assertThat(string.contentEquals(stringBuilder)).isFalse();
|
||||
assertThat(string.contentEquals(stringBuilder)).isEqualTo(false);
|
||||
assertThat(string.contentEquals(stringBuilder)).isFalse();
|
||||
assertThat(string.contains("foo")).isEqualTo(false);
|
||||
assertThat(string.contains("foo")).isFalse();
|
||||
assertThat(string.contains(stringBuilder)).isEqualTo(false);
|
||||
@@ -43,5 +43,9 @@ public class StringExpression {
|
||||
assertThat(string.startsWith("foo")).isFalse();
|
||||
assertThat(string.endsWith("foo")).isEqualTo(false);
|
||||
assertThat(string.endsWith("foo")).isFalse();
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user