use of org.entando.entando.aps.system.services.widgettype.WidgetType in project entando-core by entando.
the class TestPageAction method testSavePage_Draft_2.
public void testSavePage_Draft_2() throws Throwable {
String pageCode = "pagina_test";
assertNull(this._pageManager.getDraftPage(pageCode));
try {
IPage root = this._pageManager.getDraftRoot();
Map<String, String> params = new HashMap<String, String>();
params.put("strutsAction", String.valueOf(ApsAdminSystemConstants.ADD));
params.put("parentPageCode", root.getCode());
params.put("langit", "Pagina Test 2");
params.put("langen", "Test Page 2");
params.put("model", "internal");
params.put("group", Group.FREE_GROUP_NAME);
params.put("pageCode", pageCode);
String result = this.executeSave(params, "admin");
assertEquals(Action.SUCCESS, result);
IPage addedPage = this._pageManager.getDraftPage(pageCode);
this.executeSetDefaultWidgets(params, "admin");
assertNotNull(addedPage);
assertEquals("Pagina Test 2", addedPage.getMetadata().getTitles().getProperty("it"));
Widget[] showlets = addedPage.getWidgets();
assertEquals(addedPage.getMetadata().getModel().getFrames().length, showlets.length);
for (int i = 0; i < showlets.length; i++) {
Widget widget = showlets[i];
if (i == 3) {
assertNotNull(widget);
WidgetType type = widget.getType();
assertEquals("leftmenu", type.getCode());
assertEquals(1, type.getTypeParameters().size());
assertNull(type.getConfig());
ApsProperties config = widget.getConfig();
assertEquals(1, config.size());
assertEquals("code(homepage).subtree(1)", config.getProperty("navSpec"));
} else {
assertNull(widget);
}
}
} catch (Throwable t) {
throw t;
} finally {
this._pageManager.deletePage(pageCode);
}
}
use of org.entando.entando.aps.system.services.widgettype.WidgetType in project entando-core by entando.
the class TestWidgetTypeAction method createNewLogicWidgetType.
private WidgetType createNewLogicWidgetType(String code) {
WidgetType type = this.createNewWidgetType(code);
WidgetType parent = this._widgetTypeManager.getWidgetType("content_viewer");
assertNotNull(parent);
type.setParentType(parent);
type.setPluginCode("jacms");
ApsProperties config = new ApsProperties();
config.put("contentId", "ART112");
type.setConfig(config);
return type;
}
use of org.entando.entando.aps.system.services.widgettype.WidgetType in project entando-core by entando.
the class TestWidgetTypeAction method testAddNewWidgetType.
// TODO ADD MORE TESTS for add new widget
public void testAddNewWidgetType() throws Throwable {
String widgetTypeCode = "randomWidgetCode_4";
List<String> fragmantCodes = null;
try {
assertNull(this._widgetTypeManager.getWidgetType(widgetTypeCode));
assertNull(this._guiFragmentManager.getGuiFragment(widgetTypeCode));
String result = this.executeAddWidgetType("admin", widgetTypeCode, "**GUI**");
assertEquals(Action.SUCCESS, result);
WidgetType addedType = this._widgetTypeManager.getWidgetType(widgetTypeCode);
assertNotNull(addedType);
FieldSearchFilter filterByType = new FieldSearchFilter("widgettypecode", widgetTypeCode, false);
FieldSearchFilter[] filters = { filterByType };
fragmantCodes = this._guiFragmentManager.searchGuiFragments(filters);
assertNotNull(fragmantCodes);
assertEquals(1, fragmantCodes.size());
assertEquals(widgetTypeCode, fragmantCodes.get(0));
GuiFragment guiFragment = this._guiFragmentManager.getGuiFragment(fragmantCodes.get(0));
assertNotNull(guiFragment);
assertEquals(widgetTypeCode, guiFragment.getWidgetTypeCode());
assertEquals("**GUI**", guiFragment.getGui());
assertFalse(guiFragment.isLocked());
} catch (Throwable t) {
throw t;
} finally {
if (null != fragmantCodes) {
for (int i = 0; i < fragmantCodes.size(); i++) {
String code = fragmantCodes.get(i);
this._guiFragmentManager.deleteGuiFragment(code);
}
}
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_2.
public void testUpdate_2() throws Throwable {
String widgetTypeCode = "test_widgetType_Upd2";
assertNull(this._widgetTypeManager.getWidgetType(widgetTypeCode));
List<String> fragmentCodes = this._guiFragmentManager.getGuiFragmentCodesByWidgetType(widgetTypeCode);
assertEquals(0, fragmentCodes.size());
try {
WidgetType type = this.createNewWidgetType(widgetTypeCode);
this._widgetTypeManager.addWidgetType(type);
String result = this.executeUpdate(widgetTypeCode, "", "", "admin", null);
assertEquals(Action.INPUT, result);
fragmentCodes = this._guiFragmentManager.getGuiFragmentCodesByWidgetType(widgetTypeCode);
assertEquals(0, fragmentCodes.size());
ActionSupport action = this.getAction();
assertEquals(3, action.getFieldErrors().size());
assertEquals(1, action.getFieldErrors().get("gui").size());
result = this.executeUpdate(widgetTypeCode, "Titolo modificato", "Modified title", "admin", "** 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"));
fragmentCodes = this._guiFragmentManager.getGuiFragmentCodesByWidgetType(widgetTypeCode);
assertEquals(1, 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 TestWidgetTypeAction method testAddNewUserWidgetType.
public void testAddNewUserWidgetType() throws Throwable {
String widgetTypeCode = "randomWidgetCode_3";
try {
this.setUserOnSession("admin");
this.initAction("/do/Portal/WidgetType", "save");
this.addParameter("widgetTypeCode", widgetTypeCode);
this.addParameter("englishTitle", "en");
this.addParameter("italianTitle", "it");
this.addParameter("parentWidgetTypeCode", "content_viewer_list");
this.addParameter("strutsAction", WidgetTypeAction.NEW_USER_WIDGET);
this.addParameter("maxElemForItem", "5");
this.addParameter("contentType", "EVN");
String result = this.executeAction();
assertEquals(Action.SUCCESS, result);
WidgetType addedType = this._widgetTypeManager.getWidgetType(widgetTypeCode);
assertNotNull(addedType);
ApsProperties config = addedType.getConfig();
assertEquals(2, config.size());
assertEquals("EVN", config.getProperty("contentType"));
assertEquals("5", config.getProperty("maxElemForItem"));
} catch (Throwable t) {
throw t;
} finally {
this._widgetTypeManager.deleteWidgetType(widgetTypeCode);
}
}
Aggregations