Search in sources :

Example 11 with Entity

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);
}
Also used : Entity(org.molgenis.data.Entity) Test(org.testng.annotations.Test)

Example 12 with Entity

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);
}
Also used : Entity(org.molgenis.data.Entity) Test(org.testng.annotations.Test)

Example 13 with Entity

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);
}
Also used : TransactionDefinition(org.springframework.transaction.TransactionDefinition) Entity(org.molgenis.data.Entity) Test(org.testng.annotations.Test)

Example 14 with 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);
}
Also used : TransactionDefinition(org.springframework.transaction.TransactionDefinition) Entity(org.molgenis.data.Entity) Test(org.testng.annotations.Test)

Example 15 with 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);
}
Also used : EntityType(org.molgenis.data.meta.model.EntityType) DynamicEntity(org.molgenis.data.support.DynamicEntity) Entity(org.molgenis.data.Entity) EntityManager(org.molgenis.data.EntityManager) Attribute(org.molgenis.data.meta.model.Attribute) Test(org.testng.annotations.Test)

Aggregations

Entity (org.molgenis.data.Entity)448 Test (org.testng.annotations.Test)295 DynamicEntity (org.molgenis.data.support.DynamicEntity)192 AbstractMolgenisSpringTest (org.molgenis.data.AbstractMolgenisSpringTest)120 Attribute (org.molgenis.data.meta.model.Attribute)111 EntityType (org.molgenis.data.meta.model.EntityType)110 AbstractMockitoTest (org.molgenis.test.AbstractMockitoTest)37 MolgenisDataException (org.molgenis.data.MolgenisDataException)20 QueryImpl (org.molgenis.data.support.QueryImpl)20 AttributeType (org.molgenis.data.meta.AttributeType)18 UnexpectedEnumException (org.molgenis.util.UnexpectedEnumException)18 Stream (java.util.stream.Stream)17 QueryRule (org.molgenis.data.QueryRule)16 MultiAllelicResultFilter (org.molgenis.data.annotation.core.filter.MultiAllelicResultFilter)16 RunAsSystem (org.molgenis.security.core.runas.RunAsSystem)16 Objects.requireNonNull (java.util.Objects.requireNonNull)15 DataService (org.molgenis.data.DataService)15 AttributeMapping (org.molgenis.semanticmapper.mapping.model.AttributeMapping)15 WithMockUser (org.springframework.security.test.context.support.WithMockUser)14 Instant (java.time.Instant)13