Search in sources :

Example 11 with PropertySet

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

the class TestDataFixtures method getProfile.

private static PropertyTree getProfile() {
    final PropertySet appPropertySet = new PropertySet();
    appPropertySet.setString("subString", "subStringValue");
    appPropertySet.setLong("subLong", 123L);
    final PropertyTree profile = new PropertyTree();
    profile.setSet("myApp", appPropertySet);
    profile.setString("string", "stringValue");
    return profile;
}
Also used : PropertyTree(com.enonic.xp.data.PropertyTree) PropertySet(com.enonic.xp.data.PropertySet)

Example 12 with PropertySet

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

the class PropertyTreeMapperTest method map_in_map.

@Test
public void map_in_map() throws Exception {
    final PropertyTree properties = new PropertyTree();
    final PropertySet mySet = properties.addSet("mySet");
    mySet.setString("mySetValue", "value");
    final PropertySet mySetInSet = mySet.addSet("mySetInSet");
    mySetInSet.setString("mySetValue", "value");
    serializeAndAssert("mapper-map-in-map", properties);
}
Also used : PropertyTree(com.enonic.xp.data.PropertyTree) PropertySet(com.enonic.xp.data.PropertySet) Test(org.junit.jupiter.api.Test)

Example 13 with PropertySet

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

the class PropertyTreeMapperTest method list_of_maps.

@Test
public void list_of_maps() throws Exception {
    final PropertyTree properties = new PropertyTree();
    final PropertySet subSet1 = new PropertySet();
    subSet1.setString("subSet1Value1", "fisk1");
    subSet1.setString("subSet2Value2", "ost1");
    final PropertySet subSet2 = new PropertySet();
    subSet2.setString("subSet2Value1", "fisk2");
    subSet2.setString("subSet2Value2", "ost2");
    properties.addSets("subSets", subSet1, subSet2);
    serializeAndAssert("mapper-list-of-maps", properties);
}
Also used : PropertyTree(com.enonic.xp.data.PropertyTree) PropertySet(com.enonic.xp.data.PropertySet) Test(org.junit.jupiter.api.Test)

Example 14 with PropertySet

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

the class CreateMediaHandlerTest method createMediaAsPDFDocument.

@Test
public void createMediaAsPDFDocument() {
    Mockito.when(this.contentService.create(Mockito.any(CreateMediaParams.class))).thenAnswer(mock -> {
        final CreateMediaParams params = (CreateMediaParams) mock.getArguments()[0];
        final PropertySet attachmentSet = new PropertySet();
        attachmentSet.addString("attachment", params.getName());
        final PropertyTree propertyTree = new PropertyTree();
        propertyTree.addSet("media", attachmentSet);
        return Media.create().id(ContentId.from("dbc077af-fb97-4b17-a567-ad69e85f1010")).name(params.getName()).parentPath(params.getParent()).type(ContentTypeName.documentMedia()).displayName(params.getName()).valid(true).creator(PrincipalKey.ofAnonymous()).data(propertyTree).attachments(Attachments.create().add(Attachment.create().name("documentName.pdf").label("source").mimeType("application/pdf").size(653453).build()).build()).createdTime(Instant.parse("1975-01-08T00:00:00Z")).build();
    });
    runFunction("/test/CreateMediaHandlerTest.js", "createMediaAsPDF");
}
Also used : CreateMediaParams(com.enonic.xp.content.CreateMediaParams) PropertyTree(com.enonic.xp.data.PropertyTree) PropertySet(com.enonic.xp.data.PropertySet) Test(org.junit.jupiter.api.Test)

Example 15 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)

Aggregations

PropertySet (com.enonic.xp.data.PropertySet)208 PropertyTree (com.enonic.xp.data.PropertyTree)134 Test (org.junit.jupiter.api.Test)68 Content (com.enonic.xp.content.Content)29 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 DescriptorKey (com.enonic.xp.page.DescriptorKey)7 ContentQuery (com.enonic.xp.content.ContentQuery)6 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