Search in sources :

Example 51 with Content

use of com.agiletec.plugins.jacms.aps.system.services.content.model.Content 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 52 with Content

use of com.agiletec.plugins.jacms.aps.system.services.content.model.Content 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 53 with Content

use of com.agiletec.plugins.jacms.aps.system.services.content.model.Content in project entando-core by entando.

the class TestContentAction method testJoinRemoveGroup.

public void testJoinRemoveGroup() throws Throwable {
    String contentId = "ART1";
    String contentOnSessionMarker = this.extractSessionMarker(contentId, ApsAdminSystemConstants.EDIT);
    this.executeEdit(contentId, "admin");
    String groupToAdd = "coach";
    String extraGroupFieldName = "extraGroupName";
    Content contentOnSession = this.getContentOnEdit(contentOnSessionMarker);
    assertNotNull(contentOnSession);
    assertEquals(0, contentOnSession.getGroups().size());
    this.initContentAction("/do/jacms/Content", "joinGroup", contentOnSessionMarker);
    this.addParameter(extraGroupFieldName, groupToAdd);
    String result = this.executeAction();
    assertEquals(Action.SUCCESS, result);
    contentOnSession = this.getContentOnEdit(contentOnSessionMarker);
    assertNotNull(contentOnSession);
    assertEquals(1, contentOnSession.getGroups().size());
    // tentativo aggiunta gruppo duplicata
    this.initContentAction("/do/jacms/Content", "joinGroup", contentOnSessionMarker);
    this.addParameter(extraGroupFieldName, groupToAdd);
    result = this.executeAction();
    assertEquals(Action.SUCCESS, result);
    contentOnSession = this.getContentOnEdit(contentOnSessionMarker);
    assertNotNull(contentOnSession);
    assertEquals(1, contentOnSession.getGroups().size());
    // tentativo aggiunta gruppo inesistente
    this.initContentAction("/do/jacms/Content", "joinGroup", contentOnSessionMarker);
    this.addParameter("contentOnSessionMarker", contentOnSessionMarker);
    this.addParameter(extraGroupFieldName, "wrongGroupCode");
    result = this.executeAction();
    assertEquals(Action.SUCCESS, result);
    contentOnSession = this.getContentOnEdit(contentOnSessionMarker);
    assertNotNull(contentOnSession);
    assertEquals(1, contentOnSession.getGroups().size());
    this.initContentAction("/do/jacms/Content", "removeGroup", contentOnSessionMarker);
    this.addParameter(extraGroupFieldName, groupToAdd);
    result = this.executeAction();
    assertEquals(Action.SUCCESS, result);
    contentOnSession = this.getContentOnEdit(contentOnSessionMarker);
    assertNotNull(contentOnSession);
    assertEquals(0, contentOnSession.getGroups().size());
}
Also used : Content(com.agiletec.plugins.jacms.aps.system.services.content.model.Content)

Example 54 with Content

use of com.agiletec.plugins.jacms.aps.system.services.content.model.Content in project entando-core by entando.

the class TestContentAction method testSuccesfullEdit.

private void testSuccesfullEdit(String contentId, String currentUserName) throws Throwable {
    Content content = this.getContentManager().loadContent(contentId, false);
    String result = this.executeEdit(contentId, currentUserName);
    assertEquals(Action.SUCCESS, result);
    try {
        String contentSessionMarker = AbstractContentAction.buildContentOnSessionMarker(content, ApsAdminSystemConstants.EDIT);
        Content currentContent = this.getContentOnEdit(contentSessionMarker);
        assertEquals(content.getId(), currentContent.getId());
        assertEquals(content.getTypeCode(), currentContent.getTypeCode());
        assertEquals(content.getDescription(), currentContent.getDescription());
        assertEquals(content.getMainGroup(), currentContent.getMainGroup());
    } catch (Throwable t) {
        throw t;
    }
}
Also used : Content(com.agiletec.plugins.jacms.aps.system.services.content.model.Content)

Example 55 with Content

use of com.agiletec.plugins.jacms.aps.system.services.content.model.Content in project entando-core by entando.

the class TestContentAction method testSuspendReferencedContent.

public void testSuspendReferencedContent() throws Throwable {
    String contentId = "ART1";
    Content master = this.getContentManager().loadContent(contentId, false);
    String contentOnSessionMarker = AbstractContentAction.buildContentOnSessionMarker(master, ApsAdminSystemConstants.EDIT);
    try {
        this.executeEdit(contentId, "admin");
        Content contentOnSession = this.getContentOnEdit(contentOnSessionMarker);
        assertNotNull(contentOnSession);
        this.initContentAction("/do/jacms/Content", "suspend", contentOnSessionMarker);
        String result = this.executeAction();
        assertEquals("references", result);
        ContentAction action = (ContentAction) this.getAction();
        List contentUtilizers = (List) action.getReferences().get("jacmsContentManagerUtilizers");
        assertEquals(2, contentUtilizers.size());
        List pageUtilizers = (List) action.getReferences().get("CmsPageManagerWrapperUtilizers");
        assertEquals(1, pageUtilizers.size());
        IPage publicPageUtilizer = (IPage) pageUtilizers.get(0);
        assertEquals("homepage", publicPageUtilizer.getCode());
        assertTrue(publicPageUtilizer.isOnlineInstance());
    } catch (Throwable t) {
        this.getContentManager().insertOnLineContent(master);
        throw t;
    }
}
Also used : IPage(com.agiletec.aps.system.services.page.IPage) Content(com.agiletec.plugins.jacms.aps.system.services.content.model.Content) AbstractBaseTestContentAction(com.agiletec.plugins.jacms.apsadmin.content.util.AbstractBaseTestContentAction) List(java.util.List)

Aggregations

Content (com.agiletec.plugins.jacms.aps.system.services.content.model.Content)227 AttributeInterface (com.agiletec.aps.system.common.entity.model.attribute.AttributeInterface)55 AttributeTracer (com.agiletec.aps.system.common.entity.model.AttributeTracer)35 MonoListAttribute (com.agiletec.aps.system.common.entity.model.attribute.MonoListAttribute)29 ArrayList (java.util.ArrayList)26 ApsSystemException (com.agiletec.aps.system.exception.ApsSystemException)17 ActionSupport (com.opensymphony.xwork2.ActionSupport)14 List (java.util.List)14 CompositeAttribute (com.agiletec.aps.system.common.entity.model.attribute.CompositeAttribute)13 HttpSession (javax.servlet.http.HttpSession)13 UserDetails (com.agiletec.aps.system.services.user.UserDetails)12 IPage (com.agiletec.aps.system.services.page.IPage)10 Date (java.util.Date)8 EntitySearchFilter (com.agiletec.aps.system.common.entity.model.EntitySearchFilter)7 ITextAttribute (com.agiletec.aps.system.common.entity.model.attribute.ITextAttribute)7 LinkAttribute (com.agiletec.plugins.jacms.aps.system.services.content.model.extraAttribute.LinkAttribute)7 ResourceInterface (com.agiletec.plugins.jacms.aps.system.services.resource.model.ResourceInterface)7 ApiException (org.entando.entando.aps.system.services.api.model.ApiException)7 ListAttribute (com.agiletec.aps.system.common.entity.model.attribute.ListAttribute)6 TextAttribute (com.agiletec.aps.system.common.entity.model.attribute.TextAttribute)6