use of org.molgenis.data.Entity in project molgenis by molgenis.
the class LazyEntityTest method getEntityStringClassE.
@Test
public void getEntityStringClassE() {
String attrName = "attr";
Entity value = mock(Entity.class);
when(entity.getEntity(attrName, Entity.class)).thenReturn(value);
assertEquals(value, lazyEntity.getEntity(attrName, Entity.class));
assertEquals(value, lazyEntity.getEntity(attrName, Entity.class));
verify(dataService, times(1)).findOneById(ENTITY_NAME, id);
}
use of org.molgenis.data.Entity in project molgenis by molgenis.
the class PartialEntityTest method setEntity.
@Test
public void setEntity() {
Entity e = mock(Entity.class);
partialEntity.set(e);
verify(decoratedEntity, times(1)).set(e);
verifyZeroInteractions(entityManager);
}
use of org.molgenis.data.Entity in project molgenis by molgenis.
the class TransactionalRepositoryDecoratorTest method update.
@Test
public void update() throws Exception {
Entity entity = mock(Entity.class);
transactionalRepo.update(entity);
verify(transactionManager).getTransaction(any(TransactionDefinition.class));
verify(delegateRepository).update(entity);
}
use of org.molgenis.data.Entity in project molgenis by molgenis.
the class TransactionalRepositoryDecoratorTest method add.
@Test
public void add() throws Exception {
Entity entity = mock(Entity.class);
transactionalRepo.add(entity);
verify(transactionManager).getTransaction(any(TransactionDefinition.class));
verify(delegateRepository).add(entity);
}
use of org.molgenis.data.Entity in project molgenis by molgenis.
the class EntityUtilsTest method getTypedValueStringAttributeEntityManagerXref.
@Test
public void getTypedValueStringAttributeEntityManagerXref() {
String valueStr = "0";
Attribute attr = mock(Attribute.class);
EntityType refEntityType = mock(EntityType.class);
Attribute refIdAttr = mock(Attribute.class);
when(refIdAttr.getDataType()).thenReturn(STRING);
when(refEntityType.getIdAttribute()).thenReturn(refIdAttr);
when(attr.getRefEntity()).thenReturn(refEntityType);
when(attr.getDataType()).thenReturn(XREF);
Entity entity = mock(Entity.class);
EntityManager entityManager = mock(EntityManager.class);
when(entityManager.getReference(refEntityType, valueStr)).thenReturn(entity);
assertEquals(EntityUtils.getTypedValue(valueStr, attr, entityManager), entity);
}
Aggregations