Search in sources :

Example 11 with RequestContext

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

the class TestContentDispenser method testGetRenderedContent_1.

public void testGetRenderedContent_1() throws Throwable {
    RequestContext reqCtx = this.getRequestContext();
    ContentRenderizationInfo outputInfo = this._contentDispenser.getRenderizationInfo("ART1", 2, "en", reqCtx);
    assertEquals(this.replaceNewLine(_attendedEnART1_cached.trim()), this.replaceNewLine(outputInfo.getCachedRenderedContent().trim()));
    this._contentDispenser.resolveLinks(outputInfo, reqCtx);
    assertEquals(this.replaceNewLine(_attendedEnART1.trim()), this.replaceNewLine(outputInfo.getRenderedContent().trim()));
    this.setUserOnSession("admin");
    outputInfo = this._contentDispenser.getRenderizationInfo("ART1", 2, "en", reqCtx);
    assertEquals(this.replaceNewLine(_attendedEnART1_cached.trim()), this.replaceNewLine(outputInfo.getCachedRenderedContent().trim()));
    this._contentDispenser.resolveLinks(outputInfo, reqCtx);
    assertEquals(this.replaceNewLine(_attendedEnART1.trim()), this.replaceNewLine(outputInfo.getRenderedContent().trim()));
    outputInfo = this._contentDispenser.getRenderizationInfo("ART104", 2, "it", reqCtx);
    assertEquals(this.replaceNewLine(_attendedItART104_cached.trim()), this.replaceNewLine(outputInfo.getCachedRenderedContent().trim()));
    this.setUserOnSession("editorCoach");
    outputInfo = this._contentDispenser.getRenderizationInfo("ART104", 2, "it", reqCtx);
    assertEquals(this.replaceNewLine(_attendedItART104_cached.trim()), this.replaceNewLine(outputInfo.getCachedRenderedContent().trim()));
    this.setUserOnSession("pageManagerCoach");
    outputInfo = this._contentDispenser.getRenderizationInfo("ART104", 2, "it", reqCtx);
    assertEquals(this.replaceNewLine(_attendedItART104_cached.trim()), this.replaceNewLine(outputInfo.getCachedRenderedContent().trim()));
}
Also used : RequestContext(com.agiletec.aps.system.RequestContext)

Example 12 with RequestContext

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

the class TestNavigatorParser method testGetTargets_1.

public void testGetTargets_1() throws Throwable {
    RequestContext reqCtx = this.valueRequestContext("pagina_11", "admin");
    String spec = "current.path";
    List<NavigatorTarget> targets = this._navigatorParser.parseSpec(spec, reqCtx);
    assertEquals(3, targets.size());
    NavigatorTarget target0 = targets.get(0);
    assertEquals("homepage", target0.getPage().getCode());
    NavigatorTarget target1 = targets.get(1);
    assertEquals("pagina_1", target1.getPage().getCode());
    NavigatorTarget target2 = targets.get(2);
    assertEquals("pagina_11", target2.getPage().getCode());
}
Also used : NavigatorTarget(com.agiletec.aps.system.services.page.widget.NavigatorTarget) RequestContext(com.agiletec.aps.system.RequestContext)

Example 13 with RequestContext

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

the class TestNavigatorParser method testGetTargets_5.

public void testGetTargets_5() throws Throwable {
    RequestContext reqCtx = this.valueRequestContext("pagina_1", "editorCoach");
    String spec = "current.subtree(1)+parent.children";
    List<NavigatorTarget> targets = this._navigatorParser.parseSpec(spec, reqCtx);
    assertEquals(7, targets.size());
    NavigatorTarget target0 = targets.get(0);
    assertEquals("pagina_1", target0.getPage().getCode());
    assertEquals(0, target0.getLevel());
    NavigatorTarget target1 = targets.get(1);
    assertEquals("pagina_11", target1.getPage().getCode());
    assertEquals(1, target1.getLevel());
    NavigatorTarget target2 = targets.get(2);
    assertEquals("pagina_12", target2.getPage().getCode());
    assertEquals(1, target2.getLevel());
    NavigatorTarget target3 = targets.get(3);
    assertEquals("pagina_1", target3.getPage().getCode());
    assertEquals(0, target3.getLevel());
    NavigatorTarget target4 = targets.get(4);
    assertEquals("pagina_2", target4.getPage().getCode());
    assertEquals(0, target4.getLevel());
    NavigatorTarget target5 = targets.get(5);
    assertEquals("coach_page", target5.getPage().getCode());
    assertEquals(0, target5.getLevel());
    NavigatorTarget target6 = targets.get(6);
    assertEquals("customers_page", target6.getPage().getCode());
    assertEquals(0, target6.getLevel());
}
Also used : NavigatorTarget(com.agiletec.aps.system.services.page.widget.NavigatorTarget) RequestContext(com.agiletec.aps.system.RequestContext)

Example 14 with RequestContext

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

the class TestNavigatorParser method valueRequestContext.

private RequestContext valueRequestContext(String currentPageCode, String currentUserName) throws Throwable {
    RequestContext reqCtx = this.getRequestContext();
    this.setUserOnSession(currentUserName);
    IPage currentPage = this._pageManager.getOnlinePage(currentPageCode);
    reqCtx.addExtraParam(SystemConstants.EXTRAPAR_CURRENT_PAGE, currentPage);
    return reqCtx;
}
Also used : IPage(com.agiletec.aps.system.services.page.IPage) RequestContext(com.agiletec.aps.system.RequestContext)

Example 15 with RequestContext

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

the class TestURLManager method testGetURLString_2.

public void testGetURLString_2() throws Throwable {
    RequestContext reqCtx = this.getRequestContext();
    PageURL pageURL = _urlManager.createURL(reqCtx);
    pageURL.setLangCode("en");
    pageURL.setPageCode("pagina_11");
    try {
        String url = this._urlManager.getURLString(pageURL, reqCtx);
        assertEquals("/Entando/en/pagina_11.page", url);
        this.changeUrlStyle(SystemConstants.CONFIG_PARAM_URL_STYLE_BREADCRUMBS);
        url = this._urlManager.getURLString(pageURL, reqCtx);
        assertEquals("/Entando/pages/en/homepage/pagina_1/pagina_11/", url);
    } catch (Throwable t) {
        throw t;
    } finally {
        this.changeUrlStyle(SystemConstants.CONFIG_PARAM_URL_STYLE_CLASSIC);
    }
}
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