Search in sources :

Example 1 with EditorEntityTypeParent

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);
}
Also used : EntityType(org.molgenis.data.meta.model.EntityType) EditorAttributeIdentifier(org.molgenis.metadata.manager.model.EditorAttributeIdentifier) EditorEntityTypeParent(org.molgenis.metadata.manager.model.EditorEntityTypeParent) Test(org.testng.annotations.Test)

Example 2 with EditorEntityTypeParent

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);
}
Also used : EntityType(org.molgenis.data.meta.model.EntityType) EditorAttributeIdentifier(org.molgenis.metadata.manager.model.EditorAttributeIdentifier) Attribute(org.molgenis.data.meta.model.Attribute) EditorEntityTypeParent(org.molgenis.metadata.manager.model.EditorEntityTypeParent) Test(org.testng.annotations.Test)

Example 3 with EditorEntityTypeParent

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);
}
Also used : EditorAttributeIdentifier(org.molgenis.metadata.manager.model.EditorAttributeIdentifier) EditorEntityTypeParent(org.molgenis.metadata.manager.model.EditorEntityTypeParent)

Aggregations

EditorAttributeIdentifier (org.molgenis.metadata.manager.model.EditorAttributeIdentifier)3 EditorEntityTypeParent (org.molgenis.metadata.manager.model.EditorEntityTypeParent)3 EntityType (org.molgenis.data.meta.model.EntityType)2 Test (org.testng.annotations.Test)2 Attribute (org.molgenis.data.meta.model.Attribute)1