Search in sources :

Example 26 with ValidatorReport

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

the class TestMetadataValidator method testResolveTempMetadata.

@Test
public void testResolveTempMetadata() throws Exception {
    String ddl = "create virtual procedure proc1() RETURNS (e1 integer, e2 varchar(12)) AS begin create local temporary table x (e1 integer, e2 varchar); select * from x; end;" + "create view z (e1 integer, e2 varchar(12)) AS select x.* from (exec proc1()) as X, (exec proc1()) as Y; ";
    buildModel("vm1", false, this.vdb, this.store, ddl);
    buildTransformationMetadata();
    ValidatorReport report = new ValidatorReport();
    new MetadataValidator.ResolveQueryPlans().execute(vdb, store, report, new MetadataValidator());
    assertFalse(printError(report), report.hasItems());
}
Also used : ValidatorReport(org.teiid.query.validator.ValidatorReport) Test(org.junit.Test)

Example 27 with ValidatorReport

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

the class TestMetadataValidator method testFunctionProcedureValidation.

@Test
public void testFunctionProcedureValidation() throws Exception {
    buildModel("phy1", true, this.vdb, this.store, "CREATE VIRTUAL FUNCTION f1(VARIADIC x integer) RETURNS integer as return (select e1 from g1 where e2 = array_length(x));; create foreign table g1 (e1 string, e2 integer);");
    buildTransformationMetadata();
    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 28 with ValidatorReport

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

the class TestSystemSource method testValidate.

@Test
public void testValidate() {
    SystemSource source = new SystemSource();
    // $NON-NLS-1$
    ValidatorReport report = new ValidatorReport("Test Report");
    FunctionMetadataValidator.validateFunctionMethods(source.getFunctionMethods(), report);
    if (report.hasItems()) {
        // $NON-NLS-1$
        fail("Got validation errors while validating system functions: " + report);
    }
}
Also used : SystemSource(org.teiid.query.function.source.SystemSource) ValidatorReport(org.teiid.query.validator.ValidatorReport) Test(org.junit.Test)

Example 29 with ValidatorReport

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

the class RealMetadataFactory method fromDDL.

public static TransformationMetadata fromDDL(String vdbName, DDLHolder... schemas) throws Exception {
    CompositeMetadataStore cms = new CompositeMetadataStore(Collections.EMPTY_LIST);
    for (DDLHolder schema : schemas) {
        MetadataFactory mf = TestDDLParser.helpParse(schema.ddl, schema.name);
        cms.merge(mf.asMetadataStore());
    }
    TransformationMetadata tm = createTransformationMetadata(cms, vdbName);
    ValidatorReport report = new MetadataValidator().validate(tm.getVdbMetaData(), tm.getMetadataStore());
    if (report.hasItems()) {
        throw new RuntimeException(report.getFailureMessage());
    }
    return tm;
}
Also used : TransformationMetadata(org.teiid.query.metadata.TransformationMetadata) CompositeMetadataStore(org.teiid.query.metadata.CompositeMetadataStore) MetadataValidator(org.teiid.query.metadata.MetadataValidator) ValidatorReport(org.teiid.query.validator.ValidatorReport)

Example 30 with ValidatorReport

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

the class TestExcelMetadataProcessor method getDDL.

static String getDDL(Properties props, String filename) throws TranslatorException, ResourceException {
    ExcelExecutionFactory translator = new ExcelExecutionFactory();
    translator.start();
    String xlsName = props.getProperty("importer.excelFileName");
    MetadataFactory mf = new MetadataFactory("vdb", 1, "people", SystemMetadata.getInstance().getRuntimeTypeMap(), props, null);
    FileConnection connection = Mockito.mock(FileConnection.class);
    if (xlsName.contains("*.")) {
        Mockito.stub(connection.getFile(xlsName)).toReturn(UnitTestUtil.getTestDataFile(xlsName));
        File f = Mockito.mock(File.class);
        Mockito.stub(f.isDirectory()).toReturn(true);
        Mockito.stub(f.listFiles()).toReturn(new File[] { UnitTestUtil.getTestDataFile(filename) });
        Mockito.stub(connection.getFile(xlsName)).toReturn(f);
    } else {
        Mockito.stub(connection.getFile(xlsName)).toReturn(UnitTestUtil.getTestDataFile(xlsName));
    }
    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;
}
Also used : UDFSource(org.teiid.query.function.UDFSource) TransformationMetadata(org.teiid.query.metadata.TransformationMetadata) FunctionTree(org.teiid.query.function.FunctionTree) RealMetadataFactory(org.teiid.query.unittest.RealMetadataFactory) MetadataFactory(org.teiid.metadata.MetadataFactory) MetadataValidator(org.teiid.query.metadata.MetadataValidator) File(java.io.File) ValidatorReport(org.teiid.query.validator.ValidatorReport) FileConnection(org.teiid.translator.FileConnection)

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