Search in sources :

Example 6 with ContentService

use of com.enonic.xp.content.ContentService in project xp by enonic.

the class ExceptionRendererImplTest method setup.

@BeforeEach
void setup() {
    this.resourceService = mock(ResourceService.class);
    this.contentService = mock(ContentService.class);
    this.errorHandlerScriptFactory = mock(ErrorHandlerScriptFactory.class);
    this.postProcessor = new MockPostProcessor();
    this.renderer = new ExceptionRendererImpl(resourceService, errorHandlerScriptFactory, contentService, null, postProcessor, RunMode.DEV);
    this.request = new PortalRequest();
    final HttpServletRequest rawRequest = mock(HttpServletRequest.class);
    this.request.setRawRequest(rawRequest);
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) ResourceService(com.enonic.xp.resource.ResourceService) ContentService(com.enonic.xp.content.ContentService) ErrorHandlerScriptFactory(com.enonic.xp.portal.impl.error.ErrorHandlerScriptFactory) PortalRequest(com.enonic.xp.portal.PortalRequest) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 7 with ContentService

use of com.enonic.xp.content.ContentService in project xp by enonic.

the class MappingHandlerTest method setup.

@BeforeEach
public final void setup() throws Exception {
    this.request = new PortalRequest();
    final ControllerScriptFactory controllerScriptFactory = mock(ControllerScriptFactory.class);
    ControllerScript controllerScript = mock(ControllerScript.class);
    when(controllerScriptFactory.fromDir(Mockito.any())).thenReturn(controllerScript);
    final PortalResponse portalResponse = PortalResponse.create().build();
    when(controllerScript.execute(Mockito.any())).thenReturn(portalResponse);
    FilterScriptFactory filterScriptFactory = mock(FilterScriptFactory.class);
    FilterScript filterScript = mock(FilterScript.class);
    when(filterScriptFactory.fromScript(Mockito.any())).thenReturn(filterScript);
    when(filterScript.execute(Mockito.any(), Mockito.any(), Mockito.any())).thenReturn(portalResponse);
    this.resourceService = mock(ResourceService.class);
    final Resource resourceNotFound = mock(Resource.class);
    when(resourceNotFound.exists()).thenReturn(false);
    final Resource resource = mock(Resource.class);
    when(resource.exists()).thenReturn(true);
    when(this.resourceService.getResource(ResourceKey.from("demo:/services/test"))).thenReturn(resource);
    this.contentService = mock(ContentService.class);
    this.rendererDelegate = mock(RendererDelegate.class);
    this.siteService = mock(SiteService.class);
    this.handler = new MappingHandler(resourceService, controllerScriptFactory, filterScriptFactory, rendererDelegate, new ControllerMappingsResolver(siteService), new ContentResolver(contentService));
    this.request.setMethod(HttpMethod.GET);
}
Also used : FilterScriptFactory(com.enonic.xp.portal.filter.FilterScriptFactory) ControllerScript(com.enonic.xp.portal.controller.ControllerScript) FilterScript(com.enonic.xp.portal.filter.FilterScript) ResourceService(com.enonic.xp.resource.ResourceService) Resource(com.enonic.xp.resource.Resource) ContentService(com.enonic.xp.content.ContentService) ControllerScriptFactory(com.enonic.xp.portal.controller.ControllerScriptFactory) PortalRequest(com.enonic.xp.portal.PortalRequest) ContentResolver(com.enonic.xp.portal.impl.ContentResolver) PortalResponse(com.enonic.xp.portal.PortalResponse) SiteService(com.enonic.xp.site.SiteService) RendererDelegate(com.enonic.xp.portal.impl.rendering.RendererDelegate) BeforeEach(org.junit.jupiter.api.BeforeEach)

Aggregations

ContentService (com.enonic.xp.content.ContentService)7 BeforeEach (org.junit.jupiter.api.BeforeEach)6 PortalRequest (com.enonic.xp.portal.PortalRequest)4 ResourceService (com.enonic.xp.resource.ResourceService)2 HttpServletRequest (javax.servlet.http.HttpServletRequest)2 Attachment (com.enonic.xp.attachment.Attachment)1 ContentId (com.enonic.xp.content.ContentId)1 Media (com.enonic.xp.content.Media)1 SyncContentService (com.enonic.xp.content.SyncContentService)1 ContentDependenciesResolver (com.enonic.xp.core.impl.content.ContentDependenciesResolver)1 ContentOutboundDependenciesIdsResolver (com.enonic.xp.core.impl.content.ContentOutboundDependenciesIdsResolver)1 ContentDataSerializer (com.enonic.xp.core.impl.content.serializer.ContentDataSerializer)1 PortalResponse (com.enonic.xp.portal.PortalResponse)1 ControllerScript (com.enonic.xp.portal.controller.ControllerScript)1 ControllerScriptFactory (com.enonic.xp.portal.controller.ControllerScriptFactory)1 FilterScript (com.enonic.xp.portal.filter.FilterScript)1 FilterScriptFactory (com.enonic.xp.portal.filter.FilterScriptFactory)1 IdProviderControllerExecutionParams (com.enonic.xp.portal.idprovider.IdProviderControllerExecutionParams)1 IdProviderControllerService (com.enonic.xp.portal.idprovider.IdProviderControllerService)1 ContentResolver (com.enonic.xp.portal.impl.ContentResolver)1