Skip to content

Commit 3a58f54

Browse files
committed
Add declarative recipe for closeTo after #379
1 parent 7c2106a commit 3a58f54

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

src/main/java/org/openrewrite/java/testing/hamcrest/HamcrestMatcherToAssertJ.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ private String applySpecialCases(J.MethodInvocation mi, String template) {
165165

166166
if (CLOSE_TO_MATCHER.matches(mi)) {
167167
List<String> newTemplateArr = new ArrayList<>();
168-
for (int i = 0; i<splitTemplate.length; i++) {
168+
for (int i = 0; i < splitTemplate.length; i++) {
169169
// within needs to placed on the second argument of isCloseTo
170170
if (i == 1) {
171171
newTemplateArr.add(String.format("within(%s)", splitTemplate[i]));

src/main/resources/META-INF/rewrite/hamcrest.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,11 @@ recipeList:
180180
matcher: anEmptyMap
181181
assertion: isEmpty
182182

183+
# Number Matchers
184+
- org.openrewrite.java.testing.hamcrest.HamcrestMatcherToAssertJ:
185+
matcher: closeTo
186+
assertion: isCloseTo
187+
183188
# Matchers inverted through `not(Matcher)`
184189
- org.openrewrite.java.testing.hamcrest.HamcrestNotMatcherToAssertJ:
185190
notMatcher: equalTo

0 commit comments

Comments
 (0)