use of org.molgenis.metadata.manager.model.EditorEntityTypeParent in project molgenis by molgenis.
the class EntityTypeParentMapperTest method testToEntityTypeReference.
@Test
public void testToEntityTypeReference() {
String id = "id";
String label = "label";
@SuppressWarnings("unchecked") List<EditorAttributeIdentifier> attributes = mock(List.class);
EditorEntityTypeParent parent = mock(EditorEntityTypeParent.class);
EditorEntityTypeParent editorEntityTypeParent = EditorEntityTypeParent.create(id, label, attributes, parent);
EntityType entityType = entityTypeParentMapper.toEntityTypeReference(editorEntityTypeParent);
assertEquals(entityType.getIdValue(), id);
}
use of org.molgenis.metadata.manager.model.EditorEntityTypeParent in project molgenis by molgenis.
the class EntityTypeParentMapperTest method testToEditorEntityTypeParent.
@Test
public void testToEditorEntityTypeParent() {
String parentId = "parentId";
String parentLabel = "parentLabel";
EntityType parentEntityType = mock(EntityType.class);
when(parentEntityType.getId()).thenReturn(parentId);
when(parentEntityType.getLabel()).thenReturn(parentLabel);
@SuppressWarnings("unchecked") Iterable<Attribute> parentAttributes = mock(Iterable.class);
when(parentEntityType.getOwnAllAttributes()).thenReturn(parentAttributes);
String id = "id";
String label = "label";
EntityType entityType = mock(EntityType.class);
when(entityType.getId()).thenReturn(id);
when(entityType.getLabel()).thenReturn(label);
@SuppressWarnings("unchecked") Iterable<Attribute> attributes = mock(Iterable.class);
when(entityType.getOwnAllAttributes()).thenReturn(attributes);
when(entityType.getExtends()).thenReturn(parentEntityType);
@SuppressWarnings("unchecked") ImmutableList<EditorAttributeIdentifier> editorAttributes = mock(ImmutableList.class);
when(attributeReferenceMapper.toEditorAttributeIdentifiers(attributes)).thenReturn(editorAttributes);
@SuppressWarnings("unchecked") ImmutableList<EditorAttributeIdentifier> parentEditorAttributes = mock(ImmutableList.class);
when(attributeReferenceMapper.toEditorAttributeIdentifiers(parentAttributes)).thenReturn(parentEditorAttributes);
EditorEntityTypeParent editorEntityTypeParent = entityTypeParentMapper.toEditorEntityTypeParent(entityType);
EditorEntityTypeParent expectedEditorEntityTypeParent = EditorEntityTypeParent.create(id, label, editorAttributes, EditorEntityTypeParent.create(parentId, parentLabel, parentEditorAttributes, null));
assertEquals(editorEntityTypeParent, expectedEditorEntityTypeParent);
}
use of org.molgenis.metadata.manager.model.EditorEntityTypeParent in project molgenis by molgenis.
the class EntityTypeParentMapper method toEditorEntityTypeParent.
EditorEntityTypeParent toEditorEntityTypeParent(EntityType entityType) {
if (entityType == null) {
return null;
}
String id = entityType.getId();
String label = entityType.getLabel();
ImmutableList<EditorAttributeIdentifier> attributes = attributeReferenceMapper.toEditorAttributeIdentifiers(entityType.getOwnAllAttributes());
EditorEntityTypeParent parent = toEditorEntityTypeParent(entityType.getExtends());
return EditorEntityTypeParent.create(id, label, attributes, parent);
}
Aggregations