use of com.agiletec.aps.system.common.entity.model.AttributeTracer in project entando-core by entando.
the class TestValidateTextAttribute method testValidate_Single_2.
public void testValidate_Single_2() throws Throwable {
try {
String contentOnSessionMarker = this.executeCreateNewContent();
Content content = this.getContentOnEdit(contentOnSessionMarker);
AttributeTracer tracer = this.getTracer();
AttributeInterface textAttribute = (AttributeInterface) content.getAttribute("Text2");
// Mail attribute (required, min=15, max=30, regex=**mailFormat**)
String formFieldName = tracer.getFormFieldName(textAttribute);
assertEquals("Text:it_Text2", formFieldName);
this.initSaveContentAction(contentOnSessionMarker);
this.executeAction(Action.INPUT);
this.checkFieldErrors(0, formFieldName);
this.initSaveContentAction(contentOnSessionMarker);
this.addParameter(formFieldName, "invalidText2Value");
this.executeAction(Action.INPUT);
this.checkFieldErrors(1, formFieldName);
this.initSaveContentAction(contentOnSessionMarker);
this.addParameter(formFieldName, "ii@22.it");
this.executeAction(Action.INPUT);
this.checkFieldErrors(1, formFieldName);
this.initSaveContentAction(contentOnSessionMarker);
this.addParameter(formFieldName, "aabbccddeeffgghh112233@iillmmnnooppqq334455.it");
this.executeAction(Action.INPUT);
this.checkFieldErrors(1, formFieldName);
this.initSaveContentAction(contentOnSessionMarker);
this.addParameter(formFieldName, "aabbccdd@eeffgghhii.com");
this.executeAction(Action.INPUT);
this.checkFieldErrors(0, formFieldName);
} catch (Throwable t) {
this.deleteTestContent();
throw t;
}
}
use of com.agiletec.aps.system.common.entity.model.AttributeTracer in project entando-core by entando.
the class TestValidateTextAttribute 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 monotext = (AttributeInterface) content.getAttribute("Text");
String formFieldName = tracer.getFormFieldName(monotext);
this.initSaveContentAction(contentOnSessionMarker);
this.addParameter(formFieldName, "monotextValue");
this.executeAction(Action.INPUT);
this.checkFieldErrors(0, formFieldName);
} catch (Throwable t) {
this.deleteTestContent();
throw t;
}
}
use of com.agiletec.aps.system.common.entity.model.AttributeTracer in project entando-core by entando.
the class TestValidateTextAttribute method testValidate_Single_3.
public void testValidate_Single_3() throws Throwable {
try {
String contentOnSessionMarker = this.executeCreateNewContent();
Content content = this.getContentOnEdit(contentOnSessionMarker);
AttributeTracer tracer = this.getTracer();
// NO DEFAULT LANG
tracer.setLang(this.getLangManager().getLang("en"));
AttributeInterface textAttribute = (AttributeInterface) content.getAttribute("Text2");
// Mail attribute (required, min=15, max=50, regex=**mailFormat**)
String formFieldName = tracer.getFormFieldName(textAttribute);
assertEquals("Text:en_Text2", formFieldName);
this.initSaveContentAction(contentOnSessionMarker);
this.executeAction(Action.INPUT);
this.checkFieldErrors(0, formFieldName);
this.initSaveContentAction(contentOnSessionMarker);
this.addParameter(formFieldName, "invalidText2Value");
this.executeAction(Action.INPUT);
this.checkFieldErrors(1, formFieldName);
this.initSaveContentAction(contentOnSessionMarker);
this.addParameter(formFieldName, "ii@22.it");
this.executeAction(Action.INPUT);
this.checkFieldErrors(1, formFieldName);
this.initSaveContentAction(contentOnSessionMarker);
this.addParameter(formFieldName, "aabbccddeeffgghh112233@iillmmnnooppqq334455.it");
this.executeAction(Action.INPUT);
this.checkFieldErrors(1, formFieldName);
this.initSaveContentAction(contentOnSessionMarker);
this.addParameter(formFieldName, "aabbccdd@eeffgghhii.com");
this.executeAction(Action.INPUT);
this.checkFieldErrors(0, formFieldName);
} catch (Throwable t) {
this.deleteTestContent();
throw t;
}
}
use of com.agiletec.aps.system.common.entity.model.AttributeTracer in project entando-core by entando.
the class TestValidateTextAttribute method testValidate_MonolistCompositeElement.
public void testValidate_MonolistCompositeElement() throws Throwable {
try {
String contentOnSessionMarker = this.executeCreateNewContent();
Content content = this.getContentOnEdit(contentOnSessionMarker);
AttributeTracer tracerIT = this.getTracer();
MonoListAttribute monolist = (MonoListAttribute) content.getAttribute("MonoLCom");
CompositeAttribute compositeElement = (CompositeAttribute) monolist.addAttribute();
AttributeInterface attribute = compositeElement.getAttribute("Text");
String monolistElementFieldPrefix = "Monolist:Composite:";
String formFieldPrefix = monolistElementFieldPrefix + attribute.getType() + ":";
tracerIT.setListIndex(monolist.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_Text_0", formITFieldName);
AttributeTracer tracerEN = tracerIT.clone();
tracerEN.setLang(this.getLangManager().getLang("en"));
String formENFieldName = tracerEN.getFormFieldName(attribute);
assertEquals(formFieldPrefix + "en_MonoLCom_Text_0", formENFieldName);
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(0, formITFieldName);
this.initSaveContentAction(contentOnSessionMarker);
this.addParameter(formITFieldName, "");
this.addParameter(formENFieldName, "enValue");
this.executeAction(Action.INPUT);
this.checkFieldErrors(1, monolistElementName);
this.initSaveContentAction(contentOnSessionMarker);
this.addParameter(formITFieldName, "itValue");
this.addParameter(formENFieldName, "enValue");
this.executeAction(Action.INPUT);
this.checkFieldErrors(0, monolistElementName);
} catch (Throwable t) {
this.deleteTestContent();
throw t;
}
}
use of com.agiletec.aps.system.common.entity.model.AttributeTracer in project entando-core by entando.
the class CompositeAttribute method validate.
@Override
public List<AttributeFieldError> validate(AttributeTracer tracer) {
List<AttributeFieldError> errors = super.validate(tracer);
try {
List<AttributeInterface> attributes = this.getAttributes();
for (int i = 0; i < attributes.size(); i++) {
AttributeInterface attributeElement = attributes.get(i);
AttributeTracer elementTracer = tracer.clone();
elementTracer.setCompositeElement(true);
elementTracer.setParentAttribute(this);
List<AttributeFieldError> elementErrors = attributeElement.validate(elementTracer);
if (null != elementErrors) {
errors.addAll(elementErrors);
}
}
} catch (Throwable t) {
_logger.error("Error validating composite attribute", t);
throw new RuntimeException("Error validating composite attribute", t);
}
return errors;
}
Aggregations