use of org.entando.entando.aps.system.services.widgettype.WidgetType in project entando-core by entando.
the class TestWidgetTypeAction method testFailureTrashType_2.
public void testFailureTrashType_2() throws Throwable {
String widgetTypeCode = "test_widgetType_trash2";
assertNull(this._widgetTypeManager.getWidgetType(widgetTypeCode));
try {
WidgetType type = this.createNewLogicWidgetType(widgetTypeCode);
type.setLocked(true);
this._widgetTypeManager.addWidgetType(type);
assertNotNull(this._widgetTypeManager.getWidgetType(widgetTypeCode));
String result = this.executeTrash(widgetTypeCode, "admin");
assertEquals("inputWidgetTypes", result);
ActionSupport action = this.getAction();
assertEquals(1, action.getActionErrors().size());
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));
}
}
use of org.entando.entando.aps.system.services.widgettype.WidgetType in project entando-core by entando.
the class TestWidgetTypeAction method testPasteNewUserWidgetType_1.
public void testPasteNewUserWidgetType_1() throws Throwable {
String widgetTypeCode = "randomShowletCode_1";
try {
assertNull(this._widgetTypeManager.getWidgetType(widgetTypeCode));
String result = this.executePasteUserWidgetType("admin", widgetTypeCode, "en", "it", "customers_page", "2");
assertEquals(Action.SUCCESS, result);
Widget copiedWidget = this._pageManager.getDraftPage("customers_page").getWidgets()[2];
assertNotNull(copiedWidget);
assertNotNull(copiedWidget.getConfig());
WidgetType addedType = this._widgetTypeManager.getWidgetType(widgetTypeCode);
assertNotNull(addedType);
ApsProperties config = addedType.getConfig();
Iterator<Object> keysIter = config.keySet().iterator();
while (keysIter.hasNext()) {
String key = (String) keysIter.next();
assertEquals(copiedWidget.getConfig().getProperty(key), config.getProperty(key));
}
} catch (Throwable t) {
throw t;
} finally {
this._widgetTypeManager.deleteWidgetType(widgetTypeCode);
}
}
use of org.entando.entando.aps.system.services.widgettype.WidgetType in project entando-core by entando.
the class TestWidgetTypeAction method testUpdate_3.
public void testUpdate_3() throws Throwable {
String widgetTypeCode = "test_widgetType_Upd3";
assertNull(this._widgetTypeManager.getWidgetType(widgetTypeCode));
try {
WidgetType type = this.createNewLogicWidgetType(widgetTypeCode);
this._widgetTypeManager.addWidgetType(type);
ApsProperties newProperties = new ApsProperties();
newProperties.put("contentId", "EVN191");
String result = this.executeUpdate(widgetTypeCode, "Titolo modificato", "Modified title", "admin", newProperties, "**GUI**");
assertEquals(Action.SUCCESS, result);
WidgetType extracted = this._widgetTypeManager.getWidgetType(widgetTypeCode);
assertNotNull(extracted);
assertEquals("Titolo modificato", extracted.getTitles().get("it"));
assertEquals("Modified title", extracted.getTitles().get("en"));
assertEquals("EVN191", extracted.getConfig().getProperty("contentId"));
newProperties.put("contentId", "EVN194");
result = this.executeUpdate(widgetTypeCode, "Titolo modificato 2", "Modified title 2", "pageManagerCoach", newProperties, "*GUI*");
assertEquals(Action.SUCCESS, result);
extracted = this._widgetTypeManager.getWidgetType(widgetTypeCode);
assertNotNull(extracted);
assertEquals("Titolo modificato 2", extracted.getTitles().get("it"));
assertEquals("Modified title 2", extracted.getTitles().get("en"));
assertEquals("EVN191", extracted.getConfig().getProperty("contentId"));
} catch (Throwable t) {
throw t;
} finally {
this.cleanDatabase(widgetTypeCode);
}
}
use of org.entando.entando.aps.system.services.widgettype.WidgetType in project entando-core by entando.
the class TestWidgetTypeAction method testUpdate_1.
public void testUpdate_1() throws Throwable {
String widgetTypeCode = "test_widgetType_Upd1";
assertNull(this._widgetTypeManager.getWidgetType(widgetTypeCode));
List<String> fragmentCodes = this._guiFragmentManager.getGuiFragmentCodesByWidgetType(widgetTypeCode);
assertEquals(0, fragmentCodes.size());
try {
WidgetType type = this.createNewLogicWidgetType(widgetTypeCode);
this._widgetTypeManager.addWidgetType(type);
String result = this.executeUpdate(widgetTypeCode, "", "english title", "admin", null);
assertEquals(Action.INPUT, result);
fragmentCodes = this._guiFragmentManager.getGuiFragmentCodesByWidgetType(widgetTypeCode);
assertEquals(0, fragmentCodes.size());
ActionSupport action = this.getAction();
assertEquals(1, action.getFieldErrors().size());
result = this.executeUpdate(widgetTypeCode, "Titolo modificato", "Modified title", "admin", null);
assertEquals(Action.SUCCESS, result);
WidgetType extracted = this._widgetTypeManager.getWidgetType(widgetTypeCode);
assertNotNull(extracted);
assertEquals("Titolo modificato", extracted.getTitles().get("it"));
assertEquals("Modified title", extracted.getTitles().get("en"));
fragmentCodes = this._guiFragmentManager.getGuiFragmentCodesByWidgetType(widgetTypeCode);
assertEquals(0, fragmentCodes.size());
} catch (Throwable t) {
throw t;
} finally {
this.cleanDatabase(widgetTypeCode);
}
}
use of org.entando.entando.aps.system.services.widgettype.WidgetType in project entando-core by entando.
the class PageModelDOM method buildDefaultWidget.
private void buildDefaultWidget(Frame frame, Element defaultWidgetElement, int pos, IWidgetTypeManager widgetTypeManager) {
Widget widget = new Widget();
String widgetCode = defaultWidgetElement.getAttributeValue(ATTRIBUTE_CODE);
WidgetType type = widgetTypeManager.getWidgetType(widgetCode);
if (null == type) {
_logger.error("Unknown code of the default widget - '{}'", widgetCode);
return;
}
widget.setType(type);
Element propertiesElement = defaultWidgetElement.getChild(TAB_PROPERTIES);
if (null != propertiesElement) {
ApsProperties prop = this.buildProperties(propertiesElement);
widget.setConfig(prop);
}
// else {
// widget.setConfig(new ApsProperties());
// }
frame.setDefaultWidget(widget);
}
Aggregations