Search in sources :

Example 1 with Structure

use of com.liferay.ide.portal.core.structures.model.Structure in project liferay-ide by liferay.

the class StructuresTests method testDocumentLibraryStructuresRead.

@Test
public void testDocumentLibraryStructuresRead() throws Exception {
    final Element element = getElementFromFile(getCurrentProject(), DOCUMENT_LIBRARY_STRUCTURES, Root.TYPE);
    setElement(element);
    final Root root = element.nearest(Root.class);
    assertNotNull(root);
    final ElementList<Structure> structures = root.getStructures();
    assertNotNull(structures);
    assertEquals(8, structures.size());
    final Structure structure = structures.get(2);
    assertNotNull(structure);
    assertEquals("Learning Module Metadata", structure.getName().content(false));
    assertEquals("Learning Module Metadata", structure.getDescription().content(false));
    final Root structureRoot = structure.getRoot().content(false);
    assertNotNull(structureRoot);
    assertEquals("[$LOCALE_DEFAULT$]", structureRoot.getAvailableLocales().content(false));
    assertEquals("[$LOCALE_DEFAULT$]", structureRoot.getDefaultLocale().content(false));
    final ElementList<DynamicElement> dynamicElements = structureRoot.getDynamicElements();
    assertNotNull(dynamicElements);
    assertEquals(4, dynamicElements.size());
    final DynamicElement dynamicElement = dynamicElements.get(1);
    assertNotNull(dynamicElement);
    assertEquals("string", dynamicElement.getDataType().content(false));
    assertEquals("keyword", dynamicElement.getIndexType().content(false));
    assertEquals(true, dynamicElement.isMultiple().content(false));
    assertEquals("select3212", dynamicElement.getName().content(false));
    assertEquals(false, dynamicElement.isReadOnly().content(false));
    assertEquals(false, dynamicElement.isRequired().content(false));
    assertEquals(true, dynamicElement.isShowLabel().content(false));
    assertEquals("select", dynamicElement.getType().content(false));
    final DynamicElementMetadata metadata = dynamicElement.getMetadata().content(false);
    assertNotNull(metadata);
    assertEquals("[$LOCALE_DEFAULT$]", metadata.getLocale().content(false));
    final ElementList<Entry> entries = metadata.getEntries();
    assertNotNull(entries);
    assertEquals(3, entries.size());
    final ElementList<DynamicElement> childDynamicElements = dynamicElement.getDynamicElements();
    assertNotNull(childDynamicElements);
    assertEquals(3, childDynamicElements.size());
    final DynamicElement childDynamicElement = childDynamicElements.get(1);
    assertNotNull(childDynamicElement);
    assertEquals("2_0", childDynamicElement.getName().content(false));
    assertEquals("option", childDynamicElement.getType().content(false));
    assertEquals("2", childDynamicElement.getValue().content(false));
    final DynamicElementMetadata childMetadata = childDynamicElement.getMetadata().content(false);
    assertNotNull(childMetadata);
    assertEquals("[$LOCALE_DEFAULT$]", childMetadata.getLocale().content(false));
    final ElementList<Entry> childEntries = childMetadata.getEntries();
    assertNotNull(childEntries);
    assertEquals(1, childEntries.size());
    final Entry childEntry = childEntries.get(0);
    assertNotNull(childEntry);
    assertEquals("label", childEntry.getName().content(false));
    assertEquals("2.0", childEntry.getValue().content(false));
}
Also used : Entry(com.liferay.ide.portal.core.structures.model.Entry) Root(com.liferay.ide.portal.core.structures.model.Root) DynamicElementMetadata(com.liferay.ide.portal.core.structures.model.DynamicElementMetadata) DynamicElement(com.liferay.ide.portal.core.structures.model.DynamicElement) DynamicElement(com.liferay.ide.portal.core.structures.model.DynamicElement) Element(org.eclipse.sapphire.Element) Structure(com.liferay.ide.portal.core.structures.model.Structure) Test(org.junit.Test)

Aggregations

DynamicElement (com.liferay.ide.portal.core.structures.model.DynamicElement)1 DynamicElementMetadata (com.liferay.ide.portal.core.structures.model.DynamicElementMetadata)1 Entry (com.liferay.ide.portal.core.structures.model.Entry)1 Root (com.liferay.ide.portal.core.structures.model.Root)1 Structure (com.liferay.ide.portal.core.structures.model.Structure)1 Element (org.eclipse.sapphire.Element)1 Test (org.junit.Test)1