Search in sources :

Example 1 with ContentPaths

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

the class ContentNodeHelperTest method translateNodePathsToContentPaths.

@Test
public void translateNodePathsToContentPaths() {
    final NodePaths nodePaths = NodePaths.from("/content/site/myContent", "/content/folder/other/content");
    final ContentPaths contentPaths = ContentNodeHelper.translateNodePathsToContentPaths(nodePaths);
    assertEquals(ContentPaths.from("/site/myContent", "/folder/other/content"), contentPaths);
}
Also used : ContentPaths(com.enonic.xp.content.ContentPaths) NodePaths(com.enonic.xp.node.NodePaths) Test(org.junit.jupiter.api.Test)

Example 2 with ContentPaths

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

the class ContentPathsTest method from.

@Test
void from() {
    final ContentPaths contentPaths = ContentPaths.from(Arrays.asList(CONTENT_PATH1, CONTENT_PATH2, CONTENT_PATH3));
    assertEquals(Set.of(CONTENT_PATH1, CONTENT_PATH2, CONTENT_PATH3), contentPaths.getSet());
}
Also used : ContentPaths(com.enonic.xp.content.ContentPaths) Test(org.junit.jupiter.api.Test)

Example 3 with ContentPaths

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

the class ContentServiceImplTest_getByPaths method test_published_master.

@Test
public void test_published_master() throws Exception {
    authorizedMasterContext().callWith(() -> {
        final Content content1 = createContent(ContentPath.ROOT);
        final Content content2 = createContent(ContentPath.ROOT, ContentPublishInfo.create().from(Instant.now().minus(Duration.ofDays(1))).to(Instant.now().plus(Duration.ofDays(1))).build());
        final ContentPaths paths = ContentPaths.from(content1.getPath(), content2.getPath());
        final Contents contents = this.contentService.getByPaths(paths);
        assertEquals(contents.getSize(), 2);
        assertTrue(contents.contains(content1));
        assertTrue(contents.contains(content2));
        return null;
    });
}
Also used : ContentPaths(com.enonic.xp.content.ContentPaths) Contents(com.enonic.xp.content.Contents) Content(com.enonic.xp.content.Content) Test(org.junit.jupiter.api.Test)

Example 4 with ContentPaths

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

the class ContentServiceImplTest_getByPaths method test_pending_publish_master.

@Test
public void test_pending_publish_master() throws Exception {
    authorizedMasterContext().callWith(() -> {
        final Content content1 = createContent(ContentPath.ROOT);
        final Content content2 = createContent(ContentPath.ROOT, ContentPublishInfo.create().from(Instant.now().plus(Duration.ofDays(1))).build());
        final ContentPaths paths = ContentPaths.from(content1.getPath(), content2.getPath());
        final Contents contents = this.contentService.getByPaths(paths);
        assertEquals(contents.getSize(), 1);
        assertTrue(contents.contains(content1));
        assertFalse(contents.contains(content2));
        return null;
    });
}
Also used : ContentPaths(com.enonic.xp.content.ContentPaths) Contents(com.enonic.xp.content.Contents) Content(com.enonic.xp.content.Content) Test(org.junit.jupiter.api.Test)

Example 5 with ContentPaths

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

the class ContentServiceImplTest_getByPaths method test_pending_publish_draft.

@Test
public void test_pending_publish_draft() throws Exception {
    final Content content1 = createContent(ContentPath.ROOT);
    final Content content2 = createContent(ContentPath.ROOT, ContentPublishInfo.create().from(Instant.now().plus(Duration.ofDays(1))).build());
    final ContentPaths paths = ContentPaths.from(content1.getPath(), content2.getPath());
    final Contents contents = this.contentService.getByPaths(paths);
    assertEquals(contents.getSize(), 2);
    assertTrue(contents.contains(content1));
    assertTrue(contents.contains(content2));
}
Also used : ContentPaths(com.enonic.xp.content.ContentPaths) Contents(com.enonic.xp.content.Contents) Content(com.enonic.xp.content.Content) Test(org.junit.jupiter.api.Test)

Aggregations

ContentPaths (com.enonic.xp.content.ContentPaths)14 Test (org.junit.jupiter.api.Test)14 Content (com.enonic.xp.content.Content)6 Contents (com.enonic.xp.content.Contents)6 NodePaths (com.enonic.xp.node.NodePaths)2 ContentPath (com.enonic.xp.content.ContentPath)1