use of com.enonic.xp.content.ContentPaths in project xp by enonic.
the class ContentServiceImplTest_getByPaths method test_published_draft.
@Test
public void test_published_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().plus(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));
}
use of com.enonic.xp.content.ContentPaths in project xp by enonic.
the class ContentNodeHelperTest method translateContentPathsToNodePaths.
@Test
public void translateContentPathsToNodePaths() {
final ContentPaths contentPaths = ContentPaths.create().add(ContentPath.from("/site/myContent")).add(ContentPath.from("/folder/other/content")).build();
final NodePaths nodePaths = ContentNodeHelper.translateContentPathsToNodePaths(contentPaths);
assertEquals(NodePaths.from("/content/site/myContent", "/content/folder/other/content"), nodePaths);
}
use of com.enonic.xp.content.ContentPaths in project xp by enonic.
the class ContentPathsTest method empty.
@Test
void empty() {
ContentPaths pathsFromSet = ContentPaths.from(CONTENT_PATH1);
assertTrue(pathsFromSet.isNotEmpty());
pathsFromSet = pathsFromSet.remove(CONTENT_PATH1);
assertTrue(pathsFromSet.isEmpty());
ContentPaths pathsEmpty = ContentPaths.empty();
assertTrue(pathsEmpty.isEmpty());
assertEquals(pathsEmpty, pathsFromSet);
}
use of com.enonic.xp.content.ContentPaths in project xp by enonic.
the class ContentPathsTest method from_strings.
@Test
void from_strings() {
final ContentPaths contentPaths = ContentPaths.from(Arrays.asList(STRING_PATH1, STRING_PATH2, STRING_PATH3));
assertEquals(Set.of(ContentPath.from(STRING_PATH1), ContentPath.from(STRING_PATH2), ContentPath.from(STRING_PATH3)), contentPaths.getSet());
}
use of com.enonic.xp.content.ContentPaths in project xp by enonic.
the class ContentPathsTest method addAndRemoveString.
@Test
void addAndRemoveString() {
Set<String> set = Set.of(STRING_PATH2, STRING_PATH3);
String[] array = { STRING_PATH2, STRING_PATH3 };
ContentPaths pathsFromSet = ContentPaths.from(STRING_PATH1).add(set);
ContentPaths pathsFromArray = ContentPaths.from(STRING_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());
}
Aggregations