use of org.molgenis.data.EntityManager in project molgenis by molgenis.
the class EntityUtilsTest method getTypedValueStringAttributeEntityManagerOneToMany.
@Test
public void getTypedValueStringAttributeEntityManagerOneToMany() {
String valueStr = "0,1,2";
Attribute attr = mock(Attribute.class);
EntityType refEntityType = mock(EntityType.class);
Attribute refIdAttr = mock(Attribute.class);
when(refIdAttr.getDataType()).thenReturn(INT);
when(refEntityType.getIdAttribute()).thenReturn(refIdAttr);
when(attr.getRefEntity()).thenReturn(refEntityType);
when(attr.getDataType()).thenReturn(ONE_TO_MANY);
EntityManager entityManager = mock(EntityManager.class);
Entity entity0 = mock(Entity.class);
Entity entity1 = mock(Entity.class);
Entity entity2 = mock(Entity.class);
when(entityManager.getReference(refEntityType, 0)).thenReturn(entity0);
when(entityManager.getReference(refEntityType, 1)).thenReturn(entity1);
when(entityManager.getReference(refEntityType, 2)).thenReturn(entity2);
assertEquals(EntityUtils.getTypedValue(valueStr, attr, entityManager), newArrayList(entity0, entity1, entity2));
}
Aggregations