Search in sources :

Example 16 with ConfigFile

use of com.yahoo.elide.modelconfig.store.models.ConfigFile in project elide by yahoo.

the class ConfigDataStoreTest method createFile.

protected ConfigFile createFile(String tableName, ConfigDataStore store, boolean validateOnly) {
    Supplier<String> contentProvider = () -> String.format("{            \n" + "  tables: [{     \n" + "      name: %s\n" + "      table: test\n" + "      schema: test\n" + "      measures : [\n" + "         {\n" + "          name : measure\n" + "          type : INTEGER\n" + "          definition: 'MAX({{$measure}})'\n" + "         }\n" + "      ]      \n" + "      dimensions : [\n" + "         {\n" + "           name : dimension\n" + "           type : TEXT\n" + "           definition : '{{$dimension}}'\n" + "         }\n" + "      ]\n" + "  }]\n" + "}", tableName);
    ConfigFile newFile = ConfigFile.builder().type(TABLE).contentProvider(contentProvider).path(String.format("models/tables/%s.hjson", tableName)).build();
    ConfigDataStoreTransaction tx = store.beginTransaction();
    RequestScope scope = mock(RequestScope.class);
    if (validateOnly) {
        when(scope.getRequestHeaderByName(eq(VALIDATE_ONLY_HEADER))).thenReturn("true");
    }
    tx.createObject(newFile, scope);
    tx.save(newFile, scope);
    tx.flush(scope);
    tx.commit(scope);
    return newFile;
}
Also used : ConfigFile(com.yahoo.elide.modelconfig.store.models.ConfigFile) RequestScope(com.yahoo.elide.core.RequestScope)

Aggregations

ConfigFile (com.yahoo.elide.modelconfig.store.models.ConfigFile)16 RequestScope (com.yahoo.elide.core.RequestScope)10 DynamicConfigValidator (com.yahoo.elide.modelconfig.validator.DynamicConfigValidator)8 Validator (com.yahoo.elide.modelconfig.validator.Validator)8 Test (org.junit.jupiter.api.Test)8 File (java.io.File)2 Include (com.yahoo.elide.annotation.Include)1 SecurityCheck (com.yahoo.elide.annotation.SecurityCheck)1 EntityDictionary (com.yahoo.elide.core.dictionary.EntityDictionary)1 NO_VERSION (com.yahoo.elide.core.dictionary.EntityDictionary.NO_VERSION)1 EntityPermissions (com.yahoo.elide.core.dictionary.EntityPermissions)1 BadRequestException (com.yahoo.elide.core.exceptions.BadRequestException)1 Check (com.yahoo.elide.core.security.checks.Check)1 FilterExpressionCheck (com.yahoo.elide.core.security.checks.FilterExpressionCheck)1 UserCheck (com.yahoo.elide.core.security.checks.UserCheck)1 Type (com.yahoo.elide.core.type.Type)1 ClassScanner (com.yahoo.elide.core.utils.ClassScanner)1 DefaultClassScanner (com.yahoo.elide.core.utils.DefaultClassScanner)1 Config (com.yahoo.elide.modelconfig.Config)1 DynamicConfigHelpers (com.yahoo.elide.modelconfig.DynamicConfigHelpers)1