Search in sources :

Example 46 with RequestContext

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

the class TestDataObjectListHelper 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);
        MockDataObjectListTagBean bean = new MockDataObjectListTagBean();
        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 47 with RequestContext

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

the class TestDataObjectDispenser method testGetUnauthorizedContent.

public void testGetUnauthorizedContent() throws Throwable {
    RequestContext reqCtx = this.getRequestContext();
    DataObjectRenderizationInfo outputInfo = this._dataObjectDispenser.getRenderizationInfo("ART104", 2, "it", reqCtx);
    assertEquals("Current user 'guest' can't view this DataObject", outputInfo.getRenderedDataobject().trim());
    this.setUserOnSession("editorCustomers");
    outputInfo = this._dataObjectDispenser.getRenderizationInfo("ART104", 2, "it", reqCtx);
    assertEquals("Current user 'editorCustomers' can't view this DataObject", outputInfo.getRenderedDataobject().trim());
    this.setUserOnSession("supervisorCustomers");
    outputInfo = this._dataObjectDispenser.getRenderizationInfo("ART104", 2, "it", reqCtx);
    assertEquals("Current user 'supervisorCustomers' can't view this DataObject", outputInfo.getRenderedDataobject().trim());
}
Also used : DataObjectRenderizationInfo(org.entando.entando.aps.system.services.dataobjectdispenser.DataObjectRenderizationInfo) RequestContext(com.agiletec.aps.system.RequestContext)

Example 48 with RequestContext

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

the class TestDataObjectDispenser method testGetRenderedContent_1.

public void testGetRenderedContent_1() throws Throwable {
    RequestContext reqCtx = this.getRequestContext();
    DataObjectRenderizationInfo outputInfo = this._dataObjectDispenser.getRenderizationInfo("ART1", 2, "en", reqCtx);
    assertEquals(this.replaceNewLine(_attendedEnART1_cached.trim()), this.replaceNewLine(outputInfo.getRenderedDataobject().trim()));
    this.setUserOnSession("admin");
    outputInfo = this._dataObjectDispenser.getRenderizationInfo("ART1", 2, "en", reqCtx);
    assertEquals(this.replaceNewLine(_attendedEnART1_cached.trim()), this.replaceNewLine(outputInfo.getRenderedDataobject().trim()));
    outputInfo = this._dataObjectDispenser.getRenderizationInfo("ART104", 2, "it", reqCtx);
    assertEquals(this.replaceNewLine(_attendedItART104_cached.trim()), this.replaceNewLine(outputInfo.getRenderedDataobject().trim()));
    this.setUserOnSession("editorCoach");
    outputInfo = this._dataObjectDispenser.getRenderizationInfo("ART104", 2, "it", reqCtx);
    assertEquals(this.replaceNewLine(_attendedItART104_cached.trim()), this.replaceNewLine(outputInfo.getRenderedDataobject().trim()));
    this.setUserOnSession("pageManagerCoach");
    outputInfo = this._dataObjectDispenser.getRenderizationInfo("ART104", 2, "it", reqCtx);
    assertEquals(this.replaceNewLine(_attendedItART104_cached.trim()), this.replaceNewLine(outputInfo.getRenderedDataobject().trim()));
}
Also used : DataObjectRenderizationInfo(org.entando.entando.aps.system.services.dataobjectdispenser.DataObjectRenderizationInfo) RequestContext(com.agiletec.aps.system.RequestContext)

Example 49 with RequestContext

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

the class TestDataObjectDispenser method testGetRenderedContent_4.

public void testGetRenderedContent_4() throws Throwable {
    String dataobjectId = "ART120";
    String dataobjectShapeModel = "title (Text): testo=$data.Titolo.getText()";
    int modelId = 1972;
    try {
        this.addNewDataObjectModel(modelId, dataobjectShapeModel, "ART");
        RequestContext reqCtx = this.getRequestContext();
        this.setUserOnSession("admin");
        DataObjectRenderizationInfo outputInfo = this._dataObjectDispenser.getRenderizationInfo(dataobjectId, modelId, "en", reqCtx);
        assertEquals("title (Text): testo=Title of Administrator's Content", outputInfo.getRenderedDataobject());
        DataObjectModel model = this._dataObjectModelManager.getDataObjectModel(modelId);
        String newContentShapeModel = "title: testo=$data.Titolo.getText()";
        model.setShape(newContentShapeModel);
        this._dataObjectModelManager.updateDataObjectModel(model);
        this.waitNotifyingThread();
        outputInfo = this._dataObjectDispenser.getRenderizationInfo(dataobjectId, modelId, "en", reqCtx);
        assertEquals("title: testo=Title of Administrator's Content", outputInfo.getRenderedDataobject());
    } catch (Throwable t) {
        throw t;
    } finally {
        DataObjectModel model = this._dataObjectModelManager.getDataObjectModel(modelId);
        if (null != model) {
            this._dataObjectModelManager.removeDataObjectModel(model);
        }
    }
}
Also used : DataObjectRenderizationInfo(org.entando.entando.aps.system.services.dataobjectdispenser.DataObjectRenderizationInfo) DataObjectModel(org.entando.entando.aps.system.services.dataobjectmodel.DataObjectModel) RequestContext(com.agiletec.aps.system.RequestContext)

Example 50 with RequestContext

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

the class TestNavigatorParser method testGetTargets_4.

public void testGetTargets_4() throws Throwable {
    RequestContext reqCtx = this.valueRequestContext("pagina_11", "editorCustomers");
    String spec = "code(homepage).children";
    List<NavigatorTarget> targets = this._navigatorParser.parseSpec(spec, reqCtx);
    assertEquals(3, targets.size());
    NavigatorTarget target0 = targets.get(0);
    assertEquals("pagina_1", target0.getPage().getCode());
    assertEquals(0, target0.getLevel());
    NavigatorTarget target1 = targets.get(1);
    assertEquals("pagina_2", target1.getPage().getCode());
    assertEquals(0, target1.getLevel());
    NavigatorTarget target2 = targets.get(2);
    assertEquals("customers_page", target2.getPage().getCode());
    assertEquals(0, target2.getLevel());
}
Also used : NavigatorTarget(com.agiletec.aps.system.services.page.widget.NavigatorTarget) 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