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());
}
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());
}
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));
}
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"));
}
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());
}
Aggregations