use of org.teiid.query.sql.LanguageObject in project teiid by teiid.
the class TestBatchedUpdatePlanner method helpGetCommands.
public static List<Command> helpGetCommands(String[] sql, QueryMetadataInterface md) throws TeiidComponentException, TeiidProcessingException {
// $NON-NLS-1$
if (DEBUG)
System.out.println("\n####################################\n" + sql);
List<Command> commands = new ArrayList<Command>(sql.length);
for (int i = 0; i < sql.length; i++) {
Command command = QueryParser.getQueryParser().parseCommand(sql[i]);
QueryResolver.resolveCommand(command, md);
ValidatorReport repo = Validator.validate(command, md);
Collection<LanguageObject> failures = new ArrayList<LanguageObject>();
repo.collectInvalidObjects(failures);
if (failures.size() > 0) {
// $NON-NLS-1$
fail("Exception during validation (" + repo);
}
command = QueryRewriter.rewrite(command, md, null);
commands.add(command);
}
return commands;
}
use of org.teiid.query.sql.LanguageObject in project teiid by teiid.
the class TestDeepGroupCollectorVisitor method helpTestVisitor.
public void helpTestVisitor(String sql, String[] expectedGroups) {
LanguageObject obj = null;
try {
obj = QueryParser.getQueryParser().parseCommand(sql);
} catch (TeiidException e) {
throw new RuntimeException(e);
}
Collection actualGroups = GroupCollectorVisitor.getGroupsIgnoreInlineViews(obj, false);
// $NON-NLS-1$
assertEquals("Did not get expected number of groups", expectedGroups.length, actualGroups.size());
Iterator iter = actualGroups.iterator();
for (int i = 0; iter.hasNext(); i++) {
GroupSymbol group = (GroupSymbol) iter.next();
assertTrue(// $NON-NLS-1$ //$NON-NLS-2$
"Expected group did not match, expected=" + expectedGroups[i] + ", actual=" + group, group.getName().equalsIgnoreCase(expectedGroups[i]));
}
}
use of org.teiid.query.sql.LanguageObject in project teiid by teiid.
the class TestValidator method examineReport.
private static void examineReport(Object command, String[] expectedStringArray, ValidatorReport report) {
// Get invalid objects from report
Collection<LanguageObject> actualObjs = new ArrayList<LanguageObject>();
report.collectInvalidObjects(actualObjs);
// Compare expected and actual objects
Set<String> expectedStrings = new HashSet<String>(Arrays.asList(expectedStringArray));
Set<String> actualStrings = new HashSet<String>();
for (LanguageObject obj : actualObjs) {
actualStrings.add(SQLStringVisitor.getSQLString(obj));
}
if (expectedStrings.size() == 0 && actualStrings.size() > 0) {
// $NON-NLS-1$
fail("Expected no failures but got some: " + report.getFailureMessage());
} else if (actualStrings.size() == 0 && expectedStrings.size() > 0) {
// $NON-NLS-1$
fail("Expected some failures but got none for sql = " + command);
} else {
// $NON-NLS-1$
assertEquals("Expected and actual sets of strings are not the same: ", expectedStrings, actualStrings);
}
}
Aggregations