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