void () { final String in = """ class A extends TestCase { void testOne() { System.out.println(); } } """; final String what = "class '_A { void '_b:[regex( test.* )](); }"; final String by = "class $A$ {\n @java.lang.Override void $b$();\n}"; assertEquals(""" class A extends TestCase { @Override void testOne() { System.out.println(); } } """, replace(in, what, by, true)); final String what2 = "void '_a:[regex( test.* )]();"; final String by2 = "@org.junit.Test void $a$();"; assertEquals(""" class A extends TestCase { @org.junit.Test void testOne() { System.out.println(); } } """, replace(in, what2, by2)); }