use of com.agiletec.aps.system.common.entity.model.attribute.MonoListAttribute in project entando-core by entando.
the class TestValidateContent method testValidate_2.
public void testValidate_2() throws Throwable {
try {
Content content = this._contentManager.loadContent("EVN191", true);
content.setId(null);
// Valorizzo il gruppo proprietario
content.setMainGroup(Group.FREE_GROUP_NAME);
content.getGroups().add("customers");
MonoListAttribute linksCorrelati = (MonoListAttribute) content.getAttribute("LinkCorrelati");
LinkAttribute linkAttribute = (LinkAttribute) linksCorrelati.addAttribute();
List<FieldError> errors = content.validate(this._groupManager);
assertNotNull(errors);
assertEquals(1, errors.size());
FieldError error = errors.get(0);
// Verifica obbligatorietĂ attributo "Titolo"
assertEquals("Monolist:Link:LinkCorrelati_0", error.getFieldCode());
assertEquals(FieldError.INVALID, error.getErrorCode());
// AGGIUNGO LINK SU PAGINA COACH
linkAttribute.setText("Descrizione link", "it");
SymbolicLink symbolicLink = new SymbolicLink();
// Contenuto di coach
symbolicLink.setDestinationToContent("EVN103");
linkAttribute.setSymbolicLink(symbolicLink);
errors = content.validate(this._groupManager);
assertNotNull(errors);
assertEquals(1, errors.size());
error = errors.get(0);
assertEquals("Monolist:Link:LinkCorrelati_0", error.getFieldCode());
assertEquals(ICmsAttributeErrorCodes.INVALID_CONTENT_GROUPS, error.getErrorCode());
} catch (Throwable t) {
throw t;
}
}
use of com.agiletec.aps.system.common.entity.model.attribute.MonoListAttribute in project entando-core by entando.
the class TestContentAction method testValidate_1.
public void testValidate_1() throws Throwable {
String insertedDescr = "XXX Prova Validazione XXX";
String contentTypeCode = "ART";
Content prototype = this.getContentManager().createContentType(contentTypeCode);
String contentOnSessionMarker = AbstractContentAction.buildContentOnSessionMarker(prototype, ApsAdminSystemConstants.ADD);
try {
String result = this.executeCreateNewVoid(contentTypeCode, insertedDescr, Content.STATUS_DRAFT, Group.FREE_GROUP_NAME, "admin");
assertEquals(Action.SUCCESS, result);
Content contentOnSession = this.getContentOnEdit(contentOnSessionMarker);
assertNotNull(contentOnSession);
assertEquals(insertedDescr, contentOnSession.getDescription());
this.initContentAction("/do/jacms/Content", "save", contentOnSessionMarker);
result = this.executeAction();
assertEquals(Action.INPUT, result);
Map<String, List<String>> fieldErrors = this.getAction().getFieldErrors();
assertEquals(1, fieldErrors.size());
List<String> titleFieldErrors = fieldErrors.get("Text:it_Titolo");
assertNotNull(titleFieldErrors);
// Verifica obbligatorietĂ attributo "Titolo"
assertEquals(1, titleFieldErrors.size());
String monolistAttributeName = "Autori";
contentOnSession = this.getContentOnEdit(contentOnSessionMarker);
MonoListAttribute monolist = (MonoListAttribute) contentOnSession.getAttribute(monolistAttributeName);
assertEquals(0, monolist.getAttributes().size());
monolist.addAttribute();
assertEquals(1, monolist.getAttributes().size());
this.initContentAction("/do/jacms/Content", "save", contentOnSessionMarker);
this.addParameter("mainGroup", Group.FREE_GROUP_NAME);
result = this.executeAction();
assertEquals(Action.INPUT, result);
fieldErrors = this.getAction().getFieldErrors();
assertEquals(2, fieldErrors.size());
titleFieldErrors = fieldErrors.get("Text:it_Titolo");
assertNotNull(titleFieldErrors);
// Verifica obbligatorietĂ attributo "Titolo"
assertEquals(1, titleFieldErrors.size());
List<String> autoriFieldErrors = fieldErrors.get("Monolist:Monotext:Autori_0");
assertNotNull(autoriFieldErrors);
// Verifica non valido elemento 1 in attributo lista "Autori"
assertEquals(1, autoriFieldErrors.size());
} catch (Throwable t) {
throw t;
} finally {
this.removeTestContent(insertedDescr);
}
}
use of com.agiletec.aps.system.common.entity.model.attribute.MonoListAttribute 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.agiletec.aps.system.common.entity.model.attribute.MonoListAttribute in project entando-core by entando.
the class TestLinkAttributeAction method testChooseLink_2.
public void testChooseLink_2() throws Throwable {
String contentId = "EVN191";
String contentOnSessionMarker = this.extractSessionMarker(contentId, ApsAdminSystemConstants.EDIT);
this.executeEdit(contentId, "admin");
this.initContentAction("/do/jacms/Content", "chooseLink", contentOnSessionMarker);
this.addParameter("attributeName", "LinkCorrelati");
this.addParameter("elementIndex", "0");
this.addParameter("langCode", "it");
String result = this.executeAction();
// FALLIMENTO PER LISTA VUOTA
assertEquals(BaseAction.FAILURE, result);
Content currentContent = this.getContentOnEdit(contentOnSessionMarker);
MonoListAttribute monoListAttribute = (MonoListAttribute) currentContent.getAttribute("LinkCorrelati");
List<AttributeInterface> attributes = monoListAttribute.getAttributes();
assertEquals(0, attributes.size());
this.initContentAction("/do/jacms/Content", "addListElement", contentOnSessionMarker);
this.addParameter("attributeName", "LinkCorrelati");
this.addParameter("listLangCode", "it");
result = this.executeAction();
assertEquals("chooseLink", result);
currentContent = this.getContentOnEdit(contentOnSessionMarker);
monoListAttribute = (MonoListAttribute) currentContent.getAttribute("LinkCorrelati");
attributes = monoListAttribute.getAttributes();
assertEquals(1, attributes.size());
this.initContentAction("/do/jacms/Content", "chooseLink", contentOnSessionMarker);
this.addParameter("attributeName", "LinkCorrelati");
this.addParameter("elementIndex", "0");
this.addParameter("langCode", "it");
result = this.executeAction();
assertEquals(Action.SUCCESS, result);
HttpSession session = this.getRequest().getSession();
assertEquals("LinkCorrelati", session.getAttribute(ILinkAttributeActionHelper.ATTRIBUTE_NAME_SESSION_PARAM));
assertEquals("it", session.getAttribute(ILinkAttributeActionHelper.LINK_LANG_CODE_SESSION_PARAM));
assertNotNull(session.getAttribute(ILinkAttributeActionHelper.LIST_ELEMENT_INDEX_SESSION_PARAM));
assertEquals(new Integer(0), session.getAttribute(ILinkAttributeActionHelper.LIST_ELEMENT_INDEX_SESSION_PARAM));
currentContent = this.getContentOnEdit(contentOnSessionMarker);
assertNotNull(currentContent);
assertEquals("EVN191", currentContent.getId());
assertEquals("Evento 1", currentContent.getDescription());
}
use of com.agiletec.aps.system.common.entity.model.attribute.MonoListAttribute in project entando-core by entando.
the class LinkAttributeActionHelper method getLinkAttribute.
protected AttributeInterface getLinkAttribute(AttributeInterface attribute, HttpServletRequest request) {
HttpSession session = request.getSession();
if (attribute instanceof CompositeAttribute) {
String includedAttributeName = (String) session.getAttribute(INCLUDED_ELEMENT_NAME_SESSION_PARAM);
AttributeInterface includedAttribute = ((CompositeAttribute) attribute).getAttribute(includedAttributeName);
return getLinkAttribute(includedAttribute, request);
} else if (attribute instanceof MonoListAttribute) {
Integer elementIndex = (Integer) session.getAttribute(LIST_ELEMENT_INDEX_SESSION_PARAM);
AttributeInterface attributeElement = ((MonoListAttribute) attribute).getAttribute(elementIndex.intValue());
return getLinkAttribute(attributeElement, request);
} else if (attribute instanceof LinkAttribute) {
return attribute;
} else {
throw new RuntimeException("Caso non gestito : Atttributo tipo " + attribute.getClass());
}
}
Aggregations