use of org.teiid.query.sql.lang.JoinPredicate in project teiid by teiid.
the class TestJoinPredicate method testNonEquivalence2.
/**
* Test a <code>JoinPredicate</code> object using <code>UnitTestUtil.helpTestEquivalence</code>.
* <p>
* This test ensures that two different <code>JoinPredicate</code> objects
* constructed with the same join type but with different criteria evaluate
* as not equal.
* <p>
* For example:
* ... m.g1 FULL OUTER JOIN m.g2 ON ((m.g1.e1 = m.g2.e1) AND (m.g1.e2 = m.g2.e2))
* ... m.g1 FULL OUTER JOIN m.g2 ON ((m.g1.e2 = m.g2.e2) AND (m.g1.e1 = m.g2.e1))
*/
public void testNonEquivalence2() {
// $NON-NLS-1$ //$NON-NLS-2$
JoinPredicate jp1 = example(JoinType.JOIN_LEFT_OUTER, "e1", "e2");
// $NON-NLS-1$ //$NON-NLS-2$
JoinPredicate jp2 = example(JoinType.JOIN_LEFT_OUTER, "e2", "e1");
int equals = -1;
UnitTestUtil.helpTestEquivalence(equals, jp1, jp2);
}
use of org.teiid.query.sql.lang.JoinPredicate in project teiid by teiid.
the class TestJoinPredicate method testEquals4.
/**
* Test <code>equals()</code> method of <code>JoinPredicate</code> to
* verify it properly evaluates the equality of two <code>JoinPredicate</code>
* objects.
* <p>
* This test ensures that two different <code>JoinPredicate</code> objects
* that were constructed with the same join type but with different
* criteria evaluate as not equal.
* <p>
* For example:
* ... m.g1 INNER JOIN m.g2 ON m.g1.e1 = m.g2.e1
* ... m.g1 INNER JOIN m.g2 ON m.g1.e2 = m.g2.e2
*/
public void testEquals4() {
// $NON-NLS-1$
JoinPredicate jp1 = example(JoinType.JOIN_INNER, "e1");
// $NON-NLS-1$
JoinPredicate jp2 = example(JoinType.JOIN_INNER, "e2");
// $NON-NLS-1$ //$NON-NLS-2$
assertTrue("Different join predicate compare as equal: " + jp1 + ", " + jp2, !jp1.equals(jp2));
}
use of org.teiid.query.sql.lang.JoinPredicate in project teiid by teiid.
the class TestJoinPredicate method example.
// ################################## TEST HELPERS ################################
/**
* Constructs an example <code>JoinPredicate</code> object that can be used
* as join predicate in a query.
*
* @param joinType the type of join to be constructed
* @param joinOnElement the element name to be used in the left and right
* side criteria of the ON expression of the join
* @return a join predicate object
*/
public static JoinPredicate example(JoinType joinType, String joinOnElement) {
JoinPredicate jp = new JoinPredicate();
// $NON-NLS-1$
GroupSymbol g1 = new GroupSymbol("m.g1");
// $NON-NLS-1$
GroupSymbol g2 = new GroupSymbol("m.g2");
FromClause lc = new UnaryFromClause(g1);
FromClause rc = new UnaryFromClause(g2);
// $NON-NLS-1$
Expression le = new ElementSymbol("m.g1." + joinOnElement);
// $NON-NLS-1$
Expression re = new ElementSymbol("m.g2." + joinOnElement);
Criteria c1 = new CompareCriteria(le, CompareCriteria.EQ, re);
jp.setLeftClause(lc);
jp.setRightClause(rc);
jp.setJoinType(joinType != null ? joinType : JoinType.JOIN_LEFT_OUTER);
jp.setJoinCriteria(Arrays.asList(new Object[] { c1 }));
return jp;
}
use of org.teiid.query.sql.lang.JoinPredicate in project teiid by teiid.
the class TestJoinPredicate method testEquals3.
/**
* Test <code>equals()</code> method of <code>JoinPredicate</code> to
* verify it properly evaluates the equality of two <code>JoinPredicate</code>
* objects.
* <p>
* This test ensures that two different <code>JoinPredicate</code> objects
* that were constructed with different join types but with the same
* compound criteria evaluate as not equal.
* <p>
* For example:
* ... m.g1 LEFT OUTER JOIN m.g2 ON ((m.g1.e1 = m.g2.e1) AND (m.g1.e2 = m.g2.e2))
* ... m.g1 RIGHT OUTER JOIN m.g2 ON ((m.g1.e1 = m.g2.e1) AND (m.g1.e2 = m.g2.e2))
*/
public void testEquals3() {
// $NON-NLS-1$ //$NON-NLS-2$
JoinPredicate jp1 = example(JoinType.JOIN_LEFT_OUTER, "e1", "e2");
// $NON-NLS-1$ //$NON-NLS-2$
JoinPredicate jp2 = example(JoinType.JOIN_RIGHT_OUTER, "e1", "e2");
// $NON-NLS-1$ //$NON-NLS-2$
assertTrue("Different join predicate compare as equal: " + jp1 + ", " + jp2, !jp1.equals(jp2));
}
use of org.teiid.query.sql.lang.JoinPredicate in project teiid by teiid.
the class TestJoinPredicate method testEquals1.
// ################################## ACTUAL TESTS ################################
/**
* Test <code>equals()</code> method of <code>JoinPredicate</code> to
* verify it properly evaluates the equality of two <code>JoinPredicate</code>
* objects.
* <p>
* This test ensures that two different <code>JoinPredicate</code> objects
* that were constructed with the same join type and with the same criteria
* evaluate as equal.
* <p>
* For example:
* ... m.g1 LEFT OUTER JOIN m.g2 ON m.g1.e1 = m.g2.e1
*/
public void testEquals1() {
// $NON-NLS-1$
JoinPredicate jp1 = example(JoinType.JOIN_LEFT_OUTER, "e1");
// $NON-NLS-1$
JoinPredicate jp2 = example(JoinType.JOIN_LEFT_OUTER, "e1");
// $NON-NLS-1$ //$NON-NLS-2$
assertTrue("Equivalent join predicate don't compare as equal: " + jp1 + ", " + jp2, jp1.equals(jp2));
}
Aggregations