Search in sources :

Example 6 with ResponseProcessorDescriptor

use of com.enonic.xp.site.processor.ResponseProcessorDescriptor 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

ResponseProcessorDescriptor (com.enonic.xp.site.processor.ResponseProcessorDescriptor)6 PortalResponse (com.enonic.xp.portal.PortalResponse)4 Test (org.junit.jupiter.api.Test)4 PortalRequest (com.enonic.xp.portal.PortalRequest)3 PortalScriptService (com.enonic.xp.portal.script.PortalScriptService)3 ResourceKey (com.enonic.xp.resource.ResourceKey)3 ScriptExports (com.enonic.xp.script.ScriptExports)3 SiteConfig (com.enonic.xp.site.SiteConfig)2 SiteDescriptor (com.enonic.xp.site.SiteDescriptor)2 ResponseProcessorDescriptors (com.enonic.xp.site.processor.ResponseProcessorDescriptors)2 ApplicationKey (com.enonic.xp.app.ApplicationKey)1 PropertyTree (com.enonic.xp.data.PropertyTree)1 PortalRequestMapper (com.enonic.xp.portal.impl.mapper.PortalRequestMapper)1 PortalResponseMapper (com.enonic.xp.portal.impl.mapper.PortalResponseMapper)1 RenderException (com.enonic.xp.portal.impl.rendering.RenderException)1 ScriptValue (com.enonic.xp.script.ScriptValue)1 Trace (com.enonic.xp.trace.Trace)1 ByteSource (com.google.common.io.ByteSource)1 ArrayList (java.util.ArrayList)1