Search in sources :

Example 11 with ContentId

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

the class IssueServiceImplTest_findIssues method findByContentId1.

@Test
public void findByContentId1() throws Exception {
    ContentId contentId = ContentId.from("issue-item-1");
    IssueQuery query = IssueQuery.create().items(ContentIds.from(contentId)).build();
    final FindIssuesResult result = this.issueService.findIssues(query);
    assertNotNull(result);
    assertEquals(2, 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)

Example 12 with ContentId

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

the class IssueServiceImplTest_findIssues method findByContentId4.

@Test
public void findByContentId4() throws Exception {
    ContentId contentId = ContentId.from("issue-item-4");
    IssueQuery query = IssueQuery.create().items(ContentIds.from(contentId)).build();
    final FindIssuesResult result = this.issueService.findIssues(query);
    assertNotNull(result);
    assertEquals(1, 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)

Example 13 with ContentId

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

the class SyncContentServiceImplTest method resetWithRemovedSource.

@Test
public void resetWithRemovedSource() throws Exception {
    final Content source = sourceContext.callWith(() -> createContent(ContentPath.ROOT));
    syncCreated(source.getId());
    targetContext.runWith(() -> {
        contentService.update(new UpdateContentParams().contentId(source.getId()).editor(edit -> {
            edit.workflowInfo = WorkflowInfo.ready();
            edit.data = new PropertyTree();
        }));
    });
    sourceContext.runWith(() -> contentService.deleteWithoutFetch(DeleteContentParams.create().contentPath(source.getPath()).build()));
    assertThrows(IllegalArgumentException.class, () -> syncContentService.resetInheritance(ResetContentInheritParams.create().contentId(source.getId()).inherit(EnumSet.of(ContentInheritType.CONTENT)).projectName(targetProject.getName()).build()));
}
Also used : ChildOrder(com.enonic.xp.index.ChildOrder) Assertions.assertThrows(org.junit.jupiter.api.Assertions.assertThrows) BeforeEach(org.junit.jupiter.api.BeforeEach) WorkflowInfo(com.enonic.xp.content.WorkflowInfo) ContentPath(com.enonic.xp.content.ContentPath) ProjectSyncParams(com.enonic.xp.content.ProjectSyncParams) ContentInheritType(com.enonic.xp.content.ContentInheritType) Content(com.enonic.xp.content.Content) DeleteContentParams(com.enonic.xp.content.DeleteContentParams) UpdateContentParams(com.enonic.xp.content.UpdateContentParams) ContentSyncEventType(com.enonic.xp.core.impl.content.ContentSyncEventType) Test(org.junit.jupiter.api.Test) ParentContentSynchronizer(com.enonic.xp.core.impl.content.ParentContentSynchronizer) SyncContentServiceImpl(com.enonic.xp.core.impl.content.SyncContentServiceImpl) ContentId(com.enonic.xp.content.ContentId) ResetContentInheritParams(com.enonic.xp.content.ResetContentInheritParams) Assertions.assertFalse(org.junit.jupiter.api.Assertions.assertFalse) ProjectName(com.enonic.xp.project.ProjectName) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) SetContentChildOrderParams(com.enonic.xp.content.SetContentChildOrderParams) ContentEventsSyncParams(com.enonic.xp.core.impl.content.ContentEventsSyncParams) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) EnumSet(java.util.EnumSet) PropertyTree(com.enonic.xp.data.PropertyTree) UpdateContentParams(com.enonic.xp.content.UpdateContentParams) Content(com.enonic.xp.content.Content) PropertyTree(com.enonic.xp.data.PropertyTree) Test(org.junit.jupiter.api.Test)

Example 14 with ContentId

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

the class ProjectContentEventListenerTest method testDuplicateInherited.

@Test
public void testDuplicateInherited() throws InterruptedException {
    final Content sourceContent = sourceContext.callWith(() -> createContent(ContentPath.ROOT, "localName"));
    handleEvents();
    final ContentId duplicatedContentId = targetContext.callWith(() -> contentService.duplicate(DuplicateContentParams.create().contentId(sourceContent.getId()).build()).getDuplicatedContents().first());
    targetContext.runWith(() -> {
        final Content duplicatedTargetContent = contentService.getById(duplicatedContentId);
        assertEquals("localName-copy", duplicatedTargetContent.getName().toString());
        assertTrue(duplicatedTargetContent.getInherit().isEmpty());
    });
}
Also used : Content(com.enonic.xp.content.Content) ContentId(com.enonic.xp.content.ContentId) Test(org.junit.jupiter.api.Test)

Example 15 with ContentId

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

the class ProjectContentEventListenerTest method testSyncDuplicateWithExistedLocalName.

@Test
public void testSyncDuplicateWithExistedLocalName() throws InterruptedException {
    targetContext.callWith(() -> createContent(ContentPath.ROOT, "localName-copy"));
    targetContext.callWith(() -> createContent(ContentPath.ROOT, "localName-copy-1"));
    final Content sourceContent = sourceContext.callWith(() -> createContent(ContentPath.ROOT, "localName"));
    handleEvents();
    final ContentId duplicatedContentId = sourceContext.callWith(() -> contentService.duplicate(DuplicateContentParams.create().contentId(sourceContent.getId()).build()).getDuplicatedContents().first());
    handleEvents();
    targetContext.runWith(() -> {
        final Content duplicatedTargetContent = contentService.getById(duplicatedContentId);
        assertEquals("localName-copy-1-1", duplicatedTargetContent.getName().toString());
        assertEquals(3, duplicatedTargetContent.getInherit().size());
        assertFalse(duplicatedTargetContent.getInherit().contains(ContentInheritType.NAME));
    });
}
Also used : Content(com.enonic.xp.content.Content) ContentId(com.enonic.xp.content.ContentId) 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