mirror of
https://github.com/jlengrand/error-prone-support.git
synced 2026-03-10 08:11:25 +00:00
Add support for migrating groups attribute
This commit is contained in:
@@ -105,6 +105,24 @@ public final class AnnotationAttributeReplacement extends BugChecker implements
|
||||
SourceCode.treeToString(
|
||||
assignmentTree.getExpression(), state))))
|
||||
.build()))
|
||||
.put(
|
||||
singleArgumentMatcher("org.testng.annotations.Test#groups"),
|
||||
(annotation, argument, state) ->
|
||||
Optional.of(argument)
|
||||
.filter(AssignmentTree.class::isInstance)
|
||||
.map(AssignmentTree.class::cast)
|
||||
.map(
|
||||
assignmentTree ->
|
||||
SuggestedFix.builder()
|
||||
.merge(removeAnnotationArgument(annotation, argument, state))
|
||||
.merge(
|
||||
SuggestedFix.postfixWith(
|
||||
annotation,
|
||||
String.format(
|
||||
"\n@org.junit.jupiter.api.Tag(%s)",
|
||||
SourceCode.treeToString(
|
||||
assignmentTree.getExpression(), state))))
|
||||
.build()))
|
||||
.build();
|
||||
|
||||
@Override
|
||||
|
||||
@@ -42,13 +42,13 @@ final class AnnotationAttributeReplacementTest {
|
||||
"import org.testng.annotations.Test;",
|
||||
"",
|
||||
"class A {",
|
||||
" @Test(priority = 1, description = \"test\")",
|
||||
" @Test(priority = 1, groups = \"unit\", description = \"test\")",
|
||||
" public void foo() {}",
|
||||
"}")
|
||||
.addOutputLines(
|
||||
"A.java",
|
||||
"import org.junit.jupiter.api.MethodOrderer;",
|
||||
"import org.junit.jupiter.api.TestMethodOrder;",
|
||||
"import org.junit.jupiter.api.TestMethodOrder;",
|
||||
"import org.testng.annotations.Test;",
|
||||
"",
|
||||
"@TestMethodOrder(MethodOrderer.OrderAnnotation.class)",
|
||||
@@ -56,6 +56,7 @@ final class AnnotationAttributeReplacementTest {
|
||||
" @Test",
|
||||
" @org.junit.jupiter.api.Order(1)",
|
||||
" @org.junit.jupiter.api.DisplayName(\"test\")",
|
||||
" @org.junit.jupiter.api.Tag(\"unit\")",
|
||||
" public void foo() {}",
|
||||
"}")
|
||||
.doTest(TEXT_MATCH);
|
||||
|
||||
Reference in New Issue
Block a user