### Question:
LikeExpressionHelper { static void escape(PatternMatchNode exp) { Object pattern = exp.getOperand(1); if (pattern instanceof String) { String pString = pattern.toString(); int len = pString.length(); for (int i = 0; i < len; i++) { char c = pString.charAt(i); if (c == WILDCARD_SEQUENCE || c == WILDCARD_ONE) { exp.setOperand(1, escapeFrom(exp, pString, i, len)); break; } } } }    }### Answer:
@Test public void testEscape_NoEscapeChars() { PatternMatchNode node = new ASTLike(new ASTObjPath("x"), "abc"); LikeExpressionHelper.escape(node); assertEquals("abc", node.getOperand(1)); assertEquals(0, node.getEscapeChar()); }
@Test public void testEscape_OneChar() { PatternMatchNode node = new ASTLike(new ASTObjPath("x"), "ab_c"); LikeExpressionHelper.escape(node); assertEquals("ab!_c", node.getOperand(1)); assertEquals('!', node.getEscapeChar()); }
@Test public void testEscape_TwoChars() { PatternMatchNode node = new ASTLike(new ASTObjPath("x"), "ab_c_"); LikeExpressionHelper.escape(node); assertEquals("ab!_c!_", node.getOperand(1)); assertEquals('!', node.getEscapeChar()); }
@Test public void testEscape_TwoChars_Mix() { PatternMatchNode node = new ASTLike(new ASTObjPath("x"), "ab%c_"); LikeExpressionHelper.escape(node); assertEquals("ab!%c!_", node.getOperand(1)); assertEquals('!', node.getEscapeChar()); }
@Test public void testEscape_AltEscapeChar1() { PatternMatchNode node = new ASTLike(new ASTObjPath("x"), "a!%c"); LikeExpressionHelper.escape(node); assertEquals("a!#%c", node.getOperand(1)); assertEquals('#', node.getEscapeChar()); }
@Test public void testEscape_AltEscapeChar2() { PatternMatchNode node = new ASTLike(new ASTObjPath("x"), "a!%c#_"); LikeExpressionHelper.escape(node); assertEquals("a!$%c#$_", node.getOperand(1)); assertEquals('$', node.getEscapeChar()); }