use of org.teiid.query.sql.symbol.ElementSymbol in project teiid by teiid.
the class TestResolver method testStringConversion3.
// special test for both sides are String
@Test
public void testStringConversion3() {
// Expected left expression
// $NON-NLS-1$
ElementSymbol e1 = new ElementSymbol("pm3.g1.e1");
e1.setType(DataTypeManager.DefaultDataClasses.STRING);
// Expected right expression
// $NON-NLS-1$
Constant e2 = new Constant("2003-02-27");
// Expected criteria
CompareCriteria expected = new CompareCriteria();
expected.setLeftExpression(e1);
expected.setOperator(CompareCriteria.EQ);
expected.setRightExpression(e2);
// Resolve the query and check against expected objects
// $NON-NLS-1$
CompareCriteria actual = (CompareCriteria) helpResolveCriteria("pm3.g1.e1='2003-02-27'");
// if (! actual.getLeftExpression().equals(expected.getLeftExpression())) {
// System.out.println("left exprs not equal");
// } else if (!actual.getRightExpression().equals(expected.getRightExpression())) {
// System.out.println("right exprs not equal");
// }
// $NON-NLS-1$
assertEquals("Did not match expected criteria", expected, actual);
}
use of org.teiid.query.sql.symbol.ElementSymbol in project teiid by teiid.
the class TestResolver method testExecProjectedSymbols.
@Test
public void testExecProjectedSymbols() {
// $NON-NLS-1$
String query = "exec pm1.sq1()";
StoredProcedure proc = (StoredProcedure) helpResolve(query);
List<Expression> projected = proc.getProjectedSymbols();
assertEquals(2, projected.size());
for (Iterator<Expression> i = projected.iterator(); i.hasNext(); ) {
ElementSymbol symbol = (ElementSymbol) i.next();
assertNotNull(symbol.getGroupSymbol());
}
}
use of org.teiid.query.sql.symbol.ElementSymbol in project teiid by teiid.
the class TestOrderByRewrite method helpCheckElements.
private void helpCheckElements(OrderBy langObj, String[] elementNames, String[] elementIDs) {
List<ElementSymbol> elements = new ArrayList<ElementSymbol>();
for (Iterator<Expression> i = langObj.getSortKeys().iterator(); i.hasNext(); ) {
ElementCollectorVisitor.getElements(i.next(), elements);
}
// $NON-NLS-1$
assertEquals("Wrong number of elements: ", elementNames.length, elements.size());
for (int i = 0; i < elements.size(); i++) {
ElementSymbol symbol = elements.get(i);
// $NON-NLS-1$
assertEquals("Element name does not match: ", elementNames[i].toUpperCase(), symbol.getName().toUpperCase());
Column elementID = (Column) symbol.getMetadataID();
// $NON-NLS-1$ //$NON-NLS-2$
assertNotNull("ElementSymbol " + symbol + " was not resolved and has no metadataID", elementID);
// $NON-NLS-1$
assertEquals("ElementID name does not match: ", elementIDs[i].toUpperCase(), elementID.getFullName().toUpperCase());
}
}
use of org.teiid.query.sql.symbol.ElementSymbol in project teiid by teiid.
the class TestAccessNode method testShouldExecuteUpdate.
@Test
public void testShouldExecuteUpdate() throws Exception {
Update update = new Update();
// $NON-NLS-1$
update.setGroup(new GroupSymbol("test"));
// $NON-NLS-1$ //$NON-NLS-2$
update.addChange(new ElementSymbol("e1"), new Constant("1"));
assertTrue(RelationalNodeUtil.shouldExecute(update, false));
update.setChangeList(new SetClauseList());
assertFalse(RelationalNodeUtil.shouldExecute(update, false));
}
use of org.teiid.query.sql.symbol.ElementSymbol in project teiid by teiid.
the class TestDependentCriteriaProcessor method testNegatedSetCriteria.
@Test
public void testNegatedSetCriteria() throws Exception {
DependentAccessNode dan = new DependentAccessNode(0);
// $NON-NLS-1$
SetCriteria sc = new SetCriteria(new ElementSymbol("e1"), Arrays.asList(new Constant(1), new Constant(2)));
sc.setAllConstants(true);
sc.negate();
DependentCriteriaProcessor dcp = new DependentCriteriaProcessor(1, -1, dan, sc);
Criteria result = dcp.prepareCriteria();
assertEquals(sc, result);
assertFalse(dcp.hasNextCommand());
}
Aggregations