Search in sources :

Example 11 with Reference

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;
}
Also used : Content(com.enonic.xp.content.Content) Reference(com.enonic.xp.util.Reference) PropertyTree(com.enonic.xp.data.PropertyTree) PropertySet(com.enonic.xp.data.PropertySet)

Example 12 with Reference

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());
}
Also used : BinaryReference(com.enonic.xp.util.BinaryReference) Reference(com.enonic.xp.util.Reference) Test(org.junit.jupiter.api.Test) AbstractEqualsTest(com.enonic.xp.support.AbstractEqualsTest)

Aggregations

Reference (com.enonic.xp.util.Reference)12 PropertyTree (com.enonic.xp.data.PropertyTree)7 Test (org.junit.jupiter.api.Test)5 PropertySet (com.enonic.xp.data.PropertySet)4 Node (com.enonic.xp.node.Node)4 BinaryReference (com.enonic.xp.util.BinaryReference)3 Property (com.enonic.xp.data.Property)2 Content (com.enonic.xp.content.Content)1 ContextAccessor (com.enonic.xp.context.ContextAccessor)1 ValueTypes (com.enonic.xp.data.ValueTypes)1 DumpUpgradeStepResult (com.enonic.xp.dump.DumpUpgradeStepResult)1 PatternIndexConfigDocument (com.enonic.xp.index.PatternIndexConfigDocument)1 PublishRequestItem (com.enonic.xp.issue.PublishRequestItem)1 AttachedBinary (com.enonic.xp.node.AttachedBinary)1 BinaryAttachment (com.enonic.xp.node.BinaryAttachment)1 CreateNodeParams (com.enonic.xp.node.CreateNodeParams)1 DuplicateNodeParams (com.enonic.xp.node.DuplicateNodeParams)1 FindNodesByParentParams (com.enonic.xp.node.FindNodesByParentParams)1 FindNodesByParentResult (com.enonic.xp.node.FindNodesByParentResult)1 FindNodesByQueryResult (com.enonic.xp.node.FindNodesByQueryResult)1