use of com.yahoo.elide.core.datastore.inmemory.HashMapDataStore 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.core.datastore.inmemory.HashMapDataStore in project elide by yahoo.
the class TestBinder method configure.
@Override
protected void configure() {
EntityDictionary dictionary = EntityDictionary.builder().injector(injector::inject).build();
dictionary.scanForSecurityChecks();
bind(dictionary).to(EntityDictionary.class);
ConnectionFactory connectionFactory = new ActiveMQConnectionFactory(EMBEDDED_JMS_URL);
bind(connectionFactory).to(ConnectionFactory.class);
// Primary Elide instance for CRUD endpoints.
bindFactory(new Factory<Elide>() {
@Override
public Elide provide() {
HashMapDataStore inMemoryStore = new HashMapDataStore(Set.of(Book.class, Author.class, Publisher.class, ChatBot.class));
Elide elide = buildElide(inMemoryStore, dictionary);
elide.doScans();
SubscriptionScanner subscriptionScanner = SubscriptionScanner.builder().connectionFactory(connectionFactory).dictionary(elide.getElideSettings().getDictionary()).scanner(elide.getScanner()).build();
subscriptionScanner.bindLifecycleHooks();
return elide;
}
@Override
public void dispose(Elide elide) {
}
}).to(Elide.class).named("elide");
}
use of com.yahoo.elide.core.datastore.inmemory.HashMapDataStore in project elide by yahoo.
the class MetaDataStore method addMetaData.
/**
* Add a meta data object into this data store, check for duplication.
*
* @param object a meta data object
*/
private void addMetaData(Object object, String version) {
HashMapDataStore hashMapDataStore = hashMapDataStores.computeIfAbsent(version, SERVER_ERROR);
EntityDictionary dictionary = hashMapDataStore.getDictionary();
Type<?> cls = dictionary.lookupBoundClass(EntityDictionary.getType(object));
String id = dictionary.getId(object);
if (hashMapDataStore.get(cls).containsKey(id)) {
if (!hashMapDataStore.get(cls).get(id).equals(object)) {
throw new DuplicateMappingException("Duplicated " + cls.getSimpleName() + " metadata " + id);
}
} else {
hashMapDataStore.get(cls).put(id, object);
}
}
use of com.yahoo.elide.core.datastore.inmemory.HashMapDataStore in project elide by yahoo.
the class PersistentResourceFetcherTest method initializeQueryRunner.
@BeforeAll
public void initializeQueryRunner() {
RSQLFilterDialect filterDialect = RSQLFilterDialect.builder().dictionary(dictionary).build();
hashMapDataStore = new HashMapDataStore(DefaultClassScanner.getInstance(), Author.class.getPackage());
settings = new ElideSettingsBuilder(hashMapDataStore).withEntityDictionary(dictionary).withJoinFilterDialect(filterDialect).withSubqueryFilterDialect(filterDialect).withISO8601Dates("yyyy-MM-dd'T'HH:mm'Z'", TimeZone.getTimeZone("UTC")).build();
settings.getSerdes().forEach(CoerceUtil::register);
initializeMocks();
Elide elide = new Elide(settings);
elide.doScans();
runner = new QueryRunner(elide, NO_VERSION);
}
use of com.yahoo.elide.core.datastore.inmemory.HashMapDataStore in project elide by yahoo.
the class GraphQLEndpointTest method setupTest.
@BeforeEach
public void setupTest() throws Exception {
HashMapDataStore inMemoryStore = new HashMapDataStore(DefaultClassScanner.getInstance(), Book.class.getPackage());
Map<String, Class<? extends Check>> checkMappings = new HashMap<>();
checkMappings.put(UserChecks.IS_USER_1, UserChecks.IsUserId.One.class);
checkMappings.put(UserChecks.IS_USER_2, UserChecks.IsUserId.Two.class);
checkMappings.put(CommitChecks.IS_NOT_USER_3, CommitChecks.IsNotUser3.class);
elide = spy(new Elide(new ElideSettingsBuilder(inMemoryStore).withEntityDictionary(EntityDictionary.builder().checks(checkMappings).build()).withAuditLogger(audit).build()));
elide.doScans();
endpoint = new GraphQLEndpoint(elide);
DataStoreTransaction tx = inMemoryStore.beginTransaction();
// Initial data
Book book1 = new Book();
Author author1 = new Author();
Author author2 = new Author();
DisallowTransfer noShare = new DisallowTransfer();
book1.setId(1L);
book1.setTitle("My first book");
book1.setAuthors(Sets.newHashSet(author1));
author1.setId(1L);
author1.setName("Ricky Carmichael");
author1.setBooks(Sets.newHashSet(book1));
author1.setBookTitlesAndAwards(Stream.of(new AbstractMap.SimpleImmutableEntry<>("Bookz", "Pulitzer Prize"), new AbstractMap.SimpleImmutableEntry<>("Lost in the Data", "PEN/Faulkner Award")).collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)));
author2.setId(2L);
author2.setName("The Silent Author");
author2.setBookTitlesAndAwards(Stream.of(new AbstractMap.SimpleImmutableEntry<>("Working Hard or Hardly Working", "Booker Prize")).collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)));
noShare.setId(1L);
tx.createObject(book1, null);
tx.createObject(author1, null);
tx.createObject(author2, null);
tx.createObject(noShare, null);
tx.save(book1, null);
tx.save(author1, null);
tx.save(author2, null);
tx.save(noShare, null);
tx.commit(null);
}
Aggregations