Search in sources :

Example 31 with ContentIds

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

the class PublishContentHandlerTest method publishByPath.

@Test
public void publishByPath() {
    final Content myContent = exampleContent(PUB_ID_2, "mycontent", "My Content", "/myfolder/mycontent", "myfield", "Hello World");
    Mockito.when(this.contentService.getByPath(ContentPath.from("/myfolder/mycontent"))).thenReturn(myContent);
    final Content yourContent = exampleContent(PUB_ID_3, "yourcontent", "Your Content", "/yourfolder/yourcontent", "yourfield", "Hello Universe!");
    Mockito.when(this.contentService.getByPath(ContentPath.from("/yourfolder/yourcontent"))).thenReturn(yourContent);
    ContentIds ids = ContentIds.from(PUB_ID_2, PUB_ID_3);
    PushContentParams pushParams = PushContentParams.create().contentIds(ids).target(Branch.from("master")).build();
    Mockito.when(this.contentService.publish(pushParams)).thenReturn(exampleResult());
    runFunction("/test/PublishContentHandlerTest.js", "publishByPath");
}
Also used : Content(com.enonic.xp.content.Content) ContentIds(com.enonic.xp.content.ContentIds) PushContentParams(com.enonic.xp.content.PushContentParams) Test(org.junit.jupiter.api.Test)

Example 32 with ContentIds

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

the class AbstractContentServiceTest method assertOrder.

protected void assertOrder(final FindContentByQueryResult result, final Content... expectedOrder) {
    final ContentIds contentIds = result.getContents().getIds();
    doAssertOrder(contentIds, expectedOrder);
}
Also used : ContentIds(com.enonic.xp.content.ContentIds)

Example 33 with ContentIds

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

the class ContentServiceImplTest_resolveRequiredDependencies method resolve_with_no_parent.

@Test
public void resolve_with_no_parent() throws Exception {
    content1 = createContent(ContentPath.ROOT);
    content2 = createContent(ContentPath.ROOT);
    content3 = createContent(ContentPath.ROOT);
    refresh();
    final ContentIds result = this.contentService.resolveRequiredDependencies(ResolveRequiredDependenciesParams.create().contentIds(ContentIds.from(content1.getId(), content2.getId(), content3.getId())).target(WS_OTHER).build());
    assertTrue(result.getSize() == 0);
}
Also used : ContentIds(com.enonic.xp.content.ContentIds) Test(org.junit.jupiter.api.Test)

Example 34 with ContentIds

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

the class ContentServiceImplTest_getByIds 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 ContentIds ids = ContentIds.from(content1.getId(), content2.getId());
        final Contents contents = this.contentService.getByIds(new GetContentByIdsParams(ids));
        assertEquals(contents.getSize(), 1);
        assertTrue(contents.contains(content1));
        assertFalse(contents.contains(content2));
        return null;
    });
}
Also used : Contents(com.enonic.xp.content.Contents) GetContentByIdsParams(com.enonic.xp.content.GetContentByIdsParams) Content(com.enonic.xp.content.Content) ContentIds(com.enonic.xp.content.ContentIds) Test(org.junit.jupiter.api.Test)

Example 35 with ContentIds

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

the class ContentServiceImplTest_getByIds 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 ContentIds ids = ContentIds.from(content1.getId(), content2.getId());
        final Contents contents = this.contentService.getByIds(new GetContentByIdsParams(ids));
        assertEquals(contents.getSize(), 2);
        assertTrue(contents.contains(content1));
        assertTrue(contents.contains(content2));
        return null;
    });
}
Also used : Contents(com.enonic.xp.content.Contents) GetContentByIdsParams(com.enonic.xp.content.GetContentByIdsParams) Content(com.enonic.xp.content.Content) ContentIds(com.enonic.xp.content.ContentIds) Test(org.junit.jupiter.api.Test)

Aggregations

ContentIds (com.enonic.xp.content.ContentIds)38 Test (org.junit.jupiter.api.Test)27 Content (com.enonic.xp.content.Content)22 Contents (com.enonic.xp.content.Contents)11 GetContentByIdsParams (com.enonic.xp.content.GetContentByIdsParams)10 PropertyTree (com.enonic.xp.data.PropertyTree)8 ContentId (com.enonic.xp.content.ContentId)6 PushContentParams (com.enonic.xp.content.PushContentParams)6 UnpublishContentParams (com.enonic.xp.content.UnpublishContentParams)4 NodeIds (com.enonic.xp.node.NodeIds)4 DeleteContentsResult (com.enonic.xp.content.DeleteContentsResult)3 CreateContentParams (com.enonic.xp.content.CreateContentParams)2 DeleteContentParams (com.enonic.xp.content.DeleteContentParams)2 PublishContentResult (com.enonic.xp.content.PublishContentResult)2 UnpublishContentsResult (com.enonic.xp.content.UnpublishContentsResult)2 Context (com.enonic.xp.context.Context)2 PropertySet (com.enonic.xp.data.PropertySet)2 FindNodesByParentResult (com.enonic.xp.node.FindNodesByParentResult)2 Node (com.enonic.xp.node.Node)2 NodeId (com.enonic.xp.node.NodeId)2