Search in sources :

Example 71 with MetadataFactory

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

the class TestSwaggerMetadataProcessor method testEndpointAsName.

@Test
public void testEndpointAsName() throws Exception {
    SwaggerExecutionFactory translator = new SwaggerExecutionFactory();
    translator.start();
    MetadataFactory mf = getMetadata(translator, UnitTestUtil.getTestDataPath() + "/fahrplan-swagger.json");
    Procedure p = mf.getSchema().getProcedure("arrivalBoard/id");
    assertNotNull(p);
    assertEquals("GET", p.getProperty(RestMetadataExtension.METHOD, false).toUpperCase());
    assertEquals("http://api.deutschebahn.com/freeplan/v1/arrivalBoard/{id}", p.getProperty(RestMetadataExtension.URI, false));
    assertNotNull(p.getResultSet());
}
Also used : RealMetadataFactory(org.teiid.query.unittest.RealMetadataFactory) MetadataFactory(org.teiid.metadata.MetadataFactory) Procedure(org.teiid.metadata.Procedure) Test(org.junit.Test)

Example 72 with MetadataFactory

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

the class TestSwaggerMetadataProcessor method testReftoResponse.

@Test
public void testReftoResponse() throws TranslatorException {
    SwaggerExecutionFactory translator = new SwaggerExecutionFactory();
    translator.start();
    MetadataFactory mf = petstoreMetadata(translator);
    Procedure p = mf.getSchema().getProcedure("findPetsByTags");
    assertNotNull(p);
    assertEquals("GET", p.getProperty(RestMetadataExtension.METHOD, false).toUpperCase());
    assertEquals("http://petstore.swagger.io/v2/pet/findByTags", p.getProperty(RestMetadataExtension.URI, false));
    assertNotNull(p.getResultSet());
    List<Column> columns = p.getResultSet().getColumns();
    assertEquals(8, columns.size());
    Column pa = p.getResultSet().getColumnByName("id");
    assertNull(pa.getNameInSource());
    pa = p.getResultSet().getColumnByName("category_id");
    assertEquals("category/id", pa.getNameInSource());
    pa = p.getResultSet().getColumnByName("tags_Tag_id");
    assertEquals("tags[]/Tag/id", pa.getNameInSource());
}
Also used : RealMetadataFactory(org.teiid.query.unittest.RealMetadataFactory) MetadataFactory(org.teiid.metadata.MetadataFactory) Column(org.teiid.metadata.Column) Procedure(org.teiid.metadata.Procedure) Test(org.junit.Test)

Example 73 with MetadataFactory

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

the class TestSwaggerMetadataProcessor method testSchema.

@Test
public void testSchema() throws Exception {
    SwaggerExecutionFactory translator = new SwaggerExecutionFactory();
    translator.start();
    MetadataFactory mf = swaggerMetadata(translator);
    // TransformationMetadata metadata = getTransformationMetadata(mf, translator);
    String ddl = DDLStringVisitor.getDDLString(mf.getSchema(), null, null);
    // System.out.println(ddl);
    MetadataFactory mf2 = new MetadataFactory("vdb", 1, "x", SystemMetadata.getInstance().getRuntimeTypeMap(), new Properties(), null);
    QueryParser.getQueryParser().parseDDL(mf2, ddl);
    Set<String> procSet = new HashSet<String>();
    for (Procedure p : mf.getSchema().getProcedures().values()) {
        procSet.add(p.getName());
    }
    assertEquals(29, procSet.size());
    assertTrue(procSet.contains("addCustomer"));
    assertTrue(procSet.contains("addOneCustomer"));
    assertTrue(procSet.contains("addCustomerList"));
    assertTrue(procSet.contains("getCustomers"));
    assertTrue(procSet.contains("getCustomerList"));
    assertTrue(procSet.contains("getCustomerByCity"));
    assertTrue(procSet.contains("getCustomerByCountry"));
    assertTrue(procSet.contains("getCustomerByName"));
    assertTrue(procSet.contains("getCustomerByNumber"));
    assertTrue(procSet.contains("getByNumCityCountry"));
    assertTrue(procSet.contains("size"));
    assertTrue(procSet.contains("removeCustomer"));
    assertTrue(procSet.contains("removeCustomerByCity"));
    assertTrue(procSet.contains("removeCustomerByCountry"));
    assertTrue(procSet.contains("removeCustomerByName"));
    assertTrue(procSet.contains("removeCustomerByNumber"));
    assertTrue(procSet.contains("removeCustomerByNumCityCountry"));
    assertTrue(procSet.contains("updateCustomer"));
    assertTrue(procSet.contains("updateCustomerByCity"));
    assertTrue(procSet.contains("updateCustomerByCountry"));
    assertTrue(procSet.contains("updateCustomerByName"));
    assertTrue(procSet.contains("updateCustomerByNumber"));
    assertTrue(procSet.contains("updateCustomerByNumCityCountry"));
    // test preferences
    Procedure p = mf.getSchema().getProcedures().get("updateCustomer");
    assertEquals("application/json", p.getProperty(RestMetadataExtension.PRODUCES, false));
}
Also used : RealMetadataFactory(org.teiid.query.unittest.RealMetadataFactory) MetadataFactory(org.teiid.metadata.MetadataFactory) Procedure(org.teiid.metadata.Procedure) Properties(java.util.Properties) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 74 with MetadataFactory

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

the class TestSwaggerMetadataProcessor method testOnetoOneEmbeddedReturn.

@Test
public void testOnetoOneEmbeddedReturn() throws TranslatorException {
    SwaggerExecutionFactory translator = new SwaggerExecutionFactory();
    translator.start();
    MetadataFactory mf = swaggerMetadata(translator);
    Procedure p = mf.getSchema().getProcedure("size");
    assertNotNull(p);
    assertEquals("GET", p.getProperty(RestMetadataExtension.METHOD, false).toUpperCase());
    assertEquals("http://localhost:8080/customer/status", p.getProperty(RestMetadataExtension.URI, false));
    assertNotNull(p.getResultSet());
    ColumnSet<Procedure> results = p.getResultSet();
    assertNotNull(results.getColumnByName("size"));
    assertNotNull(results.getColumnByName("heap_maxMemory"));
    assertNotNull(results.getColumnByName("heap_freeMemory"));
}
Also used : RealMetadataFactory(org.teiid.query.unittest.RealMetadataFactory) MetadataFactory(org.teiid.metadata.MetadataFactory) Procedure(org.teiid.metadata.Procedure) Test(org.junit.Test)

Example 75 with MetadataFactory

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

the class TestSwaggerMetadataProcessor method testObjectArrayTypes.

@Test
public void testObjectArrayTypes() throws Exception {
    SwaggerExecutionFactory translator = new SwaggerExecutionFactory();
    translator.start();
    MetadataFactory mf = getMetadata(translator, UnitTestUtil.getTestDataPath() + "/doubleclick-swagger.json");
    Procedure p = mf.getSchema().getProcedure("doubleclicksearch.reports.request");
    ProcedureParameter param = p.getParameterByName("filters_values");
    assertEquals("string[]", param.getRuntimeType());
}
Also used : ProcedureParameter(org.teiid.metadata.ProcedureParameter) RealMetadataFactory(org.teiid.query.unittest.RealMetadataFactory) MetadataFactory(org.teiid.metadata.MetadataFactory) Procedure(org.teiid.metadata.Procedure) 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