Search in sources :

Example 56 with RequestContext

use of com.agiletec.aps.system.RequestContext in project entando-core by entando.

the class TestContentListHelper method testGetContents_2.

public void testGetContents_2() throws Throwable {
    String pageCode = "pagina_1";
    int frame = 1;
    try {
        this.setUserOnSession("admin");
        RequestContext reqCtx = this.valueRequestContext(pageCode, frame);
        MockContentListTagBean bean = new MockContentListTagBean();
        bean.setContentType("EVN");
        bean.addCategory("evento");
        EntitySearchFilter filter = new EntitySearchFilter("DataInizio", true);
        filter.setOrder(EntitySearchFilter.DESC_ORDER);
        bean.addFilter(filter);
        List<String> contents = this._helper.getContentsId(bean, reqCtx);
        String[] expected = { "EVN193", "EVN192" };
        assertEquals(expected.length, contents.size());
        for (int i = 0; i < expected.length; i++) {
            assertEquals(expected[i], contents.get(i));
        }
    } catch (Throwable t) {
        throw t;
    } finally {
        this.setPageWidgets(pageCode, frame, null);
    }
}
Also used : RequestContext(com.agiletec.aps.system.RequestContext) EntitySearchFilter(com.agiletec.aps.system.common.entity.model.EntitySearchFilter)

Example 57 with RequestContext

use of com.agiletec.aps.system.RequestContext in project entando-core by entando.

the class TestContentDispenser method testGetRenderedContent_2.

public void testGetRenderedContent_2() throws Throwable {
    RequestContext reqCtx = this.getRequestContext();
    this.setUserOnSession("admin");
    ContentRenderizationInfo outputInfo = this._contentDispenser.getRenderizationInfo("ART120", 2, "it", reqCtx);
    assertEquals(this.replaceNewLine(_attendedItART120_cached.trim()), this.replaceNewLine(outputInfo.getCachedRenderedContent().trim()));
    this._contentDispenser.resolveLinks(outputInfo, reqCtx);
    assertEquals(this.replaceNewLine(_attendedItART120.trim()), this.replaceNewLine(outputInfo.getRenderedContent().trim()));
    outputInfo = this._contentDispenser.getRenderizationInfo("ART120", 2, "en", reqCtx);
    assertEquals(this.replaceNewLine(_attendedEnART120_cached.trim()), this.replaceNewLine(outputInfo.getCachedRenderedContent().trim()));
    this._contentDispenser.resolveLinks(outputInfo, reqCtx);
    assertEquals(this.replaceNewLine(_attendedEnART120.trim()), this.replaceNewLine(outputInfo.getRenderedContent().trim()));
    outputInfo = this._contentDispenser.getRenderizationInfo("ART121", 2, "it", reqCtx);
    assertEquals(this.replaceNewLine(_attendedItART121_cached.trim()), this.replaceNewLine(outputInfo.getCachedRenderedContent().trim()));
    outputInfo = this._contentDispenser.getRenderizationInfo("ART121", 2, "en", reqCtx);
    assertEquals(this.replaceNewLine(_attendedEnART121_cached.trim()), this.replaceNewLine(outputInfo.getCachedRenderedContent().trim()));
    outputInfo = this._contentDispenser.getRenderizationInfo("ART122", 2, "en", reqCtx);
    assertEquals(this.replaceNewLine(_attendedEnART122_cached.trim()), this.replaceNewLine(outputInfo.getCachedRenderedContent().trim()));
}
Also used : RequestContext(com.agiletec.aps.system.RequestContext)

Example 58 with RequestContext

use of com.agiletec.aps.system.RequestContext in project entando-core by entando.

the class TestContentDispenser method testGetUnauthorizedContent.

public void testGetUnauthorizedContent() throws Throwable {
    RequestContext reqCtx = this.getRequestContext();
    ContentRenderizationInfo outputInfo = this._contentDispenser.getRenderizationInfo("ART104", 2, "it", reqCtx);
    assertEquals("Current user 'guest' can't view this content", outputInfo.getCachedRenderedContent().trim());
    this.setUserOnSession("editorCustomers");
    outputInfo = this._contentDispenser.getRenderizationInfo("ART104", 2, "it", reqCtx);
    assertEquals("Current user 'editorCustomers' can't view this content", outputInfo.getCachedRenderedContent().trim());
    this.setUserOnSession("supervisorCustomers");
    outputInfo = this._contentDispenser.getRenderizationInfo("ART104", 2, "it", reqCtx);
    assertEquals("Current user 'supervisorCustomers' can't view this content", outputInfo.getCachedRenderedContent().trim());
}
Also used : RequestContext(com.agiletec.aps.system.RequestContext)

Example 59 with RequestContext

use of com.agiletec.aps.system.RequestContext in project entando-core by entando.

the class TestContentDispenser method testGetRenderedContent_4.

public void testGetRenderedContent_4() throws Throwable {
    String contentId = "ART120";
    String contentShapeModel = "title (Text): testo=$content.Titolo.getText()";
    int modelId = 1972;
    try {
        this.addNewContentModel(modelId, contentShapeModel, "ART");
        RequestContext reqCtx = this.getRequestContext();
        this.setUserOnSession("admin");
        ContentRenderizationInfo outputInfo = this._contentDispenser.getRenderizationInfo(contentId, modelId, "en", reqCtx);
        assertEquals("title (Text): testo=Title of Administrator's Content", outputInfo.getCachedRenderedContent());
        ContentModel model = this._contentModelManager.getContentModel(modelId);
        String newContentShapeModel = "title: testo=$content.Titolo.getText()";
        model.setContentShape(newContentShapeModel);
        this._contentModelManager.updateContentModel(model);
        this.waitNotifyingThread();
        outputInfo = this._contentDispenser.getRenderizationInfo(contentId, modelId, "en", reqCtx);
        assertEquals("title: testo=Title of Administrator's Content", outputInfo.getCachedRenderedContent());
    } catch (Throwable t) {
        throw t;
    } finally {
        ContentModel model = this._contentModelManager.getContentModel(modelId);
        if (null != model) {
            this._contentModelManager.removeContentModel(model);
        }
    }
}
Also used : ContentModel(com.agiletec.plugins.jacms.aps.system.services.contentmodel.ContentModel) RequestContext(com.agiletec.aps.system.RequestContext)

Example 60 with RequestContext

use of com.agiletec.aps.system.RequestContext in project entando-core by entando.

the class TestContentDispenser method testGetRenderedContentWithWrongModel.

public void testGetRenderedContentWithWrongModel() throws Throwable {
    RequestContext reqCtx = this.getRequestContext();
    String output = _contentDispenser.getRenderedContent("ART1", 67, "en", reqCtx);
    assertEquals("Content model 67 undefined", output.trim());
}
Also used : RequestContext(com.agiletec.aps.system.RequestContext)

Aggregations

RequestContext (com.agiletec.aps.system.RequestContext)89 ServletRequest (javax.servlet.ServletRequest)25 JspException (javax.servlet.jsp.JspException)22 IPage (com.agiletec.aps.system.services.page.IPage)15 MockHttpServletRequest (org.springframework.mock.web.MockHttpServletRequest)12 Lang (com.agiletec.aps.system.services.lang.Lang)10 EntitySearchFilter (com.agiletec.aps.system.common.entity.model.EntitySearchFilter)9 HttpServletRequest (javax.servlet.http.HttpServletRequest)6 Widget (com.agiletec.aps.system.services.page.Widget)5 NavigatorTarget (com.agiletec.aps.system.services.page.widget.NavigatorTarget)5 IURLManager (com.agiletec.aps.system.services.url.IURLManager)5 ContentRenderizationInfo (com.agiletec.plugins.jacms.aps.system.services.dispenser.ContentRenderizationInfo)5 DataObjectRenderizationInfo (org.entando.entando.aps.system.services.dataobjectdispenser.DataObjectRenderizationInfo)5 ILangManager (com.agiletec.aps.system.services.lang.ILangManager)4 UserDetails (com.agiletec.aps.system.services.user.UserDetails)4 ControllerManager (com.agiletec.aps.system.services.controller.ControllerManager)3 HeadInfoContainer (com.agiletec.aps.tags.util.HeadInfoContainer)3 Content (com.agiletec.plugins.jacms.aps.system.services.content.model.Content)3 IContentListWidgetHelper (com.agiletec.plugins.jacms.aps.system.services.content.widget.IContentListWidgetHelper)3 IContentViewerHelper (com.agiletec.plugins.jacms.aps.system.services.content.widget.IContentViewerHelper)3