use of com.yahoo.elide.core.datastore.DataStoreTransaction in project elide by yahoo.
the class DataStoreIT method setUp.
@BeforeEach
public void setUp() throws IOException {
try (DataStoreTransaction tx = dataStore.beginTransaction()) {
tx.createObject(new Filtered(), null);
tx.createObject(new Filtered(), null);
tx.createObject(new Filtered(), null);
Author georgeMartin = new Author();
tx.createObject(georgeMartin, null);
georgeMartin.setName("George R. R. Martin");
Book book1 = new Book();
tx.createObject(book1, null);
book1.setTitle(SONG_OF_ICE_AND_FIRE);
book1.setAuthors(Arrays.asList(georgeMartin));
Book book2 = new Book();
tx.createObject(book2, null);
book2.setTitle(CLASH_OF_KINGS);
book2.setAuthors(Arrays.asList(georgeMartin));
Book book3 = new Book();
tx.createObject(book3, null);
book3.setTitle(STORM_OF_SWORDS);
book3.setAuthors(Arrays.asList(georgeMartin));
georgeMartin.setBooks(Arrays.asList(book1, book2, book3));
addChapters(ICE_AND_FIRE_CHAPTER_COUNT, book1, tx);
addChapters(CLASH_OF_KINGS_CHAPTER_COUNT, book2, tx);
addChapters(STORM_OF_SWORDS_CHAPTER_COUNT, book3, tx);
tx.save(book1, null);
tx.save(book2, null);
tx.save(book3, null);
tx.save(georgeMartin, null);
tx.commit(null);
}
}
use of com.yahoo.elide.core.datastore.DataStoreTransaction in project elide by yahoo.
the class EmbeddedIT method setup.
@BeforeEach
public void setup() throws IOException {
dataStore.populateEntityDictionary(EntityDictionary.builder().build());
DataStoreTransaction tx = dataStore.beginTransaction();
// id 1
Embedded embedded = new Embedded();
embedded.setSegmentIds(ImmutableSet.of(3L, 4L, 5L));
tx.createObject(embedded, null);
Left left = new Left();
Right right = new Right();
left.setOne2one(right);
right.setOne2one(left);
tx.createObject(left, null);
tx.createObject(right, null);
tx.commit(null);
tx.close();
}
use of com.yahoo.elide.core.datastore.DataStoreTransaction in project elide by yahoo.
the class EmbeddedIdIT method setup.
@BeforeEach
public void setup() throws IOException {
dataStore.populateEntityDictionary(EntityDictionary.builder().build());
DataStoreTransaction tx = dataStore.beginTransaction();
Building building1 = new Building();
building1.setAddress(address1);
building1.setName("Fort Knox");
Building building2 = new Building();
building2.setAddress(address3);
building2.setName("Assembly Hall");
building1.setNeighbors(Sets.newHashSet(building2));
building2.setNeighbors(Sets.newHashSet(building1));
tx.createObject(building1, null);
tx.createObject(building2, null);
tx.commit(null);
tx.close();
}
use of com.yahoo.elide.core.datastore.DataStoreTransaction in project elide by yahoo.
the class LegacyNPlusOneIT method setUp.
@BeforeEach
public void setUp() throws IOException {
reset(logger);
try (DataStoreTransaction tx = dataStore.beginTransaction()) {
Book book1 = new Book();
book1.setTitle("Test Book1");
tx.createObject(book1, null);
Book book2 = new Book();
book2.setTitle("Test Book2");
tx.createObject(book2, null);
Book book3 = new Book();
book3.setTitle("Test Book3");
tx.createObject(book3, null);
Author author1 = new Author();
author1.setName("Bob1");
tx.createObject(author1, null);
Author author2 = new Author();
author2.setName("Bob2");
tx.createObject(author2, null);
Author author3 = new Author();
author3.setName("Bob3");
tx.createObject(author3, null);
Publisher publisher = new Publisher();
tx.createObject(publisher, null);
author1.setBooks(Arrays.asList(book1, book2));
author2.setBooks(Arrays.asList(book1, book2));
author3.setBooks(Arrays.asList(book3));
book1.setAuthors(Arrays.asList(author1, author2));
book2.setAuthors(Arrays.asList(author1, author2));
book3.setAuthors(Arrays.asList(author3));
book1.setPublisher(publisher);
book2.setPublisher(publisher);
publisher.setBooks(new HashSet<>(Arrays.asList(book1, book2)));
tx.commit(null);
}
}
use of com.yahoo.elide.core.datastore.DataStoreTransaction in project elide by yahoo.
the class HashMapDataStoreTest method testValidCommit.
@Test
public void testValidCommit() throws Exception {
FirstBean object = new FirstBean();
object.id = "0";
object.name = "Test";
try (DataStoreTransaction t = inMemoryDataStore.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 = inMemoryDataStore.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(!"0".equals(bean.id) && "Test".equals(bean.name));
}
}
Aggregations