@Test public void testNonEquivalence2(){ MatchCriteria c1 = example("abc", '#'); //$NON-NLS-1$ c1.setNegated(true); MatchCriteria c2 = example("abc", '#'); //$NON-NLS-1$ c2.setNegated(false); int equals = -1; UnitTestUtil.helpTestEquivalence(equals, c1, c2); } }
final public MatchCriteria regexMatchCrit(ParseInfo info, Expression expression) throws ParseException { Expression value = null; boolean negated = false; switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case NOT: jj_consume_token(NOT); negated = true; break; default: jj_la1[214] = jj_gen; ; } jj_consume_token(LIKE_REGEX); value = commonValueExpression(info); MatchCriteria matchcriteria = new MatchCriteria(expression, value); matchcriteria.setNegated(negated); matchcriteria.setMode(MatchMode.REGEX); {if (true) return matchcriteria;} throw new Error("Missing return statement in function"); }
final public MatchCriteria regexMatchCrit(ParseInfo info, Expression expression) throws ParseException { Expression value = null; boolean negated = false; switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case NOT: jj_consume_token(NOT); negated = true; break; default: jj_la1[214] = jj_gen; ; } jj_consume_token(LIKE_REGEX); value = commonValueExpression(info); MatchCriteria matchcriteria = new MatchCriteria(expression, value); matchcriteria.setNegated(negated); matchcriteria.setMode(MatchMode.REGEX); {if (true) return matchcriteria;} throw new Error("Missing return statement in function"); }
final public MatchCriteria regexMatchCrit(ParseInfo info, Expression expression) throws ParseException { Expression value = null; boolean negated = false; switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case NOT: jj_consume_token(NOT); negated = true; break; default: jj_la1[213] = jj_gen; ; } jj_consume_token(LIKE_REGEX); value = commonValueExpression(info); MatchCriteria matchcriteria = new MatchCriteria(expression, value); matchcriteria.setNegated(negated); matchcriteria.setMode(MatchMode.REGEX); {if (true) return matchcriteria;} throw new Error("Missing return statement in function"); }
@Test public void testEquals2() { MatchCriteria c1 = example("abc", '#'); //$NON-NLS-1$ c1.setNegated(true); MatchCriteria c2 = example("abc", '#'); //$NON-NLS-1$ c2.setNegated(true); assertTrue("Equivalent match criteria don't compare as equal: " + c1 + ", " + c2, c1.equals(c2)); //$NON-NLS-1$ //$NON-NLS-2$ }
public static MatchCriteria helpExample(String right, char escape, boolean negated) { ElementSymbol e1 = TestElementImpl.helpExample("vm1.g1", "e1"); //$NON-NLS-1$ //$NON-NLS-2$ MatchCriteria match = new MatchCriteria(e1, new Constant(right), escape); match.setNegated(negated); return match; }
@Test public void testEquals3() { MatchCriteria c1 = example("abc", '#'); //$NON-NLS-1$ c1.setNegated(true); MatchCriteria c2 = (MatchCriteria) c1.clone(); assertTrue("Equivalent match criteria don't compare as equal: " + c1 + ", " + c2, c1.equals(c2)); //$NON-NLS-1$ //$NON-NLS-2$ }
/** * Deep copy of object * @return Deep copy of object */ public Object clone() { Expression leftCopy = null; if(getLeftExpression() != null) { leftCopy = (Expression) getLeftExpression().clone(); } Expression rightCopy = null; if(getRightExpression() != null) { rightCopy = (Expression) getRightExpression().clone(); } MatchCriteria criteriaCopy = new MatchCriteria(leftCopy, rightCopy, getEscapeChar()); criteriaCopy.setNegated(isNegated()); criteriaCopy.mode = mode; return criteriaCopy; }
/** * Deep copy of object * @return Deep copy of object */ public Object clone() { Expression leftCopy = null; if(getLeftExpression() != null) { leftCopy = (Expression) getLeftExpression().clone(); } Expression rightCopy = null; if(getRightExpression() != null) { rightCopy = (Expression) getRightExpression().clone(); } MatchCriteria criteriaCopy = new MatchCriteria(leftCopy, rightCopy, getEscapeChar()); criteriaCopy.setNegated(isNegated()); criteriaCopy.mode = mode; return criteriaCopy; }
/** * Deep copy of object * @return Deep copy of object */ public Object clone() { Expression leftCopy = null; if(getLeftExpression() != null) { leftCopy = (Expression) getLeftExpression().clone(); } Expression rightCopy = null; if(getRightExpression() != null) { rightCopy = (Expression) getRightExpression().clone(); } MatchCriteria criteriaCopy = new MatchCriteria(leftCopy, rightCopy, getEscapeChar()); criteriaCopy.setNegated(isNegated()); criteriaCopy.mode = mode; return criteriaCopy; }
@Test public void testMatchCriteria3() { MatchCriteria mc = new MatchCriteria(); mc.setLeftExpression(new ElementSymbol("m.g.e1")); //$NON-NLS-1$ mc.setRightExpression(new Constant("abc")); //$NON-NLS-1$ mc.setNegated(true); helpTest(mc, "m.g.e1 NOT LIKE 'abc'"); //$NON-NLS-1$ }
private void helpTestMatch(String value, String pattern, char escape, boolean negated, boolean expectedMatch) throws ExpressionEvaluationException, BlockedException, TeiidComponentException { MatchCriteria crit = new MatchCriteria(new Constant(value), new Constant(pattern), escape); crit.setNegated(negated); boolean actualMatch = Evaluator.evaluate(crit); // Compare actual and expected match assertEquals("Match criteria test failed for value=[" + value + "], pattern=[" + pattern + "], hasEscape=" + (escape != MatchCriteria.NULL_ESCAPE_CHAR) + ": ", expectedMatch, actualMatch); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ }
matchcriteria.setNegated(negated); if(esc == null && ((value instanceof Constant && t.image != null && t.image.startsWith("E'"))
matchcriteria.setNegated(negated); if(esc == null && ((value instanceof Constant && t.image != null && t.image.startsWith("E'"))
matchcriteria.setNegated(negated); if(esc == null && ((value instanceof Constant && t.image != null && t.image.startsWith("E'"))
/** SELECT a FROM db.g WHERE b NOT LIKE 'aString'*/ @Test public void testLike1(){ GroupSymbol g = new GroupSymbol("db.g"); //$NON-NLS-1$ From from = new From(); from.addGroup(g); Select select = new Select(); ElementSymbol a = new ElementSymbol("a"); //$NON-NLS-1$ select.addSymbol(a); Expression string1 = new Constant("aString"); //$NON-NLS-1$ MatchCriteria crit = new MatchCriteria(new ElementSymbol("b"), string1); //$NON-NLS-1$ crit.setNegated(true); Query query = new Query(); query.setSelect(select); query.setFrom(from); query.setCriteria(crit); helpTest("SELECT a FROM db.g WHERE b NOT LIKE 'aString'", //$NON-NLS-1$ "SELECT a FROM db.g WHERE b NOT LIKE 'aString'", //$NON-NLS-1$ query); }