Search in sources :

Example 6 with FirstBean

use of com.yahoo.elide.example.beans.FirstBean in project elide by yahoo.

the class MultiplexManagerTest method testValidCommit.

@Test
public void testValidCommit() throws IOException {
    final FirstBean object = new FirstBean();
    object.setId(null);
    object.setName("Test");
    try (DataStoreTransaction t = multiplexManager.beginTransaction()) {
        assertFalse(t.loadObjects(EntityProjection.builder().type(FirstBean.class).build(), null).iterator().hasNext());
        t.createObject(object, null);
        assertFalse(t.loadObjects(EntityProjection.builder().type(FirstBean.class).build(), null).iterator().hasNext());
        t.commit(null);
    }
    try (DataStoreTransaction t = multiplexManager.beginTransaction()) {
        Iterable<Object> beans = t.loadObjects(EntityProjection.builder().type(FirstBean.class).build(), null);
        assertNotNull(beans);
        assertTrue(beans.iterator().hasNext());
        FirstBean bean = (FirstBean) IterableUtils.first(beans);
        assertTrue(bean.getId() != null && "Test".equals(bean.getName()));
    }
}
Also used : FirstBean(com.yahoo.elide.example.beans.FirstBean) DataStoreTransaction(com.yahoo.elide.core.datastore.DataStoreTransaction) Test(org.junit.jupiter.api.Test)

Aggregations

DataStoreTransaction (com.yahoo.elide.core.datastore.DataStoreTransaction)6 FirstBean (com.yahoo.elide.example.beans.FirstBean)6 Test (org.junit.jupiter.api.Test)6 FirstChildBean (com.yahoo.elide.example.beans.FirstChildBean)2 DataStore (com.yahoo.elide.core.datastore.DataStore)1 HashMapDataStore (com.yahoo.elide.core.datastore.inmemory.HashMapDataStore)1 EntityDictionary (com.yahoo.elide.core.dictionary.EntityDictionary)1 OtherBean (com.yahoo.elide.example.other.OtherBean)1 HashSet (java.util.HashSet)1