Recipe Name:
Use AssertJ's containsExactlyInAnyOrder() instead of containsInAnyOrder
Description:
Can be replaced with AssertJ style assertions
Level:
warning
Language:
- java
Tags:
- AssertJ
- Hamcrest
Recipe
id: scw:assertj:hamcrest-contains-in-any-order version: 10 metadata: name: Use AssertJ's containsExactlyInAnyOrder() instead of containsInAnyOrder shortDescription: Can be replaced with AssertJ style assertions level: warning language: java enabled: true tags: AssertJ; Hamcrest search: methodcall: name: assertThat anyOf: - args: 2: value: is: methodcall: anyOf: - name: containsInAnyOrder type: org.hamcrest.Matchers - name: containsInAnyOrder type: org.hamcrest.collection.IsIterableContainingInAnyOrder argCount: 2 - args: 1: type: String 3: value: is: methodcall: anyOf: - name: containsInAnyOrder type: org.hamcrest.Matchers - name: containsInAnyOrder type: org.hamcrest.collection.IsIterableContainingInAnyOrder argCount: 3 type: org.hamcrest.MatcherAssert availableFixes: - doStaticImports: true name: Change to assertThat(collection).containsExactlyInAnyOrder(expectedElements) availableIf: markedElement: is: methodcall: argCount: 2 actions: - rewrite: to: org.assertj.core.api.Assertions.assertThat({{{ arguments.0 }}}).containsExactlyInAnyOrder({{{ arguments.1.arguments }}}) - doStaticImports: true name: Change to assertThat(collection).as(reason).containsExactlyInAnyOrder(expectedElements) availableIf: markedElement: is: methodcall: argCount: 3 actions: - rewrite: to: org.assertj.core.api.Assertions.assertThat({{{ arguments.1 }}}).as({{{ arguments.0 }}}).containsExactlyInAnyOrder({{{ arguments.2.arguments }}})