use of com.yahoo.elide.modelconfig.validator.Validator 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.Validator 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.Validator 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));
}
use of com.yahoo.elide.modelconfig.validator.Validator in project elide by yahoo.
the class ConfigDataStoreTest method testCreateValidateOnly.
@Test
public void testCreateValidateOnly(@TempDir Path configPath) {
String configRoot = configPath.toFile().getPath();
Validator validator = new DynamicConfigValidator(DefaultClassScanner.getInstance(), configRoot);
ConfigDataStore store = new ConfigDataStore(configRoot, validator);
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);
assertNull(loaded);
}
use of com.yahoo.elide.modelconfig.validator.Validator in project elide by yahoo.
the class ConfigDataStoreTest method testCreateReadOnly.
@Test
public void testCreateReadOnly() {
// This path is read only (Classpath)...
String configRoot = "src/test/resources/validator/valid";
Validator validator = new DynamicConfigValidator(DefaultClassScanner.getInstance(), configRoot);
ConfigDataStore store = new ConfigDataStore(configRoot, validator);
assertThrows(UnsupportedOperationException.class, () -> createFile("test", store, false));
}
Aggregations