Search in sources :

Example 26 with AttributeInterface

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;
    }
}
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 27 with AttributeInterface

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

Example 28 with AttributeInterface

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;
}
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)

Example 29 with AttributeInterface

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);
}
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)

Example 30 with AttributeInterface

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);
}
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

AttributeInterface (com.agiletec.aps.system.common.entity.model.attribute.AttributeInterface)147 Content (com.agiletec.plugins.jacms.aps.system.services.content.model.Content)55 AttributeTracer (com.agiletec.aps.system.common.entity.model.AttributeTracer)38 MonoListAttribute (com.agiletec.aps.system.common.entity.model.attribute.MonoListAttribute)37 CompositeAttribute (com.agiletec.aps.system.common.entity.model.attribute.CompositeAttribute)27 ApsSystemException (com.agiletec.aps.system.exception.ApsSystemException)22 ArrayList (java.util.ArrayList)18 IApsEntity (com.agiletec.aps.system.common.entity.model.IApsEntity)17 ITextAttribute (com.agiletec.aps.system.common.entity.model.attribute.ITextAttribute)16 DateAttribute (com.agiletec.aps.system.common.entity.model.attribute.DateAttribute)14 NumberAttribute (com.agiletec.aps.system.common.entity.model.attribute.NumberAttribute)12 ListAttribute (com.agiletec.aps.system.common.entity.model.attribute.ListAttribute)11 BooleanAttribute (com.agiletec.aps.system.common.entity.model.attribute.BooleanAttribute)10 IndexableAttributeInterface (com.agiletec.aps.system.common.searchengine.IndexableAttributeInterface)10 HttpSession (javax.servlet.http.HttpSession)10 EntityAttributeIterator (com.agiletec.aps.system.common.util.EntityAttributeIterator)9 IEntityManager (com.agiletec.aps.system.common.entity.IEntityManager)7 MonoTextAttribute (com.agiletec.aps.system.common.entity.model.attribute.MonoTextAttribute)7 Lang (com.agiletec.aps.system.services.lang.Lang)7 Date (java.util.Date)7