Search in sources :

Example 21 with ValidatorReport

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());
}
Also used : ValidatorReport(org.teiid.query.validator.ValidatorReport) Test(org.junit.Test)

Example 22 with ValidatorReport

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());
}
Also used : ValidatorReport(org.teiid.query.validator.ValidatorReport) Test(org.junit.Test)

Example 23 with ValidatorReport

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());
}
Also used : Table(org.teiid.metadata.Table) MetadataFactory(org.teiid.metadata.MetadataFactory) Properties(java.util.Properties) ValidatorReport(org.teiid.query.validator.ValidatorReport) ModelMetaData(org.teiid.adminapi.impl.ModelMetaData) Test(org.junit.Test)

Example 24 with ValidatorReport

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;
}
Also used : ValidatorReport(org.teiid.query.validator.ValidatorReport)

Example 25 with ValidatorReport

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());
}
Also used : ValidatorReport(org.teiid.query.validator.ValidatorReport) Test(org.junit.Test)

Aggregations

ValidatorReport (org.teiid.query.validator.ValidatorReport)70 Test (org.junit.Test)40 MetadataValidator (org.teiid.query.metadata.MetadataValidator)20 TransformationMetadata (org.teiid.query.metadata.TransformationMetadata)16 MetadataFactory (org.teiid.metadata.MetadataFactory)13 RealMetadataFactory (org.teiid.query.unittest.RealMetadataFactory)12 UDFSource (org.teiid.query.function.UDFSource)11 ModelMetaData (org.teiid.adminapi.impl.ModelMetaData)10 FunctionTree (org.teiid.query.function.FunctionTree)10 Command (org.teiid.query.sql.lang.Command)8 ValidatorFailure (org.teiid.query.validator.ValidatorFailure)6 QueryParser (org.teiid.query.parser.QueryParser)5 GroupSymbol (org.teiid.query.sql.symbol.GroupSymbol)5 FileReader (java.io.FileReader)4 Properties (java.util.Properties)4 EdmxFormatParser (org.odata4j.format.xml.EdmxFormatParser)4 VDBMetaData (org.teiid.adminapi.impl.VDBMetaData)4 TranslationUtility (org.teiid.cdk.api.TranslationUtility)4 MetadataException (org.teiid.metadata.MetadataException)4 Table (org.teiid.metadata.Table)4