Search in sources :

Example 1 with ElideSettings

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

the class ElideCustomSerdeRegistrationTest method testRegisterCustomSerde.

@Test
public void testRegisterCustomSerde() {
    // Create a fake Elide.  Don't actually bind any entities.
    HashMapDataStore wrapped = new HashMapDataStore(DefaultClassScanner.getInstance(), String.class.getPackage());
    InMemoryDataStore store = new InMemoryDataStore(wrapped);
    ElideSettings elideSettings = new ElideSettingsBuilder(store).withEntityDictionary(EntityDictionary.builder().build()).build();
    Elide elide = new Elide(elideSettings);
    elide.doScans();
    assertNotNull(CoerceUtil.lookup(Dummy.class));
    assertNotNull(CoerceUtil.lookup(DummyTwo.class));
    assertNotNull(CoerceUtil.lookup(DummyThree.class));
}
Also used : ElideSettingsBuilder(com.yahoo.elide.ElideSettingsBuilder) HashMapDataStore(com.yahoo.elide.core.datastore.inmemory.HashMapDataStore) ElideSettings(com.yahoo.elide.ElideSettings) Elide(com.yahoo.elide.Elide) InMemoryDataStore(com.yahoo.elide.core.datastore.inmemory.InMemoryDataStore) Test(org.junit.jupiter.api.Test)

Example 2 with ElideSettings

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

the class DefaultAsyncAPIDAOTest method setupMocks.

@BeforeEach
public void setupMocks() {
    dataStore = mock(DataStore.class);
    asyncQuery = mock(AsyncQuery.class);
    asyncQueryResult = mock(AsyncQueryResult.class);
    filter = mock(FilterExpression.class);
    tx = mock(DataStoreTransaction.class);
    Map<String, Class<? extends Check>> checkMappings = new HashMap<>();
    EntityDictionary dictionary = EntityDictionary.builder().checks(checkMappings).build();
    dictionary.bindEntity(AsyncQuery.class);
    dictionary.bindEntity(AsyncQueryResult.class);
    ElideSettings elideSettings = new ElideSettingsBuilder(dataStore).withEntityDictionary(dictionary).withJoinFilterDialect(RSQLFilterDialect.builder().dictionary(dictionary).build()).withSubqueryFilterDialect(RSQLFilterDialect.builder().dictionary(dictionary).build()).withISO8601Dates("yyyy-MM-dd'T'HH:mm'Z'", TimeZone.getTimeZone("UTC")).build();
    elide = new Elide(elideSettings);
    when(dataStore.beginTransaction()).thenReturn(tx);
    asyncAPIDAO = new DefaultAsyncAPIDAO(elide.getElideSettings(), dataStore);
}
Also used : HashMap(java.util.HashMap) Check(com.yahoo.elide.core.security.checks.Check) AsyncQueryResult(com.yahoo.elide.async.models.AsyncQueryResult) ElideSettingsBuilder(com.yahoo.elide.ElideSettingsBuilder) DataStore(com.yahoo.elide.core.datastore.DataStore) AsyncQuery(com.yahoo.elide.async.models.AsyncQuery) DataStoreTransaction(com.yahoo.elide.core.datastore.DataStoreTransaction) ElideSettings(com.yahoo.elide.ElideSettings) FilterExpression(com.yahoo.elide.core.filter.expression.FilterExpression) Elide(com.yahoo.elide.Elide) EntityDictionary(com.yahoo.elide.core.dictionary.EntityDictionary) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 3 with ElideSettings

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

the class PermissionAnnotationTest method setup.

@BeforeAll
public static void setup() {
    dictionary.bindEntity(FunWithPermissions.class);
    FunWithPermissions fun = new FunWithPermissions();
    fun.setId(1);
    AuditLogger testLogger = new TestAuditLogger();
    ElideSettings elideSettings = new ElideSettingsBuilder(null).withDefaultPageSize(10).withDefaultMaxPageSize(10).withAuditLogger(testLogger).withEntityDictionary(dictionary).build();
    RequestScope goodScope = new RequestScope(null, null, NO_VERSION, null, null, GOOD_USER, null, null, UUID.randomUUID(), elideSettings);
    funRecord = new PersistentResource<>(fun, goodScope.getUUIDFor(fun), goodScope);
    RequestScope badScope = new RequestScope(null, null, NO_VERSION, null, null, BAD_USER, null, null, UUID.randomUUID(), elideSettings);
    badRecord = new PersistentResource<>(fun, badScope.getUUIDFor(fun), badScope);
}
Also used : ElideSettingsBuilder(com.yahoo.elide.ElideSettingsBuilder) AuditLogger(com.yahoo.elide.core.audit.AuditLogger) TestAuditLogger(com.yahoo.elide.core.audit.TestAuditLogger) ElideSettings(com.yahoo.elide.ElideSettings) TestAuditLogger(com.yahoo.elide.core.audit.TestAuditLogger) FunWithPermissions(example.FunWithPermissions) RequestScope(com.yahoo.elide.core.RequestScope) BeforeAll(org.junit.jupiter.api.BeforeAll)

Example 4 with ElideSettings

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

the class PermissionExpressionNormalizationVisitorTest method setUp.

@BeforeAll
public void setUp() {
    EntityDictionary dictionary = TestDictionary.getTestDictionary();
    ElideSettings elideSettings = new ElideSettingsBuilder(null).withEntityDictionary(dictionary).build();
    RequestScope requestScope = new RequestScope(null, null, NO_VERSION, null, null, null, null, null, UUID.randomUUID(), elideSettings);
    permissionExpressionVisitor = new PermissionExpressionVisitor(dictionary, (check -> new CheckExpression(check, null, requestScope, null, null)));
    normalizationVisitor = new PermissionExpressionNormalizationVisitor();
}
Also used : ElideSettingsBuilder(com.yahoo.elide.ElideSettingsBuilder) PermissionExpressionVisitor(com.yahoo.elide.core.security.visitors.PermissionExpressionVisitor) ElideSettings(com.yahoo.elide.ElideSettings) EntityDictionary(com.yahoo.elide.core.dictionary.EntityDictionary) RequestScope(com.yahoo.elide.core.RequestScope) PermissionExpressionNormalizationVisitor(com.yahoo.elide.core.security.visitors.PermissionExpressionNormalizationVisitor) CheckExpression(com.yahoo.elide.core.security.permissions.expressions.CheckExpression) BeforeAll(org.junit.jupiter.api.BeforeAll)

Example 5 with ElideSettings

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

the class RequestHandler method executeRequest.

public synchronized ExecutionResult executeRequest(Subscribe subscribeRequest) {
    if (transaction != null) {
        throw new IllegalStateException("Already handling an active request.");
    }
    transaction = topicStore.beginReadTransaction();
    elide.getTransactionRegistry().addRunningTransaction(requestID, transaction);
    ElideSettings settings = elide.getElideSettings();
    GraphQLProjectionInfo projectionInfo = new SubscriptionEntityProjectionMaker(settings, subscribeRequest.getPayload().getVariables(), connectionInfo.getGetApiVersion()).make(subscribeRequest.getPayload().getQuery());
    GraphQLRequestScope requestScope = new GraphQLRequestScope(connectionInfo.getBaseUrl(), transaction, connectionInfo.getUser(), connectionInfo.getGetApiVersion(), settings, projectionInfo, requestID, connectionInfo.getParameters());
    ExecutionInput executionInput = ExecutionInput.newExecutionInput().query(subscribeRequest.getPayload().getQuery()).operationName(subscribeRequest.getPayload().getOperationName()).variables(subscribeRequest.getPayload().getVariables()).localContext(requestScope).build();
    log.info("Processing GraphQL query:\n{}", subscribeRequest.getPayload().getQuery());
    return api.execute(executionInput);
}
Also used : GraphQLProjectionInfo(com.yahoo.elide.graphql.parser.GraphQLProjectionInfo) ElideSettings(com.yahoo.elide.ElideSettings) GraphQLRequestScope(com.yahoo.elide.graphql.GraphQLRequestScope) ExecutionInput(graphql.ExecutionInput) SubscriptionEntityProjectionMaker(com.yahoo.elide.graphql.parser.SubscriptionEntityProjectionMaker)

Aggregations

ElideSettings (com.yahoo.elide.ElideSettings)5 ElideSettingsBuilder (com.yahoo.elide.ElideSettingsBuilder)4 Elide (com.yahoo.elide.Elide)2 RequestScope (com.yahoo.elide.core.RequestScope)2 EntityDictionary (com.yahoo.elide.core.dictionary.EntityDictionary)2 BeforeAll (org.junit.jupiter.api.BeforeAll)2 AsyncQuery (com.yahoo.elide.async.models.AsyncQuery)1 AsyncQueryResult (com.yahoo.elide.async.models.AsyncQueryResult)1 AuditLogger (com.yahoo.elide.core.audit.AuditLogger)1 TestAuditLogger (com.yahoo.elide.core.audit.TestAuditLogger)1 DataStore (com.yahoo.elide.core.datastore.DataStore)1 DataStoreTransaction (com.yahoo.elide.core.datastore.DataStoreTransaction)1 HashMapDataStore (com.yahoo.elide.core.datastore.inmemory.HashMapDataStore)1 InMemoryDataStore (com.yahoo.elide.core.datastore.inmemory.InMemoryDataStore)1 FilterExpression (com.yahoo.elide.core.filter.expression.FilterExpression)1 Check (com.yahoo.elide.core.security.checks.Check)1 CheckExpression (com.yahoo.elide.core.security.permissions.expressions.CheckExpression)1 PermissionExpressionNormalizationVisitor (com.yahoo.elide.core.security.visitors.PermissionExpressionNormalizationVisitor)1 PermissionExpressionVisitor (com.yahoo.elide.core.security.visitors.PermissionExpressionVisitor)1 GraphQLRequestScope (com.yahoo.elide.graphql.GraphQLRequestScope)1