use of com.yahoo.elide.modelconfig.model.Table in project elide by yahoo.
the class TableTypeTest method testInvalidResolver.
@Test
void testInvalidResolver() throws Exception {
Table testTable = Table.builder().table("table1").name("Table").measure(Measure.builder().name("measure1").type(Type.BOOLEAN).maker("does.not.exist.class").build()).build();
TableType testType = new TableType(testTable);
Field field = testType.getDeclaredField("measure1");
MetricFormula metricFormula = field.getAnnotation(MetricFormula.class);
assertThrows(IllegalStateException.class, () -> metricFormula.maker());
}
use of com.yahoo.elide.modelconfig.model.Table in project elide by yahoo.
the class TableTypeTest method testDimensionAnnotations.
@Test
void testDimensionAnnotations() throws Exception {
Set<String> tags = new HashSet<>(Arrays.asList("tag1", "tag2"));
Table testTable = Table.builder().table("table1").name("Table").dimension(Dimension.builder().type(Type.TEXT).category("category1").definition("{{region}}").hidden(false).friendlyName("Region").name("region").readAccess("Admin").description("A dimension").tags(tags).cardinality("small").tableSource(TableSource.builder().table("region").column("id").build()).build()).build();
TableType testType = new TableType(testTable);
Field field = testType.getDeclaredField("region");
assertNotNull(field);
ReadPermission readPermission = field.getAnnotation(ReadPermission.class);
assertEquals("Admin", readPermission.expression());
ColumnMeta columnMeta = field.getAnnotation(ColumnMeta.class);
assertEquals("A dimension", columnMeta.description());
assertEquals("category1", columnMeta.category());
assertEquals("Region", columnMeta.friendlyName());
assertEquals(CardinalitySize.SMALL, columnMeta.size());
assertEquals(tags, new HashSet<>(Arrays.asList(columnMeta.tags())));
DimensionFormula dimensionFormula = field.getAnnotation(DimensionFormula.class);
assertEquals("{{region}}", dimensionFormula.value());
}
use of com.yahoo.elide.modelconfig.model.Table in project elide by yahoo.
the class TableTypeTest method testTableAnnotations.
@Test
void testTableAnnotations() throws Exception {
Set<String> tags = new HashSet<>(Arrays.asList("tag1", "tag2"));
Set<String> hints = new HashSet<>(Arrays.asList("hint1", "hint2"));
Table testTable = Table.builder().cardinality("medium").description("A test table").friendlyName("foo").table("table1").name("Table").schema("db1").category("category1").readAccess("Admin").dbConnectionName("dbConn").isFact(true).filterTemplate("a==b").tags(tags).hints(hints).build();
TableType testType = new TableType(testTable);
Include include = (Include) testType.getAnnotation(Include.class);
assertEquals("Table", include.name());
FromTable fromTable = (FromTable) testType.getAnnotation(FromTable.class);
assertEquals("db1.table1", fromTable.name());
assertEquals("dbConn", fromTable.dbConnectionName());
TableMeta tableMeta = (TableMeta) testType.getAnnotation(TableMeta.class);
assertEquals("foo", tableMeta.friendlyName());
assertEquals(CardinalitySize.MEDIUM, tableMeta.size());
assertEquals("A test table", tableMeta.description());
assertEquals("category1", tableMeta.category());
assertTrue(tableMeta.isFact());
assertEquals(tags, new HashSet<>(Arrays.asList(tableMeta.tags())));
assertEquals(hints, new HashSet<>(Arrays.asList(tableMeta.hints())));
assertEquals("a==b", tableMeta.filterTemplate());
ReadPermission readPermission = (ReadPermission) testType.getAnnotation(ReadPermission.class);
assertEquals("Admin", readPermission.expression());
}
Aggregations