Search in sources :

Example 66 with Site

use of com.enonic.xp.site.Site in project xp by enonic.

the class ContentServiceImplTest_getNearestSite method child_of_site_pending_publish_master.

@Test
public void child_of_site_pending_publish_master() {
    final Content site = createSite();
    final Content child = createContent(site.getPath(), ContentPublishInfo.create().from(Instant.now().plus(Duration.ofDays(1))).build());
    this.contentService.publish(PushContentParams.create().target(ContentConstants.BRANCH_MASTER).contentIds(ContentIds.from(site.getId())).build());
    final Site fetchedSite = authorizedMasterContext().callWith(() -> this.contentService.getNearestSite(child.getId()));
    assertNull(fetchedSite);
}
Also used : Site(com.enonic.xp.site.Site) Content(com.enonic.xp.content.Content) Test(org.junit.jupiter.api.Test)

Example 67 with Site

use of com.enonic.xp.site.Site in project xp by enonic.

the class ContentServiceImplTest_getNearestSite method child_of_site.

@Test
public void child_of_site() {
    final Content site = createSite();
    final Content child = createContent(site.getPath());
    final Site fetchedSite = this.contentService.getNearestSite(child.getId());
    assertNotNull(fetchedSite);
    assertEquals(site.getId(), fetchedSite.getId());
}
Also used : Site(com.enonic.xp.site.Site) Content(com.enonic.xp.content.Content) Test(org.junit.jupiter.api.Test)

Example 68 with Site

use of com.enonic.xp.site.Site in project xp by enonic.

the class ContentServiceImplTest_getNearestSite method deep_child_of_site.

@Test
public void deep_child_of_site() {
    final Content site = createSite();
    final Content childLevel1 = createContent(site.getPath());
    final Content childLevel2 = createContent(childLevel1.getPath());
    final Content childLevel3 = createContent(childLevel2.getPath());
    final Site fetchedSite = this.contentService.getNearestSite(childLevel3.getId());
    assertNotNull(fetchedSite);
    assertEquals(site.getId(), fetchedSite.getId());
}
Also used : Site(com.enonic.xp.site.Site) Content(com.enonic.xp.content.Content) Test(org.junit.jupiter.api.Test)

Example 69 with Site

use of com.enonic.xp.site.Site in project xp by enonic.

the class GetSiteConfigHandlerTest method testExample.

@Test
public void testExample() {
    final Site site = TestDataFixtures.newSite();
    when(this.contentService.findNearestSiteByPath(Mockito.any())).thenReturn(site);
    when(this.contentService.getNearestSite(Mockito.any())).thenReturn(site);
    runScript("/lib/xp/examples/content/getSiteConfig.js");
}
Also used : Site(com.enonic.xp.site.Site) Test(org.junit.jupiter.api.Test)

Example 70 with Site

use of com.enonic.xp.site.Site in project xp by enonic.

the class GetCurrentSiteScriptTest method testExample.

@Test
public void testExample() {
    final Site site = TestDataFixtures.newSite().build();
    this.portalRequest.setSite(site);
    runScript("/lib/xp/examples/portal/getSite.js");
}
Also used : Site(com.enonic.xp.site.Site) Test(org.junit.jupiter.api.Test)

Aggregations

Site (com.enonic.xp.site.Site)78 Test (org.junit.jupiter.api.Test)51 Content (com.enonic.xp.content.Content)41 PortalRequest (com.enonic.xp.portal.PortalRequest)17 PropertyTree (com.enonic.xp.data.PropertyTree)14 Page (com.enonic.xp.page.Page)12 ContentId (com.enonic.xp.content.ContentId)10 ContentPath (com.enonic.xp.content.ContentPath)10 SiteConfig (com.enonic.xp.site.SiteConfig)10 WebException (com.enonic.xp.web.WebException)10 ApplicationKey (com.enonic.xp.app.ApplicationKey)9 PageTemplate (com.enonic.xp.page.PageTemplate)8 PortalResponse (com.enonic.xp.portal.PortalResponse)7 ControllerMappingDescriptor (com.enonic.xp.site.mapping.ControllerMappingDescriptor)7 SiteDescriptor (com.enonic.xp.site.SiteDescriptor)6 BeforeEach (org.junit.jupiter.api.BeforeEach)6 DescriptorKey (com.enonic.xp.page.DescriptorKey)5 SiteConfigs (com.enonic.xp.site.SiteConfigs)5 Branch (com.enonic.xp.branch.Branch)4 ContentService (com.enonic.xp.content.ContentService)4