Skip to content

Commit 135a45b

Browse files
authored
Remove @SuppressStaticInitializationFor during PowerMockito migration (#946) (#946)
1 parent 04c94f8 commit 135a45b

2 files changed

Lines changed: 33 additions & 0 deletions

File tree

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ recipeList:
2828
- org.openrewrite.java.testing.mockito.ReplacePowerMockDependencies
2929
- org.openrewrite.java.RemoveAnnotation:
3030
annotationPattern: "@org.powermock.core.classloader.annotations.PowerMockIgnore"
31+
- org.openrewrite.java.RemoveAnnotation:
32+
annotationPattern: "@org.powermock.core.classloader.annotations.SuppressStaticInitializationFor"
3133
- org.openrewrite.java.ChangeMethodTargetToStatic:
3234
methodPattern: org.powermock.api.mockito.PowerMockito mockStatic(..)
3335
fullyQualifiedTargetTypeName: org.mockito.Mockito

src/test/java/org/openrewrite/java/testing/mockito/ReplacePowerMockitoIntegrationTest.java

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1826,4 +1826,35 @@ void removesManagedPowerMockDependencies() {
18261826
)
18271827
);
18281828
}
1829+
1830+
@Test
1831+
void thatSuppressStaticInitializationForIsRemoved() {
1832+
//language=java
1833+
rewriteRun(
1834+
java(
1835+
"""
1836+
import org.powermock.core.classloader.annotations.SuppressStaticInitializationFor;
1837+
import org.testng.annotations.Test;
1838+
1839+
@SuppressStaticInitializationFor("com.example.MyClass")
1840+
class StaticInitTest {
1841+
1842+
@Test
1843+
void testSomething() {
1844+
}
1845+
}
1846+
""",
1847+
"""
1848+
import org.testng.annotations.Test;
1849+
1850+
class StaticInitTest {
1851+
1852+
@Test
1853+
void testSomething() {
1854+
}
1855+
}
1856+
"""
1857+
)
1858+
);
1859+
}
18291860
}

0 commit comments

Comments
 (0)