use of com.opensymphony.xwork2.ActionSupport 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 com.opensymphony.xwork2.ActionSupport in project entando-core by entando.
the class TestNavigatorWidgetConfigAction method testFailureAddExpression_2.
public void testFailureAddExpression_2() throws Throwable {
Map<String, String> params = new HashMap<String, String>();
params.put("pageCode", "pagina_2");
params.put("frame", "3");
params.put("widgetTypeCode", "leftmenu");
params.put("navSpec", "parent.subtree(2)+abs(1).subtree(2)+current");
params.put("specId", "3");
params.put("specSuperLevel", "-2");
String result = this.executeAddExpression("admin", params);
assertEquals(Action.INPUT, result);
ActionSupport action = this.getAction();
assertEquals(1, action.getActionErrors().size());
NavigatorWidgetConfigAction navAction = (NavigatorWidgetConfigAction) action;
Widget widget = navAction.getWidget();
assertNotNull(widget);
ApsProperties props = widget.getConfig();
assertEquals(0, props.size());
assertEquals("parent.subtree(2)+abs(1).subtree(2)+current", navAction.getNavSpec());
assertEquals(3, navAction.getExpressions().size());
}
use of com.opensymphony.xwork2.ActionSupport in project entando-core by entando.
the class TestContentAction method testValidate_3.
public void testValidate_3() throws Throwable {
// Description maxlength
String contentTypeCode = "ART";
String contentOnSessionMarker = this.extractSessionMarker(contentTypeCode, ApsAdminSystemConstants.ADD);
String marker = "__DESCR_TEST__";
String insertedDescr = marker;
while (insertedDescr.length() < 300) {
insertedDescr += marker;
}
try {
String result = this.executeCreateNewVoid(contentTypeCode, "descr", Content.STATUS_DRAFT, Group.FREE_GROUP_NAME, "admin");
assertEquals(Action.SUCCESS, result);
Content contentOnSession = this.getContentOnEdit(contentOnSessionMarker);
assertNotNull(contentOnSession);
this.initContentAction("/do/jacms/Content", "save", contentOnSessionMarker);
this.setUserOnSession("admin");
this.addParameter("descr", insertedDescr);
result = this.executeAction();
assertEquals(Action.INPUT, result);
ActionSupport action = this.getAction();
Map<String, List<String>> fieldErros = action.getFieldErrors();
assertEquals(2, fieldErros.size());
List<String> descrFieldsErrors = fieldErros.get("descr");
assertEquals(1, descrFieldsErrors.size());
List<String> titleFieldsErrors = fieldErros.get("Text:it_Titolo");
assertEquals(1, titleFieldsErrors.size());
} catch (Throwable t) {
throw t;
} finally {
this.removeTestContent(insertedDescr);
}
}
use of com.opensymphony.xwork2.ActionSupport in project entando-core by entando.
the class TestContentAction method testValidate_5.
public void testValidate_5() throws Throwable {
String contentTypeCode = "RAH";
String contentOnSessionMarker = this.extractSessionMarker(contentTypeCode, ApsAdminSystemConstants.ADD);
String insertedDescr = "XXX Prova Validazione XXX";
String shortTitle = "short";
String longTitle = "Titolo che supera la lunghezza massima di cento caratteri; " + "Ripeto, Titolo che supera la lunghezza massima di cento caratteri";
try {
String result = this.executeCreateNewVoid(contentTypeCode, "descr", Content.STATUS_DRAFT, Group.FREE_GROUP_NAME, "admin");
assertEquals(Action.SUCCESS, result);
Content contentOnSession = this.getContentOnEdit(contentOnSessionMarker);
assertNotNull(contentOnSession);
this.initContentAction("/do/jacms/Content", "save", contentOnSessionMarker);
this.setUserOnSession("admin");
this.addParameter("descr", insertedDescr);
this.addParameter("Text:it_Titolo", shortTitle);
result = this.executeAction();
assertEquals(Action.INPUT, result);
ActionSupport action = this.getAction();
Map<String, List<String>> fieldErros = action.getFieldErrors();
assertEquals(1, fieldErros.size());
List<String> titleItFieldErrors = fieldErros.get("Text:it_Titolo");
assertEquals(1, titleItFieldErrors.size());
this.initContentAction("/do/jacms/Content", "save", contentOnSessionMarker);
this.setUserOnSession("admin");
this.addParameter("mainGroup", Group.FREE_GROUP_NAME);
this.addParameter("descr", insertedDescr);
this.addParameter("Text:it_Titolo", longTitle);
result = this.executeAction();
assertEquals(Action.INPUT, result);
action = this.getAction();
fieldErros = action.getFieldErrors();
assertEquals(1, fieldErros.size());
titleItFieldErrors = fieldErros.get("Text:it_Titolo");
assertEquals(1, titleItFieldErrors.size());
this.initContentAction("/do/jacms/Content", "save", contentOnSessionMarker);
this.setUserOnSession("admin");
this.addParameter("mainGroup", Group.FREE_GROUP_NAME);
this.addParameter("descr", insertedDescr);
this.addParameter("Text:it_Titolo", "Right Title length");
this.addParameter("Text:en_Titolo", longTitle);
result = this.executeAction();
assertEquals(Action.INPUT, result);
action = this.getAction();
fieldErros = action.getFieldErrors();
assertEquals(1, fieldErros.size());
titleItFieldErrors = fieldErros.get("Text:en_Titolo");
assertEquals(1, titleItFieldErrors.size());
} catch (Throwable t) {
throw t;
} finally {
this.removeTestContent(insertedDescr);
}
}
use of com.opensymphony.xwork2.ActionSupport in project entando-core by entando.
the class TestContentAction method testSaveContentWithPageReference.
public void testSaveContentWithPageReference() throws Throwable {
String contentId = "ART111";
this.executeEdit(contentId, "admin");
Content master = this.getContentManager().loadContent(contentId, false);
String contentOnSessionMarker = AbstractContentAction.buildContentOnSessionMarker(master, ApsAdminSystemConstants.EDIT);
String groupToRemove = "customers";
try {
Content contentOnSession = this.getContentOnEdit(contentOnSessionMarker);
assertNotNull(contentOnSession);
assertEquals(2, contentOnSession.getGroups().size());
assertTrue(contentOnSession.getGroups().contains(groupToRemove));
this.initContentAction("/do/jacms/Content", "removeGroup", contentOnSessionMarker);
this.addParameter("extraGroupName", groupToRemove);
String result = this.executeAction();
assertEquals(Action.SUCCESS, result);
contentOnSession = this.getContentOnEdit(contentOnSessionMarker);
assertNotNull(contentOnSession);
assertEquals(1, contentOnSession.getGroups().size());
assertFalse(contentOnSession.getGroups().contains(groupToRemove));
this.initContentAction("/do/jacms/Content", "save", contentOnSessionMarker);
this.addParameter("descr", master.getDescription());
this.addParameter("mainGroup", master.getMainGroup());
this.addParameter("descr", master.getDescription());
result = this.executeAction();
assertEquals(Action.INPUT, result);
ActionSupport action = this.getAction();
Map<String, List<String>> fieldErrors = action.getFieldErrors();
assertEquals(1, fieldErrors.size());
List<String> mainGroupFieldErrors = (List<String>) fieldErrors.get("mainGroup");
assertEquals(2, mainGroupFieldErrors.size());
} catch (Throwable t) {
this.getContentManager().saveContent(master);
throw t;
}
}
Aggregations