Search in sources :

Example 6 with PageUrlParams

use of com.enonic.xp.portal.url.PageUrlParams in project xp by enonic.

the class PortalUrlServiceImpl_pageUrlTest method createUrl_withId.

@Test
public void createUrl_withId() {
    final Content content = ContentFixtures.newContent();
    Mockito.when(this.contentService.getById(content.getId())).thenReturn(content);
    final PageUrlParams params = new PageUrlParams().portalRequest(this.portalRequest).id("123456");
    final String url = this.service.pageUrl(params);
    assertEquals("/site/default/draft/a/b/mycontent", url);
}
Also used : Content(com.enonic.xp.content.Content) PageUrlParams(com.enonic.xp.portal.url.PageUrlParams) Test(org.junit.jupiter.api.Test)

Example 7 with PageUrlParams

use of com.enonic.xp.portal.url.PageUrlParams in project xp by enonic.

the class PortalUrlServiceImpl_pageUrlTest method createUrl_withAbsolutePath.

@Test
public void createUrl_withAbsolutePath() {
    final PageUrlParams params = new PageUrlParams().portalRequest(this.portalRequest).path("/a/b");
    final String url = this.service.pageUrl(params);
    assertEquals("/site/default/draft/a/b", url);
}
Also used : PageUrlParams(com.enonic.xp.portal.url.PageUrlParams) Test(org.junit.jupiter.api.Test)

Example 8 with PageUrlParams

use of com.enonic.xp.portal.url.PageUrlParams in project xp by enonic.

the class PortalUrlServiceImpl_pageUrlTest method createUrl_withId_notFound.

@Test
public void createUrl_withId_notFound() {
    final Content content = ContentFixtures.newContent();
    Mockito.when(this.contentService.getById(content.getId())).thenThrow(new ContentNotFoundException(content.getId(), Branch.from("draft")));
    final PageUrlParams params = new PageUrlParams().portalRequest(this.portalRequest).id("123456");
    final String url = this.service.pageUrl(params);
    assertEquals("/site/default/draft/context/path/_/error/404?message=Content+with+id+%5B123456%5D+was+not+found+in+branch+%5Bdraft%5D", url);
}
Also used : ContentNotFoundException(com.enonic.xp.content.ContentNotFoundException) Content(com.enonic.xp.content.Content) PageUrlParams(com.enonic.xp.portal.url.PageUrlParams) Test(org.junit.jupiter.api.Test)

Example 9 with PageUrlParams

use of com.enonic.xp.portal.url.PageUrlParams in project xp by enonic.

the class PortalUrlServiceImpl_pageUrlTest method createUrl_withIdAndPath.

@Test
public void createUrl_withIdAndPath() {
    final Content content = ContentFixtures.newContent();
    Mockito.when(this.contentService.getById(content.getId())).thenReturn(content);
    final PageUrlParams params = new PageUrlParams().portalRequest(this.portalRequest).id("123456").path("/a/b");
    final String url = this.service.pageUrl(params);
    assertEquals("/site/default/draft/a/b/mycontent", url);
}
Also used : Content(com.enonic.xp.content.Content) PageUrlParams(com.enonic.xp.portal.url.PageUrlParams) Test(org.junit.jupiter.api.Test)

Aggregations

PageUrlParams (com.enonic.xp.portal.url.PageUrlParams)9 Test (org.junit.jupiter.api.Test)7 Content (com.enonic.xp.content.Content)3 ApplicationKey (com.enonic.xp.app.ApplicationKey)1 ApplicationKeys (com.enonic.xp.app.ApplicationKeys)1 ContentNotFoundException (com.enonic.xp.content.ContentNotFoundException)1 Property (com.enonic.xp.data.Property)1 PortalRequest (com.enonic.xp.portal.PortalRequest)1 AttachmentUrlParams (com.enonic.xp.portal.url.AttachmentUrlParams)1 ImageUrlParams (com.enonic.xp.portal.url.ImageUrlParams)1 PortalUrlService (com.enonic.xp.portal.url.PortalUrlService)1 Site (com.enonic.xp.site.Site)1 ImageStyle (com.enonic.xp.style.ImageStyle)1 StyleDescriptorService (com.enonic.xp.style.StyleDescriptorService)1 StyleDescriptors (com.enonic.xp.style.StyleDescriptors)1 Reference (com.enonic.xp.util.Reference)1 Splitter (com.google.common.base.Splitter)1 ImmutableList (com.google.common.collect.ImmutableList)1 ImmutableMap (com.google.common.collect.ImmutableMap)1 ImmutableSet (com.google.common.collect.ImmutableSet)1