use of com.enonic.xp.portal.PortalRequest in project xp by enonic.
the class AssetHandlerTest method setup.
@BeforeEach
public final void setup() throws Exception {
this.request = new PortalRequest();
this.resources = new HashMap<>();
resourceService = Mockito.mock(ResourceService.class);
when(resourceService.getResource(Mockito.any())).then(this::getResource);
this.handler = new AssetHandler(resourceService);
this.handler.activate(mock(PortalConfig.class, invocation -> invocation.getMethod().getDefaultValue()));
this.nullResource = Mockito.mock(Resource.class);
when(this.nullResource.exists()).thenReturn(false);
this.request.setMethod(HttpMethod.GET);
this.request.setEndpointPath("/_/asset/demo/css/main.css");
}
use of com.enonic.xp.portal.PortalRequest in project xp by enonic.
the class ImageHandlerTest method setup.
@BeforeEach
final void setup() {
this.request = new PortalRequest();
this.contentService = mock(ContentService.class);
this.imageService = mock(ImageService.class);
this.mediaInfoService = mock(MediaInfoService.class);
this.handler = new ImageHandler();
this.handler.setContentService(this.contentService);
this.handler.setImageService(this.imageService);
this.handler.setMediaInfoService(this.mediaInfoService);
this.handler.activate(mock(PortalConfig.class, invocation -> invocation.getMethod().getDefaultValue()));
this.request.setMethod(HttpMethod.GET);
this.request.setBranch(ContentConstants.BRANCH_MASTER);
this.request.setBaseUri("/site");
this.request.setContentPath(ContentPath.from("/path/to/content"));
this.request.setEndpointPath("/_/image/123456/scale-100-100/image-name.jpg");
}
use of com.enonic.xp.portal.PortalRequest in project xp by enonic.
the class IdentityHandlerTest method setup.
@BeforeEach
public final void setup() throws Exception {
this.request = new PortalRequest();
final ContentService contentService = Mockito.mock(ContentService.class);
final IdProviderControllerService idProviderControllerService = Mockito.mock(IdProviderControllerService.class);
final HttpServletRequest rawRequest = Mockito.mock(HttpServletRequest.class);
Mockito.when(idProviderControllerService.execute(Mockito.any())).thenAnswer(invocation -> {
Object[] args = invocation.getArguments();
final IdProviderControllerExecutionParams arg = (IdProviderControllerExecutionParams) args[0];
if (IdProviderKey.from("myidprovider").equals(arg.getIdProviderKey()) && "get".equals(arg.getFunctionName())) {
return PortalResponse.create().build();
}
return null;
});
this.handler = new IdentityHandler();
this.handler.setContentService(contentService);
this.handler.setIdProviderControllerService(idProviderControllerService);
this.request.setMethod(HttpMethod.GET);
this.request.setEndpointPath("/_/idprovider/myidprovider?param1=value1");
this.request.setRawPath("/site/draft/_/idprovider/myidprovider?param1=value1");
this.request.setRawRequest(rawRequest);
}
use of com.enonic.xp.portal.PortalRequest in project xp by enonic.
the class IdProviderControllerServiceImplTest method executeIdProviderWithoutApplication.
@Test
public void executeIdProviderWithoutApplication() throws IOException {
final IdProviderControllerExecutionParams executionParams = IdProviderControllerExecutionParams.create().portalRequest(new PortalRequest()).idProviderKey(IdProviderKey.from("myemptyidprovider")).functionName("myfunction").build();
final PortalResponse portalResponse = idProviderControllerService.execute(executionParams);
assertNull(portalResponse);
}
use of com.enonic.xp.portal.PortalRequest in project xp by enonic.
the class IdProviderControllerServiceImplTest method execute.
@Test
public void execute() throws IOException {
final IdProviderControllerExecutionParams executionParams = IdProviderControllerExecutionParams.create().portalRequest(new PortalRequest()).idProviderKey(IdProviderKey.from("myidprovider")).functionName("myfunction").build();
final PortalResponse portalResponse = idProviderControllerService.execute(executionParams);
assertNotNull(portalResponse);
assertEquals(HttpStatus.OK, portalResponse.getStatus());
assertEquals("myapplication/myfunction", portalResponse.getBody());
}
Aggregations