Search in sources :

Example 6 with RenderException

use of com.enonic.xp.portal.impl.rendering.RenderException in project xp by enonic.

the class MacroInstructionTest method testMacroInstructionMissingController.

@Test
public void testMacroInstructionMissingController() throws Exception {
    MacroKey key = MacroKey.from("myapp:mymacro");
    MacroDescriptor macroDescriptor = MacroDescriptor.create().key(key).build();
    when(macroDescriptorService.getByKey(key)).thenReturn(macroDescriptor);
    try {
        macroInstruction.evaluate(portalRequest, "MACRO _name=\"mymacro\" param1=\"value1\" _body=\"body\"");
        fail("Expected exception");
    } catch (RenderException e) {
        assertEquals("Macro controller not found: mymacro", e.getMessage());
    }
}
Also used : MacroKey(com.enonic.xp.macro.MacroKey) RenderException(com.enonic.xp.portal.impl.rendering.RenderException) MacroDescriptor(com.enonic.xp.macro.MacroDescriptor) Test(org.junit.jupiter.api.Test)

Example 7 with RenderException

use of com.enonic.xp.portal.impl.rendering.RenderException in project xp by enonic.

the class ResponseProcessorExecutorTest method testExecuteResponseProcessorNotImplementingMethod.

@Test
public void testExecuteResponseProcessorNotImplementingMethod() throws Exception {
    final PortalScriptService scriptService = Mockito.mock(PortalScriptService.class);
    final ScriptExports scriptExports = Mockito.mock(ScriptExports.class);
    when(scriptService.execute(any(ResourceKey.class))).thenReturn(scriptExports);
    final ResponseProcessorExecutor filterExecutor = new ResponseProcessorExecutor(scriptService);
    final ResponseProcessorDescriptor filter = ResponseProcessorDescriptor.create().application(ApplicationKey.from("myApp")).name("filter1").build();
    final PortalRequest request = new PortalRequest();
    final PortalResponse response = PortalResponse.create().build();
    try {
        filterExecutor.execute(filter, request, response);
        fail("Expected exception");
    } catch (RenderException e) {
        assertEquals("Missing exported function [responseProcessor] in response filter [/site/processors/filter1.js]", e.getMessage());
    }
}
Also used : PortalResponse(com.enonic.xp.portal.PortalResponse) RenderException(com.enonic.xp.portal.impl.rendering.RenderException) PortalScriptService(com.enonic.xp.portal.script.PortalScriptService) ResponseProcessorDescriptor(com.enonic.xp.site.processor.ResponseProcessorDescriptor) ScriptExports(com.enonic.xp.script.ScriptExports) ResourceKey(com.enonic.xp.resource.ResourceKey) PortalRequest(com.enonic.xp.portal.PortalRequest) Test(org.junit.jupiter.api.Test)

Aggregations

RenderException (com.enonic.xp.portal.impl.rendering.RenderException)7 ApplicationKey (com.enonic.xp.app.ApplicationKey)2 MacroDescriptor (com.enonic.xp.macro.MacroDescriptor)2 Component (com.enonic.xp.region.Component)2 LayoutComponent (com.enonic.xp.region.LayoutComponent)2 ResourceKey (com.enonic.xp.resource.ResourceKey)2 ScriptExports (com.enonic.xp.script.ScriptExports)2 Test (org.junit.jupiter.api.Test)2 Content (com.enonic.xp.content.Content)1 MacroKey (com.enonic.xp.macro.MacroKey)1 Page (com.enonic.xp.page.Page)1 PageRegions (com.enonic.xp.page.PageRegions)1 PortalRequest (com.enonic.xp.portal.PortalRequest)1 PortalResponse (com.enonic.xp.portal.PortalResponse)1 MacroContext (com.enonic.xp.portal.macro.MacroContext)1 MacroProcessor (com.enonic.xp.portal.macro.MacroProcessor)1 PostProcessInstruction (com.enonic.xp.portal.postprocess.PostProcessInstruction)1 PortalScriptService (com.enonic.xp.portal.script.PortalScriptService)1 LayoutRegions (com.enonic.xp.region.LayoutRegions)1 ResourceNotFoundException (com.enonic.xp.resource.ResourceNotFoundException)1