use of com.yahoo.elide.modelconfig.validator.DynamicConfigValidator in project elide by yahoo.
the class TemplateConfigValidator method rebuildMetaDataStore.
// Rebuilds the MetaDataStore for each validation so that we can validate templates.
MetaDataStore rebuildMetaDataStore(Map<String, ConfigFile> resourceMap) {
DynamicConfigValidator validator = new DynamicConfigValidator(scanner, configRoot);
validator.validate(resourceMap);
MetaDataStore metaDataStore = new MetaDataStore(scanner, validator.getTables(), validator.getNamespaceConfigurations(), false);
// Populates the metadata store with SQL tables.
new SQLQueryEngine(metaDataStore, (unused) -> null, new HashSet<>(), new DefaultQueryPlanMerger(metaDataStore), new DefaultQueryValidator(metaDataStore.getMetadataDictionary()));
return metaDataStore;
}
use of com.yahoo.elide.modelconfig.validator.DynamicConfigValidator in project elide by yahoo.
the class HandlebarsHydratorTest method setup.
@BeforeAll
public void setup() throws IOException {
hydrator = new HandlebarsHydrator();
testClass = new DynamicConfigValidator(DefaultClassScanner.getInstance(), CONFIG_PATH);
testClass.readConfigs();
}
use of com.yahoo.elide.modelconfig.validator.DynamicConfigValidator in project elide by yahoo.
the class ConfigDataStoreTest method testUpdate.
@Test
public void testUpdate(@TempDir Path configPath) {
String configRoot = configPath.toFile().getPath();
Validator validator = new DynamicConfigValidator(DefaultClassScanner.getInstance(), configRoot);
ConfigDataStore store = new ConfigDataStore(configRoot, validator);
createFile("test", store, false);
ConfigFile updateFile = updateFile(configRoot, store);
ConfigDataStoreTransaction readTx = store.beginReadTransaction();
RequestScope scope = mock(RequestScope.class);
ConfigFile loaded = readTx.loadObject(EntityProjection.builder().type(ClassType.of(ConfigFile.class)).build(), toId("models/tables/test.hjson", NO_VERSION), scope);
assertTrue(compare(updateFile, loaded));
}
use of com.yahoo.elide.modelconfig.validator.DynamicConfigValidator in project elide by yahoo.
the class ConfigDataStoreTest method testUpdateWithPermissionError.
@Test
public void testUpdateWithPermissionError(@TempDir Path configPath) {
String configRoot = configPath.toFile().getPath();
Validator validator = new DynamicConfigValidator(DefaultClassScanner.getInstance(), configRoot);
ConfigDataStore store = new ConfigDataStore(configRoot, validator);
ConfigFile createdFile = createFile("test", store, false);
String createdFilePath = Path.of(configPath.toFile().getPath(), createdFile.getPath()).toFile().getPath();
File file = new File(createdFilePath);
boolean blockFailed = blockWrites(file);
if (blockFailed) {
// We can't actually test because setting permissions isn't working.
return;
}
assertThrows(UnsupportedOperationException.class, () -> updateFile(configRoot, store));
}
use of com.yahoo.elide.modelconfig.validator.DynamicConfigValidator in project elide by yahoo.
the class ConfigDataStoreTest method testCreateInvalid.
@Test
public void testCreateInvalid(@TempDir Path configPath) {
String configRoot = configPath.toFile().getPath();
Validator validator = new DynamicConfigValidator(DefaultClassScanner.getInstance(), configRoot);
ConfigDataStore store = new ConfigDataStore(configRoot, validator);
assertThrows(BadRequestException.class, () -> createInvalidFile(configRoot, store));
}
Aggregations