use of com.yahoo.elide.core.dictionary.EntityDictionary in project elide by yahoo.
the class PathTest method testIsComputed.
@Test
public void testIsComputed() {
EntityDictionary dictionary = EntityDictionary.builder().build();
dictionary.bindEntity(Book.class);
dictionary.bindEntity(Editor.class);
Path computedRelationshipPath = new Path(List.of(new Path.PathElement(Book.class, Editor.class, "editor"), new Path.PathElement(Editor.class, String.class, "firstName")));
Path computedAttributePath = new Path(List.of(new Path.PathElement(Editor.class, String.class, "fullName")));
Path attributePath = new Path(List.of(new Path.PathElement(Book.class, String.class, "title")));
assertTrue(computedRelationshipPath.isComputed(dictionary));
assertTrue(computedAttributePath.isComputed(dictionary));
assertFalse(attributePath.isComputed(dictionary));
}
use of com.yahoo.elide.core.dictionary.EntityDictionary in project elide by yahoo.
the class PersistenceResourceTestSetup method initDictionary.
protected static EntityDictionary initDictionary() {
EntityDictionary dictionary = TestDictionary.getTestDictionary();
dictionary.bindEntity(UpdateAndCreate.class);
dictionary.bindEntity(Author.class);
dictionary.bindEntity(Book.class);
dictionary.bindEntity(Publisher.class);
dictionary.bindEntity(Child.class);
dictionary.bindEntity(Parent.class);
dictionary.bindEntity(FunWithPermissions.class);
dictionary.bindEntity(Job.class);
dictionary.bindEntity(Left.class);
dictionary.bindEntity(Right.class);
dictionary.bindEntity(NoReadEntity.class);
dictionary.bindEntity(NoDeleteEntity.class);
dictionary.bindEntity(NoUpdateEntity.class);
dictionary.bindEntity(NoCreateEntity.class);
dictionary.bindEntity(NoShareEntity.class);
dictionary.bindEntity(example.User.class);
dictionary.bindEntity(FirstClassFields.class);
dictionary.bindEntity(MapColorShape.class);
dictionary.bindEntity(PersistentResourceTest.ChangeSpecModel.class);
dictionary.bindEntity(PersistentResourceTest.ChangeSpecChild.class);
dictionary.bindEntity(Invoice.class);
dictionary.bindEntity(LineItem.class);
dictionary.bindEntity(ComputedBean.class);
dictionary.bindEntity(ContainerWithPackageShare.class);
dictionary.bindEntity(ShareableWithPackageShare.class);
dictionary.bindEntity(NoTransferBiDirectional.class);
dictionary.bindEntity(StrictNoTransfer.class);
dictionary.bindEntity(Untransferable.class);
dictionary.bindEntity(Company.class);
dictionary.bindTrigger(Book.class, "price", LifeCycleHookBinding.Operation.UPDATE, LifeCycleHookBinding.TransactionPhase.PRESECURITY, bookUpdatePrice);
return dictionary;
}
use of com.yahoo.elide.core.dictionary.EntityDictionary in project elide by yahoo.
the class RequestScopeTest method testNewObjectsForInheritedTypes.
@Test
public void testNewObjectsForInheritedTypes() throws Exception {
@Entity
@Include(rootLevel = false)
class MyBaseClass {
@Id
public long id;
}
@Entity
@Include(rootLevel = false)
class MyInheritedClass extends MyBaseClass {
public String myField;
}
EntityDictionary dictionary = EntityDictionary.builder().build();
dictionary.bindEntity(MyBaseClass.class);
dictionary.bindEntity(MyInheritedClass.class);
RequestScope requestScope = new RequestScope(null, "/", NO_VERSION, null, null, null, null, null, UUID.randomUUID(), new ElideSettingsBuilder(null).withEntityDictionary(dictionary).build());
String myId = "myId";
// Test that a new inherited class is counted for base type
requestScope.setUUIDForObject(ClassType.of(MyInheritedClass.class), myId, new MyInheritedClass());
assertNotNull(requestScope.getObjectById(ClassType.of(MyBaseClass.class), myId));
}
use of com.yahoo.elide.core.dictionary.EntityDictionary in project elide by yahoo.
the class LogMessageImplTest method init.
@BeforeAll
public static void init() {
final EntityDictionary dictionary = EntityDictionary.builder().build();
dictionary.bindEntity(Child.class);
dictionary.bindEntity(Parent.class);
final Child child = new Child();
child.setId(5);
final Parent parent = new Parent();
parent.setId(7);
final Child friend = new Child();
friend.setId(9);
child.setFriends(Sets.newHashSet(friend));
final RequestScope requestScope = new RequestScope(null, null, NO_VERSION, null, null, new TestUser("aaron"), null, null, UUID.randomUUID(), new ElideSettingsBuilder(null).withAuditLogger(new TestAuditLogger()).withEntityDictionary(dictionary).build());
final PersistentResource<Parent> parentRecord = new PersistentResource<>(parent, requestScope.getUUIDFor(parent), requestScope);
childRecord = new PersistentResource<>(child, parentRecord, "children", requestScope.getUUIDFor(child), requestScope);
friendRecord = new PersistentResource<>(friend, childRecord, "friends", requestScope.getUUIDFor(friend), requestScope);
}
use of com.yahoo.elide.core.dictionary.EntityDictionary in project elide by yahoo.
the class DataStoreTransactionTest method setupMocks.
@BeforeEach
public void setupMocks() {
// this will test with the default interface implementation
scope = mock(RequestScope.class);
EntityDictionary dictionary = mock(EntityDictionary.class);
when(scope.getDictionary()).thenReturn(dictionary);
when(dictionary.getIdType(STRING_TYPE)).thenReturn(new ClassType(Long.class));
when(dictionary.getValue(ENTITY, NAME, scope)).thenReturn(3L);
when(dictionary.getValue(ENTITY, NAME2, scope)).thenReturn(new DataStoreIterableBuilder(List.of(1L, 2L, 3L)).build());
}
Aggregations