Search in sources :

Example 1 with EditorAttributeIdentifier

use of org.molgenis.metadata.manager.model.EditorAttributeIdentifier in project molgenis by molgenis.

the class AttributeReferenceMapperTest method testToAttributeReference.

@Test
public void testToAttributeReference() {
    String id = "id";
    String label = "label";
    EditorAttributeIdentifier editorAttributeIdentifier = EditorAttributeIdentifier.create(id, label);
    Attribute attribute = attributeReferenceMapper.toAttributeReference(editorAttributeIdentifier);
    assertEquals(attribute.getIdValue(), id);
}
Also used : EditorAttributeIdentifier(org.molgenis.metadata.manager.model.EditorAttributeIdentifier) Attribute(org.molgenis.data.meta.model.Attribute) Test(org.testng.annotations.Test)

Example 2 with EditorAttributeIdentifier

use of org.molgenis.metadata.manager.model.EditorAttributeIdentifier 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 3 with EditorAttributeIdentifier

use of org.molgenis.metadata.manager.model.EditorAttributeIdentifier in project molgenis by molgenis.

the class AttributeReferenceMapperTest method testToEditorAttributeIdentifier.

@Test
public void testToEditorAttributeIdentifier() {
    String id = "id";
    String label = "label";
    String entityTypeId = "id";
    String entityTypeLabel = "label";
    Attribute attribute = mock(Attribute.class);
    EntityType entityType = mock(EntityType.class);
    when(attribute.getIdentifier()).thenReturn(id);
    when(attribute.getLabel()).thenReturn(label);
    when(attribute.getEntity()).thenReturn(entityType);
    when(entityType.getId()).thenReturn(entityTypeId);
    when(entityType.getLabel()).thenReturn(entityTypeLabel);
    EditorAttributeIdentifier editorAttributeIdentifier = attributeReferenceMapper.toEditorAttributeIdentifier(attribute);
    EditorEntityTypeIdentifier editorEntityTypeIdentifier = EditorEntityTypeIdentifier.create(entityTypeId, entityTypeLabel);
    assertEquals(editorAttributeIdentifier, EditorAttributeIdentifier.create(id, label, editorEntityTypeIdentifier));
}
Also used : EntityType(org.molgenis.data.meta.model.EntityType) EditorEntityTypeIdentifier(org.molgenis.metadata.manager.model.EditorEntityTypeIdentifier) EditorAttributeIdentifier(org.molgenis.metadata.manager.model.EditorAttributeIdentifier) Attribute(org.molgenis.data.meta.model.Attribute) Test(org.testng.annotations.Test)

Example 4 with EditorAttributeIdentifier

use of org.molgenis.metadata.manager.model.EditorAttributeIdentifier in project molgenis by molgenis.

the class AttributeReferenceMapperTest method testToEditorAttributeIdentifiers.

@Test
public void testToEditorAttributeIdentifiers() {
    String id = "id";
    String label = "label";
    String entityTypeId = "id";
    String entityTypeLabel = "label";
    Attribute attribute = mock(Attribute.class);
    EntityType entityType = mock(EntityType.class);
    when(attribute.getIdentifier()).thenReturn(id);
    when(attribute.getLabel()).thenReturn(label);
    when(attribute.getEntity()).thenReturn(entityType);
    when(entityType.getId()).thenReturn(entityTypeId);
    when(entityType.getLabel()).thenReturn(entityTypeLabel);
    ImmutableList<EditorAttributeIdentifier> editorAttributeIdentifier = attributeReferenceMapper.toEditorAttributeIdentifiers(of(attribute));
    EditorEntityTypeIdentifier editorEntityTypeIdentifier = EditorEntityTypeIdentifier.create(entityTypeId, entityTypeLabel);
    assertEquals(editorAttributeIdentifier, of(EditorAttributeIdentifier.create(id, label, editorEntityTypeIdentifier)));
}
Also used : EntityType(org.molgenis.data.meta.model.EntityType) EditorEntityTypeIdentifier(org.molgenis.metadata.manager.model.EditorEntityTypeIdentifier) EditorAttributeIdentifier(org.molgenis.metadata.manager.model.EditorAttributeIdentifier) Attribute(org.molgenis.data.meta.model.Attribute) Test(org.testng.annotations.Test)

Example 5 with EditorAttributeIdentifier

use of org.molgenis.metadata.manager.model.EditorAttributeIdentifier 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)

Aggregations

EditorAttributeIdentifier (org.molgenis.metadata.manager.model.EditorAttributeIdentifier)6 Test (org.testng.annotations.Test)5 Attribute (org.molgenis.data.meta.model.Attribute)4 EntityType (org.molgenis.data.meta.model.EntityType)4 EditorEntityTypeParent (org.molgenis.metadata.manager.model.EditorEntityTypeParent)3 EditorEntityTypeIdentifier (org.molgenis.metadata.manager.model.EditorEntityTypeIdentifier)2