diff --git a/src/main/java/org/openrewrite/staticanalysis/MaskCreditCardNumbers.java b/src/main/java/org/openrewrite/staticanalysis/MaskCreditCardNumbers.java index 8e5c45d66..2743bc47f 100644 --- a/src/main/java/org/openrewrite/staticanalysis/MaskCreditCardNumbers.java +++ b/src/main/java/org/openrewrite/staticanalysis/MaskCreditCardNumbers.java @@ -47,8 +47,8 @@ public String getDescription() { public TreeVisitor getVisitor() { return new JavaIsoVisitor() { @Override - public J.Literal visitLiteral(J.Literal literal, ExecutionContext executionContext) { - J.Literal l = super.visitLiteral(literal, executionContext); + public J.Literal visitLiteral(J.Literal literal, ExecutionContext ctx) { + J.Literal l = super.visitLiteral(literal, ctx); if(l.getValue() instanceof String) { String value = (String) l.getValue(); Matcher m = CC_PATTERN.matcher(value); diff --git a/src/test/java/org/openrewrite/staticanalysis/MaskCreditCardNumbersTest.java b/src/test/java/org/openrewrite/staticanalysis/MaskCreditCardNumbersTest.java index b188f7242..c6368a680 100644 --- a/src/test/java/org/openrewrite/staticanalysis/MaskCreditCardNumbersTest.java +++ b/src/test/java/org/openrewrite/staticanalysis/MaskCreditCardNumbersTest.java @@ -16,6 +16,7 @@ package org.openrewrite.staticanalysis; import org.junit.jupiter.api.Test; +import org.openrewrite.DocumentExample; import org.openrewrite.test.RecipeSpec; import org.openrewrite.test.RewriteTest; @@ -29,20 +30,23 @@ public void defaults(RecipeSpec spec) { spec.recipe(new MaskCreditCardNumbers()); } + @DocumentExample @Test void noSpaces() { rewriteRun( //language=java - java(""" - class A { - String cc = "1234567890123456"; - } - """, + java( """ - class A { - String cc = "12345678XXXXXXXX"; - } - """) + class A { + String cc = "1234567890123456"; + } + """, + """ + class A { + String cc = "12345678XXXXXXXX"; + } + """ + ) ); } @@ -50,16 +54,18 @@ class A { void withSpaces() { rewriteRun( //language=java - java(""" - class A { - String cc = "1234 5678 9012 3456"; - } - """, - """ - class A { - String cc = "1234 5678 XXXX XXXX"; - } - """) + java( + """ + class A { + String cc = "1234 5678 9012 3456"; + } + """, + """ + class A { + String cc = "1234 5678 XXXX XXXX"; + } + """ + ) ); } }