use of com.opensymphony.xwork2.ActionSupport in project entando-core by entando.
the class TestRoleAction method testFailureSave.
public void testFailureSave() throws Throwable {
this.executeNew("admin");
String[] permissions = { "editContents" };
// permessi non disponibili
String result = this.executeSaveNew("developersConf", "roleName", "description", permissions);
assertEquals("apslogin", result);
// roleName giĆ esistente
result = this.executeSaveNew("admin", "editor", "description", permissions);
assertEquals(Action.INPUT, result);
ActionSupport action = this.getAction();
Map<String, List<String>> fieldErrors = action.getFieldErrors();
assertEquals(1, fieldErrors.size());
List<String> errors = fieldErrors.get("name");
assertEquals(1, errors.size());
// description non valorizzato
result = this.executeSaveNew("admin", "roleName", "", permissions);
assertEquals(Action.INPUT, result);
fieldErrors = this.getAction().getFieldErrors();
assertEquals(1, fieldErrors.size());
errors = fieldErrors.get("description");
assertEquals(1, errors.size());
// name e description non valorizzati
result = this.executeSaveNew("admin", "", "", permissions);
assertEquals(Action.INPUT, result);
fieldErrors = this.getAction().getFieldErrors();
assertEquals(2, fieldErrors.size());
errors = fieldErrors.get("name");
assertEquals(1, errors.size());
errors = fieldErrors.get("description");
assertEquals(1, errors.size());
// name troppo lungo
result = this.executeSaveNew("admin", "roleNameDecisamenteTroppoLungo", "description", permissions);
assertEquals(Action.INPUT, result);
fieldErrors = this.getAction().getFieldErrors();
assertEquals(1, fieldErrors.size());
errors = fieldErrors.get("name");
assertEquals(1, errors.size());
}
use of com.opensymphony.xwork2.ActionSupport in project entando-core by entando.
the class TestContentAction method testValidate_4.
/*
* We test, among other things the CheckBox attribute
*/
public void testValidate_4() throws Throwable {
String contentTypeCode = "RAH";
String contentOnSessionMarker = this.extractSessionMarker(contentTypeCode, ApsAdminSystemConstants.ADD);
String insertedDescr = "XXX Prova Validazione XXX";
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("Monotext:email", "wrongEmailAddress");
this.addParameter("Number:Numero", "wrongNumber");
this.addParameter("CheckBox:Checkbox", "true");
result = this.executeAction();
assertEquals(Action.INPUT, result);
ActionSupport action = this.getAction();
Map<String, List<String>> fieldErros = action.getFieldErrors();
assertEquals(2, fieldErros.size());
List<String> emailFieldErrors = fieldErros.get("Monotext:email");
assertEquals(1, emailFieldErrors.size());
List<String> numberFieldErrors = fieldErros.get("Number:Numero");
assertEquals(1, numberFieldErrors.size());
Content content = this.getContentOnEdit(contentOnSessionMarker);
assertNotNull(content);
assertTrue(content.getAttributeMap().containsKey("Checkbox"));
BooleanAttribute attribute = (BooleanAttribute) content.getAttribute("Checkbox");
assertNotNull(attribute);
assertEquals("CheckBox", attribute.getType());
assertEquals(Boolean.TRUE, attribute.getValue());
this.initContentAction("/do/jacms/Content", "save", contentOnSessionMarker);
this.setUserOnSession("admin");
this.addParameter("mainGroup", Group.FREE_GROUP_NAME);
this.addParameter("descr", insertedDescr);
this.addParameter("Monotext:email", "wrongEmailAddress");
this.addParameter("Number:Numero", "wrongNumber");
// LEAVING the Checkbox parameter will result in the checkbox attribute being later evaluated as 'false'
result = this.executeAction();
assertEquals(Action.INPUT, result);
content = this.getContentOnEdit(contentOnSessionMarker);
assertNotNull(content);
assertTrue(content.getAttributeMap().containsKey("Checkbox"));
attribute = (BooleanAttribute) content.getAttribute("Checkbox");
assertNotNull(attribute);
assertEquals("CheckBox", attribute.getType());
assertEquals(Boolean.FALSE, attribute.getValue());
} 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_6.
public void testValidate_6() throws Throwable {
String contentId = "ART112";
String contentOnSessionMarker = this.extractSessionMarker(contentId, ApsAdminSystemConstants.EDIT);
try {
this.initAction("/do/jacms/Content", "edit");
this.setUserOnSession("admin");
this.addParameter("contentId", contentId);
String result = this.executeAction();
assertEquals(Action.SUCCESS, result);
Content contentOnEdit = this.getContentOnEdit(contentOnSessionMarker);
assertNotNull(contentOnEdit);
assertEquals("coach", contentOnEdit.getMainGroup());
assertEquals(2, contentOnEdit.getGroups().size());
assertTrue(contentOnEdit.getGroups().contains("customers"));
assertTrue(contentOnEdit.getGroups().contains("helpdesk"));
this.initContentAction("/do/jacms/Content", "removeGroup", contentOnSessionMarker);
this.addParameter("extraGroupName", "customers");
this.addParameter("descr", contentOnEdit.getDescription());
result = this.executeAction();
assertEquals(Action.SUCCESS, result);
contentOnEdit = (Content) this.getRequest().getSession().getAttribute(ContentActionConstants.SESSION_PARAM_NAME_CURRENT_CONTENT_PREXIX + contentOnSessionMarker);
assertEquals(1, contentOnEdit.getGroups().size());
} catch (Throwable t) {
throw t;
}
Content mainContent = this.getContentManager().loadContent(contentId, true);
try {
this.initContentAction("/do/jacms/Content", "save", contentOnSessionMarker);
this.addParameter("descr", mainContent.getDescription());
String result = this.executeAction();
assertEquals(Action.INPUT, result);
ActionSupport action = this.getAction();
assertEquals(1, action.getFieldErrors().size());
assertEquals(1, action.getFieldErrors().get("mainGroup").size());
} catch (Throwable t) {
this.getContentManager().insertOnLineContent(mainContent);
throw t;
}
}
use of com.opensymphony.xwork2.ActionSupport in project entando-core by entando.
the class TestContentAction method testValidate_2.
public void testValidate_2() throws Throwable {
String insertedDescr = "XXX Prova Validazione XXX";
try {
Content contentForTest = this.getContentManager().loadContent("EVN191", true);
String contentOnSessionMarker = AbstractContentAction.buildContentOnSessionMarker(contentForTest, ApsAdminSystemConstants.EDIT);
contentForTest.setId(null);
contentForTest.setDescription(insertedDescr);
// Valorizzo il gruppo proprietario
contentForTest.setMainGroup("coach");
contentForTest.getGroups().add("customers");
// AGGIUNGO LINK SU PAGINA COACH
MonoListAttribute linksCorrelati = (MonoListAttribute) contentForTest.getAttribute("LinkCorrelati");
LinkAttribute linkAttribute = (LinkAttribute) linksCorrelati.addAttribute();
linkAttribute.setText("Descrizione link", "it");
SymbolicLink symbolicLink = new SymbolicLink();
// Contenuto di coach
symbolicLink.setDestinationToContent("EVN103");
linkAttribute.setSymbolicLink(symbolicLink);
this.getRequest().getSession().setAttribute(ContentActionConstants.SESSION_PARAM_NAME_CURRENT_CONTENT_PREXIX + contentOnSessionMarker, contentForTest);
this.initContentAction("/do/jacms/Content", "save", contentOnSessionMarker);
this.setUserOnSession("admin");
String result = this.executeAction();
assertEquals(Action.INPUT, result);
ActionSupport action = this.getAction();
assertEquals(1, action.getFieldErrors().size());
assertEquals(1, action.getFieldErrors().get("Monolist:Link:LinkCorrelati_0").size());
} catch (Throwable t) {
throw t;
} finally {
this.removeTestContent(insertedDescr);
}
}
use of com.opensymphony.xwork2.ActionSupport in project entando-core by entando.
the class TestContentGroupAction method testDeleteContents_2.
public void testDeleteContents_2() throws Throwable {
this.setUserOnSession("supervisorCoach");
// 2 CONTENUTI FREE, 1 Customers e 1 Coach
String[] masterContentIds = { "ART180", "EVN20", "ART104", "ART102" };
String[] newContentIds = null;
try {
newContentIds = this.addDraftContentsForTest(masterContentIds, false);
for (int i = 0; i < newContentIds.length; i++) {
Content content = this.getContentManager().loadContent(newContentIds[i], false);
assertFalse(content.isOnLine());
}
this.initAction("/do/jacms/Content", "deleteContentGroup");
this.addParameter("contentIds", newContentIds);
String result = this.executeAction();
assertEquals(Action.SUCCESS, result);
int deletedContents = 0;
for (int i = 0; i < newContentIds.length; i++) {
Content content = this.getContentManager().loadContent(newContentIds[i], false);
if (content == null) {
++deletedContents;
} else {
// Verifica che non si sono cancellati contenuti free
String mainGroup = content.getMainGroup();
assertTrue(Group.FREE_GROUP_NAME.equals(mainGroup));
}
}
assertEquals(2, deletedContents);
ActionSupport action = this.getAction();
Collection<String> messages = action.getActionMessages();
assertEquals(1, messages.size());
Collection<String> errors = action.getActionErrors();
assertEquals(2, errors.size());
} catch (Throwable t) {
throw t;
} finally {
this.deleteContents(newContentIds);
}
}
Aggregations