Search in sources :

Example 41 with Content

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

the class ContentServiceImplTest_publish method publish_rename_move_publish.

/*

     create /a
     create /a/a1
     create /a/a2
     create /b

     publish /a, /a/a1, /a/a2

     rename /a name to "a_old"
     rename /b to "a"
     move a1 and a2 to the new /a

     publish the new /a ("b") and check "Include child items"
     */
@Test
public void publish_rename_move_publish() throws Exception {
    final Content a = createContent(ContentPath.ROOT, "a");
    final Content b = createContent(ContentPath.ROOT, "b");
    final Content a1 = createContent(a.getPath(), "a1");
    final Content a2 = createContent(a.getPath(), "a2");
    doPublish(ContentIds.empty(), a.getId());
    System.out.println("After initial push:");
    printContentTree(getByPath(ContentPath.ROOT).getId());
    printContentTree(getByPath(ContentPath.ROOT).getId(), ctxOther());
    doRename(a.getId(), "a_old");
    doRename(b.getId(), "a");
    doMove(a1.getId(), "/a");
    doMove(a2.getId(), "/a");
    doPublish(ContentIds.empty(), b.getId());
    System.out.println();
    System.out.println("After second push:");
    printContentTree(getByPath(ContentPath.ROOT).getId());
    printContentTree(getByPath(ContentPath.ROOT).getId(), ctxOther());
    assertStatus(b.getId(), CompareStatus.EQUAL);
}
Also used : Content(com.enonic.xp.content.Content) Test(org.junit.jupiter.api.Test)

Example 42 with Content

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

the class ContentServiceImplTest_publish method createContentTree2.

/**
 * ./content1
 * ../content1_1 -> Ref:content2_1_1
 * ./content2
 * ../content2_1
 * ../../content2_1_1
 * ./content3
 */
private void createContentTree2() {
    this.content1 = this.contentService.create(CreateContentParams.create().contentData(new PropertyTree()).displayName("content1").parent(ContentPath.ROOT).type(ContentTypeName.folder()).build());
    this.content2 = this.contentService.create(CreateContentParams.create().contentData(new PropertyTree()).displayName("content2").parent(ContentPath.ROOT).type(ContentTypeName.folder()).build());
    this.content2_1 = this.contentService.create(CreateContentParams.create().contentData(new PropertyTree()).displayName("content2_1").parent(content2.getPath()).type(ContentTypeName.folder()).build());
    final Content content2_1_1 = this.contentService.create(CreateContentParams.create().contentData(new PropertyTree()).displayName("content2_1_1").parent(content2_1.getPath()).type(ContentTypeName.folder()).build());
    final PropertyTree data = new PropertyTree();
    data.addReference("myRef", Reference.from(content2_1_1.getId().toString()));
    this.content1_1 = this.contentService.create(CreateContentParams.create().contentData(data).displayName("content1_1").parent(content1.getPath()).type(ContentTypeName.folder()).build());
    this.contentService.create(CreateContentParams.create().contentData(new PropertyTree()).displayName("content3").parent(ContentPath.ROOT).type(ContentTypeName.folder()).build());
    refresh();
}
Also used : Content(com.enonic.xp.content.Content) PropertyTree(com.enonic.xp.data.PropertyTree)

Example 43 with Content

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

the class ContentServiceImplTest_publish method publish_move_delete_old_parent.

/**
 * /content1
 * /content1_1
 * /content2
 * /content2_1 -> ref:content1_1
 */
@Test
public void publish_move_delete_old_parent() throws Exception {
    createContentTree();
    this.contentService.publish(PushContentParams.create().contentIds(ContentIds.from(content1.getId())).target(WS_OTHER).excludeChildrenIds(ContentIds.from(content1.getId())).build());
    final MoveContentParams params = MoveContentParams.create().contentId(content2_1.getId()).parentContentPath(content1.getPath()).build();
    this.contentService.move(params);
    this.contentService.deleteWithoutFetch(DeleteContentParams.create().contentPath(content2.getPath()).build());
    final Content movedContent = this.contentService.getByPath(ContentPath.from(content1.getPath(), content2_1.getName().toString()));
    assertNotNull(movedContent);
}
Also used : MoveContentParams(com.enonic.xp.content.MoveContentParams) Content(com.enonic.xp.content.Content) Test(org.junit.jupiter.api.Test)

Example 44 with Content

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

the class ContentServiceImplTest_publish method publish_move_delete_moved_also_published.

@Test
public void publish_move_delete_moved_also_published() throws Exception {
    final Content s1 = createContent(ContentPath.ROOT, "s1");
    final Content f1 = createContent(s1.getPath(), "f1");
    final Content c1 = createContent(f1.getPath(), "c1");
    doPublish(ContentIds.empty(), s1.getId());
    // Move to f2, delete f1
    final Content f2 = createContent(s1.getPath(), "f2");
    doMove(c1.getId(), f2.getPath());
    doDelete(f1.getPath(), false);
    // include children = false should be overridden since its a pending delete
    final PublishContentResult result = doPublish(ContentIds.from(f1.getId()), f1.getId());
    assertTrue(result.getPushedContents().contains(c1.getId()));
    assertStatus(c1.getId(), CompareStatus.EQUAL);
}
Also used : PublishContentResult(com.enonic.xp.content.PublishContentResult) Content(com.enonic.xp.content.Content) Test(org.junit.jupiter.api.Test)

Example 45 with Content

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

the class ContentServiceImplTest_publish method push_one_content_not_valid.

@Disabled
@Test
public void push_one_content_not_valid() throws Exception {
    ContentType contentType = ContentType.create().superType(ContentTypeName.structured()).name("myapplication:test").addFormItem(Input.create().name("title").label("Title").inputType(InputTypeName.TEXT_LINE).required(true).build()).build();
    Mockito.when(this.contentTypeService.getByName(GetContentTypeParams.from(contentType.getName()))).thenReturn(contentType);
    final CreateContentParams createContentParams = CreateContentParams.create().contentData(new PropertyTree()).displayName("This is my content").parent(ContentPath.ROOT).type(contentType.getName()).build();
    final Content content = this.contentService.create(createContentParams);
    final PublishContentResult push = this.contentService.publish(PushContentParams.create().contentIds(ContentIds.from(content.getId())).target(WS_OTHER).includeDependencies(false).build());
    assertEquals(1, push.getPushedContents().getSize());
}
Also used : PublishContentResult(com.enonic.xp.content.PublishContentResult) ContentType(com.enonic.xp.schema.content.ContentType) CreateContentParams(com.enonic.xp.content.CreateContentParams) Content(com.enonic.xp.content.Content) PropertyTree(com.enonic.xp.data.PropertyTree) Test(org.junit.jupiter.api.Test) Disabled(org.junit.jupiter.api.Disabled)

Aggregations

Content (com.enonic.xp.content.Content)563 Test (org.junit.jupiter.api.Test)435 PropertyTree (com.enonic.xp.data.PropertyTree)131 CreateContentParams (com.enonic.xp.content.CreateContentParams)57 ContentId (com.enonic.xp.content.ContentId)50 UpdateContentParams (com.enonic.xp.content.UpdateContentParams)48 ContentPath (com.enonic.xp.content.ContentPath)47 ValidationErrors (com.enonic.xp.content.ValidationErrors)47 Site (com.enonic.xp.site.Site)43 PropertySet (com.enonic.xp.data.PropertySet)31 GetContentTypeParams (com.enonic.xp.schema.content.GetContentTypeParams)27 Page (com.enonic.xp.page.Page)26 Contents (com.enonic.xp.content.Contents)25 Node (com.enonic.xp.node.Node)25 ContentIds (com.enonic.xp.content.ContentIds)24 ContentQuery (com.enonic.xp.content.ContentQuery)24 FindContentByParentParams (com.enonic.xp.content.FindContentByParentParams)24 FindContentByParentResult (com.enonic.xp.content.FindContentByParentResult)23 DataValidationError (com.enonic.xp.content.DataValidationError)21 ContentType (com.enonic.xp.schema.content.ContentType)20