use of com.yahoo.elide.modelconfig.model.Table in project elide by yahoo.
the class TableTypeTest method testMultipleTimeDimensionGrains.
@Test
void testMultipleTimeDimensionGrains() throws Exception {
Table testTable = Table.builder().table("table1").name("Table").dimension(Dimension.builder().type(Type.TIME).definition("{{createdOn}}").name("createdOn").grain(Grain.builder().sql("some sql").type(Grain.GrainType.DAY).build()).grain(Grain.builder().sql("some other sql").type(Grain.GrainType.YEAR).build()).build()).build();
TableType testType = new TableType(testTable);
Field field = testType.getDeclaredField("createdOn");
assertNotNull(field);
Temporal temporal = field.getAnnotation(Temporal.class);
assertEquals("UTC", temporal.timeZone());
assertTrue(temporal.grains().length == 2);
assertEquals("some sql", temporal.grains()[0].expression());
assertEquals("some other sql", temporal.grains()[1].expression());
assertEquals(TimeGrain.DAY, temporal.grains()[0].grain());
assertEquals(TimeGrain.YEAR, temporal.grains()[1].grain());
}
use of com.yahoo.elide.modelconfig.model.Table in project elide by yahoo.
the class TableTypeTest method testEnumeratedDimension.
@Test
void testEnumeratedDimension() throws Exception {
Table testTable = Table.builder().table("table1").name("Table").dimension(Dimension.builder().name("dim1").type("ENUM_ORDINAL").values(Set.of("A", "B", "C")).build()).build();
TableType testType = new TableType(testTable);
Field field = testType.getDeclaredField("dim1");
assertNotNull(field);
Enumerated enumerated = field.getAnnotation(Enumerated.class);
assertNotNull(enumerated);
assertEquals(EnumType.ORDINAL, enumerated.value());
}
use of com.yahoo.elide.modelconfig.model.Table in project elide by yahoo.
the class TableTypeTest method testTimeDimensionAnnotations.
@Test
void testTimeDimensionAnnotations() throws Exception {
Set<String> tags = new HashSet<>(Arrays.asList("tag1", "tag2"));
Table testTable = Table.builder().table("table1").name("Table").dimension(Dimension.builder().type(Type.TIME).category("category1").definition("{{createdOn }}").hidden(false).friendlyName("Created On").name("createdOn").readAccess("Admin").description("A time dimension").tags(tags).build()).build();
TableType testType = new TableType(testTable);
Field field = testType.getDeclaredField("createdOn");
assertNotNull(field);
ReadPermission readPermission = field.getAnnotation(ReadPermission.class);
assertEquals("Admin", readPermission.expression());
ColumnMeta columnMeta = field.getAnnotation(ColumnMeta.class);
assertEquals("A time dimension", columnMeta.description());
assertEquals("category1", columnMeta.category());
assertEquals("Created On", columnMeta.friendlyName());
assertEquals(CardinalitySize.UNKNOWN, columnMeta.size());
assertEquals(tags, new HashSet<>(Arrays.asList(columnMeta.tags())));
DimensionFormula dimensionFormula = field.getAnnotation(DimensionFormula.class);
assertEquals("{{createdOn}}", dimensionFormula.value());
Temporal temporal = field.getAnnotation(Temporal.class);
assertEquals("UTC", temporal.timeZone());
assertTrue(temporal.grains().length == 0);
}
use of com.yahoo.elide.modelconfig.model.Table in project elide by yahoo.
the class TableTypeTest method testTableNameWithoutSchema.
@Test
void testTableNameWithoutSchema() throws Exception {
Table testTable = Table.builder().table("table1").name("Table").build();
TableType testType = new TableType(testTable);
FromTable fromTable = (FromTable) testType.getAnnotation(FromTable.class);
assertEquals("table1", fromTable.name());
}
use of com.yahoo.elide.modelconfig.model.Table in project elide by yahoo.
the class TableTypeTest method testHiddenMeasure.
@Test
void testHiddenMeasure() throws Exception {
Table testTable = Table.builder().table("table1").name("Table").measure(Measure.builder().name("measure1").type(Type.BOOLEAN).hidden(true).build()).build();
TableType testType = new TableType(testTable);
Field field = testType.getDeclaredField("measure1");
assertNotNull(field);
ColumnMeta columnMeta = field.getAnnotation(ColumnMeta.class);
assertNotNull(columnMeta);
assertTrue(columnMeta.isHidden());
}
Aggregations