use of com.yahoo.elide.modelconfig.model.Table in project elide by yahoo.
the class TableArgumentValidatorTest method testArgumentValues.
@Test
public void testArgumentValues() {
Table mainTable = mainTableBuilder.argument(Argument.builder().name("testArg").type(Type.INTEGER).values(Sets.newHashSet("1", "2.5")).defaultValue("").build()).build();
Set<Table> tables = new HashSet<>();
tables.add(mainTable);
MetaDataStore metaDataStore = new MetaDataStore(DefaultClassScanner.getInstance(), tables, this.namespaceConfigs, true);
QueryPlanMerger merger = new DefaultQueryPlanMerger(metaDataStore);
Exception e = assertThrows(IllegalStateException.class, () -> new SQLQueryEngine(metaDataStore, connectionLookup, optimizers, merger, queryValidator));
assertEquals("Failed to verify table arguments for table: namespace_MainTable. Value: '2.5' for Argument 'testArg' with Type 'INTEGER' is invalid.", e.getMessage());
}
use of com.yahoo.elide.modelconfig.model.Table in project elide by yahoo.
the class TableTypeTest method testTableSQL.
@Test
void testTableSQL() throws Exception {
Table testTable = Table.builder().sql("SELECT * FROM FOO").name("Table").dbConnectionName("dbConn").build();
TableType testType = new TableType(testTable);
FromSubquery fromSubquery = (FromSubquery) testType.getAnnotation(FromSubquery.class);
assertEquals("SELECT * FROM FOO", fromSubquery.sql());
assertEquals("dbConn", fromSubquery.dbConnectionName());
}
use of com.yahoo.elide.modelconfig.model.Table in project elide by yahoo.
the class TableTypeTest method testGetAndSetField.
@Test
void testGetAndSetField() throws Exception {
Table testTable = Table.builder().dimension(Dimension.builder().name("dim1").type(Type.BOOLEAN).build()).build();
TableType testType = new TableType(testTable);
DynamicModelInstance testTypeInstance = testType.newInstance();
Field field = testType.getDeclaredField("dim1");
field.set(testTypeInstance, true);
assertTrue((Boolean) field.get(testTypeInstance));
field.set(testTypeInstance, false);
assertFalse((Boolean) field.get(testTypeInstance));
}
use of com.yahoo.elide.modelconfig.model.Table in project elide by yahoo.
the class TableTypeTest method testIdField.
@Test
void testIdField() throws Exception {
Table testTable = Table.builder().table("table1").name("Table").build();
TableType testType = new TableType(testTable);
assertTrue(testType.getFields().length == 1);
Field field = testType.getDeclaredField("id");
assertNotNull(field);
Id id = field.getAnnotation(Id.class);
assertNotNull(id);
}
use of com.yahoo.elide.modelconfig.model.Table in project elide by yahoo.
the class TableTypeTest method testHiddenTableAnnotations.
@Test
void testHiddenTableAnnotations() throws Exception {
Table testTable = Table.builder().cardinality("medium").description("A test table").friendlyName("foo").table("table1").name("Table").hidden(true).schema("db1").category("category1").build();
TableType testType = new TableType(testTable);
Include include = (Include) testType.getAnnotation(Include.class);
assertNotNull(include);
TableMeta tableMeta = (TableMeta) testType.getAnnotation(TableMeta.class);
assertNotNull(tableMeta);
assertTrue(tableMeta.isHidden());
}
Aggregations