use of com.agiletec.plugins.jacms.aps.system.services.content.model.Content 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.agiletec.plugins.jacms.aps.system.services.content.model.Content 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.agiletec.plugins.jacms.aps.system.services.content.model.Content in project entando-core by entando.
the class TestContentAction method testSaveNewContent.
public void testSaveNewContent() throws Throwable {
String contentId = "ART1";
Content master = this.getContentManager().loadContent(contentId, false);
String contentOnSessionMarker = AbstractContentAction.buildContentOnSessionMarker(master, ApsAdminSystemConstants.ADD);
master.setId(null);
String descr = "Contenuto di prova per testSave";
try {
this.getRequest().getSession().setAttribute(ContentActionConstants.SESSION_PARAM_NAME_CURRENT_CONTENT_PREXIX + contentOnSessionMarker, master);
this.initContentAction("/do/jacms/Content", "save", contentOnSessionMarker);
this.setUserOnSession("admin");
this.addParameter("Text:it_Titolo", "");
this.addParameter("descr", "");
String result = this.executeAction();
assertEquals(Action.INPUT, result);
Map<String, List<String>> fieldErrors = this.getAction().getFieldErrors();
assertEquals(2, fieldErrors.size());
assertEquals(1, fieldErrors.get("descr").size());
assertEquals(1, fieldErrors.get("Text:it_Titolo").size());
this.initContentAction("/do/jacms/Content", "save", contentOnSessionMarker);
this.addParameter("Text:it_Titolo", descr);
result = this.executeAction();
assertEquals(Action.SUCCESS, result);
} catch (Throwable t) {
throw t;
} finally {
this.removeTestContent(descr);
}
}
use of com.agiletec.plugins.jacms.aps.system.services.content.model.Content 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;
}
}
use of com.agiletec.plugins.jacms.aps.system.services.content.model.Content in project entando-core by entando.
the class TestContentGroupAction method testSuspendContents_2.
public void testSuspendContents_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, true);
for (int i = 0; i < newContentIds.length; i++) {
Content content = this.getContentManager().loadContent(newContentIds[i], false);
assertTrue(content.isOnLine());
}
this.initAction("/do/jacms/Content", "suspendContentGroup");
this.addParameter("contentIds", newContentIds);
String result = this.executeAction();
assertEquals(Action.SUCCESS, result);
int suspendedContents = 0;
for (int i = 0; i < newContentIds.length; i++) {
Content content = this.getContentManager().loadContent(newContentIds[i], false);
if (!Group.FREE_GROUP_NAME.equals(content.getMainGroup())) {
assertFalse(content.isOnLine());
++suspendedContents;
} else {
assertTrue(content.isOnLine());
}
}
assertEquals(2, suspendedContents);
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