void () { String s1 = """ public class X { /** * zzz */ private void f(int i) { //s } }"""; String s2 = """ class 'c { /** * zzz */ void f('_t '_p){'_s+;} }"""; String s3 = """ class $c$ { /** * ppp */ void f($t$ $p$){$s$;} }"""; String expectedResult = """ public class X { /** * ppp */ private void f(int i){//s } }"""; assertEquals("Correct class replacement", expectedResult, replace(s1, s2, s3)); String s1_2 = """ public class X { /** * zzz */ private void f(int i) { int a = 1; //s } }"""; String expectedResult2 = """ public class X { /** * ppp */ private void f(int i){int a = 1; //s } }"""; assertEquals("Correct class replacement, 2", expectedResult2, replace(s1_2, s2, s3)); }