Search in sources :

Example 1 with DynamicConfigValidator

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;
}
Also used : SQLQueryEngine(com.yahoo.elide.datastores.aggregation.queryengines.sql.SQLQueryEngine) DefaultQueryValidator(com.yahoo.elide.datastores.aggregation.DefaultQueryValidator) MetaDataStore(com.yahoo.elide.datastores.aggregation.metadata.MetaDataStore) DefaultQueryPlanMerger(com.yahoo.elide.datastores.aggregation.query.DefaultQueryPlanMerger) DynamicConfigValidator(com.yahoo.elide.modelconfig.validator.DynamicConfigValidator)

Example 2 with DynamicConfigValidator

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();
}
Also used : DynamicConfigValidator(com.yahoo.elide.modelconfig.validator.DynamicConfigValidator) BeforeAll(org.junit.jupiter.api.BeforeAll)

Example 3 with DynamicConfigValidator

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));
}
Also used : ConfigFile(com.yahoo.elide.modelconfig.store.models.ConfigFile) RequestScope(com.yahoo.elide.core.RequestScope) DynamicConfigValidator(com.yahoo.elide.modelconfig.validator.DynamicConfigValidator) Validator(com.yahoo.elide.modelconfig.validator.Validator) DynamicConfigValidator(com.yahoo.elide.modelconfig.validator.DynamicConfigValidator) Test(org.junit.jupiter.api.Test)

Example 4 with DynamicConfigValidator

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));
}
Also used : ConfigFile(com.yahoo.elide.modelconfig.store.models.ConfigFile) ConfigFile(com.yahoo.elide.modelconfig.store.models.ConfigFile) File(java.io.File) DynamicConfigValidator(com.yahoo.elide.modelconfig.validator.DynamicConfigValidator) Validator(com.yahoo.elide.modelconfig.validator.Validator) DynamicConfigValidator(com.yahoo.elide.modelconfig.validator.DynamicConfigValidator) Test(org.junit.jupiter.api.Test)

Example 5 with DynamicConfigValidator

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));
}
Also used : DynamicConfigValidator(com.yahoo.elide.modelconfig.validator.DynamicConfigValidator) Validator(com.yahoo.elide.modelconfig.validator.Validator) DynamicConfigValidator(com.yahoo.elide.modelconfig.validator.DynamicConfigValidator) Test(org.junit.jupiter.api.Test)

Aggregations

DynamicConfigValidator (com.yahoo.elide.modelconfig.validator.DynamicConfigValidator)15 Validator (com.yahoo.elide.modelconfig.validator.Validator)11 Test (org.junit.jupiter.api.Test)11 ConfigFile (com.yahoo.elide.modelconfig.store.models.ConfigFile)9 RequestScope (com.yahoo.elide.core.RequestScope)7 File (java.io.File)3 DefaultQueryValidator (com.yahoo.elide.datastores.aggregation.DefaultQueryValidator)1 MetaDataStore (com.yahoo.elide.datastores.aggregation.metadata.MetaDataStore)1 DefaultQueryPlanMerger (com.yahoo.elide.datastores.aggregation.query.DefaultQueryPlanMerger)1 SQLQueryEngine (com.yahoo.elide.datastores.aggregation.queryengines.sql.SQLQueryEngine)1 BeforeAll (org.junit.jupiter.api.BeforeAll)1 ConditionalOnExpression (org.springframework.boot.autoconfigure.condition.ConditionalOnExpression)1 ConditionalOnMissingBean (org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean)1 RefreshScope (org.springframework.cloud.context.config.annotation.RefreshScope)1 Bean (org.springframework.context.annotation.Bean)1 Scope (org.springframework.context.annotation.Scope)1