void () { String s1 = "map.put(key, value); // line 1"; String s2 = "map.put(key, value); // line 1"; String s3 = "map.put(key, value); // line 1"; String expectedResult = "map.put(key, value); // line 1"; assertEquals("replace self with comment after", expectedResult, replace(s1, s2, s3)); String s4 = "if (true) System.out.println(\"1111\"); else System.out.println(\"2222\");\n" + "while(true) System.out.println(\"1111\");"; String s5 = "System.out.println('_Test);"; String s6 = "/* System.out.println($Test$); */"; String expectedResult2 = "if (true) /* System.out.println(\"1111\"); */; else /* System.out.println(\"2222\"); */;\n" + "while(true) /* System.out.println(\"1111\"); */;"; assertEquals("replace with comment", expectedResult2, replace(s4, s5, s6)); }