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;
}
Aggregations