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);
}
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();
}
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);
}
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);
}
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());
}
Aggregations