use of org.teiid.query.validator.ValidatorReport in project teiid by teiid.
the class TestMetadataValidator method testCrossReferenceFKFromUniqueKey.
@Test
public void testCrossReferenceFKFromUniqueKey() throws Exception {
String ddl = "CREATE FOREIGN TABLE G1(g1e1 integer, g1e2 varchar, UNIQUE(g1e2));";
String ddl2 = "CREATE FOREIGN TABLE G2(g2e1 integer, g2e2 varchar, FOREIGN KEY (g2e2) REFERENCES pm1.G1(g1e2))";
buildModel("pm1", true, this.vdb, this.store, ddl);
buildModel("pm2", true, this.vdb, this.store, ddl2);
buildTransformationMetadata();
ValidatorReport report = new ValidatorReport();
report = new MetadataValidator().validate(this.vdb, this.store);
assertFalse(printError(report), report.hasItems());
assertNotNull(this.store.getSchema("pm2").getTable("G2").getForeignKeys().get(0).getReferenceKey());
assertEquals(1, this.store.getSchema("pm2").getTable("G2").getForeignKeys().get(0).getReferenceKey().getColumns().size());
assertEquals("g1e2", this.store.getSchema("pm2").getTable("G2").getForeignKeys().get(0).getReferenceKey().getColumns().get(0).getName());
}
use of org.teiid.query.validator.ValidatorReport in project teiid by teiid.
the class TestMetadataValidator method testAfterTrigger.
@Test
public void testAfterTrigger() throws Exception {
String ddl = "CREATE FOREIGN TABLE T ( e1 integer, e2 varchar);" + "CREATE TRIGGER tr ON T AFTER UPDATE AS " + "FOR EACH ROW \n" + "BEGIN ATOMIC \n" + "if (\"new\" is not distinct from \"old\") raise sqlexception 'error';\n" + "END;";
buildModel("phy1", true, this.vdb, this.store, ddl);
buildTransformationMetadata();
ValidatorReport report = new MetadataValidator().validate(this.vdb, this.store);
assertFalse(printError(report), report.hasItems());
}
use of org.teiid.query.validator.ValidatorReport in project teiid by teiid.
the class TestMetadataValidator method testSkipDocumentModel.
@Test
public void testSkipDocumentModel() throws Exception {
ModelMetaData model = new ModelMetaData();
model.setName("xmlstuff");
model.setModelType(Model.Type.VIRTUAL);
vdb.addModel(model);
MetadataFactory mf = new MetadataFactory("myVDB", 1, "xmlstuff", TestDDLParser.getDataTypes(), new Properties(), null);
mf.getSchema().setPhysical(false);
Table t = mf.addTable("xmldoctable");
t.setTableType(Table.Type.Document);
mf.addColumn("c1", "string", t);
t.setSelectTransformation("some dummy stuff, should not be validated");
t.setVirtual(true);
Table t2 = mf.addTable("xmldoctable2");
t2.setTableType(Table.Type.XmlMappingClass);
mf.addColumn("c1", "string", t2);
t2.setSelectTransformation("some dummy stuff, should not be validated");
t2.setVirtual(true);
mf.mergeInto(store);
buildTransformationMetadata();
ValidatorReport report = new MetadataValidator().validate(this.vdb, this.store);
assertFalse(printError(report), report.hasItems());
}
use of org.teiid.query.validator.ValidatorReport in project teiid by teiid.
the class TestMetadataValidator method helpTest.
private ValidatorReport helpTest(String ddl, boolean expectErrors) throws Exception {
buildModel("pm1", true, this.vdb, this.store, ddl);
buildTransformationMetadata();
ValidatorReport report = new ValidatorReport();
report = new MetadataValidator().validate(this.vdb, this.store);
if (expectErrors) {
assertTrue(printError(report), report.hasItems());
} else {
assertFalse(printError(report), report.hasItems());
}
return report;
}
use of org.teiid.query.validator.ValidatorReport in project teiid by teiid.
the class TestMetadataValidator method testExternalMaterializationValidateMissingColumns.
@Test
public void testExternalMaterializationValidateMissingColumns() throws Exception {
String ddl = "CREATE FOREIGN TABLE G1(e1 integer, e2 varchar); CREATE FOREIGN TABLE status(e1 integer, e2 varchar);";
String ddl2 = "CREATE VIEW G2 OPTIONS (MATERIALIZED 'true', MATERIALIZED_TABLE 'pm1.G1', \"teiid_rel:MATVIEW_STATUS_TABLE\" 'status') AS SELECT * FROM pm1.G1";
buildModel("pm1", true, this.vdb, this.store, ddl);
buildModel("vm1", false, this.vdb, this.store, ddl2);
buildTransformationMetadata();
ValidatorReport report = new ValidatorReport();
report = new MetadataValidator().validate(this.vdb, this.store);
assertTrue(printError(report), report.hasItems());
}
Aggregations