Migrate Hamcrest assertions to AssertJ
org.openrewrite.java.testing.hamcrest.MigrateHamcrestToAssertJ
Migrate Hamcrest assertThat(..)
to AssertJ Assertions
.
Tags
- testing
- assertj
- hamcrest
Recipe source
GitHub, Issue Tracker, Maven Central
This recipe is composed of more than one recipe. If you want to customize the set of recipes this is composed of, you can find and copy the GitHub source for the recipe from the link above.
License
This recipe is available under the Moderne Source Available License.
Definition
- Recipe List
- Yaml Recipe List
- Add Gradle or Maven dependency
- groupId:
org.assertj
- artifactId:
assertj-core
- version:
3.x
- onlyIfUsing:
org.hamcrest.*
- acceptTransitive:
true
- groupId:
- Use consistent Hamcrest matcher imports
- Migrate Hamcrest
is(Object)
to AssertJ - Migrate
anyOf
Hamcrest Matcher to AssertJ - Migrate Hamcrest
assertThat(boolean, Matcher)
to AssertJ - Migrate from Hamcrest
Matcher
to AssertJ- matcher:
comparesEqualTo
- assertion:
isEqualTo
- argumentType:
java.lang.String
- matcher:
- Migrate from Hamcrest
Matcher
to AssertJ- matcher:
comparesEqualTo
- assertion:
isEqualByComparingTo
- matcher:
- Migrate from Hamcrest
Matcher
to AssertJ- matcher:
lessThan
- assertion:
isBefore
- argumentType:
java.util.Date
- matcher:
- Migrate from Hamcrest
Matcher
to AssertJ- matcher:
lessThanOrEqualTo
- assertion:
isBeforeOrEqualTo
- argumentType:
java.util.Date
- matcher:
- Migrate from Hamcrest
Matcher
to AssertJ- matcher:
greaterThan
- assertion:
isAfter
- argumentType:
java.util.Date
- matcher:
- Migrate from Hamcrest
Matcher
to AssertJ- matcher:
greaterThanOrEqualTo
- assertion:
isAfterOrEqualTo
- argumentType:
java.util.Date
- matcher:
- Migrate from Hamcrest
Matcher
to AssertJ- matcher:
lessThan
- assertion:
isBefore
- argumentType:
java.time.Instant
- matcher:
- Migrate from Hamcrest
Matcher
to AssertJ- matcher:
lessThanOrEqualTo
- assertion:
isBeforeOrEqualTo
- argumentType:
java.time.Instant
- matcher:
- Migrate from Hamcrest
Matcher
to AssertJ- matcher:
greaterThan
- assertion:
isAfter
- argumentType:
java.time.Instant
- matcher:
- Migrate from Hamcrest
Matcher
to AssertJ- matcher:
greaterThanOrEqualTo
- assertion:
isAfterOrEqualTo
- argumentType:
java.time.Instant
- matcher:
- Migrate from Hamcrest
Matcher
to AssertJ- matcher:
equalTo
- assertion:
isEqualTo
- matcher:
- Migrate from Hamcrest
Matcher
to AssertJ- matcher:
greaterThanOrEqualTo
- assertion:
isGreaterThanOrEqualTo
- matcher:
- Migrate from Hamcrest
Matcher
to AssertJ- matcher:
greaterThan
- assertion:
isGreaterThan
- matcher:
- Migrate from Hamcrest
Matcher
to AssertJ- matcher:
hasToString
- assertion:
hasToString
- matcher:
- Migrate from Hamcrest
Matcher
to AssertJ- matcher:
lessThanOrEqualTo
- assertion:
isLessThanOrEqualTo
- matcher:
- Migrate from Hamcrest
Matcher
to AssertJ- matcher:
lessThan
- assertion:
isLessThan
- matcher:
- Migrate from Hamcrest
Matcher
to AssertJ- matcher:
notNullValue
- assertion:
isNotNull
- matcher:
- Migrate from Hamcrest
Matcher
to AssertJ- matcher:
not
- assertion:
isNotEqualTo
- matcher:
- Migrate from Hamcrest
Matcher
to AssertJ- matcher:
nullValue
- assertion:
isNull
- matcher:
- Migrate from Hamcrest
Matcher
to AssertJ- matcher:
sameInstance
- assertion:
isSameAs
- matcher:
- Migrate from Hamcrest
Matcher
to AssertJ- matcher:
instanceOf
- assertion:
isInstanceOf
- matcher:
- Migrate from Hamcrest
Matcher
to AssertJ- matcher:
isA
- assertion:
isInstanceOf
- matcher:
- Migrate from Hamcrest
Matcher
to AssertJ- matcher:
arrayContaining
- assertion:
containsExactly
- matcher:
- Migrate from Hamcrest
Matcher
to AssertJ- matcher:
arrayContainingInAnyOrder
- assertion:
containsExactlyInAnyOrder
- matcher:
- Migrate from Hamcrest
Matcher
to AssertJ- matcher:
arrayWithSize
- assertion:
hasSize
- matcher:
- Migrate from Hamcrest
Matcher
to AssertJ- matcher:
emptyArray
- assertion:
isEmpty
- matcher:
- Migrate from Hamcrest
Matcher
to AssertJ- matcher:
hasItemInArray
- assertion:
contains
- matcher:
- Migrate from Hamcrest
Matcher
to AssertJ- matcher:
blankString
- assertion:
isBlank
- matcher:
- Migrate from Hamcrest
Matcher
to AssertJ- matcher:
containsString
- assertion:
contains
- matcher:
- Migrate from Hamcrest
Matcher
to AssertJ- matcher:
containsStringIgnoringCase
- assertion:
containsIgnoringCase
- matcher:
- Migrate from Hamcrest
Matcher
to AssertJ- matcher:
emptyOrNullString
- assertion:
isNullOrEmpty
- matcher:
- Migrate from Hamcrest
Matcher
to AssertJ- matcher:
emptyString
- assertion:
isEmpty
- matcher:
- Migrate from Hamcrest
Matcher
to AssertJ- matcher:
endsWith
- assertion:
endsWith
- matcher:
- Migrate from Hamcrest
Matcher
to AssertJ- matcher:
endsWithIgnoringCase
- assertion:
endsWithIgnoringCase
- matcher:
- Migrate from Hamcrest
Matcher
to AssertJ- matcher:
equalToIgnoringCase
- assertion:
isEqualToIgnoringCase
- matcher:
- Migrate from Hamcrest
Matcher
to AssertJ- matcher:
equalToIgnoringWhiteSpace
- assertion:
isEqualToIgnoringWhitespace
- matcher:
- Migrate from Hamcrest
Matcher
to AssertJ- matcher:
hasLength
- assertion:
hasSize
- matcher:
- Migrate from Hamcrest
Matcher
to AssertJ- matcher:
isEmptyString
- assertion:
isEmpty
- matcher:
- Migrate from Hamcrest
Matcher
to AssertJ- matcher:
isEmptyOrNullString
- assertion:
isNullOrEmpty
- matcher:
- Migrate from Hamcrest
Matcher
to AssertJ- matcher:
matchesPattern
- assertion:
matches
- matcher:
- Migrate from Hamcrest
Matcher
to AssertJ- matcher:
matchesRegex
- assertion:
matches
- matcher:
- Migrate from Hamcrest
Matcher
to AssertJ- matcher:
startsWith
- assertion:
startsWith
- matcher:
- Migrate from Hamcrest
Matcher
to AssertJ- matcher:
startsWithIgnoringCase
- assertion:
startsWithIgnoringCase
- matcher:
- Migrate from Hamcrest
Matcher
to AssertJ- matcher:
contains
- assertion:
containsExactly
- matcher:
- Migrate from Hamcrest
Matcher
to AssertJ- matcher:
containsInAnyOrder
- assertion:
containsExactlyInAnyOrder
- matcher:
- Migrate from Hamcrest
Matcher
to AssertJ- matcher:
empty
- assertion:
isEmpty
- matcher:
- Migrate from Hamcrest
Matcher
to AssertJ- matcher:
hasSize
- assertion:
hasSize
- matcher:
- Migrate from Hamcrest
Matcher
to AssertJ- matcher:
hasItem
- assertion:
contains
- matcher:
- Migrate from Hamcrest
Matcher
to AssertJ- matcher:
hasItems
- assertion:
contains
- matcher:
- Migrate from Hamcrest
Matcher
to AssertJ- matcher:
in
- assertion:
isIn
- matcher:
- Migrate from Hamcrest
Matcher
to AssertJ- matcher:
isIn
- assertion:
isIn
- matcher:
- Migrate from Hamcrest
Matcher
to AssertJ- matcher:
hasEntry
- assertion:
containsEntry
- matcher:
- Migrate from Hamcrest
Matcher
to AssertJ- matcher:
hasKey
- assertion:
containsKey
- matcher:
- Migrate from Hamcrest
Matcher
to AssertJ- matcher:
hasValue
- assertion:
containsValue
- matcher:
- Migrate from Hamcrest
Matcher
to AssertJ- matcher:
aMapWithSize
- assertion:
hasSize
- matcher:
- Migrate from Hamcrest
Matcher
to AssertJ- matcher:
anEmptyMap
- assertion:
isEmpty
- matcher:
- Migrate from Hamcrest
Matcher
to AssertJ- matcher:
closeTo
- assertion:
isCloseTo
- matcher:
- Migrate Hamcrest
not(Matcher)
to AssertJ- notMatcher:
equalTo
- assertion:
isNotEqualTo
- notMatcher:
- Migrate Hamcrest
not(Matcher)
to AssertJ- notMatcher:
hasToString
- assertion:
doesNotHaveToString
- notMatcher:
- Migrate Hamcrest
not(Matcher)
to AssertJ- notMatcher:
in
- assertion:
isNotIn
- notMatcher:
- Migrate Hamcrest
not(Matcher)
to AssertJ- notMatcher:
isIn
- assertion:
isNotIn
- notMatcher:
- Migrate Hamcrest
not(Matcher)
to AssertJ- notMatcher:
instanceOf
- assertion:
isNotInstanceOf
- notMatcher:
- Migrate Hamcrest
not(Matcher)
to AssertJ- notMatcher:
nullValue
- assertion:
isNotNull
- notMatcher:
- Migrate Hamcrest
not(Matcher)
to AssertJ- notMatcher:
sameInstance
- assertion:
isNotSameAs
- notMatcher:
- Migrate Hamcrest
not(Matcher)
to AssertJ- notMatcher:
equalToIgnoringCase
- assertion:
isNotEqualToIgnoringCase
- notMatcher:
- Migrate Hamcrest
not(Matcher)
to AssertJ- notMatcher:
equalToIgnoringWhiteSpace
- assertion:
isNotEqualToIgnoringWhitespace
- notMatcher:
- Migrate Hamcrest
not(Matcher)
to AssertJ- notMatcher:
containsString
- assertion:
doesNotContain
- notMatcher:
- Migrate Hamcrest
not(Matcher)
to AssertJ- notMatcher:
containsStringIgnoringCase
- assertion:
doesNotContainIgnoringCase
- notMatcher:
- Migrate Hamcrest
not(Matcher)
to AssertJ- notMatcher:
startsWith
- assertion:
doesNotStartWith
- notMatcher:
- Migrate Hamcrest
not(Matcher)
to AssertJ- notMatcher:
endsWith
- assertion:
doesNotEndWith
- notMatcher:
- Migrate Hamcrest
not(Matcher)
to AssertJ- notMatcher:
matchesPattern
- assertion:
doesNotMatch
- notMatcher:
- Migrate Hamcrest
not(Matcher)
to AssertJ- notMatcher:
matchesRegex
- assertion:
doesNotMatch
- notMatcher:
- Migrate Hamcrest
not(Matcher)
to AssertJ- notMatcher:
blankString
- assertion:
isNotBlank
- notMatcher:
- Migrate Hamcrest
not(Matcher)
to AssertJ- notMatcher:
emptyString
- assertion:
isNotEmpty
- notMatcher:
- Migrate Hamcrest
not(Matcher)
to AssertJ- notMatcher:
hasItem
- assertion:
doesNotContain
- notMatcher:
- Migrate Hamcrest
not(Matcher)
to AssertJ- notMatcher:
hasItems
- assertion:
doesNotContain
- notMatcher:
- Migrate Hamcrest
not(Matcher)
to AssertJ- notMatcher:
empty
- assertion:
isNotEmpty
- notMatcher:
---
type: specs.openrewrite.org/v1beta/recipe
name: org.openrewrite.java.testing.hamcrest.MigrateHamcrestToAssertJ
displayName: Migrate Hamcrest assertions to AssertJ
description: Migrate Hamcrest `assertThat(..)` to AssertJ `Assertions`.
tags:
- testing
- assertj
- hamcrest
recipeList:
- org.openrewrite.java.dependencies.AddDependency:
groupId: org.assertj
artifactId: assertj-core
version: 3.x
onlyIfUsing: org.hamcrest.*
acceptTransitive: true
- org.openrewrite.java.testing.hamcrest.ConsistentHamcrestMatcherImports
- org.openrewrite.java.testing.hamcrest.HamcrestIsMatcherToAssertJ
- org.openrewrite.java.testing.hamcrest.HamcrestOfMatchersToAssertJ
- org.openrewrite.java.testing.hamcrest.AssertThatBooleanToAssertJ
- org.openrewrite.java.testing.hamcrest.HamcrestMatcherToAssertJ:
matcher: comparesEqualTo
assertion: isEqualTo
argumentType: java.lang.String
- org.openrewrite.java.testing.hamcrest.HamcrestMatcherToAssertJ:
matcher: comparesEqualTo
assertion: isEqualByComparingTo
- org.openrewrite.java.testing.hamcrest.HamcrestMatcherToAssertJ:
matcher: lessThan
assertion: isBefore
argumentType: java.util.Date
- org.openrewrite.java.testing.hamcrest.HamcrestMatcherToAssertJ:
matcher: lessThanOrEqualTo
assertion: isBeforeOrEqualTo
argumentType: java.util.Date
- org.openrewrite.java.testing.hamcrest.HamcrestMatcherToAssertJ:
matcher: greaterThan
assertion: isAfter
argumentType: java.util.Date
- org.openrewrite.java.testing.hamcrest.HamcrestMatcherToAssertJ:
matcher: greaterThanOrEqualTo
assertion: isAfterOrEqualTo
argumentType: java.util.Date
- org.openrewrite.java.testing.hamcrest.HamcrestMatcherToAssertJ:
matcher: lessThan
assertion: isBefore
argumentType: java.time.Instant
- org.openrewrite.java.testing.hamcrest.HamcrestMatcherToAssertJ:
matcher: lessThanOrEqualTo
assertion: isBeforeOrEqualTo
argumentType: java.time.Instant
- org.openrewrite.java.testing.hamcrest.HamcrestMatcherToAssertJ:
matcher: greaterThan
assertion: isAfter
argumentType: java.time.Instant
- org.openrewrite.java.testing.hamcrest.HamcrestMatcherToAssertJ:
matcher: greaterThanOrEqualTo
assertion: isAfterOrEqualTo
argumentType: java.time.Instant
- org.openrewrite.java.testing.hamcrest.HamcrestMatcherToAssertJ:
matcher: equalTo
assertion: isEqualTo
- org.openrewrite.java.testing.hamcrest.HamcrestMatcherToAssertJ:
matcher: greaterThanOrEqualTo
assertion: isGreaterThanOrEqualTo
- org.openrewrite.java.testing.hamcrest.HamcrestMatcherToAssertJ:
matcher: greaterThan
assertion: isGreaterThan
- org.openrewrite.java.testing.hamcrest.HamcrestMatcherToAssertJ:
matcher: hasToString
assertion: hasToString
- org.openrewrite.java.testing.hamcrest.HamcrestMatcherToAssertJ:
matcher: lessThanOrEqualTo
assertion: isLessThanOrEqualTo
- org.openrewrite.java.testing.hamcrest.HamcrestMatcherToAssertJ:
matcher: lessThan
assertion: isLessThan
- org.openrewrite.java.testing.hamcrest.HamcrestMatcherToAssertJ:
matcher: notNullValue
assertion: isNotNull
- org.openrewrite.java.testing.hamcrest.HamcrestMatcherToAssertJ:
matcher: not
assertion: isNotEqualTo
- org.openrewrite.java.testing.hamcrest.HamcrestMatcherToAssertJ:
matcher: nullValue
assertion: isNull
- org.openrewrite.java.testing.hamcrest.HamcrestMatcherToAssertJ:
matcher: sameInstance
assertion: isSameAs
- org.openrewrite.java.testing.hamcrest.HamcrestMatcherToAssertJ:
matcher: instanceOf
assertion: isInstanceOf
- org.openrewrite.java.testing.hamcrest.HamcrestMatcherToAssertJ:
matcher: isA
assertion: isInstanceOf
- org.openrewrite.java.testing.hamcrest.HamcrestMatcherToAssertJ:
matcher: arrayContaining
assertion: containsExactly
- org.openrewrite.java.testing.hamcrest.HamcrestMatcherToAssertJ:
matcher: arrayContainingInAnyOrder
assertion: containsExactlyInAnyOrder
- org.openrewrite.java.testing.hamcrest.HamcrestMatcherToAssertJ:
matcher: arrayWithSize
assertion: hasSize
- org.openrewrite.java.testing.hamcrest.HamcrestMatcherToAssertJ:
matcher: emptyArray
assertion: isEmpty
- org.openrewrite.java.testing.hamcrest.HamcrestMatcherToAssertJ:
matcher: hasItemInArray
assertion: contains
- org.openrewrite.java.testing.hamcrest.HamcrestMatcherToAssertJ:
matcher: blankString
assertion: isBlank
- org.openrewrite.java.testing.hamcrest.HamcrestMatcherToAssertJ:
matcher: containsString
assertion: contains
- org.openrewrite.java.testing.hamcrest.HamcrestMatcherToAssertJ:
matcher: containsStringIgnoringCase
assertion: containsIgnoringCase
- org.openrewrite.java.testing.hamcrest.HamcrestMatcherToAssertJ:
matcher: emptyOrNullString
assertion: isNullOrEmpty
- org.openrewrite.java.testing.hamcrest.HamcrestMatcherToAssertJ:
matcher: emptyString
assertion: isEmpty
- org.openrewrite.java.testing.hamcrest.HamcrestMatcherToAssertJ:
matcher: endsWith
assertion: endsWith
- org.openrewrite.java.testing.hamcrest.HamcrestMatcherToAssertJ:
matcher: endsWithIgnoringCase
assertion: endsWithIgnoringCase
- org.openrewrite.java.testing.hamcrest.HamcrestMatcherToAssertJ:
matcher: equalToIgnoringCase
assertion: isEqualToIgnoringCase
- org.openrewrite.java.testing.hamcrest.HamcrestMatcherToAssertJ:
matcher: equalToIgnoringWhiteSpace
assertion: isEqualToIgnoringWhitespace
- org.openrewrite.java.testing.hamcrest.HamcrestMatcherToAssertJ:
matcher: hasLength
assertion: hasSize
- org.openrewrite.java.testing.hamcrest.HamcrestMatcherToAssertJ:
matcher: isEmptyString
assertion: isEmpty
- org.openrewrite.java.testing.hamcrest.HamcrestMatcherToAssertJ:
matcher: isEmptyOrNullString
assertion: isNullOrEmpty
- org.openrewrite.java.testing.hamcrest.HamcrestMatcherToAssertJ:
matcher: matchesPattern
assertion: matches
- org.openrewrite.java.testing.hamcrest.HamcrestMatcherToAssertJ:
matcher: matchesRegex
assertion: matches
- org.openrewrite.java.testing.hamcrest.HamcrestMatcherToAssertJ:
matcher: startsWith
assertion: startsWith
- org.openrewrite.java.testing.hamcrest.HamcrestMatcherToAssertJ:
matcher: startsWithIgnoringCase
assertion: startsWithIgnoringCase
- org.openrewrite.java.testing.hamcrest.HamcrestMatcherToAssertJ:
matcher: contains
assertion: containsExactly
- org.openrewrite.java.testing.hamcrest.HamcrestMatcherToAssertJ:
matcher: containsInAnyOrder
assertion: containsExactlyInAnyOrder
- org.openrewrite.java.testing.hamcrest.HamcrestMatcherToAssertJ:
matcher: empty
assertion: isEmpty
- org.openrewrite.java.testing.hamcrest.HamcrestMatcherToAssertJ:
matcher: hasSize
assertion: hasSize
- org.openrewrite.java.testing.hamcrest.HamcrestMatcherToAssertJ:
matcher: hasItem
assertion: contains
- org.openrewrite.java.testing.hamcrest.HamcrestMatcherToAssertJ:
matcher: hasItems
assertion: contains
- org.openrewrite.java.testing.hamcrest.HamcrestMatcherToAssertJ:
matcher: in
assertion: isIn
- org.openrewrite.java.testing.hamcrest.HamcrestMatcherToAssertJ:
matcher: isIn
assertion: isIn
- org.openrewrite.java.testing.hamcrest.HamcrestMatcherToAssertJ:
matcher: hasEntry
assertion: containsEntry
- org.openrewrite.java.testing.hamcrest.HamcrestMatcherToAssertJ:
matcher: hasKey
assertion: containsKey
- org.openrewrite.java.testing.hamcrest.HamcrestMatcherToAssertJ:
matcher: hasValue
assertion: containsValue
- org.openrewrite.java.testing.hamcrest.HamcrestMatcherToAssertJ:
matcher: aMapWithSize
assertion: hasSize
- org.openrewrite.java.testing.hamcrest.HamcrestMatcherToAssertJ:
matcher: anEmptyMap
assertion: isEmpty
- org.openrewrite.java.testing.hamcrest.HamcrestMatcherToAssertJ:
matcher: closeTo
assertion: isCloseTo
- org.openrewrite.java.testing.hamcrest.HamcrestNotMatcherToAssertJ:
notMatcher: equalTo
assertion: isNotEqualTo
- org.openrewrite.java.testing.hamcrest.HamcrestNotMatcherToAssertJ:
notMatcher: hasToString
assertion: doesNotHaveToString
- org.openrewrite.java.testing.hamcrest.HamcrestNotMatcherToAssertJ:
notMatcher: in
assertion: isNotIn
- org.openrewrite.java.testing.hamcrest.HamcrestNotMatcherToAssertJ:
notMatcher: isIn
assertion: isNotIn
- org.openrewrite.java.testing.hamcrest.HamcrestNotMatcherToAssertJ:
notMatcher: instanceOf
assertion: isNotInstanceOf
- org.openrewrite.java.testing.hamcrest.HamcrestNotMatcherToAssertJ:
notMatcher: nullValue
assertion: isNotNull
- org.openrewrite.java.testing.hamcrest.HamcrestNotMatcherToAssertJ:
notMatcher: sameInstance
assertion: isNotSameAs
- org.openrewrite.java.testing.hamcrest.HamcrestNotMatcherToAssertJ:
notMatcher: equalToIgnoringCase
assertion: isNotEqualToIgnoringCase
- org.openrewrite.java.testing.hamcrest.HamcrestNotMatcherToAssertJ:
notMatcher: equalToIgnoringWhiteSpace
assertion: isNotEqualToIgnoringWhitespace
- org.openrewrite.java.testing.hamcrest.HamcrestNotMatcherToAssertJ:
notMatcher: containsString
assertion: doesNotContain
- org.openrewrite.java.testing.hamcrest.HamcrestNotMatcherToAssertJ:
notMatcher: containsStringIgnoringCase
assertion: doesNotContainIgnoringCase
- org.openrewrite.java.testing.hamcrest.HamcrestNotMatcherToAssertJ:
notMatcher: startsWith
assertion: doesNotStartWith
- org.openrewrite.java.testing.hamcrest.HamcrestNotMatcherToAssertJ:
notMatcher: endsWith
assertion: doesNotEndWith
- org.openrewrite.java.testing.hamcrest.HamcrestNotMatcherToAssertJ:
notMatcher: matchesPattern
assertion: doesNotMatch
- org.openrewrite.java.testing.hamcrest.HamcrestNotMatcherToAssertJ:
notMatcher: matchesRegex
assertion: doesNotMatch
- org.openrewrite.java.testing.hamcrest.HamcrestNotMatcherToAssertJ:
notMatcher: blankString
assertion: isNotBlank
- org.openrewrite.java.testing.hamcrest.HamcrestNotMatcherToAssertJ:
notMatcher: emptyString
assertion: isNotEmpty
- org.openrewrite.java.testing.hamcrest.HamcrestNotMatcherToAssertJ:
notMatcher: hasItem
assertion: doesNotContain
- org.openrewrite.java.testing.hamcrest.HamcrestNotMatcherToAssertJ:
notMatcher: hasItems
assertion: doesNotContain
- org.openrewrite.java.testing.hamcrest.HamcrestNotMatcherToAssertJ:
notMatcher: empty
assertion: isNotEmpty
Usage
This recipe has no required configuration options. It can be activated by adding a dependency on org.openrewrite.recipe:rewrite-testing-frameworks
in your build file or by running a shell command (in which case no build changes are needed):
- Gradle
- Gradle init script
- Maven POM
- Maven Command Line
- Moderne CLI
- Add the following to your
build.gradle
file:
plugins {
id("org.openrewrite.rewrite") version("6.28.3")
}
rewrite {
activeRecipe("org.openrewrite.java.testing.hamcrest.MigrateHamcrestToAssertJ")
setExportDatatables(true)
}
repositories {
mavenCentral()
}
dependencies {
rewrite("org.openrewrite.recipe:rewrite-testing-frameworks:2.24.0")
}
- Run
gradle rewriteRun
to run the recipe.
- Create a file named
init.gradle
in the root of your project.
initscript {
repositories {
maven { url "https://plugins.gradle.org/m2" }
}
dependencies { classpath("org.openrewrite:plugin:6.28.3") }
}
rootProject {
plugins.apply(org.openrewrite.gradle.RewritePlugin)
dependencies {
rewrite("org.openrewrite.recipe:rewrite-testing-frameworks:2.24.0")
}
rewrite {
activeRecipe("org.openrewrite.java.testing.hamcrest.MigrateHamcrestToAssertJ")
setExportDatatables(true)
}
afterEvaluate {
if (repositories.isEmpty()) {
repositories {
mavenCentral()
}
}
}
}
- Run the recipe.
gradle --init-script init.gradle rewriteRun
- Add the following to your
pom.xml
file:
<project>
<build>
<plugins>
<plugin>
<groupId>org.openrewrite.maven</groupId>
<artifactId>rewrite-maven-plugin</artifactId>
<version>5.47.0</version>
<configuration>
<exportDatatables>true</exportDatatables>
<activeRecipes>
<recipe>org.openrewrite.java.testing.hamcrest.MigrateHamcrestToAssertJ</recipe>
</activeRecipes>
</configuration>
<dependencies>
<dependency>
<groupId>org.openrewrite.recipe</groupId>
<artifactId>rewrite-testing-frameworks</artifactId>
<version>2.24.0</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
</project>
- Run
mvn rewrite:run
to run the recipe.
You will need to have Maven installed on your machine before you can run the following command.
mvn -U org.openrewrite.maven:rewrite-maven-plugin:run -Drewrite.recipeArtifactCoordinates=org.openrewrite.recipe:rewrite-testing-frameworks:RELEASE -Drewrite.activeRecipes=org.openrewrite.java.testing.hamcrest.MigrateHamcrestToAssertJ -Drewrite.exportDatatables=true
You will need to have configured the Moderne CLI on your machine before you can run the following command.
mod run . --recipe MigrateHamcrestToAssertJ
If the recipe is not available locally, then you can install it using:
mod config recipes jar install org.openrewrite.recipe:rewrite-testing-frameworks:2.24.0
See how this recipe works across multiple open-source repositories
Run this recipe on OSS repos at scale with the Moderne SaaS.
The community edition of the Moderne platform enables you to easily run recipes across thousands of open-source repositories.
Please contact Moderne for more information about safely running the recipes on your own codebase in a private SaaS.
Data Tables
Source files that had results
org.openrewrite.table.SourcesFileResults
Source files that were modified by the recipe run.
Column Name | Description |
---|---|
Source path before the run | The source path of the file before the run. null when a source file was created during the run. |
Source path after the run | A recipe may modify the source path. This is the path after the run. null when a source file was deleted during the run. |
Parent of the recipe that made changes | In a hierarchical recipe, the parent of the recipe that made a change. Empty if this is the root of a hierarchy or if the recipe is not hierarchical at all. |
Recipe that made changes | The specific recipe that made a change. |
Estimated time saving | An estimated effort that a developer to fix manually instead of using this recipe, in unit of seconds. |
Cycle | The recipe cycle in which the change was made. |
Source files that errored on a recipe
org.openrewrite.table.SourcesFileErrors
The details of all errors produced by a recipe run.
Column Name | Description |
---|---|
Source path | The file that failed to parse. |
Recipe that made changes | The specific recipe that made a change. |
Stack trace | The stack trace of the failure. |
Recipe performance
org.openrewrite.table.RecipeRunStats
Statistics used in analyzing the performance of recipes.
Column Name | Description |
---|---|
The recipe | The recipe whose stats are being measured both individually and cumulatively. |
Source file count | The number of source files the recipe ran over. |
Source file changed count | The number of source files which were changed in the recipe run. Includes files created, deleted, and edited. |
Cumulative scanning time | The total time spent across the scanning phase of this recipe. |
99th percentile scanning time | 99 out of 100 scans completed in this amount of time. |
Max scanning time | The max time scanning any one source file. |
Cumulative edit time | The total time spent across the editing phase of this recipe. |
99th percentile edit time | 99 out of 100 edits completed in this amount of time. |
Max edit time | The max time editing any one source file. |
Contributors
Tim te Beek, Knut Wannheden, Jonathan Schnéider, Aleksandar A Simpson