void () { String s1 = "String ID_SPEED = \"Speed\";"; String s2 = "String 'name = \"'_string\";"; String s2_2 = "String 'name = \"'_string:[regex( .* )]\";"; String s3 = "VSegAttribute $name$ = new VSegAttribute(\"$string$\");"; String expectedResult = "VSegAttribute ID_SPEED = new VSegAttribute(\"Speed\");"; assertEquals("Matching/replacing literals", expectedResult, replace(s1, s2, s3)); assertEquals("Matching/replacing literals", expectedResult, replace(s1, s2_2, s3)); String s4 = "params.put(\"BACKGROUND\", \"#7B528D\");"; String s5 = "params.put(\"$FieldName$\", \"#$exp$\");"; String s6 = "String $FieldName$ = \"$FieldName$\";\n" + "params.put($FieldName$, \"$exp$\");"; String expectedResult2 = "String BACKGROUND = \"BACKGROUND\";\n" + "params.put(BACKGROUND, \"7B528D\");"; assertEquals("string literal replacement 2", expectedResult2, replace(s4, s5, s6)); String s7 = """ IconLoader.getIcon("/ant/property.png"); IconLoader.getIcon("/ant/another/property.png"); """; String s8 = "IconLoader.getIcon(\"/'_module/'_name:[regex( \\w+ )].png\");"; String s9 = "Icons.$module$.$name$;"; String expectedResult3 = """ Icons.ant.property; IconLoader.getIcon("/ant/another/property.png"); """; assertEquals("string literal replacement 3", expectedResult3, replace(s7, s8, s9)); String s10 = """ configureByFile(path + "1.html"); checkResultByFile(path + "1_after.html"); checkResultByFile(path + "1_after2.html"); checkResultByFile(path + "1_after3.html");"""; String s11 = "\"'a.html\""; String s12 = "\"$a$.\"+ext"; String expectedResult4 = """ configureByFile(path + "1."+ext); checkResultByFile(path + "1_after."+ext); checkResultByFile(path + "1_after2."+ext); checkResultByFile(path + "1_after3."+ext);"""; assertEquals("string literal replacement 4", expectedResult4, replace(s10, s11, s12)); }