use of org.apache.ignite.internal.processors.query.h2.SchemaManager.SQL_TBL_COLS_VIEW in project ignite by apache.
the class JmxExporterSpiTest method testTableColumns.
/**
* @throws Exception If failed.
*/
@Test
public void testTableColumns() throws Exception {
String tableName = "TEST";
IgniteEx ignite = startGrid(getConfiguration().setCacheConfiguration(new CacheConfiguration<>(DEFAULT_CACHE_NAME).setQueryEntities(F.asList(new QueryEntity().setTableName(tableName).setKeyFieldName("ID").setValueType(Integer.class.getName()).addQueryField("ID", Integer.class.getName(), null)))));
Map<String, String> expTypes = new HashMap<>();
expTypes.put("_KEY", null);
expTypes.put("_VAL", null);
expTypes.put("ID", Integer.class.getName());
TabularDataSupport columns = (TabularDataSupport) metricRegistry(ignite.name(), VIEWS, SQL_TBL_COLS_VIEW).getAttribute(VIEWS);
columns.values().stream().map(data -> (CompositeData) data).filter(data -> tableName.equals(data.get("tableName"))).forEach(data -> {
String columnName = (String) data.get("columnName");
assertTrue("Unexpected column: " + columnName, expTypes.containsKey(columnName));
assertEquals(expTypes.remove(columnName), data.get("type"));
});
assertTrue("Expected columns: " + expTypes.keySet(), expTypes.isEmpty());
}
Aggregations