Search in sources :

Example 1 with Type

use of com.yahoo.elide.modelconfig.model.Type in project elide by yahoo.

the class TableTypeTest method testJoinField.

@Test
void testJoinField() throws Exception {
    Table testTable1 = Table.builder().name("table1").join(Join.builder().definition("{{id }} = {{ table2.id}}").kind(Join.Kind.TOONE).type(Join.Type.INNER).name("join1").to("table2.dim2").build()).build();
    Table testTable2 = Table.builder().name("table2").dimension(Dimension.builder().name("dim2").type(Type.BOOLEAN).build()).build();
    TableType testType1 = new TableType(testTable1);
    TableType testType2 = new TableType(testTable2);
    Map<String, com.yahoo.elide.core.type.Type<?>> tables = new HashMap<>();
    tables.put("table1", testType1);
    tables.put("table2", testType2);
    testType1.resolveJoins(tables);
    Field field = testType1.getDeclaredField("join1");
    assertNotNull(field);
    com.yahoo.elide.datastores.aggregation.annotation.Join join = field.getAnnotation(com.yahoo.elide.datastores.aggregation.annotation.Join.class);
    assertEquals(INNER, join.type());
    assertEquals("{{id}} = {{table2.id}}", join.value());
}
Also used : Field(com.yahoo.elide.core.type.Field) EnumType(javax.persistence.EnumType) Type(com.yahoo.elide.modelconfig.model.Type) Table(com.yahoo.elide.modelconfig.model.Table) FromTable(com.yahoo.elide.datastores.aggregation.queryengines.sql.annotation.FromTable) HashMap(java.util.HashMap) Test(org.junit.jupiter.api.Test)

Aggregations

Field (com.yahoo.elide.core.type.Field)1 FromTable (com.yahoo.elide.datastores.aggregation.queryengines.sql.annotation.FromTable)1 Table (com.yahoo.elide.modelconfig.model.Table)1 Type (com.yahoo.elide.modelconfig.model.Type)1 HashMap (java.util.HashMap)1 EnumType (javax.persistence.EnumType)1 Test (org.junit.jupiter.api.Test)1