use of org.teiid.query.sql.lang.Command in project teiid by teiid.
the class TestConnectorWorkItem method testSourcHints.
@Test
public void testSourcHints() throws Exception {
// $NON-NLS-1$
Command command = helpGetCommand("update bqt1.smalla set stringkey = 1 where stringkey = 2", EXAMPLE_BQT);
command.setSourceHint(new SourceHint());
AtomicRequestMessage arm = createNewAtomicRequestMessage(1, 1);
arm.setCommand(command);
ConnectorManager cm = TestConnectorManager.getConnectorManager();
cm.registerRequest(arm);
}
use of org.teiid.query.sql.lang.Command in project teiid by teiid.
the class TestConnectorWorkItem method testConvertIn.
@Test
public void testConvertIn() throws Exception {
// $NON-NLS-1$
Command command = helpGetCommand("select intkey from bqt1.smalla where stringkey in ('1', '2')", EXAMPLE_BQT);
AtomicRequestMessage arm = createNewAtomicRequestMessage(1, 1);
arm.setCommand(command);
ConnectorManager cm = TestConnectorManager.getConnectorManager();
cm.getExecutionFactory().setSourceRequired(false);
ConnectorWork synchConnectorWorkItem = cm.registerRequest(arm);
synchConnectorWorkItem.execute();
synchConnectorWorkItem.close();
FakeConnector fc = (FakeConnector) cm.getExecutionFactory();
assertEquals("SELECT SmallA.IntKey FROM SmallA WHERE SmallA.StringKey = '2' OR SmallA.StringKey = '1'", fc.getCommands().get(0).toString());
assertEquals(1, fc.getConnectionCount());
assertEquals(1, fc.getCloseCount());
}
use of org.teiid.query.sql.lang.Command in project teiid by teiid.
the class TestConnectorWorkItem method helpGetCommand.
private static Command helpGetCommand(String sql, QueryMetadataInterface metadata) throws Exception {
Command command = QueryParser.getQueryParser().parseCommand(sql);
QueryResolver.resolveCommand(command, metadata);
return command;
}
use of org.teiid.query.sql.lang.Command in project teiid by teiid.
the class TestAuthorizationValidationVisitor method helpTest.
private void helpTest(String sql, QueryMetadataInterface metadata, String[] expectedInaccesible, VDBMetaData vdb, DataPolicyMetadata... roles) throws QueryParserException, QueryResolverException, TeiidComponentException {
QueryParser parser = QueryParser.getQueryParser();
Command command = parser.parseCommand(sql);
QueryResolver.resolveCommand(command, metadata);
DataRolePolicyDecider dataRolePolicyDecider = createPolicyDecider(metadata, vdb, roles);
// $NON-NLS-1$
AuthorizationValidationVisitor visitor = new AuthorizationValidationVisitor(dataRolePolicyDecider, context);
ValidatorReport report = Validator.validate(command, metadata, visitor);
if (report.hasItems()) {
ValidatorFailure firstFailure = report.getItems().iterator().next();
// strings
Set<String> expected = new HashSet<String>(Arrays.asList(expectedInaccesible));
// elements
Set<String> actual = new HashSet<String>();
for (LanguageObject obj : firstFailure.getInvalidObjects()) {
if (obj instanceof ElementSymbol) {
actual.add(((ElementSymbol) obj).getName());
} else {
actual.add(obj.toString());
}
}
assertEquals(expected, actual);
} else if (expectedInaccesible.length > 0) {
// $NON-NLS-1$
fail("Expected inaccessible objects, but got none.");
}
}
use of org.teiid.query.sql.lang.Command in project teiid by teiid.
the class TestProcedureImpl method example.
public static Call example() throws Exception {
// $NON-NLS-1$
String sql = "EXEC pm1.sq3('x', 1)";
Command command = new QueryParser().parseCommand(sql);
QueryResolver.resolveCommand(command, TstLanguageBridgeFactory.metadata);
return TstLanguageBridgeFactory.factory.translate((StoredProcedure) command);
}
Aggregations