Search in sources :

Example 16 with ElideSettingsBuilder

use of com.yahoo.elide.ElideSettingsBuilder in project elide by yahoo.

the class ResourceIT method elideSecurityEnabled.

@Test
public void elideSecurityEnabled() {
    Elide elide = new Elide(new ElideSettingsBuilder(dataStore).withEntityDictionary(EntityDictionary.builder().checks(TestCheckMappings.MAPPINGS).build()).withAuditLogger(new TestAuditLogger()).build());
    elide.doScans();
    com.yahoo.elide.core.security.User user = new com.yahoo.elide.core.security.User(() -> "-1");
    ElideResponse response = elide.get(baseUrl, "parent/1/children", new MultivaluedHashMap<>(), user, NO_VERSION);
    assertEquals(HttpStatus.SC_OK, response.getResponseCode());
    assertEquals("{\"data\":[]}", response.getBody());
}
Also used : ElideSettingsBuilder(com.yahoo.elide.ElideSettingsBuilder) User(example.User) ElideResponse(com.yahoo.elide.ElideResponse) TestAuditLogger(com.yahoo.elide.core.audit.TestAuditLogger) Elide(com.yahoo.elide.Elide) Test(org.junit.jupiter.api.Test) IntegrationTest(com.yahoo.elide.initialization.IntegrationTest) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 17 with ElideSettingsBuilder

use of com.yahoo.elide.ElideSettingsBuilder in project elide by yahoo.

the class StandardTestBinder method configure.

@Override
protected void configure() {
    EntityDictionary dictionary = EntityDictionary.builder().injector(injector::inject).checks(TestCheckMappings.MAPPINGS).build();
    bind(dictionary).to(EntityDictionary.class);
    // Elide instance
    bindFactory(new Factory<Elide>() {

        @Override
        public Elide provide() {
            DefaultFilterDialect defaultFilterStrategy = new DefaultFilterDialect(dictionary);
            RSQLFilterDialect rsqlFilterStrategy = RSQLFilterDialect.builder().dictionary(dictionary).build();
            MultipleFilterDialect multipleFilterStrategy = new MultipleFilterDialect(Arrays.asList(rsqlFilterStrategy, defaultFilterStrategy), Arrays.asList(rsqlFilterStrategy, defaultFilterStrategy));
            Elide elide = new Elide(new ElideSettingsBuilder(IntegrationTest.getDataStore()).withAuditLogger(auditLogger).withJoinFilterDialect(multipleFilterStrategy).withSubqueryFilterDialect(multipleFilterStrategy).withEntityDictionary(dictionary).withISO8601Dates("yyyy-MM-dd'T'HH:mm'Z'", Calendar.getInstance().getTimeZone()).build());
            elide.doScans();
            return elide;
        }

        @Override
        public void dispose(Elide elide) {
        }
    }).to(Elide.class).named("elide");
    bind(BILLING_SERVICE).to(BillingService.class);
}
Also used : ElideSettingsBuilder(com.yahoo.elide.ElideSettingsBuilder) MultipleFilterDialect(com.yahoo.elide.core.filter.dialect.jsonapi.MultipleFilterDialect) DefaultFilterDialect(com.yahoo.elide.core.filter.dialect.jsonapi.DefaultFilterDialect) Elide(com.yahoo.elide.Elide) EntityDictionary(com.yahoo.elide.core.dictionary.EntityDictionary) RSQLFilterDialect(com.yahoo.elide.core.filter.dialect.RSQLFilterDialect)

Example 18 with ElideSettingsBuilder

use of com.yahoo.elide.ElideSettingsBuilder in project elide by yahoo.

the class SubscriptionWebSocketConfigurator method buildElide.

protected Elide buildElide(DataStore store, EntityDictionary dictionary) {
    RSQLFilterDialect rsqlFilterStrategy = RSQLFilterDialect.builder().dictionary(dictionary).build();
    ElideSettingsBuilder builder = new ElideSettingsBuilder(store).withAuditLogger(auditLogger).withErrorMapper(errorMapper).withBaseUrl(baseUrl).withJoinFilterDialect(rsqlFilterStrategy).withSubqueryFilterDialect(rsqlFilterStrategy).withEntityDictionary(dictionary).withISO8601Dates("yyyy-MM-dd'T'HH:mm'Z'", Calendar.getInstance().getTimeZone());
    if (verboseErrors) {
        builder = builder.withVerboseErrors();
    }
    Elide elide = new Elide(builder.build());
    elide.doScans();
    return elide;
}
Also used : ElideSettingsBuilder(com.yahoo.elide.ElideSettingsBuilder) Elide(com.yahoo.elide.Elide) RSQLFilterDialect(com.yahoo.elide.core.filter.dialect.RSQLFilterDialect)

Example 19 with ElideSettingsBuilder

use of com.yahoo.elide.ElideSettingsBuilder in project elide by yahoo.

the class ElideStandaloneTestSettings method getElideSettings.

@Override
public ElideSettings getElideSettings(EntityDictionary dictionary, DataStore dataStore, JsonApiMapper mapper) {
    String jsonApiBaseUrl = getBaseUrl() + getJsonApiPathSpec().replaceAll("/\\*", "") + "/";
    ElideSettingsBuilder builder = new ElideSettingsBuilder(dataStore).withEntityDictionary(dictionary).withErrorMapper(getErrorMapper()).withJoinFilterDialect(RSQLFilterDialect.builder().dictionary(dictionary).build()).withSubqueryFilterDialect(RSQLFilterDialect.builder().dictionary(dictionary).build()).withJSONApiLinks(new DefaultJSONApiLinks(jsonApiBaseUrl)).withBaseUrl("https://elide.io").withAuditLogger(getAuditLogger()).withVerboseErrors().withJsonApiMapper(mapper).withJsonApiPath(getJsonApiPathSpec().replaceAll("/\\*", "")).withGraphQLApiPath(getGraphQLApiPathSpec().replaceAll("/\\*", "")).withExportApiPath(getAsyncProperties().getExportApiPathSpec().replaceAll("/\\*", ""));
    if (enableISO8601Dates()) {
        builder = builder.withISO8601Dates("yyyy-MM-dd'T'HH:mm'Z'", TimeZone.getTimeZone("UTC"));
    }
    return builder.build();
}
Also used : ElideSettingsBuilder(com.yahoo.elide.ElideSettingsBuilder) DefaultJSONApiLinks(com.yahoo.elide.jsonapi.links.DefaultJSONApiLinks)

Example 20 with ElideSettingsBuilder

use of com.yahoo.elide.ElideSettingsBuilder in project elide by yahoo.

the class IntegrationTestSetup method initializeElide.

// Initialize beans here if needed.
// We recreate the Elide bean here without @RefreshScope so that it can be used With @SpyBean.
@Bean
public RefreshableElide initializeElide(EntityDictionary dictionary, DataStore dataStore, ElideConfigProperties settings, JsonApiMapper mapper, ErrorMapper errorMapper) {
    ElideSettingsBuilder builder = new ElideSettingsBuilder(dataStore).withEntityDictionary(dictionary).withErrorMapper(errorMapper).withJsonApiMapper(mapper).withDefaultMaxPageSize(settings.getMaxPageSize()).withDefaultPageSize(settings.getPageSize()).withJoinFilterDialect(RSQLFilterDialect.builder().dictionary(dictionary).build()).withSubqueryFilterDialect(RSQLFilterDialect.builder().dictionary(dictionary).build()).withAuditLogger(new Slf4jLogger()).withBaseUrl(settings.getBaseUrl()).withISO8601Dates("yyyy-MM-dd'T'HH:mm'Z'", TimeZone.getTimeZone("UTC")).withJsonApiPath(settings.getJsonApi().getPath()).withGraphQLApiPath(settings.getGraphql().getPath());
    if (settings.isVerboseErrors()) {
        builder.withVerboseErrors();
    }
    if (settings.getAsync() != null && settings.getAsync().getExport() != null && settings.getAsync().getExport().isEnabled()) {
        builder.withExportApiPath(settings.getAsync().getExport().getPath());
    }
    if (settings.getJsonApi() != null && settings.getJsonApi().isEnabled() && settings.getJsonApi().isEnableLinks()) {
        String baseUrl = settings.getBaseUrl();
        if (StringUtils.isEmpty(baseUrl)) {
            builder.withJSONApiLinks(new DefaultJSONApiLinks());
        } else {
            String jsonApiBaseUrl = baseUrl + settings.getJsonApi().getPath() + "/";
            builder.withJSONApiLinks(new DefaultJSONApiLinks(jsonApiBaseUrl));
        }
    }
    Elide elide = new Elide(builder.build(), new TransactionRegistry(), dictionary.getScanner(), true);
    return new RefreshableElide(spy(elide));
}
Also used : ElideSettingsBuilder(com.yahoo.elide.ElideSettingsBuilder) Slf4jLogger(com.yahoo.elide.core.audit.Slf4jLogger) DefaultJSONApiLinks(com.yahoo.elide.jsonapi.links.DefaultJSONApiLinks) TransactionRegistry(com.yahoo.elide.core.TransactionRegistry) RefreshableElide(com.yahoo.elide.RefreshableElide) Elide(com.yahoo.elide.Elide) RefreshableElide(com.yahoo.elide.RefreshableElide) Bean(org.springframework.context.annotation.Bean)

Aggregations

ElideSettingsBuilder (com.yahoo.elide.ElideSettingsBuilder)30 Elide (com.yahoo.elide.Elide)20 Check (com.yahoo.elide.core.security.checks.Check)12 HashMap (java.util.HashMap)12 HashMapDataStore (com.yahoo.elide.core.datastore.inmemory.HashMapDataStore)10 BeforeEach (org.junit.jupiter.api.BeforeEach)10 RequestScope (com.yahoo.elide.core.RequestScope)9 EntityDictionary (com.yahoo.elide.core.dictionary.EntityDictionary)7 Test (org.junit.jupiter.api.Test)7 DataStoreTransaction (com.yahoo.elide.core.datastore.DataStoreTransaction)5 RSQLFilterDialect (com.yahoo.elide.core.filter.dialect.RSQLFilterDialect)5 User (com.yahoo.elide.core.security.User)5 BeforeAll (org.junit.jupiter.api.BeforeAll)5 ElideSettings (com.yahoo.elide.ElideSettings)4 AsyncQuery (com.yahoo.elide.async.models.AsyncQuery)4 Slf4jLogger (com.yahoo.elide.core.audit.Slf4jLogger)4 TestAuditLogger (com.yahoo.elide.core.audit.TestAuditLogger)4 ElideResponse (com.yahoo.elide.ElideResponse)3 DefaultAsyncAPIDAO (com.yahoo.elide.async.service.dao.DefaultAsyncAPIDAO)3 FileResultStorageEngine (com.yahoo.elide.async.service.storageengine.FileResultStorageEngine)3