Search in sources :

Example 56 with PropertySet

use of com.enonic.xp.data.PropertySet in project xp by enonic.

the class CreateContentCommandTest method initContent.

private NodePath initContent(final ContentTypeName contentTypeName, final String name, final NodePath parentPath) {
    final PropertyTree nodeData = new PropertyTree();
    nodeData.setString(ContentPropertyNames.TYPE, contentTypeName.toString());
    nodeData.setSet(ContentPropertyNames.DATA, new PropertySet());
    nodeData.setString(ContentPropertyNames.CREATOR, "user:myidprovider:user1");
    final Node node = Node.create().id(NodeId.from(name)).name(name).parentPath(parentPath).data(nodeData).build();
    Mockito.when(nodeService.getByPath(Mockito.eq(node.path()))).thenReturn(node);
    Mockito.when(nodeService.getById(Mockito.eq(node.id()))).thenReturn(node);
    return node.path();
}
Also used : PropertyTree(com.enonic.xp.data.PropertyTree) Node(com.enonic.xp.node.Node) PropertySet(com.enonic.xp.data.PropertySet)

Example 57 with PropertySet

use of com.enonic.xp.data.PropertySet in project xp by enonic.

the class PageRegionsConfigProcessorTest method test_complex_component_config.

@Test
public void test_complex_component_config() throws Exception {
    final PropertyTree config = new PropertyTree();
    final PropertySet items = config.addSet("items");
    items.addStrings("input", "a", "b", "c");
    final Page page = Page.create().regions(PageRegions.create().add(Region.create().name("region1").add(PartComponent.create().descriptor(DescriptorKey.from("appKey1:partName1")).config(new PropertyTree()).build()).add(LayoutComponent.create().descriptor(DescriptorKey.from("appKey2:layoutName")).config(new PropertyTree()).regions(LayoutRegions.create().add(Region.create().name("region").add(PartComponent.create().descriptor(DescriptorKey.from("appKey3:partName2")).config(new PropertyTree()).build()).build()).build()).build()).build()).build()).build();
    final Form form = Form.create().addFormItem(FormItemSet.create().name("items").addFormItem(Input.create().name("input").label("input").inputType(InputTypeName.TEXT_LINE).occurrences(0, 5).build()).build()).build();
    final PatternIndexConfigDocument result = processPage(page, Arrays.asList(form, form).listIterator(), singletonList(form).listIterator());
    assertEquals(8, result.getPathIndexConfigs().size());
    assertEquals(IndexConfig.BY_TYPE, result.getConfigForPath(PropertyPath.from("components.part.config.appKey1.partName1")));
    assertEquals(IndexConfig.BY_TYPE, result.getConfigForPath(PropertyPath.from("components.part.config.appKey2.layoutName")));
    assertEquals(IndexConfig.BY_TYPE, result.getConfigForPath(PropertyPath.from("components.part.config.appkey3.partname2")));
}
Also used : Form(com.enonic.xp.form.Form) PropertyTree(com.enonic.xp.data.PropertyTree) PropertySet(com.enonic.xp.data.PropertySet) Page(com.enonic.xp.page.Page) PatternIndexConfigDocument(com.enonic.xp.index.PatternIndexConfigDocument) Test(org.junit.jupiter.api.Test)

Example 58 with PropertySet

use of com.enonic.xp.data.PropertySet in project xp by enonic.

the class ProjectAccessSiteProcessorTest method createSiteConfig.

private PropertySet createSiteConfig(final String bgColor) {
    PropertySet set = new PropertySet();
    set.addString("applicationKey", "com.enonic.app.test");
    PropertySet siteConfig = set.addSet("config");
    siteConfig.addString("backgroundColor", bgColor);
    return set;
}
Also used : PropertySet(com.enonic.xp.data.PropertySet)

Example 59 with PropertySet

use of com.enonic.xp.data.PropertySet in project xp by enonic.

the class ArchiveInitializer method initArchiveNode.

private void initArchiveNode() {
    LOG.info("Archive root-node not found, creating");
    final PropertyTree data = new PropertyTree();
    data.setString(ContentPropertyNames.TYPE, ContentTypeName.folder().toString());
    data.setSet(ContentPropertyNames.DATA, new PropertySet());
    data.setString(ContentPropertyNames.CREATOR, ContextAccessor.current().getAuthInfo().getUser().toString());
    data.setString(ContentPropertyNames.MODIFIER, ContextAccessor.current().getAuthInfo().getUser().toString());
    final Node archiveRoot = nodeService.create(CreateNodeParams.create().data(data).name(ArchiveConstants.ARCHIVE_ROOT_NAME).parent(NodePath.ROOT).permissions(Objects.requireNonNullElse(accessControlList, ArchiveConstants.ARCHIVE_ROOT_DEFAULT_ACL)).childOrder(ArchiveConstants.DEFAULT_ARCHIVE_REPO_ROOT_ORDER).build());
    LOG.info("Created archive root-node: " + archiveRoot.path());
    nodeService.refresh(RefreshMode.ALL);
}
Also used : PropertyTree(com.enonic.xp.data.PropertyTree) Node(com.enonic.xp.node.Node) PropertySet(com.enonic.xp.data.PropertySet)

Example 60 with PropertySet

use of com.enonic.xp.data.PropertySet in project xp by enonic.

the class SchedulableTaskImplTest method mockNode.

private void mockNode() {
    final PropertyTree jobData = new PropertyTree();
    final PropertySet calendar = new PropertySet();
    calendar.addString(ScheduledJobPropertyNames.CALENDAR_TYPE, "ONE_TIME");
    calendar.addString(ScheduledJobPropertyNames.CALENDAR_VALUE, "2021-02-25T10:44:33.170079900Z");
    jobData.addString(ScheduledJobPropertyNames.DESCRIPTOR, "app:key");
    jobData.addBoolean(ScheduledJobPropertyNames.ENABLED, true);
    jobData.addSet(ScheduledJobPropertyNames.CALENDAR, calendar);
    jobData.addSet(ScheduledJobPropertyNames.CONFIG, new PropertySet());
    jobData.setString(ScheduledJobPropertyNames.CREATOR, "user:system:creator");
    jobData.setString(ScheduledJobPropertyNames.MODIFIER, "user:system:modifier");
    jobData.setString(ScheduledJobPropertyNames.CREATED_TIME, "2021-02-26T10:44:33.170079900Z");
    jobData.setString(ScheduledJobPropertyNames.MODIFIED_TIME, "2021-03-26T10:44:33.170079900Z");
    final Node job = Node.create().id(NodeId.from("abc")).name("test").parentPath(NodePath.ROOT).data(jobData).build();
    when(nodeService.update(isA(UpdateNodeParams.class))).thenReturn(job);
}
Also used : PropertyTree(com.enonic.xp.data.PropertyTree) Node(com.enonic.xp.node.Node) UpdateNodeParams(com.enonic.xp.node.UpdateNodeParams) PropertySet(com.enonic.xp.data.PropertySet)

Aggregations

PropertySet (com.enonic.xp.data.PropertySet)225 PropertyTree (com.enonic.xp.data.PropertyTree)150 Test (org.junit.jupiter.api.Test)69 Content (com.enonic.xp.content.Content)30 Node (com.enonic.xp.node.Node)20 CreateContentParams (com.enonic.xp.content.CreateContentParams)12 ContentId (com.enonic.xp.content.ContentId)11 Property (com.enonic.xp.data.Property)11 LogAuditLogParams (com.enonic.xp.audit.LogAuditLogParams)10 PrincipalKey (com.enonic.xp.security.PrincipalKey)9 ContentQuery (com.enonic.xp.content.ContentQuery)7 DescriptorKey (com.enonic.xp.page.DescriptorKey)7 ExtraDatas (com.enonic.xp.content.ExtraDatas)6 Form (com.enonic.xp.form.Form)6 PatternIndexConfigDocument (com.enonic.xp.index.PatternIndexConfigDocument)6 CreateAttachment (com.enonic.xp.attachment.CreateAttachment)5 ContentPropertyNames (com.enonic.xp.content.ContentPropertyNames)5 ExtraData (com.enonic.xp.content.ExtraData)5 PropertyPath (com.enonic.xp.data.PropertyPath)5 Page (com.enonic.xp.page.Page)5