Recipe Name:
Use AssertJ's isFalse() (with message)
Description:
Can be replaced with AssertJ style assertions
Level:
warning
Language:
  • java
Tags:
  • AssertJ
  • TestNG
Recipe
id: scw:assertj:junit-assert-false-message
version: 10
metadata:
  name: Use AssertJ's isFalse() (with message)
  shortDescription: Can be replaced with AssertJ style assertions
  level: warning
  language: java
  enabled: true
  tags: AssertJ; TestNG
search:
  methodcall:
    argCount: 2
    name: assertFalse
    anyOf:
    - args:
        1:
          type: String
        2:
          anyOf:
          - type: java.lang.Boolean
          - type: boolean
      anyOf:
      - type: org.junit.Assert
      - type: junit.framework.TestCase
      - type: junit.framework.Assert
      - type: org.testng.AssertJUnit
    - args:
        1:
          anyOf:
          - type: java.lang.Boolean
          - type: boolean
        2:
          type: String
      type: org.junit.jupiter.api.Assertions
availableFixes:
- doStaticImports: true
  name: Change to assertThat(actual).as(message).isFalse()
  actions:
  - rewrite:
      applyIf:
        markedElement:
          is:
            methodcall:
              not:
                type: org.junit.jupiter.api.Assertions
      to: org.assertj.core.api.Assertions.assertThat({{{ arguments.1 }}}).as({{{ arguments.0 }}}).isFalse()
  - rewrite:
      applyIf:
        markedElement:
          is:
            methodcall:
              type: org.junit.jupiter.api.Assertions
      to: org.assertj.core.api.Assertions.assertThat({{{ arguments.0 }}}).as({{{ arguments.1 }}}).isFalse()