use of com.agiletec.aps.system.common.entity.model.attribute.MonoListAttribute in project entando-core by entando.
the class TestValidateContent method testValidate_1.
public void testValidate_1() throws Throwable {
String insertedDescr = "XXX Prova Validazione XXX";
try {
Content content = this.createNewVoid("ART", insertedDescr, Content.STATUS_DRAFT, Group.FREE_GROUP_NAME, "admin");
List<FieldError> errors = content.validate(this._groupManager);
assertNotNull(errors);
assertEquals(1, errors.size());
FieldError error = errors.get(0);
// Verifica obbligatorietĂ attributo "Titolo"
assertEquals("Text:it_Titolo", error.getFieldCode());
assertEquals(FieldError.MANDATORY, error.getErrorCode());
String monolistAttributeName = "Autori";
MonoListAttribute monolist = (MonoListAttribute) content.getAttribute(monolistAttributeName);
monolist.addAttribute();
assertEquals(1, monolist.getAttributes().size());
errors = content.validate(this._groupManager);
assertEquals(2, errors.size());
error = errors.get(0);
// Verifica obbligatorietĂ attributo "Titolo"
assertEquals("Text:it_Titolo", error.getFieldCode());
assertEquals(FieldError.MANDATORY, error.getErrorCode());
error = errors.get(1);
// Verifica non valido elemento 1 in attributo lista "Autori"
assertEquals("Monolist:Monotext:Autori_0", error.getFieldCode());
assertEquals(FieldError.INVALID, 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 TestValidateBooleanAttributes method validateMonolistElement.
protected void validateMonolistElement(String monolistAttributeName) throws Throwable {
try {
String contentOnSessionMarker = this.executeCreateNewContent();
Content content = this.getContentOnEdit(contentOnSessionMarker);
AttributeTracer tracer = this.getTracer();
MonoListAttribute monolist = (MonoListAttribute) content.getAttribute(monolistAttributeName);
AttributeInterface attribute = monolist.addAttribute();
String formFieldPrefix = "Monolist:" + attribute.getType() + ":";
tracer.setListIndex(monolist.getAttributes().size() - 1);
tracer.setListLang(this.getLangManager().getDefaultLang());
tracer.setMonoListElement(true);
String formFieldName = tracer.getFormFieldName(attribute);
assertEquals(formFieldPrefix + monolistAttributeName + "_0", formFieldName);
this.initSaveContentAction(contentOnSessionMarker);
this.executeAction(Action.INPUT);
this.checkFieldErrors(0, formFieldName);
this.initSaveContentAction(contentOnSessionMarker);
this.addParameter(formFieldName, "true");
this.executeAction(Action.INPUT);
this.checkFieldErrors(0, formFieldName);
this.initSaveContentAction(contentOnSessionMarker);
this.addParameter(formFieldName, "false");
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 + monolistAttributeName + "_1", formFieldName2);
this.initSaveContentAction(contentOnSessionMarker);
this.executeAction(Action.INPUT);
this.checkFieldErrors(0, formFieldName2);
} catch (Throwable t) {
this.deleteTestContent();
throw t;
}
}
use of com.agiletec.aps.system.common.entity.model.attribute.MonoListAttribute in project entando-core by entando.
the class TestValidateDateAttribute 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("MonoLDate");
AttributeInterface attribute = monolist.addAttribute();
String formFieldPrefix = "Monolist:" + attribute.getType() + ":";
tracer.setListIndex(monolist.getAttributes().size() - 1);
tracer.setListLang(this.getLangManager().getDefaultLang());
tracer.setMonoListElement(true);
String formFieldName = tracer.getFormFieldName(attribute);
assertEquals(formFieldPrefix + "MonoLDate_0", formFieldName);
this.initSaveContentAction(contentOnSessionMarker);
this.executeAction(Action.INPUT);
this.checkFieldErrors(1, formFieldName);
this.initSaveContentAction(contentOnSessionMarker);
this.addParameter(formFieldName, "dateValue");
this.executeAction(Action.INPUT);
this.checkFieldErrors(1, formFieldName);
this.initSaveContentAction(contentOnSessionMarker);
this.addParameter(formFieldName, "11/07/1982");
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 + "MonoLDate_1", formFieldName2);
this.initSaveContentAction(contentOnSessionMarker);
this.executeAction(Action.INPUT);
this.checkFieldErrors(1, formFieldName2);
this.initSaveContentAction(contentOnSessionMarker);
this.executeAction(Action.INPUT);
this.addParameter(formFieldName2, "18/04/1971");
this.checkFieldErrors(1, formFieldName2);
} catch (Throwable t) {
this.deleteTestContent();
throw t;
}
}
use of com.agiletec.aps.system.common.entity.model.attribute.MonoListAttribute 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.MonoListAttribute 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;
}
Aggregations