Search in sources :

Example 6 with ContentId

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

the class ContentServiceImplTest_publish method checkCollection.

private boolean checkCollection(final ContentIds currentExpected, final ContentIds currentResult, final StringBuilder message) {
    boolean hasFailed = false;
    for (final ContentId expectedEntry : currentExpected) {
        message.append(LINE_SEPARATOR).append("Content: ").append(getName(expectedEntry)).append(" expected: ");
        if (!currentResult.contains(expectedEntry)) {
            message.append("<FAIL>");
            hasFailed = true;
        } else {
            message.append("OK");
        }
    }
    for (final ContentId found : currentResult) {
        if (!currentExpected.contains(found)) {
            message.append(LINE_SEPARATOR).append("Content: ").append(getName(found)).append(" not expected");
            hasFailed = true;
        }
    }
    return hasFailed;
}
Also used : ContentId(com.enonic.xp.content.ContentId)

Example 7 with ContentId

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

the class ContentServiceImplTest_restore method restore_inherited.

@Test
public void restore_inherited() {
    final Content content = createContent(ContentPath.ROOT, "content");
    this.contentService.deleteWithoutFetch(DeleteContentParams.create().contentPath(content.getPath()).build());
    refresh();
    final ContentId importedId = archiveContext().callWith(() -> this.contentService.importContent(ImportContentParams.create().importContent(content).targetPath(content.getPath()).inherit(EnumSet.allOf(ContentInheritType.class)).build()).getContent().getId());
    this.contentService.restore(RestoreContentParams.create().contentId(importedId).build());
    final Set<ContentInheritType> inherit = this.contentService.getById(importedId).getInherit();
    assertEquals(2, inherit.size());
    assertTrue(inherit.contains(ContentInheritType.SORT));
    assertTrue(inherit.contains(ContentInheritType.NAME));
}
Also used : Content(com.enonic.xp.content.Content) ContentId(com.enonic.xp.content.ContentId) ContentInheritType(com.enonic.xp.content.ContentInheritType) Test(org.junit.jupiter.api.Test)

Example 8 with ContentId

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

the class ContentServiceImplTest_restore method restore_dont_stop_inherited.

@Test
public void restore_dont_stop_inherited() {
    final Content content = createContent(ContentPath.ROOT, "content");
    this.contentService.deleteWithoutFetch(DeleteContentParams.create().contentPath(content.getPath()).build());
    refresh();
    final ContentId importedId = archiveContext().callWith(() -> this.contentService.importContent(ImportContentParams.create().importContent(content).targetPath(content.getPath()).inherit(EnumSet.allOf(ContentInheritType.class)).build()).getContent().getId());
    this.contentService.restore(RestoreContentParams.create().contentId(importedId).stopInherit(false).build());
    final Set<ContentInheritType> inherit = this.contentService.getById(importedId).getInherit();
    assertEquals(4, inherit.size());
}
Also used : Content(com.enonic.xp.content.Content) ContentId(com.enonic.xp.content.ContentId) ContentInheritType(com.enonic.xp.content.ContentInheritType) Test(org.junit.jupiter.api.Test)

Example 9 with ContentId

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

the class JavaTypeConvertersTest method convertToContentId.

@Test
public void convertToContentId() {
    ContentId contentId = ContentId.from("id");
    assertEquals(contentId, JavaTypeConverters.CONTENT_ID.convertFrom(contentId));
    assertEquals(contentId, JavaTypeConverters.CONTENT_ID.convertFrom("id"));
    assertNull(JavaTypeConverters.CONTENT_ID.convertFrom(new Object()));
}
Also used : ContentId(com.enonic.xp.content.ContentId) Test(org.junit.jupiter.api.Test)

Example 10 with ContentId

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

the class IssueServiceImplTest_findIssues method findByContentId2.

@Test
public void findByContentId2() throws Exception {
    ContentId contentId = ContentId.from("issue-item-2");
    IssueQuery query = IssueQuery.create().items(ContentIds.from(contentId)).build();
    final FindIssuesResult result = this.issueService.findIssues(query);
    assertNotNull(result);
    assertEquals(3, result.getHits());
    assertTrue(result.getIssues().stream().allMatch(issue -> issue.getPublishRequest().getItems().stream().anyMatch(item -> item.getId().equals(contentId))));
}
Also used : BeforeEach(org.junit.jupiter.api.BeforeEach) Assertions.assertNotNull(org.junit.jupiter.api.Assertions.assertNotNull) Issue(com.enonic.xp.issue.Issue) PublishRequestItem(com.enonic.xp.issue.PublishRequestItem) CreateIssueParams(com.enonic.xp.issue.CreateIssueParams) Test(org.junit.jupiter.api.Test) ContentId(com.enonic.xp.content.ContentId) ContentIds(com.enonic.xp.content.ContentIds) IssueQuery(com.enonic.xp.issue.IssueQuery) FindIssuesResult(com.enonic.xp.issue.FindIssuesResult) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) PublishRequest(com.enonic.xp.issue.PublishRequest) ContentId(com.enonic.xp.content.ContentId) IssueQuery(com.enonic.xp.issue.IssueQuery) FindIssuesResult(com.enonic.xp.issue.FindIssuesResult) Test(org.junit.jupiter.api.Test)

Aggregations

ContentId (com.enonic.xp.content.ContentId)83 Content (com.enonic.xp.content.Content)34 Test (org.junit.jupiter.api.Test)33 PropertyTree (com.enonic.xp.data.PropertyTree)16 ContentPath (com.enonic.xp.content.ContentPath)14 ContentNotFoundException (com.enonic.xp.content.ContentNotFoundException)13 ContentIds (com.enonic.xp.content.ContentIds)11 PropertySet (com.enonic.xp.data.PropertySet)10 NodeId (com.enonic.xp.node.NodeId)9 BeforeEach (org.junit.jupiter.api.BeforeEach)8 ContentInheritType (com.enonic.xp.content.ContentInheritType)7 Assertions.assertEquals (org.junit.jupiter.api.Assertions.assertEquals)7 Assertions.assertTrue (org.junit.jupiter.api.Assertions.assertTrue)7 UpdateContentParams (com.enonic.xp.content.UpdateContentParams)6 Context (com.enonic.xp.context.Context)6 DeleteContentParams (com.enonic.xp.content.DeleteContentParams)5 Node (com.enonic.xp.node.Node)5 Branch (com.enonic.xp.branch.Branch)4 ContentConstants (com.enonic.xp.content.ContentConstants)4 ContextBuilder (com.enonic.xp.context.ContextBuilder)4