Search in sources :

Example 11 with ValidatorReport

use of org.teiid.query.validator.ValidatorReport in project teiid by teiid.

the class TestMetadataValidator method testCrossReferenceFKNoPKonRefTable.

@Test
public void testCrossReferenceFKNoPKonRefTable() 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(g1e1 integer, g1e2 varchar, UNIQUE(g1e1, g1e2));";
    String ddl2 = "CREATE FOREIGN TABLE G2( g2e1 integer, g2e2 varchar, PRIMARY KEY(g2e1, g2e2), FOREIGN KEY (g2e1, g2e2) REFERENCES pm1.G1)";
    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);
    assertTrue(printError(report), report.hasItems());
}
Also used : ValidatorReport(org.teiid.query.validator.ValidatorReport) Test(org.junit.Test)

Example 12 with ValidatorReport

use of org.teiid.query.validator.ValidatorReport in project teiid by teiid.

the class TestMetadataValidator method testProcWithOutOfOrderReturn.

@Test(expected = ParseException.class)
public void testProcWithOutOfOrderReturn() throws Exception {
    String ddl = "create foreign procedure x (out param1 string, out param2 string result); ";
    buildModel("pm1", true, this.vdb, this.store, ddl);
    buildTransformationMetadata();
    ValidatorReport report = new MetadataValidator().validate(vdb, store);
    assertTrue(printError(report), report.hasItems());
}
Also used : ValidatorReport(org.teiid.query.validator.ValidatorReport) Test(org.junit.Test)

Example 13 with ValidatorReport

use of org.teiid.query.validator.ValidatorReport in project teiid by teiid.

the class TestMetadataValidator method testResolveMetadataError.

@Test
public void testResolveMetadataError() throws Exception {
    buildModel("vm1", false, this.vdb, this.store, "create view g1 (e1 integer, e2 varchar(12)) AS select * from pm1.g1; create view g2 AS select * from pm1.g1;");
    buildTransformationMetadata();
    ValidatorReport report = new ValidatorReport();
    new MetadataValidator.ResolveQueryPlans().execute(vdb, store, report, new MetadataValidator());
    assertTrue(printError(report), report.hasItems());
}
Also used : ValidatorReport(org.teiid.query.validator.ValidatorReport) Test(org.junit.Test)

Example 14 with ValidatorReport

use of org.teiid.query.validator.ValidatorReport in project teiid by teiid.

the class TestMetadataValidator method testProcWithMultipleReturn.

@Test(expected = ParseException.class)
public void testProcWithMultipleReturn() throws Exception {
    String ddl = "create foreign procedure x (out param1 string result, out param2 string result); ";
    buildModel("pm1", true, this.vdb, this.store, ddl);
    buildTransformationMetadata();
    ValidatorReport report = new MetadataValidator().validate(vdb, store);
    assertTrue(printError(report), report.hasItems());
}
Also used : ValidatorReport(org.teiid.query.validator.ValidatorReport) Test(org.junit.Test)

Example 15 with ValidatorReport

use of org.teiid.query.validator.ValidatorReport in project teiid by teiid.

the class TestMetadataValidator method testCrossReferenceFK.

@Test
public void testCrossReferenceFK() throws Exception {
    String ddl = "CREATE FOREIGN TABLE G1(g1e1 integer, g1e2 varchar, PRIMARY KEY(g1e1, g1e2));";
    String ddl2 = "CREATE FOREIGN TABLE G2( g2e1 integer, g2e2 varchar, PRIMARY KEY(g2e1, g2e2), FOREIGN KEY (g2e1, g2e2) REFERENCES pm1.G1(g1e1, 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(2, this.store.getSchema("pm2").getTable("G2").getForeignKeys().get(0).getReferenceKey().getColumns().size());
    assertEquals("g1e1", 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)

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