Search in sources :

Example 1 with ContentAction

use of com.agiletec.plugins.jacms.apsadmin.content.ContentAction in project entando-core by entando.

the class TestExtendedResourceFinderAction method testJoinImageResource.

public void testJoinImageResource() throws Throwable {
    this.executeEdit("ART102", "admin");
    String contentOnSessionMarker = super.extractSessionMarker("ART102", ApsAdminSystemConstants.EDIT);
    ContentAction action = (ContentAction) this.getAction();
    ImageAttribute imageAttribute = (ImageAttribute) action.getContent().getAttribute("Foto");
    assertNull(imageAttribute.getResource("it"));
    assertNull(imageAttribute.getResource("en"));
    // iniziazione parametri sessione
    HttpSession session = this.getRequest().getSession();
    session.setAttribute(ResourceAttributeActionHelper.ATTRIBUTE_NAME_SESSION_PARAM, "Foto");
    session.setAttribute(ResourceAttributeActionHelper.RESOURCE_TYPE_CODE_SESSION_PARAM, "Image");
    session.setAttribute(ResourceAttributeActionHelper.RESOURCE_LANG_CODE_SESSION_PARAM, "it");
    this.initContentAction("/do/jacms/Content/Resource", "joinResource", contentOnSessionMarker);
    // per replicare il chain in occasione dei chooseResource da edit Contenuto.
    this.addParameter("resourceTypeCode", "Image");
    this.addParameter("resourceId", "44");
    String result = this.executeAction();
    assertEquals(Action.SUCCESS, result);
    ExtendedResourceFinderAction attributeAction = (ExtendedResourceFinderAction) this.getAction();
    imageAttribute = (ImageAttribute) attributeAction.getContent().getAttribute("Foto");
    assertNotNull(imageAttribute.getResource("it"));
    assertEquals("44", imageAttribute.getResource("it").getId());
    assertNull(imageAttribute.getResource("en"));
}
Also used : HttpSession(javax.servlet.http.HttpSession) ContentAction(com.agiletec.plugins.jacms.apsadmin.content.ContentAction) AbstractBaseTestContentAction(com.agiletec.plugins.jacms.apsadmin.content.util.AbstractBaseTestContentAction) ExtendedResourceFinderAction(com.agiletec.plugins.jacms.apsadmin.content.attribute.action.resource.ExtendedResourceFinderAction) ImageAttribute(com.agiletec.plugins.jacms.aps.system.services.content.model.extraAttribute.ImageAttribute)

Aggregations

ImageAttribute (com.agiletec.plugins.jacms.aps.system.services.content.model.extraAttribute.ImageAttribute)1 ContentAction (com.agiletec.plugins.jacms.apsadmin.content.ContentAction)1 ExtendedResourceFinderAction (com.agiletec.plugins.jacms.apsadmin.content.attribute.action.resource.ExtendedResourceFinderAction)1 AbstractBaseTestContentAction (com.agiletec.plugins.jacms.apsadmin.content.util.AbstractBaseTestContentAction)1 HttpSession (javax.servlet.http.HttpSession)1