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;
}
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);
}
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);
}
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");
}
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;
}
Aggregations