use of com.yahoo.elide.core.datastore.DataStoreTransaction in project elide by yahoo.
the class PersistentResourceNoopUpdateTest method testNOOPToOneAddRelation.
@Test
public void testNOOPToOneAddRelation() {
FunWithPermissions fun = new FunWithPermissions();
Child child = newChild(1);
fun.setRelation3(child);
DataStoreTransaction tx = mock(DataStoreTransaction.class);
RequestScope goodScope = new RequestScope(null, null, NO_VERSION, null, tx, goodUser, null, null, UUID.randomUUID(), elideSettings);
PersistentResource<FunWithPermissions> funResource = new PersistentResource<>(fun, "3", goodScope);
PersistentResource<Child> childResource = new PersistentResource<>(child, "1", goodScope);
when(tx.getToOneRelation(eq(tx), eq(fun), any(), any())).thenReturn(child);
// We do not want the update to one method to be called when we add the existing entity to the relation
funResource.addRelation("relation3", childResource);
verify(tx, never()).updateToOneRelation(eq(tx), eq(fun), any(), any(), eq(goodScope));
}
use of com.yahoo.elide.core.datastore.DataStoreTransaction in project elide by yahoo.
the class PersistentResourceNoopUpdateTest method testToManyAddRelation.
@Test
public void testToManyAddRelation() {
FunWithPermissions fun = new FunWithPermissions();
Child child = newChild(1);
DataStoreTransaction tx = mock(DataStoreTransaction.class);
RequestScope goodScope = new RequestScope(null, null, NO_VERSION, null, tx, goodUser, null, null, UUID.randomUUID(), elideSettings);
PersistentResource<FunWithPermissions> funResource = new PersistentResource<>(fun, "3", goodScope);
PersistentResource<Child> childResource = new PersistentResource<>(child, null, goodScope);
funResource.addRelation("relation1", childResource);
verify(tx, times(1)).updateToManyRelation(eq(tx), eq(fun), eq("relation1"), any(), any(), eq(goodScope));
}
use of com.yahoo.elide.core.datastore.DataStoreTransaction in project elide by yahoo.
the class PersistentResourceNoopUpdateTest method testToOneAddRelation.
@Test
public void testToOneAddRelation() {
FunWithPermissions fun = new FunWithPermissions();
Child child = newChild(1);
DataStoreTransaction tx = mock(DataStoreTransaction.class);
RequestScope goodScope = new RequestScope(null, null, NO_VERSION, null, tx, goodUser, null, null, UUID.randomUUID(), elideSettings);
PersistentResource<FunWithPermissions> funResource = new PersistentResource<>(fun, "3", goodScope);
PersistentResource<Child> childResource = new PersistentResource<>(child, "1", goodScope);
funResource.addRelation("relation3", childResource);
verify(tx, times(1)).updateToOneRelation(eq(tx), eq(fun), any(), any(), eq(goodScope));
}
use of com.yahoo.elide.core.datastore.DataStoreTransaction in project elide by yahoo.
the class InMemoryStoreTransactionTest method testInMemoryDataStore.
@Test
public void testInMemoryDataStore() {
HashMapDataStore wrapped = new HashMapDataStore(DefaultClassScanner.getInstance(), Book.class.getPackage());
InMemoryDataStore store = new InMemoryDataStore(wrapped);
DataStoreTransaction tx = store.beginReadTransaction();
assertEquals(InMemoryStoreTransaction.class, tx.getClass());
assertEquals(wrapped, wrapped.getDataStore());
// extract class names from DataStore string
String tos = store.toString().replace("Data store contents", "").replace("Table ClassType{cls=class", "").replace("} contents", "").replace("Wrapped:[", "").replace("]", "").replace("\n\n", ",").replace(" ", "").replace("\n", "");
// make sure count is correct
assertEquals(ImmutableSet.copyOf(new String[] { "example.Author", "example.Book", "example.Child", "example.CoerceBean", "example.ComputedBean", "example.Editor", "example.FieldAnnotations", "example.FirstClassFields", "example.FunWithPermissions", "example.Invoice", "example.Job", "example.Left", "example.LineItem", "example.MapColorShape", "example.NoDeleteEntity", "example.NoReadEntity", "example.NoShareEntity", "example.NoUpdateEntity", "example.Parent", "example.Post", "example.PrimitiveId", "example.Publisher", "example.Right", "example.StringId", "example.UpdateAndCreate", "example.User", "example.Company", "example.models.generics.Employee", "example.models.generics.Manager", "example.models.generics.Overlord", "example.models.generics.Peon", "example.models.packageinfo.IncludedPackageLevel", "example.models.packageinfo.included.IncludedSubPackage", "example.models.triggers.Invoice", "example.models.versioned.BookV2", "example.nontransferable.ContainerWithPackageShare", "example.nontransferable.NoTransferBiDirectional", "example.nontransferable.ShareableWithPackageShare", "example.nontransferable.StrictNoTransfer", "example.nontransferable.Untransferable" }), ImmutableSet.copyOf(tos.split(",")));
}
use of com.yahoo.elide.core.datastore.DataStoreTransaction in project elide by yahoo.
the class TransactionWrapperTest method testFlush.
@Test
public void testFlush() {
DataStoreTransaction wrapped = mock(DataStoreTransaction.class);
DataStoreTransaction wrapper = new TestTransactionWrapper(wrapped);
wrapper.flush(null);
verify(wrapped, times(1)).flush(any());
}
Aggregations