Search in sources :

Example 1 with MonoListAttribute

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

Example 2 with MonoListAttribute

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;
    }
}
Also used : MonoListAttribute(com.agiletec.aps.system.common.entity.model.attribute.MonoListAttribute) 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 3 with MonoListAttribute

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;
    }
}
Also used : MonoListAttribute(com.agiletec.aps.system.common.entity.model.attribute.MonoListAttribute) 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 4 with MonoListAttribute

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;
    }
}
Also used : MonoListAttribute(com.agiletec.aps.system.common.entity.model.attribute.MonoListAttribute) 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 5 with MonoListAttribute

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

Aggregations

MonoListAttribute (com.agiletec.aps.system.common.entity.model.attribute.MonoListAttribute)41 AttributeInterface (com.agiletec.aps.system.common.entity.model.attribute.AttributeInterface)34 Content (com.agiletec.plugins.jacms.aps.system.services.content.model.Content)25 CompositeAttribute (com.agiletec.aps.system.common.entity.model.attribute.CompositeAttribute)16 AttributeTracer (com.agiletec.aps.system.common.entity.model.AttributeTracer)14 ListAttribute (com.agiletec.aps.system.common.entity.model.attribute.ListAttribute)9 LinkAttribute (com.agiletec.plugins.jacms.aps.system.services.content.model.extraAttribute.LinkAttribute)6 DateAttribute (com.agiletec.aps.system.common.entity.model.attribute.DateAttribute)5 TextAttribute (com.agiletec.aps.system.common.entity.model.attribute.TextAttribute)5 HttpSession (javax.servlet.http.HttpSession)5 IApsEntity (com.agiletec.aps.system.common.entity.model.IApsEntity)4 HypertextAttribute (com.agiletec.aps.system.common.entity.model.attribute.HypertextAttribute)4 ListAttributeInterface (com.agiletec.aps.system.common.entity.model.attribute.ListAttributeInterface)4 MonoTextAttribute (com.agiletec.aps.system.common.entity.model.attribute.MonoTextAttribute)4 ResourceAttributeInterface (com.agiletec.plugins.jacms.aps.system.services.content.model.extraAttribute.ResourceAttributeInterface)4 List (java.util.List)4 FieldError (com.agiletec.aps.system.common.entity.model.FieldError)3 NumberAttribute (com.agiletec.aps.system.common.entity.model.attribute.NumberAttribute)3 AbstractResourceAttribute (com.agiletec.plugins.jacms.aps.system.services.content.model.extraAttribute.AbstractResourceAttribute)3 DataObject (org.entando.entando.aps.system.services.dataobject.model.DataObject)3