Search in sources :

Example 1 with DynamicElement

use of com.liferay.ide.portal.core.structures.model.DynamicElement 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)

Example 2 with DynamicElement

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

the class StructuresTests method testDDMStructureBasicDocumentRead.

@Test
public void testDDMStructureBasicDocumentRead() throws Exception {
    final Element element = getElementFromFile(getCurrentProject(), DDM_STRUCTURE_BASIC_DOCUMENT, Root.TYPE);
    setElement(element);
    final Root root = element.nearest(Root.class);
    assertNotNull(root);
    assertEquals("en_US", root.getAvailableLocales().content());
    assertEquals("en_US", root.getDefaultLocale().content());
    final ElementList<DynamicElement> dynamicElements = root.getDynamicElements();
    assertEquals(154, dynamicElements.size());
    final DynamicElement dynamicElement = dynamicElements.get(1);
    assertNotNull(dynamicElement);
    assertEquals("string", dynamicElement.getDataType().content(false));
    assertEquals("ClimateForcast_COMMAND_LINE", dynamicElement.getName().content(false));
    assertEquals("text", dynamicElement.getType().content(false));
    final DynamicElementMetadata metaData = dynamicElement.getMetadata().content(false);
    assertNotNull(metaData);
    assertEquals("en_US", metaData.getLocale().content(false));
    final ElementList<Entry> entries = metaData.getEntries();
    assertNotNull(entries);
    assertEquals(4, entries.size());
    final Entry entry = entries.get(2);
    assertNotNull(entry);
    assertEquals("required", entry.getName().content(false));
    assertEquals("false", entry.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) Test(org.junit.Test)

Aggregations

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