Added hasSize(), isEmpty() and isNotEmpty() for AssertThatFileExpression when using AssertJ >= 3.14.0.
This commit is contained in:
parent
ae2076a425
commit
5113cc15ab
16
README.md
16
README.md
@ -362,6 +362,21 @@ You can toggle the various inspections in the Settings/Editor/Inspections in the
|
|||||||
to: assertThat(file).isNotEmptyDirectory();
|
to: assertThat(file).isNotEmptyDirectory();
|
||||||
```
|
```
|
||||||
|
|
||||||
|
and additionally with AssertJ 3.14.0 or later
|
||||||
|
|
||||||
|
```
|
||||||
|
from: assertThat(file.length()).isEqualTo(0);
|
||||||
|
from: assertThat(file.length()).isZero();
|
||||||
|
to: assertThat(file).isEmpty();
|
||||||
|
|
||||||
|
from: assertThat(file.length()).isNotEqualTo(0);
|
||||||
|
from: assertThat(file.length()).isNotZero();
|
||||||
|
to: assertThat(file).isNotEmpty();
|
||||||
|
|
||||||
|
from: assertThat(file.length()).isEqualTo(len);
|
||||||
|
to: assertThat(file).hasSize(len);
|
||||||
|
```
|
||||||
|
|
||||||
- AssertThatPathExpression
|
- AssertThatPathExpression
|
||||||
|
|
||||||
Moves ```Path``` method calls inside ```assertThat()``` out.
|
Moves ```Path``` method calls inside ```assertThat()``` out.
|
||||||
@ -701,6 +716,7 @@ Feel free to use the code (in package ```de.platon42.intellij.jupiter```) for yo
|
|||||||
- Added first version of AssertThatPathExpression for a limited number transformations (more stuff is possible,
|
- Added first version of AssertThatPathExpression for a limited number transformations (more stuff is possible,
|
||||||
but requires detection and transformation of static ```Files```-methods).
|
but requires detection and transformation of static ```Files```-methods).
|
||||||
- Added AssertThatComparableExpression for funny ```compareTo()``` uses.
|
- Added AssertThatComparableExpression for funny ```compareTo()``` uses.
|
||||||
|
- Added ```hasSize(), isEmpty()``` and ```isNotEmpty()``` for AssertThatFileExpression when using AssertJ >= 3.14.0.
|
||||||
|
|
||||||
#### V1.6 (30-Sep-19)
|
#### V1.6 (30-Sep-19)
|
||||||
- Really fixed AssertThatGuavaOptional inspections to avoid conversions from ```.get()``` to ```.contains()```
|
- Really fixed AssertThatGuavaOptional inspections to avoid conversions from ```.get()``` to ```.contains()```
|
||||||
|
@ -49,6 +49,7 @@ patchPluginXml {
|
|||||||
<li>Added first version of AssertThatPathExpression for a limited number transformations (more stuff is possible,
|
<li>Added first version of AssertThatPathExpression for a limited number transformations (more stuff is possible,
|
||||||
but requires detection and transformation of static Files-methods).
|
but requires detection and transformation of static Files-methods).
|
||||||
<li>Added AssertThatComparableExpression for funny compareTo() uses.
|
<li>Added AssertThatComparableExpression for funny compareTo() uses.
|
||||||
|
<li>Added hasSize(), isEmpty() and isNotEmpty() for AssertThatFileExpression when using AssertJ >= 3.14.0.
|
||||||
</ul>
|
</ul>
|
||||||
<p>Full changelog available at <a href="https://github.com/chrisly42/cajon-plugin#changelog">Github project site</a>.</p>
|
<p>Full changelog available at <a href="https://github.com/chrisly42/cajon-plugin#changelog">Github project site</a>.</p>
|
||||||
"""
|
"""
|
||||||
|
@ -48,6 +48,8 @@ class AssertJClassNames {
|
|||||||
@NonNls
|
@NonNls
|
||||||
const val ABSTRACT_ITERABLE_ASSERT_CLASSNAME = "org.assertj.core.api.AbstractIterableAssert"
|
const val ABSTRACT_ITERABLE_ASSERT_CLASSNAME = "org.assertj.core.api.AbstractIterableAssert"
|
||||||
@NonNls
|
@NonNls
|
||||||
|
const val ABSTRACT_FILE_ASSERT_CLASSNAME = "org.assertj.core.api.AbstractFileAssert"
|
||||||
|
@NonNls
|
||||||
const val ABSTRACT_OPTIONAL_ASSERT_CLASSNAME = "org.assertj.core.api.AbstractOptionalAssert"
|
const val ABSTRACT_OPTIONAL_ASSERT_CLASSNAME = "org.assertj.core.api.AbstractOptionalAssert"
|
||||||
@NonNls
|
@NonNls
|
||||||
const val EXTRACTORS_CLASSNAME = "org.assertj.core.extractor.Extractors"
|
const val EXTRACTORS_CLASSNAME = "org.assertj.core.extractor.Extractors"
|
||||||
|
@ -137,9 +137,13 @@ abstract class AbstractAssertJInspection : AbstractBaseJavaLocalInspectionTool()
|
|||||||
val IS_LESS_THAN_OR_EQUAL_TO_INT = CallMatcher.instanceCall(ABSTRACT_COMPARABLE_ASSERT_CLASSNAME, MethodNames.IS_LESS_THAN_OR_EQUAL_TO)
|
val IS_LESS_THAN_OR_EQUAL_TO_INT = CallMatcher.instanceCall(ABSTRACT_COMPARABLE_ASSERT_CLASSNAME, MethodNames.IS_LESS_THAN_OR_EQUAL_TO)
|
||||||
.parameterTypes("int")!!
|
.parameterTypes("int")!!
|
||||||
|
|
||||||
val IS_ZERO = CallMatcher.instanceCall(ABSTRACT_INTEGER_ASSERT_CLASSNAME, MethodNames.IS_ZERO)
|
val IS_ZERO_INT = CallMatcher.instanceCall(ABSTRACT_INTEGER_ASSERT_CLASSNAME, MethodNames.IS_ZERO)
|
||||||
.parameterCount(0)!!
|
.parameterCount(0)!!
|
||||||
val IS_NOT_ZERO = CallMatcher.instanceCall(ABSTRACT_INTEGER_ASSERT_CLASSNAME, MethodNames.IS_NOT_ZERO)
|
val IS_NOT_ZERO_INT = CallMatcher.instanceCall(ABSTRACT_INTEGER_ASSERT_CLASSNAME, MethodNames.IS_NOT_ZERO)
|
||||||
|
.parameterCount(0)!!
|
||||||
|
val IS_ZERO_LONG = CallMatcher.instanceCall(ABSTRACT_LONG_ASSERT_CLASSNAME, MethodNames.IS_ZERO)
|
||||||
|
.parameterCount(0)!!
|
||||||
|
val IS_NOT_ZERO_LONG = CallMatcher.instanceCall(ABSTRACT_LONG_ASSERT_CLASSNAME, MethodNames.IS_NOT_ZERO)
|
||||||
.parameterCount(0)!!
|
.parameterCount(0)!!
|
||||||
val IS_ONE = CallMatcher.instanceCall(ABSTRACT_INTEGER_ASSERT_CLASSNAME, "isOne")
|
val IS_ONE = CallMatcher.instanceCall(ABSTRACT_INTEGER_ASSERT_CLASSNAME, "isOne")
|
||||||
.parameterCount(0)!!
|
.parameterCount(0)!!
|
||||||
|
@ -42,7 +42,8 @@ abstract class AbstractMoveOutInspection : AbstractAssertJInspection() {
|
|||||||
MoveOutMethodCallExpressionQuickFix(
|
MoveOutMethodCallExpressionQuickFix(
|
||||||
desc, method,
|
desc, method,
|
||||||
replaceOnlyThisMethod = mapping.expectedMatcher,
|
replaceOnlyThisMethod = mapping.expectedMatcher,
|
||||||
replaceFromOriginalMethod = mapping.replaceFromOriginalMethod
|
replaceFromOriginalMethod = mapping.replaceFromOriginalMethod,
|
||||||
|
noExpectedExpression = mapping.noExpectedExpression
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -57,6 +58,7 @@ abstract class AbstractMoveOutInspection : AbstractAssertJInspection() {
|
|||||||
val expectNullNonNull: Boolean? = null,
|
val expectNullNonNull: Boolean? = null,
|
||||||
val expectedMatcher: CallMatcher? = null,
|
val expectedMatcher: CallMatcher? = null,
|
||||||
val replaceFromOriginalMethod: Boolean = false,
|
val replaceFromOriginalMethod: Boolean = false,
|
||||||
|
val noExpectedExpression: Boolean = false,
|
||||||
val additionalCondition: ((PsiExpressionStatement, PsiMethodCallExpression) -> Boolean)? = null
|
val additionalCondition: ((PsiExpressionStatement, PsiMethodCallExpression) -> Boolean)? = null
|
||||||
)
|
)
|
||||||
}
|
}
|
@ -27,7 +27,7 @@ class AssertThatComparableInspection : AbstractMoveOutInspection() {
|
|||||||
),
|
),
|
||||||
MoveOutMapping(
|
MoveOutMapping(
|
||||||
COMPARABLE_COMPARE_TO,
|
COMPARABLE_COMPARE_TO,
|
||||||
"isEqualByComparingTo", expectedMatcher = IS_ZERO, replaceFromOriginalMethod = true
|
"isEqualByComparingTo", expectedMatcher = IS_ZERO_INT, replaceFromOriginalMethod = true
|
||||||
),
|
),
|
||||||
|
|
||||||
MoveOutMapping(
|
MoveOutMapping(
|
||||||
@ -37,7 +37,7 @@ class AssertThatComparableInspection : AbstractMoveOutInspection() {
|
|||||||
),
|
),
|
||||||
MoveOutMapping(
|
MoveOutMapping(
|
||||||
COMPARABLE_COMPARE_TO,
|
COMPARABLE_COMPARE_TO,
|
||||||
"isNotEqualByComparingTo", expectedMatcher = IS_NOT_ZERO, replaceFromOriginalMethod = true
|
"isNotEqualByComparingTo", expectedMatcher = IS_NOT_ZERO_INT, replaceFromOriginalMethod = true
|
||||||
),
|
),
|
||||||
|
|
||||||
MoveOutMapping(
|
MoveOutMapping(
|
||||||
|
@ -1,13 +1,9 @@
|
|||||||
package de.platon42.intellij.plugins.cajon.inspections
|
package de.platon42.intellij.plugins.cajon.inspections
|
||||||
|
|
||||||
import com.intellij.codeInspection.ProblemsHolder
|
import com.intellij.codeInspection.ProblemsHolder
|
||||||
import com.intellij.psi.CommonClassNames
|
import com.intellij.psi.*
|
||||||
import com.intellij.psi.JavaElementVisitor
|
|
||||||
import com.intellij.psi.PsiElementVisitor
|
|
||||||
import com.intellij.psi.PsiExpressionStatement
|
|
||||||
import com.siyeh.ig.callMatcher.CallMatcher
|
import com.siyeh.ig.callMatcher.CallMatcher
|
||||||
import de.platon42.intellij.plugins.cajon.AssertJClassNames
|
import de.platon42.intellij.plugins.cajon.*
|
||||||
import de.platon42.intellij.plugins.cajon.MethodNames
|
|
||||||
|
|
||||||
|
|
||||||
class AssertThatFileExpressionInspection : AbstractMoveOutInspection() {
|
class AssertThatFileExpressionInspection : AbstractMoveOutInspection() {
|
||||||
@ -15,6 +11,13 @@ class AssertThatFileExpressionInspection : AbstractMoveOutInspection() {
|
|||||||
companion object {
|
companion object {
|
||||||
private const val DISPLAY_NAME = "Asserting a file specific expression"
|
private const val DISPLAY_NAME = "Asserting a file specific expression"
|
||||||
|
|
||||||
|
private val ARG_IS_ZERO_CONST: (PsiExpressionStatement, PsiMethodCallExpression) -> Boolean = { _, call -> call.firstArg.calculateConstantValue() == 0 }
|
||||||
|
private val ARG_IS_NOT_ZERO_CONST: (PsiExpressionStatement, PsiMethodCallExpression) -> Boolean = { _, call ->
|
||||||
|
val constant =
|
||||||
|
call.firstArg.calculateConstantValue()
|
||||||
|
(constant != null) && (constant != 0)
|
||||||
|
}
|
||||||
|
|
||||||
private val MAPPINGS = listOf(
|
private val MAPPINGS = listOf(
|
||||||
MoveOutMapping(
|
MoveOutMapping(
|
||||||
CallMatcher.instanceCall(CommonClassNames.JAVA_IO_FILE, "canRead").parameterCount(0),
|
CallMatcher.instanceCall(CommonClassNames.JAVA_IO_FILE, "canRead").parameterCount(0),
|
||||||
@ -63,13 +66,39 @@ class AssertThatFileExpressionInspection : AbstractMoveOutInspection() {
|
|||||||
CallMatcher.instanceCall(CommonClassNames.JAVA_IO_FILE, "list", "listFiles").parameterCount(0),
|
CallMatcher.instanceCall(CommonClassNames.JAVA_IO_FILE, "list", "listFiles").parameterCount(0),
|
||||||
"isEmptyDirectory",
|
"isEmptyDirectory",
|
||||||
expectedMatcher = CallMatcher.instanceCall(AssertJClassNames.ABSTRACT_OBJECT_ARRAY_ASSERT_CLASSNAME, MethodNames.IS_EMPTY)
|
expectedMatcher = CallMatcher.instanceCall(AssertJClassNames.ABSTRACT_OBJECT_ARRAY_ASSERT_CLASSNAME, MethodNames.IS_EMPTY)
|
||||||
.parameterCount(0)!!
|
.parameterCount(0)
|
||||||
),
|
),
|
||||||
MoveOutMapping(
|
MoveOutMapping(
|
||||||
CallMatcher.instanceCall(CommonClassNames.JAVA_IO_FILE, "list", "listFiles").parameterCount(0),
|
CallMatcher.instanceCall(CommonClassNames.JAVA_IO_FILE, "list", "listFiles").parameterCount(0),
|
||||||
"isNotEmptyDirectory",
|
"isNotEmptyDirectory",
|
||||||
expectedMatcher = CallMatcher.instanceCall(AssertJClassNames.ABSTRACT_OBJECT_ARRAY_ASSERT_CLASSNAME, MethodNames.IS_NOT_EMPTY)
|
expectedMatcher = CallMatcher.instanceCall(AssertJClassNames.ABSTRACT_OBJECT_ARRAY_ASSERT_CLASSNAME, MethodNames.IS_NOT_EMPTY)
|
||||||
.parameterCount(0)!!
|
.parameterCount(0)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
private val MAPPINGS_SINCE_ASSERTJ_3_14_0 = listOf(
|
||||||
|
MoveOutMapping(
|
||||||
|
CallMatcher.instanceCall(CommonClassNames.JAVA_IO_FILE, "length").parameterCount(0),
|
||||||
|
"isEmpty", expectedMatcher = IS_ZERO_LONG, noExpectedExpression = true
|
||||||
|
),
|
||||||
|
MoveOutMapping(
|
||||||
|
CallMatcher.instanceCall(CommonClassNames.JAVA_IO_FILE, "length").parameterCount(0),
|
||||||
|
"isEmpty", expectedMatcher = IS_EQUAL_TO_LONG, noExpectedExpression = true,
|
||||||
|
additionalCondition = ARG_IS_ZERO_CONST
|
||||||
|
),
|
||||||
|
MoveOutMapping(
|
||||||
|
CallMatcher.instanceCall(CommonClassNames.JAVA_IO_FILE, "length").parameterCount(0),
|
||||||
|
"isNotEmpty", expectedMatcher = IS_NOT_ZERO_LONG, noExpectedExpression = true
|
||||||
|
),
|
||||||
|
MoveOutMapping(
|
||||||
|
CallMatcher.instanceCall(CommonClassNames.JAVA_IO_FILE, "length").parameterCount(0),
|
||||||
|
"isNotEmpty", expectedMatcher = IS_NOT_EQUAL_TO_LONG, noExpectedExpression = true,
|
||||||
|
additionalCondition = ARG_IS_ZERO_CONST
|
||||||
|
),
|
||||||
|
MoveOutMapping(
|
||||||
|
CallMatcher.instanceCall(CommonClassNames.JAVA_IO_FILE, "length").parameterCount(0),
|
||||||
|
"hasSize", expectedMatcher = IS_EQUAL_TO_LONG,
|
||||||
|
additionalCondition = ARG_IS_NOT_ZERO_CONST
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@ -81,6 +110,9 @@ class AssertThatFileExpressionInspection : AbstractMoveOutInspection() {
|
|||||||
override fun visitExpressionStatement(statement: PsiExpressionStatement) {
|
override fun visitExpressionStatement(statement: PsiExpressionStatement) {
|
||||||
super.visitExpressionStatement(statement)
|
super.visitExpressionStatement(statement)
|
||||||
createInspectionsForMappings(statement, holder, MAPPINGS)
|
createInspectionsForMappings(statement, holder, MAPPINGS)
|
||||||
|
if (hasAssertJMethod(statement, AssertJClassNames.ABSTRACT_FILE_ASSERT_CLASSNAME, MethodNames.HAS_SIZE)) {
|
||||||
|
createInspectionsForMappings(statement, holder, MAPPINGS_SINCE_ASSERTJ_3_14_0)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -57,10 +57,10 @@ class AssertThatSizeInspection : AbstractAssertJInspection() {
|
|||||||
} else {
|
} else {
|
||||||
val isTestForEmpty = ((IS_LESS_THAN_OR_EQUAL_TO_INT.test(expression) && (constValue == 0))
|
val isTestForEmpty = ((IS_LESS_THAN_OR_EQUAL_TO_INT.test(expression) && (constValue == 0))
|
||||||
|| (IS_LESS_THAN_INT.test(expression) && (constValue == 1))
|
|| (IS_LESS_THAN_INT.test(expression) && (constValue == 1))
|
||||||
|| IS_ZERO.test(expression))
|
|| IS_ZERO_INT.test(expression))
|
||||||
val isTestForNotEmpty = ((IS_GREATER_THAN_INT.test(expression) && (constValue == 0))
|
val isTestForNotEmpty = ((IS_GREATER_THAN_INT.test(expression) && (constValue == 0))
|
||||||
|| (IS_GREATER_THAN_OR_EQUAL_TO_INT.test(expression) && (constValue == 1))
|
|| (IS_GREATER_THAN_OR_EQUAL_TO_INT.test(expression) && (constValue == 1))
|
||||||
|| IS_NOT_ZERO.test(expression))
|
|| IS_NOT_ZERO_INT.test(expression))
|
||||||
if ((isTestForEmpty && isLastExpression) || isTestForNotEmpty) {
|
if ((isTestForEmpty && isLastExpression) || isTestForNotEmpty) {
|
||||||
val replacementMethod = isTestForEmpty.map(MethodNames.IS_EMPTY, MethodNames.IS_NOT_EMPTY)
|
val replacementMethod = isTestForEmpty.map(MethodNames.IS_EMPTY, MethodNames.IS_NOT_EMPTY)
|
||||||
return Match(expression, replacementMethod, noExpectedExpression = true)
|
return Match(expression, replacementMethod, noExpectedExpression = true)
|
||||||
|
@ -60,7 +60,7 @@ class AssertThatStringExpressionInspection : AbstractMoveOutInspection() {
|
|||||||
),
|
),
|
||||||
MoveOutMapping(
|
MoveOutMapping(
|
||||||
STRING_COMPARE_TO_IGNORE_CASE,
|
STRING_COMPARE_TO_IGNORE_CASE,
|
||||||
MethodNames.IS_EQUAL_TO_IC, expectedMatcher = IS_ZERO, replaceFromOriginalMethod = true
|
MethodNames.IS_EQUAL_TO_IC, expectedMatcher = IS_ZERO_INT, replaceFromOriginalMethod = true
|
||||||
),
|
),
|
||||||
MoveOutMapping(
|
MoveOutMapping(
|
||||||
STRING_COMPARE_TO_IGNORE_CASE,
|
STRING_COMPARE_TO_IGNORE_CASE,
|
||||||
@ -69,7 +69,7 @@ class AssertThatStringExpressionInspection : AbstractMoveOutInspection() {
|
|||||||
),
|
),
|
||||||
MoveOutMapping(
|
MoveOutMapping(
|
||||||
STRING_COMPARE_TO_IGNORE_CASE,
|
STRING_COMPARE_TO_IGNORE_CASE,
|
||||||
MethodNames.IS_NOT_EQUAL_TO_IC, expectedMatcher = IS_NOT_ZERO, replaceFromOriginalMethod = true
|
MethodNames.IS_NOT_EQUAL_TO_IC, expectedMatcher = IS_NOT_ZERO_INT, replaceFromOriginalMethod = true
|
||||||
),
|
),
|
||||||
|
|
||||||
MoveOutMapping(
|
MoveOutMapping(
|
||||||
@ -79,7 +79,7 @@ class AssertThatStringExpressionInspection : AbstractMoveOutInspection() {
|
|||||||
),
|
),
|
||||||
MoveOutMapping(
|
MoveOutMapping(
|
||||||
STRING_INDEX_OF,
|
STRING_INDEX_OF,
|
||||||
MethodNames.STARTS_WITH, expectedMatcher = IS_ZERO, replaceFromOriginalMethod = true
|
MethodNames.STARTS_WITH, expectedMatcher = IS_ZERO_INT, replaceFromOriginalMethod = true
|
||||||
),
|
),
|
||||||
|
|
||||||
MoveOutMapping(
|
MoveOutMapping(
|
||||||
@ -89,7 +89,7 @@ class AssertThatStringExpressionInspection : AbstractMoveOutInspection() {
|
|||||||
),
|
),
|
||||||
MoveOutMapping(
|
MoveOutMapping(
|
||||||
STRING_INDEX_OF,
|
STRING_INDEX_OF,
|
||||||
MethodNames.DOES_NOT_START_WITH, expectedMatcher = IS_NOT_ZERO, replaceFromOriginalMethod = true
|
MethodNames.DOES_NOT_START_WITH, expectedMatcher = IS_NOT_ZERO_INT, replaceFromOriginalMethod = true
|
||||||
),
|
),
|
||||||
|
|
||||||
MoveOutMapping(
|
MoveOutMapping(
|
||||||
|
@ -46,7 +46,7 @@ class MoveOutMethodCallExpressionQuickFix(
|
|||||||
val expectedExpression = createExpectedMethodCall(
|
val expectedExpression = createExpectedMethodCall(
|
||||||
it,
|
it,
|
||||||
replacementMethod,
|
replacementMethod,
|
||||||
*if (replaceFromOriginalMethod) arrayOf(assertExpressionArg!!) else it.argumentList.expressions
|
*if (replaceFromOriginalMethod || noExpectedExpression) listOfNotNull(assertExpressionArg).toTypedArray() else it.argumentList.expressions
|
||||||
)
|
)
|
||||||
expectedExpression.replaceQualifierFromMethodCall(it)
|
expectedExpression.replaceQualifierFromMethodCall(it)
|
||||||
it.replace(expectedExpression)
|
it.replace(expectedExpression)
|
||||||
|
@ -30,6 +30,9 @@ internal class AssertThatFileExpressionInspectionTest : AbstractCajonTest() {
|
|||||||
executeQuickFixes(myFixture, Regex.fromLiteral("Remove listFiles() of actual expression and use assertThat().isNotEmptyDirectory() instead"), 1)
|
executeQuickFixes(myFixture, Regex.fromLiteral("Remove listFiles() of actual expression and use assertThat().isNotEmptyDirectory() instead"), 1)
|
||||||
executeQuickFixes(myFixture, Regex.fromLiteral("Remove list() of actual expression and use assertThat().isEmptyDirectory() instead"), 1)
|
executeQuickFixes(myFixture, Regex.fromLiteral("Remove list() of actual expression and use assertThat().isEmptyDirectory() instead"), 1)
|
||||||
executeQuickFixes(myFixture, Regex.fromLiteral("Remove list() of actual expression and use assertThat().isNotEmptyDirectory() instead"), 1)
|
executeQuickFixes(myFixture, Regex.fromLiteral("Remove list() of actual expression and use assertThat().isNotEmptyDirectory() instead"), 1)
|
||||||
|
executeQuickFixes(myFixture, Regex.fromLiteral("Remove length() of actual expression and use assertThat().isEmpty() instead"), 2)
|
||||||
|
executeQuickFixes(myFixture, Regex.fromLiteral("Remove length() of actual expression and use assertThat().isNotEmpty() instead"), 2)
|
||||||
|
executeQuickFixes(myFixture, Regex.fromLiteral("Remove length() of actual expression and use assertThat().hasSize() instead"), 1)
|
||||||
myFixture.checkResultByFile("FileExpressionAfter.java")
|
myFixture.checkResultByFile("FileExpressionAfter.java")
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -75,6 +75,12 @@ public class FileExpression {
|
|||||||
assertThat(file.getParentFile()).isNotEqualTo(null);
|
assertThat(file.getParentFile()).isNotEqualTo(null);
|
||||||
assertThat(file.getParentFile()).isNotNull();
|
assertThat(file.getParentFile()).isNotNull();
|
||||||
|
|
||||||
|
assertThat(file).isEmpty();
|
||||||
|
assertThat(file).isEmpty();
|
||||||
|
assertThat(file).isNotEmpty();
|
||||||
|
assertThat(file).isNotEmpty();
|
||||||
|
assertThat(file).hasSize(2);
|
||||||
|
|
||||||
assertThat(file.listFiles()).isNull();
|
assertThat(file.listFiles()).isNull();
|
||||||
assertThat(file.listFiles()).isNullOrEmpty();
|
assertThat(file.listFiles()).isNullOrEmpty();
|
||||||
assertThat(file).isEmptyDirectory();
|
assertThat(file).isEmptyDirectory();
|
||||||
|
@ -75,6 +75,12 @@ public class FileExpression {
|
|||||||
assertThat(file.getParentFile()).isNotEqualTo(null);
|
assertThat(file.getParentFile()).isNotEqualTo(null);
|
||||||
assertThat(file.getParentFile()).isNotNull();
|
assertThat(file.getParentFile()).isNotNull();
|
||||||
|
|
||||||
|
assertThat(file.length()).isEqualTo(0);
|
||||||
|
assertThat(file.length()).isZero();
|
||||||
|
assertThat(file.length()).isNotEqualTo(0);
|
||||||
|
assertThat(file.length()).isNotZero();
|
||||||
|
assertThat(file.length()).isEqualTo(2);
|
||||||
|
|
||||||
assertThat(file.listFiles()).isNull();
|
assertThat(file.listFiles()).isNull();
|
||||||
assertThat(file.listFiles()).isNullOrEmpty();
|
assertThat(file.listFiles()).isNullOrEmpty();
|
||||||
assertThat(file.listFiles()).isEmpty();
|
assertThat(file.listFiles()).isEmpty();
|
||||||
|
Loading…
Reference in New Issue
Block a user