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