Search in sources :

Example 36 with DataStore

use of com.yahoo.elide.core.datastore.DataStore in project elide by yahoo.

the class MultiplexTransactionTest method testGetProperty.

@Test
public void testGetProperty() throws Exception {
    DataStore store1 = mock(HashMapDataStore.class);
    DataStore store2 = mock(DataStore.class);
    DataStoreTransaction tx1 = mock(HashMapStoreTransaction.class);
    DataStoreTransaction tx2 = mock(DataStoreTransaction.class);
    when(store1.beginReadTransaction()).thenReturn(tx1);
    when(store2.beginReadTransaction()).thenReturn(tx2);
    when(tx1.getProperty(any())).thenReturn(null);
    when(tx2.getProperty(any())).thenReturn("Foo");
    MultiplexManager store = new MultiplexManager(store1, store2);
    DataStoreTransaction multiplexTx = store.beginReadTransaction();
    String propertyName = "com.yahoo.elide.core.datastore.Bar";
    String result = multiplexTx.getProperty(propertyName);
    verify(tx1, Mockito.never()).getProperty(eq(propertyName));
    verify(tx2, Mockito.times(1)).getProperty(eq(propertyName));
    assertEquals("Foo", result);
}
Also used : HashMapDataStore(com.yahoo.elide.core.datastore.inmemory.HashMapDataStore) DataStore(com.yahoo.elide.core.datastore.DataStore) DataStoreTransaction(com.yahoo.elide.core.datastore.DataStoreTransaction) Test(org.junit.jupiter.api.Test)

Example 37 with DataStore

use of com.yahoo.elide.core.datastore.DataStore in project elide by yahoo.

the class NoopDataStoreTest method testPopulateEntityDictionary.

@Test
public void testPopulateEntityDictionary() throws Exception {
    DataStore store = new NoopDataStore(Arrays.asList(NoopBean.class));
    EntityDictionary dictionary = EntityDictionary.builder().build();
    store.populateEntityDictionary(dictionary);
    assertEquals(ClassType.of(NoopBean.class), dictionary.getEntityClass("theNoopBean", EntityDictionary.NO_VERSION));
}
Also used : NoopBean(com.yahoo.elide.beans.NoopBean) DataStore(com.yahoo.elide.core.datastore.DataStore) EntityDictionary(com.yahoo.elide.core.dictionary.EntityDictionary) Test(org.junit.jupiter.api.Test)

Example 38 with DataStore

use of com.yahoo.elide.core.datastore.DataStore in project elide by yahoo.

the class NoopDataStoreTest method testBeginTransaction.

@Test
public void testBeginTransaction() throws Exception {
    DataStore store = new NoopDataStore(Arrays.asList(NoopBean.class));
    DataStoreTransaction tx = store.beginReadTransaction();
    assertTrue(tx instanceof NoopTransaction);
}
Also used : NoopBean(com.yahoo.elide.beans.NoopBean) DataStore(com.yahoo.elide.core.datastore.DataStore) DataStoreTransaction(com.yahoo.elide.core.datastore.DataStoreTransaction) Test(org.junit.jupiter.api.Test)

Aggregations

DataStore (com.yahoo.elide.core.datastore.DataStore)38 DataStoreTransaction (com.yahoo.elide.core.datastore.DataStoreTransaction)31 Test (org.junit.jupiter.api.Test)27 Elide (com.yahoo.elide.Elide)25 ElideResponse (com.yahoo.elide.ElideResponse)21 RequestScope (com.yahoo.elide.core.RequestScope)19 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)18 EntityProjection (com.yahoo.elide.core.request.EntityProjection)10 EntityDictionary (com.yahoo.elide.core.dictionary.EntityDictionary)5 MultivaluedHashMap (javax.ws.rs.core.MultivaluedHashMap)5 HashMapDataStore (com.yahoo.elide.core.datastore.inmemory.HashMapDataStore)3 FieldTestModel (com.yahoo.elide.core.lifecycle.FieldTestModel)3 AggregationDataStore (com.yahoo.elide.datastores.aggregation.AggregationDataStore)3 MetaDataStore (com.yahoo.elide.datastores.aggregation.metadata.MetaDataStore)3 JpaDataStore (com.yahoo.elide.datastores.jpa.JpaDataStore)3 NonJtaTransaction (com.yahoo.elide.datastores.jpa.transaction.NonJtaTransaction)3 MultiplexManager (com.yahoo.elide.datastores.multiplex.MultiplexManager)3 NoopBean (com.yahoo.elide.beans.NoopBean)2 TemplateConfigValidator (com.yahoo.elide.datastores.aggregation.validator.TemplateConfigValidator)2 ConfigDataStore (com.yahoo.elide.modelconfig.store.ConfigDataStore)2