use of org.teiid.api.exception.query.QueryValidatorException in project teiid by teiid.
the class TestProcedureProcessor method testVarArgsVirtNotNull.
@Test
public void testVarArgsVirtNotNull() throws Exception {
String ddl = "create virtual procedure vproc (x integer, VARIADIC z integer NOT NULL) returns (y integer) as begin select array_length(z); end;";
TransformationMetadata tm = TestProcedureResolving.createMetadata(ddl);
// $NON-NLS-1$
String sql = "call vproc(1, null, 3)";
try {
getProcedurePlan(sql, tm);
fail();
} catch (QueryValidatorException e) {
}
// $NON-NLS-1$
sql = "call vproc(1, (select cast(null as integer)), 3)";
ProcessorPlan plan = getProcedurePlan(sql, tm);
HardcodedDataManager dataManager = new HardcodedDataManager();
try {
helpTestProcess(plan, null, dataManager, tm);
fail();
} catch (QueryValidatorException e) {
}
}
use of org.teiid.api.exception.query.QueryValidatorException in project teiid by teiid.
the class TestSecurityFunctions method testHasRoleWithService.
@Test
public void testHasRoleWithService() throws Exception {
// $NON-NLS-1$
String sql = "select pm1.g1.e2 from pm1.g1 where true = hasRole('data', pm1.g1.e1)";
// Create expected results
List[] expected = new List[] {};
// Construct data manager with data
HardcodedDataManager dataManager = new HardcodedDataManager();
dataManager.addData("SELECT pm1.g1.e1, pm1.g1.e2 FROM pm1.g1", new List[] { // $NON-NLS-1$
Arrays.asList(new Object[] { "fooRole", new Integer(0) }) });
CommandContext context = new CommandContext();
context.setAuthoriziationValidator(new AuthorizationValidator() {
@Override
public boolean validate(String[] originalSql, Command command, QueryMetadataInterface metadata, CommandContext commandContext, CommandType commandType) throws QueryValidatorException, TeiidComponentException {
return false;
}
@Override
public boolean hasRole(String roleName, CommandContext commandContext) {
return false;
}
@Override
public boolean isAccessible(AbstractMetadataRecord record, CommandContext commandContext) {
return true;
}
});
Command command = TestProcessor.helpParse(sql);
ProcessorPlan plan = TestProcessor.helpGetPlan(command, RealMetadataFactory.example1Cached(), new DefaultCapabilitiesFinder(), context);
// Run query
TestProcessor.helpProcess(plan, context, dataManager, expected);
}
use of org.teiid.api.exception.query.QueryValidatorException in project teiid by teiid.
the class TestValidator method validateProcedure.
private void validateProcedure(String userUpdateStr, QueryMetadataInterface metadata) throws QueryResolverException, QueryMetadataException, TeiidComponentException, QueryValidatorException {
ProcedureContainer command = (ProcedureContainer) helpResolve(userUpdateStr, metadata);
Command proc = QueryResolver.expandCommand(command, metadata, AnalysisRecord.createNonRecordingRecord());
ValidatorReport report = Validator.validate(proc, metadata);
if (report.hasItems()) {
throw new QueryValidatorException(report.getFailureMessage());
}
report = Validator.validate(command, metadata);
if (report.hasItems()) {
throw new QueryValidatorException(report.getFailureMessage());
}
}
use of org.teiid.api.exception.query.QueryValidatorException in project teiid by teiid.
the class TestValidator method helpFailProcedure.
private void helpFailProcedure(String procedure, String userUpdateStr, Table.TriggerEvent procedureType) {
QueryMetadataInterface metadata = RealMetadataFactory.exampleUpdateProc(procedureType, procedure);
try {
validateProcedure(userUpdateStr, metadata);
fail("Expected failures for " + procedure);
} catch (QueryValidatorException e) {
} catch (TeiidException e) {
throw new RuntimeException(e);
}
}
Aggregations