use of com.mysql.cj.xdevapi.DatabaseObject in project aws-mysql-jdbc by awslabs.
the class SchemaTest method testListTables.
@Test
public void testListTables() {
String collName = "test_list_tables_collection";
String tableName = "test_list_tables_table";
String viewName = "test_list_tables_view";
try {
dropCollection(collName);
sqlUpdate("drop view if exists " + viewName);
sqlUpdate("drop table if exists " + tableName);
Collection coll = this.schema.createCollection(collName);
sqlUpdate("create table " + tableName + "(name varchar(32), age int, role int)");
sqlUpdate("create view " + viewName + " as select name, age from " + tableName);
Table table = this.schema.getTable(tableName);
Table view = this.schema.getTable(viewName);
List<DatabaseObject> tables = new ArrayList<>();
tables.addAll(this.schema.getTables());
assertFalse(tables.contains(coll));
assertTrue(tables.contains(table));
assertTrue(tables.contains(view));
tables = new ArrayList<>();
tables.addAll(this.schema.getTables("%tables_t%"));
assertFalse(tables.contains(coll));
assertTrue(tables.contains(table));
assertFalse(tables.contains(view));
} finally {
dropCollection(collName);
sqlUpdate("drop view if exists " + viewName);
sqlUpdate("drop table if exists " + tableName);
}
}
Aggregations