use of com.enonic.xp.util.Reference in project xp by enonic.
the class AbstractContentServiceTest method createPropertyTreeForAllInputTypes.
protected PropertyTree createPropertyTreeForAllInputTypes() {
// Creates a content and a reference to this object
final Content referredContent = this.contentService.create(CreateContentParams.create().contentData(new PropertyTree()).displayName("Referred content").parent(ContentPath.ROOT).type(ContentTypeName.folder()).build());
final Reference reference = Reference.from(referredContent.getId().toString());
// Creates a property set
PropertySet propertySet = new PropertySet();
propertySet.addString("setString", "stringValue");
propertySet.addDouble("setDouble", 1.5d);
// Creates the property tree with value assigned for each attribute
PropertyTree data = new PropertyTree();
data.addString("textLine", "textLine");
data.addDouble("double", 1.4d);
data.addLong("long", 2L);
data.addString("color", "FFFFFF");
data.addString("comboBox", "value2");
data.addBoolean("checkbox", false);
data.addString("phone", "012345678");
data.addString("tag", "tag");
data.addReference("contentSelector", reference);
data.addString("contentTypeFilter", "stringValue");
data.addString("siteConfigurator", "com.enonic.app.features");
data.addLocalDate("date", LocalDate.of(2015, 3, 13));
data.addLocalTime("time", LocalTime.NOON);
data.addGeoPoint("geoPoint", GeoPoint.from("59.9127300 ,10.7460900"));
data.addString("htmlArea", "<p>paragraph</p>");
data.addString("xml", "<elem>paragraph</elem>");
data.addLocalDateTime("localDateTime", LocalDateTime.of(2015, 3, 13, 10, 0, 0));
data.addInstant("dateTime", Instant.now());
data.addSet("set", propertySet);
return data;
}
use of com.enonic.xp.util.Reference in project xp by enonic.
the class PropertyTreeTest method setReference.
@Test
public void setReference() {
PropertyTree tree = new PropertyTree();
Reference reference1 = Reference.from("myRef1");
tree.setReference("ref1", reference1);
assertEquals(1, tree.getTotalSize());
assertEquals(reference1, tree.getReference("ref1"));
Reference reference2 = Reference.from("myRef2");
tree.setReference(PropertyPath.from("ref2"), reference2);
assertEquals(2, tree.getTotalSize());
assertEquals(reference2, tree.getReference(PropertyPath.from("ref2")));
Reference reference3 = Reference.from("myRef3");
tree.setReference("ref3", 0, reference3);
assertEquals(3, tree.getTotalSize());
assertEquals(reference3, tree.getReference("ref3", 0));
assertEquals("myRef3", tree.getReferences("ref3").iterator().next().toString());
}
Aggregations