use of com.yahoo.elide.ElideSettingsBuilder in project elide by yahoo.
the class VerboseErrorResponsesTestBinder 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(getDataStore()).withAuditLogger(auditLogger).withJoinFilterDialect(multipleFilterStrategy).withSubqueryFilterDialect(multipleFilterStrategy).withEntityDictionary(dictionary).withVerboseErrors().build());
elide.doScans();
return elide;
}
@Override
public void dispose(Elide elide) {
// do nothing
}
}).to(Elide.class).named("elide");
bind(new BillingService() {
@Override
public long purchase(Invoice invoice) {
return 0;
}
}).to(BillingService.class);
}
use of com.yahoo.elide.ElideSettingsBuilder 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.ElideSettingsBuilder in project elide by yahoo.
the class AsyncAPICancelRunnableTest method setupMocks.
@BeforeEach
public void setupMocks() {
HashMapDataStore inMemoryStore = new HashMapDataStore(DefaultClassScanner.getInstance(), AsyncQuery.class.getPackage());
Map<String, Class<? extends Check>> checkMappings = new HashMap<>();
elide = new Elide(new ElideSettingsBuilder(inMemoryStore).withEntityDictionary(EntityDictionary.builder().checks(checkMappings).build()).withISO8601Dates("yyyy-MM-dd'T'HH:mm'Z'", TimeZone.getTimeZone("UTC")).build());
asyncAPIDao = mock(DefaultAsyncAPIDAO.class);
cancelThread = new AsyncAPICancelRunnable(7, elide, asyncAPIDao);
transactionRegistry = elide.getTransactionRegistry();
}
use of com.yahoo.elide.ElideSettingsBuilder in project elide by yahoo.
the class AsyncAPICleanerRunnableTest method setupMocks.
@BeforeEach
public void setupMocks() {
HashMapDataStore inMemoryStore = new HashMapDataStore(DefaultClassScanner.getInstance(), AsyncQuery.class.getPackage());
Map<String, Class<? extends Check>> checkMappings = new HashMap<>();
elide = new Elide(new ElideSettingsBuilder(inMemoryStore).withEntityDictionary(EntityDictionary.builder().checks(checkMappings).build()).withISO8601Dates("yyyy-MM-dd'T'HH:mm'Z'", TimeZone.getTimeZone("UTC")).build());
asyncAPIDao = mock(DefaultAsyncAPIDAO.class);
dateUtil = mock(DateUtil.class);
cleanerThread = new AsyncAPICleanerRunnable(7, elide, 7, asyncAPIDao, dateUtil);
}
use of com.yahoo.elide.ElideSettingsBuilder in project elide by yahoo.
the class JMSDataStoreTest method testLoadObjects.
@Test
public void testLoadObjects() throws Exception {
Author author1 = new Author();
author1.setId(1);
author1.setName("Jon Doe");
Book book1 = new Book();
book1.setTitle("Enders Game");
book1.setId(1);
book1.setAuthors(Sets.newHashSet(author1));
Book book2 = new Book();
book2.setTitle("Grapes of Wrath");
book2.setId(2);
try (DataStoreTransaction tx = store.beginReadTransaction()) {
RequestScope scope = new RequestScope("/json", "/", NO_VERSION, null, tx, null, null, Collections.EMPTY_MAP, UUID.randomUUID(), new ElideSettingsBuilder(store).withEntityDictionary(dictionary).build());
Iterable<Book> books = tx.loadObjects(EntityProjection.builder().argument(Argument.builder().name("topic").value(TopicType.ADDED).build()).type(Book.class).build(), scope);
JMSContext context = connectionFactory.createContext();
Destination destination = context.createTopic("bookAdded");
JMSProducer producer = context.createProducer();
ObjectMapper mapper = new ObjectMapper();
producer.send(destination, mapper.writeValueAsString(book1));
producer.send(destination, mapper.writeValueAsString(book2));
Iterator<Book> booksIterator = books.iterator();
assertTrue(booksIterator.hasNext());
Book receivedBook = booksIterator.next();
assertEquals("Enders Game", receivedBook.getTitle());
assertEquals(1, receivedBook.getId());
Set<Author> receivedAuthors = Sets.newHashSet((Iterable) tx.getToManyRelation(tx, receivedBook, Relationship.builder().name("authors").projection(EntityProjection.builder().type(Author.class).build()).build(), scope));
assertTrue(receivedAuthors.contains(author1));
assertTrue(booksIterator.hasNext());
receivedBook = booksIterator.next();
assertEquals("Grapes of Wrath", receivedBook.getTitle());
assertEquals(2, receivedBook.getId());
assertFalse(booksIterator.hasNext());
}
}
Aggregations