use of com.yahoo.elide.core.dictionary.EntityDictionary in project elide by yahoo.
the class MatchesTemplateVisitorTest method setup.
@BeforeEach
public void setup() {
EntityDictionary dictionary = EntityDictionary.builder().build();
dictionary.bindEntity(PlayerStats.class);
dictionary.bindEntity(Player.class);
dictionary.addArgumentToAttribute(dictionary.getEntityClass("playerStats", EntityDictionary.NO_VERSION), "recordedDate", new ArgumentType("grain", ClassType.STRING_TYPE, TimeGrain.DAY));
dialect = RSQLFilterDialect.builder().dictionary(dictionary).addDefaultArguments(false).build();
}
use of com.yahoo.elide.core.dictionary.EntityDictionary in project elide by yahoo.
the class SplitFilterExpressionVisitorTest method setupEntityDictionary.
@BeforeAll
public static void setupEntityDictionary() {
EntityDictionary entityDictionary = EntityDictionary.builder().build();
entityDictionary.bindEntity(PlayerStats.class);
entityDictionary.bindEntity(Country.class);
entityDictionary.bindEntity(SubCountry.class);
entityDictionary.bindEntity(Player.class);
Namespace namespace = new Namespace(DEFAULT_NAMESPACE);
Table table = new SQLTable(namespace, ClassType.of(PlayerStats.class), entityDictionary);
splitFilterExpressionVisitor = new SplitFilterExpressionVisitor(table);
}
use of com.yahoo.elide.core.dictionary.EntityDictionary in project elide by yahoo.
the class JoinPathTest method init.
@BeforeAll
public static void init() {
Set<Type<?>> models = new HashSet<>();
models.add(ClassType.of(PlayerStats.class));
models.add(ClassType.of(CountryView.class));
models.add(ClassType.of(Country.class));
models.add(ClassType.of(SubCountry.class));
models.add(ClassType.of(Player.class));
models.add(ClassType.of(PlayerRanking.class));
models.add(ClassType.of(CountryViewNested.class));
models.add(ClassType.of(PlayerStatsWithView.class));
EntityDictionary dictionary = EntityDictionary.builder().build();
models.stream().forEach(dictionary::bindEntity);
store = new MetaDataStore(dictionary.getScanner(), models, true);
store.populateEntityDictionary(dictionary);
DataSource mockDataSource = mock(DataSource.class);
// The query engine populates the metadata store with actual tables.
new SQLQueryEngine(store, (unused) -> new ConnectionDetails(mockDataSource, SQLDialectFactory.getDefaultDialect()));
}
use of com.yahoo.elide.core.dictionary.EntityDictionary in project elide by yahoo.
the class ElideStandaloneConfigStoreTest method init.
@BeforeAll
public void init() throws Exception {
configRoot = Files.createTempDirectory("test");
settings = new ElideStandaloneTestSettings() {
@Override
public EntityDictionary getEntityDictionary(ServiceLocator injector, ClassScanner scanner, Optional<DynamicConfiguration> dynamicConfiguration, Set<Type<?>> entitiesToExclude) {
Map<String, Class<? extends Check>> checks = new HashMap<>();
if (getAnalyticProperties().enableDynamicModelConfigAPI()) {
checks.put(ConfigChecks.CAN_CREATE_CONFIG, ConfigChecks.CanCreate.class);
checks.put(ConfigChecks.CAN_READ_CONFIG, ConfigChecks.CanRead.class);
checks.put(ConfigChecks.CAN_DELETE_CONFIG, ConfigChecks.CanDelete.class);
checks.put(ConfigChecks.CAN_UPDATE_CONFIG, ConfigChecks.CanNotUpdate.class);
}
EntityDictionary dictionary = new EntityDictionary(// Checks
checks, // Role Checks
new HashMap<>(), new Injector() {
@Override
public void inject(Object entity) {
injector.inject(entity);
}
@Override
public <T> T instantiate(Class<T> cls) {
return injector.create(cls);
}
}, // Serde Lookup
CoerceUtil::lookup, entitiesToExclude, scanner);
dynamicConfiguration.map(DynamicConfiguration::getRoles).orElseGet(Collections::emptySet).forEach(role -> dictionary.addRoleCheck(role, new Role.RoleMemberCheck(role)));
return dictionary;
}
@Override
public ElideStandaloneAnalyticSettings getAnalyticProperties() {
return new ElideStandaloneAnalyticSettings() {
@Override
public boolean enableDynamicModelConfig() {
return true;
}
@Override
public boolean enableDynamicModelConfigAPI() {
return true;
}
@Override
public String getDynamicConfigPath() {
return configRoot.toFile().getAbsolutePath();
}
@Override
public boolean enableAggregationDataStore() {
return true;
}
@Override
public boolean enableMetaDataStore() {
return true;
}
};
}
};
elide = new ElideStandalone(settings);
elide.start(false);
}
use of com.yahoo.elide.core.dictionary.EntityDictionary in project elide by yahoo.
the class SwaggerBuilderTest method testSortParameter.
@Test
public void testSortParameter() {
@Entity
@Include
class NothingToSort {
@Id
long name;
}
EntityDictionary entityDictionary = EntityDictionary.builder().build();
entityDictionary.bindEntity(NothingToSort.class);
Info info = new Info().title("Test Service").version(NO_VERSION);
SwaggerBuilder builder = new SwaggerBuilder(entityDictionary, info);
Swagger testSwagger = builder.build();
List<Parameter> params = testSwagger.getPaths().get("/nothingToSort").getGet().getParameters();
QueryParameter sortParam = (QueryParameter) params.stream().filter((param) -> param.getName().equals("sort")).findFirst().get();
assertEquals("query", sortParam.getIn());
List<String> sortValues = Arrays.asList("id", "-id");
assertEquals(sortValues, ((StringProperty) sortParam.getItems()).getEnum());
}
Aggregations