use of org.molgenis.data.meta.model.Attribute in project molgenis by molgenis.
the class EntityUtilsTest method getMockAttr.
private Attribute getMockAttr(String toString) {
Attribute attr = getMockAttr();
when(attr.toString()).thenReturn(toString);
return attr;
}
use of org.molgenis.data.meta.model.Attribute in project molgenis by molgenis.
the class EntityUtilsTest method isEmptyAttributeValuesNotNull.
@Test
public void isEmptyAttributeValuesNotNull() {
EntityType entityType = when(mock(EntityType.class).getId()).thenReturn("entity").getMock();
Attribute attr = when(mock(Attribute.class).getName()).thenReturn("attr").getMock();
when(attr.getDataType()).thenReturn(STRING);
when(entityType.getAtomicAttributes()).thenReturn(singletonList(attr));
when(entityType.getAttribute("attr")).thenReturn(attr);
assertFalse(EntityUtils.isEmpty(new DynamicEntity(entityType, of("attr", "val"))));
}
use of org.molgenis.data.meta.model.Attribute in project molgenis by molgenis.
the class EntityTypeUtilsTest method isMultipleReferenceTypeProvider.
@DataProvider(name = "isMultipleReferenceTypeProvider")
public static Iterator<Object[]> isMultipleReferenceTypeProvider() {
List<Object[]> dataList = Lists.newArrayList();
for (AttributeType attrType : AttributeType.values()) {
Attribute attr = mock(Attribute.class);
when(attr.getDataType()).thenReturn(attrType);
when(attr.toString()).thenReturn("attr_" + attrType.toString());
boolean isMultipleRefAttr = attrType == CATEGORICAL_MREF || attrType == MREF || attrType == ONE_TO_MANY;
dataList.add(new Object[] { attr, isMultipleRefAttr });
}
return dataList.iterator();
}
use of org.molgenis.data.meta.model.Attribute in project molgenis by molgenis.
the class EntityTypeUtilsTest method getAttributeNames.
@Test
public void getAttributeNames() {
Attribute attr0 = when(mock(Attribute.class).getName()).thenReturn("attr0").getMock();
Attribute attr1 = when(mock(Attribute.class).getName()).thenReturn("attr1").getMock();
assertEquals(newArrayList(EntityTypeUtils.getAttributeNames(asList(attr0, attr1))), asList("attr0", "attr1"));
}
use of org.molgenis.data.meta.model.Attribute in project molgenis by molgenis.
the class MapOfStringsExpressionEvaluatorTest method testMapOfStringsEvaluatorConstructorChecksIfAttributeHasRefEntity.
@Test
public void testMapOfStringsEvaluatorConstructorChecksIfAttributeHasRefEntity() {
Attribute amd = when(mock(Attribute.class).getName()).thenReturn("location").getMock();
when(amd.getDataType()).thenReturn(XREF);
when(amd.getExpression()).thenReturn("{'a':b}");
try {
new MapOfStringsExpressionEvaluator(amd, emd);
fail("Expected IllegalArgumentException.");
} catch (NullPointerException expected) {
assertEquals(expected.getMessage(), "refEntity not specified.");
}
}
Aggregations