Search in sources :

Example 51 with WidgetType

use of org.entando.entando.aps.system.services.widgettype.WidgetType in project entando-core by entando.

the class TestWidgetTypeManager method testGetWidgetType_1.

public void testGetWidgetType_1() throws ApsSystemException {
    WidgetType widgetType = _widgetTypeManager.getWidgetType("content_viewer");
    assertEquals("content_viewer", widgetType.getCode());
    assertEquals("Contenuti - Pubblica un Contenuto", widgetType.getTitles().get("it"));
    assertTrue(widgetType.isLocked());
    assertFalse(widgetType.isLogic());
    assertFalse(widgetType.isUserType());
    assertNull(widgetType.getParentType());
    assertNull(widgetType.getConfig());
    String action = widgetType.getAction();
    assertEquals(action, "viewerConfig");
    List<WidgetTypeParameter> list = widgetType.getTypeParameters();
    Iterator<WidgetTypeParameter> iter = list.iterator();
    Map<String, String> parameters = new HashMap<String, String>();
    while (iter.hasNext()) {
        WidgetTypeParameter parameter = (WidgetTypeParameter) iter.next();
        parameters.put(parameter.getName(), parameter.getDescr());
    }
    boolean containsKey = parameters.containsKey("contentId");
    boolean containsValue = parameters.containsValue("Identificativo del Contenuto");
    assertEquals(containsKey, true);
    assertEquals(containsValue, true);
    containsKey = parameters.containsKey("modelId");
    containsValue = parameters.containsValue("Identificativo del Modello di Contenuto");
    assertEquals(containsKey, true);
    assertEquals(containsValue, true);
}
Also used : HashMap(java.util.HashMap) WidgetType(org.entando.entando.aps.system.services.widgettype.WidgetType) WidgetTypeParameter(org.entando.entando.aps.system.services.widgettype.WidgetTypeParameter)

Example 52 with WidgetType

use of org.entando.entando.aps.system.services.widgettype.WidgetType in project entando-core by entando.

the class TestWidgetTypeManager method testGetWidgetType_2.

public void testGetWidgetType_2() throws ApsSystemException {
    WidgetType widgetType = _widgetTypeManager.getWidgetType("90_events");
    assertEquals("90_events", widgetType.getCode());
    assertEquals("Lista contenuti anni '90", widgetType.getTitles().get("it"));
    assertFalse(widgetType.isLocked());
    assertTrue(widgetType.isLogic());
    assertTrue(widgetType.isUserType());
    assertNull(widgetType.getAction());
    assertNull(widgetType.getTypeParameters());
    assertNotNull(widgetType.getParentType());
    assertEquals("content_viewer_list", widgetType.getParentType().getCode());
    assertNotNull(widgetType.getConfig());
    String contentTypeParam = widgetType.getConfig().getProperty("contentType");
    assertEquals("EVN", contentTypeParam);
    String filtersParam = widgetType.getConfig().getProperty("filters");
    assertTrue(filtersParam.contains("start=01/01/1990"));
}
Also used : WidgetType(org.entando.entando.aps.system.services.widgettype.WidgetType)

Example 53 with WidgetType

use of org.entando.entando.aps.system.services.widgettype.WidgetType in project entando-core by entando.

the class TestWidgetTypeManager method testAddDeleteWidgetType.

public void testAddDeleteWidgetType() throws Throwable {
    String widgetTypeCode = "test_widgetType";
    assertNull(this._widgetTypeManager.getWidgetType(widgetTypeCode));
    try {
        this._widgetTypeManager.deleteWidgetType(widgetTypeCode);
        WidgetType type = this.createNewWidgetType(widgetTypeCode);
        this._widgetTypeManager.addWidgetType(type);
        assertNotNull(this._widgetTypeManager.getWidgetType(widgetTypeCode));
    } catch (Throwable t) {
        throw t;
    } finally {
        if (null != this._widgetTypeManager.getWidgetType(widgetTypeCode)) {
            this._widgetTypeManager.deleteWidgetType(widgetTypeCode);
        }
        assertNull(this._widgetTypeManager.getWidgetType(widgetTypeCode));
    }
}
Also used : WidgetType(org.entando.entando.aps.system.services.widgettype.WidgetType)

Example 54 with WidgetType

use of org.entando.entando.aps.system.services.widgettype.WidgetType in project entando-core by entando.

the class TestWidgetTypeManager method testFailureDeleteWidgetType_2.

public void testFailureDeleteWidgetType_2() throws Throwable {
    String widgetTypeCode = "test_widgetType";
    assertNull(this._widgetTypeManager.getWidgetType(widgetTypeCode));
    try {
        WidgetType type = this.createNewWidgetType(widgetTypeCode);
        type.setLocked(true);
        this._widgetTypeManager.addWidgetType(type);
        assertNotNull(this._widgetTypeManager.getWidgetType(widgetTypeCode));
        try {
            this._widgetTypeManager.deleteWidgetType(widgetTypeCode);
            fail();
        } catch (Throwable t) {
            assertNotNull(this._widgetTypeManager.getWidgetType(widgetTypeCode));
        }
    } catch (Throwable t) {
        throw t;
    } finally {
        if (null != this._widgetTypeManager.getWidgetType(widgetTypeCode)) {
            this._mockWidgetTypeDAO.deleteWidgetType(widgetTypeCode);
        }
        ((IManager) this._widgetTypeManager).refresh();
        assertNull(this._widgetTypeManager.getWidgetType(widgetTypeCode));
    }
}
Also used : IManager(com.agiletec.aps.system.common.IManager) WidgetType(org.entando.entando.aps.system.services.widgettype.WidgetType)

Example 55 with WidgetType

use of org.entando.entando.aps.system.services.widgettype.WidgetType in project entando-core by entando.

the class TestWidgetTypeManager method testUpdateTitles.

public void testUpdateTitles() throws Throwable {
    String widgetTypeCode = "test_widgetType";
    assertNull(this._widgetTypeManager.getWidgetType(widgetTypeCode));
    try {
        WidgetType type = this.createNewWidgetType(widgetTypeCode);
        this._widgetTypeManager.addWidgetType(type);
        WidgetType extracted = this._widgetTypeManager.getWidgetType(widgetTypeCode);
        assertNotNull(extracted);
        assertEquals("Titolo", extracted.getTitles().get("it"));
        assertEquals("Title", extracted.getTitles().get("en"));
        ApsProperties newTitles = new ApsProperties();
        newTitles.put("it", "Titolo modificato");
        newTitles.put("en", "Modified title");
        this._widgetTypeManager.updateWidgetType(widgetTypeCode, newTitles, type.getConfig(), type.getMainGroup());
        extracted = this._widgetTypeManager.getWidgetType(widgetTypeCode);
        assertNotNull(extracted);
        assertEquals("Titolo modificato", extracted.getTitles().get("it"));
        assertEquals("Modified title", extracted.getTitles().get("en"));
    } catch (Throwable t) {
        throw t;
    } finally {
        if (null != this._widgetTypeManager.getWidgetType(widgetTypeCode)) {
            this._widgetTypeManager.deleteWidgetType(widgetTypeCode);
        }
        assertNull(this._widgetTypeManager.getWidgetType(widgetTypeCode));
    }
}
Also used : WidgetType(org.entando.entando.aps.system.services.widgettype.WidgetType) ApsProperties(com.agiletec.aps.util.ApsProperties)

Aggregations

WidgetType (org.entando.entando.aps.system.services.widgettype.WidgetType)70 ApsProperties (com.agiletec.aps.util.ApsProperties)33 Widget (com.agiletec.aps.system.services.page.Widget)20 IPage (com.agiletec.aps.system.services.page.IPage)11 GuiFragment (org.entando.entando.aps.system.services.guifragment.GuiFragment)10 ApiException (org.entando.entando.aps.system.services.api.model.ApiException)9 ArrayList (java.util.ArrayList)8 HashMap (java.util.HashMap)5 WidgetTypeParameter (org.entando.entando.aps.system.services.widgettype.WidgetTypeParameter)5 ActionSupport (com.opensymphony.xwork2.ActionSupport)4 IManager (com.agiletec.aps.system.common.IManager)3 ApsSystemException (com.agiletec.aps.system.exception.ApsSystemException)3 Lang (com.agiletec.aps.system.services.lang.Lang)3 List (java.util.List)3 JAXBGuiFragment (org.entando.entando.aps.system.services.guifragment.api.JAXBGuiFragment)3 IWidgetTypeManager (org.entando.entando.aps.system.services.widgettype.IWidgetTypeManager)3 ILangManager (com.agiletec.aps.system.services.lang.ILangManager)2 SelectItem (com.agiletec.aps.util.SelectItem)2 Properties (java.util.Properties)2 ApiMethod (org.entando.entando.aps.system.services.api.model.ApiMethod)2