use of com.enonic.xp.content.ContentPaths in project xp by enonic.
the class ContentPathsTest method builder.
@Test
void builder() {
final ContentPaths contentPaths = ContentPaths.create().add(CONTENT_PATH1).addAll(ContentPaths.from(CONTENT_PATH2, CONTENT_PATH3)).build();
assertEquals(Set.of(CONTENT_PATH1, CONTENT_PATH2, CONTENT_PATH3), contentPaths.getSet());
}
use of com.enonic.xp.content.ContentPaths in project xp by enonic.
the class ContentPathsTest method addAndRemoveContentPath.
@Test
void addAndRemoveContentPath() {
Set<ContentPath> set = Set.of(CONTENT_PATH2, CONTENT_PATH3);
ContentPath[] array = { CONTENT_PATH2, CONTENT_PATH3 };
ContentPaths pathsFromSet = ContentPaths.from(CONTENT_PATH1).add(set);
ContentPaths pathsFromArray = ContentPaths.from(CONTENT_PATH1).add(array);
assertEquals(pathsFromSet, pathsFromArray);
pathsFromArray = pathsFromArray.remove(set);
pathsFromSet = pathsFromSet.remove(array);
assertEquals(pathsFromSet, pathsFromArray);
assertEquals(pathsFromSet.hashCode(), pathsFromArray.hashCode());
assertEquals(pathsFromSet.toString(), pathsFromArray.toString());
}
use of com.enonic.xp.content.ContentPaths in project xp by enonic.
the class ContentServiceImplTest_getByPaths method test_publish_expired_master.
@Test
public void test_publish_expired_master() throws Exception {
authorizedMasterContext().callWith(() -> {
final Content content1 = createContent(ContentPath.ROOT);
final Content content2 = createContent(ContentPath.ROOT, ContentPublishInfo.create().from(Instant.now().minus(Duration.ofDays(1))).to(Instant.now().minus(Duration.ofDays(1))).build());
final ContentPaths paths = ContentPaths.from(content1.getPath(), content2.getPath());
final Contents contents = this.contentService.getByPaths(paths);
assertEquals(contents.getSize(), 1);
assertTrue(contents.contains(content1));
assertFalse(contents.contains(content2));
return null;
});
}
use of com.enonic.xp.content.ContentPaths in project xp by enonic.
the class ContentServiceImplTest_getByPaths method test_publish_expired_draft.
@Test
public void test_publish_expired_draft() throws Exception {
final Content content1 = createContent(ContentPath.ROOT);
final Content content2 = createContent(ContentPath.ROOT, ContentPublishInfo.create().from(Instant.now().minus(Duration.ofDays(1))).to(Instant.now().minus(Duration.ofDays(1))).build());
final ContentPaths paths = ContentPaths.from(content1.getPath(), content2.getPath());
final Contents contents = this.contentService.getByPaths(paths);
assertEquals(contents.getSize(), 2);
assertTrue(contents.contains(content1));
assertTrue(contents.contains(content2));
}
Aggregations