use of com.agiletec.aps.system.common.entity.model.attribute.AttributeInterface in project entando-core by entando.
the class TestValidateMonotextAttribute method testValidate_MonoListElement.
public void testValidate_MonoListElement() throws Throwable {
try {
String contentOnSessionMarker = this.executeCreateNewContent();
Content content = this.getContentOnEdit(contentOnSessionMarker);
AttributeTracer tracer = this.getTracer();
MonoListAttribute monolist = (MonoListAttribute) content.getAttribute("MonoLMonot");
AttributeInterface attribute = monolist.addAttribute();
String formFieldPrefix = "Monolist:" + attribute.getType() + ":";
tracer.setLang(this.getLangManager().getDefaultLang());
tracer.setListIndex(monolist.getAttributes().size() - 1);
tracer.setListLang(this.getLangManager().getDefaultLang());
tracer.setMonoListElement(true);
tracer.setParentAttribute(monolist);
String formFieldName = tracer.getFormFieldName(attribute);
assertEquals(formFieldPrefix + "MonoLMonot_0", formFieldName);
this.initSaveContentAction(contentOnSessionMarker);
this.executeAction(Action.INPUT);
this.checkFieldErrors(1, formFieldName);
this.initSaveContentAction(contentOnSessionMarker);
this.addParameter(formFieldName, "MonoLMonotElement0Value");
this.executeAction(Action.INPUT);
this.checkFieldErrors(0, formFieldName);
AttributeInterface attribute2 = monolist.addAttribute();
tracer.setListIndex(monolist.getAttributes().size() - 1);
String formFieldName2 = tracer.getFormFieldName(attribute2);
assertEquals(formFieldPrefix + "MonoLMonot_1", formFieldName2);
this.initSaveContentAction(contentOnSessionMarker);
this.executeAction(Action.INPUT);
this.checkFieldErrors(1, formFieldName2);
} 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 TestValidateMonotextAttribute method testValidate_ListElement.
public void testValidate_ListElement() throws Throwable {
try {
String contentOnSessionMarker = this.executeCreateNewContent();
Content content = this.getContentOnEdit(contentOnSessionMarker);
AttributeTracer tracer = this.getTracer();
ListAttribute list = (ListAttribute) content.getAttribute("ListMonot");
AttributeInterface attribute = list.addAttribute("it");
assertEquals(0, list.getAttributeList("en").size());
assertEquals(1, list.getAttributeList("it").size());
tracer.setLang(this.getLangManager().getLang("it"));
tracer.setListIndex(list.getAttributeList("it").size() - 1);
tracer.setListLang(this.getLangManager().getLang("it"));
tracer.setListElement(true);
tracer.setParentAttribute(list);
String formFieldName = tracer.getFormFieldName(attribute);
String formFieldPrefix = "List:" + attribute.getType() + ":";
assertEquals(formFieldPrefix + "it_ListMonot_0", formFieldName);
this.initSaveContentAction(contentOnSessionMarker);
this.executeAction(Action.INPUT);
this.checkFieldErrors(1, formFieldName);
this.initSaveContentAction(contentOnSessionMarker);
this.addParameter(formFieldName, "ListMonotElement0Value");
this.executeAction(Action.INPUT);
this.checkFieldErrors(0, formFieldName);
AttributeInterface attribute2 = list.addAttribute("it");
tracer.setListIndex(list.getAttributes().size() - 1);
formFieldName = tracer.getFormFieldName(attribute2);
assertEquals(formFieldPrefix + "it_ListMonot_1", formFieldName);
this.initSaveContentAction(contentOnSessionMarker);
this.executeAction(Action.INPUT);
this.checkFieldErrors(1, 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 TestListAttributeAction method initEditContent.
private String initEditContent() throws Throwable {
String contentId = "ART1";
Content content = this.getContentManager().loadContent(contentId, false);
this.executeEdit(contentId, "admin");
String contentOnSessionMarker = AbstractContentAction.buildContentOnSessionMarker(content, ApsAdminSystemConstants.EDIT);
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);
return contentOnSessionMarker;
}
use of com.agiletec.aps.system.common.entity.model.attribute.AttributeInterface in project entando-core by entando.
the class TestListAttributeAction method testRemoveListElement.
public void testRemoveListElement() throws Throwable {
String contentOnSessionMarker = this.initEditContent();
this.initContentAction("/do/jacms/Content", "removeListElement", contentOnSessionMarker);
this.addParameter("attributeName", "Autori");
this.addParameter("elementIndex", "1");
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", "Pluto" };
this.verifyText(attributes, expected);
}
use of com.agiletec.aps.system.common.entity.model.attribute.AttributeInterface in project entando-core by entando.
the class TestListAttributeAction method testMoveListElement.
public void testMoveListElement() throws Throwable {
String contentOnSessionMarker = this.initEditContent();
this.initContentAction("/do/jacms/Content", "moveListElement", contentOnSessionMarker);
this.addParameter("attributeName", "Autori");
this.addParameter("elementIndex", "1");
this.addParameter("listLangCode", "it");
this.addParameter("movement", IListAttributeAction.MOVEMENT_UP_CODE);
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 = { "Paperino", "Pippo", "Pluto" };
this.verifyText(attributes, expected);
this.initContentAction("/do/jacms/Content", "moveListElement", contentOnSessionMarker);
this.addParameter("attributeName", "Autori");
this.addParameter("elementIndex", "1");
this.addParameter("listLangCode", "it");
this.addParameter("movement", IListAttributeAction.MOVEMENT_DOWN_CODE);
result = this.executeAction();
assertEquals(Action.SUCCESS, result);
currentContent = this.getContentOnEdit(contentOnSessionMarker);
monoListAttribute = (MonoListAttribute) currentContent.getAttribute("Autori");
attributes = monoListAttribute.getAttributes();
String[] expected2 = { "Paperino", "Pluto", "Pippo" };
this.verifyText(attributes, expected2);
}
Aggregations