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