Search in sources :

Example 31 with PropertySet

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

the class ContentServiceImplTest_move method createSiteConfig.

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

Example 32 with PropertySet

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

the class TestDataFixtures method newPropertyTree.

public static PropertyTree newPropertyTree() {
    final PropertyTree tree = new PropertyTree();
    tree.setBoolean("boolean", true);
    tree.addBooleans("boolean", true, false);
    tree.setLong("long", 1L);
    tree.addLongs("longs", 1L, 2L, 3L);
    tree.setDouble("double", 2.2);
    tree.addDoubles("doubles", 1.1, 2.2, 3.3);
    tree.setString("string", "a");
    tree.addStrings("strings", "a", "b", "c");
    tree.setString("stringEmpty", "");
    tree.setString("stringNull", null);
    tree.setString("set.property", "value");
    tree.addXml("xml", "<xml><my-xml hello='world'/></xml>");
    tree.addBinaryReference("binaryReference", BinaryReference.from("abc"));
    tree.addLink("link", Link.from(ContentPath.from("/my/content").toString()));
    tree.addGeoPoint("geoPoint", new GeoPoint(1.1, -1.1));
    tree.addGeoPoints("geoPoints", new GeoPoint(1.1, -1.1), new GeoPoint(2.2, -2.2));
    tree.addInstant("instant", Instant.MAX);
    tree.addLocalDate("localDate", LocalDate.of(2014, 1, 31));
    tree.addLocalDateTime("localDateTime", LocalDateTime.of(2014, 1, 31, 10, 30, 5));
    final PropertySet set1 = tree.addSet("c");
    set1.setBoolean("d", true);
    set1.addStrings("e", "3", "4", "5");
    set1.setLong("f", 2L);
    return tree;
}
Also used : GeoPoint(com.enonic.xp.util.GeoPoint) PropertyTree(com.enonic.xp.data.PropertyTree) PropertySet(com.enonic.xp.data.PropertySet)

Example 33 with PropertySet

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

the class ContentDataSerializerTest method update_add_workflow_info.

@Test
public void update_add_workflow_info() {
    final ContentDataSerializer contentDataSerializer = createContentDataSerializer();
    final PropertyTree propertyTree = new PropertyTree();
    propertyTree.setString("myData", "myValue");
    final PropertyTree data = contentDataSerializer.toUpdateNodeData(UpdateContentTranslatorParams.create().editedContent(Content.create().name("myContent").parentPath(ContentPath.ROOT).creator(PrincipalKey.ofAnonymous()).data(propertyTree).build()).modifier(PrincipalKey.ofAnonymous()).build());
    final PropertySet workflowData = data.getSet(ContentPropertyNames.WORKFLOW_INFO);
    assertEquals(WorkflowState.READY.toString(), workflowData.getString(ContentPropertyNames.WORKFLOW_INFO_STATE));
}
Also used : PropertyTree(com.enonic.xp.data.PropertyTree) PropertySet(com.enonic.xp.data.PropertySet) Test(org.junit.jupiter.api.Test)

Example 34 with PropertySet

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

the class ContentDataSerializerTest method create_propertyTree_populated_with_attachment_properties.

@Test
public void create_propertyTree_populated_with_attachment_properties() {
    final ContentDataSerializer contentDataSerializer = createContentDataSerializer();
    final String binaryName = "myName";
    final String binaryLabel = "myLabel";
    final String binaryMimeType = "myMimeType";
    final byte[] binaryData = "my binary".getBytes();
    final CreateContentTranslatorParams params = CreateContentTranslatorParams.create().parent(ContentPath.ROOT).name("myContentName").contentData(new PropertyTree()).displayName("myDisplayName").type(ContentTypeName.codeMedia()).creator(PrincipalKey.ofAnonymous()).childOrder(ChildOrder.defaultOrder()).createAttachments(CreateAttachments.from(CreateAttachment.create().byteSource(ByteSource.wrap(binaryData)).label(binaryLabel).mimeType(binaryMimeType).name(binaryName).build())).build();
    final PropertyTree data = contentDataSerializer.toCreateNodeData(params);
    final PropertySet attachmentData = data.getSet(ContentPropertyNames.ATTACHMENT);
    assertNotNull(attachmentData);
    assertEquals(binaryName, attachmentData.getString(ContentPropertyNames.ATTACHMENT_NAME));
    assertEquals(binaryLabel, attachmentData.getString(ContentPropertyNames.ATTACHMENT_LABEL));
    assertEquals(binaryMimeType, attachmentData.getString(ContentPropertyNames.ATTACHMENT_MIMETYPE));
    assertEquals(binaryData.length + "", attachmentData.getString(ContentPropertyNames.ATTACHMENT_SIZE));
    assertEquals(binaryName, attachmentData.getString(ContentPropertyNames.ATTACHMENT_BINARY_REF));
}
Also used : CreateContentTranslatorParams(com.enonic.xp.content.CreateContentTranslatorParams) PropertyTree(com.enonic.xp.data.PropertyTree) PropertySet(com.enonic.xp.data.PropertySet) Test(org.junit.jupiter.api.Test)

Example 35 with PropertySet

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

the class ContentDataSerializerTest method create_propertyTree_populated_with_extraData.

@Test
public void create_propertyTree_populated_with_extraData() {
    final ContentDataSerializer contentDataSerializer = createContentDataSerializer();
    PropertyTree mixinData = new PropertyTree();
    mixinData.setString("myKey1", "myValue1");
    mixinData.setString("myKey2", "myValue2");
    final PropertyTree data = contentDataSerializer.toCreateNodeData(CreateContentTranslatorParams.create().parent(ContentPath.ROOT).name("myContentName").contentData(new PropertyTree()).displayName("myDisplayName").type(ContentTypeName.codeMedia()).creator(PrincipalKey.ofAnonymous()).childOrder(ChildOrder.defaultOrder()).extraDatas(ExtraDatas.create().add(new ExtraData(XDataName.from(ApplicationKey.SYSTEM, "myMixin"), mixinData)).build()).build());
    final PropertySet extraData = data.getSet(ContentPropertyNames.EXTRA_DATA);
    assertNotNull(extraData);
    final PropertySet systemAppData = extraData.getSet(ApplicationKey.SYSTEM.getName());
    assertNotNull(systemAppData);
    final PropertySet myMixinData = systemAppData.getSet("myMixin");
    assertNotNull(myMixinData);
    assertEquals("myValue1", myMixinData.getString("myKey1"));
    assertEquals("myValue1", myMixinData.getString("myKey1"));
}
Also used : PropertyTree(com.enonic.xp.data.PropertyTree) PropertySet(com.enonic.xp.data.PropertySet) ExtraData(com.enonic.xp.content.ExtraData) Test(org.junit.jupiter.api.Test)

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