Recipe Name:
Use AssertJ's isEqualTo()
Description:
Can be replaced with AssertJ style assertions
Level:
warning
Language:
  • java
Tags:
  • AssertJ
  • TestNG
Recipe
id: scw:assertj:testng-assert-equals
version: 10
metadata:
  name: Use AssertJ's isEqualTo()
  shortDescription: Can be replaced with AssertJ style assertions
  level: warning
  language: java
  enabled: true
  tags: AssertJ; TestNG
search:
  methodcall:
    name: assertEquals
    anyOf:
    - argCount: 2
    - args:
        3:
          type: String
      argCount: 3
    type: org.testng.Assert
availableFixes:
- doStaticImports: true
  name: Change to assertThat(actual).isEqualTo(expected)
  availableIf:
    markedElement:
      is:
        methodcall:
          argCount: 2
  actions:
  - rewrite:
      to: org.assertj.core.api.Assertions.assertThat({{{ arguments.0 }}}).isEqualTo({{{ arguments.1 }}})
- doStaticImports: true
  name: Change to assertThat(actual).as(message).isEqualTo(expected)
  availableIf:
    markedElement:
      is:
        methodcall:
          argCount: 3
  actions:
  - rewrite:
      to: org.assertj.core.api.Assertions.assertThat({{{ arguments.0 }}}).as({{{ arguments.2 }}}).isEqualTo({{{ arguments.1 }}})