use of org.teiid.query.validator.ValidatorReport in project teiid by teiid.
the class TestMetadataValidator method testEmptyKey.
@Test
public void testEmptyKey() throws Exception {
String ddl = "CREATE FOREIGN TABLE G1(g1e1 integer, g1e2 varchar, PRIMARY KEY(g1e1, g1e2));";
buildModel("pm1", true, this.vdb, this.store, ddl);
buildTransformationMetadata();
this.store.getSchema("pm1").getTable("G1").getPrimaryKey().getColumns().clear();
ValidatorReport report = new ValidatorReport();
report = new MetadataValidator().validate(this.vdb, this.store);
assertTrue(printError(report), report.hasItems());
}
use of org.teiid.query.validator.ValidatorReport in project teiid by teiid.
the class TestMetadataValidator method testInternalMaterializationValidate.
@Test
public void testInternalMaterializationValidate() throws Exception {
// note here the unique here does not matter for non-existent reference columns, only primary key counted.
String ddl = "CREATE FOREIGN TABLE G1(e1 integer, e2 varchar);";
String ddl2 = "CREATE VIEW G2 OPTIONS (MATERIALIZED 'YES') 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);
assertFalse(printError(report), report.hasItems());
}
use of org.teiid.query.validator.ValidatorReport in project teiid by teiid.
the class TestMetadataValidator method testModelArtifactsSucess.
@Test
public void testModelArtifactsSucess() throws Exception {
buildModel("vm1", false, this.vdb, this.store, "create view g2(e1 integer, e2 varchar(12)) AS select * from foo;");
buildModel("pm1", true, this.vdb, this.store, "create foreign table g1(e1 integer, e2 varchar(12));");
ValidatorReport report = new ValidatorReport();
new MetadataValidator.SourceModelArtifacts().execute(vdb, store, report, new MetadataValidator());
assertFalse(printError(report), report.hasItems());
}
use of org.teiid.query.validator.ValidatorReport in project teiid by teiid.
the class TestMetadataValidator method testSourceModelArtifacts.
@Test
public void testSourceModelArtifacts() throws Exception {
String ddl = "create foreign table g1(e1 integer, e2 varchar(12)); create view g2(e1 integer, e2 varchar(12)) AS select * from foo;";
buildModel("pm1", true, this.vdb, this.store, ddl);
ValidatorReport report = new ValidatorReport();
new MetadataValidator.SourceModelArtifacts().execute(vdb, store, report, new MetadataValidator());
assertFalse(printError(report), report.hasItems());
}
use of org.teiid.query.validator.ValidatorReport in project teiid by teiid.
the class TestSimpleDBMetadataProcessor method getDDL.
static String getDDL(Properties props) throws TranslatorException {
SimpleDBExecutionFactory translator = new SimpleDBExecutionFactory();
translator.start();
MetadataFactory mf = new MetadataFactory("vdb", 1, "people", SystemMetadata.getInstance().getRuntimeTypeMap(), props, null);
SimpleDBConnection connection = Mockito.mock(SimpleDBConnection.class);
Mockito.stub(connection.getDomains()).toReturn(Arrays.asList("G1", "G2"));
HashSet<SimpleDBAttribute> cols = new HashSet<SimpleDBConnection.SimpleDBAttribute>();
cols.add(new SimpleDBAttribute("e1", false));
cols.add(new SimpleDBAttribute("e2", false));
Mockito.stub(connection.getAttributeNames("G1")).toReturn(cols);
HashSet<SimpleDBAttribute> cols2 = new HashSet<SimpleDBConnection.SimpleDBAttribute>();
cols2.add(new SimpleDBAttribute("e1", false));
cols2.add(new SimpleDBAttribute("e2", true));
Mockito.stub(connection.getAttributeNames("G2")).toReturn(cols2);
translator.getMetadata(mf, connection);
TransformationMetadata metadata = RealMetadataFactory.createTransformationMetadata(mf.asMetadataStore(), "vdb", new FunctionTree("foo", new UDFSource(translator.getPushDownFunctions())));
ValidatorReport report = new MetadataValidator().validate(metadata.getVdbMetaData(), metadata.getMetadataStore());
if (report.hasItems()) {
throw new RuntimeException(report.getFailureMessage());
}
String ddl = DDLStringVisitor.getDDLString(mf.getSchema(), null, null);
return ddl;
}
Aggregations