Search in sources :

Example 96 with MetadataFactory

use of org.teiid.metadata.MetadataFactory in project teiid by teiid.

the class TestODataMetadataProcessor method testTeiidImplicitFk.

@Test
public void testTeiidImplicitFk() throws Exception {
    String file = "teiid-implicit.xml";
    String schema = "teiid";
    String schemaNamespace = "teiid5221data.1.data";
    MetadataFactory mf = createMetadata(file, schema, schemaNamespace);
    String metadataDDL = DDLStringVisitor.getDDLString(mf.getSchema(), null, null);
    assertEquals(ObjectConverterUtil.convertFileToString(UnitTestUtil.getTestDataFile("teiid-implicit.ddl")), metadataDDL);
}
Also used : RealMetadataFactory(org.teiid.query.unittest.RealMetadataFactory) MetadataFactory(org.teiid.metadata.MetadataFactory) Test(org.junit.Test)

Example 97 with MetadataFactory

use of org.teiid.metadata.MetadataFactory in project teiid by teiid.

the class TestODataMetadataProcessor method testFunction.

@Test
public void testFunction() throws Exception {
    CsdlReturnType returnType = new CsdlReturnType();
    returnType.setType("Edm.String");
    MetadataFactory mf = functionMetadata("invoke", returnType, null);
    Procedure p = mf.getSchema().getProcedure("invoke");
    assertNotNull(p);
    assertEquals(3, p.getParameters().size());
    assertNull(p.getResultSet());
    assertNotNull(getReturnParameter(p));
    ProcedureParameter pp = getReturnParameter(p);
    assertEquals("string", pp.getRuntimeType());
    ODataType type = ODataType.valueOf(p.getProperty(ODataMetadataProcessor.ODATA_TYPE, false));
    assertEquals(ODataType.FUNCTION, type);
}
Also used : ProcedureParameter(org.teiid.metadata.ProcedureParameter) RealMetadataFactory(org.teiid.query.unittest.RealMetadataFactory) MetadataFactory(org.teiid.metadata.MetadataFactory) ODataType(org.teiid.translator.odata4.ODataMetadataProcessor.ODataType) Procedure(org.teiid.metadata.Procedure) Test(org.junit.Test)

Example 98 with MetadataFactory

use of org.teiid.metadata.MetadataFactory in project teiid by teiid.

the class TestODataQueryExecution method testFunctionReturnsPrimitiveCollection.

@Test
public void testFunctionReturnsPrimitiveCollection() throws Exception {
    String query = "exec invoke(1, 'foo')";
    String expectedURL = "invoke?e1=1&e2='foo'";
    String response = "{\"value\": [\"returnX\", \"returnY\"]}";
    CsdlReturnType returnType = new CsdlReturnType();
    returnType.setType("Edm.String");
    returnType.setCollection(true);
    MetadataFactory mf = TestODataMetadataProcessor.functionMetadata("invoke", returnType, null);
    ProcedureExecution excution = helpProcedureExecute(mf, query, response, expectedURL, 200);
    assertArrayEquals(new Object[] { "returnX", "returnY" }, ((List) excution.getOutputParameterValues().get(0)).toArray());
}
Also used : MetadataFactory(org.teiid.metadata.MetadataFactory) ProcedureExecution(org.teiid.translator.ProcedureExecution) CsdlReturnType(org.apache.olingo.commons.api.edm.provider.CsdlReturnType) Test(org.junit.Test)

Example 99 with MetadataFactory

use of org.teiid.metadata.MetadataFactory in project teiid by teiid.

the class TestODataQueryExecution method testFunctionReturnsComplex.

@Test
public void testFunctionReturnsComplex() throws Exception {
    String query = "exec invoke(1, 'foo')";
    String expectedURL = "invoke?e1=1&e2='foo'";
    String response = "{\"value\":{\n" + "            \"street\":\"United States\",\n" + "            \"city\":\"Boise\",\n" + "            \"state\":\"ID\"\n" + "         }}";
    CsdlComplexType complex = TestODataMetadataProcessor.complexType("Address");
    CsdlReturnType returnType = new CsdlReturnType();
    returnType.setType("namespace.Address");
    MetadataFactory mf = TestODataMetadataProcessor.functionMetadata("invoke", returnType, complex);
    ProcedureExecution excution = helpProcedureExecute(mf, query, response, expectedURL, 200);
    assertArrayEquals(new Object[] { "United States", "Boise", "ID" }, excution.next().toArray(new Object[3]));
    assertNull(excution.next());
}
Also used : MetadataFactory(org.teiid.metadata.MetadataFactory) ProcedureExecution(org.teiid.translator.ProcedureExecution) CsdlComplexType(org.apache.olingo.commons.api.edm.provider.CsdlComplexType) CsdlReturnType(org.apache.olingo.commons.api.edm.provider.CsdlReturnType) Test(org.junit.Test)

Example 100 with MetadataFactory

use of org.teiid.metadata.MetadataFactory in project teiid by teiid.

the class TestODataQueryExecution method testFunctionReturnsPrimitiveEncoded.

@Test
public void testFunctionReturnsPrimitiveEncoded() throws Exception {
    String query = "exec invoke(1, 'foo bar')";
    String expectedURL = "invoke?e1=1&e2=%27foo%20bar%27";
    String response = "{\"value\":\"returnX\"}";
    CsdlReturnType returnType = new CsdlReturnType();
    returnType.setType("Edm.String");
    MetadataFactory mf = TestODataMetadataProcessor.functionMetadata("invoke", returnType, null);
    ProcedureExecution excution = helpProcedureExecute(mf, query, response, expectedURL, 200, false);
    assertArrayEquals(new Object[] { "returnX" }, excution.getOutputParameterValues().toArray(new Object[1]));
}
Also used : MetadataFactory(org.teiid.metadata.MetadataFactory) ProcedureExecution(org.teiid.translator.ProcedureExecution) CsdlReturnType(org.apache.olingo.commons.api.edm.provider.CsdlReturnType) Test(org.junit.Test)

Aggregations

MetadataFactory (org.teiid.metadata.MetadataFactory)159 Test (org.junit.Test)116 RealMetadataFactory (org.teiid.query.unittest.RealMetadataFactory)91 Properties (java.util.Properties)74 Table (org.teiid.metadata.Table)59 TransformationMetadata (org.teiid.query.metadata.TransformationMetadata)35 Procedure (org.teiid.metadata.Procedure)30 ModelMetaData (org.teiid.adminapi.impl.ModelMetaData)21 Column (org.teiid.metadata.Column)20 Connection (java.sql.Connection)18 FunctionTree (org.teiid.query.function.FunctionTree)15 UDFSource (org.teiid.query.function.UDFSource)14 CouchbaseMetadataProcessor (org.teiid.translator.couchbase.CouchbaseMetadataProcessor)14 Dimension (org.teiid.translator.couchbase.CouchbaseMetadataProcessor.Dimension)14 CouchbaseProperties (org.teiid.translator.couchbase.CouchbaseProperties)14 TranslationUtility (org.teiid.cdk.api.TranslationUtility)13 ValidatorReport (org.teiid.query.validator.ValidatorReport)13 XMLMetadata (org.apache.olingo.client.api.edm.xml.XMLMetadata)12 ClientCsdlXMLMetadata (org.apache.olingo.client.core.edm.ClientCsdlXMLMetadata)12 ForeignKey (org.teiid.metadata.ForeignKey)12