use of com.yahoo.elide.modelconfig.model.NamespaceConfig in project elide by yahoo.
the class QueryKeyExtractorTest method testDuplicateFullQuery.
@Test
public void testDuplicateFullQuery() throws Exception {
// Build 1st Table
NamespaceConfig testNamespace = NamespaceConfig.builder().name("namespace1").build();
NamespacePackage testNamespacePackage = new NamespacePackage(testNamespace);
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").namespace("namespace1").dimension(Dimension.builder().name("dim1").definition("{{dim1}}").type(Type.BOOLEAN).values(Collections.EMPTY_SET).tags(Collections.EMPTY_SET).build()).build();
TableType testType = new TableType(testTable, testNamespacePackage);
dictionary.bindEntity(testType);
SQLTable testSqlTable = new SQLTable(new Namespace(testNamespacePackage), testType, dictionary);
// Build 2nd Table
NamespaceConfig anotherTestNamespace = NamespaceConfig.builder().name("namespace2").build();
NamespacePackage anotherTestNamespacePackage = new NamespacePackage(anotherTestNamespace);
Table anotherTestTable = // Exactly same as testTable but different namespace
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").namespace("namespace2").dimension(Dimension.builder().name("dim1").definition("{{dim1}}").type(Type.BOOLEAN).values(Collections.EMPTY_SET).tags(Collections.EMPTY_SET).build()).build();
TableType anotherTestType = new TableType(anotherTestTable, anotherTestNamespacePackage);
dictionary.bindEntity(anotherTestType);
SQLTable anotherTestSqlTable = new SQLTable(new Namespace(anotherTestNamespacePackage), anotherTestType, dictionary);
// Build Query and Test
Query query = Query.builder().source(testSqlTable).dimensionProjection(testSqlTable.getDimensionProjection("dim1")).pagination(new ImmutablePagination(0, 2, false, true)).build();
assertEquals(// table name
"namespace1_Table;" + // metrics
"{}" + // Group by
"{dim1;{}}" + // time dimensions
"{}" + // where
";" + // having
";" + // sort
";" + // pagination
"{0;2;1;}", QueryKeyExtractor.extractKey(query));
Query anotherQuery = Query.builder().source(anotherTestSqlTable).dimensionProjection(anotherTestSqlTable.getDimensionProjection("dim1")).pagination(new ImmutablePagination(0, 2, false, true)).build();
assertEquals(// table name
"namespace2_Table;" + // metrics
"{}" + // Group by
"{dim1;{}}" + // time dimensions
"{}" + // where
";" + // having
";" + // sort
";" + // pagination
"{0;2;1;}", QueryKeyExtractor.extractKey(anotherQuery));
assertNotEquals(QueryKeyExtractor.extractKey(anotherQuery), QueryKeyExtractor.extractKey(query));
}
use of com.yahoo.elide.modelconfig.model.NamespaceConfig in project elide by yahoo.
the class NamespacePackageTest method testAnnotations.
@Test
void testAnnotations() throws Exception {
NamespaceConfig testNamespace = NamespaceConfig.builder().description("A test Namespace").name("Test").build();
NamespacePackage namespace = new NamespacePackage(testNamespace);
ReadPermission readPermission = namespace.getDeclaredAnnotation(ReadPermission.class);
assertEquals("Prefab.Role.All", readPermission.expression());
Include meta = namespace.getDeclaredAnnotation(Include.class);
assertEquals("A test Namespace", meta.description());
assertNull(meta.friendlyName());
ApiVersion apiVersion = namespace.getDeclaredAnnotation(ApiVersion.class);
assertEquals("", apiVersion.version());
}
use of com.yahoo.elide.modelconfig.model.NamespaceConfig in project elide by yahoo.
the class DynamicConfigValidator method validateNamespaceConfig.
/**
* Validate namespace configs.
* @return boolean true if all provided namespace properties passes validation
*/
private boolean validateNamespaceConfig() {
Set<String> extractedChecks = new HashSet<>();
PermissionExpressionVisitor visitor = new PermissionExpressionVisitor();
for (NamespaceConfig namespace : elideNamespaceConfig.getNamespaceconfigs()) {
extractChecksFromExpr(namespace.getReadAccess(), extractedChecks, visitor);
}
validateChecks(extractedChecks, Collections.EMPTY_SET);
return true;
}
use of com.yahoo.elide.modelconfig.model.NamespaceConfig in project elide by yahoo.
the class NamespacePackageTest method testGet.
@Test
void testGet() throws Exception {
NamespaceConfig testNamespace = NamespaceConfig.builder().description("A test Namespace").name("Test").build();
NamespacePackage namespace = new NamespacePackage(testNamespace);
assertEquals("Test", namespace.getName());
}
Aggregations