use of org.teiid.language.Command in project teiid by teiid.
the class TestSybaseIQTranslator method helpTestVisitor.
public void helpTestVisitor(String vdb, String input, String expectedOutput) {
// Convert from sql to objects
Command obj = TranslationHelper.helpTranslate(vdb, input);
TranslatedCommand tc = new TranslatedCommand(Mockito.mock(ExecutionContext.class), trans);
try {
tc.translateCommand(obj);
} catch (TranslatorException e) {
throw new RuntimeException(e);
}
// $NON-NLS-1$
assertEquals("Did not get correct sql", expectedOutput, tc.getSql());
}
use of org.teiid.language.Command in project teiid by teiid.
the class TestSybaseSQLConversionVisitor method helpTestVisitor.
public void helpTestVisitor(String vdb, String input, String expectedOutput) {
// Convert from sql to objects
Command obj = TranslationHelper.helpTranslate(vdb, input);
TranslatedCommand tc = new TranslatedCommand(Mockito.mock(ExecutionContext.class), trans);
try {
tc.translateCommand(obj);
} catch (TranslatorException e) {
throw new RuntimeException(e);
}
// $NON-NLS-1$
assertEquals("Did not get correct sql", expectedOutput, tc.getSql());
}
use of org.teiid.language.Command in project teiid by teiid.
the class TestAccessSQLTranslator method helpTestVisitor.
public void helpTestVisitor(String input, String expectedOutput) throws TranslatorException {
// Convert from sql to objects
Command obj = FakeTranslationFactory.getInstance().getBQTTranslationUtility().parseCommand(input);
TranslatedCommand tc = new TranslatedCommand(Mockito.mock(ExecutionContext.class), TRANSLATOR);
tc.translateCommand(obj);
// Check stuff
// $NON-NLS-1$
assertEquals("Did not get correct sql", expectedOutput, tc.getSql());
}
use of org.teiid.language.Command in project teiid by teiid.
the class TestDB2SqlTranslator method helpTestVisitor.
public void helpTestVisitor(TranslationUtility util, String input, String expectedOutput) throws TranslatorException {
// Convert from sql to objects
Command obj = util.parseCommand(input);
TranslatedCommand tc = new TranslatedCommand(Mockito.mock(ExecutionContext.class), TRANSLATOR);
tc.translateCommand(obj);
// $NON-NLS-1$
assertEquals("Did not get correct sql", expectedOutput, tc.getSql());
}
use of org.teiid.language.Command in project teiid by teiid.
the class TestSqlServerConversionVisitor method testBooleanExpression.
/**
* the first column expression needs converted to a single clause case
* the second column condition in the case should not be altered
* the third column nested boolean expression needs converted accounting for 3 level logic
*/
@Test
public void testBooleanExpression() throws Exception {
// $NON-NLS-1$
String input = "select stringkey is null, case when stringkey = 'b' then 1 end, coalesce(intkey = 1, true) from bqt1.smalla";
// $NON-NLS-1$
String output = "SELECT CASE WHEN g_0.StringKey IS NULL THEN 1 ELSE 0 END, CASE WHEN g_0.StringKey = 'b' THEN 1 END, isnull(CASE WHEN g_0.IntKey = 1 THEN 1 WHEN NOT (g_0.IntKey = 1) THEN 0 END, 1) FROM SmallA g_0";
CommandBuilder commandBuilder = new CommandBuilder(RealMetadataFactory.exampleBQTCached());
Command obj = commandBuilder.getCommand(input, true, true);
TranslationHelper.helpTestVisitor(output, trans, obj);
}
Aggregations