Search in sources :

Example 66 with PortalRequest

use of com.enonic.xp.portal.PortalRequest in project xp by enonic.

the class UnknownEndpointHandlerTest method setUp.

@BeforeEach
public void setUp() {
    this.handler = new UnknownEndpointHandler();
    this.request = new PortalRequest();
}
Also used : PortalRequest(com.enonic.xp.portal.PortalRequest) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 67 with PortalRequest

use of com.enonic.xp.portal.PortalRequest in project xp by enonic.

the class IdProviderControllerServiceImplTest method executeMissingIdProvider.

@Test
public void executeMissingIdProvider() throws IOException {
    final IdProviderControllerExecutionParams executionParams = IdProviderControllerExecutionParams.create().portalRequest(new PortalRequest()).idProviderKey(IdProviderKey.from("missingidprovider")).functionName("missingfunction").build();
    final PortalResponse portalResponse = idProviderControllerService.execute(executionParams);
    assertNull(portalResponse);
}
Also used : PortalResponse(com.enonic.xp.portal.PortalResponse) IdProviderControllerExecutionParams(com.enonic.xp.portal.idprovider.IdProviderControllerExecutionParams) PortalRequest(com.enonic.xp.portal.PortalRequest) AbstractControllerTest(com.enonic.xp.portal.impl.controller.AbstractControllerTest) Test(org.junit.jupiter.api.Test)

Example 68 with PortalRequest

use of com.enonic.xp.portal.PortalRequest in project xp by enonic.

the class IdProviderControllerServiceImplTest method executeMissingFunction.

@Test
public void executeMissingFunction() throws IOException {
    final IdProviderControllerExecutionParams executionParams = IdProviderControllerExecutionParams.create().portalRequest(new PortalRequest()).idProviderKey(IdProviderKey.from("myemptyidprovider")).functionName("missingfunction").build();
    final PortalResponse portalResponse = idProviderControllerService.execute(executionParams);
    assertNull(portalResponse);
}
Also used : PortalResponse(com.enonic.xp.portal.PortalResponse) IdProviderControllerExecutionParams(com.enonic.xp.portal.idprovider.IdProviderControllerExecutionParams) PortalRequest(com.enonic.xp.portal.PortalRequest) AbstractControllerTest(com.enonic.xp.portal.impl.controller.AbstractControllerTest) Test(org.junit.jupiter.api.Test)

Example 69 with PortalRequest

use of com.enonic.xp.portal.PortalRequest in project xp by enonic.

the class PortalRequestMapperTest method setup.

@BeforeEach
public void setup() {
    this.portalRequest = new PortalRequest();
    this.portalRequest.setMethod(HttpMethod.GET);
    this.portalRequest.setScheme("http");
    this.portalRequest.setHost("localhost");
    this.portalRequest.setPort(80);
    this.portalRequest.setRemoteAddress("10.0.0.1");
    this.portalRequest.setPath("/site/live/master/a/b");
    this.portalRequest.setRawPath("/site/live/master/a/b");
    this.portalRequest.setContextPath("/site/live/master/a");
    this.portalRequest.setUrl("http://localhost/site/live/master/a/b?param1=value1");
    this.portalRequest.setValidTicket(Boolean.TRUE);
    this.portalRequest.getParams().put("param1", "value1");
    this.portalRequest.getParams().put("param2", "value2");
    this.portalRequest.getParams().put("param3", "value3-A");
    this.portalRequest.getParams().put("param3", "value3-B");
    this.portalRequest.getHeaders().put("header1", "value1");
    this.portalRequest.getHeaders().put("header2", "value2");
    this.portalRequest.getHeaders().put("header3", "value3");
    this.portalRequest.setApplicationKey(ApplicationKey.from("myapplication"));
    this.portalRequest.setContent(ContentFixtures.newContent());
    this.portalRequest.setSite(ContentFixtures.newSite());
    this.portalRequest.setPageDescriptor(ContentFixtures.newPageDescriptor());
}
Also used : PortalRequest(com.enonic.xp.portal.PortalRequest) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 70 with PortalRequest

use of com.enonic.xp.portal.PortalRequest in project xp by enonic.

the class PostProcessorImplTest method testPostProcessingInjections.

private void testPostProcessingInjections(final HttpMethod httpMethod) throws Exception {
    final String html = readResource("postProcessSource2.html");
    final PostProcessorImpl postProcessor = new PostProcessorImpl();
    postProcessor.addInjection(new TestPostProcessInjection());
    final PortalResponse.Builder portalResponseBuilder = PortalResponse.create().contentType(MediaType.HTML_UTF_8).body(html);
    final PortalRequest portalRequest = new PortalRequest();
    portalRequest.setMethod(httpMethod);
    final PortalResponse portalResponse = postProcessor.processResponse(portalRequest, portalResponseBuilder.build());
    final String outputHtml = portalResponse.getBody().toString();
    final String expectedResult = readResource("postProcessResult2.html");
    assertEqualsTrimmed(expectedResult, outputHtml);
}
Also used : PortalResponse(com.enonic.xp.portal.PortalResponse) PortalRequest(com.enonic.xp.portal.PortalRequest)

Aggregations

PortalRequest (com.enonic.xp.portal.PortalRequest)103 Test (org.junit.jupiter.api.Test)47 BeforeEach (org.junit.jupiter.api.BeforeEach)35 PortalResponse (com.enonic.xp.portal.PortalResponse)25 Site (com.enonic.xp.site.Site)19 Content (com.enonic.xp.content.Content)12 HttpServletRequest (javax.servlet.http.HttpServletRequest)11 ApplicationKey (com.enonic.xp.app.ApplicationKey)10 ContentPath (com.enonic.xp.content.ContentPath)10 ContentService (com.enonic.xp.content.ContentService)10 ControllerScriptFactory (com.enonic.xp.portal.controller.ControllerScriptFactory)10 ControllerScript (com.enonic.xp.portal.controller.ControllerScript)9 ResourceKey (com.enonic.xp.resource.ResourceKey)9 ResourceService (com.enonic.xp.resource.ResourceService)9 ContentId (com.enonic.xp.content.ContentId)7 Matcher (java.util.regex.Matcher)7 Assertions.assertEquals (org.junit.jupiter.api.Assertions.assertEquals)7 Assertions.assertNull (org.junit.jupiter.api.Assertions.assertNull)7 Assertions.fail (org.junit.jupiter.api.Assertions.fail)7 Mockito.when (org.mockito.Mockito.when)7