Search in sources :

Example 46 with AttributeTracer

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;
    }
}
Also used : AttributeTracer(com.agiletec.aps.system.common.entity.model.AttributeTracer) Content(com.agiletec.plugins.jacms.aps.system.services.content.model.Content) AttributeInterface(com.agiletec.aps.system.common.entity.model.attribute.AttributeInterface)

Example 47 with AttributeTracer

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;
    }
}
Also used : AttributeTracer(com.agiletec.aps.system.common.entity.model.AttributeTracer) Content(com.agiletec.plugins.jacms.aps.system.services.content.model.Content) AttributeInterface(com.agiletec.aps.system.common.entity.model.attribute.AttributeInterface)

Example 48 with AttributeTracer

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;
    }
}
Also used : AttributeTracer(com.agiletec.aps.system.common.entity.model.AttributeTracer) Content(com.agiletec.plugins.jacms.aps.system.services.content.model.Content) AttributeInterface(com.agiletec.aps.system.common.entity.model.attribute.AttributeInterface)

Example 49 with AttributeTracer

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;
    }
}
Also used : MonoListAttribute(com.agiletec.aps.system.common.entity.model.attribute.MonoListAttribute) AttributeTracer(com.agiletec.aps.system.common.entity.model.AttributeTracer) CompositeAttribute(com.agiletec.aps.system.common.entity.model.attribute.CompositeAttribute) Content(com.agiletec.plugins.jacms.aps.system.services.content.model.Content) AttributeInterface(com.agiletec.aps.system.common.entity.model.attribute.AttributeInterface)

Example 50 with AttributeTracer

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;
}
Also used : AttributeTracer(com.agiletec.aps.system.common.entity.model.AttributeTracer) AttributeFieldError(com.agiletec.aps.system.common.entity.model.AttributeFieldError) IndexableAttributeInterface(com.agiletec.aps.system.common.searchengine.IndexableAttributeInterface)

Aggregations

AttributeTracer (com.agiletec.aps.system.common.entity.model.AttributeTracer)50 AttributeInterface (com.agiletec.aps.system.common.entity.model.attribute.AttributeInterface)38 Content (com.agiletec.plugins.jacms.aps.system.services.content.model.Content)35 MonoListAttribute (com.agiletec.aps.system.common.entity.model.attribute.MonoListAttribute)18 CompositeAttribute (com.agiletec.aps.system.common.entity.model.attribute.CompositeAttribute)13 AttributeFieldError (com.agiletec.aps.system.common.entity.model.AttributeFieldError)8 Lang (com.agiletec.aps.system.services.lang.Lang)7 ListAttribute (com.agiletec.aps.system.common.entity.model.attribute.ListAttribute)5 ResourceInterface (com.agiletec.plugins.jacms.aps.system.services.resource.model.ResourceInterface)5 AbstractResourceAttribute (com.agiletec.plugins.jacms.aps.system.services.content.model.extraAttribute.AbstractResourceAttribute)4 IndexableAttributeInterface (com.agiletec.aps.system.common.searchengine.IndexableAttributeInterface)3 ArrayList (java.util.ArrayList)3 AttributeSearchInfo (com.agiletec.aps.system.common.entity.model.AttributeSearchInfo)2 Field (org.apache.lucene.document.Field)2 IntField (org.apache.lucene.document.IntField)2 StringField (org.apache.lucene.document.StringField)2 TextField (org.apache.lucene.document.TextField)2 AttributeManagerInterface (com.agiletec.apsadmin.system.entity.attribute.manager.AttributeManagerInterface)1 SymbolicLink (com.agiletec.plugins.jacms.aps.system.services.content.model.SymbolicLink)1 ResourceAttributeInterface (com.agiletec.plugins.jacms.aps.system.services.content.model.extraAttribute.ResourceAttributeInterface)1