use of org.teiid.translator.Execution in project teiid by teiid.
the class TestLDAPDirectQueryExecution method testWithoutMarker.
@Test(expected = TranslatorException.class)
public void testWithoutMarker() throws Exception {
String input = "exec native('context-name=corporate;filter=(objectClass=*);count-limit=5;timout=6;search-scope=ONELEVEL_SCOPE;attributes=uid,cn')";
TranslationUtility util = FakeTranslationFactory.getInstance().getExampleTranslationUtility();
Command command = util.parseCommand(input);
ExecutionContext ec = Mockito.mock(ExecutionContext.class);
RuntimeMetadata rm = Mockito.mock(RuntimeMetadata.class);
LdapContext connection = Mockito.mock(LdapContext.class);
LdapContext ctx = Mockito.mock(LdapContext.class);
Mockito.stub(connection.lookup("corporate")).toReturn(ctx);
Execution execution = TRANSLATOR.createExecution(command, ec, rm, connection);
assertTrue(!(execution instanceof LDAPDirectSearchQueryExecution));
execution.execute();
}
use of org.teiid.translator.Execution in project teiid by teiid.
the class TestEmbeddedMongoExecution method executeCmd.
private Execution executeCmd(String sql) throws Exception {
Command cmd = utility.parseCommand(sql);
CommandContext cc = Mockito.mock(CommandContext.class);
Mockito.stub(cc.isReturnAutoGeneratedKeys()).toReturn(false);
ExecutionContext ec = Mockito.mock(ExecutionContext.class);
Mockito.stub(ec.getCommandContext()).toReturn(cc);
Execution exec = translator.createExecution(cmd, ec, utility.createRuntimeMetadata(), this.connection);
exec.execute();
return exec;
}
use of org.teiid.translator.Execution in project teiid by teiid.
the class TestVisitors method helpTest.
private void helpTest(String sql, String expected) throws Exception {
Command command = translationUtility.parseCommand(sql);
SalesForceExecutionFactory factory = new SalesForceExecutionFactory();
ExecutionContext ec = Mockito.mock(ExecutionContext.class);
RuntimeMetadata rm = Mockito.mock(RuntimeMetadata.class);
SalesforceConnection connection = Mockito.mock(SalesforceConnection.class);
ArgumentCaptor<String> queryArgument = ArgumentCaptor.forClass(String.class);
QueryResult qr = Mockito.mock(QueryResult.class);
Mockito.stub(connection.query(queryArgument.capture(), Mockito.anyInt(), Mockito.anyBoolean())).toReturn(qr);
Execution execution = factory.createExecution(command, ec, rm, connection);
execution.execute();
Mockito.verify(connection, Mockito.times(1)).query(queryArgument.capture(), Mockito.anyInt(), Mockito.anyBoolean());
assertEquals(expected, queryArgument.getValue().trim());
}
use of org.teiid.translator.Execution in project teiid by teiid.
the class TestAccumuloQueryExecution method executeCmd.
private Execution executeCmd(String sql) throws TranslatorException {
Command cmd = TestAccumuloQueryExecution.utility.parseCommand(sql);
Execution exec = translator.createExecution(cmd, Mockito.mock(ExecutionContext.class), utility.createRuntimeMetadata(), TestAccumuloQueryExecution.connection);
exec.execute();
return exec;
}
use of org.teiid.translator.Execution in project teiid by teiid.
the class TestNativeCassandra method testNativeQuery.
@Test
public void testNativeQuery() throws Exception {
CassandraExecutionFactory cef = new CassandraExecutionFactory();
cef.setSupportsDirectQueryProcedure(true);
String input = "call proc('a', 1)";
TransformationMetadata metadata = RealMetadataFactory.fromDDL("create foreign procedure proc (in x string, in y integer) options (\"teiid_rel:native-query\" 'delete from $1 where $2')", "x", "y");
TranslationUtility util = new TranslationUtility(metadata);
Command command = util.parseCommand(input);
ExecutionContext ec = Mockito.mock(ExecutionContext.class);
RuntimeMetadata rm = Mockito.mock(RuntimeMetadata.class);
CassandraConnection connection = Mockito.mock(CassandraConnection.class);
ResultSetFuture rsf = Mockito.mock(ResultSetFuture.class);
Mockito.stub(connection.executeQuery("delete from 'a' where 1")).toReturn(rsf);
Execution execution = cef.createExecution(command, ec, rm, connection);
execution.execute();
Mockito.verify(connection).executeQuery("delete from 'a' where 1");
}
Aggregations