use of com.enonic.xp.content.ContentIds in project xp by enonic.
the class ContentOutboundDependenciesIdsResolverTest method resolve_outbound_with_missing_dependency.
@Test
public void resolve_outbound_with_missing_dependency() throws Exception {
final PropertyTree data = new PropertyTree();
final Content folderRefContent1 = createContent("folderRefContent1", data, ContentTypeName.folder());
final Content folderRefContent2 = createContent("folderRefContent2", data, ContentTypeName.folder());
data.addReference("myRef1", Reference.from(folderRefContent1.getId().toString()));
data.addReference("myRef2", Reference.from(folderRefContent2.getId().toString()));
data.addReference("myRef3", Reference.from("some-id"));
final Content content = createContent("content", data, ContentTypeName.site());
Mockito.when(contentService.getByIds(Mockito.any())).thenReturn(Contents.from(folderRefContent1, folderRefContent2));
Mockito.when(contentService.getById(content.getId())).thenReturn(content);
final ContentIds result = resolver.resolve(content.getId());
assertEquals(result.getSize(), 3);
assertTrue(result.contains(ContentId.from("some-id")));
}
use of com.enonic.xp.content.ContentIds in project xp by enonic.
the class ContentOutboundDependenciesIdsResolverTest method resolve_outbound_dependencies.
@Test
public void resolve_outbound_dependencies() throws Exception {
final PropertyTree data = new PropertyTree();
final Content folderRefContent1 = createContent("folderRefContent1", data, ContentTypeName.folder());
final Content folderRefContent2 = createContent("folderRefContent2", data, ContentTypeName.folder());
final Content siteRefContent1 = createContent("siteRefContent1", data, ContentTypeName.site());
data.addReference("myRef1", Reference.from(folderRefContent1.getId().toString()));
data.addReference("myRef2", Reference.from(folderRefContent2.getId().toString()));
data.addReference("myRef3", Reference.from(siteRefContent1.getId().toString()));
data.addReference("refToMyself", Reference.from("contentId"));
final Content content = createContent("contentId", data, ContentTypeName.site());
Mockito.when(contentService.getByIds(Mockito.any())).thenReturn(Contents.from(folderRefContent1, folderRefContent2, siteRefContent1));
Mockito.when(contentService.getById(content.getId())).thenReturn(content);
final ContentIds result = resolver.resolve(content.getId());
assertEquals(result.getSize(), 3);
assertTrue(result.contains(folderRefContent1.getId()));
assertTrue(result.contains(folderRefContent2.getId()));
assertTrue(result.contains(siteRefContent1.getId()));
}
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);
}
use of com.enonic.xp.content.ContentIds in project xp by enonic.
the class UnpublishContentHandlerTest method unpublishByPath.
@Test
public void unpublishByPath() {
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);
UnpublishContentParams unpublishParams = UnpublishContentParams.create().contentIds(ids).unpublishBranch(ContentConstants.BRANCH_MASTER).includeChildren(true).build();
Mockito.when(this.contentService.unpublishContent(unpublishParams)).thenReturn(exampleResult());
runFunction("/test/UnpublishContentHandlerTest.js", "unpublishByPath");
}
use of com.enonic.xp.content.ContentIds in project xp by enonic.
the class UnpublishContentCommand method removePublishInfo.
private Void removePublishInfo(final ContentIds contentIds) {
final Instant now = Instant.now();
for (final ContentId contentId : contentIds) {
this.nodeService.update(UpdateNodeParams.create().editor(toBeEdited -> {
if (toBeEdited.data.getInstant(ContentPropertyNames.PUBLISH_INFO + PropertyPath.ELEMENT_DIVIDER + ContentPropertyNames.PUBLISH_FROM) != null) {
PropertySet publishInfo = toBeEdited.data.getSet(ContentPropertyNames.PUBLISH_INFO);
if (publishInfo.hasProperty(ContentPropertyNames.PUBLISH_FROM)) {
publishInfo.removeProperty(ContentPropertyNames.PUBLISH_FROM);
}
if (publishInfo.hasProperty(ContentPropertyNames.PUBLISH_TO)) {
publishInfo.removeProperty(ContentPropertyNames.PUBLISH_TO);
}
if (publishInfo.getInstant(ContentPropertyNames.PUBLISH_FIRST).compareTo(Instant.now()) > 0) {
publishInfo.removeProperty(ContentPropertyNames.PUBLISH_FIRST);
}
}
}).id(NodeId.from(contentId)).build());
commitUnpublishedNode(contentId);
}
return null;
}
Aggregations