use of com.agiletec.aps.system.common.entity.model.attribute.AttributeInterface in project entando-core by entando.
the class TestListAttributeAction method testAddListElement.
public void testAddListElement() throws Throwable {
String contentOnSessionMarker = this.initEditContent();
this.initContentAction("/do/jacms/Content", "addListElement", contentOnSessionMarker);
this.addParameter("attributeName", "Autori");
this.addParameter("listLangCode", "it");
String result = this.executeAction();
assertEquals(Action.SUCCESS, result);
Content currentContent = this.getContentOnEdit(contentOnSessionMarker);
MonoListAttribute monoListAttribute = (MonoListAttribute) currentContent.getAttribute("Autori");
List<AttributeInterface> attributes = monoListAttribute.getAttributes();
String[] expected = { "Pippo", "Paperino", "Pluto", "" };
this.verifyText(attributes, expected);
}
use of com.agiletec.aps.system.common.entity.model.attribute.AttributeInterface in project entando-core by entando.
the class TestValidateNumberAttribute method testValidate_ListElement.
public void testValidate_ListElement() throws Throwable {
try {
String contentOnSessionMarker = this.executeCreateNewContent();
Content content = this.getContentOnEdit(contentOnSessionMarker);
AttributeTracer tracerIT = this.getTracer();
ListAttribute list = (ListAttribute) content.getAttribute("ListNumber");
AttributeInterface attributeIT = list.addAttribute("it");
assertEquals(0, list.getAttributeList("en").size());
assertEquals(1, list.getAttributeList("it").size());
tracerIT.setListIndex(list.getAttributeList("it").size() - 1);
tracerIT.setListLang(this.getLangManager().getLang("it"));
tracerIT.setListElement(true);
String formFieldItName = tracerIT.getFormFieldName(attributeIT);
String formFieldPrefix = "List:" + attributeIT.getType() + ":";
assertEquals(formFieldPrefix + "it_ListNumber_0", formFieldItName);
AttributeTracer tracerEN = tracerIT.clone();
tracerEN.setLang(this.getLangManager().getLang("en"));
tracerEN.setListLang(this.getLangManager().getLang("en"));
this.initSaveContentAction(contentOnSessionMarker);
this.executeAction(Action.INPUT);
this.checkFieldErrors(1, formFieldItName);
this.initSaveContentAction(contentOnSessionMarker);
this.addParameter(formFieldItName, "wrongNumber");
this.executeAction(Action.INPUT);
this.checkFieldErrors(1, formFieldItName);
this.initSaveContentAction(contentOnSessionMarker);
this.addParameter(formFieldItName, "27");
this.executeAction(Action.INPUT);
this.checkFieldErrors(0, formFieldItName);
AttributeInterface attribute2 = list.addAttribute("it");
tracerIT.setListIndex(list.getAttributes().size() - 1);
formFieldItName = tracerIT.getFormFieldName(attribute2);
assertEquals(formFieldPrefix + "it_ListNumber_1", formFieldItName);
this.initSaveContentAction(contentOnSessionMarker);
this.executeAction(Action.INPUT);
this.checkFieldErrors(1, formFieldItName);
this.initSaveContentAction(contentOnSessionMarker);
this.addParameter(formFieldItName, "26");
this.executeAction(Action.INPUT);
this.checkFieldErrors(0, formFieldItName);
AttributeInterface attributeEN = list.addAttribute("en");
String formFieldEnName = tracerEN.getFormFieldName(attributeEN);
assertEquals(formFieldPrefix + "en_ListNumber_0", formFieldEnName);
this.initSaveContentAction(contentOnSessionMarker);
this.executeAction(Action.INPUT);
this.checkFieldErrors(1, formFieldEnName);
this.initSaveContentAction(contentOnSessionMarker);
this.addParameter(formFieldEnName, "57");
this.executeAction(Action.INPUT);
this.checkFieldErrors(0, formFieldEnName);
} catch (Throwable t) {
this.deleteTestContent();
throw t;
}
}
use of com.agiletec.aps.system.common.entity.model.attribute.AttributeInterface in project entando-core by entando.
the class TestValidateNumberAttribute method testValidate_Single_1.
public void testValidate_Single_1() throws Throwable {
try {
String contentOnSessionMarker = this.executeCreateNewContent();
Content content = this.getContentOnEdit(contentOnSessionMarker);
AttributeTracer tracer = this.getTracer();
AttributeInterface numberAttribute = (AttributeInterface) content.getAttribute("Number");
String formFieldName = tracer.getFormFieldName(numberAttribute);
this.initSaveContentAction(contentOnSessionMarker);
this.addParameter(formFieldName, "wrongNumber");
this.executeAction(Action.INPUT);
this.checkFieldErrors(1, formFieldName);
this.initSaveContentAction(contentOnSessionMarker);
this.addParameter(formFieldName, "41");
this.executeAction(Action.INPUT);
this.checkFieldErrors(0, formFieldName);
} catch (Throwable t) {
this.deleteTestContent();
throw t;
}
}
use of com.agiletec.aps.system.common.entity.model.attribute.AttributeInterface in project entando-core by entando.
the class TestValidateNumberAttribute method testValidate_CompositeElement.
public void testValidate_CompositeElement() throws Throwable {
try {
String contentOnSessionMarker = this.executeCreateNewContent();
Content content = this.getContentOnEdit(contentOnSessionMarker);
AttributeTracer tracer = this.getTracer();
CompositeAttribute compositeAttribute = (CompositeAttribute) content.getAttribute("Composite");
AttributeInterface attribute = compositeAttribute.getAttribute("Number");
tracer.setCompositeElement(true);
tracer.setParentAttribute(compositeAttribute);
String formFieldName = tracer.getFormFieldName(attribute);
String formFieldPrefix = "Composite:" + attribute.getType() + ":";
assertEquals(formFieldPrefix + "Composite_Number", formFieldName);
this.initSaveContentAction(contentOnSessionMarker);
this.executeAction(Action.INPUT);
this.checkFieldErrors(0, formFieldName);
this.initSaveContentAction(contentOnSessionMarker);
this.addParameter(formFieldName, "wrongNumberValue");
this.executeAction(Action.INPUT);
this.checkFieldErrors(1, formFieldName);
// OGNL VALIDATION - evalOnValuedAttribute="true"
// #entity.getAttribute(''Number'').value == null || (#entity.getAttribute(''Number'').value != null && value > #entity.getAttribute(''Number'').value)
this.initSaveContentAction(contentOnSessionMarker);
this.addParameter(formFieldName, "58");
this.executeAction(Action.INPUT);
this.checkFieldErrors(0, formFieldName);
this.initSaveContentAction(contentOnSessionMarker);
this.addParameter("Number:Number", "100");
this.executeAction(Action.INPUT);
this.checkFieldErrors(1, formFieldName);
this.initSaveContentAction(contentOnSessionMarker);
this.addParameter(formFieldName, "101");
this.executeAction(Action.INPUT);
this.checkFieldErrors(0, formFieldName);
} catch (Throwable t) {
this.deleteTestContent();
throw t;
}
}
use of com.agiletec.aps.system.common.entity.model.attribute.AttributeInterface in project entando-core by entando.
the class TestValidateResourceAttribute method testValidate_MonolistCompositeElement.
protected void testValidate_MonolistCompositeElement(String elementName, String testResourceId) throws Throwable {
try {
String contentOnSessionMarker = this.executeCreateNewContent();
Content content = this.getContentOnEdit(contentOnSessionMarker);
AttributeTracer tracerIT = this.getTracer();
MonoListAttribute monolistAttribute = (MonoListAttribute) content.getAttribute("MonoLCom");
CompositeAttribute compositeElement = (CompositeAttribute) monolistAttribute.addAttribute();
AttributeInterface attribute = compositeElement.getAttribute(elementName);
String monolistElementFieldPrefix = "Monolist:Composite:";
String formFieldPrefix = monolistElementFieldPrefix + attribute.getType() + ":";
tracerIT.setListIndex(monolistAttribute.getAttributes().size() - 1);
tracerIT.setListLang(this.getLangManager().getDefaultLang());
tracerIT.setMonoListElement(true);
tracerIT.setCompositeElement(true);
tracerIT.setParentAttribute(compositeElement);
String formITFieldName = tracerIT.getFormFieldName(attribute);
assertEquals(formFieldPrefix + "it_MonoLCom_" + elementName + "_0", formITFieldName);
String monolistElementName = tracerIT.getMonolistElementFieldName(compositeElement);
assertEquals(monolistElementFieldPrefix + "MonoLCom_0", monolistElementName);
this.initSaveContentAction(contentOnSessionMarker);
this.executeAction(Action.INPUT);
this.checkFieldErrors(1, monolistElementName);
this.initSaveContentAction(contentOnSessionMarker);
this.addParameter(formITFieldName, "itValue");
this.executeAction(Action.INPUT);
this.checkFieldErrors(1, formFieldPrefix + "MonoLCom_" + elementName + "_0");
content = this.getContentOnEdit(contentOnSessionMarker);
monolistAttribute = (MonoListAttribute) content.getAttribute("MonoLCom");
compositeElement = (CompositeAttribute) monolistAttribute.getAttribute(0);
AbstractResourceAttribute resourceAttribute = (AbstractResourceAttribute) compositeElement.getAttribute(elementName);
ResourceInterface resource = this._resourceManager.loadResource(testResourceId);
resourceAttribute.setResource(resource, this.getLangManager().getDefaultLang().getCode());
this.initSaveContentAction(contentOnSessionMarker);
this.executeAction(Action.INPUT);
this.checkFieldErrors(0, "MonoLCom_" + elementName + "_0");
} catch (Throwable t) {
this.deleteTestContent();
throw t;
}
}
Aggregations